From: Keith F. <ven...@us...> - 2003-11-05 08:30:11
|
Update of /cvsroot/planeshift/planeshift/src/npcclient In directory sc8-pr-cvs1:/tmp/cvs-serv28690 Modified Files: npcclient.cpp npcbehave.h npcbehave.cpp npc.h networkmgr.cpp Log Message: Fixed respawn of npcs to superclient and fixed npc brain reset on death, so that they start fresh when respawned. Index: npcclient.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/npcclient.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** npcclient.cpp 4 Nov 2003 06:05:45 -0000 1.22 --- npcclient.cpp 5 Nov 2003 08:30:07 -0000 1.23 *************** *** 330,339 **** AttachNPC(npc_ent,npcs[j]); ! return true; } } return false; } return false; } --- 330,342 ---- AttachNPC(npc_ent,npcs[j]); ! npcs[j]->SetAlive(true); ! printf("Attached entity %u to NPC %u.\n",entity,player); return true; } } + printf("Found entity %u but not NPC %u.\n",entity,player); return false; } + printf("Could not find entity %u for NPC %u.\n",entity,player); return false; } Index: npcbehave.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/npcbehave.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** npcbehave.h 4 Nov 2003 06:05:45 -0000 1.23 --- npcbehave.h 5 Nov 2003 08:30:08 -0000 1.24 *************** *** 188,192 **** bool GetActive() { return is_active; } ! void ResetNeed() { current_need = init_need; } void StartScript(NPC *npc,EventManager *eventmgr); --- 188,192 ---- bool GetActive() { return is_active; } ! void ResetNeed() { current_need = new_need = init_need; } void StartScript(NPC *npc,EventManager *eventmgr); *************** *** 197,201 **** bool operator==(Behavior& other) { return (current_need == other.current_need && ! name == other.name ); } bool operator<(Behavior& other) { --- 197,201 ---- bool operator==(Behavior& other) { return (current_need == other.current_need && ! name == other.name ); } bool operator<(Behavior& other) { Index: npcbehave.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/npcbehave.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** npcbehave.cpp 4 Nov 2003 06:05:45 -0000 1.30 --- npcbehave.cpp 5 Nov 2003 08:30:08 -0000 1.31 *************** *** 176,184 **** { BinaryTreeIterator<Behavior> iter(&behaviors); ! Behavior *b; ! for (b = iter.First(); b; b = ++iter) { b->ResetNeed(); } } --- 176,195 ---- { BinaryTreeIterator<Behavior> iter(&behaviors); ! Behavior *b,*next; ! for (b = iter.First(); b; b = (next) ? next : ++iter) { + next = ++iter; // save next position to restore next time through loop + + behaviors.Delete(b); b->ResetNeed(); + b->SetActive(false); + behaviors.Add(b); + + if (next) + iter.Find(next); // Find rebuilds the iterator, so it doesn't matter if tree structure has changed + else + break; } + active = NULL; } Index: npc.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/npc.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** npc.h 4 Nov 2003 06:05:45 -0000 1.17 --- npc.h 5 Nov 2003 08:30:08 -0000 1.18 *************** *** 76,80 **** public: ! NPC() { alive=true; is_debugging=false; last_perception=NULL; region=NULL; last_update=0; brain=NULL; entity=NULL; id=0; ang_vel=vel=999; } ~NPC() { if (brain) delete brain; } --- 76,80 ---- public: ! NPC() { alive=false; is_debugging=false; last_perception=NULL; region=NULL; last_update=0; brain=NULL; entity=NULL; id=0; ang_vel=vel=999; } ~NPC() { if (brain) delete brain; } Index: networkmgr.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/networkmgr.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** networkmgr.cpp 4 Nov 2003 21:15:00 -0000 1.25 --- networkmgr.cpp 5 Nov 2003 08:30:08 -0000 1.26 *************** *** 244,251 **** } ! if (!npcclient->FindActor(entity)) ! npcclient->AddActor(entity); ! else ! Warning2(LOG_CELPERSIST,"Received double copy of %s!\n",entity->GetName() ); } else --- 244,248 ---- } ! npcclient->AddActor(entity); } else *************** *** 260,264 **** Debug3(LOG_CELPERSIST,"Mapping Entity %d to player id %d.\n",entity->GetID(), pmsg.id); ! npcclient->AttachNPCtoEntity( pmsg.id,entity->GetID() ); vfs->ChDir(pwd); --- 257,261 ---- Debug3(LOG_CELPERSIST,"Mapping Entity %d to player id %d.\n",entity->GetID(), pmsg.id); ! npcclient->AttachNPCtoEntity( pmsg.id,netpersist->GetMappedID(entity) ); vfs->ChDir(pwd); |