[Orxonox-commit 3208] r7901 - in code/branches/lastmanstanding2: data/levels data/overlays src/modules/overlays/hud src/orxonox/gametypes

jo at orxonox.net jo at orxonox.net
Tue Feb 15 15:38:55 CET 2011


Author: jo
Date: 2011-02-15 15:38:54 +0100 (Tue, 15 Feb 2011)
New Revision: 7901

Modified:
   code/branches/lastmanstanding2/data/levels/lastManStanding.oxw
   code/branches/lastmanstanding2/data/levels/lastTeamStanding.oxw
   code/branches/lastmanstanding2/data/overlays/lastTeamStandingHUD.oxo
   code/branches/lastmanstanding2/src/modules/overlays/hud/GametypeStatus.cc
   code/branches/lastmanstanding2/src/modules/overlays/hud/GametypeStatus.h
   code/branches/lastmanstanding2/src/orxonox/gametypes/Gametype.h
   code/branches/lastmanstanding2/src/orxonox/gametypes/LastTeamStanding.cc
Log:
Finally working as intended.

Modified: code/branches/lastmanstanding2/data/levels/lastManStanding.oxw
===================================================================
--- code/branches/lastmanstanding2/data/levels/lastManStanding.oxw	2011-02-15 13:34:09 UTC (rev 7900)
+++ code/branches/lastmanstanding2/data/levels/lastManStanding.oxw	2011-02-15 14:38:54 UTC (rev 7901)
@@ -1,3 +1,9 @@
+<LevelInfo
+ name = "Last Man Standing"
+ description = "Be the sole survivor."
+ tags = ""
+/>
+
 <?lua
   include("stats.oxo")
   include("HUDTemplates3.oxo")

Modified: code/branches/lastmanstanding2/data/levels/lastTeamStanding.oxw
===================================================================
--- code/branches/lastmanstanding2/data/levels/lastTeamStanding.oxw	2011-02-15 13:34:09 UTC (rev 7900)
+++ code/branches/lastmanstanding2/data/levels/lastTeamStanding.oxw	2011-02-15 14:38:54 UTC (rev 7901)
@@ -1,3 +1,8 @@
+<LevelInfo
+ name = "Last Team Standing"
+ description = "Survive as a team."
+ tags = "singleplayer"
+/>
 <?lua
   include("stats.oxo")
   include("HUDTemplates3.oxo")

Modified: code/branches/lastmanstanding2/data/overlays/lastTeamStandingHUD.oxo
===================================================================
--- code/branches/lastmanstanding2/data/overlays/lastTeamStandingHUD.oxo	2011-02-15 13:34:09 UTC (rev 7900)
+++ code/branches/lastmanstanding2/data/overlays/lastTeamStandingHUD.oxo	2011-02-15 14:38:54 UTC (rev 7901)
@@ -1,7 +1,7 @@
 <Template name="lastTeamStandingHUD">
   <OverlayGroup name="lastTeamStandingHUD" scale = "1, 1">
 
-<GametypeFadingMessag
+<GametypeFadingMessage
      name     = "fadingmessage"
      position = "0.5, 0.01"
      font     = "VeraMono"

Modified: code/branches/lastmanstanding2/src/modules/overlays/hud/GametypeStatus.cc
===================================================================
--- code/branches/lastmanstanding2/src/modules/overlays/hud/GametypeStatus.cc	2011-02-15 13:34:09 UTC (rev 7900)
+++ code/branches/lastmanstanding2/src/modules/overlays/hud/GametypeStatus.cc	2011-02-15 14:38:54 UTC (rev 7901)
@@ -35,6 +35,7 @@
 #include "infos/PlayerInfo.h"
 #include "worldentities/ControllableEntity.h"
 #include "worldentities/pawns/Spectator.h"
+//#include "gametypes/Gametype.h"
 
 namespace orxonox
 {
@@ -49,8 +50,10 @@
     {
         RegisterObject(GametypeStatus);
 
+        //this->game_ = 0;
         this->owner_ = 0;
         this->bNoCaption_ = false;
+        //this->bForcedSpawn_ = false;
 
         ModifyConsoleCommand(__CC_GametypeStatus_name, __CC_displayCaption_name).setObject(this);
     }
@@ -66,6 +69,11 @@
 
         if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getControllableEntity())
         {
+            //if (this->game_)
+            //    this->bForcedSpawn_ = this->game_->getForceSpawn();
+            //else
+            //    this->bForcedSpawn_ = false;
+
             const GametypeInfo* gtinfo = this->owner_->getGametypeInfo();
             ControllableEntity* ce = this->owner_->getControllableEntity();
 
@@ -86,7 +94,7 @@
             {
                 if (gtinfo->isStartCountdownRunning())
                     this->setCaption(multi_cast<std::string>(static_cast<int>(ceil(gtinfo->getStartCountdown()))));
-                else if (ce->isA(Class(Spectator)))
+                else if (ce->isA(Class(Spectator))/*&&(!bForcedSpawn_)*/)
                     this->setCaption("Press [Fire] to respawn");
                 else
                     this->setCaption("");
@@ -100,7 +108,7 @@
     void GametypeStatus::changedOwner()
     {
         SUPER(GametypeStatus, changedOwner);
-
+        //this->game_ = orxonox_cast<Gametype*>(this->getOwner());
         this->owner_ = orxonox_cast<PlayerInfo*>(this->getOwner());
     }
 

Modified: code/branches/lastmanstanding2/src/modules/overlays/hud/GametypeStatus.h
===================================================================
--- code/branches/lastmanstanding2/src/modules/overlays/hud/GametypeStatus.h	2011-02-15 13:34:09 UTC (rev 7900)
+++ code/branches/lastmanstanding2/src/modules/overlays/hud/GametypeStatus.h	2011-02-15 14:38:54 UTC (rev 7901)
@@ -48,8 +48,10 @@
             void setDisplayCaption(bool bValue); //!< Toggles whether the gametype status is displayed.
 
         private:
+            //Gametype* game_;
             PlayerInfo* owner_;
             bool bNoCaption_;
+            //bool bForcedSpawn_;
 
     };
 }

Modified: code/branches/lastmanstanding2/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/branches/lastmanstanding2/src/orxonox/gametypes/Gametype.h	2011-02-15 13:34:09 UTC (rev 7900)
+++ code/branches/lastmanstanding2/src/orxonox/gametypes/Gametype.h	2011-02-15 14:38:54 UTC (rev 7901)
@@ -149,6 +149,9 @@
             inline void setTimeLimit(float t)
               { this->timeLimit_ = t; }
 
+            //inline bool getForceSpawn()
+            //  { return this->bForceSpawn_; }       
+
             virtual void resetTimer();
             virtual void resetTimer(float t);
 

Modified: code/branches/lastmanstanding2/src/orxonox/gametypes/LastTeamStanding.cc
===================================================================
--- code/branches/lastmanstanding2/src/orxonox/gametypes/LastTeamStanding.cc	2011-02-15 13:34:09 UTC (rev 7900)
+++ code/branches/lastmanstanding2/src/orxonox/gametypes/LastTeamStanding.cc	2011-02-15 14:38:54 UTC (rev 7901)
@@ -57,11 +57,11 @@
     
     LastTeamStanding::~LastTeamStanding()
     {
-        this->playerLives_.clear();
-        this->eachTeamsPlayers.clear();
-        this->timeToAct_.clear();
-        this->inGame_.clear();
-        this->playerDelayTime_.clear();
+        //this->playerLives_.clear();
+        //this->eachTeamsPlayers.clear();
+        //this->timeToAct_.clear();
+        //this->inGame_.clear();
+        //this->playerDelayTime_.clear();
     }   
 
     void LastTeamStanding::playerEntered(PlayerInfo* player)
@@ -74,15 +74,17 @@
         else
             playerLives_[player]=getMinLives();//new players only get minimum of lives */
         
-        if(this->eachTeamsPlayers[getTeam(player)]==0) //if a player is the first in his group, a new team is alive
-            this->teamsAlive++;
-        this->eachTeamsPlayers[getTeam(player)]++; //the number of player in this team is increased
-
         if (teamsAlive>1) // Now the game is allowed to end, since there are at least two teams.
             bMinTeamsReached = true; // since there are at least two teams, the game is allowed to end
         this->timeToAct_[player] = timeRemaining;
         this->playerDelayTime_[player] = respawnDelay;
         this->inGame_[player] = true;
+        int team = getTeam(player);
+        if( team < 0|| team > teams_) // make sure getTeam returns a regular value
+            return;
+        if(this->eachTeamsPlayers[team]==0) //if a player is the first in his group, a new team is alive
+            this->teamsAlive++;
+        this->eachTeamsPlayers[team]++; //the number of player in this team is increased
     }
 
     bool LastTeamStanding::playerLeft(PlayerInfo* player)
@@ -90,13 +92,16 @@
         bool valid_player = TeamDeathmatch::playerLeft(player);
         if (valid_player)
         {
-            this->eachTeamsPlayers[getTeam(player)]--;       // a player left the team
-            if(this->eachTeamsPlayers[getTeam(player)] == 0) // if it was the last player a team died
-                 this->teamsAlive--;
             this->playerLives_.erase(player);
             this->timeToAct_.erase(player);
             this->playerDelayTime_.erase(player);
             this->inGame_.erase(player);
+            int team = getTeam(player);
+            if( team < 0|| team > teams_) // make sure getTeam returns a regular value
+                return valid_player;
+            this->eachTeamsPlayers[team]--;       // a player left the team
+            if(this->eachTeamsPlayers[team] == 0) // if it was the last player a team died
+                this->teamsAlive--;
         }
 
         return valid_player;
@@ -113,14 +118,16 @@
         this->inGame_[victim->getPlayer()] = false; //if player dies, he isn't allowed to respawn immediately
         if (playerLives_[victim->getPlayer()]<=0) //if player lost all lives
         {
-            this->eachTeamsPlayers[getTeam(victim->getPlayer())]--;
-            if(eachTeamsPlayers[getTeam(victim->getPlayer())] == 0) //last team member died
+            int team = getTeam(victim->getPlayer());
+            if(team < 0|| team > teams_) // make sure getTeam returns a regular value
+                return allow;
+            this->eachTeamsPlayers[team]--;
+            if(eachTeamsPlayers[team] == 0) //last team member died
                 this->teamsAlive--;
             const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
             COUT(0) << message << std::endl;
             Host::Broadcast(message);
         }
-
         return allow;
     }
 




More information about the Orxonox-commit mailing list