From: <z-...@us...> - 2008-01-28 22:02:23
|
Revision: 7686 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=7686&view=rev Author: z-man Date: 2008-01-28 14:02:21 -0800 (Mon, 28 Jan 2008) Log Message: ----------- Hole score management is now done with an extra redirection: hole->explosion->cycle. hat way, in case a cycle can produce multiple explosions (not the case with respawning, there it is a new cycle every spawn), the player can get multiple scores for holes. Modified Paths: -------------- armagetronad/branches/0.2.8/armagetronad/src/tron/gCycle.cpp armagetronad/branches/0.2.8/armagetronad/src/tron/gCycle.h armagetronad/branches/0.2.8/armagetronad/src/tron/gExplosion.cpp armagetronad/branches/0.2.8/armagetronad/src/tron/gExplosion.h armagetronad/branches/0.2.8/armagetronad/src/tron/gWall.cpp armagetronad/branches/0.2.8/armagetronad/src/tron/gWall.h Modified: armagetronad/branches/0.2.8/armagetronad/src/tron/gCycle.cpp =================================================================== --- armagetronad/branches/0.2.8/armagetronad/src/tron/gCycle.cpp 2008-01-28 21:31:33 UTC (rev 7685) +++ armagetronad/branches/0.2.8/armagetronad/src/tron/gCycle.cpp 2008-01-28 22:02:21 UTC (rev 7686) @@ -2071,7 +2071,6 @@ void gCycle::MyInitAfterCreation(){ dropWallRequested_ = false; lastGoodPosition_ = pos; - holeAccountedFor_ = false; #ifdef DEBUG // con << "creating cycle.\n"; @@ -3271,17 +3270,23 @@ gPlayerWall const * w = dynamic_cast< gPlayerWall const * >( ww ); if ( w ) { - gCycle * holer = w->Holer( a, time ); - if ( holer && !holer->holeAccountedFor_ && - holer->Player() && - Player() && - holer->Player()->CurrentTeam() == Player()->CurrentTeam() && - w->Cycle() && w->Cycle()->Player() && - w->Cycle()->Player()->CurrentTeam() != Player()->CurrentTeam() - ) + gExplosion * explosion = w->Holer( a, time ); + if ( explosion ) { - holer->holeAccountedFor_ = true; - holer->Player()->AddScore( score_hole, tOutput("$player_win_hole"), tOutput("$player_lose_hole") ); + gCycle * holer = explosion->GetOwner(); + if ( holer && holer->Player() && + Player() && + w->Cycle() && w->Cycle()->Player() && + holer->Player()->CurrentTeam() == Player()->CurrentTeam() && // holer must have been a teammate + w->Cycle()->Player()->CurrentTeam() != Player()->CurrentTeam() // wall must have been an enemy + ) + { + // this test must come last, it resets the flag. + if ( explosion->AccountForHole() ) + { + holer->Player()->AddScore( score_hole, tOutput("$player_win_hole"), tOutput("$player_lose_hole") ); + } + } } } Modified: armagetronad/branches/0.2.8/armagetronad/src/tron/gCycle.h =================================================================== --- armagetronad/branches/0.2.8/armagetronad/src/tron/gCycle.h 2008-01-28 21:31:33 UTC (rev 7685) +++ armagetronad/branches/0.2.8/armagetronad/src/tron/gCycle.h 2008-01-28 22:02:21 UTC (rev 7686) @@ -121,7 +121,6 @@ friend class gPlayerWall; friend class gNetPlayerWall; friend class gDestination; - friend class gExplosion; eSoundPlayer *engine; eSoundPlayer *turning; @@ -135,7 +134,6 @@ std::auto_ptr< gCycleChatBot > chatBot_; bool dropWallRequested_; //!< flag indicating that someone requested a wall drop - bool holeAccountedFor_; //!< flag indicating whether we already gave the player credit for making a hole for his teammates public: eCoord lastGoodPosition_; // the location of the last known good position Modified: armagetronad/branches/0.2.8/armagetronad/src/tron/gExplosion.cpp =================================================================== --- armagetronad/branches/0.2.8/armagetronad/src/tron/gExplosion.cpp 2008-01-28 21:31:33 UTC (rev 7685) +++ armagetronad/branches/0.2.8/armagetronad/src/tron/gExplosion.cpp 2008-01-28 22:02:21 UTC (rev 7686) @@ -57,7 +57,7 @@ static eCoord s_explosionCoord; static REAL s_explosionRadius; static REAL s_explosionTime; -static gCycle * s_holer = 0; +static gExplosion * s_holer = 0; // blow a hole centered at s_explosionCoord with radius s_explosionRadius into wall w static void S_BlowHoles( eWall * w ) @@ -143,8 +143,7 @@ listID(-1), owner_(owner) { - if ( owner ) - owner->holeAccountedFor_ = false; + holeAccountedFor_ = false; lastTime = time; explosion_r = color.r; @@ -218,7 +217,7 @@ REAL factor = expansion / REAL( expansionSteps ); s_explosionRadius = gCycle::ExplosionRadius() * sqrt(factor); s_explosionTime = createTime; - s_holer = owner_; + s_holer = this; if ( s_explosionRadius > 0 && (currentTime < createTime+4) ) { @@ -279,6 +278,13 @@ createTime=lastTime-100; } +bool gExplosion::AccountForHole() +{ + bool ret = !holeAccountedFor_; + holeAccountedFor_ = true; + return ret; +} + void gExplosion::OnNewWall( eWall* w ) { for ( int i = sg_Explosions.Len() - 1; i>=0; --i ) @@ -400,3 +406,9 @@ } #endif +void gExplosion::RemoveFromGame() +{ + sg_Explosions.Remove( this, listID ); + RemoveFromList(); +} + Modified: armagetronad/branches/0.2.8/armagetronad/src/tron/gExplosion.h =================================================================== --- armagetronad/branches/0.2.8/armagetronad/src/tron/gExplosion.h 2008-01-28 21:31:33 UTC (rev 7685) +++ armagetronad/branches/0.2.8/armagetronad/src/tron/gExplosion.h 2008-01-28 22:02:21 UTC (rev 7686) @@ -35,7 +35,7 @@ class gCycle; struct gRealColor; -class gExplosion: virtual public eGameObject +class gExplosion: virtual public eGameObject, public tReferencable< gExplosion > { // Boom! public: gExplosion(eGrid *grid, const eCoord &pos,REAL time, gRealColor& color, gCycle * owner ); @@ -55,7 +55,19 @@ int viewer,REAL rvol,REAL lvol); #endif + bool AccountForHole(); // will return true exactly once per explosion; to be used to make the holing score only count once. + static void OnNewWall( eWall* w ); // blow holes into a new wall + + // returns the owner + gCycle * GetOwner() const + { + return owner_; + } + + virtual void AddRef(){tReferencable< gExplosion >::AddRef();} + virtual void Release(){tReferencable< gExplosion >::Release();} + virtual void RemoveFromGame(); private: eSoundPlayer sound; @@ -73,6 +85,8 @@ static int expansionSteps; static REAL expansionTime; + bool holeAccountedFor_; //!< flag indicating whether we already gave the player credit for making a hole for his teammates + int listID; tJUST_CONTROLLED_PTR< gCycle > owner_; // the owner/victim of the explosion Modified: armagetronad/branches/0.2.8/armagetronad/src/tron/gWall.cpp =================================================================== --- armagetronad/branches/0.2.8/armagetronad/src/tron/gWall.cpp 2008-01-28 21:31:33 UTC (rev 7685) +++ armagetronad/branches/0.2.8/armagetronad/src/tron/gWall.cpp 2008-01-28 22:02:21 UTC (rev 7686) @@ -1352,7 +1352,7 @@ } // returns the guy who holed here -gCycle * gPlayerWall::Holer( REAL a, REAL time ) const +gExplosion * gPlayerWall::Holer( REAL a, REAL time ) const { CHECKWALL; @@ -1387,7 +1387,7 @@ return netWall_->Time( netWall_->Alpha( this->begDist_ ) ); } -void gPlayerWall::BlowHole ( REAL beg, REAL end, gCycle * holer ) +void gPlayerWall::BlowHole ( REAL beg, REAL end, gExplosion * holer ) { CHECKWALL; @@ -2378,7 +2378,7 @@ } // returns the guy who holed here -gCycle * gNetPlayerWall::Holer( REAL a, REAL time ) const +gExplosion * gNetPlayerWall::Holer( REAL a, REAL time ) const { CHECKWALL; @@ -2421,7 +2421,7 @@ return coords_(0).Time; } -void gNetPlayerWall::BlowHole ( REAL beg, REAL end, gCycle * holer ) +void gNetPlayerWall::BlowHole ( REAL beg, REAL end, gExplosion * holer ) { CHECKWALL; Modified: armagetronad/branches/0.2.8/armagetronad/src/tron/gWall.h =================================================================== --- armagetronad/branches/0.2.8/armagetronad/src/tron/gWall.h 2008-01-28 21:31:33 UTC (rev 7685) +++ armagetronad/branches/0.2.8/armagetronad/src/tron/gWall.h 2008-01-28 22:02:21 UTC (rev 7686) @@ -32,6 +32,7 @@ #include "eAdvWall.h" #include "nNetObject.h" //#include "nObserver.h" +class gExplosion; class gCycle; class gCycleMovement; class gNetPlayerWall; @@ -70,7 +71,7 @@ REAL Pos; //!< the start position, measured relative to the point where the cycle started driving REAL Time; //!< the time this point was created bool IsDangerous; //!< true iff the segment AFTER this point is a true wall (and not a hole) - tJUST_CONTROLLED_PTR< gCycle > holer; //< if it is a hole, store who made it here. + tJUST_CONTROLLED_PTR< gExplosion > holer; //< if it is a hole, store who made it here. }; class gPlayerWall:public eWall{ @@ -109,9 +110,9 @@ REAL Alpha(REAL pos) const; bool IsDangerousAnywhere( REAL time ) const; bool IsDangerous( REAL a, REAL time ) const; - gCycle * Holer( REAL a, REAL time ) const; // returns the guy who holed here + gExplosion * Holer( REAL a, REAL time ) const; // returns the guy who holed here - void BlowHole ( REAL dbeg, REAL dend, gCycle * holer ); // blow a hole into the wall form distance dbeg to dend, created by holer + void BlowHole ( REAL dbeg, REAL dend, gExplosion * holer ); // blow a hole into the wall form distance dbeg to dend, created by holer REAL BegPos() const; REAL EndPos() const; @@ -158,9 +159,8 @@ unsigned short inGrid; // are we planned to be insite the grid? REAL gridding; // when are we going to enter the grid? - -bool preliminary:1; // is it a eWall preliminary installed? - REAL obsoleted_; // the game time this preliminary wall got obsoleted by a final wall (negative if it is not yet obsolete) + bool preliminary:1; // is it a eWall preliminary installed? + REAL obsoleted_; // the game time this preliminary wall got obsoleted by a final wall (negative if it is not yet obsolete) // by the client while it is waiting for the real eWall from the server? void CreateEdge(); @@ -201,9 +201,9 @@ bool IsDangerousAnywhere( REAL time ) const; bool IsDangerousApartFromHoles( REAL a, REAL time ) const; // checks all danger signs, except hooles bool IsDangerous( REAL a, REAL time ) const; // checks all danger signs - gCycle * Holer( REAL a, REAL time ) const; // returns the cycle responsible for a hole + gExplosion * Holer( REAL a, REAL time ) const; // returns the cycle responsible for a hole - void BlowHole ( REAL dbeg, REAL dend, gCycle * holer ); // blow a hole into the wall form distance dbeg to dend + void BlowHole ( REAL dbeg, REAL dend, gExplosion * holer ); // blow a hole into the wall form distance dbeg to dend REAL BegPos() const; REAL EndPos() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |