]> git.xonotic.org Git - xonotic/darkplaces.git/blob - world.h
Revert "Tell clients to reconnect before loading the next map. Should fix lag/stutter"
[xonotic/darkplaces.git] / world.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20 // world.h
21
22 #ifndef WORLD_H
23 #define WORLD_H
24
25 #include "qtypes.h"
26 #include "com_list.h"
27 #include "collision.h"
28
29 #define MOVE_NORMAL     0
30 #define MOVE_NOMONSTERS 1
31 #define MOVE_MISSILE    2
32 #define MOVE_WORLDONLY  3
33 #define MOVE_HITMODEL   4
34
35 #define AREA_GRID 128
36 #define AREA_GRIDNODES (AREA_GRID * AREA_GRID)
37
38 typedef struct link_s
39 {
40         llist_t list;
41         int entitynumber;
42 } link_t;
43
44 typedef struct world_physics_s
45 {
46         // for ODE physics engine
47         qbool ode; // if true then ode is activated
48         void *ode_world;
49         void *ode_space;
50         void *ode_contactgroup;
51         // number of constraint solver iterations to use (for dWorldQuickStep)
52         int ode_iterations;
53         // actual step (server frametime / ode_iterations)
54         vec_t ode_step;
55         // time we need to simulate, for constantstep
56         vec_t ode_time;
57         // stats
58         int ode_numobjects; // total objects cound
59         int ode_activeovjects; // active objects count
60         // max velocity for a 1-unit radius object at current step to prevent
61         // missed collisions
62         vec_t ode_movelimit;
63 }
64 world_physics_t;
65
66 struct prvm_prog_s;
67
68 typedef struct world_s
69 {
70         // convenient fields
71         char filename[MAX_QPATH];
72         vec3_t mins;
73         vec3_t maxs;
74         struct prvm_prog_s *prog;
75
76         int areagrid_stats_calls;
77         int areagrid_stats_nodechecks;
78         int areagrid_stats_entitychecks;
79
80         link_t areagrid[AREA_GRIDNODES];
81         link_t areagrid_outside;
82         vec3_t areagrid_bias;
83         vec3_t areagrid_scale;
84         vec3_t areagrid_mins;
85         vec3_t areagrid_maxs;
86         vec3_t areagrid_size;
87         int areagrid_marknumber;
88
89         // if the QC uses a physics engine, the data for it is here
90         world_physics_t physics;
91 }
92 world_t;
93
94 struct prvm_edict_s;
95
96 // cyclic doubly-linked list functions
97 void World_ClearLink(link_t *l);
98 void World_RemoveLink(link_t *l);
99 void World_InsertLinkBefore(link_t *l, link_t *before, int entitynumber);
100
101 void World_Init(void);
102 void World_Shutdown(void);
103
104 /// called after the world model has been loaded, before linking any entities
105 void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs, struct prvm_prog_s *prog);
106 /// unlinks all entities (used before reallocation of edicts)
107 void World_UnlinkAll(world_t *world);
108
109 void World_PrintAreaStats(world_t *world, const char *worldname);
110
111 /// call before removing an entity, and before trying to move one,
112 /// so it doesn't clip against itself
113 void World_UnlinkEdict(struct prvm_edict_s *ent);
114
115 /// Needs to be called any time an entity changes origin, mins, maxs
116 void World_LinkEdict(world_t *world, struct prvm_edict_s *ent, const vec3_t mins, const vec3_t maxs);
117
118 /// \returns list of entities touching a box
119 int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, struct prvm_edict_s **list);
120
121 void World_Start(world_t *world);
122 void World_End(world_t *world);
123
124 // update physics
125 // this is called by SV_Physics
126 void World_Physics_Frame(world_t *world, double frametime, double gravity);
127
128 // change physics properties of entity
129 struct prvm_edict_s;
130 struct edict_odefunc_s;
131 void World_Physics_ApplyCmd(struct prvm_edict_s *ed, struct edict_odefunc_s *f);
132
133 // remove physics data from entity
134 // this is called by entity removal
135 void World_Physics_RemoveFromEntity(world_t *world, struct prvm_edict_s *ed);
136 void World_Physics_RemoveJointFromEntity(world_t *world, struct prvm_edict_s *ed);
137
138 #endif
139