From: Anders R. <ma...@us...> - 2006-07-26 23:51:07
|
Update of /cvsroot/planeshift/planeshift/src/common/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3828/src/common/util Modified Files: location.cpp location.h Log Message: - Added flag to distribution of items to super clients to allow to check for no pickup. This to allow item perception not to be trigged of things that can't be picked up. - Added a CloneNPC function to the EntityManager to be used when super client clone tribe members. - Rewrote the reproduce NPC client perseption that wasn't used to call the CloneNPC function instead of updating a dynamic spawn possition. Spawn position will be taken from the npc that clone plus a small random delta. - Added attaching of NPC's to behaviours based on a name match to. This to allow new cloned NPC's to get a behaviour. They will have the name of their parent and will therefor match an existing entity in the super client. - Added Attaching of NPC's based on name match with npc's in a tribe to include new cloned NPC's in the tribe. - Rewrote the Advance tribe function to more indicate how a brain could be inserted. For now the brain is just random. - Added reproduction perception from the brain with a hard coded limit on tribe size. The limit check will be changed later. Index: location.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/location.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** location.cpp 29 Aug 2005 14:54:38 -0000 1.9 --- location.cpp 26 Jul 2006 21:04:03 -0000 1.10 *************** *** 25,31 **** --- 25,45 ---- #include <iutil/document.h> #include <csutil/xmltiny.h> + #include <iengine/engine.h> #include "location.h" #include "util/consoleout.h" + #include "util/log.h" + + + /*------------------------------------------------------------------*/ + + iSector* Location::GetSector(iEngine * engine) + { + if (sector) return sector; + + sector = engine->FindSector(sectorName.GetDataSafe()); + return sector; + } + *************** *** 101,105 **** } ! bool Waypoint::Load(iDocumentNode *node) { name = node->GetAttributeValue("name"); --- 115,119 ---- } ! bool Waypoint::Load(iDocumentNode *node, iEngine * engine) { name = node->GetAttributeValue("name"); *************** *** 107,110 **** --- 121,126 ---- loc.pos.y = node->GetAttributeValueAsFloat("y"); loc.pos.z = node->GetAttributeValueAsFloat("z"); + loc.sectorName = node->GetAttributeValue("sector"); + loc.sector = engine->FindSector(loc.sectorName); loc.rot_angle = node->GetAttributeValueAsFloat("radius"); // kinda hacky, but reusing this parm for radius allow_return = node->GetAttributeValueAsBool("allow_return",false); // by default don't allow return to previous point Index: location.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/location.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** location.h 8 Sep 2005 16:27:06 -0000 1.8 --- location.h 26 Jul 2006 21:04:03 -0000 1.9 *************** *** 22,29 **** #include <csutil/csstring.h> #include <csgeom/vector3.h> - #include "util/prb.h" - #include "util/growarray.h" #include <csutil/parray.h> #include <iengine/sector.h> /** --- 22,31 ---- #include <csutil/csstring.h> #include <csgeom/vector3.h> #include <csutil/parray.h> #include <iengine/sector.h> + #include <csutil/weakref.h> + + #include "util/prb.h" + #include "util/growarray.h" /** *************** *** 34,40 **** { public: ! csVector3 pos; ! float rot_angle; ! iSector* sector; }; --- 36,45 ---- { public: ! csVector3 pos; ! float rot_angle; ! csWeakRef<iSector> sector; // Cached sector ! csString sectorName; ! /// Return cached sector or find the sector and cache it from engine. ! iSector* GetSector(iEngine * engine); }; *************** *** 79,83 **** { return (strcmp(name,other.name)<0); } ! bool Load(iDocumentNode *node); }; --- 84,91 ---- { return (strcmp(name,other.name)<0); } ! bool Load(iDocumentNode *node, iEngine *engine); ! ! /// Get the sector from the location. ! iSector* GetSector(iEngine * engine) { return loc.GetSector(engine); } }; |