Cube  Check-in [ef1d7e47f7]

Overview
Comment:Remove all default arguments from protos.h
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ef1d7e47f7204700ed6e3b1191a1bdcb6e1d0257586183bc6571b8ff92464042
User & Date: js on 2025-03-20 20:38:43
Other Links: manifest | tags
Context
2025-03-20
20:59
Convert several files to pure Objective-C check-in: eac9e3d948 user: js tags: trunk
20:38
Remove all default arguments from protos.h check-in: ef1d7e47f7 user: js tags: trunk
20:11
Convert all references to pointers in protos.h check-in: c38d75087b user: js tags: trunk
Changes

Modified src/Command.mm from [ca8bd2ebde] to [6dc988a0ae].

120
121
122
123
124
125
126
127

128
129
130
131
132
133
134


135
136
137
138
139
140
141
120
121
122
123
124
125
126

127
128
129
130
131
132
133

134
135
136
137
138
139
140
141
142







-
+






-
+
+







		((void(__cdecl *)(bool, OFString *))_function)(
		    isDown, arguments[1]);
		break;
	case ARG_1EXP:
		if (isDown) {
			arguments = padArguments(arguments, 2);
			return ((int(__cdecl *)(int))_function)(
			    execute(arguments[1]));
			    execute(arguments[1], isDown));
		}
		break;
	case ARG_2EXP:
		if (isDown) {
			arguments = padArguments(arguments, 3);
			return ((int(__cdecl *)(int, int))_function)(
			    execute(arguments[1]), execute(arguments[2]));
			    execute(arguments[1], isDown),
			    execute(arguments[2], isDown));
		}
		break;
	case ARG_1EST:
		if (isDown) {
			arguments = padArguments(arguments, 2);
			return ((int(__cdecl *)(OFString *))_function)(
			    arguments[1]);

Modified src/Cube.mm from [91778984c2] to [6edead03c0].

292
293
294
295
296
297
298
299

300
301
302
303
304
305
306
292
293
294
295
296
297
298

299
300
301
302
303
304
305
306







-
+







		}
	}
}

- (void)applicationWillTerminate:(OFNotification *)notification
{
	stop();
	disconnect(true);
	disconnect(true, false);
	writecfg();
	cleangl();
	cleansound();
	cleanupserver();
	SDL_ShowCursor(1);
	SDL_Quit();
}
353
354
355
356
357
358
359

360
361

362


363
364





365
366
367
368
369
370
371
353
354
355
356
357
358
359
360
361

362
363
364
365


366
367
368
369
370
371
372
373
374
375
376
377







+

-
+

+
+
-
-
+
+
+
+
+







- (void)quit
{
	writeservercfg();
	[OFApplication terminateWithStatus:0];
}
@end

// failure exit
void
fatal(OFString *s, OFString *o) // failure exit
fatal(OFConstantString *s, ...)
{
	va_list args;
	va_start(args, s);
	OFString *msg =
	    [OFString stringWithFormat:@"%@%@ (%s)\n", s, o, SDL_GetError()];
	OFMutableString *msg = [[OFMutableString alloc] initWithFormat:s
	                                                     arguments:args];
	va_end(args);

	[msg appendFormat:@" (%s)\n", SDL_GetError()];

	[Cube.sharedInstance showMessage:msg];
	[OFApplication terminateWithStatus:1];
}

void
quit() // normal exit

Modified src/clientgame.mm from [5aac2f8a02] to [6041eeb1a7].

247
248
249
250
251
252
253
254

255
256
257
258
259
260
261
247
248
249
250
251
252
253

254
255
256
257
258
259
260
261







-
+







