Skip to content

Commit 36dcf78

Browse files
committed
继续完善aoi
1 parent 76856b3 commit 36dcf78

11 files changed

Lines changed: 89 additions & 22 deletions

File tree

‎kbe/bin/client/kbengine.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<use_logfile>false</use_logfile>
2424
<disables>
2525
<item>Baseappmgr::updateBaseapp</item>
26+
<item>Client::onUpdateVolatileData</item>
2627
</disables>
2728
</trace_packet>
2829

‎kbe/res/server/kbengine_defs.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<use_logfile>false</use_logfile>
2525
<disables>
2626
<item>Baseappmgr::updateBaseapp</item>
27+
<item>Client::onUpdateVolatileData</item>
2728
</disables>
2829
</trace_packet>
2930

@@ -241,7 +242,7 @@
241242
tickcount: 每次添加数量
242243
-->
243244
<defaultAddBots>
244-
<totalcount> 50 </totalcount> <!-- Type: Integer -->
245+
<totalcount> 3 </totalcount> <!-- Type: Integer -->
245246
<ticktime> 0.1 </ticktime> <!-- Type: Float -->
246247
<tickcount> 2 </tickcount> <!-- Type: Integer -->
247248
</defaultAddBots>

‎kbe/src/lib/client_lib/clientobjectbase.cpp‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,17 @@ client::Entity* ClientObjectBase::createEntityCommon(const char* entityType, PyO
143143
ScriptDefModule* sm = EntityDef::findScriptModule(entityType);
144144
if(sm == NULL)
145145
{
146-
PyErr_Format(PyExc_TypeError, "ClientObjectBase::createEntityCommon: entity [%s] not found.\n", entityType);
146+
PyErr_Format(PyExc_TypeError, "ClientObjectBase::createEntityCommon: entity [%s] not found.\n",
147+
entityType);
148+
147149
PyErr_PrintEx(0);
148150
return NULL;
149151
}
150152
else if(!sm->hasClient())
151153
{
152-
PyErr_Format(PyExc_TypeError, "ClientObjectBase::createEntityCommon: entity [%s] not found.\n", entityType);
154+
PyErr_Format(PyExc_TypeError, "ClientObjectBase::createEntityCommon: entity [%s] not found.\n",
155+
entityType);
156+
153157
PyErr_PrintEx(0);
154158
return NULL;
155159
}
@@ -174,11 +178,13 @@ client::Entity* ClientObjectBase::createEntityCommon(const char* entityType, PyO
174178

175179
if(g_debugEntity)
176180
{
177-
INFO_MSG(boost::format("ClientObjectBase::createEntityCommon: new %1% (%2%) refc=%3%.\n") % entityType % eid % obj->ob_refcnt);
181+
INFO_MSG(boost::format("ClientObjectBase::createEntityCommon: new %1% (%2%) refc=%3%.\n") %
182+
entityType % eid % obj->ob_refcnt);
178183
}
179184
else
180185
{
181-
INFO_MSG(boost::format("ClientObjectBase::createEntityCommon: new %1% (%2%)\n") % entityType % eid);
186+
INFO_MSG(boost::format("ClientObjectBase::createEntityCommon: new %1% (%2%)\n") %
187+
entityType % eid);
182188
}
183189

184190
EventData_CreatedEntity eventdata;
@@ -453,7 +459,8 @@ void ClientObjectBase::onEntityEnterWorld(Mercury::Channel * pChannel, ENTITY_ID
453459
}
454460
}
455461

456-
DEBUG_MSG(boost::format("ClientObjectBase::onEntityEnterWorld: %1%.\n") % eid);
462+
DEBUG_MSG(boost::format("ClientObjectBase::onEntityEnterWorld: %1%(%2%).\n") %
463+
entity->getScriptName() % eid);
457464

458465
EventData_EnterWorld eventdata;
459466
eventdata.spaceID = spaceID;
@@ -480,7 +487,9 @@ void ClientObjectBase::onEntityLeaveWorld(Mercury::Channel * pChannel, ENTITY_ID
480487
return;
481488
}
482489

483-
DEBUG_MSG(boost::format("ClientObjectBase::onEntityLeaveWorld: %1%.\n") % eid);
490+
DEBUG_MSG(boost::format("ClientObjectBase::onEntityLeaveWorld: %1%(%2%).\n") %
491+
entity->getScriptName() % eid);
492+
484493
entity->onLeaveWorld();
485494

486495
EventData_LeaveWorld eventdata;
@@ -502,7 +511,8 @@ void ClientObjectBase::onEntityEnterSpace(Mercury::Channel * pChannel, SPACE_ID
502511
return;
503512
}
504513

505-
DEBUG_MSG(boost::format("ClientObjectBase::onEntityEnterSpace: %1%.\n") % eid);
514+
DEBUG_MSG(boost::format("ClientObjectBase::onEntityEnterSpace: %1%(%2%).\n") %
515+
entity->getScriptName() % eid);
506516

507517
EventData_EnterSpace eventdata;
508518
eventdata.spaceID = spaceID;
@@ -521,7 +531,8 @@ void ClientObjectBase::onEntityLeaveSpace(Mercury::Channel * pChannel, SPACE_ID
521531
return;
522532
}
523533

524-
DEBUG_MSG(boost::format("ClientObjectBase::onEntityLeaveSpace: %1%.\n") % eid);
534+
DEBUG_MSG(boost::format("ClientObjectBase::onEntityLeaveSpace: %1%(%2%).\n") %
535+
entity->getScriptName() % eid);
525536

526537
EventData_LeaveSpace eventdata;
527538
eventdata.spaceID = spaceID;
@@ -539,7 +550,9 @@ void ClientObjectBase::onEntityDestroyed(Mercury::Channel * pChannel, ENTITY_ID
539550
return;
540551
}
541552

542-
DEBUG_MSG(boost::format("ClientObjectBase::onEntityDestroyed: %1%.\n") % eid);
553+
DEBUG_MSG(boost::format("ClientObjectBase::onEntityDestroyed: %1%(%2%).\n") %
554+
entity->getScriptName() % eid);
555+
543556
pEntities_->erase(eid);
544557
}
545558

‎kbe/src/server/cellapp/entity_range_node.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ EntityRangeNode::~EntityRangeNode()
4040
//-------------------------------------------------------------------------------------
4141
float EntityRangeNode::x()const
4242
{
43+
if((flags() & RANGENODE_FLAG_REMOVE) > 0)
44+
return -FLT_MAX;
45+
4346
return pEntity_->getPosition().x;
4447
}
4548

‎kbe/src/server/cellapp/entityref.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,26 @@ EntityRef::EntityRef(Entity* pEntity):
2727
pEntity_(pEntity),
2828
flags_(ENTITYREF_FLAG_UNKONWN)
2929
{
30+
id_ = pEntity->getID();
3031
}
3132

3233
//-------------------------------------------------------------------------------------
3334
EntityRef::~EntityRef()
3435
{
3536
}
3637

38+
//-------------------------------------------------------------------------------------
39+
void EntityRef::pEntity(Entity* e)
40+
{
41+
pEntity_ = e;
42+
id_ = e->getID();
43+
}
44+
45+
//-------------------------------------------------------------------------------------
46+
bool findif_vector_entityref_exist_handler::operator()(const EntityRef* obj)
47+
{
48+
return obj->id() == obj_->getID();
49+
}
50+
3751
//-------------------------------------------------------------------------------------
3852
}

‎kbe/src/server/cellapp/entityref.hpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ class EntityRef
4343
uint32 flags(){ return flags_; }
4444

4545
Entity* pEntity()const { return pEntity_; }
46+
void pEntity(Entity* e);
47+
48+
ENTITY_ID id()const{ return id_; }
4649
private:
50+
ENTITY_ID id_;
4751
Entity* pEntity_;
4852
uint32 flags_;
4953
};
@@ -55,10 +59,7 @@ class findif_vector_entityref_exist_handler
5559
findif_vector_entityref_exist_handler(Entity* obj)
5660
: obj_(obj) {}
5761

58-
bool operator()(const EntityRef* obj)
59-
{
60-
return obj->pEntity() == obj_;
61-
}
62+
bool operator()(const EntityRef* obj);
6263
private:
6364
Entity* obj_;
6465
};

‎kbe/src/server/cellapp/range_list.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ bool RangeList::insert(RangeNode* pNode)
8282
//-------------------------------------------------------------------------------------
8383
bool RangeList::remove(RangeNode* pNode)
8484
{
85+
pNode->flags(pNode->flags() | RANGENODE_FLAG_REMOVE);
86+
pNode->onRemove();
87+
update(pNode);
88+
8589
// 如果是第一个节点
8690
if(first_x_rangeNode_ == pNode)
8791
{

‎kbe/src/server/cellapp/range_node.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@ void RangeNode::onNodePassZ(RangeNode* pNode, bool isfront)
7272
{
7373
}
7474

75+
//-------------------------------------------------------------------------------------
76+
void RangeNode::onRemove()
77+
{
78+
x_ = -FLT_MAX;
79+
}
80+
7581
//-------------------------------------------------------------------------------------
7682
}

‎kbe/src/server/cellapp/range_node.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace KBEngine{
3030
#define RANGENODE_FLAG_ENTITY 0x00000001 // 一个entity节点
3131
#define RANGENODE_FLAG_TRIGGER 0x00000002 // 一个触发器节点
3232
#define RANGENODE_FLAG_HIDE 0x00000004 // 隐藏节点(其他节点不可见)
33+
#define RANGENODE_FLAG_REMOVE 0x00000008 // 删除节点
3334

3435
class RangeList;
3536
class RangeNode
@@ -97,6 +98,8 @@ class RangeNode
9798
virtual void onNodePassY(RangeNode* pNode, bool isfront);
9899
virtual void onNodePassZ(RangeNode* pNode, bool isfront);
99100

101+
virtual void onRemove();
102+
100103
/**
101104
当节点有变动时,需要更新它在list中的
102105
相关位置等信息

‎kbe/src/server/cellapp/range_trigger.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ RangeTriggerNode::~RangeTriggerNode()
4242

4343
//-------------------------------------------------------------------------------------
4444
float RangeTriggerNode::x()const
45-
{
45+
{
4646
return pRangeTrigger_->origin()->x() + range_xz_;
4747
}
4848

4949
//-------------------------------------------------------------------------------------
5050
float RangeTriggerNode::y()const
51-
{
51+
{
5252
return pRangeTrigger_->origin()->y() + range_y_;
5353
}
5454

5555
//-------------------------------------------------------------------------------------
5656
float RangeTriggerNode::z()const
57-
{
57+
{
5858
return pRangeTrigger_->origin()->z() + range_xz_;
5959
}
6060

0 commit comments

Comments
 (0)