1 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2 /* If you are missing that file, acquire a complete release at teeworlds.com. */
3 #ifndef GAME_SERVER_GAMECONTROLLER_H
4 #define GAME_SERVER_GAMECONTROLLER_H
6 #include <base/vmath.h>
10 Controls the main game logic. Keeping track of team and player score,
11 winning conditions and specific game logic.
15 vec2 m_aaSpawnPoints
[3][64];
16 int m_aNumSpawnPoints
[3];
18 class CGameContext
*m_pGameServer
;
19 class IServer
*m_pServer
;
22 CGameContext
*GameServer() const { return m_pGameServer
; }
23 IServer
*Server() const { return m_pServer
; }
31 m_Pos
= vec2(100,100);
40 float EvaluateSpawnPos(CSpawnEval
*pEval
, vec2 Pos
);
41 void EvaluateSpawnType(CSpawnEval
*pEval
, int Type
);
42 bool EvaluateSpawn(class CPlayer
*pP
, vec2
*pPos
);
64 const char *m_pGameType
;
66 bool IsTeamplay() const;
68 IGameController(class CGameContext
*pGameServer
);
69 virtual ~IGameController();
71 virtual void DoWincheck();
73 void DoWarmup(int Seconds
);
77 void ChangeMap(const char *pToMap
);
79 bool IsFriendlyFire(int ClientID1
, int ClientID2
);
81 bool IsForceBalanced();
86 virtual bool CanBeMovedOnBalance(int ClientID
);
90 virtual void Snap(int SnappingClient
);
94 Called when the map is loaded to process an entity
99 pos - Where the entity is located in the world.
104 virtual bool OnEntity(int Index
, vec2 Pos
);
107 Function: on_CCharacter_spawn
108 Called when a CCharacter spawns into the game world.
111 chr - The CCharacter that was spawned.
113 virtual void OnCharacterSpawn(class CCharacter
*pChr
);
116 Function: on_CCharacter_death
117 Called when a CCharacter in the world dies.
120 victim - The CCharacter that died.
121 killer - The player that killed it.
122 weapon - What weapon that killed it. Can be -1 for undefined
123 weapon when switching team or player suicides.
125 virtual int OnCharacterDeath(class CCharacter
*pVictim
, class CPlayer
*pKiller
, int Weapon
);
128 virtual void OnPlayerInfoChange(class CPlayer
*pP
);
131 virtual bool CanSpawn(int Team
, vec2
*pPos
);
136 virtual const char *GetTeamName(int Team
);
137 virtual int GetAutoTeam(int NotThisID
);
138 virtual bool CanJoinTeam(int Team
, int NotThisID
);
139 bool CheckTeamBalance();
140 bool CanChangeTeam(CPlayer
*pPplayer
, int JoinTeam
);
141 int ClampTeam(int Team
);
143 virtual void PostReset();