1
2
3
4
5
6
7
8
9
10
11
12
13
|
// clientgame.cpp: core game related stuff
#include "cube.h"
#include <memory>
int nextmode = 0; // nextmode becomes gamemode after next map load
VAR(gamemode, 1, 0, 0);
void
mode(int n)
{
addmsg(1, 2, SV_GAMEMODE, nextmode = n);
|
<
<
|
1
2
3
4
5
6
7
8
9
10
11
|
// clientgame.cpp: core game related stuff
#include "cube.h"
int nextmode = 0; // nextmode becomes gamemode after next map load
VAR(gamemode, 1, 0, 0);
void
mode(int n)
{
addmsg(1, 2, SV_GAMEMODE, nextmode = n);
|
243
244
245
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
void
updateworld(int millis) // main game update loop
{
if (lastmillis) {
curtime = millis - lastmillis;
if (sleepwait && lastmillis > sleepwait) {
sleepwait = 0;
@autoreleasepool {
std::unique_ptr<char> cmd(
strdup(sleepcmd.UTF8String));
execute(cmd.get());
}
}
physicsframe();
checkquad(curtime);
if (m_arena)
arenarespawn();
moveprojectiles((float)curtime);
demoplaybackstep();
if (!demoplayback) {
if (getclientnum() >= 0)
shoot(player1, worldpos); // only shoot when
// connected to server
gets2c(); // do this first, so we have most accurate
// information when our player moves
};
otherplayers();
if (!demoplayback) {
monsterthink();
if (player1->state == CS_DEAD) {
if (lastmillis - player1->lastaction < 2000) {
player1->move = player1->strafe = 0;
moveplayer(player1, 10, false);
} else if (!m_arena && !m_sp &&
lastmillis - player1->lastaction >
10000)
respawn();
} else if (!intermission) {
moveplayer(player1, 20, true);
checkitems();
};
c2sinfo(player1); // do this last, to reduce the
// effective frame lag
};
};
lastmillis = millis;
};
void
entinmap(dynent *
d) // brute force but effective way to find a free spawn spot in the map
{
loopi(100) // try max 100 times
{
|
<
<
<
|
<
<
>
<
<
>
>
<
>
|
241
242
243
244
245
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
void
updateworld(int millis) // main game update loop
{
if (lastmillis) {
curtime = millis - lastmillis;
if (sleepwait && lastmillis > sleepwait) {
sleepwait = 0;
execute(sleepcmd);
}
physicsframe();
checkquad(curtime);
if (m_arena)
arenarespawn();
moveprojectiles((float)curtime);
demoplaybackstep();
if (!demoplayback) {
if (getclientnum() >= 0)
shoot(player1, worldpos); // only shoot when
// connected to server
gets2c(); // do this first, so we have most accurate
// information when our player moves
}
otherplayers();
if (!demoplayback) {
monsterthink();
if (player1->state == CS_DEAD) {
if (lastmillis - player1->lastaction < 2000) {
player1->move = player1->strafe = 0;
moveplayer(player1, 10, false);
} else if (!m_arena && !m_sp &&
lastmillis - player1->lastaction >
10000)
respawn();
} else if (!intermission) {
moveplayer(player1, 20, true);
checkitems();
};
c2sinfo(player1); // do this last, to reduce the
// effective frame lag
}
}
lastmillis = millis;
}
void
entinmap(dynent *
d) // brute force but effective way to find a free spawn spot in the map
{
loopi(100) // try max 100 times
{
|