XenevaOS
Loading...
Searching...
No Matches
p_local.h
Go to the documentation of this file.
1//
2// Copyright(C) 1993-1996 Id Software, Inc.
3// Copyright(C) 2005-2014 Simon Howard
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// DESCRIPTION:
16// Play functions, animation, global header.
17//
18
19
20#ifndef __P_LOCAL__
21#define __P_LOCAL__
22
23#ifndef __R_LOCAL__
24#include "r_local.h"
25#endif
26
27#define FLOATSPEED (FRACUNIT*4)
28
29
30#define MAXHEALTH 100
31#define VIEWHEIGHT (41*FRACUNIT)
32
33// mapblocks are used to check movement
34// against lines and things
35#define MAPBLOCKUNITS 128
36#define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT)
37#define MAPBLOCKSHIFT (FRACBITS+7)
38#define MAPBMASK (MAPBLOCKSIZE-1)
39#define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS)
40
41
42// player radius for movement checking
43#define PLAYERRADIUS 16*FRACUNIT
44
45// MAXRADIUS is for precalculated sector block boxes
46// the spider demon is larger,
47// but we do not have any moving sectors nearby
48#define MAXRADIUS 32*FRACUNIT
49
50#define GRAVITY FRACUNIT
51#define MAXMOVE (30*FRACUNIT)
52
53#define USERANGE (64*FRACUNIT)
54#define MELEERANGE (64*FRACUNIT)
55#define MISSILERANGE (32*64*FRACUNIT)
56
57// follow a player exlusively for 3 seconds
58#define BASETHRESHOLD 100
59
60
61
62//
63// P_TICK
64//
65
66// both the head and tail of the thinker list
67extern thinker_t thinkercap;
68
69
70void P_InitThinkers (void);
71void P_AddThinker (thinker_t* thinker);
72void P_RemoveThinker (thinker_t* thinker);
73
74
75//
76// P_PSPR
77//
78void P_SetupPsprites (player_t* curplayer);
79void P_MovePsprites (player_t* curplayer);
80void P_DropWeapon (player_t* player);
81
82
83//
84// P_USER
85//
86void P_PlayerThink (player_t* player);
87
88
89//
90// P_MOBJ
91//
92#define ONFLOORZ INT_MIN
93#define ONCEILINGZ INT_MAX
94
95// Time interval for item respawning.
96#define ITEMQUESIZE 128
97
98extern mapthing_t itemrespawnque[ITEMQUESIZE];
100extern int iquehead;
101extern int iquetail;
102
103
104void P_RespawnSpecials (void);
105
106mobj_t*
108( fixed_t x,
109 fixed_t y,
110 fixed_t z,
111 mobjtype_t type );
112
113void P_RemoveMobj (mobj_t* th);
115boolean P_SetMobjState (mobj_t* mobj, statenum_t state);
116void P_MobjThinker (mobj_t* mobj);
117
118void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z);
119void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage);
120mobj_t* P_SpawnMissile (mobj_t* source, mobj_t* dest, mobjtype_t type);
121void P_SpawnPlayerMissile (mobj_t* source, mobjtype_t type);
122
123
124//
125// P_ENEMY
126//
127void P_NoiseAlert (mobj_t* target, mobj_t* emmiter);
128
129
130//
131// P_MAPUTL
132//
133typedef struct
134{
139
140} divline_t;
141
142typedef struct
143{
144 fixed_t frac; // along trace line
145 boolean isaline;
146 union {
149 } d;
151
152// Extended MAXINTERCEPTS, to allow for intercepts overrun emulation.
153
154#define MAXINTERCEPTS_ORIGINAL 128
155#define MAXINTERCEPTS (MAXINTERCEPTS_ORIGINAL + 61)
156
159
161
163int P_PointOnLineSide (fixed_t x, fixed_t y, line_t* line);
165void P_MakeDivline (line_t* li, divline_t* dl);
167int P_BoxOnLineSide (fixed_t* tmbox, line_t* ld);
168
169extern fixed_t opentop;
170extern fixed_t openbottom;
171extern fixed_t openrange;
172extern fixed_t lowfloor;
173
175
176boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) );
177boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) );
178
179#define PT_ADDLINES 1
180#define PT_ADDTHINGS 2
181#define PT_EARLYOUT 4
182
183extern divline_t trace;
184
185boolean
187( fixed_t x1,
188 fixed_t y1,
189 fixed_t x2,
190 fixed_t y2,
191 int flags,
192 boolean (*trav) (intercept_t *));
193
194void P_UnsetThingPosition (mobj_t* thing);
195void P_SetThingPosition (mobj_t* thing);
196
197
198//
199// P_MAP
200//
201
202// If "floatok" true, move would be ok
203// if within "tmfloorz - tmceilingz".
204extern boolean floatok;
205extern fixed_t tmfloorz;
206extern fixed_t tmceilingz;
207
208
209extern line_t* ceilingline;
210
211// fraggle: I have increased the size of this buffer. In the original Doom,
212// overrunning past this limit caused other bits of memory to be overwritten,
213// affecting demo playback. However, in doing so, the limit was still
214// exceeded. So we have to support more than 8 specials.
215//
216// We keep the original limit, to detect what variables in memory were
217// overwritten (see SpechitOverrun())
218
219#define MAXSPECIALCROSS 20
220#define MAXSPECIALCROSS_ORIGINAL 8
221
223extern int numspechit;
224
225boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y);
226boolean P_TryMove (mobj_t* thing, fixed_t x, fixed_t y);
227boolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y);
228void P_SlideMove (mobj_t* mo);
229boolean P_CheckSight (mobj_t* t1, mobj_t* t2);
230void P_UseLines (player_t* player);
231
232boolean P_ChangeSector (sector_t* sector, boolean crunch);
233
234extern mobj_t* linetarget; // who got hit (or NULL)
235
238( mobj_t* t1,
239 angle_t angle,
240 fixed_t distance );
241
242void
244( mobj_t* t1,
245 angle_t angle,
246 fixed_t distance,
247 fixed_t slope,
248 int damage );
249
250void
252( mobj_t* spot,
253 mobj_t* source,
254 int damage );
255
256
257
258//
259// P_SETUP
260//
261extern byte* rejectmatrix; // for fast sight rejection
262extern short* blockmaplump; // offsets in blockmap are from here
263extern short* blockmap;
264extern int bmapwidth;
265extern int bmapheight; // in mapblocks
266extern fixed_t bmaporgx;
267extern fixed_t bmaporgy; // origin of block map
268extern mobj_t** blocklinks; // for thing chains
269
270
271
272//
273// P_INTER
274//
275extern int maxammo[NUMAMMO];
276extern int clipammo[NUMAMMO];
277
278void
280( mobj_t* special,
281 mobj_t* toucher );
282
283void
285( mobj_t* target,
286 mobj_t* inflictor,
287 mobj_t* source,
288 int damage );
289
290
291//
292// P_SPEC
293//
294#include "p_spec.h"
295
296
297#endif // __P_LOCAL__
uint8_t flags
Definition virtio.h:0
@ NUMAMMO
Definition doomdef.h:133
boolean
Definition doomtype.h:74
statenum_t
Definition info.h:172
mobjtype_t
Definition info.h:1159
#define d
Definition libunicode.c:1833
int fixed_t
Definition m_fixed.h:32
mobj_t * P_SubstNullMobj(mobj_t *th)
Definition p_mobj.c:929
void P_MakeDivline(line_t *li, divline_t *dl)
Definition p_maputl.c:207
void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z)
Definition p_mobj.c:852
fixed_t bmaporgy
Definition p_setup.c:89
void P_LineAttack(mobj_t *t1, angle_t angle, fixed_t distance, fixed_t slope, int damage)
Definition p_map.c:1111
mobj_t * P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type)
Definition p_mobj.c:951
boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
Definition p_map.c:403
divline_t trace
Definition p_maputl.c:542
mobj_t * P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
Definition p_mobj.c:507
void P_SetupPsprites(player_t *curplayer)
Definition p_pspr.c:840
boolean P_BlockThingsIterator(int x, int y, boolean(*func)(mobj_t *))
Definition p_maputl.c:509
void P_RespawnSpecials(void)
Definition p_mobj.c:604
boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y)
Definition p_map.c:132
boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
Definition p_mobj.c:49
intercept_t intercepts[MAXINTERCEPTS]
Definition p_maputl.c:539
boolean(* traverser_t)(intercept_t *in)
Definition p_local.h:160
boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
Definition p_sight.c:302
thinker_t thinkercap
Definition p_tick.c:40
int clipammo[NUMAMMO]
Definition p_inter.c:51
mapthing_t itemrespawnque[ITEMQUESIZE]
Definition p_mobj.c:566
byte * rejectmatrix
Definition p_setup.c:101
fixed_t openrange
Definition p_maputl.c:291
fixed_t P_AimLineAttack(mobj_t *t1, angle_t angle, fixed_t distance)
Definition p_map.c:1069
void P_UnsetThingPosition(mobj_t *thing)
Definition p_maputl.c:342
fixed_t P_InterceptVector(divline_t *v2, divline_t *v1)
Definition p_maputl.c:227
void P_RemoveMobj(mobj_t *th)
Definition p_mobj.c:572
fixed_t opentop
Definition p_maputl.c:289
void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher)
Definition p_inter.c:334
intercept_t * intercept_p
Definition p_maputl.c:540
void P_SpawnPlayerMissile(mobj_t *source, mobjtype_t type)
Definition p_mobj.c:997
line_t * spechit[MAXSPECIALCROSS]
Definition p_map.c:85
void P_LineOpening(line_t *linedef)
Definition p_maputl.c:295
void P_AddThinker(thinker_t *thinker)
Definition p_tick.c:58
fixed_t openbottom
Definition p_maputl.c:290
void P_PlayerThink(player_t *player)
Definition p_user.c:229
mobj_t * linetarget
Definition p_map.c:821
mobj_t ** blocklinks
Definition p_setup.c:91
void P_SetThingPosition(mobj_t *thing)
Definition p_maputl.c:391
void P_RemoveThinker(thinker_t *thinker)
Definition p_tick.c:73
boolean P_ChangeSector(sector_t *sector, boolean crunch)
Definition p_map.c:1369
short * blockmaplump
Definition p_setup.c:86
short * blockmap
Definition p_setup.c:84
#define MAXINTERCEPTS
Definition p_local.h:155
boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y)
Definition p_map.c:479
fixed_t P_AproxDistance(fixed_t dx, fixed_t dy)
Definition p_maputl.c:45
int numspechit
Definition p_map.c:86
int P_BoxOnLineSide(fixed_t *tmbox, line_t *ld)
Definition p_maputl.c:106
void P_DropWeapon(player_t *player)
Definition p_pspr.c:256
void P_MobjThinker(mobj_t *mobj)
Definition p_mobj.c:441
void P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, int damage)
Definition p_inter.c:780
void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage)
Definition p_mobj.c:879
boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, boolean(*trav)(intercept_t *))
Definition p_maputl.c:862
int bmapwidth
Definition p_setup.c:82
int iquehead
Definition p_mobj.c:568
int bmapheight
Definition p_setup.c:83
int itemrespawntime[ITEMQUESIZE]
Definition p_mobj.c:567
fixed_t tmfloorz
Definition p_map.c:74
int maxammo[NUMAMMO]
Definition p_inter.c:50
fixed_t bmaporgx
Definition p_setup.c:88
boolean P_BlockLinesIterator(int x, int y, boolean(*func)(line_t *))
Definition p_maputl.c:468
line_t * ceilingline
Definition p_map.c:80
void P_RadiusAttack(mobj_t *spot, mobj_t *source, int damage)
Definition p_map.c:1254
int P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line)
Definition p_maputl.c:62
void P_UseLines(player_t *player)
Definition p_map.c:1177
#define MAXSPECIALCROSS
Definition p_local.h:219
void P_NoiseAlert(mobj_t *target, mobj_t *emmiter)
Definition p_enemy.c:153
fixed_t tmceilingz
Definition p_map.c:75
#define ITEMQUESIZE
Definition p_local.h:96
fixed_t lowfloor
Definition p_maputl.c:292
void P_MovePsprites(player_t *curplayer)
Definition p_pspr.c:860
int iquetail
Definition p_mobj.c:569
int P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line)
Definition p_maputl.c:157
void P_InitThinkers(void)
Definition p_tick.c:46
void P_SlideMove(mobj_t *mo)
Definition p_map.c:722
boolean floatok
Definition p_map.c:72
line_t * linedef
Definition r_bsp.c:42
Definition p_local.h:134
fixed_t dx
Definition p_local.h:137
fixed_t x
Definition p_local.h:135
fixed_t dy
Definition p_local.h:138
fixed_t y
Definition p_local.h:136
Definition p_local.h:143
boolean isaline
Definition p_local.h:145
fixed_t frac
Definition p_local.h:144
mobj_t * thing
Definition p_local.h:147
line_t * line
Definition p_local.h:148
Definition r_defs.h:176
Definition p_mobj.h:202
Definition d_player.h:79
Definition r_defs.h:98
Definition d_think.h:59
unsigned angle_t
Definition tables.h:81
#define state(x)