From: Anders R. <ma...@us...> - 2003-12-29 18:20:10
|
Update of /cvsroot/planeshift/planeshift/src/npcclient In directory sc8-pr-cvs1:/tmp/cvs-serv11614/src/npcclient Modified Files: gem.h networkmgr.cpp networkmgr.h npcclient.cpp perceptions.cpp Log Message: - Changed command name list to entlist on server to match name in psnpcclient. - Updated entlist command in npcclient and server to create matching output. - Implemented the disconnect message in the npcclient to detect situations where server reject npcclient when connecting. Index: gem.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/gem.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gem.h 14 Dec 2003 23:08:04 -0000 1.1 --- gem.h 29 Dec 2003 18:19:59 -0000 1.2 *************** *** 44,47 **** --- 44,50 ---- const char* GetName() { return name; } virtual int GetPlayerID() { return 0; } + + virtual const char* GetObjectType(){ return "Object"; } + protected: static psNPCClient *cel; *************** *** 65,68 **** --- 68,73 ---- int GetPlayerID() { return playerID; } + + virtual const char* GetObjectType(){ return "Actor"; } protected: *************** *** 80,83 **** --- 85,91 ---- public: gemNPCItem( psNPCClient* cel, MsgEntry* me ); + virtual ~gemNPCItem(){} + + virtual const char* GetObjectType(){ return "Item"; } protected: Index: networkmgr.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/networkmgr.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** networkmgr.cpp 14 Dec 2003 23:08:04 -0000 1.27 --- networkmgr.cpp 29 Dec 2003 18:19:59 -0000 1.28 *************** *** 34,37 **** --- 34,38 ---- #include "npc.h" #include "gem.h" + #include "util/serverconsole.h" SCF_IMPLEMENT_IBASE( NetworkManager ) *************** *** 50,55 **** msghandler->Subscribe(this,MSGTYPEALLENTITYPOS); msghandler->Subscribe(this,MSGTYPENPCOMMANDLIST); ! msghandler->Subscribe( this, MSG_PERSIST_ACTOR ); ! msghandler->Subscribe( this, MSG_PERSIST_ITEM ); netpersist = new psNetPersist; --- 51,57 ---- msghandler->Subscribe(this,MSGTYPEALLENTITYPOS); msghandler->Subscribe(this,MSGTYPENPCOMMANDLIST); ! msghandler->Subscribe(this,MSG_PERSIST_ACTOR); ! msghandler->Subscribe(this,MSG_PERSIST_ITEM); ! msghandler->Subscribe(this,MSGTYPEDISCONNECT); netpersist = new psNetPersist; *************** *** 68,71 **** --- 70,76 ---- msghandler->Unsubscribe(this,MSGTYPEALLENTITYPOS); msghandler->Unsubscribe(this,MSGTYPENPCOMMANDLIST); + msghandler->Unsubscribe(this,MSG_PERSIST_ACTOR); + msghandler->Unsubscribe(this,MSG_PERSIST_ITEM); + msghandler->Unsubscribe(this,MSGTYPEDISCONNECT); } } *************** *** 122,125 **** --- 127,135 ---- break; } + case MSGTYPEDISCONNECT: + { + HandleDisconnect(me); + break; + } } } *************** *** 281,284 **** --- 291,302 ---- } } + + void NetworkManager::HandleDisconnect(MsgEntry *msg) + { + psDisconnectMessage disconnect(msg); + printf("Disconnected: %s\n",disconnect.msgReason.GetData()); + ServerConsole::Stop(); + } + Index: networkmgr.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/networkmgr.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** networkmgr.h 14 Dec 2003 23:08:04 -0000 1.17 --- networkmgr.h 29 Dec 2003 18:19:59 -0000 1.18 *************** *** 47,50 **** --- 47,51 ---- void HandlePersistMessage(MsgEntry *msg); void HandlePerceptions(MsgEntry *msg); + void HandleDisconnect(MsgEntry *msg); void RemoveEntity(psCelPersistMessage& pmsg); Index: npcclient.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/npcclient.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** npcclient.cpp 23 Dec 2003 16:58:14 -0000 1.26 --- npcclient.cpp 29 Dec 2003 18:19:59 -0000 1.27 *************** *** 360,371 **** { iCelEntity *ent = FindEntity(id); - iCelEntity *npc = (iCelEntity *)npc_entities.Get( ent->GetID() ); - if (npc) - { - // printf("Update npc %s skipped.\n",npc->GetName() ); - return; - } if (ent) { psGameObject::SetPosition(ent,pos); // printf("Setting entity '%s' to (%1.2f,%1.2f,%1.2f)...\n",ent->GetName(),pos.x,pos.y,pos.z); --- 360,373 ---- { iCelEntity *ent = FindEntity(id); if (ent) { + iCelEntity *npc = (iCelEntity *)npc_entities.Get( ent->GetID() ); + if (npc) + { + // Skipp updating NPC + // printf("Update npc %s skipped.\n",npc->GetName() ); + return; + } + psGameObject::SetPosition(ent,pos); // printf("Setting entity '%s' to (%1.2f,%1.2f,%1.2f)...\n",ent->GetName(),pos.x,pos.y,pos.z); *************** *** 581,598 **** void psNPCClient::ListAllEntities() { ! /* ! for (int i=0; i < GetActorCount(); i++) { ! iCelEntity *ent = GetActor(i); csVector3 pos; float rot; iSector *sector; psGameObject::GetPosition(ent,pos,rot,sector); ! printf("%d\t%-20s %3.0f %3.0f %3.0f\n", ent->GetID(), ! ent->GetName(), ! pos.x,pos.y,pos.z); } ! */ } --- 583,604 ---- void psNPCClient::ListAllEntities() { ! for (int i=0; i < objects.Length(); i++) { ! gemNPCObject * obj = objects[i]; ! iCelEntity *ent = obj->GetEntity(); csVector3 pos; float rot; iSector *sector; psGameObject::GetPosition(ent,pos,rot,sector); ! const char *sector_name = ! (sector) ? sector->QueryObject()->GetName():"(null)"; ! ! printf("%5d %-10s %-20s (%9.3f,%9.3f,%9.3f, %s)\n", ent->GetID(), ! obj->GetObjectType(), ! obj->GetName(), ! pos.x,pos.y,pos.z,sector_name); } ! } Index: perceptions.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/perceptions.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** perceptions.cpp 11 Nov 2003 06:59:34 -0000 1.9 --- perceptions.cpp 29 Dec 2003 18:19:59 -0000 1.10 *************** *** 111,115 **** // zero delta means guarantee that this affected // need becomes the highest (and thus active) one. ! int highest = who->GetCurrentBehavior()->CurrentNeed(); affected->ApplyNeedDelta( highest - affected->CurrentNeed() + 25); } --- 111,115 ---- // zero delta means guarantee that this affected // need becomes the highest (and thus active) one. ! float highest = who->GetCurrentBehavior()->CurrentNeed(); affected->ApplyNeedDelta( highest - affected->CurrentNeed() + 25); } |