1
2
3
4
5
6
7
8
9
10
11
12
|
// editing.cpp: most map editing commands go here, entity editing commands are
// in world.cpp
#include "cube.h"
bool editmode = false;
// the current selection, used by almost all editing commands
// invariant: all code assumes that these are kept inside MINBORD distance of
// the edge of the map
block sel;
|
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
// editing.cpp: most map editing commands go here, entity editing commands are
// in world.cpp
#include "cube.h"
#import "DynamicEntity.h"
bool editmode = false;
// the current selection, used by almost all editing commands
// invariant: all code assumes that these are kept inside MINBORD distance of
// the edge of the map
block sel;
|
︙ | | | ︙ | |
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
|
sqr rtex;
VAR(editing, 0, 0, 1);
void
toggleedit()
{
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)
monsterclear(); // all monsters back at their spawns for
// editing
projreset();
}
Cube.sharedInstance.repeatsKeys = editmode;
selset = false;
|
|
|
|
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
|
sqr rtex;
VAR(editing, 0, 0, 1);
void
toggleedit()
{
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)
monsterclear(); // all monsters back at their spawns for
// editing
projreset();
}
Cube.sharedInstance.repeatsKeys = editmode;
selset = false;
|
︙ | | | ︙ | |
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
171
172
173
174
175
176
177
|
? (s->type == FHF ? s->floor - t->vdelta / 4.0f : (float)s->floor)
: (s->type == CHF ? s->ceil + t->vdelta / 4.0f : (float)s->ceil);
}
void
cursorupdate() // called every frame from hud
{
flrceil = ((int)(player1->pitch >= 0)) * 2;
volatile float x =
worldpos.x; // volatile needed to prevent msvc7 optimizer bug?
volatile float y = worldpos.y;
volatile float z = worldpos.z;
cx = (int)x;
cy = (int)y;
if (OUTBORD(cx, cy))
return;
sqr *s = S(cx, cy);
// selected wall
if (fabs(sheight(s, s, z) - z) > 1) {
x += x > player1->o.x ? 0.5f : -0.5f; // find right wall cube
y += y > player1->o.y ? 0.5f : -0.5f;
cx = (int)x;
cy = (int)y;
if (OUTBORD(cx, cy))
return;
}
|
|
|
|
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
? (s->type == FHF ? s->floor - t->vdelta / 4.0f : (float)s->floor)
: (s->type == CHF ? s->ceil + t->vdelta / 4.0f : (float)s->ceil);
}
void
cursorupdate() // called every frame from hud
{
flrceil = ((int)(player1.pitch >= 0)) * 2;
volatile float x =
worldpos.x; // volatile needed to prevent msvc7 optimizer bug?
volatile float y = worldpos.y;
volatile float z = worldpos.z;
cx = (int)x;
cy = (int)y;
if (OUTBORD(cx, cy))
return;
sqr *s = S(cx, cy);
// selected wall
if (fabs(sheight(s, s, z) - z) > 1) {
x += x > player1.o.x ? 0.5f : -0.5f; // find right wall cube
y += y > player1.o.y ? 0.5f : -0.5f;
cx = (int)x;
cy = (int)y;
if (OUTBORD(cx, cy))
return;
}
|
︙ | | | ︙ | |
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
p[0] = t;
curedittex[i] = -1;
}
}
}
void
editdrag(bool isdown)
{
if (dragging = isdown) {
lastx = cx;
lasty = cy;
lasth = ch;
selset = false;
tofronttex();
}
makesel();
|
|
|
|
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
p[0] = t;
curedittex[i] = -1;
}
}
}
void
editdrag(bool isDown)
{
if ((dragging = isDown)) {
lastx = cx;
lasty = cy;
lasth = ch;
selset = false;
tofronttex();
}
makesel();
|
︙ | | | ︙ | |
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
|
}
void
newent(OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4)
{
EDITSEL;
@autoreleasepool {
newentity(sel.x, sel.y, (int)player1->o.z, what,
(int)[a1 longLongValueWithBase:0],
(int)[a2 longLongValueWithBase:0],
(int)[a3 longLongValueWithBase:0],
(int)[a4 longLongValueWithBase:0]);
}
}
|
|
|
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
|
}
void
newent(OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4)
{
EDITSEL;
@autoreleasepool {
newentity(sel.x, sel.y, (int)player1.o.z, what,
(int)[a1 longLongValueWithBase:0],
(int)[a2 longLongValueWithBase:0],
(int)[a3 longLongValueWithBase:0],
(int)[a4 longLongValueWithBase:0]);
}
}
|
︙ | | | ︙ | |