2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_SERVER_GAMECONTROLLER_H
|
|
|
|
#define GAME_SERVER_GAMECONTROLLER_H
|
|
|
|
|
|
|
|
#include <base/vmath.h>
|
|
|
|
|
2010-08-11 18:29:08 +00:00
|
|
|
class CDoor;
|
2018-05-29 09:38:52 +00:00
|
|
|
#if !defined(_MSC_VER) || _MSC_VER >= 1600
|
|
|
|
#include <cstdint>
|
|
|
|
#else
|
2013-12-31 05:13:57 +00:00
|
|
|
typedef __int32 int32_t;
|
|
|
|
typedef unsigned __int32 uint32_t;
|
|
|
|
typedef __int64 int64_t;
|
|
|
|
typedef unsigned __int64 uint64_t;
|
|
|
|
#endif
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
/*
|
|
|
|
Class: Game Controller
|
|
|
|
Controls the main game logic. Keeping track of team and player score,
|
|
|
|
winning conditions and specific game logic.
|
|
|
|
*/
|
|
|
|
class IGameController
|
|
|
|
{
|
2018-02-04 15:00:47 +00:00
|
|
|
friend class CSaveTeam; // need access to GameServer() and Server()
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
vec2 m_aaSpawnPoints[3][64];
|
|
|
|
int m_aNumSpawnPoints[3];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CGameContext *m_pGameServer;
|
|
|
|
class IServer *m_pServer;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
protected:
|
|
|
|
CGameContext *GameServer() const { return m_pGameServer; }
|
|
|
|
IServer *Server() const { return m_pServer; }
|
|
|
|
|
|
|
|
struct CSpawnEval
|
|
|
|
{
|
|
|
|
CSpawnEval()
|
|
|
|
{
|
|
|
|
m_Got = false;
|
|
|
|
m_FriendlyTeam = -1;
|
|
|
|
m_Pos = vec2(100,100);
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
vec2 m_Pos;
|
|
|
|
bool m_Got;
|
|
|
|
int m_FriendlyTeam;
|
|
|
|
float m_Score;
|
|
|
|
};
|
|
|
|
|
|
|
|
float EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos);
|
|
|
|
void EvaluateSpawnType(CSpawnEval *pEval, int Type);
|
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
//void CycleMap();
|
2010-05-29 07:25:38 +00:00
|
|
|
void ResetGame();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
char m_aMapWish[128];
|
|
|
|
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_RoundStartTick;
|
|
|
|
int m_GameOverTick;
|
|
|
|
int m_SuddenDeath;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
//int m_aTeamscore[2];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_Warmup;
|
|
|
|
int m_RoundCount;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_GameFlags;
|
|
|
|
int m_UnbalancedTick;
|
|
|
|
bool m_ForceBalanced;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
const char *m_pGameType;
|
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
//bool IsTeamplay() const;
|
2012-04-12 00:09:31 +00:00
|
|
|
//bool IsGameOver() const { return m_GameOverTick != -1; }
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
IGameController(class CGameContext *pGameServer);
|
|
|
|
virtual ~IGameController();
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
// virtual void DoWincheck();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void DoWarmup(int Seconds);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void StartRound();
|
|
|
|
void EndRound();
|
|
|
|
void ChangeMap(const char *pToMap);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-02-12 10:40:36 +00:00
|
|
|
bool IsFriendlyFire(int ClientID1, int ClientID2);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool IsForceBalanced();
|
|
|
|
|
|
|
|
/*
|
2011-04-13 18:37:12 +00:00
|
|
|
|
|
|
|
*/
|
2011-02-12 10:40:36 +00:00
|
|
|
virtual bool CanBeMovedOnBalance(int ClientID);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
virtual void Tick();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Snap(int SnappingClient);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
/*
|
|
|
|
Function: on_entity
|
|
|
|
Called when the map is loaded to process an entity
|
|
|
|
in the map.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Arguments:
|
|
|
|
index - Entity index.
|
|
|
|
pos - Where the entity is located in the world.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Returns:
|
|
|
|
bool?
|
|
|
|
*/
|
2011-04-09 06:41:31 +00:00
|
|
|
//virtual bool OnEntity(int Index, vec2 Pos);
|
2010-11-13 13:22:19 +00:00
|
|
|
virtual bool OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Number = 0);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
/*
|
|
|
|
Function: on_CCharacter_spawn
|
|
|
|
Called when a CCharacter spawns into the game world.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Arguments:
|
|
|
|
chr - The CCharacter that was spawned.
|
|
|
|
*/
|
|
|
|
virtual void OnCharacterSpawn(class CCharacter *pChr);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
/*
|
|
|
|
Function: on_CCharacter_death
|
|
|
|
Called when a CCharacter in the world dies.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Arguments:
|
|
|
|
victim - The CCharacter that died.
|
|
|
|
killer - The player that killed it.
|
|
|
|
weapon - What weapon that killed it. Can be -1 for undefined
|
|
|
|
weapon when switching team or player suicides.
|
|
|
|
*/
|
|
|
|
virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon);
|
|
|
|
|
|
|
|
|
2011-04-09 20:45:34 +00:00
|
|
|
//virtual void OnPlayerInfoChange(class CPlayer *pP);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
//
|
2011-02-14 07:43:44 +00:00
|
|
|
virtual bool CanSpawn(int Team, vec2 *pPos);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
/*
|
2011-04-13 18:37:12 +00:00
|
|
|
|
|
|
|
*/
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual const char *GetTeamName(int Team);
|
2011-02-12 10:40:36 +00:00
|
|
|
virtual int GetAutoTeam(int NotThisID);
|
|
|
|
virtual bool CanJoinTeam(int Team, int NotThisID);
|
2010-07-29 05:21:18 +00:00
|
|
|
//bool CheckTeamBalance();
|
|
|
|
//bool CanChangeTeam(CPlayer *pPplayer, int JoinTeam);
|
2010-05-29 07:25:38 +00:00
|
|
|
int ClampTeam(int Team);
|
|
|
|
|
|
|
|
virtual void PostReset();
|
2011-01-29 00:59:50 +00:00
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
// DDRace
|
|
|
|
|
2011-01-29 00:59:50 +00:00
|
|
|
float m_CurrentRecord;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2011-02-14 07:43:44 +00:00
|
|
|
#endif
|