Emergency 20 Dokumentation  4.2.0
PlayerManager-inl.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Namespace ]
6 //[-------------------------------------------------------]
7 namespace em5
8 {
9 
10 
11  //[-------------------------------------------------------]
12  //[ Public static methods ]
13  //[-------------------------------------------------------]
15  {
16  return mLocalPlayer;
17  }
18 
20  {
21  QSF_CHECK(nullptr != mLocalPlayer, "Local player instance is invalid", QSF_REACT_THROW);
22  return *mLocalPlayer;
23  }
24 
25 
26  //[-------------------------------------------------------]
27  //[ Public methods ]
28  //[-------------------------------------------------------]
30  mWasDeserialized(false)
31  {
32  // Nothing here
33  }
34 
36  {
37  // Nothing here
38  }
39 
40  inline Player* PlayerManager::getPlayerByIndex(uint32 playerIndex) const
41  {
42  // Is the player in the list?
43  PlayerMap::const_iterator iterator = mPlayers.find(playerIndex);
44  if (iterator != mPlayers.end())
45  {
46  // Found him
47  return iterator->second;
48  }
49  else
50  {
51  // None found
52  return nullptr;
53  }
54  }
55 
57  {
58  return mPlayerList;
59  }
60 
61 
62 //[-------------------------------------------------------]
63 //[ Namespace ]
64 //[-------------------------------------------------------]
65 } // em5
Definition: ActionPriority.h:13
unsigned int uint32
Definition: PlatformTypes.h:181
#define QSF_REACT_THROW
Definition: ErrorHandling.h:203
virtual ~PlayerManager()
Destructor.
Definition: PlayerManager-inl.h:35
EMERGENCY 5 player class.
Definition: Player.h:57
PlayerManager()
Constructor.
Definition: PlayerManager-inl.h:29
Player * getPlayerByIndex(uint32 playerIndex) const
Return a player by his index, or null pointer of there is none with this index.
Definition: PlayerManager-inl.h:40
static Player * getLocalPlayer()
Return the instance of the local player.
Definition: PlayerManager-inl.h:14
std::vector< Player * > PlayerList
Holds a list of players (no special ordering guaranteed)
Definition: PlayerManager.h:54
static Player & getLocalPlayerSafe()
Return the instance of the local player.
Definition: PlayerManager-inl.h:19
const PlayerList & getAllPlayers() const
Return a list of all players.
Definition: PlayerManager-inl.h:56
#define QSF_CHECK(condition, explanation, reaction)
Definition: ErrorHandling.h:126