From: <ma...@us...> - 2011-02-09 21:09:46
|
Revision: 6904 http://planeshift.svn.sourceforge.net/planeshift/?rev=6904&view=rev Author: magodra Date: 2011-02-09 21:09:40 +0000 (Wed, 09 Feb 2011) Log Message: ----------- - Updated WanderOperation to new clone pattern. Modified Paths: -------------- trunk/src/npcclient/npcoperations.cpp trunk/src/npcclient/npcoperations.h Modified: trunk/src/npcclient/npcoperations.cpp =================================================================== --- trunk/src/npcclient/npcoperations.cpp 2011-02-09 20:45:08 UTC (rev 6903) +++ trunk/src/npcclient/npcoperations.cpp 2011-02-09 21:09:40 UTC (rev 6904) @@ -3524,6 +3524,59 @@ //--------------------------------------------------------------------------- +WanderOperation::WanderOperation() + : ScriptOperation("Wander"), + // Instance states + // Instance states + wanderRouteFilter(this), + active_wp(NULL), + prior_wp(NULL), + next_wp(NULL), + dest_sector(NULL), + current_sector(NULL), + turn_queued(false), + turn_angle_vel(0.0f), + turn_end_angle(0.0f), + path(NULL), + anchor(NULL) + // Operation parameters + // Initialized in the load function +{ +} + +WanderOperation::WanderOperation(const WanderOperation* other) + : ScriptOperation(other), + // Instance states + wanderRouteFilter(this), + active_wp(NULL), + prior_wp(NULL), + next_wp(NULL), + dest_sector(NULL), + current_sector(NULL), + turn_queued(false), + turn_angle_vel(0.0f), + turn_end_angle(0.0f), + path(NULL), + anchor(NULL), + // Operation parameters + action(other->action), + random(other->random), + undergroundValid(other->undergroundValid), + underground(other->underground), + underwaterValid(other->underwaterValid), + underwater(other->underwater), + privValid(other->privValid), + priv(other->priv), + pubValid(other->pubValid), + pub(other->pub), + cityValid(other->cityValid), + city(other->city), + indoorValid(other->indoorValid), + indoor(other->indoor) +{ +} + + WanderOperation::~WanderOperation() { if (anchor) @@ -4006,27 +4059,7 @@ ScriptOperation *WanderOperation::MakeCopy() { - WanderOperation *op = new WanderOperation; - op->action = action; - op->velSource = velSource; - op->vel = vel; - op->random = random; - op->undergroundValid = undergroundValid; - op->underground = underground; - op->underwaterValid = underwaterValid; - op->underwater = underwater; - op->privValid = privValid; - op->priv = priv; - op->pubValid = pubValid; - op->pub = pub; - op->cityValid = cityValid; - op->city = city; - op->indoorValid = indoorValid; - op->indoor = indoor; - - // Internal variables set to defaults - path = NULL; - anchor = NULL; + WanderOperation *op = new WanderOperation(this); return op; } Modified: trunk/src/npcclient/npcoperations.h =================================================================== --- trunk/src/npcclient/npcoperations.h 2011-02-09 20:45:08 UTC (rev 6903) +++ trunk/src/npcclient/npcoperations.h 2011-02-09 21:09:40 UTC (rev 6904) @@ -83,7 +83,6 @@ // Start of instance temp variables. These dosn't need to be copied. csString name; - bool completed; /// This flag is set to false by Run(), and set to true by CompleteOperation(), in case of multiple Complete's being called. psResumeScriptEvent *resumeScriptEvent; @@ -1055,16 +1054,20 @@ class WanderOperation : public ScriptOperation { protected: - csString action; - bool random; - bool undergroundValid,underground; - bool underwaterValid,underwater; - bool privValid,priv; - bool pubValid,pub; - bool cityValid,city; - bool indoorValid,indoor; + //////////////////////////////////////////////////////////// + // Start of instance temp variables. These dosn't need to be copied. - // Instance temp variables. These dosn't need to be copied. + class WanderRouteFilter : public psPathNetwork::RouteFilter + { + public: + WanderRouteFilter( WanderOperation * parent ):parent(parent){}; + virtual bool Filter( const Waypoint* waypoint ) const; + protected: + WanderOperation * parent; + }; + + WanderRouteFilter wanderRouteFilter; + Waypoint *active_wp,*prior_wp,*next_wp; csVector3 dest,current_pos; iSector *dest_sector,*current_sector; @@ -1078,19 +1081,23 @@ psPath *path; psPathAnchor *anchor; + // End of instance temp variables. + //////////////////////////////////////////////////////////// - class WanderRouteFilter : public psPathNetwork::RouteFilter - { - public: - WanderRouteFilter( WanderOperation * parent ):parent(parent){}; - virtual bool Filter( const Waypoint* waypoint ) const; - protected: - WanderOperation * parent; - }; + //////////////////////////////////////////////////////////// + // Start of operation parameters + csString action; + bool random; + bool undergroundValid,underground; + bool underwaterValid,underwater; + bool privValid,priv; + bool pubValid,pub; + bool cityValid,city; + bool indoorValid,indoor; + // End of operation parameters + //////////////////////////////////////////////////////////// - WanderRouteFilter wanderRouteFilter; - /** Calculate a random position within the waypoint as destination */ void CalculateTargetPos(csVector3& dest, iSector*§or); @@ -1104,12 +1111,8 @@ public: - WanderOperation(): ScriptOperation("Wander"), wanderRouteFilter(this) - { active_wp=NULL; prior_wp=NULL; next_wp=NULL; - dest_sector=NULL; current_sector=NULL; - turn_queued=false; - turn_angle_vel=0.0f; turn_end_angle=0.0f; path=NULL, anchor=NULL; - }; + WanderOperation(); + WanderOperation(const WanderOperation* other); virtual ~WanderOperation(); bool CalculateWaypointList(NPC *npc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |