fixed editor zooming if gui is not active
[twcon.git] / src / game / server / gamecontroller.h
blob4706df4864fde76084edbf7a4bdba94bed7b8657
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>
8 /*
9 Class: Game Controller
10 Controls the main game logic. Keeping track of team and player score,
11 winning conditions and specific game logic.
13 class IGameController
15 vec2 m_aaSpawnPoints[3][64];
16 int m_aNumSpawnPoints[3];
18 class CGameContext *m_pGameServer;
19 class IServer *m_pServer;
21 protected:
22 CGameContext *GameServer() const { return m_pGameServer; }
23 IServer *Server() const { return m_pServer; }
25 struct CSpawnEval
27 CSpawnEval()
29 m_Got = false;
30 m_FriendlyTeam = -1;
31 m_Pos = vec2(100,100);
34 vec2 m_Pos;
35 bool m_Got;
36 int m_FriendlyTeam;
37 float m_Score;
40 float EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos);
41 void EvaluateSpawnType(CSpawnEval *pEval, int Type);
42 bool EvaluateSpawn(class CPlayer *pP, vec2 *pPos);
44 void CycleMap();
45 void ResetGame();
47 char m_aMapWish[128];
50 int m_RoundStartTick;
51 int m_GameOverTick;
52 int m_SuddenDeath;
54 int m_aTeamscore[2];
56 int m_Warmup;
57 int m_RoundCount;
59 int m_GameFlags;
60 int m_UnbalancedTick;
61 bool m_ForceBalanced;
63 public:
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);
75 void StartRound();
76 void EndRound();
77 void ChangeMap(const char *pToMap);
79 bool IsFriendlyFire(int ClientID1, int ClientID2);
81 bool IsForceBalanced();
86 virtual bool CanBeMovedOnBalance(int ClientID);
88 virtual void Tick();
90 virtual void Snap(int SnappingClient);
93 Function: on_entity
94 Called when the map is loaded to process an entity
95 in the map.
97 Arguments:
98 index - Entity index.
99 pos - Where the entity is located in the world.
101 Returns:
102 bool?
104 virtual bool OnEntity(int Index, vec2 Pos);
107 Function: on_CCharacter_spawn
108 Called when a CCharacter spawns into the game world.
110 Arguments:
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.
119 Arguments:
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();
146 #endif