void
updateworld(int millis) // main game update loop
{
	if (lastmillis) {
		curtime = millis - lastmillis;
		if (sleepwait && lastmillis > sleepwait) {
			sleepwait = 0;
			execute(sleepcmd);
			execute(sleepcmd, true);
		}
		physicsframe();
		checkquad(curtime);
		if (m_arena)
			arenarespawn();
		moveprojectiles((float)curtime);
		demoplaybackstep();
441
442
443
444
445
446
447
448

449
450
451
452

453
454
455
456
457
458
459
441
442
443
444
445
446
447

448
449
450
451

452
453
454
455
456
457
458
459







-
+



-
+







		showscores(true);
		addmsg(1, 2, SV_DIED, actor);
		player1.lifesequence++;
		player1.attacking = false;
		player1.state = CS_DEAD;
		player1.pitch = 0;
		player1.roll = 60;
		playsound(S_DIE1 + rnd(2));
		playsound(S_DIE1 + rnd(2), NULL);
		spawnstate(player1);
		player1.lastaction = lastmillis;
	} else
		playsound(S_PAIN6);
		playsound(S_PAIN6, NULL);
}

void
timeupdate(int timeremain)
{
	if (!timeremain) {
		intermission = true;

Modified src/clients.mm from [9e4179b5d8] to [0b1a4d40d0].

90
91
92
93
94
95
96
97

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

117
118
119
120
121

122
123
124
125
126
127
128
90
91
92
93
94
95
96

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

116
117
118
119
120

121
122
123
124
125
126
127
128







-
+


















-
+




-
+







	[stream writeFormat:@"name \"%@\"\nteam \"%@\"\n", player1.name,
	        player1.team];
}

void
connects(OFString *servername)
{
	disconnect(1); // reset state
	disconnect(true, false); // reset state
	addserver(servername);

	conoutf(@"attempting to connect to %@", servername);
	ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT };
	if (enet_address_set_host(&address, servername.UTF8String) < 0) {
		conoutf(@"could not resolve server %@", servername);
		return;
	}

	clienthost = enet_host_create(NULL, 1, rate, rate);

	if (clienthost) {
		enet_host_connect(clienthost, &address, 1);
		enet_host_flush(clienthost);
		connecting = lastmillis;
		connattempts = 0;
	} else {
		conoutf(@"could not connect to server");
		disconnect();
		disconnect(false, false);
	}
}

void
disconnect(int onlyclean, int async)
disconnect(bool onlyclean, bool async)
{
	if (clienthost) {
		if (!connecting && !disconnecting) {
			enet_peer_disconnect(clienthost->peers);
			enet_host_flush(clienthost);
			disconnecting = lastmillis;
		}
158
159
160
161
162
163
164
165

166
167
168
169
170
171
172
158
159
160
161
162
163
164

165
166
167
168
169
170
171
172







-
+







{
	if (!clienthost) {
		conoutf(@"not connected");
		return;
	}
	if (connecting) {
		conoutf(@"aborting connection attempt");
		disconnect();
		disconnect(false, false);
		return;
	}
	conoutf(@"attempting to disconnect...");
	disconnect(0, !disconnecting);
}

static OFString *ctext;
229
230
231
232
233
234
235
236

237
238
239
240
241
242
243
229
230
231
232
233
234
235

236
237
238
239
240
241
242
243







-
+







	[messages addObject:msg];
}

void
server_err()
{
	conoutf(@"server network error, disconnecting...");
	disconnect();
	disconnect(false, false);
}

int lastupdate = 0, lastping = 0;
OFString *toservermap;
bool senditemstoserver =
    false; // after a map change, since server doesn't have map data

378
379
380
381
382
383
384
385

386
387
388
389
390
391
392
378
379
380
381
382
383
384

385
386
387
388
389
390
391
392







-
+







		return;
	if (connecting && lastmillis / 3000 > connecting / 3000) {
		conoutf(@"attempting to connect...");
		connecting = lastmillis;
		++connattempts;
		if (connattempts > 3) {
			conoutf(@"could not connect to server");
			disconnect();
			disconnect(false, false);
			return;
		}
	}
	while (
	    clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0)
		switch (event.type) {
		case ENET_EVENT_TYPE_CONNECT:
402
403
404
405
406
407
408
409

410
411
412
413
414
402
403
404
405
406
407
408

409
410
411
412
413
414







-
+





				localservertoclient(event.packet->data,
				    event.packet->dataLength);
			enet_packet_destroy(event.packet);
			break;

		case ENET_EVENT_TYPE_DISCONNECT:
			if (disconnecting)
				disconnect();
				disconnect(false, false);
			else
				server_err();
			return;
		}
}

