Cube  Diff

Differences From Artifact [1510ae8332]:

To Artifact [974268cfe4]:


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
		}
	});
}

int selh = 0;
bool selset = false;

#define loopselxy(b)                                                       \
	{                                                                  \
		makeundo();                                                \
		for (int x = 0; x < sel->xs; x++) {                        \
			for (int y = 0; y < sel->ys; y++) {                \
				struct sqr *s = S(sel->x + x, sel->y + y); \
				b;                                         \
			}                                                  \
		}                                                          \
		remip(sel, 0);                                             \
	}

int cx, cy, ch;

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

bool dragging = false;
int lastx, lasty, lasth;

int lasttype = 0, lasttex = 0;
static struct sqr rtex;

VAR(editing, 0, 0, 1);

void
toggleedit()
{
	Player *player1 = Player.player1;
	if (player1.state == CS_DEAD)
		return; // do not allow dead players to edit to avoid state
		        // confusion
	if (!editmode && !allowedittoggle())
		return; // not in most multiplayer modes

	if (!(editmode = !editmode)) {
		settagareas();     // reset triggers to allow quick playtesting

		entinmap(player1); // find spawn closest to current floating pos

	} else {
		resettagareas(); // clear trigger areas to allow them to be
		                 // edited

		player1.health = 100;
		if (m_classicsp)
			// all monsters back at their spawns for editing
			[Monster resetAll];
		projreset();
	}
	Cube.sharedInstance.repeatsKeys = editmode;







|
|
|
|
|

|
|
|
|



















|
|

|
>

|
>
|
>

|
<
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
		}
	});
}

int selh = 0;
bool selset = false;

#define loopselxy(b)							   \
	{								   \
		makeundo();						   \
		for (int x = 0; x < sel->xs; x++) {			   \
			for (int y = 0; y < sel->ys; y++) {		   \
				struct sqr *s = S(sel->x + x, sel->y + y); \
				b;					   \
			}						   \
		}							   \
		remip(sel, 0);						   \
	}

int cx, cy, ch;

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

bool dragging = false;
int lastx, lasty, lasth;

int lasttype = 0, lasttex = 0;
static struct sqr rtex;

VAR(editing, 0, 0, 1);

void
toggleedit()
{
	Player *player1 = Player.player1;
	if (player1.state == CS_DEAD)
		// do not allow dead players to edit to avoid state
		return;
	if (!editmode && !allowedittoggle())
		// not in most multiplayer modes
		return;
	if (!(editmode = !editmode)) {
		// reset triggers to allow quick playtesting
		settagareas();
		// find spawn closest to current floating pos
		entinmap(player1);
	} else {
		// clear trigger areas to allow them to be edited

		resettagareas();
		player1.health = 100;
		if (m_classicsp)
			// all monsters back at their spawns for editing
			[Monster resetAll];
		projreset();
	}
	Cube.sharedInstance.repeatsKeys = editmode;
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
noselection()
{
	if (!selset)
		conoutf(@"no selection");
	return !selset;
}

#define EDITSEL                             \
	if (noteditmode() || noselection()) \
		return;
#define EDITSELMP                                            \
	if (noteditmode() || noselection() || multiplayer()) \
		return;
#define EDITMP                              \
	if (noteditmode() || multiplayer()) \
		return;

COMMAND(select, ARG_4INT, (^ (int x, int y, int xs, int ys) {
	struct block s = { x, y, xs, ys };
	sel = s;
	selh = 0;
	correctsel();







|
|

|
|

|
|







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
noselection()
{
	if (!selset)
		conoutf(@"no selection");
	return !selset;
}

#define EDITSEL					\
	if (noteditmode() || noselection())	\
		return;
#define EDITSELMP						\
	if (noteditmode() || noselection() || multiplayer())	\
		return;
#define EDITMP					\
	if (noteditmode() || multiplayer())	\
		return;

COMMAND(select, ARG_4INT, (^ (int x, int y, int xs, int ys) {
	struct block s = { x, y, xs, ys };
	sel = s;
	selh = 0;
	correctsel();
338
339
340
341
342
343
344

345
346
347
348
349
350
351
352
353
354
	}
	makeundo();
	copybuf->x = sel.x;
	copybuf->y = sel.y;
	blockpaste(copybuf);
})


void
tofronttex() // maintain most recently used of the texture lists when applying
             // texture
{
	for (int i = 0; i < 3; i++) {
		int c = curedittex[i];
		if (c >= 0) {
			unsigned char *p = hdr.texlists[i];
			int t = p[c];
			for (int a = c - 1; a >= 0; a--)







>

|
<







341
342
343
344
345
346
347
348
349
350

351
352
353
354
355
356
357
	}
	makeundo();
	copybuf->x = sel.x;
	copybuf->y = sel.y;
	blockpaste(copybuf);
})

// maintain most recently used of the texture lists when applying texture
void
tofronttex()

{
	for (int i = 0; i < 3; i++) {
		int c = curedittex[i];
		if (c >= 0) {
			unsigned char *p = hdr.texlists[i];
			int t = p[c];
			for (int a = c - 1; a >= 0; a--)
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
COMMAND(editheight, ARG_2INT, ^ (int flr, int amount) {
	editheight(flr, amount);
})

void
edittexxy(int type, int t, const struct block *sel)
{
	loopselxy(switch (type) {

	        case 0:
		        s->ftex = t;
		        break;
	        case 1:
		        s->wtex = t;
		        break;
	        case 2:
		        s->ctex = t;
		        break;
	        case 3:
		        s->utex = t;
		        break;

	});
}

COMMAND(edittex, ARG_2INT, ^ (int type, int dir) {
	EDITSEL;

	if (type < 0 || type > 3)
		return;







|
>
|
|
|
|
|
|
|
|
|
|
|
|
>
|







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
COMMAND(editheight, ARG_2INT, ^ (int flr, int amount) {
	editheight(flr, amount);
})

void
edittexxy(int type, int t, const struct block *sel)
{
	loopselxy(
		switch (type) {
		case 0:
			s->ftex = t;
			break;
		case 1:
			s->wtex = t;
			break;
		case 2:
			s->ctex = t;
			break;
		case 3:
			s->utex = t;
			break;
		}
	);
}

COMMAND(edittex, ARG_2INT, ^ (int type, int dir) {
	EDITSEL;

	if (type < 0 || type > 3)
		return;
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
}

static void
edittype(int type)
{
	EDITSEL;

	if (type == CORNER &&
	    (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);
}







<
|
|







487
488
489
490
491
492
493

494
495
496
497
498
499
500
501
502
}

static void
edittype(int type)
{
	EDITSEL;


	if (type == CORNER && (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);
}
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
		sel.xs = MAXARCHVERT;
	if (sel.ys > MAXARCHVERT)
		sel.ys = MAXARCHVERT;

	struct block *sel_ = &sel;
	// Ugly hack to make the macro work.
	struct 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, 0);
})

COMMAND(slope, ARG_2INT, ^ (int xd, int yd) {
	EDITSELMP;

	int off = 0;







|
<
|
|
|







582
583
584
585
586
587
588
589

590
591
592
593
594
595
596
597
598
599
		sel.xs = MAXARCHVERT;
	if (sel.ys > MAXARCHVERT)
		sel.ys = MAXARCHVERT;

	struct block *sel_ = &sel;
	// Ugly hack to make the macro work.
	struct 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, 0);
})

COMMAND(slope, ARG_2INT, ^ (int xd, int yd) {
	EDITSELMP;

	int off = 0;