Cube  Diff

Differences From Artifact [1c22ea0614]:

To Artifact [a8feb3f63c]:


62
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
62
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







-
+
















-
-
+
+





-
+


-
+








// set for playing
void
settagareas()
{
	settag(0, 1);

	[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
	[ents enumerateObjectsUsingBlock: ^ (Entity *e, size_t i, bool *stop) {
		if (ents[i].type == CARROT)
			setspawn(i, true);
	}];
}

void
trigger(int tag, int type, bool savegame)
{
	if (!tag)
		return;

	settag(tag, type);

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

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

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

	if (type == 2)
		[Monster endSinglePlayerWithAllKilled:false];
		[Monster endSinglePlayerWithAllKilled: false];
}

COMMAND(trigger, ARG_2INT, ^(int tag, int type, bool savegame) {
COMMAND(trigger, ARG_2INT, ^ (int tag, int type, bool savegame) {
	trigger(tag, type, savegame);
})

// main geometric mipmapping routine, recursively rebuild mipmaps within block
// b. tries to produce cube out of 4 lower level mips as well as possible, sets
// defer to 0 if mipped cube is a perfect mip, i.e. can be rendered at this mip
// level indistinguishable from its constituent cubes (saves considerable
289
290
291
292
293
294
295
296

297
298
299
300
301
302
303
304
305
306
307
308
309
310
311

312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
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
289
290
291
292
293
294
295

296
297
298
299
300
301
302
303
304
305
306
307
308
309
310

311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
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







-
+














-
+



















-
+

















-
+







closestent() // used for delent and edit mode ent display
{
	if (noteditmode())
		return -1;

	__block int best;
	__block float bdist = 99999;
	[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
	[ents enumerateObjectsUsingBlock: ^ (Entity *e, size_t i, bool *stop) {
		if (e.type == NOTUSED)
			return;

		OFVector3D v = OFMakeVector3D(e.x, e.y, e.z);
		float dist = OFDistanceOfVectors3D(v, Player.player1.origin);
		if (dist < bdist) {
			best = i;
			bdist = dist;
		}
	}];

	return (bdist == 99999 ? -1 : best);
}

COMMAND(entproperty, ARG_2INT, ^(int prop, int amount) {
COMMAND(entproperty, ARG_2INT, ^ (int prop, int amount) {
	int e = closestent();
	if (e < 0)
		return;
	switch (prop) {
	case 0:
		ents[e].attr1 += amount;
		break;
	case 1:
		ents[e].attr2 += amount;
		break;
	case 2:
		ents[e].attr3 += amount;
		break;
	case 3:
		ents[e].attr4 += amount;
		break;
	}
})

COMMAND(delent, ARG_NONE, ^{
COMMAND(delent, ARG_NONE, ^ {
	int e = closestent();
	if (e < 0) {
		conoutf(@"no more entities");
		return;
	}
	int t = ents[e].type;
	conoutf(@"%@ entity deleted", entnames[t]);
	ents[e].type = NOTUSED;
	addmsg(1, 10, SV_EDITENT, e, NOTUSED, 0, 0, 0, 0, 0, 0, 0);
	if (t == LIGHT)
		calclight();
})

int
findtype(OFString *what)
{
	for (int i = 0; i < MAXENTTYPES; i++)
		if ([what isEqual:entnames[i]])
		if ([what isEqual: entnames[i]])
			return i;
	conoutf(@"unknown entity type \"%@\"", what);
	return NOTUSED;
}

Entity *
newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
385
386
387
388
389
390
391
392

393
394
395
396
397
398
399
400

401
402
403
404
405
406
407
385
386
387
388
389
390
391

392
393
394
395
396
397
398
399

400
401
402
403
404
405
406
407







-
+







-
+







	case PLAYERSTART:
		e.attr1 = (int)Player.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];
	[ents addObject: e];

	if (type == LIGHT)
		calclight();

	return e;
}

COMMAND(clearents, ARG_1STR, ^(OFString *name) {
COMMAND(clearents, ARG_1STR, ^ (OFString *name) {
	int type = findtype(name);

	if (noteditmode() || multiplayer())
		return;

	for (Entity *e in ents)
		if (e.type == type)
416
417
418
419
420
421
422
423

424
425
426
427
428
429
430
416
417
418
419
420
421
422

423
424
425
426
427
428
429
430







-
+







{
	int n = c * intens / 100;
	if (n > 255)
		n = 255;
	return n;
}

COMMAND(scalelights, ARG_2INT, ^(int f, int intens) {
COMMAND(scalelights, ARG_2INT, ^ (int f, int intens) {
	for (Entity *e in ents) {
		if (e.type != LIGHT)
			continue;

		e.attr1 = e.attr1 * f / 100;
		if (e.attr1 < 2)
			e.attr1 = 2;
541
542
543
544
545
546
547
548

549
550
551
552

553
554
555
556

557
558
541
542
543
544
545
546
547

548
549
550
551

552
553
554
555

556
557
558







-
+



-
+



-
+


	if (oldworld) {
		OFFreeMemory(oldworld);
		toggleedit();
		execute(@"fullbright 1", true);
	}
}

COMMAND(mapenlarge, ARG_NONE, ^{
COMMAND(mapenlarge, ARG_NONE, ^ {
	empty_world(-1, false);
})

COMMAND(newmap, ARG_1INT, ^(int i) {
COMMAND(newmap, ARG_1INT, ^ (int i) {
	empty_world(i, false);
})

COMMAND(recalc, ARG_NONE, ^{
COMMAND(recalc, ARG_NONE, ^ {
	calclight();
})