Modified src/clients2c.mm from [2a4e83496a] to [783cdb6446].

10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
10
11
12
13
14
15
16

17
18
19
20
21
22
23
24







-
+







extern OFString *toservermap;
extern OFString *clientpassword;

void
neterr(OFString *s)
{
	conoutf(@"illegal network message (%@)", s);
	disconnect();
	disconnect(false, false);
}

void
changemapserv(OFString *name, int mode) // forced map change from the server
{
	gamemode = mode;
	load_world(name);
63
64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

90
91
92
93
94
95
96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110







-
+


















-
+













-
+








// processes any updates from the server
void
localservertoclient(uchar *buf, int len)
{
	if (ENET_NET_TO_HOST_16(*(ushort *)buf) != len)
		neterr(@"packet length");
	incomingdemodata(buf, len);
	incomingdemodata(buf, len, false);

	uchar *end = buf + len;
	uchar *p = buf + 2;
	char text[MAXTRANS];
	int cn = -1, type;
	DynamicEntity *d = nil;
	bool mapchanged = false;

	while (p < end)
		switch (type = getint(&p)) {
		case SV_INITS2C: // welcome messsage from the server
		{
			cn = getint(&p);
			int prot = getint(&p);
			if (prot != PROTOCOL_VERSION) {
				conoutf(@"you are using a different game "
				        @"protocol (you: %d, server: %d)",
				    PROTOCOL_VERSION, prot);
				disconnect();
				disconnect(false, false);
				return;
			}
			toservermap = @"";
			clientnum = cn; // we are now fully connected
			if (!getint(&p))
				// we are the first client on this server, set
				// map
				toservermap = getclientmap();
			sgetstr();
			if (text[0] &&
			    strcmp(text, clientpassword.UTF8String)) {
				conoutf(@"you need to set the correct password "
				        @"to join this server!");
				disconnect();
				disconnect(false, false);
				return;
			}
			if (getint(&p) == 1)
				conoutf(@"server is FULL, disconnecting..");
			break;
		}

217
218
219
220
221
222
223
224

225
226
227
228
229
230
231
217
218
219
220
221
222
223

224
225
226
227
228
229
230
231







-
+







			s.y = getint(&p) / DMF;
			s.z = getint(&p) / DMF;
			e.x = getint(&p) / DMF;
			e.y = getint(&p) / DMF;
			e.z = getint(&p) / DMF;
			if (gun == GUN_SG)
				createrays(&s, &e);
			shootv(gun, &s, &e, d);
			shootv(gun, &s, &e, d, false);
			break;
		}

		case SV_DAMAGE: {
			int target = getint(&p);
			int damage = getint(&p);
			int ls = getint(&p);

Modified src/commands.mm from [586613b4e5] to [b377b2846b].

119
120
121
122
123
124
125

126

127
128
129
130
131
132
133
119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
134







+
-
+







			return NULL;
		}
	}
	char *s = strndup(word, p - word - 1);
	if (left == '(') {
		OFString *t;
		@try {
			t = [OFString
			t = [OFString stringWithFormat:@"%d", execute(@(s))];
			    stringWithFormat:@"%d", execute(@(s), true)];
		} @finally {
			free(s);
		}
		s = strdup(t.UTF8String);
	}
	return s;
}
325
326
327
328
329
330
331
332

333
334
335
336
337
338
339
326
327
328
329
330
331
332

333
334
335
336
337
338
339
340







-
+







		command = [OFString stringWithContentsOfIRI:cfgfile];
	} @catch (OFOpenItemFailedException *e) {
		return false;
	} @catch (OFReadFailedException *e) {
		return false;
	}

	execute(command);
	execute(command, true);
	return true;
}

