[Orxonox-commit 4259] r8930 - in code/branches/gamecontent/src/orxonox: gametypes infos
jo at orxonox.net
jo at orxonox.net
Wed Nov 9 16:16:25 CET 2011
Author: jo
Date: 2011-11-09 16:16:24 +0100 (Wed, 09 Nov 2011)
New Revision: 8930
Modified:
code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc
code/branches/gamecontent/src/orxonox/gametypes/Gametype.h
code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc
code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h
code/branches/gamecontent/src/orxonox/infos/GametypeInfo.h
Log:
Adding some variables.
Modified: code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc 2011-11-09 15:12:35 UTC (rev 8929)
+++ code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc 2011-11-09 15:16:24 UTC (rev 8930)
@@ -84,6 +84,7 @@
this->dedicatedAddBots_ = createConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );
this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );
/* HACK HACK HACK */
+ //this->numberOfPlayers_ = 0;
}
Gametype::~Gametype()
Modified: code/branches/gamecontent/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/Gametype.h 2011-11-09 15:12:35 UTC (rev 8929)
+++ code/branches/gamecontent/src/orxonox/gametypes/Gametype.h 2011-11-09 15:16:24 UTC (rev 8930)
@@ -154,6 +154,8 @@
virtual void resetTimer();
virtual void resetTimer(float t);
+ inline unsigned int getNumberOfPlayers()
+ { return this->gtinfo_->getNumberOfPlayers(); }
protected:
virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
@@ -191,6 +193,7 @@
ConsoleCommand* dedicatedAddBots_;
ConsoleCommand* dedicatedKillBots_;
/* HACK HACK HACK */
+
};
}
Modified: code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc 2011-11-09 15:12:35 UTC (rev 8929)
+++ code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc 2011-11-09 15:16:24 UTC (rev 8930)
@@ -30,6 +30,7 @@
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
+#include "infos/PlayerInfo.h"
#include "interfaces/TeamColourable.h"
#include "worldentities/TeamSpawnPoint.h"
#include "worldentities/pawns/Pawn.h"
@@ -44,7 +45,8 @@
this->teams_ = 2;
this->allowFriendlyFire_ = false;
-
+ //this->playersPerTeam_ = 0;
+ this->maxPlayers_ = 0;
this->setConfigValues();
}
@@ -103,6 +105,20 @@
return valid_player;
}
+ void TeamGametype::spawnDeadPlayersIfRequested()
+ {
+ for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end();
+++it)
+ if (it->second.state_ == PlayerState::Dead)
+ {
+ if ((it->first->isReadyToSpawn() || this->bForceSpawn_))
+ {
+ this->spawnPlayer(it->first);
+ }
+ }
+ }
+
+
bool TeamGametype::allowPawnHit(Pawn* victim, Pawn* originator)
{// hit allowed: if victim & originator are foes or if originator doesnot exist or if friendlyfire is allowed
return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator || this->allowFriendlyFire_);
Modified: code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h 2011-11-09 15:12:35 UTC (rev 8929)
+++ code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h 2011-11-09 15:16:24 UTC (rev 8930)
@@ -48,6 +48,7 @@
virtual void playerEntered(PlayerInfo* player);
virtual void findAndSetTeam(PlayerInfo* player);
virtual bool playerLeft(PlayerInfo* player);
+ virtual void spawnDeadPlayersIfRequested(); //!< Prevents players to respawn.
virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
@@ -55,6 +56,7 @@
virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
+
int getTeam(PlayerInfo* player);
inline const ColourValue& getTeamColour(int teamnr) const
@@ -67,7 +69,9 @@
bool allowFriendlyFire_; //<! friendlyfire is per default switched off: friendlyFire_ = false;
std::map<PlayerInfo*, int> teamnumbers_;
std::vector<ColourValue> teamcolours_;
- unsigned int teams_;
+ unsigned int teams_; //<! Number of teams. Value 0 : no teams!
+ //unsigned int playersPerTeam_; //<! Defines Maximum for players per team. Value 0: no maximum!
+ unsigned int maxPlayers_; //<! Defines Maximum for number of players. Value 0 : no maximum!
};
}
Modified: code/branches/gamecontent/src/orxonox/infos/GametypeInfo.h
===================================================================
--- code/branches/gamecontent/src/orxonox/infos/GametypeInfo.h 2011-11-09 15:12:35 UTC (rev 8929)
+++ code/branches/gamecontent/src/orxonox/infos/GametypeInfo.h 2011-11-09 15:16:24 UTC (rev 8930)
@@ -118,6 +118,9 @@
inline const std::string& getHUDTemplate() const
{ return this->hudtemplate_; }
+
+ inline unsigned int getNumberOfPlayers() const
+ { return this->spawnedPlayers_.size(); }
void sendAnnounceMessage(const std::string& message);
void sendAnnounceMessage(const std::string& message, unsigned int clientID);
More information about the Orxonox-commit
mailing list