Organize game-server includes

This commit is contained in:
Robert Müller 2022-06-17 19:54:10 +02:00
parent 2add5d5c3c
commit 352734de56
20 changed files with 64 additions and 30 deletions

View file

@ -8,6 +8,7 @@
#include "entities/character.h" #include "entities/character.h"
#include "player.h" #include "player.h"
#include "score.h"
bool CheckClientID(int ClientID); bool CheckClientID(int ClientID);

View file

@ -1,5 +1,8 @@
/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */ /* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
#include "gamecontext.h" #include "gamecontext.h"
#include <engine/antibot.h>
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <game/server/entities/character.h> #include <game/server/entities/character.h>
#include <game/server/gamemodes/DDRace.h> #include <game/server/gamemodes/DDRace.h>

View file

@ -1,10 +1,14 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* (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. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <antibot/antibot_data.h> #include <antibot/antibot_data.h>
#include <engine/antibot.h>
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <game/generated/server_data.h> #include <game/generated/server_data.h>
#include <game/mapitems.h> #include <game/mapitems.h>
#include <game/server/gamecontext.h> #include <game/server/gamecontext.h>
#include <game/server/gamecontroller.h>
#include <game/server/player.h> #include <game/server/player.h>
#include "character.h" #include "character.h"

View file

@ -3,12 +3,12 @@
#ifndef GAME_SERVER_ENTITIES_CHARACTER_H #ifndef GAME_SERVER_ENTITIES_CHARACTER_H
#define GAME_SERVER_ENTITIES_CHARACTER_H #define GAME_SERVER_ENTITIES_CHARACTER_H
#include <engine/antibot.h>
#include <game/server/entity.h> #include <game/server/entity.h>
#include <game/server/save.h> #include <game/server/save.h>
class CAntibot;
class CGameTeams; class CGameTeams;
class CGameWorld;
class IAntibot;
struct CAntibotCharacterData; struct CAntibotCharacterData;
enum enum

View file

@ -4,7 +4,7 @@
#include <game/server/entity.h> #include <game/server/entity.h>
class CTrigger; class CGameWorld;
class CDoor : public CEntity class CDoor : public CEntity
{ {

View file

@ -2,9 +2,11 @@
#ifndef GAME_SERVER_ENTITIES_DRAGGER_BEAM_H #ifndef GAME_SERVER_ENTITIES_DRAGGER_BEAM_H
#define GAME_SERVER_ENTITIES_DRAGGER_BEAM_H #define GAME_SERVER_ENTITIES_DRAGGER_BEAM_H
#include "dragger.h"
#include <game/server/entity.h> #include <game/server/entity.h>
class CDragger;
class CGameWorld;
/** /**
* Dragger beams pull a selected player towards their center * Dragger beams pull a selected player towards their center
* *

View file

@ -6,10 +6,10 @@
#include <base/vmath.h> #include <base/vmath.h>
#include "alloc.h" #include "alloc.h"
#include "gamecontext.h"
#include "gameworld.h" #include "gameworld.h"
class CCollision; class CCollision;
class CGameContext;
/* /*
Class: Entity Class: Entity
@ -20,12 +20,12 @@ class CEntity
MACRO_ALLOC_HEAP() MACRO_ALLOC_HEAP()
private: private:
friend class CGameWorld; // entity list handling friend CGameWorld; // entity list handling
CEntity *m_pPrevTypeEntity; CEntity *m_pPrevTypeEntity;
CEntity *m_pNextTypeEntity; CEntity *m_pNextTypeEntity;
/* Identity */ /* Identity */
class CGameWorld *m_pGameWorld; CGameWorld *m_pGameWorld;
CCollision *m_pCCollision; CCollision *m_pCCollision;
int m_ID; int m_ID;
@ -59,7 +59,7 @@ public: // TODO: Maybe make protected
/* Objects */ /* Objects */
std::vector<SSwitchers> &Switchers() { return m_pGameWorld->m_Core.m_vSwitchers; } std::vector<SSwitchers> &Switchers() { return m_pGameWorld->m_Core.m_vSwitchers; }
class CGameWorld *GameWorld() { return m_pGameWorld; } CGameWorld *GameWorld() { return m_pGameWorld; }
class CConfig *Config() { return m_pGameWorld->Config(); } class CConfig *Config() { return m_pGameWorld->Config(); }
class CGameContext *GameServer() { return m_pGameWorld->GameServer(); } class CGameContext *GameServer() { return m_pGameWorld->GameServer(); }
class IServer *Server() { return m_pGameWorld->Server(); } class IServer *Server() { return m_pGameWorld->Server(); }

View file

@ -3,7 +3,6 @@
#ifndef GAME_SERVER_GAMECONTEXT_H #ifndef GAME_SERVER_GAMECONTEXT_H
#define GAME_SERVER_GAMECONTEXT_H #define GAME_SERVER_GAMECONTEXT_H
#include <engine/antibot.h>
#include <engine/console.h> #include <engine/console.h>
#include <engine/server.h> #include <engine/server.h>
@ -47,15 +46,17 @@ enum
NUM_TUNEZONES = 256 NUM_TUNEZONES = 256
}; };
class CCharacter;
class CConfig; class CConfig;
class CHeap; class CHeap;
class CPlayer; class CPlayer;
class CScore; class CScore;
class IConsole; class CUnpacker;
class IAntibot;
class IGameController; class IGameController;
class IEngine; class IEngine;
class IStorage; class IStorage;
struct CAntibotData; struct CAntibotRoundData;
struct CScoreRandomMapResult; struct CScoreRandomMapResult;
class CGameContext : public IGameServer class CGameContext : public IGameServer
@ -305,7 +306,7 @@ private:
// starting 1 to make 0 the special value "no client id" // starting 1 to make 0 the special value "no client id"
uint32_t NextUniqueClientID = 1; uint32_t NextUniqueClientID = 1;
bool m_VoteWillPass; bool m_VoteWillPass;
class CScore *m_pScore; CScore *m_pScore;
//DDRace Console Commands //DDRace Console Commands
@ -446,7 +447,7 @@ private:
public: public:
CLayers *Layers() { return &m_Layers; } CLayers *Layers() { return &m_Layers; }
class CScore *Score() { return m_pScore; } CScore *Score() { return m_pScore; }
enum enum
{ {

View file

@ -8,6 +8,7 @@
#include <game/server/entities/character.h> #include <game/server/entities/character.h>
#include <game/server/gamecontext.h> #include <game/server/gamecontext.h>
#include <game/server/player.h> #include <game/server/player.h>
#include <game/server/score.h>
#include <game/version.h> #include <game/version.h>
#define GAME_TYPE_NAME "DDraceNetwork" #define GAME_TYPE_NAME "DDraceNetwork"

View file

@ -5,9 +5,12 @@
#include "entities/character.h" #include "entities/character.h"
#include "entity.h" #include "entity.h"
#include "gamecontext.h" #include "gamecontext.h"
#include "gamecontroller.h"
#include "player.h" #include "player.h"
#include <algorithm>
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <algorithm>
#include <utility> #include <utility>
////////////////////////////////////////////////// //////////////////////////////////////////////////

View file

@ -88,8 +88,8 @@ public:
Returns: Returns:
Returns a pointer to the closest hit or NULL of there is no intersection. Returns a pointer to the closest hit or NULL of there is no intersection.
*/ */
//class CCharacter *IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis = 0); //CCharacter *IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis = 0);
class CCharacter *IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CCharacter *pNotThis = 0, int CollideWith = -1, class CCharacter *pThisOnly = 0); CCharacter *IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, CCharacter *pNotThis = 0, int CollideWith = -1, CCharacter *pThisOnly = 0);
/* /*
Function: ClosestCharacter Function: ClosestCharacter
Finds the closest CCharacter to a specific point. Finds the closest CCharacter to a specific point.
@ -102,7 +102,7 @@ public:
Returns: Returns:
Returns a pointer to the closest CCharacter or NULL if no CCharacter is close enough. Returns a pointer to the closest CCharacter or NULL if no CCharacter is close enough.
*/ */
class CCharacter *ClosestCharacter(vec2 Pos, float Radius, CEntity *ppNotThis); CCharacter *ClosestCharacter(vec2 Pos, float Radius, CEntity *ppNotThis);
/* /*
Function: InsertEntity Function: InsertEntity
@ -163,7 +163,7 @@ public:
Returns: Returns:
Returns list with all Characters on line. Returns list with all Characters on line.
*/ */
std::list<class CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis = 0); std::list<CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis = 0);
}; };
#endif #endif

View file

