[Orxonox-commit 4285] r8956 - in code/branches/gamecontent: data/levels src/orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Wed Nov 30 17:12:00 CET 2011
Author: jo
Date: 2011-11-30 17:12:00 +0100 (Wed, 30 Nov 2011)
New Revision: 8956
Modified:
code/branches/gamecontent/data/levels/lastTeamStanding.oxw
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
Log:
implementing first player control parameter.
Modified: code/branches/gamecontent/data/levels/lastTeamStanding.oxw
===================================================================
--- code/branches/gamecontent/data/levels/lastTeamStanding.oxw 2011-11-30 15:57:35 UTC (rev 8955)
+++ code/branches/gamecontent/data/levels/lastTeamStanding.oxw 2011-11-30 16:12:00 UTC (rev 8956)
@@ -16,7 +16,7 @@
<Level
name = "Last Team Standing"
description = "testmap for gametype last team standing"
- gametype = "LastTeamStanding"
+ gametype = "TeamGametype"
>
<templates>
<Template link=lodtemplate_default />
Modified: code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc 2011-11-30 15:57:35 UTC (rev 8955)
+++ code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc 2011-11-30 16:12:00 UTC (rev 8956)
@@ -132,7 +132,7 @@
if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
this->gtinfo_->playerReadyToSpawn(it->first);
}
-
+
this->checkStart();
}
else if (!this->gtinfo_->hasEnded())
@@ -439,7 +439,7 @@
if(player->isHumanPlayer())
this->gtinfo_->playerSpawned(player);
-
+
this->playerPostSpawn(player);
}
else
Modified: code/branches/gamecontent/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/Gametype.h 2011-11-30 15:57:35 UTC (rev 8955)
+++ code/branches/gamecontent/src/orxonox/gametypes/Gametype.h 2011-11-30 16:12:00 UTC (rev 8956)
@@ -125,9 +125,6 @@
virtual void addBots(unsigned int amount);
void killBots(unsigned int amount = 0);
- inline unsigned int getNumberOfPlayers() const
- { return this->players_.size(); }
-
virtual void addTime(float t);
virtual void removeTime(float t);
@@ -150,7 +147,7 @@
{ this->timeLimit_ = t; }
//inline bool getForceSpawn()
- // { return this->bForceSpawn_; }
+ // { return this->bForceSpawn_; }
virtual void resetTimer();
virtual void resetTimer(float t);
Modified: code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc 2011-11-30 15:57:35 UTC (rev 8955)
+++ code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc 2011-11-30 16:12:00 UTC (rev 8956)
@@ -45,10 +45,10 @@
{
RegisterObject(TeamGametype);
- this->teams_ = 2;
+ this->teams_ = 2; //most team gametypes use two different teams
this->allowFriendlyFire_ = false;
//this->playersPerTeam_ = 0;
- this->maxPlayers_ = 0;
+ this->maxPlayers_ = 2; //TEST
this->setConfigValues();
}
@@ -77,10 +77,15 @@
Gametype::playerEntered(player);
if(player == NULL) return;
this->findAndSetTeam(player);
- if( getNumberOfPlayers() < maxPlayers_ || maxPlayers_ == 0)
+ if( this->players_.size() <= maxPlayers_ || maxPlayers_ == 0)
+ {
this->allowedInGame_[player]= true;
+ }
else
+ {
this->allowedInGame_[player]= false;
+ orxout() << "not allowed in game: players = " << this->players_.size() << " > maximum: " << maxPlayers_ << endl;
+ }
}
void TeamGametype::findAndSetTeam(PlayerInfo* player)
@@ -109,10 +114,22 @@
bool TeamGametype::playerLeft(PlayerInfo* player)
{
bool valid_player = Gametype::playerLeft(player);
+ if( (this->players_.size() >= maxPlayers_) && (allowedInGame_[player] == true) ) // if there's a "waiting list"
+ {
+ for (std::map<PlayerInfo*, bool>::iterator it = this->allowedInGame_.begin(); it != this->allowedInGame_.end(); ++it)
+ {
+ if(it->second == false) // waiting player found
+ {it->second = true; break;} // allow player to enter
+ }
+ }
if (valid_player)
+ { // clean up the maps
this->teamnumbers_.erase(player);
+ this->allowedInGame_.erase(player);
+ }
+
return valid_player;
}
@@ -120,8 +137,10 @@
{
for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)\
{
- if(true)//check if dead player is allowed to enter -> if maximum nr of players is exceeded & player was not in game before: disallow
- //continue;
+ if(allowedInGame_[it->first] == false)//check if dead player is allowed to enter
+ {
+ continue;
+ }
if (it->second.state_ == PlayerState::Dead)
{
if ((it->first->isReadyToSpawn() || this->bForceSpawn_))
@@ -134,7 +153,7 @@
bool TeamGametype::allowPawnHit(Pawn* victim, Pawn* originator)
- {// hit allowed: if victim & originator are foes or if originator doesnot exist or if friendlyfire is allowed
+ {// 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_);
}
@@ -261,7 +280,7 @@
{
if(pawn == NULL)
return;
-
+
int teamnumber = pawn->getTeam();
if(teamnumber >= 0)
@@ -291,7 +310,7 @@
void TeamGametype::colourPawn(Pawn* pawn, int teamNr)
{// catch no-colouring-case and wrong input
- if(teamNr < 0 || pawn == NULL) return;
+ if(teamNr < 0 || pawn == NULL) return;
pawn->setRadarObjectColour(this->teamcolours_[teamNr]);
std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
Modified: code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h 2011-11-30 15:57:35 UTC (rev 8955)
+++ code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h 2011-11-30 16:12:00 UTC (rev 8956)
@@ -66,12 +66,12 @@
virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
- bool allowFriendlyFire_; //<! friendlyfire is per default switched off: friendlyFire_ = false;
+ bool allowFriendlyFire_; //!< friendlyfire is per default switched off: friendlyFire_ = false;
std::map<PlayerInfo*, int> teamnumbers_;
std::vector<ColourValue> teamcolours_;
- 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!
+ 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!
std::map<PlayerInfo*, bool> allowedInGame_; //!< Only those players are allowed to spawn which are listed here as 'true'.
void setTeamColour(PlayerInfo* player, Pawn* pawn);
void setDefaultObjectColour(Pawn* pawn);
More information about the Orxonox-commit
mailing list