Cube  Diff

Differences From Artifact [ea9ed1c660]:

To Artifact [b2a4ca42d9]:


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
98
99
100
101
102
103
104



105
106
107
108
109
110
111







-
-
-







#define LARGEST_FACTOR 11 // 10 is already insane
#define SOLID(x) ((x)->type == SOLID)
#define MINBORD 2 // 2 cubes from the edge of the world are always solid
#define OUTBORD(x, y)                                                          \
	((x) < MINBORD || (y) < MINBORD || (x) >= ssize - MINBORD ||           \
	    (y) >= ssize - MINBORD)

struct vec {
	float x, y, z;
};
struct block {
	int x, y, xs, ys;
};
struct mapmodelinfo {
	int rad, h, zoff, snap;
	const char *name;
};
124
125
126
127
128
129
130
131
132


133
134
135
136
137
138
139
121
122
123
124
125
126
127


128
129
130
131
132
133
134
135
136







-
-
+
+







	GUN_SLIMEBALL,
	GUN_BITE,
	NUMGUNS
};

struct dynent // players & monsters
{
	vec o, vel;             // origin, velocity
	float yaw, pitch, roll; // used as vec in one place
	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
150
151
152
153
154
155
156
157
158


159
160
161
162
163
164
165
147
148
149
150
151
152
153


154
155
156
157
158
159
160
161
162







-
-
+
+







	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
	vec attacktarget; // delayed attacks
	int anger;        // how many times already hit by fellow monster
	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
291
292
293
294
295
296
297
298

299
300
301
302
303
304
305
288
289
290
291
292
293
294

295
296
297
298
299
300
301
302







-
+







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 vec worldpos;        // current target of the crosshair in the world
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;
extern bool demoplayback;

#define DMF 16.0f
337
338
339
340
341
342
343
344

345
346
347
348
349
350
351
334
335
336
337
338
339
340

341
342
343
344
345
346
347
348







-
+







#define vsub(u, v)                                                             \
	{                                                                      \
		(u).x -= (v).x;                                                \
		(u).y -= (v).y;                                                \
		(u).z -= (v).z;                                                \
	};
#define vdist(d, v, e, s)                                                      \
	vec v = 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))
#define vlinterp(v, f, u, g)                                                   \
	{                                                                      \