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. */
|
2008-08-14 18:42:47 +00:00
|
|
|
#ifndef GAME_SERVER_GAMEWORLD_H
|
|
|
|
#define GAME_SERVER_GAMEWORLD_H
|
2008-08-14 18:25:44 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/gamecore.h>
|
2008-08-14 18:42:47 +00:00
|
|
|
|
2010-08-31 11:01:46 +00:00
|
|
|
#include <list>
|
2008-08-14 18:42:47 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CEntity;
|
|
|
|
class CCharacter;
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Class: Game World
|
|
|
|
Tracks all entities in the game. Propagates tick and
|
|
|
|
snap calls to all entities.
|
|
|
|
*/
|
2010-05-29 07:25:38 +00:00
|
|
|
class CGameWorld
|
2008-08-14 18:25:44 +00:00
|
|
|
{
|
2011-01-19 17:27:50 +00:00
|
|
|
public:
|
2008-08-14 18:25:44 +00:00
|
|
|
enum
|
|
|
|
{
|
2011-01-19 17:27:50 +00:00
|
|
|
ENTTYPE_PROJECTILE = 0,
|
|
|
|
ENTTYPE_LASER,
|
|
|
|
ENTTYPE_PICKUP,
|
|
|
|
ENTTYPE_FLAG,
|
|
|
|
ENTTYPE_CHARACTER,
|
|
|
|
NUM_ENTTYPES
|
2008-08-14 18:25:44 +00:00
|
|
|
};
|
|
|
|
|
2011-01-19 17:27:50 +00:00
|
|
|
private:
|
|
|
|
void Reset();
|
|
|
|
void RemoveEntities();
|
|
|
|
|
2011-01-19 14:31:42 +00:00
|
|
|
CEntity *m_pNextTraverseEntity;
|
2011-01-19 17:27:50 +00:00
|
|
|
CEntity *m_apFirstEntityTypes[NUM_ENTTYPES];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CGameContext *m_pGameServer;
|
2021-01-10 12:47:07 +00:00
|
|
|
class CConfig *m_pConfig;
|
2010-05-29 07:25:38 +00:00
|
|
|
class IServer *m_pServer;
|
2008-08-14 18:25:44 +00:00
|
|
|
|
2013-12-31 05:13:57 +00:00
|
|
|
void UpdatePlayerMaps();
|
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
public:
|
2010-05-29 07:25:38 +00:00
|
|
|
class CGameContext *GameServer() { return m_pGameServer; }
|
2021-01-10 12:47:07 +00:00
|
|
|
class CConfig *Config() { return m_pConfig; }
|
2010-05-29 07:25:38 +00:00
|
|
|
class IServer *Server() { return m_pServer; }
|
|
|
|
|
|
|
|
bool m_ResetRequested;
|
|
|
|
bool m_Paused;
|
|
|
|
CWorldCore m_Core;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CGameWorld();
|
|
|
|
~CGameWorld();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void SetGameServer(CGameContext *pGameServer);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CEntity *FindFirst(int Type);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
/*
|
|
|
|
Function: find_entities
|
|
|
|
Finds entities close to a position and returns them in a list.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Arguments:
|
|
|
|
pos - Position.
|
|
|
|
radius - How close the entities have to be.
|
|
|
|
ents - Pointer to a list that should be filled with the pointers
|
|
|
|
to the entities.
|
|
|
|
max - Number of entities that fits into the ents array.
|
2011-01-19 17:27:50 +00:00
|
|
|
type - Type of the entities to find.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Returns:
|
|
|
|
Number of entities found and added to the ents array.
|
|
|
|
*/
|
2011-01-19 17:27:50 +00:00
|
|
|
int FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, int Type);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
/*
|
2010-08-31 13:19:01 +00:00
|
|
|
Function: InterserctCharacters
|
|
|
|
Finds the CCharacters that intersects the line. // made for types lasers=1 and doors=0
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Arguments:
|
|
|
|
pos0 - Start position
|
|
|
|
pos2 - End position
|
2010-05-29 07:25:38 +00:00
|
|
|
radius - How for from the line the CCharacter is allowed to be.
|
2008-08-14 18:25:44 +00:00
|
|
|
new_pos - Intersection position
|
|
|
|
notthis - Entity to ignore intersecting with
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Returns:
|
|
|
|
Returns a pointer to the closest hit or NULL of there is no intersection.
|
|
|
|
*/
|
2011-04-09 06:41:31 +00:00
|
|
|
//class CCharacter *IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis = 0);
|
2011-03-19 20:21:42 +00:00
|
|
|
class CCharacter *IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CCharacter *pNotThis = 0, int CollideWith = -1, class CCharacter *pThisOnly = 0);
|
2008-08-14 18:25:44 +00:00
|
|
|
/*
|
2010-05-29 07:25:38 +00:00
|
|
|
Function: closest_CCharacter
|
|
|
|
Finds the closest CCharacter to a specific point.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Arguments:
|
|
|
|
pos - The center position.
|
2010-05-29 07:25:38 +00:00
|
|
|
radius - How far off the CCharacter is allowed to be
|
2008-08-14 18:25:44 +00:00
|
|
|
notthis - Entity to ignore
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Returns:
|
2010-05-29 07:25:38 +00:00
|
|
|
Returns a pointer to the closest CCharacter or NULL if no CCharacter is close enough.
|
2008-08-14 18:25:44 +00:00
|
|
|
*/
|
2010-05-29 07:25:38 +00:00
|
|
|
class CCharacter *ClosestCharacter(vec2 Pos, float Radius, CEntity *ppNotThis);
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: insert_entity
|
|
|
|
Adds an entity to the world.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Arguments:
|
|
|
|
entity - Entity to add
|
|
|
|
*/
|
2010-05-29 07:25:38 +00:00
|
|
|
void InsertEntity(CEntity *pEntity);
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: remove_entity
|
|
|
|
Removes an entity from the world.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Arguments:
|
|
|
|
entity - Entity to remove
|
|
|
|
*/
|
2010-05-29 07:25:38 +00:00
|
|
|
void RemoveEntity(CEntity *pEntity);
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: snap
|
|
|
|
Calls snap on all the entities in the world to create
|
|
|
|
the snapshot.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
Arguments:
|
|
|
|
snapping_client - ID of the client which snapshot
|
|
|
|
is being created.
|
|
|
|
*/
|
2010-05-29 07:25:38 +00:00
|
|
|
void Snap(int SnappingClient);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
/*
|
|
|
|
Function: tick
|
|
|
|
Calls tick on all the entities in the world to progress
|
|
|
|
the world to the next tick.
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
*/
|
2010-05-29 07:25:38 +00:00
|
|
|
void Tick();
|
2010-09-11 09:42:35 +00:00
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
// DDRace
|
2011-02-13 05:35:13 +00:00
|
|
|
void ReleaseHooked(int ClientID);
|
2010-09-11 09:42:35 +00:00
|
|
|
|
2010-09-10 06:55:04 +00:00
|
|
|
/*
|
|
|
|
Function: interserct_CCharacters
|
|
|
|
Finds all CCharacters that intersect the line.
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2010-09-10 06:55:04 +00:00
|
|
|
Arguments:
|
|
|
|
pos0 - Start position
|
|
|
|
pos2 - End position
|
|
|
|
radius - How for from the line the CCharacter is allowed to be.
|
|
|
|
new_pos - Intersection position
|
|
|
|
notthis - Entity to ignore intersecting with
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2010-09-10 06:55:04 +00:00
|
|
|
Returns:
|
|
|
|
Returns list with all Characters on line.
|
|
|
|
*/
|
|
|
|
std::list<class CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis = 0);
|
2008-08-14 18:25:44 +00:00
|
|
|
};
|
2008-08-14 18:42:47 +00:00
|
|
|
|
|
|
|
#endif
|