void
exec(OFString *cfgfile)
{
	if (!execfile([Cube.sharedInstance.userDataIRI
403
404
405
406
407
408
409
410

411
412
413
414
415
416
417
418
419
420
421

422
423
424
425
426
427
428
429


430
431
432
433
434
435
436

437
438
439
440
441
442
443
404
405
406
407
408
409
410

411
412
413
414
415
416
417
418
419
420
421

422
423
424
425
426
427
428


429
430
431
432
433
434
435
436

437
438
439
440
441
442
443
444







-
+










-
+






-
-
+
+






-
+







{
	alias(name, [OFString stringWithFormat:@"%d", v]);
}

void
ifthen(OFString *cond, OFString *thenp, OFString *elsep)
{
	execute((![cond hasPrefix:@"0"] ? thenp : elsep));
	execute((![cond hasPrefix:@"0"] ? thenp : elsep), true);
}

void
loopa(OFString *times, OFString *body)
{
	int t = times.cube_intValue;

	loopi(t)
	{
		intset(@"i", i);
		execute(body);
		execute(body, true);
	}
}

void
whilea(OFString *cond, OFString *body)
{
	while (execute(cond))
		execute(body);
	while (execute(cond, true))
		execute(body, true);
}

void
onrelease(bool on, OFString *body)
{
	if (!on)
		execute(body);
		execute(body, true);
}

void
concat(OFString *s)
{
	alias(@"s", s);
}

Modified src/console.mm from [555c5a6eb3] to [2703ba3edf].

173
174
175
176
177
178
179
180

181
182
183
184
185
186
187
173
174
175
176
177
178
179

180
181
182
183
184
185
186
187







-
+







void
history(int n)
{
	static bool rec = false;

	if (!rec && n >= 0 && n < vhistory.count) {
		rec = true;
		execute(vhistory[vhistory.count - n - 1]);
		execute(vhistory[vhistory.count - n - 1], true);
		rec = false;
	}
}
COMMAND(history, ARG_1INT)

void
keypress(int code, bool isDown)

Modified src/editing.mm from [cc23cfc264] to [93fef8399d].

33
34
35
36
37
38
39
40

41
42
43
44
45
46
47
33
34
35
36
37
38
39

40
41
42
43
44
45
46
47







-
+







	{                                                   \
		makeundo();                                 \
		loop(x, sel->xs) loop(y, sel->ys)           \
		{                                           \
			sqr *s = S(sel->x + x, sel->y + y); \
			b;                                  \
		}                                           \
		remip(sel);                                 \
		remip(sel, 0);                              \
	}

int cx, cy, ch;

int curedittex[] = { -1, -1, -1 };

bool dragging = false;
436
437
438
439
440
441
442
443

444
445
446
447
448
449
450
436
437
438
439
440
441
442

443
444
445
446
447
448
449
450







-
+







		case 3:
			if (s->utex == rtex.utex)
				s->utex = lasttex;
			break;
		}
	}
	block b = { 0, 0, ssize, ssize };
	remip(&b);
	remip(&b, 0);
}

void
edittypexy(int type, const block *sel)
{
	loopselxy(s->type = type);
}
514
515
516
517
518
519
520
521

522
523
524
525
526
527
528
514
515
516
517
518
519
520

521
522
523
524
525
526
527
528







-
+







}
COMMAND(equalize, ARG_1INT)

void
setvdeltaxy(int delta, const block *sel)
{
	loopselxy(s->vdelta = max(s->vdelta + delta, 0));
	remipmore(sel);
	remipmore(sel, 0);
}

void
setvdelta(int delta)
{
	EDITSEL;
	setvdeltaxy(delta, &sel);
559
560
561
562
563
564
565
566

567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584

585
586
587
588
589
590
591
592
593
594
595
596
597
598
599

600
601
602
603
604
605
606
559
560
561
562
563
564
565

566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583

584
585
586
587
588
589
590
591
592
593
594
595
596
597
598

599
600
601
602
603
604
605
606







-
+

















-
+














-
+







	// Ugly hack to make the macro work.
	block *sel = sel_;
	loopselxy(s->vdelta = sel->xs > sel->ys
	        ? (archverts[sel->xs - 1][x] +
	              (y == 0 || y == sel->ys - 1 ? sidedelta : 0))
	        : (archverts[sel->ys - 1][y] +
	              (x == 0 || x == sel->xs - 1 ? sidedelta : 0)));
	remipmore(sel);
	remipmore(sel, 0);
}

void
slope(int xd, int yd)
{
	EDITSELMP;
	int off = 0;
	if (xd < 0)
		off -= xd * sel.xs;
	if (yd < 0)
		off -= yd * sel.ys;
	sel.xs++;
	sel.ys++;
	block *sel_ = &sel;
	// Ugly hack to make the macro work.
	block *sel = sel_;
	loopselxy(s->vdelta = xd * x + yd * y + off);
	remipmore(sel);
	remipmore(sel, 0);
}

void
perlin(int scale, int seed, int psize)
{
	EDITSELMP;
	sel.xs++;
	sel.ys++;
	makeundo();
	sel.xs--;
	sel.ys--;
	perlinarea(&sel, scale, seed, psize);
	sel.xs++;
	sel.ys++;
	remipmore(&sel);
	remipmore(&sel, 0);
	sel.xs--;
	sel.ys--;
}

VARF(
    fullbright, 0, 0, 1, if (fullbright) {
	    if (noteditmode())

Modified src/entities.mm from [115703834e] to [47ee9d00d9].

50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
50
51
52
53
54
55
56

57
58
59
60
61
62
63
64







-
+







			if (mmi == nil)
				continue;
			rendermodel(mmi.name, 0, 1, e.attr4, (float)mmi.rad,
			    OFMakeVector3D(e.x,
			        (float)S(e.x, e.y)->floor + mmi.zoff + e.attr3,
			        e.y),
			    (float)((e.attr1 + 7) - (e.attr1 + 7) % 15), 0,
			    false, 1.0f, 10.0f, mmi.snap);
			    false, 1.0f, 10.0f, mmi.snap, 0);
		} else {
			if (OUTBORD(e.x, e.y))
				continue;
			if (e.type != CARROT) {
				if (!e.spawned && e.type != TELEPORT)
					continue;
				if (e.type < I_SHELLS || e.type > TELEPORT)

Modified src/protos.h from [8ea505a066] to [9719c1da0f].

1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17









-
+







// protos for ALL external functions in cube...

// command
extern int variable(OFString *name, int min, int cur, int max, int *storage,
    void (*fun)(), bool persist);
extern void setvar(OFString *name, int i);
extern int getvar(OFString *name);
extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(OFString *p, bool down = true);
extern int execute(OFString *p, bool down);
extern void exec(OFString *cfgfile);
extern bool execfile(OFIRI *cfgfile);
extern void resetcomplete();
extern void complete(OFMutableString *s);
extern void alias(OFString *name, OFString *action);
extern OFString *getalias(OFString *name);
extern void writecfg();
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81







-
+







extern int renderwater(float hf);
extern void finishstrips();
extern void setarraypointers();

// client
extern void localservertoclient(uchar *buf, int len);
extern void connects(OFString *servername);
extern void disconnect(int onlyclean = 0, int async = 0);
extern void disconnect(bool onlyclean, bool async);
extern void toserver(OFString *text);
extern void addmsg(int rel, int num, int type, ...);
extern bool multiplayer();
extern bool allowedittoggle();
extern void sendpackettoserv(void *packet);
extern void gets2c();
extern void c2sinfo(DynamicEntity *d);
110
111
112
113
114
115
116
117
118


119
120

121
122
123
124
125
126
127
110
111
112
113
114
115
116


117
118
119

120
121
122
123
124
125
126
127







-
-
+
+

-
+







    DynamicEntity *d, bool team, OFString *mdlname, bool hellpig, float scale);
void showscores(bool on);
extern void renderscores();

// world
extern void setupworld(int factor);
extern void empty_world(int factor, bool force);
extern void remip(const block *b, int level = 0);
extern void remipmore(const block *b, int level = 0);
extern void remip(const block *b, int level);
extern void remipmore(const block *b, int level);
extern int closestent();
extern int findentity(int type, int index = 0);
extern int findentity(int type, int index);
extern void trigger(int tag, int type, bool savegame);
extern void resettagareas();
extern void settagareas();
extern Entity *newentity(
    int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4);

// worldlight
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
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







-
+


















-
+







    float widef, int w, int h);

// worldocull
extern void computeraytable(float vx, float vy);
extern int isoccluded(float vx, float vy, float cx, float cy, float csize);

// main
extern void fatal(OFString *s, OFString *o = @"");
extern void fatal(OFConstantString *s, ...);

// rendertext
extern void draw_text(OFString *string, int left, int top, int gl_num);
extern void draw_textf(
    OFConstantString *format, int left, int top, int gl_num, ...);
extern int text_width(OFString *string);
extern void draw_envbox(int t, int fogdist);

// editing
extern void cursorupdate();
extern void toggleedit();
extern void editdrag(bool isdown);
extern void setvdeltaxy(int delta, const block *sel);
extern void editequalisexy(bool isfloor, const block *sel);
extern void edittypexy(int type, const block *sel);
extern void edittexxy(int type, int t, const block *sel);
extern void editheightxy(bool isfloor, int amount, const block *sel);
extern bool noteditmode();
extern void pruneundos(int maxremain = 0);
extern void pruneundos(int maxremain);

// renderextras
extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
extern void box(const block *b, float z1, float z2, float z3, float z4);
extern void dot(int x, int y, float z);
extern void linestyle(float width, int r, int g, int b);
extern void newsphere(const OFVector3D *o, float max, int type);
184
185
186
187
188
189
190
191

192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

207
208
209
210
211
212
213
214

215
216
217
218
219
220
221
184
185
186
187
188
189
190

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213

214
215
216
217
218
219
220
221







-
+














-
+







-
+








// worldio
extern void save_world(OFString *fname);
extern void load_world(OFString *mname);
extern void writemap(OFString *mname, int msize, uchar *mdata);
extern OFData *readmap(OFString *mname);
extern void loadgamerest();
extern void incomingdemodata(uchar *buf, int len, bool extras = false);
extern void incomingdemodata(uchar *buf, int len, bool extras);
extern void demoplaybackstep();
extern void stop();
extern void stopifrecording();
extern void demodamage(int damage, const OFVector3D *o);
extern void demoblend(int damage);

// physics
extern void moveplayer(DynamicEntity *pl, int moveres, bool local);
extern bool collide(DynamicEntity *d, bool spawn, float drop, float rise);
extern void entinmap(DynamicEntity *d);
extern void setentphysics(int mml, int mmr);
extern void physicsframe();

// sound
extern void playsound(int n, const OFVector3D *loc = NULL);
extern void playsound(int n, const OFVector3D *loc);
extern void playsoundc(int n);
extern void initsound();
extern void cleansound();

// rendermd2
extern void rendermodel(OFString *mdl, int frame, int range, int tex, float rad,
    OFVector3D position, float yaw, float pitch, bool teammate, float scale,
    float speed, int snap = 0, int basetime = 0);
    float speed, int snap, int basetime);
@class MapModelInfo;
extern MapModelInfo *getmminfo(int i);

// server
extern void initserver(bool dedicated, int uprate, OFString *sdesc,
    OFString *ip, OFString *master, OFString *passwd, int maxcl);
extern void cleanupserver();
233
234
235
236
237
238
239
240

241
242
243

244
245
246
247
248
249
250
233
234
235
236
237
238
239

240
241
242

243
244
245
246
247
248
249
250







-
+


-
+







extern void serverms(int mode, int numplayers, int minremain,
    OFString *smapname, int seconds, bool isfull);
extern void servermsinit(OFString *master, OFString *sdesc, bool listen);
extern void sendmaps(int n, OFString *mapname, int mapsize, uchar *mapdata);
extern ENetPacket *recvmap(int n);

// weapon
extern void selectgun(int a = -1, int b = -1, int c = -1);
extern void selectgun(int a, int b, int c);
extern void shoot(DynamicEntity *d, const OFVector3D *to);
extern void shootv(int gun, const OFVector3D *from, const OFVector3D *to,
    DynamicEntity *d = 0, bool local = false);
    DynamicEntity *d, bool local);
extern void createrays(const OFVector3D *from, const OFVector3D *to);
extern void moveprojectiles(float time);
extern void projreset();
extern OFString *playerincrosshair();
extern int reloadtime(int gun);

// monster

Modified src/rendermd2.mm from [72886c2cec] to [10e74a7f04].

19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
19
20
21
22
23
24
25

26
27
28
29
30
31
32
33







-
+







		OFString *path = [OFString
		    stringWithFormat:@"packages/models/%@", m.loadname];
		OFIRI *baseIRI = [Cube.sharedInstance.gameDataIRI
		    IRIByAppendingPathComponent:path];

		OFIRI *IRI1 = [baseIRI IRIByAppendingPathComponent:@"tris.md2"];
		if (![m loadWithIRI:IRI1])
			fatal(@"loadmodel: ", IRI1.string);
			fatal(@"loadmodel: %@", IRI1.string);

		OFIRI *IRI2 = [baseIRI IRIByAppendingPathComponent:@"skin.jpg"];
		int xs, ys;
		installtex(FIRSTMDL + m.mdlnum, IRI2, &xs, &ys, false);
		m.loaded = true;
	}
}

Modified src/savegamedemo.mm from [f1dd561ea3] to [01e4530b16].

347
348
349
350
351
352
353
354

355
356
357
358
359
360
361
347
348
349
350
351
352
353

354
355
356
357
358
359
360
361







-
+








void
stopreset()
{
	conoutf(@"demo stopped (%d msec elapsed)", lastmillis - starttime);
	stop();
	[players removeAllObjects];
	disconnect(0, 0);
	disconnect(false, false);
}

VAR(demoplaybackspeed, 10, 100, 1000);
int
scaletime(int t)
{
	return (int)(t * (100.0f / demoplaybackspeed)) + starttime;

Modified src/serverbrowser.mm from [3253e95f9b] to [3cbd2b77d6].

269
270
271
272
273
274
275
276

277
278
279
280
281
282
283
269
270
271
272
273
274
275

276
277
278
279
280
281
282
283







-
+







	uchar buf[MAXUPD];
	uchar *reply = retrieveservers(buf, MAXUPD);
	if (!*reply || strstr((char *)reply, "<html>") ||
	    strstr((char *)reply, "<HTML>"))
		conoutf(@"master server not replying");
	else {
		[servers removeAllObjects];
		execute(@((char *)reply));
		execute(@((char *)reply), true);
	}
	servermenu();
}

COMMAND(addserver, ARG_1STR)
COMMAND(servermenu, ARG_NONE)
COMMAND(updatefrommaster, ARG_NONE)

Modified src/serverutil.mm from [3bd542851a] to [f5a43d9173].

136
137
138
139
140
141
142
143

144
145






146


147
148
149
150
151
152
153
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







-
+


+
+
+
+
+
+
-
+
+








void
localservertoclient(uchar *buf, int len)
{
}

void
fatal(OFString *s, OFString *o)
fatal(OFConstantString *s, ...)
{
	cleanupserver();

	va_list args;
	va_start(args, s);
	OFString *msg = [[OFString alloc] initWithFormat:s arguments:args];
	va_end(args);

	[OFStdOut writeFormat:@"servererror: %@\n", s];
	[OFStdOut writeFormat:@"servererror: %@\n", msg];

	exit(1);
}

void *
alloc(int s)
{
	void *b = calloc(1, s);

Modified src/sound.mm from [f965fc3ef4] to [eeaee8a784].

155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169







-
+







	}
}

void
playsoundc(int n)
{
	addmsg(0, 2, SV_SOUND, n);
	playsound(n);
	playsound(n, NULL);
}

int soundsatonce = 0, lastsoundmillis = 0;

void
playsound(int n, const OFVector3D *loc)
{

Modified src/world.mm from [96ee092ff1] to [8078c12089].

38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52







-
+







				minx = x;
			if (y < miny)
				miny = y;
		}
	}
	block b = { minx, miny, maxx - minx + 1, maxy - miny + 1 };
	if (maxx)
		remip(&b); // remip minimal area of changed geometry
		remip(&b, 0); // remip minimal area of changed geometry
}

void
resettagareas()
{
	settag(0, 0);
} // reset for editing or map saving
66
67
68
69
70
71
72
73

74
75
76
77
78
79

80
81
82
83
84
85
86
66
67
68
69
70
71
72

73
74
75
76
77
78

79
80
81
82
83
84
85
86







-
+





-
+







{
	if (!tag)
		return;

	settag(tag, type);

	if (!savegame && type != 3)
		playsound(S_RUMBLE);
		playsound(S_RUMBLE, NULL);

	OFString *aliasname =
	    [OFString stringWithFormat:@"level_trigger_%d", tag];

	if (identexists(aliasname))
		execute(aliasname);
		execute(aliasname, true);

	if (type == 2)
		endsp(false);
}
COMMAND(trigger, ARG_2INT)

// main geometric mipmapping routine, recursively rebuild mipmaps within block
453
454
455
456
457
458
459
460

461
462
463
464
465
466
467
453
454
455
456
457
458
459

460
461
462
463
464
465
466
467







-
+







// world by 1
void
empty_world(int factor, bool force)
{
	if (!force && noteditmode())
		return;
	cleardlights();
	pruneundos();
	pruneundos(0);
	sqr *oldworld = world;
	bool copy = false;
	if (oldworld && factor < 0) {
		factor = sfactor + 1;
		copy = true;
	}
	if (factor < SMALLEST_FACTOR)
512
513
514
515
516
517
518
519

520
521
522
523
524
525
526
512
513
514
515
516
517
518

519
520
521
522
523
524
525
526







-
+







	}

	calclight();
	startmap(@"base/unnamed");
	if (oldworld) {
		OFFreeMemory(oldworld);
		toggleedit();
		execute(@"fullbright 1");
		execute(@"fullbright 1", true);
	}
}

void
mapenlarge()
{
	empty_world(-1, false);

Modified src/worldio.mm from [823b65f982] to [402ec6ee8c].

258
259
260
261
262
263
264
265

266
267
268
269
270
271
272
258
259
260
261
262
263
264

265
266
267
268
269
270
271
272







-
+








void
load_world(OFString *mname) // still supports all map formats that have existed
                            // since the earliest cube betas!
{
	stopifrecording();
	cleardlights();
	pruneundos();
	pruneundos(0);
	setnames(mname);
	gzFile f =
	    gzopen([cgzname cStringWithEncoding:OFLocale.encoding], "rb9");
	if (!f) {
		conoutf(@"could not read map %@", cgzname);
		return;
	}
346
347
348
349
350
351
352
353

354
355
356
357
358



359
360
361
362
363
364
365
366
346
347
348
349
350
351
352

353





354
355
356

357
358
359
360
361
362
363







-
+
-
-
-
-
-
+
+
+
-







			s->utex = s->wtex;
			s->tag = 0;
			s->floor = 0;
			s->ceil = 16;
			break;
		}
		default: {
			if (type < 0 || type >= MAXTYPE) {
			if (type < 0 || type >= MAXTYPE)
				OFString *t = [OFString
				    stringWithFormat:@"%d @ %d", type, k];
				fatal(@"while reading map: type out of "
				      @"range: ",
				    t);
				fatal(@"while reading map: type out of range: "
				      @"%d @ %d",
				    type, k);
			}
			s->type = type;
			s->floor = gzgetc(f);
			s->ceil = gzgetc(f);
			if (s->floor >= s->ceil)
				s->floor = s->ceil - 1; // for pre 12_13
			s->wtex = gzgetc(f);
			s->ftex = gzgetc(f);

Modified src/worldlight.mm from [ecc6786def] to [2b192347af].

161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
161
162
163
164
165
166
167

168
169
170
171
172
173
174
175







-
+







	        SW(s, 1, -1)->m + SW(s, -1, 1)->m + SW(s, -1, -1)->m) /      \
	    14; // median is 4/2/1 instead
		median(r);
		median(g);
		median(b);
	}

	remip(&a);
	remip(&a, 0);
}

void
calclight()
{
	loop(x, ssize) loop(y, ssize)
	{
264
265
266
267
268
269
270
271

272
264
265
266
267
268
269
270

271
272







-
+

void
blockpaste(const block *b)
{
	sqr *q = (sqr *)(b + 1);
	for (int x = b->x; x < b->xs + b->x; x++)
		for (int y = b->y; y < b->ys + b->y; y++)
			*S(x, y) = *q++;
	remipmore(b);
	remipmore(b, 0);
}