Cube  Diff

Differences From Artifact [50f4e28f8c]:

To Artifact [e205b06d1f]:


21
22
23
24
25
26
27
28

29
30
31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46
			if (tag) {
				if (tag == s->tag)
					s->type = SPACE;
				else
					continue;
			} else {
				s->type = type ? SOLID : SPACE;
			};

			if (x > maxx)
				maxx = x;
			if (y > maxy)
				maxy = y;
			if (x < minx)
				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
}

void
resettagareas()
{







<
>








<
|
>
|







21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45
46
			if (tag) {
				if (tag == s->tag)
					s->type = SPACE;
				else
					continue;
			} else {
				s->type = type ? SOLID : SPACE;

			}
			if (x > maxx)
				maxx = x;
			if (y > maxy)
				maxy = y;
			if (x < minx)
				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
}

void
resettagareas()
{
93
94
95
96
97
98
99
100

101
102
103
104

105
106
107
108
109
110
111
	sqr *v = wmip[level + 1];
	int ws = ssize >> level;
	int vs = ssize >> (level + 1);
	block s = b;
	if (s.x & 1) {
		s.x--;
		s.xs++;
	};

	if (s.y & 1) {
		s.y--;
		s.ys++;
	};

	s.xs = (s.xs + 1) & ~1;
	s.ys = (s.ys + 1) & ~1;
	for (int x = s.x; x < s.x + s.xs; x += 2)
		for (int y = s.y; y < s.y + s.ys; y += 2) {
			sqr *o[4];
			o[0] = SWS(w, x, y, ws); // the 4 constituent cubes
			o[1] = SWS(w, x + 1, y, ws);







<
>



<
>







93
94
95
96
97
98
99

100
101
102
103

104
105
106
107
108
109
110
111
	sqr *v = wmip[level + 1];
	int ws = ssize >> level;
	int vs = ssize >> (level + 1);
	block s = b;
	if (s.x & 1) {
		s.x--;
		s.xs++;

	}
	if (s.y & 1) {
		s.y--;
		s.ys++;

	}
	s.xs = (s.xs + 1) & ~1;
	s.ys = (s.ys + 1) & ~1;
	for (int x = s.x; x < s.x + s.xs; x += 2)
		for (int y = s.y; y < s.y + s.ys; y += 2) {
			sqr *o[4];
			o[0] = SWS(w, x, y, ws); // the 4 constituent cubes
			o[1] = SWS(w, x + 1, y, ws);
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
							ch += o[i]->vdelta / 4 +
							    2; // FIXME: needs
							       // to somehow
							       // take into
							       // account middle
							       // vertices on
							       // higher mips
					};

					if (fh < floor)
						floor =
						    fh; // take lowest floor and
						        // highest ceil, so we
						        // never have to see
						        // missing lower/upper
						        // from the side
					if (ch > ceil)
						ceil = ch;
				}
				r->floor = floor;
				r->ceil = ceil;
			};

			if (r->type == CORNER)
				goto mip; // special case: don't ever split even
				          // if textures etc are different
			r->defer = 1;
			if (SOLID(r)) {
				loopi(3)
				{







<
>












<
>







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
							ch += o[i]->vdelta / 4 +
							    2; // FIXME: needs
							       // to somehow
							       // take into
							       // account middle
							       // vertices on
							       // higher mips

					}
					if (fh < floor)
						floor =
						    fh; // take lowest floor and
						        // highest ceil, so we
						        // never have to see
						        // missing lower/upper
						        // from the side
					if (ch > ceil)
						ceil = ch;
				}
				r->floor = floor;
				r->ceil = ceil;

			}
			if (r->type == CORNER)
				goto mip; // special case: don't ever split even
				          // if textures etc are different
			r->defer = 1;
			if (SOLID(r)) {
				loopi(3)
				{
214
215
216
217
218
219
220
221
222


223
224
225
226
227
228
229
230

231
232
233
234
235
236
237
					            SWS(w, x + 2, y + 1, ws)
					                ->vdelta ||
					    o[1]->vdelta - o[2]->vdelta !=
					        o[2]->vdelta -
					            SWS(w, x + 1, y + 2, ws)
					                ->vdelta)
						goto c;
				};
			};


			{
				loopi(4) if (o[i]->defer) goto c;
			}; // if any of the constituents is not perfect, then
			   // this one isn't either
		mip:
			r->defer = 0;
		c:;
		};

	s.x /= 2;
	s.y /= 2;
	s.xs /= 2;
	s.ys /= 2;
	remip(s, level + 1);
}








<
<
>
>


|
|



<
>







214
215
216
217
218
219
220


221
222
223
224
225
226
227
228
229

230
231
232
233
234
235
236
237
					            SWS(w, x + 2, y + 1, ws)
					                ->vdelta ||
					    o[1]->vdelta - o[2]->vdelta !=
					        o[2]->vdelta -
					            SWS(w, x + 1, y + 2, ws)
					                ->vdelta)
						goto c;


				}
			}
			{
				loopi(4) if (o[i]->defer) goto c;
			} // if any of the constituents is not perfect, then
			  // this one isn't either
		mip:
			r->defer = 0;
		c:;

		}
	s.x /= 2;
	s.y /= 2;
	s.xs /= 2;
	s.ys /= 2;
	remip(s, level + 1);
}

263
264
265
266
267
268
269
270

271
272
273
274
275
276
277
		if (e.type == NOTUSED)
			continue;
		OFVector3D v = OFMakeVector3D(e.x, e.y, e.z);
		vdist(dist, t, player1->o, v);
		if (dist < bdist) {
			best = i;
			bdist = dist;
		};

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

void
entproperty(int prop, int amount)
{







<
>







263
264
265
266
267
268
269

270
271
272
273
274
275
276
277
		if (e.type == NOTUSED)
			continue;
		OFVector3D v = OFMakeVector3D(e.x, e.y, e.z);
		vdist(dist, t, player1->o, v);
		if (dist < bdist) {
			best = i;
			bdist = dist;

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

void
entproperty(int prop, int amount)
{
287
288
289
290
291
292
293
294

295
296
297
298
299
300
301
		break;
	case 2:
		ents[e].attr3 += amount;
		break;
	case 3:
		ents[e].attr4 += amount;
		break;
	};

}

void
delent()
{
	int e = closestent();
	if (e < 0) {







<
>







287
288
289
290
291
292
293

294
295
296
297
298
299
300
301
		break;
	case 2:
		ents[e].attr3 += amount;
		break;
	case 3:
		ents[e].attr4 += amount;
		break;

	}
}

void
delent()
{
	int e = closestent();
	if (e < 0) {
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
357
	}
}

entity *
newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
{
	int type = findtype(what);
	persistent_entity e = {(short)x, (short)y, (short)z, (short)v1,
	    (uchar)type, (uchar)v2, (uchar)v3, (uchar)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.length(), type, e.x, e.y, e.z, e.attr1,
	    e.attr2, e.attr3, e.attr4);
	ents.add(*((entity *)&e)); // unsafe!
	if (type == LIGHT)
		calclight();
	return &ents.last();
}







|
|



















<
>







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
357
	}
}

entity *
newentity(int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4)
{
	int type = findtype(what);
	persistent_entity e = { (short)x, (short)y, (short)z, (short)v1,
		(uchar)type, (uchar)v2, (uchar)v3, (uchar)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.length(), type, e.x, e.y, e.z, e.attr1,
	    e.attr2, e.attr3, e.attr4);
	ents.add(*((entity *)&e)); // unsafe!
	if (type == LIGHT)
		calclight();
	return &ents.last();
}
395
396
397
398
399
400
401
402

403
404
405
406
407
408
409
			e.attr1 = 2;
		if (e.attr1 > 32)
			e.attr1 = 32;
		if (intens) {
			scalecomp(e.attr2, intens);
			scalecomp(e.attr3, intens);
			scalecomp(e.attr4, intens);
		};

	}
	calclight();
}
COMMAND(scalelights, ARG_2INT)

int
findentity(int type, int index)







<
>







395
396
397
398
399
400
401

402
403
404
405
406
407
408
409
			e.attr1 = 2;
		if (e.attr1 > 32)
			e.attr1 = 32;
		if (intens) {
			scalecomp(e.attr2, intens);
			scalecomp(e.attr3, intens);
			scalecomp(e.attr4, intens);

		}
	}
	calclight();
}
COMMAND(scalelights, ARG_2INT)

int
findentity(int type, int index)
441
442
443
444
445
446
447
448

449
450
451
452
453
454
455
	cleardlights();
	pruneundos();
	sqr *oldworld = world;
	bool copy = false;
	if (oldworld && factor < 0) {
		factor = sfactor + 1;
		copy = true;
	};

	if (factor < SMALLEST_FACTOR)
		factor = SMALLEST_FACTOR;
	if (factor > LARGEST_FACTOR)
		factor = LARGEST_FACTOR;
	setupworld(factor);

	loop(x, ssize) loop(y, ssize)







<
>







441
442
443
444
445
446
447

448
449
450
451
452
453
454
455
	cleardlights();
	pruneundos();
	sqr *oldworld = world;
	bool copy = false;
	if (oldworld && factor < 0) {
		factor = sfactor + 1;
		copy = true;

	}
	if (factor < SMALLEST_FACTOR)
		factor = SMALLEST_FACTOR;
	if (factor > LARGEST_FACTOR)
		factor = LARGEST_FACTOR;
	setupworld(factor);

	loop(x, ssize) loop(y, ssize)
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
		}
	} else {
		strn0cpy(hdr.maptitle, "Untitled Map by Unknown", 128);
		hdr.waterlevel = -100000;
		loopi(15) hdr.reserved[i] = 0;
		loopk(3) loopi(256) hdr.texlists[k][i] = i;
		ents.setsize(0);
		block b = {8, 8, ssize - 16, ssize - 16};
		edittypexy(SPACE, b);
	}

	calclight();
	startmap(@"base/unnamed");
	if (oldworld) {
		free(oldworld);







|







484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
		}
	} else {
		strn0cpy(hdr.maptitle, "Untitled Map by Unknown", 128);
		hdr.waterlevel = -100000;
		loopi(15) hdr.reserved[i] = 0;
		loopk(3) loopi(256) hdr.texlists[k][i] = i;
		ents.setsize(0);
		block b = { 8, 8, ssize - 16, ssize - 16 };
		edittypexy(SPACE, b);
	}

	calclight();
	startmap(@"base/unnamed");
	if (oldworld) {
		free(oldworld);