DDraceNetwork Documentation
Loading...
Searching...
No Matches
gameworld.h
Go to the documentation of this file.
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_GAMEWORLD_H
4#define GAME_SERVER_GAMEWORLD_H
5
6#include <game/gamecore.h>
7
8#include "save.h"
9
10#include <vector>
11
12class CEntity;
13class CCharacter;
14
15/*
16 Class: Game World
17 Tracks all entities in the game. Propagates tick and
18 snap calls to all entities.
19*/
20class CGameWorld
21{
22public:
23 enum
24 {
31 };
32
33private:
34 void Reset();
36
39
43
44public:
46 class CConfig *Config() { return m_pConfig; }
47 class IServer *Server() { return m_pServer; }
48
52
55
57
58 CEntity *FindFirst(int Type);
59
60 /*
61 Function: FindEntities
62 Finds entities close to a position and returns them in a list.
63
64 Arguments:
65 Pos - Position.
66 Radius - How close the entities have to be.
67 ppEnts - Pointer to a list that should be filled with the pointers
68 to the entities.
69 Max - Number of entities that fits into the ents array.
70 Type - Type of the entities to find.
71
72 Returns:
73 Number of entities found and added to the ents array.
74 */
75 int FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, int Type);
76
93
110 CEntity *IntersectEntity(vec2 Pos0, vec2 Pos1, float Radius, int Type, vec2 &NewPos, const CEntity *pNotThis = nullptr, int CollideWith = -1, const CEntity *pThisOnly = nullptr);
111
112 /*
113 Function: ClosestCharacter
114 Finds the closest CCharacter to a specific point.
115
116 Arguments:
117 Pos - The center position.
118 Radius - How far off the CCharacter is allowed to be
119 pNotThis - Entity to ignore
120
121 Returns:
122 Returns a pointer to the closest CCharacter or NULL if no CCharacter is close enough.
123 */
125
126 /*
127 Function: InsertEntity
128 Adds an entity to the world.
129
130 Arguments:
131 pEntity - Entity to add
132 */
134
135 /*
136 Function: RemoveEntity
137 Removes an entity from the world.
138
139 Arguments:
140 pEntity - Entity to remove
141 */
143
146
147 /*
148 Function: Snap
149 Calls Snap on all the entities in the world to create
150 the snapshot.
151
152 Arguments:
153 SnappingClient - ID of the client which snapshot
154 is being created.
155 */
156 void Snap(int SnappingClient);
157
158 /*
159 Function: Tick
160 Calls Tick on all the entities in the world to progress
161 the world to the next tick.
162 */
163 void Tick();
164
165 /*
166 Function: SwapClients
167 Calls SwapClients on all the entities in the world to ensure that /swap
168 command is handled safely.
169 */
170 void SwapClients(int Client1, int Client2);
171
172 /*
173 Function: BlocksSave
174 Checks if any entity would block /save
175 */
176 ESaveResult BlocksSave(int ClientId);
177
178 // DDRace
179 void ReleaseHooked(int ClientId);
180
181 /*
182 Function: IntersectedCharacters
183 Finds all CCharacters that intersect the line.
184
185 Arguments:
186 Pos0 - Start position
187 Pos1 - End position
188 Radius - How for from the line the CCharacter is allowed to be.
189 pNotThis - Entity to ignore intersecting with
190
191 Returns:
192 Returns list with all Characters on line.
193 */
194 std::vector<CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, const CEntity *pNotThis = nullptr);
195
197
200 CTuningParams *GetTuning(int i) { return &TuningList()[i]; }
201};
202
203#endif
Definition character.h:24
Definition config.h:25
Definition entity.h:13
Definition gamecontext.h:106
Definition gameworld.h:18
void Snap(int SnappingClient)
Definition gameworld.cpp:109
CEntity * IntersectEntity(vec2 Pos0, vec2 Pos1, float Radius, int Type, vec2 &NewPos, const CEntity *pNotThis=nullptr, int CollideWith=-1, const CEntity *pThisOnly=nullptr)
bool m_Paused
Definition gameworld.h:50
CTuningParams * TuningList()
Definition gameworld.h:199
CCharacter * IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, const CCharacter *pNotThis=nullptr, int CollideWith=-1, const CCharacter *pThisOnly=nullptr)
CTuningParams * Tuning()
void InsertEntity(CEntity *pEntity, bool Last=false)
Definition gameworld.cpp:85
class IServer * Server()
Definition gameworld.h:47
class CConfig * Config()
Definition gameworld.h:46
CTuningParams * m_pTuningList
Definition gameworld.h:104
void SetGameServer(CGameContext *pGameServer)
Definition gameworld.cpp:38
CEntity * m_pNextTraverseEntity
Definition gameworld.h:114
class CConfig * m_pConfig
Definition gameworld.h:41
void Tick()
void RemoveEntities()
class CGameContext * GameServer()
Definition gameworld.h:45
CEntity * FindFirst(int Type)
CWorldCore m_Core
Definition gameworld.h:35
@ ENTTYPE_CHARACTER
Definition gameworld.h:31
@ NUM_ENTTYPES
Definition gameworld.h:32
@ ENTTYPE_FLAG
Definition gameworld.h:30
@ ENTTYPE_LASER
Definition gameworld.h:23
@ ENTTYPE_PROJECTILE
Definition gameworld.h:22
@ ENTTYPE_PICKUP
Definition gameworld.h:29
CCharacter * ClosestCharacter(vec2 Pos, float Radius, const CEntity *pNotThis)
Definition gameworld.cpp:326
void RemoveEntitiesFromPlayer(int PlayerId)
Definition gameworld.cpp:152
class CGameContext * m_pGameServer
Definition gameworld.h:40
CEntity * m_apFirstEntityTypes[NUM_ENTTYPES]
Definition gameworld.h:115
ESaveResult BlocksSave(int ClientId)
Definition gameworld.cpp:257
void SwapClients(int Client1, int Client2)
Definition gameworld.cpp:272
CTuningParams * GetTuning(int i)
Definition gameworld.h:200
std::vector< CCharacter * > IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, const CEntity *pNotThis=nullptr)
int FindEntities(vec2 Pos, float Radius, CEntity **ppEnts, int Max, int Type)
void RemoveEntitiesFromPlayers(int PlayerIds[], int NumPlayers)
Definition gameworld.cpp:157
class IServer * m_pServer
Definition gameworld.h:42
void ReleaseHooked(int ClientId)
void RemoveEntity(CEntity *pEntity)
bool m_ResetRequested
Definition gameworld.h:49
void Reset()
Definition gameworld.cpp:132
Definition gamecore.h:43
Definition gamecore.h:148
Definition server.h:31
Definition vmath.h:15
ESaveResult
Definition save.h:27