From: <phi...@us...> - 2007-06-21 16:51:07
|
Revision: 7306 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=7306&view=rev Author: philippeqc Date: 2007-06-21 09:51:02 -0700 (Thu, 21 Jun 2007) Log Message: ----------- Added an acceleration effect for the zones Modified Paths: -------------- armagetronad/trunk/armagetronad/src/tron/gCycleMovement.cpp armagetronad/trunk/armagetronad/src/tron/gCycleMovement.h armagetronad/trunk/armagetronad/src/tron/gParser.cpp armagetronad/trunk/armagetronad/src/tron/zone/zEffector.cpp armagetronad/trunk/armagetronad/src/tron/zone/zEffector.h Modified: armagetronad/trunk/armagetronad/src/tron/gCycleMovement.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gCycleMovement.cpp 2007-06-17 19:42:08 UTC (rev 7305) +++ armagetronad/trunk/armagetronad/src/tron/gCycleMovement.cpp 2007-06-21 16:51:02 UTC (rev 7306) @@ -2341,6 +2341,7 @@ destinationList(NULL),currentDestination(NULL),lastDestination(NULL), dirDrive(dir), acceleration(0), + totalZoneAcceleration(0), lastTimestep_(0), verletSpeed_(sg_speedCycleStart * SpeedMultiplier()), pendingTurns() @@ -2365,6 +2366,7 @@ destinationList(NULL),currentDestination(NULL),lastDestination(NULL), dirDrive(1,0), acceleration(0), + totalZoneAcceleration(0), lastTimestep_(0), verletSpeed_(5) { @@ -2828,6 +2830,8 @@ // apply wall acceleration acceleration += totalWallAcceleration; + acceleration += totalZoneAcceleration; + totalZoneAcceleration = 0.0; // This comes from external influence and should be applied only once per Timestep tASSERT( good( acceleration ) ); sg_ArchiveReal( acceleration, 9 ); @@ -3948,4 +3952,7 @@ return ret; } - +void gCycleMovement::AddZoneAcceleration( REAL zoneAcceleration ) +{ + totalZoneAcceleration += zoneAcceleration; +} Modified: armagetronad/trunk/armagetronad/src/tron/gCycleMovement.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gCycleMovement.h 2007-06-17 19:42:08 UTC (rev 7305) +++ armagetronad/trunk/armagetronad/src/tron/gCycleMovement.h 2007-06-21 16:51:02 UTC (rev 7306) @@ -208,6 +208,7 @@ eCoord dirSpawn; //!< the direction we were facing on the last spawn eCoord lastDirDrive; //!< the direction we were facing before the last turn REAL acceleration; //!< current acceleration + REAL totalZoneAcceleration; //!< current acceleration from the effect of zones and monitor REAL lastTimestep_; //!< the length of the last timestep REAL verletSpeed_; //!< object speed according to verlet (speed of half a frame ago) @@ -261,6 +262,8 @@ inline REAL const & GetLastTurnTime( void ) const; //!< Gets the time of the last turn inline gCycleMovement const & GetLastTurnTime( REAL & lastTurnTime ) const; //!< Gets the time of the last turn REAL GetAcceleration(void) const { return acceleration; }; //!< Gets the cycle's acceleration + virtual void AddZoneAcceleration ( REAL zoneAcceleration ) ; + protected: inline gCycleMovement & SetLastTurnPos( eCoord const & lastTurnPos ); //!< Sets the location of the last turn inline gCycleMovement & SetLastTurnTime( REAL const & lastTurnTime ); //!< Sets the time of the last turn Modified: armagetronad/trunk/armagetronad/src/tron/gParser.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gParser.cpp 2007-06-17 19:42:08 UTC (rev 7305) +++ armagetronad/trunk/armagetronad/src/tron/gParser.cpp 2007-06-21 16:51:02 UTC (rev 7306) @@ -943,6 +943,7 @@ effectors[tString("spawnplayer")] = zEffectorSpawnPlayer::create; effectors[tString("brakerecharge")] = zEffectorCycleBrake::create; effectors[tString("rubberrecharge")] = zEffectorCycleRubber::create; + effectors[tString("acceleration")] = zEffectorCycleAcceleration::create; effectors[tString("setting")] = zEffectorSetting::create; @@ -967,6 +968,16 @@ effectorPoint->setPoint(myxmlGetPropInt(cur, "score")); } + // Should we load the acceleration + zEffectorCycleAcceleration *effectorAcceleration; + effectorAcceleration = dynamic_cast<zEffectorCycleAcceleration *>(effector.get()); + if (effectorAcceleration) { + tFunction tfValue; + string str = string(myxmlGetProp(cur, "value")); + myCheapParameterSplitter(str, tfValue, false); + effectorAcceleration->setValue(tfValue); + } + // Should we set the grid and arena for respawning zEffectorSpawnPlayer *effectorSpawnPlayer; effectorSpawnPlayer = dynamic_cast<zEffectorSpawnPlayer *>(effector.get()); @@ -1825,8 +1836,6 @@ void gParser::parseOwnership(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword) { - if (sn_GetNetState() != nCLIENT ) - { // Prepare the structures to store the ownership information TeamOwnershipInfo mapIdOfTeamOwners; @@ -1876,7 +1885,6 @@ ++index; ++iterTeamOwnership; } // EOP - } } void Modified: armagetronad/trunk/armagetronad/src/tron/zone/zEffector.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/zone/zEffector.cpp 2007-06-17 19:42:08 UTC (rev 7305) +++ armagetronad/trunk/armagetronad/src/tron/zone/zEffector.cpp 2007-06-21 16:51:02 UTC (rev 7306) @@ -49,33 +49,33 @@ void zEffector::setMessage(tString unformated) {/* - tString res; - for (size_t i=0; i< unformated.Size(); i++) - { - char c = unformated(i); - if (c != '\\') - res += c; - else if (i < unformated.Size()) - { - switch (unformated(i+1)) - { - case 'n': - res += '\n'; - i++; - break; - case '1': - res += '\1'; - i++; - break; - default: - res += '\\'; - break; - } - } - } + tString res; + for (size_t i=0; i< unformated.Size(); i++) + { + char c = unformated(i); + if (c != '\\') + res += c; + else if (i < unformated.Size()) + { + switch (unformated(i+1)) + { + case 'n': + res += '\n'; + i++; + break; + case '1': + res += '\1'; + i++; + break; + default: + res += '\\'; + break; + } + } + } - message = res; - */ + message = res; + */ message << unformated; /* message.Append( unformated ); @@ -161,6 +161,21 @@ // // +void zEffectorCycleAcceleration::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets) +{ + gVectorExtra<ePlayerNetID *>::iterator iter; + for(iter = d_calculatedTargets.begin(); + iter != d_calculatedTargets.end(); + ++iter) + { + static_cast<gCycle *>((*iter)->Object())->AddZoneAcceleration(acceleration.GetOffset()); + } +} + +// +// +// + void zEffectorSpawnPlayer::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets) { gVectorExtra<ePlayerNetID *>::iterator iter; Modified: armagetronad/trunk/armagetronad/src/tron/zone/zEffector.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/zone/zEffector.h 2007-06-17 19:42:08 UTC (rev 7305) +++ armagetronad/trunk/armagetronad/src/tron/zone/zEffector.h 2007-06-21 16:51:02 UTC (rev 7306) @@ -36,6 +36,7 @@ #include "gCycle.h" #include "eTeam.h" #include "tLocale.h" +#include "tFunction.h" class zEffector { @@ -133,6 +134,23 @@ virtual void effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets); }; +class zEffectorCycleAcceleration : public zEffector +{ +public: + static zEffector* create() { return new zEffectorCycleAcceleration(); }; + zEffectorCycleAcceleration():zEffector(),acceleration(1.0, 1.0) { }; //<! Constructor + //zEffectorCycleAcceleration(zEffectorCycleAcceleration const &other):zEffector(other) { acceleration = other.acceleration}; + // void operator=(zEffectorCycleAcceleration const &other) { this->zEffector::operator=(other); }; //!< overloaded assignment operator + virtual zEffectorCycleAcceleration *copy(void) const { return new zEffectorCycleAcceleration(*this); }; + virtual ~zEffectorCycleAcceleration() {}; + + virtual void effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets); + + virtual void setValue(tFunction const &accel) { acceleration = accel; }; +protected: + tFunction acceleration; +}; + class gArena; class zEffectorSpawnPlayer : public zEffector This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |