1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
// one big bad include file for the whole engine... nasty!
#import <ObjFW/ObjFW.h>
#define gamma gamma__
#include <SDL2/SDL.h>
#undef gamma
#include "tools.h"
@interface Cube: OFObject <OFApplicationDelegate>
@property (class, readonly, nonatomic) Cube *sharedInstance;
@property (readonly, nonatomic) SDL_Window *window;
@property (readonly, nonatomic) OFIRI *gameDataIRI, *userDataIRI;
@property (nonatomic) bool repeatsKeys;
@property (nonatomic) int framesInMap;
|
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
// one big bad include file for the whole engine... nasty!
#import <ObjFW/ObjFW.h>
#define gamma gamma__
#include <SDL2/SDL.h>
#undef gamma
#include "tools.h"
@class DynamicEntity;
@interface Cube: OFObject <OFApplicationDelegate>
@property (class, readonly, nonatomic) Cube *sharedInstance;
@property (readonly, nonatomic) SDL_Window *window;
@property (readonly, nonatomic) OFIRI *gameDataIRI, *userDataIRI;
@property (nonatomic) bool repeatsKeys;
@property (nonatomic) int framesInMap;
|
︙ | | | ︙ | |
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
GUN_FIREBALL,
GUN_ICEBALL,
GUN_SLIMEBALL,
GUN_BITE,
NUMGUNS
};
struct dynent // players & monsters
{
OFVector3D o, vel; // origin, velocity
float yaw, pitch, roll; // used as OFVector3D in one place
float maxspeed; // cubes per second, 24 for player
bool outsidemap; // from his eyes
bool inwater;
bool onfloor, jumpnext;
int move, strafe;
bool k_left, k_right, k_up, k_down; // see input code
int timeinair; // used for fake gravity
float radius, eyeheight, aboveeye; // bounding box size
int lastupdate, plag, ping;
int lifesequence; // sequence id for each respawn, used in damage test
int state; // one of CS_* below
int frags;
int health, armour, armourtype, quadmillis;
int gunselect, gunwait;
int lastaction, lastattackgun, lastmove;
bool attacking;
int ammo[NUMGUNS];
int monsterstate; // one of M_* below, M_NONE means human
int mtype; // see monster.cpp
dynent *enemy; // monster wants to kill this entity
float targetyaw; // monster wants to look in this direction
bool blocked, moving; // used by physics to signal ai
int trigger; // millis at which transition to another monsterstate takes
// place
OFVector3D attacktarget; // delayed attacks
int anger; // how many times already hit by fellow monster
string name, team;
};
#define SAVEGAMEVERSION \
4 // bump if dynent/netprotocol changes or any other savegame/demo data
enum { A_BLUE, A_GREEN, A_YELLOW }; // armour types... take 20/40/60 % off
enum {
M_NONE = 0,
M_SEARCH,
M_HOME,
M_ATTACKING,
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
<
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
GUN_FIREBALL,
GUN_ICEBALL,
GUN_SLIMEBALL,
GUN_BITE,
NUMGUNS
};
// bump if dynent/netprotocol changes or any other savegame/demo data
#define SAVEGAMEVERSION 4
enum { A_BLUE, A_GREEN, A_YELLOW }; // armour types... take 20/40/60 % off
enum {
M_NONE = 0,
M_SEARCH,
M_HOME,
M_ATTACKING,
|
︙ | | | ︙ | |
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
// vertex array format
struct vertex {
float u, v, x, y, z;
uchar r, g, b, a;
};
typedef vector<dynent *> dvector;
// globals ooh naughty
extern sqr *world,
*wmip[]; // map data, the mips are sequential 2D arrays in memory
extern header hdr; // current map header
extern int sfactor, ssize; // ssize = 2^sfactor
extern int cubicsize, mipsize; // cubicsize = ssize^2
extern dynent
*player1; // special client ent that receives input and acts as camera
extern dvector players; // all the other clients (in multiplayer)
extern bool editmode;
extern vector<entity> ents; // map entities
extern OFVector3D worldpos; // current target of the crosshair in the world
extern int lastmillis; // last time
extern int curtime; // current frame time
extern int gamemode, nextmode;
extern int xtraverts;
|
<
<
<
|
>
|
>
|
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
// vertex array format
struct vertex {
float u, v, x, y, z;
uchar r, g, b, a;
};
// globals ooh naughty
extern sqr *world,
*wmip[]; // map data, the mips are sequential 2D arrays in memory
extern header hdr; // current map header
extern int sfactor, ssize; // ssize = 2^sfactor
extern int cubicsize, mipsize; // cubicsize = ssize^2
// special client ent that receives input and acts as camera
extern DynamicEntity *player1;
// all the other clients (in multiplayer)
extern OFMutableArray *players;
extern bool editmode;
extern vector<entity> ents; // map entities
extern OFVector3D worldpos; // current target of the crosshair in the world
extern int lastmillis; // last time
extern int curtime; // current frame time
extern int gamemode, nextmode;
extern int xtraverts;
|
︙ | | | ︙ | |
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
#define PIXELTAB (VIRTW / 12)
#define PI (3.1415927f)
#define PI2 (2 * PI)
// simplistic vector ops
#define dotprod(u, v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z)
#define vmul(u, f) \
{ \
(u).x *= (f); \
(u).y *= (f); \
(u).z *= (f); \
}
#define vdiv(u, f) \
{ \
(u).x /= (f); \
(u).y /= (f); \
(u).z /= (f); \
}
#define vadd(u, v) \
{ \
(u).x += (v).x; \
(u).y += (v).y; \
(u).z += (v).z; \
};
#define vsub(u, v) \
{ \
(u).x -= (v).x; \
(u).y -= (v).y; \
(u).z -= (v).z; \
};
#define vdist(d, v, e, s) \
OFVector3D v = s; \
vsub(v, e); \
float d = (float)sqrt(dotprod(v, v));
#define vreject(v, u, max) \
((v).x > (u).x + (max) || (v).x < (u).x - (max) || \
(v).y > (u).y + (max) || (v).y < (u).y - (max))
|
|
|
|
|
>
|
|
|
<
|
>
>
|
|
|
>
>
|
<
<
<
>
|
|
>
>
|
<
<
<
>
|
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
#define PIXELTAB (VIRTW / 12)
#define PI (3.1415927f)
#define PI2 (2 * PI)
// simplistic vector ops
#define dotprod(u, v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z)
#define vmul(u, f) \
{ \
OFVector3D tmp_ = u; \
float tmp2_ = f; \
u = OFMakeVector3D( \
tmp_.x * tmp2_, tmp_.y * tmp2_, tmp_.z * tmp2_); \
}
#define vdiv(u, f) \
{ \
OFVector3D tmp_ = u; \
float tmp2_ = f; \
u = OFMakeVector3D( \
tmp_.x / tmp2_, tmp_.y / tmp2_, tmp_.z / tmp2_); \
}
#define vadd(u, v) \
{ \
OFVector3D tmp_ = u; \
u = OFMakeVector3D( \
tmp_.x + (v).x, tmp_.y + (v).y, tmp_.z + (v).z); \
}
#define vsub(u, v) \
{ \
OFVector3D tmp_ = u; \
u = OFMakeVector3D( \
tmp_.x - (v).x, tmp_.y - (v).y, tmp_.z - (v).z); \
}
#define vdist(d, v, e, s) \
OFVector3D v = s; \
vsub(v, e); \
float d = (float)sqrt(dotprod(v, v));
#define vreject(v, u, max) \
((v).x > (u).x + (max) || (v).x < (u).x - (max) || \
(v).y > (u).y + (max) || (v).y < (u).y - (max))
|
︙ | | | ︙ | |
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
|
#define m_noitemsrail (gamemode <= 5)
#define m_arena (gamemode >= 8)
#define m_tarena (gamemode >= 10)
#define m_teammode (gamemode & 1 && gamemode > 2)
#define m_sp (gamemode < 0)
#define m_dmsp (gamemode == -1)
#define m_classicsp (gamemode == -2)
#define isteam(a, b) (m_teammode && strcmp(a, b) == 0)
enum // function signatures for script functions, see command.cpp
{
ARG_1INT,
ARG_2INT,
ARG_3INT,
ARG_4INT,
|
|
|
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
#define m_noitemsrail (gamemode <= 5)
#define m_arena (gamemode >= 8)
#define m_tarena (gamemode >= 10)
#define m_teammode (gamemode & 1 && gamemode > 2)
#define m_sp (gamemode < 0)
#define m_dmsp (gamemode == -1)
#define m_classicsp (gamemode == -2)
#define isteam(a, b) (m_teammode && [a isEqual:b])
enum // function signatures for script functions, see command.cpp
{
ARG_1INT,
ARG_2INT,
ARG_3INT,
ARG_4INT,
|
︙ | | | ︙ | |