cleaned up dependencies in game/server a bit

This commit is contained in:
oy 2012-02-15 01:39:18 +01:00
parent 5e4caa9b9c
commit 24bda2faa0
19 changed files with 106 additions and 79 deletions

51
src/game/server/alloc.h Normal file
View file

@ -0,0 +1,51 @@
/* (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. */
#ifndef GAME_SERVER_ALLOC_H
#define GAME_SERVER_ALLOC_H
#include <new>
#define MACRO_ALLOC_HEAP() \
public: \
void *operator new(size_t Size) \
{ \
void *p = mem_alloc(Size, 1); \
/*dbg_msg("", "++ %p %d", p, size);*/ \
mem_zero(p, Size); \
return p; \
} \
void operator delete(void *pPtr) \
{ \
/*dbg_msg("", "-- %p", p);*/ \
mem_free(pPtr); \
} \
private:
#define MACRO_ALLOC_POOL_ID() \
public: \
void *operator new(size_t Size, int id); \
void operator delete(void *p); \
private:
#define MACRO_ALLOC_POOL_ID_IMPL(POOLTYPE, PoolSize) \
static char ms_PoolData##POOLTYPE[PoolSize][sizeof(POOLTYPE)] = {{0}}; \
static int ms_PoolUsed##POOLTYPE[PoolSize] = {0}; \
void *POOLTYPE::operator new(size_t Size, int id) \
{ \
dbg_assert(sizeof(POOLTYPE) == Size, "size error"); \
dbg_assert(!ms_PoolUsed##POOLTYPE[id], "already used"); \
/*dbg_msg("pool", "++ %s %d", #POOLTYPE, id);*/ \
ms_PoolUsed##POOLTYPE[id] = 1; \
mem_zero(ms_PoolData##POOLTYPE[id], Size); \
return ms_PoolData##POOLTYPE[id]; \
} \
void POOLTYPE::operator delete(void *p) \
{ \
int id = (POOLTYPE*)p - (POOLTYPE*)ms_PoolData##POOLTYPE; \
dbg_assert(ms_PoolUsed##POOLTYPE[id], "not used"); \
/*dbg_msg("pool", "-- %s %d", #POOLTYPE, id);*/ \
ms_PoolUsed##POOLTYPE[id] = 0; \
mem_zero(ms_PoolData##POOLTYPE[id], sizeof(POOLTYPE)); \
}
#endif

View file

@ -1,9 +1,11 @@
/* (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. */
#include <new>
#include <engine/shared/config.h>
#include <game/generated/server_data.h>
#include <game/server/gamecontext.h>
#include <game/mapitems.h>
#include <game/server/gamecontroller.h>
#include <game/server/player.h>
#include "character.h"
#include "laser.h"

View file

@ -4,17 +4,7 @@
#define GAME_SERVER_ENTITIES_CHARACTER_H
#include <game/server/entity.h>
#include <game/generated/server_data.h>
#include <game/generated/protocol.h>
#include <game/gamecore.h>
enum
{
WEAPON_GAME = -3, // team switching etc
WEAPON_SELF = -2, // console kill command
WEAPON_WORLD = -1, // death tiles etc
};
class CCharacter : public CEntity
{

View file

@ -1,6 +1,8 @@
/* (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. */
#include <game/server/gamecontext.h>
#include "character.h"
#include "flag.h"
CFlag::CFlag(CGameWorld *pGameWorld, int Team)

View file

@ -1,7 +1,8 @@
/* (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. */
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include "character.h"
#include "laser.h"
CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner)

View file

@ -1,7 +1,10 @@
/* (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. */
#include <game/generated/protocol.h>
#include <game/generated/server_data.h>
#include <game/server/gamecontext.h>
#include <game/server/player.h>
#include "character.h"
#include "pickup.h"
CPickup::CPickup(CGameWorld *pGameWorld, int Type, int SubType)

View file

@ -1,7 +1,8 @@
/* (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. */
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include "character.h"
#include "projectile.h"
CProjectile::CProjectile(CGameWorld *pGameWorld, int Type, int Owner, vec2 Pos, vec2 Dir, int Span,

View file

@ -3,6 +3,7 @@
#include "entity.h"
#include "gamecontext.h"
#include "player.h"
//////////////////////////////////////////////////
// Entity

View file

@ -3,52 +3,11 @@
#ifndef GAME_SERVER_ENTITY_H
#define GAME_SERVER_ENTITY_H
#include <new>
#include <base/vmath.h>
#include <game/server/gameworld.h>
#define MACRO_ALLOC_HEAP() \
public: \
void *operator new(size_t Size) \
{ \
void *p = mem_alloc(Size, 1); \
/*dbg_msg("", "++ %p %d", p, size);*/ \
mem_zero(p, Size); \
return p; \
} \
void operator delete(void *pPtr) \
{ \
/*dbg_msg("", "-- %p", p);*/ \
mem_free(pPtr); \
} \
private:
#define MACRO_ALLOC_POOL_ID() \
public: \
void *operator new(size_t Size, int id); \
void operator delete(void *p); \
private:
#define MACRO_ALLOC_POOL_ID_IMPL(POOLTYPE, PoolSize) \
static char ms_PoolData##POOLTYPE[PoolSize][sizeof(POOLTYPE)] = {{0}}; \
static int ms_PoolUsed##POOLTYPE[PoolSize] = {0}; \
void *POOLTYPE::operator new(size_t Size, int id) \
{ \
dbg_assert(sizeof(POOLTYPE) == Size, "size error"); \
dbg_assert(!ms_PoolUsed##POOLTYPE[id], "already used"); \
/*dbg_msg("pool", "++ %s %d", #POOLTYPE, id);*/ \
ms_PoolUsed##POOLTYPE[id] = 1; \
mem_zero(ms_PoolData##POOLTYPE[id], Size); \
return ms_PoolData##POOLTYPE[id]; \
} \
void POOLTYPE::operator delete(void *p) \
{ \
int id = (POOLTYPE*)p - (POOLTYPE*)ms_PoolData##POOLTYPE; \
dbg_assert(ms_PoolUsed##POOLTYPE[id], "not used"); \
/*dbg_msg("pool", "-- %s %d", #POOLTYPE, id);*/ \
ms_PoolUsed##POOLTYPE[id] = 0; \
mem_zero(ms_PoolData##POOLTYPE[id], sizeof(POOLTYPE)); \
}
#include "alloc.h"
/*
Class: Entity

View file

@ -2,6 +2,7 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include "eventhandler.h"
#include "gamecontext.h"
#include "player.h"
//////////////////////////////////////////////////
// Event handler

View file

@ -1,18 +1,22 @@
/* (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. */
#include <new>
#include <base/math.h>
#include <engine/shared/config.h>
#include <engine/shared/memheap.h>
#include <engine/map.h>
#include <engine/console.h>
#include "gamecontext.h"
#include <game/version.h>
#include <game/collision.h>
#include <game/gamecore.h>
#include "gamemodes/dm.h"
#include "gamemodes/tdm.h"
#include <game/version.h>
#include "entities/character.h"
#include "gamemodes/ctf.h"
#include "gamemodes/dm.h"
#include "gamemodes/mod.h"
#include "gamemodes/tdm.h"
#include "gamecontext.h"
#include "player.h"
enum
{

View file

@ -3,17 +3,14 @@
#ifndef GAME_SERVER_GAMECONTEXT_H
#define GAME_SERVER_GAMECONTEXT_H
#include <engine/server.h>
#include <engine/console.h>
#include <engine/shared/memheap.h>
#include <engine/server.h>
#include <game/layers.h>
#include <game/voting.h>
#include "eventhandler.h"
#include "gamecontroller.h"
#include "gameworld.h"
#include "player.h"
/*
Tick
@ -81,9 +78,9 @@ public:
void Clear();
CEventHandler m_Events;
CPlayer *m_apPlayers[MAX_CLIENTS];
class CPlayer *m_apPlayers[MAX_CLIENTS];
IGameController *m_pController;
class IGameController *m_pController;
CGameWorld m_World;
// helper functions
@ -113,7 +110,7 @@ public:
VOTE_ENFORCE_NO,
VOTE_ENFORCE_YES,
};
CHeap *m_pVoteOptionHeap;
class CHeap *m_pVoteOptionHeap;
CVoteOptionServer *m_pVoteOptionFirst;
CVoteOptionServer *m_pVoteOptionLast;

View file

@ -4,9 +4,11 @@
#include <game/mapitems.h>
#include "entities/character.h"
#include "entities/pickup.h"
#include "gamecontroller.h"
#include "gamecontext.h"
#include "gamecontroller.h"
#include "player.h"
IGameController::IGameController(CGameContext *pGameServer)

View file

@ -4,6 +4,7 @@
#define GAME_SERVER_GAMECONTROLLER_H
#include <base/vmath.h>
#include <game/generated/protocol.h>
/*

View file

@ -6,8 +6,8 @@
#include <game/server/entities/character.h>
#include <game/server/entities/flag.h>
#include <game/server/player.h>
#include <game/server/gamecontext.h>
#include <game/server/player.h>
#include "ctf.h"
CGameControllerCTF::CGameControllerCTF(CGameContext *pGameServer)

View file

@ -3,6 +3,7 @@
#include <engine/shared/config.h>
#include <game/server/entities/character.h>
#include <game/server/gamecontext.h>
#include <game/server/player.h>
#include "tdm.h"

View file

@ -1,9 +1,12 @@
/* (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. */
#include "gameworld.h"
#include "entities/character.h"
#include "entity.h"
#include "gamecontext.h"
#include "gamecontroller.h"
#include "gameworld.h"
//////////////////////////////////////////////////
// game world

View file

@ -1,7 +1,9 @@
/* (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. */
#include <new>
#include <engine/shared/config.h>
#include "entities/character.h"
#include "gamecontext.h"
#include "gamecontroller.h"
#include "player.h"

View file

@ -3,9 +3,15 @@
#ifndef GAME_SERVER_PLAYER_H
#define GAME_SERVER_PLAYER_H
// this include should perhaps be removed
#include "entities/character.h"
#include "gamecontext.h"
#include "alloc.h"
enum
{
WEAPON_GAME = -3, // team switching etc
WEAPON_SELF = -2, // console kill command
WEAPON_WORLD = -1, // death tiles etc
};
// player object
class CPlayer