@ -3,10 +3,14 @@
#include "player.h" #include "player.h"
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <engine/antibot.h>
#include <engine/server.h>
#include "base/system.h" #include "base/system.h"
#include "entities/character.h" #include "entities/character.h"
#include "gamecontext.h" #include "gamecontext.h"
#include <engine/server.h> #include "gamecontroller.h"
#include "score.h"
#include <game/gamecore.h> #include <game/gamecore.h>
#include <game/teamscore.h> #include <game/teamscore.h>

View file

@ -3,12 +3,21 @@
#ifndef GAME_SERVER_PLAYER_H #ifndef GAME_SERVER_PLAYER_H
#define GAME_SERVER_PLAYER_H #define GAME_SERVER_PLAYER_H
#include "alloc.h" #include <base/vmath.h>
// this include should perhaps be removed #include <engine/shared/protocol.h>
#include "score.h"
#include "alloc.h"
#include "teeinfo.h" #include "teeinfo.h"
#include <memory>
class CCharacter;
class CGameContext;
class IServer;
struct CNetObj_PlayerInput;
struct CScorePlayerResult;
enum enum
{ {
WEAPON_GAME = -3, // team switching etc WEAPON_GAME = -3, // team switching etc

View file

@ -1,9 +1,10 @@
#ifndef GAME_SERVER_SAVE_H #ifndef GAME_SERVER_SAVE_H
#define GAME_SERVER_SAVE_H #define GAME_SERVER_SAVE_H
#include <base/vmath.h>
#include <engine/shared/protocol.h> #include <engine/shared/protocol.h>
#include <game/generated/protocol.h> #include <game/generated/protocol.h>
#include <game/server/gamecontroller.h>
class IGameController; class IGameController;
class CGameContext; class CGameContext;

View file

@ -5,7 +5,6 @@
#include "scoreworker.h" #include "scoreworker.h"
#include <base/system.h> #include <base/system.h>
#include <engine/server/databases/connection.h>
#include <engine/server/databases/connection_pool.h> #include <engine/server/databases/connection_pool.h>
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <engine/shared/console.h> #include <engine/shared/console.h>
@ -13,9 +12,10 @@
#include <engine/storage.h> #include <engine/storage.h>
#include <game/generated/wordlist.h> #include <game/generated/wordlist.h>
#include <algorithm>
#include <memory> #include <memory>
class IDbConnection;
std::shared_ptr<CScorePlayerResult> CScore::NewSqlPlayerResult(int ClientID) std::shared_ptr<CScorePlayerResult> CScore::NewSqlPlayerResult(int ClientID)
{ {
CPlayer *pCurPlayer = GameServer()->m_apPlayers[ClientID]; CPlayer *pCurPlayer = GameServer()->m_apPlayers[ClientID];

View file

@ -1,13 +1,15 @@
#ifndef GAME_SERVER_SCORE_H #ifndef GAME_SERVER_SCORE_H
#define GAME_SERVER_SCORE_H #define GAME_SERVER_SCORE_H
#include <engine/server/databases/connection_pool.h>
#include <game/prng.h> #include <game/prng.h>
#include "save.h"
#include "scoreworker.h" #include "scoreworker.h"
class CDbConnectionPool;
class CGameContext; class CGameContext;
class IDbConnection;
class IServer;
struct ISqlData;
class CScore class CScore
{ {

View file

@ -14,7 +14,7 @@
#include <game/voting.h> #include <game/voting.h>
class IDbConnection; class IDbConnection;
class IServer; class IGameController;
enum enum
{ {

View file

@ -1,6 +1,7 @@
/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */ /* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
#include "teams.h" #include "teams.h"
#include "entities/character.h" #include "entities/character.h"
#include "gamecontroller.h"
#include "player.h" #include "player.h"
#include "score.h" #include "score.h"
#include "teehistorian.h" #include "teehistorian.h"

View file

@ -4,9 +4,12 @@
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <game/server/gamecontext.h> #include <game/server/gamecontext.h>
#include <game/server/scoreworker.h>
#include <game/teamscore.h> #include <game/teamscore.h>
class CCharacter;
class CPlayer;
struct CScoreSaveResult;
class CGameTeams class CGameTeams
{ {
// `m_TeeStarted` is used to keep track whether a given tee has hit the // `m_TeeStarted` is used to keep track whether a given tee has hit the

View file

@ -11,7 +11,6 @@
class CConfig; class CConfig;
class CTuningParams; class CTuningParams;
class CUuidManager; class CUuidManager;
class CPlayer;
class CTeeHistorian class CTeeHistorian
{ {