Cube  Diff

Differences From Artifact [8334b2a352]:

To Artifact [e35d803d58]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
// 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);
};
COMMAND(mode, ARG_1INT);

bool intermission = false;

dynent *player1 = newdynent(); // our client
dvector players;               // other clients

VARP(sensitivity, 0, 10, 10000);
VARP(sensitivityscale, 1, 1, 10000);
VARP(invmouse, 0, 0, 1);

int lastmillis = 0;
int curtime = 10;
string clientmap;

extern int framesinmap;

char *
getclientmap()
{
	return clientmap;
};


void
resetmovement(dynent *d)
{
	d->k_left = false;
	d->k_right = false;
	d->k_up = false;












|












|



|



<
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
// 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);
};
COMMAND(mode, ARG_1INT)

bool intermission = false;

dynent *player1 = newdynent(); // our client
dvector players;               // other clients

VARP(sensitivity, 0, 10, 10000);
VARP(sensitivityscale, 1, 1, 10000);
VARP(invmouse, 0, 0, 1);

int lastmillis = 0;
int curtime = 10;
OFString *clientmap;

extern int framesinmap;

OFString *
getclientmap()
{
	return clientmap;

}

void
resetmovement(dynent *d)
{
	d->k_left = false;
	d->k_right = false;
	d->k_up = false;
216
217
218
219
220
221
222
223

224
225
226
227
228
229
230
231


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
respawn()
{
	if (player1->state == CS_DEAD) {
		player1->attacking = false;
		if (m_arena) {
			conoutf(@"waiting for new round to start...");
			return;
		};

		if (m_sp) {
			nextmode = gamemode;
			changemap(clientmap);
			return;
		}; // if we die in SP we try the same map again
		respawnself();
	};
};



int sleepwait = 0;
string sleepcmd;
void
sleepf(char *msec, char *cmd)
{
	sleepwait = atoi(msec) + lastmillis;
	strcpy_s(sleepcmd, cmd);
};
COMMANDN(sleep, sleepf, ARG_2STR);

void
updateworld(int millis) // main game update loop
{
	if (lastmillis) {
		curtime = millis - lastmillis;
		if (sleepwait && lastmillis > sleepwait) {







<
>




|

<
<
>
>









|







216
217
218
219
220
221
222

223
224
225
226
227
228
229


230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
respawn()
{
	if (player1->state == CS_DEAD) {
		player1->attacking = false;
		if (m_arena) {
			conoutf(@"waiting for new round to start...");
			return;

		}
		if (m_sp) {
			nextmode = gamemode;
			changemap(clientmap);
			return;
		} // if we die in SP we try the same map again
		respawnself();


	}
}

int sleepwait = 0;
string sleepcmd;
void
sleepf(char *msec, char *cmd)
{
	sleepwait = atoi(msec) + lastmillis;
	strcpy_s(sleepcmd, cmd);
};
COMMANDN(sleep, sleepf, ARG_2STR)

void
updateworld(int millis) // main game update loop
{
	if (lastmillis) {
		curtime = millis - lastmillis;
		if (sleepwait && lastmillis > sleepwait) {
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
void
jumpn(bool on)
{
	if (!intermission && (player1->jumpnext = on))
		respawn();
};

COMMAND(backward, ARG_DOWN);
COMMAND(forward, ARG_DOWN);
COMMAND(left, ARG_DOWN);
COMMAND(right, ARG_DOWN);
COMMANDN(jump, jumpn, ARG_DOWN);
COMMAND(attack, ARG_DOWN);
COMMAND(showscores, ARG_DOWN);

void
fixplayer1range()
{
	const float MAXPITCH = 90.0f;
	if (player1->pitch > MAXPITCH)
		player1->pitch = MAXPITCH;







|
|
|
|
|
|
|







357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
void
jumpn(bool on)
{
	if (!intermission && (player1->jumpnext = on))
		respawn();
};

COMMAND(backward, ARG_DOWN)
COMMAND(forward, ARG_DOWN)
COMMAND(left, ARG_DOWN)
COMMAND(right, ARG_DOWN)
COMMANDN(jump, jumpn, ARG_DOWN)
COMMAND(attack, ARG_DOWN)
COMMAND(showscores, ARG_DOWN)

void
fixplayer1range()
{
	const float MAXPITCH = 90.0f;
	if (player1->pitch > MAXPITCH)
		player1->pitch = MAXPITCH;
480
481
482
483
484
485
486
487
488
489

490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505

506

507
508
509
510
511
512
513
514
515
516
517

518
		players.add(NULL);
	return players[cn] ? players[cn] : (players[cn] = newdynent());
}

void
initclient()
{
	clientmap[0] = 0;
	initclientnet();
};


void
startmap(char *name) // called just after a map load
{
	if (netmapstart() && m_sp) {
		gamemode = 0;
		conoutf(@"coop sp not supported yet");
	}
	sleepwait = 0;
	monsterclear();
	projreset();
	spawncycle = -1;
	spawnplayer(player1);
	player1->frags = 0;
	loopv(players) if (players[i]) players[i]->frags = 0;
	resetspawns();

	strcpy_s(clientmap, name);

	if (editmode)
		toggleedit();
	setvar("gamespeed", 100);
	setvar("fog", 180);
	setvar("fogcolour", 0x8099B3);
	showscores(false);
	intermission = false;
	framesinmap = 0;
	conoutf(@"game mode is %s", modestr(gamemode));
};


COMMANDN(map, changemap, ARG_1STR);







|

<
>
















>
|
>









<
|
>
|
480
481
482
483
484
485
486
487
488

489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517

518
519
520
		players.add(NULL);
	return players[cn] ? players[cn] : (players[cn] = newdynent());
}

void
initclient()
{
	clientmap = @"";
	initclientnet();

}

void
startmap(char *name) // called just after a map load
{
	if (netmapstart() && m_sp) {
		gamemode = 0;
		conoutf(@"coop sp not supported yet");
	}
	sleepwait = 0;
	monsterclear();
	projreset();
	spawncycle = -1;
	spawnplayer(player1);
	player1->frags = 0;
	loopv(players) if (players[i]) players[i]->frags = 0;
	resetspawns();
	@autoreleasepool {
		clientmap = @(name);
	}
	if (editmode)
		toggleedit();
	setvar("gamespeed", 100);
	setvar("fog", 180);
	setvar("fogcolour", 0x8099B3);
	showscores(false);
	intermission = false;
	framesinmap = 0;
	conoutf(@"game mode is %s", modestr(gamemode));

}

COMMANDN(map, changemap, ARG_1STR)