From: <ma...@us...> - 2010-05-14 19:31:40
|
Revision: 5911 http://planeshift.svn.sourceforge.net/planeshift/?rev=5911&view=rev Author: magodra Date: 2010-05-14 19:31:34 +0000 (Fri, 14 May 2010) Log Message: ----------- - Fixed memory release problems in npcclient. Modified Paths: -------------- trunk/src/npcclient/gem.cpp trunk/src/npcclient/networkmgr.cpp trunk/src/npcclient/npc.cpp trunk/src/npcclient/npc.h trunk/src/npcclient/npcbehave.h trunk/src/npcclient/npcclient.cpp trunk/src/npcclient/npcoperations.cpp trunk/src/npcclient/npcoperations.h Modified: trunk/src/npcclient/gem.cpp =================================================================== --- trunk/src/npcclient/gem.cpp 2010-05-14 15:31:53 UTC (rev 5910) +++ trunk/src/npcclient/gem.cpp 2010-05-14 19:31:34 UTC (rev 5911) @@ -177,7 +177,7 @@ gemNPCActor::gemNPCActor( psNPCClient* npcclient, psPersistActor& mesg) - : gemNPCObject( npcclient, mesg.entityid ), npc(NULL) + : gemNPCObject( npcclient, mesg.entityid ), pcmove(NULL), npc(NULL) { name = mesg.name; type = mesg.type; @@ -206,6 +206,11 @@ npc->SetActor(NULL); npc = NULL; } + if (pcmove) + { + delete pcmove; + pcmove = NULL; + } } void gemNPCActor::AttachNPC(NPC * newNPC) Modified: trunk/src/npcclient/networkmgr.cpp =================================================================== --- trunk/src/npcclient/networkmgr.cpp 2010-05-14 15:31:53 UTC (rev 5910) +++ trunk/src/npcclient/networkmgr.cpp 2010-05-14 19:31:34 UTC (rev 5911) @@ -101,6 +101,9 @@ msghandler->Unsubscribe(this,MSGTYPE_NPC_COMMAND); msghandler->Unsubscribe(this,MSGTYPE_NPCRACELIST); } + + delete outbound; + outbound = NULL; } void NetworkManager::Authenticate(csString& host,int port,csString& user,csString& pass) Modified: trunk/src/npcclient/npc.cpp =================================================================== --- trunk/src/npcclient/npc.cpp 2010-05-14 15:31:53 UTC (rev 5910) +++ trunk/src/npcclient/npc.cpp 2010-05-14 19:31:34 UTC (rev 5911) @@ -105,7 +105,20 @@ if (brain) { delete brain; + brain = NULL; } + + if (last_perception) + { + delete last_perception; + last_perception = NULL; + } + + // Cleare some cached values + region = NULL; + active_locate_sector = NULL; + active_locate_wp = NULL; + raceInfo = NULL; } void NPC::Tick() Modified: trunk/src/npcclient/npc.h =================================================================== --- trunk/src/npcclient/npc.h 2010-05-14 15:31:53 UTC (rev 5910) +++ trunk/src/npcclient/npc.h 2010-05-14 19:31:34 UTC (rev 5911) @@ -50,6 +50,7 @@ struct RaceInfo_t; class LocationType; class psNPCTick; +class psLinearMovement; #define NPC_BRAIN_TICK 200 Modified: trunk/src/npcclient/npcbehave.h =================================================================== --- trunk/src/npcclient/npcbehave.h 2010-05-14 15:31:53 UTC (rev 5910) +++ trunk/src/npcclient/npcbehave.h 2010-05-14 19:31:34 UTC (rev 5911) @@ -44,6 +44,7 @@ //============================================================================= #include "perceptions.h" #include "walkpoly.h" +#include "npcoperations.h" class ScriptOperation; class Perception; @@ -171,16 +172,16 @@ }; protected: - csString name; ///< The name of this NPC type. - csArray<Reaction*> reactions; ///< The reactions available for this NPCType. - BehaviorSet behaviors; ///< The set of behaviors available for this NPCType. - float ang_vel; ///< Default ang_vel for this NPCType. - ///< Will be used for all behaviors unless overriden - ///< by each behavior. - float vel; ///< Default vel for this NPCType. - ///< Will be used for all behaviors unless overriden - ///< by each behavior. - VelSource velSource; ///< + csString name; ///< The name of this NPC type. + csPDelArray<Reaction> reactions; ///< The reactions available for this NPCType. + BehaviorSet behaviors; ///< The set of behaviors available for this NPCType. + float ang_vel; ///< Default ang_vel for this NPCType. + ///< Will be used for all behaviors unless overriden + ///< by each behavior. + float vel; ///< Default vel for this NPCType. + ///< Will be used for all behaviors unless overriden + ///< by each behavior. + VelSource velSource; ///< public: NPCType(psNPCClient* npcclient, EventManager* eventmanager); @@ -227,7 +228,7 @@ protected: csString name; ///< The name of this behavior - csArray<ScriptOperation*> sequence; ///< Sequence of ScriptOperations. + csPDelArray<ScriptOperation> sequence; ///< Sequence of ScriptOperations. size_t current_step; ///< The ScriptOperation in the sequence that is currently executed. bool loop; ///< True if this behavior should start over when completed all operations. bool isActive; ///< Set to true when this behavior is active Modified: trunk/src/npcclient/npcclient.cpp =================================================================== --- trunk/src/npcclient/npcclient.cpp 2010-05-14 15:31:53 UTC (rev 5910) +++ trunk/src/npcclient/npcclient.cpp 2010-05-14 19:31:34 UTC (rev 5911) @@ -91,6 +91,8 @@ psNPCClient::psNPCClient () : serverconsole(NULL) { world = NULL; + PFMaps = NULL; + pathNetwork = NULL; eventmanager = NULL; running = true; database = NULL; @@ -102,14 +104,35 @@ psNPCClient::~psNPCClient() { + + + + csArray<NPC*>::Iterator npcIter(npcs.GetIterator()); + while (npcIter.HasNext()) + delete npcIter.Next(); + npcs.Empty(); + + + csHash<NPCType*, const char*>::GlobalIterator npcTypeIter(npctypes.GetIterator()); + while (npcTypeIter.HasNext()) + delete npcTypeIter.Next(); + npctypes.Empty(); + + csHash<LocationType*, csString>::GlobalIterator iter(loctypes.GetIterator()); while(iter.HasNext()) delete iter.Next(); + loctypes.Empty(); running = false; delete network; delete serverconsole; delete database; + + + delete pathNetwork; + delete PFMaps; + delete world; } bool psNPCClient::Initialize(iObjectRegistry* object_reg,const char *_host, const char *_user, const char *_pass, int _port) Modified: trunk/src/npcclient/npcoperations.cpp =================================================================== --- trunk/src/npcclient/npcoperations.cpp 2010-05-14 15:31:53 UTC (rev 5910) +++ trunk/src/npcclient/npcoperations.cpp 2010-05-14 19:31:34 UTC (rev 5911) @@ -3334,6 +3334,15 @@ //--------------------------------------------------------------------------- +WanderOperation::~WanderOperation() +{ + if (anchor) + { + delete anchor; + anchor = NULL; + } +} + void WanderOperation::CalculateTargetPos(csVector3& dest, iSector*§or) { dest = active_wp->loc.pos; Modified: trunk/src/npcclient/npcoperations.h =================================================================== --- trunk/src/npcclient/npcoperations.h 2010-05-14 15:31:53 UTC (rev 5910) +++ trunk/src/npcclient/npcoperations.h 2010-05-14 19:31:34 UTC (rev 5911) @@ -989,7 +989,7 @@ turn_queued=false; turn_angle_vel=0.0f; turn_end_angle=0.0f; path=NULL, anchor=NULL; }; - virtual ~WanderOperation() {}; + virtual ~WanderOperation(); bool CalculateWaypointList(NPC *npc); virtual bool Run(NPC *npc,EventManager *eventmgr,bool interrupted); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |