Cube  Check-in [0e7605d101]

Overview
Comment:Fix all warnings
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0e7605d101d4079a75f8b62b072f342cb5ce5ff95090cf2068318193de907e2c
User & Date: js on 2025-03-20 22:40:48
Other Links: manifest | tags
References
2025-03-20
22:43 New ticket [f7cb97dc7c] Test editing corners. artifact: 8c00728175 user: js
Context
2025-03-20
23:02
Fix -Wgnu-folding-constant check-in: e79356d2a6 user: js tags: trunk
22:40
Fix all warnings check-in: 0e7605d101 user: js tags: trunk
22:22
Convert remaining files to pure Objective-C check-in: 12cac9666a user: js tags: trunk
Changes

Modified src/Entity.h from [6a40859f40] to [0c6f848420].

1

2

3
4








5

1
2
3


4
5
6
7
8
9
10
11
12
-
+

+
-
-
+
+
+
+
+
+
+
+

#import "PersistentEntity.h"
#import <ObjFW/ObjFW.h>

// map entity
@interface Entity: PersistentEntity
@property (nonatomic) bool spawned; // the only dynamic state of a map entity
@interface Entity: OFObject
@property (nonatomic) short x, y, z; // cube aligned position
@property (nonatomic) short attr1;
@property (nonatomic) unsigned char type; // type is one of the above
@property (nonatomic) unsigned char attr2, attr3, attr4;
@property (nonatomic) bool spawned;

+ (instancetype)entity;
@end

Modified src/Entity.m from [54155c553d] to [aab70a6ce9].

1
2
3




4
1
2
3
4
5
6
7
8



+
+
+
+

#import "Entity.h"

@implementation Entity
+ (instancetype)entity
{
	return [[self alloc] init];
}
@end

Deleted src/PersistentEntity.h version [1383bfd2c4].

Deleted src/PersistentEntity.m version [2ab320312c].

Modified src/clientextras.m from [cdaa70e30e] to [572b41b936].

18
19
20
21
22
23
24

25

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

26
27
28
29
30
31
32
33







+
-
+







void
renderclient(
    DynamicEntity *d, bool team, OFString *mdlname, bool hellpig, float scale)
{
	int n = 3;
	float speed = 100.0f;
	float mz = d.o.z - d.eyeheight + 1.55f * scale;
	intptr_t tmp = (intptr_t)d;
	int basetime = -((intptr_t)d & 0xFFF);
	int basetime = -(tmp & 0xFFF);
	if (d.state == CS_DEAD) {
		int r;
		if (hellpig) {
			n = 2;
			r = range[3];
		} else {
			n = (intptr_t)d % 3;

Modified src/clients.m from [6783fe61cf] to [edb3579f73].

368
369
370
371
372
373
374

375
376

377
378
379
380
381


382
383
384
385
386

387
388


389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410


411

412
368
369
370
371
372
373
374
375
376
377
378
379
380
381


382
383
384
385
386
387
388
389


390
391
392
393
394
395
396
397

398
399
400
401
402
403
404
405

406
407
408
409
410
411
412
413
414
415
416







+


+



-
-
+
+





+
-
-
+
+






-








-






+
+

+

		loadgamerest(); // hack
}

void
gets2c() // get updates from the server
{
	ENetEvent event;

	if (!clienthost)
		return;

	if (connecting && lastmillis / 3000 > connecting / 3000) {
		conoutf(@"attempting to connect...");
		connecting = lastmillis;
		++connattempts;
		if (connattempts > 3) {

		if (++connattempts > 3) {
			conoutf(@"could not connect to server");
			disconnect(false, false);
			return;
		}
	}

	while (
	    clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0)
	while (clienthost != NULL &&
	    enet_host_service(clienthost, &event, 0) > 0) {
		switch (event.type) {
		case ENET_EVENT_TYPE_CONNECT:
			conoutf(@"connected to server");
			connecting = 0;
			throttle();
			break;

		case ENET_EVENT_TYPE_RECEIVE:
			if (disconnecting)
				conoutf(@"attempting to disconnect...");
			else
				localservertoclient(event.packet->data,
				    event.packet->dataLength);
			enet_packet_destroy(event.packet);
			break;

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

Modified src/editing.m from [27b5ed2226] to [3450764149].

450
451
452
453
454
455
456
457

458
459
460
461
462
463
464
450
451
452
453
454
455
456

457
458
459
460
461
462
463
464







-
+







}

void
edittype(int type)
{
	EDITSEL;
	if (type == CORNER &&
	    (sel.xs != sel.ys || sel.xs == 3 || sel.xs > 4 && sel.xs != 8 ||
	    (sel.xs != sel.ys || sel.xs == 3 || (sel.xs > 4 && sel.xs != 8) ||
	        sel.x & ~-sel.xs || sel.y & ~-sel.ys)) {
		conoutf(@"corner selection must be power of 2 aligned");
		return;
	}
	edittypexy(type, &sel);
	addmsg(1, 6, SV_EDITS, sel.x, sel.y, sel.xs, sel.ys, type);
}

Modified src/meson.build from [d01d70dfdd] to [d366589544].

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







-







    'Identifier.m',
    'KeyMapping.m',
    'MD2.m',
    'MapModelInfo.m',
    'Menu.m',
    'MenuItem.m',
    'OFString+Cube.m',
    'PersistentEntity.m',
    'Projectile.m',
    'ResolverResult.m',
    'ResolverThread.m',
    'ServerEntity.m',
    'ServerInfo.m',
    'Variable.m',
    'clients.m',

Modified src/physics.m from [1c146ff92c] to [25a7c9cd46].

109
110
111
112
113
114
115

116
117
118
119
120
121
122

123
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
109
110
111
112
113
114
115
116
117
118
119

120
121

122
123
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







+



-


-
+


-
-
+
+


-
-
+
+


-
-
+
+


-
+



-
-
-
+
+
+





-






+







		for (int y = y1; y <= y2; y++) {
			// collide with map
			if (OUTBORD(x, y))
				return false;
			struct sqr *s = S(x, y);
			float ceil = s->ceil;
			float floor = s->floor;

			switch (s->type) {
			case SOLID:
				return false;

			case CORNER: {
				int bx = x, by = y, bs = 1;
				if (x == x1 && y == y1 &&
				if ((x == x1 && y == y1 &&
				        cornertest(
				            0, x, y, -1, -1, &bx, &by, &bs) &&
				        fx1 - bx + fy1 - by <= bs ||
				    x == x2 && y == y1 &&
				        fx1 - bx + fy1 - by <= bs) ||
				    (x == x2 && y == y1 &&
				        cornertest(
				            0, x, y, 1, -1, &bx, &by, &bs) &&
				        fx2 - bx >= fy1 - by ||
				    x == x1 && y == y2 &&
				        fx2 - bx >= fy1 - by) ||
				    (x == x1 && y == y2 &&
				        cornertest(
				            0, x, y, -1, 1, &bx, &by, &bs) &&
				        fx1 - bx <= fy2 - by ||
				    x == x2 && y == y2 &&
				        fx1 - bx <= fy2 - by) ||
				    (x == x2 && y == y2 &&
				        cornertest(
				            0, x, y, 1, 1, &bx, &by, &bs) &&
				        fx2 - bx + fy2 - by >= bs)
				        fx2 - bx + fy2 - by >= bs))
					return false;
				break;
			}

			case FHF: // FIXME: too simplistic collision with
			          // slopes, makes it feels like tiny stairs
			// FIXME: too simplistic collision with slopes, makes
			// it feels like tiny stairs
			case FHF:
				floor -= (s->vdelta + S(x + 1, y)->vdelta +
				             S(x, y + 1)->vdelta +
				             S(x + 1, y + 1)->vdelta) /
				    16.0f;
				break;

			case CHF:
				ceil += (s->vdelta + S(x + 1, y)->vdelta +
				            S(x, y + 1)->vdelta +
				            S(x + 1, y + 1)->vdelta) /
				    16.0f;
			}

			if (ceil < hi)
				hi = ceil;
			if (floor > lo)
				lo = floor;
			if (floor < minfloor)
				return false;
		}

Modified src/server.m from [761c67a79c] to [7cdeba7547].

479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494


495
496
497
498
499
500
501
479
480
481
482
483
484
485

486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502







-








+
+







		}
		case ENET_EVENT_TYPE_RECEIVE:
			brec += event.packet->dataLength;
			process(event.packet, (intptr_t)event.peer->data);
			if (event.packet->referenceCount == 0)
				enet_packet_destroy(event.packet);
			break;

		case ENET_EVENT_TYPE_DISCONNECT:
			if ((intptr_t)event.peer->data < 0)
				break;
			[OFStdOut writeFormat:@"disconnected client (%@)\n",
			          clients[(size_t)event.peer->data].hostname];
			clients[(size_t)event.peer->data].type = ST_EMPTY;
			send2(true, -1, SV_CDIS, (intptr_t)event.peer->data);
			event.peer->data = (void *)-1;
			break;
		case ENET_EVENT_TYPE_NONE:
			break;
		}

		if (numplayers > maxclients)
			disconnect_client(lastconnect, @"maxclients reached");
	}
#ifndef _WIN32

Modified src/world.m from [861b8a0f13] to [16c30b946f].

125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
140
141
142
125
126
127
128
129
130
131

132
133
134

135
136
137
138
139
140
141







-
+


-







			loopi(MAXTYPE) nums[i] = 0;
			loopj(4) nums[o[j]->type]++;
			// cube contains both solid and space, treated
			// specially in the renderer
			r->type = SEMISOLID;
			loopk(MAXTYPE) if (nums[k] == 4) r->type = k;
			if (!SOLID(r)) {
				int floor = 127, ceil = -128, num = 0;
				int floor = 127, ceil = -128;
				loopi(4) if (!SOLID(o[i]))
				{
					num++;
					int fh = o[i]->floor;
					int ch = o[i]->ceil;
					if (r->type == SEMISOLID) {
						if (o[i]->type == FHF)
							// crap hack, needed
							// for rendering large
							// mips next to hfs
328
329
330
331
332
333
334
335

336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368

369
370
371
372
373
374
375
327
328
329
330
331
332
333

334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352

353
354
355
356
357
358
359
360
361
362
363
364
365

366
367
368
369
370
371
372
373







-
+


















-













-
+







}

Entity *
newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
{
	int type = findtype(what);

	PersistentEntity *e = [PersistentEntity entity];
	Entity *e = [Entity entity];
	e.x = x;
	e.y = y;
	e.z = z;
	e.attr1 = v1;
	e.type = type;
	e.attr2 = v2;
	e.attr3 = v3;
	e.attr4 = v4;

	switch (type) {
	case LIGHT:
		if (v1 > 32)
			v1 = 32;
		if (!v1)
			e.attr1 = 16;
		if (!v2 && !v3 && !v4)
			e.attr2 = 255;
		break;

	case MAPMODEL:
		e.attr4 = e.attr3;
		e.attr3 = e.attr2;
	case MONSTER:
	case TELEDEST:
		e.attr2 = (uchar)e.attr1;
	case PLAYERSTART:
		e.attr1 = (int)player1.yaw;
		break;
	}
	addmsg(1, 10, SV_EDITENT, ents.count, type, e.x, e.y, e.z, e.attr1,
	    e.attr2, e.attr3, e.attr4);

	[ents addObject:e]; // unsafe!
	[ents addObject:e];

	if (type == LIGHT)
		calclight();

	return e;
}

Modified src/worldlight.m from [49154c0e62] to [feb6b04e94].

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

16
17
18
19
20
21
22
1
2
3
4
5
6

7
8
9
10
11
12
13

14
15
16
17
18
19
20
21






-







-
+







// worldlight.cpp

#include "cube.h"

#import "DynamicEntity.h"
#import "Entity.h"
#import "PersistentEntity.h"

extern bool hasoverbright;

VAR(lightscale, 1, 4, 100);

// done in realtime, needs to be fast
void
lightray(float bx, float by, PersistentEntity *light)
lightray(float bx, float by, Entity *light)
{
	float lx = light.x + (rnd(21) - 10) * 0.1f;
	float ly = light.y + (rnd(21) - 10) * 0.1f;
	float dx = bx - lx;
	float dy = by - ly;
	float dist = (float)sqrt(dx * dx + dy * dy);
	if (dist < 1.0f)
35
36
37
38
39
40
41
42
43
44


45

46
47
48
49
50
51
52
34
35
36
37
38
39
40



41
42

43
44
45
46
47
48
49
50







-
-
-
+
+
-
+







	    fast_f2nat(l / (float)steps); // incorrect: light will fade quicker
	                                  // if near edge of the world

	if (hasoverbright) {
		l /= lightscale;
		stepl /= lightscale;

		if (light.attr3 ||
		    light.attr4) // coloured light version, special case because
		                 // most lights are white
		// coloured light version, special case because most lights are
		// white
		{
		if (light.attr3 || light.attr4) {
			int dimness = rnd(
			    (255 -
			        (light.attr2 + light.attr3 + light.attr4) / 3) /
			        16 +
			    1);
			x += stepx * dimness;
			y += stepy * dimness;
119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131







-
+







			y += stepy;
			l -= stepl;
		}
	}
}

void
calclightsource(PersistentEntity *l)
calclightsource(Entity *l)
{
	int reach = l.attr1;
	int sx = l.x - reach;
	int ex = l.x + reach;
	int sy = l.y - reach;
	int ey = l.y + reach;

231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
229
230
231
232
233
234
235

236
237
238
239
240
241
242
243







-
+







		dlights = [[OFMutableData alloc]
		    initWithItemSize:sizeof(struct block *)];

	// backup area before rendering in dynlight
	struct block *copy = blockcopy(&b);
	[dlights addItem:&copy];

	PersistentEntity *l = [Entity entity];
	Entity *l = [Entity entity];
	l.x = v->x;
	l.y = v->y;
	l.z = v->z;
	l.attr1 = reach;
	l.type = LIGHT;
	l.attr2 = strength;
	calclightsource(l);