From: <z-...@us...> - 2008-02-04 17:01:19
|
Revision: 7722 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=7722&view=rev Author: z-man Date: 2008-02-04 09:01:03 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Merging branch 0.2.8 from revision 7702 to 7721: ------------------------------------------------------------------------ r7721 | z-man | 2008-02-04 17:36:23 +0100 (Mon, 04 Feb 2008) | 2 lines Better virtual RemoveFromGame logic for eGameObjects, derived classes now don't have to worry about things like removing themselves from the lists or clearing the current grid face (forgetting that has ugly effects). ------------------------------------------------------------------------ r7713 | z-man | 2008-01-31 23:12:57 +0100 (Thu, 31 Jan 2008) | 2 lines Negative hole scores now affect the score of the player who took the hole, positive goes to the one who made the hole. ------------------------------------------------------------------------ r7712 | wrtlprnft | 2008-01-31 15:22:54 +0100 (Thu, 31 Jan 2008) | 2 lines Removed unnecessary line of code, probably resulting in a 1e-9% performance increase. ------------------------------------------------------------------------ r7711 | z-man | 2008-01-30 22:28:37 +0100 (Wed, 30 Jan 2008) | 2 lines If console lines are wrapped, the continuation gets indented a bit. ------------------------------------------------------------------------ r7710 | z-man | 2008-01-30 21:48:36 +0100 (Wed, 30 Jan 2008) | 2 lines Fortress zones no longer collapse if FORTRESS_HELD_SCORE is zero. ------------------------------------------------------------------------ r7708 | z-man | 2008-01-30 12:19:45 +0100 (Wed, 30 Jan 2008) | 2 lines Made the random color picker dislike black even more. ------------------------------------------------------------------------ r7707 | z-man | 2008-01-30 11:55:13 +0100 (Wed, 30 Jan 2008) | 2 lines Eliminating duplicate password storage items on load. ------------------------------------------------------------------------ r7706 | z-man | 2008-01-30 11:36:27 +0100 (Wed, 30 Jan 2008) | 2 lines Fixed bug where you would get points for holding the base, but still was eliminated by its collapse. ------------------------------------------------------------------------ r7705 | z-man | 2008-01-30 10:35:32 +0100 (Wed, 30 Jan 2008) | 2 lines Hopefully a crashfix, and hopefully no reopening of old leak :) ------------------------------------------------------------------------ Revision Links: -------------- http://armagetronad.svn.sourceforge.net/armagetronad/?rev=7702&view=rev Modified Paths: -------------- armagetronad/trunk/armagetronad/config/settings_dedicated.cfg armagetronad/trunk/armagetronad/src/engine/eGameObject.cpp armagetronad/trunk/armagetronad/src/engine/eGameObject.h armagetronad/trunk/armagetronad/src/engine/eNetGameObject.cpp armagetronad/trunk/armagetronad/src/engine/eNetGameObject.h armagetronad/trunk/armagetronad/src/engine/ePlayer.cpp armagetronad/trunk/armagetronad/src/engine/eVoter.cpp armagetronad/trunk/armagetronad/src/render/rConsoleGraph.cpp armagetronad/trunk/armagetronad/src/render/rFont.cpp armagetronad/trunk/armagetronad/src/tron/gCycle.cpp armagetronad/trunk/armagetronad/src/tron/gCycle.h armagetronad/trunk/armagetronad/src/tron/gCycleMovement.cpp armagetronad/trunk/armagetronad/src/tron/gCycleMovement.h armagetronad/trunk/armagetronad/src/tron/gExplosion.cpp armagetronad/trunk/armagetronad/src/tron/gExplosion.h armagetronad/trunk/armagetronad/src/tron/gGame.cpp Modified: armagetronad/trunk/armagetronad/config/settings_dedicated.cfg =================================================================== --- armagetronad/trunk/armagetronad/config/settings_dedicated.cfg 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/config/settings_dedicated.cfg 2008-02-04 17:01:03 UTC (rev 7722) @@ -228,7 +228,7 @@ CYCLE_RUBBER_MINDISTANCE_LEGACY 1 # extra factor for minimal distance to walls enforced by the rubber code, active when peers with the rip bug are connected # single player settings, active while only one client is connected. -# Either SP_MIN_PLAYERS or SP_MIN_TEAMS must be bigger than 1, otherwise there will +# Either SP_MIN_PLAYERS or SP_TEAMS_MIN must be bigger than 1, otherwise there will # be no opponent and no meaningful rounds. SP_TEAM_BALANCE_WITH_AIS needs to stay enabled, # too. Modified: armagetronad/trunk/armagetronad/src/engine/eGameObject.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eGameObject.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/engine/eGameObject.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -80,14 +80,43 @@ } -void eGameObject::RemoveFromGame(){ +void eGameObject::RemoveFromGame() +{ + int oldID = id; + if ( oldID >= 0 ) + { + AddRef(); + } + + OnRemoveFromGame(); + DoRemoveFromGame(); + + if ( oldID >= 0 ) + { + Release(); + } +} + + +// called on RemoveFromGame(). Call base class implementation, too, in your implementation. +void eGameObject::OnRemoveFromGame() +{ + // remove from lists RemoveFromListsAll(); + // remove from grid + currentFace = 0; +} + + +// called on RemoveFromGame(). Do not call base class implementation of this function, don't expect to get called from subclasses. +void eGameObject::DoRemoveFromGame() +{ + // simply delete delete this; } - eGameObject::eGameObject(eGrid *g,const eCoord &p,const eCoord &d,eFace *currentface,bool autodel) :autodelete(autodel),pos(p),dir(d),z(0),grid(g){ tASSERT(g); Modified: armagetronad/trunk/armagetronad/src/engine/eGameObject.h =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eGameObject.h 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/engine/eGameObject.h 2008-02-04 17:01:03 UTC (rev 7722) @@ -108,8 +108,14 @@ void AddToList(); void RemoveFromList(); void RemoveFromListsAll(); - virtual void RemoveFromGame(); // call this instead of the destructor + void RemoveFromGame(); //!< removes the object physically from the game +protected: + virtual void OnRemoveFromGame(); //!< called on RemoveFromGame(). Call base class implementation, too, in your implementation. Must keep the object alive. +private: + virtual void DoRemoveFromGame(); //!< called on RemoveFromGame() after OnRemoveFromGame(). Do not call base class implementation of this function, don't expect to get called from subclasses. +public: + int GOID() const {return id;} REAL LastTime() const {return lastTime;} virtual REAL NextInterestingTime() const {return lastTime;} //!< the next time something interesting is going to happen with this object Modified: armagetronad/trunk/armagetronad/src/engine/eNetGameObject.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eNetGameObject.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/engine/eNetGameObject.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -111,14 +111,12 @@ pingOverflow=0; } -void eNetGameObject::RemoveFromGame(){ +void eNetGameObject::DoRemoveFromGame(){ // let the object get deleted on exit if nobody else is interested tControlledPTR< eNetGameObject > bounce; if ( this->GetRefcount() >= 0 ) bounce = this; - RemoveFromListsAll(); - // unregister from player if ( player && this == player->object ) { @@ -126,8 +124,6 @@ } team = NULL; - - currentFace = 0; } eNetGameObject::~eNetGameObject(){ Modified: armagetronad/trunk/armagetronad/src/engine/eNetGameObject.h =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eNetGameObject.h 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/engine/eNetGameObject.h 2008-02-04 17:01:03 UTC (rev 7722) @@ -75,7 +75,7 @@ eNetGameObject(eGrid *grid, const eCoord &pos,const eCoord &dir,ePlayerNetID* p,bool autodelete=false); eNetGameObject(nMessage &m); - virtual void RemoveFromGame(); // just remove it from the lists and unregister it + virtual void DoRemoveFromGame(); // just remove it from the lists and unregister it virtual void WriteCreate(nMessage &m); virtual void WriteSync(nMessage &m); Modified: armagetronad/trunk/armagetronad/src/engine/ePlayer.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/ePlayer.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/engine/ePlayer.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -83,7 +83,12 @@ PasswordStorage(): save(false){}; }; - +static bool operator == ( PasswordStorage const & a, PasswordStorage const & b ) +{ + return + a.username == b.username; +} + static tArray<PasswordStorage> S_passwords; void se_DeletePasswords(){ @@ -158,7 +163,19 @@ PasswordStorage &storage = S_passwords[S_passwords.Len()]; nKrawall::ReadScrambledPassword(s, storage.password); storage.username.ReadLine(s); + storage.save = true; + + // check for duplicates + for( int i = S_passwords.Len() - 2; i >= 0; --i ) + { + PasswordStorage &other = S_passwords[i]; + if ( other == storage ) + { + storage.save = false; + break; + } + } } } }; @@ -3513,8 +3530,8 @@ newRGB[i] = randomizer.Get(15); } - int currentMinDiff = se_ColorDistance( currentRGB, nullRGB ) * 2; - int newMinDiff = se_ColorDistance( newRGB, nullRGB ) * 2; + int currentMinDiff = se_ColorDistance( currentRGB, nullRGB )/2; + int newMinDiff = se_ColorDistance( newRGB, nullRGB )/2; // check the minimal distance of the new random color with all players for ( int i = se_PlayerNetIDs.Len()-1; i >= 0; --i ) Modified: armagetronad/trunk/armagetronad/src/engine/eVoter.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eVoter.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/engine/eVoter.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -732,8 +732,6 @@ virtual void OnDestroy() { machine_ = 0; - - delete this; } private: nMachine * machine_; Modified: armagetronad/trunk/armagetronad/src/render/rConsoleGraph.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/render/rConsoleGraph.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/render/rConsoleGraph.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -112,6 +112,7 @@ rTextField out(-.95f,.99f,rCHEIGHT_CON, sr_fontConsole);//,&rFont::s_defaultFontSmall); out.SetWidth(1.9f); out.EnableLineWrap(); + out.SetIndent(3); int i; for(i=currentTop;i<=currentIn && i<=currentTop+MaxHeight();i++) Modified: armagetronad/trunk/armagetronad/src/render/rFont.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/render/rFont.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/render/rFont.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -618,7 +618,14 @@ { WriteChar('\n'); c++; - if (wordWidth >= maxWidth) { + + for ( int i = parIndent-1; i >= 0; --i ) + { + WriteChar(' '); + cursorPos++; + } + + if (wordWidth >= maxWidth) { trouble = true; currentWidth = 0.; } else { Modified: armagetronad/trunk/armagetronad/src/tron/gCycle.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gCycle.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/tron/gCycle.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -2301,7 +2301,7 @@ */ } -void gCycle::RemoveFromGame() +void gCycle::OnRemoveFromGame() { // keep this cycle alive tJUST_CONTROLLED_PTR< gCycle > keep; @@ -2329,7 +2329,7 @@ currentWall=NULL; lastWall=NULL; - gCycleMovement::RemoveFromGame(); + gCycleMovement::OnRemoveFromGame(); delete joystick_; joystick_ = NULL; @@ -3271,6 +3271,11 @@ } } +static void sg_HoleScore( gCycle & cycle ) +{ + cycle.Player()->AddScore( score_hole, tOutput("$player_win_hole"), tOutput("$player_lose_hole") ); +} + void gCycle::PassEdge(const eWall *ww,REAL time,REAL a,int){ { // deactivate time check @@ -3284,7 +3289,7 @@ // check whether we drove through a hole in an enemy wall made by a teammate gPlayerWall const * w = dynamic_cast< gPlayerWall const * >( ww ); - if ( w ) + if ( w && score_hole ) { gExplosion * explosion = w->Holer( a, time ); if ( explosion ) @@ -3300,8 +3305,18 @@ // 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") ); - } + if ( score_hole > 0 ) + { + // positive hole score goes to the holer + sg_HoleScore( *holer ); + } + else + { + // negative hole score to the driver + sg_HoleScore( *this ); + + } + } } } } Modified: armagetronad/trunk/armagetronad/src/tron/gCycle.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gCycle.h 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/tron/gCycle.h 2008-02-04 17:01:03 UTC (rev 7722) @@ -195,7 +195,7 @@ protected: virtual ~gCycle(); - virtual void RemoveFromGame(); // call this instead of the destructor + virtual void OnRemoveFromGame(); // called when the cycle is physically removed from the game virtual void OnRoundEnd(); //!< called when the round ends Modified: armagetronad/trunk/armagetronad/src/tron/gCycleMovement.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gCycleMovement.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/tron/gCycleMovement.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -2552,12 +2552,12 @@ maxSpaceHit_ = NULL; } -void gCycleMovement::RemoveFromGame() +void gCycleMovement::OnRemoveFromGame() { delete maxSpaceHit_; maxSpaceHit_ = NULL; - eNetGameObject::RemoveFromGame(); + eNetGameObject::OnRemoveFromGame(); } // ******************************************************************************************* Modified: armagetronad/trunk/armagetronad/src/tron/gCycleMovement.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gCycleMovement.h 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/tron/gCycleMovement.h 2008-02-04 17:01:03 UTC (rev 7722) @@ -139,7 +139,7 @@ , bool autodelete=1 ) ; //!< local constructor gCycleMovement ( nMessage & message ) ; //!< remote constructor virtual ~gCycleMovement () ; //!< destructor - virtual void RemoveFromGame(); // call this instead of the destructor + virtual void OnRemoveFromGame(); // called when the cycle is physically removed from the game protected: //! data from sync message struct SyncData Modified: armagetronad/trunk/armagetronad/src/tron/gExplosion.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gExplosion.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/tron/gExplosion.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -493,8 +493,7 @@ #endif -void gExplosion::RemoveFromGame() +void gExplosion::DoRemoveFromGame() { sg_Explosions.Remove( this, listID ); - RemoveFromList(); } Modified: armagetronad/trunk/armagetronad/src/tron/gExplosion.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gExplosion.h 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/tron/gExplosion.h 2008-02-04 17:01:03 UTC (rev 7722) @@ -71,7 +71,7 @@ virtual void AddRef(){tReferencable< gExplosion >::AddRef();} virtual void Release(){tReferencable< gExplosion >::Release();} - virtual void RemoveFromGame(); + virtual void DoRemoveFromGame(); // called last when the object is removed from the game private: REAL createTime; Modified: armagetronad/trunk/armagetronad/src/tron/gGame.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gGame.cpp 2008-02-04 16:36:23 UTC (rev 7721) +++ armagetronad/trunk/armagetronad/src/tron/gGame.cpp 2008-02-04 17:01:03 UTC (rev 7722) @@ -2991,7 +2991,6 @@ tOutput o("$gamestate_30seconds_warn"); sn_CenterMessage(o); sn_ConsoleOut(o); - warning=6; warning=5; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |