︙ | | | ︙ | |
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
[stream writeFormat:@"name \"%@\"\nteam \"%@\"\n", player1.name,
player1.team];
}
void
connects(OFString *servername)
{
disconnect(1); // reset state
addserver(servername);
conoutf(@"attempting to connect to %@", servername);
ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT };
if (enet_address_set_host(&address, servername.UTF8String) < 0) {
conoutf(@"could not resolve server %@", servername);
return;
}
clienthost = enet_host_create(NULL, 1, rate, rate);
if (clienthost) {
enet_host_connect(clienthost, &address, 1);
enet_host_flush(clienthost);
connecting = lastmillis;
connattempts = 0;
} else {
conoutf(@"could not connect to server");
disconnect();
}
}
void
disconnect(int onlyclean, int async)
{
if (clienthost) {
if (!connecting && !disconnecting) {
enet_peer_disconnect(clienthost->peers);
enet_host_flush(clienthost);
disconnecting = lastmillis;
}
|
|
|
|
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
[stream writeFormat:@"name \"%@\"\nteam \"%@\"\n", player1.name,
player1.team];
}
void
connects(OFString *servername)
{
disconnect(true, false); // reset state
addserver(servername);
conoutf(@"attempting to connect to %@", servername);
ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT };
if (enet_address_set_host(&address, servername.UTF8String) < 0) {
conoutf(@"could not resolve server %@", servername);
return;
}
clienthost = enet_host_create(NULL, 1, rate, rate);
if (clienthost) {
enet_host_connect(clienthost, &address, 1);
enet_host_flush(clienthost);
connecting = lastmillis;
connattempts = 0;
} else {
conoutf(@"could not connect to server");
disconnect(false, false);
}
}
void
disconnect(bool onlyclean, bool async)
{
if (clienthost) {
if (!connecting && !disconnecting) {
enet_peer_disconnect(clienthost->peers);
enet_host_flush(clienthost);
disconnecting = lastmillis;
}
|
︙ | | | ︙ | |
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
{
if (!clienthost) {
conoutf(@"not connected");
return;
}
if (connecting) {
conoutf(@"aborting connection attempt");
disconnect();
return;
}
conoutf(@"attempting to disconnect...");
disconnect(0, !disconnecting);
}
static OFString *ctext;
|
|
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
{
if (!clienthost) {
conoutf(@"not connected");
return;
}
if (connecting) {
conoutf(@"aborting connection attempt");
disconnect(false, false);
return;
}
conoutf(@"attempting to disconnect...");
disconnect(0, !disconnecting);
}
static OFString *ctext;
|
︙ | | | ︙ | |
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
[messages addObject:msg];
}
void
server_err()
{
conoutf(@"server network error, disconnecting...");
disconnect();
}
int lastupdate = 0, lastping = 0;
OFString *toservermap;
bool senditemstoserver =
false; // after a map change, since server doesn't have map data
|
|
|
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
[messages addObject:msg];
}
void
server_err()
{
conoutf(@"server network error, disconnecting...");
disconnect(false, false);
}
int lastupdate = 0, lastping = 0;
OFString *toservermap;
bool senditemstoserver =
false; // after a map change, since server doesn't have map data
|
︙ | | | ︙ | |
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
return;
if (connecting && lastmillis / 3000 > connecting / 3000) {
conoutf(@"attempting to connect...");
connecting = lastmillis;
++connattempts;
if (connattempts > 3) {
conoutf(@"could not connect to server");
disconnect();
return;
}
}
while (
clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0)
switch (event.type) {
case ENET_EVENT_TYPE_CONNECT:
|
|
|
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
return;
if (connecting && lastmillis / 3000 > connecting / 3000) {
conoutf(@"attempting to connect...");
connecting = lastmillis;
++connattempts;
if (connattempts > 3) {
conoutf(@"could not connect to server");
disconnect(false, false);
return;
}
}
while (
clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0)
switch (event.type) {
case ENET_EVENT_TYPE_CONNECT:
|
︙ | | | ︙ | |
402
403
404
405
406
407
408
409
410
411
412
413
414
|
localservertoclient(event.packet->data,
event.packet->dataLength);
enet_packet_destroy(event.packet);
break;
case ENET_EVENT_TYPE_DISCONNECT:
if (disconnecting)
disconnect();
else
server_err();
return;
}
}
|
|
|
402
403
404
405
406
407
408
409
410
411
412
413
414
|
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;
}
}
|
︙ | | | ︙ | |
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
extern OFString *toservermap;
extern OFString *clientpassword;
void
neterr(OFString *s)
{
conoutf(@"illegal network message (%@)", s);
disconnect();
}
void
changemapserv(OFString *name, int mode) // forced map change from the server
{
gamemode = mode;
load_world(name);
|
|
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
extern OFString *toservermap;
extern OFString *clientpassword;
void
neterr(OFString *s)
{
conoutf(@"illegal network message (%@)", s);
disconnect(false, false);
}
void
changemapserv(OFString *name, int mode) // forced map change from the server
{
gamemode = mode;
load_world(name);
|
︙ | | | ︙ | |
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
104
105
106
107
108
109
110
|
// processes any updates from the server
void
localservertoclient(uchar *buf, int len)
{
if (ENET_NET_TO_HOST_16(*(ushort *)buf) != len)
neterr(@"packet length");
incomingdemodata(buf, len);
uchar *end = buf + len;
uchar *p = buf + 2;
char text[MAXTRANS];
int cn = -1, type;
DynamicEntity *d = nil;
bool mapchanged = false;
while (p < end)
switch (type = getint(&p)) {
case SV_INITS2C: // welcome messsage from the server
{
cn = getint(&p);
int prot = getint(&p);
if (prot != PROTOCOL_VERSION) {
conoutf(@"you are using a different game "
@"protocol (you: %d, server: %d)",
PROTOCOL_VERSION, prot);
disconnect();
return;
}
toservermap = @"";
clientnum = cn; // we are now fully connected
if (!getint(&p))
// we are the first client on this server, set
// map
toservermap = getclientmap();
sgetstr();
if (text[0] &&
strcmp(text, clientpassword.UTF8String)) {
conoutf(@"you need to set the correct password "
@"to join this server!");
disconnect();
return;
}
if (getint(&p) == 1)
conoutf(@"server is FULL, disconnecting..");
break;
}
|
|
|
|
|
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
104
105
106
107
108
109
110
|
// processes any updates from the server
void
localservertoclient(uchar *buf, int len)
{
if (ENET_NET_TO_HOST_16(*(ushort *)buf) != len)
neterr(@"packet length");
incomingdemodata(buf, len, false);
uchar *end = buf + len;
uchar *p = buf + 2;
char text[MAXTRANS];
int cn = -1, type;
DynamicEntity *d = nil;
bool mapchanged = false;
while (p < end)
switch (type = getint(&p)) {
case SV_INITS2C: // welcome messsage from the server
{
cn = getint(&p);
int prot = getint(&p);
if (prot != PROTOCOL_VERSION) {
conoutf(@"you are using a different game "
@"protocol (you: %d, server: %d)",
PROTOCOL_VERSION, prot);
disconnect(false, false);
return;
}
toservermap = @"";
clientnum = cn; // we are now fully connected
if (!getint(&p))
// we are the first client on this server, set
// map
toservermap = getclientmap();
sgetstr();
if (text[0] &&
strcmp(text, clientpassword.UTF8String)) {
conoutf(@"you need to set the correct password "
@"to join this server!");
disconnect(false, false);
return;
}
if (getint(&p) == 1)
conoutf(@"server is FULL, disconnecting..");
break;
}
|
︙ | | | ︙ | |
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
s.y = getint(&p) / DMF;
s.z = getint(&p) / DMF;
e.x = getint(&p) / DMF;
e.y = getint(&p) / DMF;
e.z = getint(&p) / DMF;
if (gun == GUN_SG)
createrays(&s, &e);
shootv(gun, &s, &e, d);
break;
}
case SV_DAMAGE: {
int target = getint(&p);
int damage = getint(&p);
int ls = getint(&p);
|
|
|
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
s.y = getint(&p) / DMF;
s.z = getint(&p) / DMF;
e.x = getint(&p) / DMF;
e.y = getint(&p) / DMF;
e.z = getint(&p) / DMF;
if (gun == GUN_SG)
createrays(&s, &e);
shootv(gun, &s, &e, d, false);
break;
}
case SV_DAMAGE: {
int target = getint(&p);
int damage = getint(&p);
int ls = getint(&p);
|
︙ | | | ︙ | |
︙ | | | ︙ | |
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
return NULL;
}
}
char *s = strndup(word, p - word - 1);
if (left == '(') {
OFString *t;
@try {
t = [OFString stringWithFormat:@"%d", execute(@(s))];
} @finally {
free(s);
}
s = strdup(t.UTF8String);
}
return s;
}
|
>
|
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
return NULL;
}
}
char *s = strndup(word, p - word - 1);
if (left == '(') {
OFString *t;
@try {
t = [OFString
stringWithFormat:@"%d", execute(@(s), true)];
} @finally {
free(s);
}
s = strdup(t.UTF8String);
}
return s;
}
|
︙ | | | ︙ | |
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
command = [OFString stringWithContentsOfIRI:cfgfile];
} @catch (OFOpenItemFailedException *e) {
return false;
} @catch (OFReadFailedException *e) {
return false;
}
execute(command);
return true;
}
void
exec(OFString *cfgfile)
{
if (!execfile([Cube.sharedInstance.userDataIRI
|
|
|
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
command = [OFString stringWithContentsOfIRI:cfgfile];
} @catch (OFOpenItemFailedException *e) {
return false;
} @catch (OFReadFailedException *e) {
return false;
}
execute(command, true);
return true;
}
void
exec(OFString *cfgfile)
{
if (!execfile([Cube.sharedInstance.userDataIRI
|
︙ | | | ︙ | |
403
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
432
433
434
435
436
437
438
439
440
441
442
443
|
{
alias(name, [OFString stringWithFormat:@"%d", v]);
}
void
ifthen(OFString *cond, OFString *thenp, OFString *elsep)
{
execute((![cond hasPrefix:@"0"] ? thenp : elsep));
}
void
loopa(OFString *times, OFString *body)
{
int t = times.cube_intValue;
loopi(t)
{
intset(@"i", i);
execute(body);
}
}
void
whilea(OFString *cond, OFString *body)
{
while (execute(cond))
execute(body);
}
void
onrelease(bool on, OFString *body)
{
if (!on)
execute(body);
}
void
concat(OFString *s)
{
alias(@"s", s);
}
|
|
|
|
|
|
|
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
432
433
434
435
436
437
438
439
440
441
442
443
444
|
{
alias(name, [OFString stringWithFormat:@"%d", v]);
}
void
ifthen(OFString *cond, OFString *thenp, OFString *elsep)
{
execute((![cond hasPrefix:@"0"] ? thenp : elsep), true);
}
void
loopa(OFString *times, OFString *body)
{
int t = times.cube_intValue;
loopi(t)
{
intset(@"i", i);
execute(body, true);
}
}
void
whilea(OFString *cond, OFString *body)
{
while (execute(cond, true))
execute(body, true);
}
void
onrelease(bool on, OFString *body)
{
if (!on)
execute(body, true);
}
void
concat(OFString *s)
{
alias(@"s", s);
}
|
︙ | | | ︙ | |
︙ | | | ︙ | |
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
{ \
makeundo(); \
loop(x, sel->xs) loop(y, sel->ys) \
{ \
sqr *s = S(sel->x + x, sel->y + y); \
b; \
} \
remip(sel); \
}
int cx, cy, ch;
int curedittex[] = { -1, -1, -1 };
bool dragging = false;
|
|
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
{ \
makeundo(); \
loop(x, sel->xs) loop(y, sel->ys) \
{ \
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;
|
︙ | | | ︙ | |
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
case 3:
if (s->utex == rtex.utex)
s->utex = lasttex;
break;
}
}
block b = { 0, 0, ssize, ssize };
remip(&b);
}
void
edittypexy(int type, const block *sel)
{
loopselxy(s->type = type);
}
|
|
|
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
case 3:
if (s->utex == rtex.utex)
s->utex = lasttex;
break;
}
}
block b = { 0, 0, ssize, ssize };
remip(&b, 0);
}
void
edittypexy(int type, const block *sel)
{
loopselxy(s->type = type);
}
|
︙ | | | ︙ | |
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
}
COMMAND(equalize, ARG_1INT)
void
setvdeltaxy(int delta, const block *sel)
{
loopselxy(s->vdelta = max(s->vdelta + delta, 0));
remipmore(sel);
}
void
setvdelta(int delta)
{
EDITSEL;
setvdeltaxy(delta, &sel);
|
|
|
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
}
COMMAND(equalize, ARG_1INT)
void
setvdeltaxy(int delta, const block *sel)
{
loopselxy(s->vdelta = max(s->vdelta + delta, 0));
remipmore(sel, 0);
}
void
setvdelta(int delta)
{
EDITSEL;
setvdeltaxy(delta, &sel);
|
︙ | | | ︙ | |
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
|
// Ugly hack to make the macro work.
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);
}
void
slope(int xd, int yd)
{
EDITSELMP;
int off = 0;
if (xd < 0)
off -= xd * sel.xs;
if (yd < 0)
off -= yd * sel.ys;
sel.xs++;
sel.ys++;
block *sel_ = &sel;
// Ugly hack to make the macro work.
block *sel = sel_;
loopselxy(s->vdelta = xd * x + yd * y + off);
remipmore(sel);
}
void
perlin(int scale, int seed, int psize)
{
EDITSELMP;
sel.xs++;
sel.ys++;
makeundo();
sel.xs--;
sel.ys--;
perlinarea(&sel, scale, seed, psize);
sel.xs++;
sel.ys++;
remipmore(&sel);
sel.xs--;
sel.ys--;
}
VARF(
fullbright, 0, 0, 1, if (fullbright) {
if (noteditmode())
|
|
|
|
|
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
|
// Ugly hack to make the macro work.
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);
}
void
slope(int xd, int yd)
{
EDITSELMP;
int off = 0;
if (xd < 0)
off -= xd * sel.xs;
if (yd < 0)
off -= yd * sel.ys;
sel.xs++;
sel.ys++;
block *sel_ = &sel;
// Ugly hack to make the macro work.
block *sel = sel_;
loopselxy(s->vdelta = xd * x + yd * y + off);
remipmore(sel, 0);
}
void
perlin(int scale, int seed, int psize)
{
EDITSELMP;
sel.xs++;
sel.ys++;
makeundo();
sel.xs--;
sel.ys--;
perlinarea(&sel, scale, seed, psize);
sel.xs++;
sel.ys++;
remipmore(&sel, 0);
sel.xs--;
sel.ys--;
}
VARF(
fullbright, 0, 0, 1, if (fullbright) {
if (noteditmode())
|
︙ | | | ︙ | |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// protos for ALL external functions in cube...
// command
extern int variable(OFString *name, int min, int cur, int max, int *storage,
void (*fun)(), bool persist);
extern void setvar(OFString *name, int i);
extern int getvar(OFString *name);
extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(OFString *p, bool down = true);
extern void exec(OFString *cfgfile);
extern bool execfile(OFIRI *cfgfile);
extern void resetcomplete();
extern void complete(OFMutableString *s);
extern void alias(OFString *name, OFString *action);
extern OFString *getalias(OFString *name);
extern void writecfg();
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// protos for ALL external functions in cube...
// command
extern int variable(OFString *name, int min, int cur, int max, int *storage,
void (*fun)(), bool persist);
extern void setvar(OFString *name, int i);
extern int getvar(OFString *name);
extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(OFString *p, bool down);
extern void exec(OFString *cfgfile);
extern bool execfile(OFIRI *cfgfile);
extern void resetcomplete();
extern void complete(OFMutableString *s);
extern void alias(OFString *name, OFString *action);
extern OFString *getalias(OFString *name);
extern void writecfg();
|
︙ | | | ︙ | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
extern int renderwater(float hf);
extern void finishstrips();
extern void setarraypointers();
// client
extern void localservertoclient(uchar *buf, int len);
extern void connects(OFString *servername);
extern void disconnect(int onlyclean = 0, int async = 0);
extern void toserver(OFString *text);
extern void addmsg(int rel, int num, int type, ...);
extern bool multiplayer();
extern bool allowedittoggle();
extern void sendpackettoserv(void *packet);
extern void gets2c();
extern void c2sinfo(DynamicEntity *d);
|
|
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
extern int renderwater(float hf);
extern void finishstrips();
extern void setarraypointers();
// client
extern void localservertoclient(uchar *buf, int len);
extern void connects(OFString *servername);
extern void disconnect(bool onlyclean, bool async);
extern void toserver(OFString *text);
extern void addmsg(int rel, int num, int type, ...);
extern bool multiplayer();
extern bool allowedittoggle();
extern void sendpackettoserv(void *packet);
extern void gets2c();
extern void c2sinfo(DynamicEntity *d);
|
︙ | | | ︙ | |
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
DynamicEntity *d, bool team, OFString *mdlname, bool hellpig, float scale);
void showscores(bool on);
extern void renderscores();
// world
extern void setupworld(int factor);
extern void empty_world(int factor, bool force);
extern void remip(const block *b, int level = 0);
extern void remipmore(const block *b, int level = 0);
extern int closestent();
extern int findentity(int type, int index = 0);
extern void trigger(int tag, int type, bool savegame);
extern void resettagareas();
extern void settagareas();
extern Entity *newentity(
int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4);
// worldlight
|
|
|
|
|
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
DynamicEntity *d, bool team, OFString *mdlname, bool hellpig, float scale);
void showscores(bool on);
extern void renderscores();
// world
extern void setupworld(int factor);
extern void empty_world(int factor, bool force);
extern void remip(const block *b, int level);
extern void remipmore(const block *b, int level);
extern int closestent();
extern int findentity(int type, int index);
extern void trigger(int tag, int type, bool savegame);
extern void resettagareas();
extern void settagareas();
extern Entity *newentity(
int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4);
// worldlight
|
︙ | | | ︙ | |
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
163
164
165
166
167
168
169
170
|
float widef, int w, int h);
// worldocull
extern void computeraytable(float vx, float vy);
extern int isoccluded(float vx, float vy, float cx, float cy, float csize);
// main
extern void fatal(OFString *s, OFString *o = @"");
// rendertext
extern void draw_text(OFString *string, int left, int top, int gl_num);
extern void draw_textf(
OFConstantString *format, int left, int top, int gl_num, ...);
extern int text_width(OFString *string);
extern void draw_envbox(int t, int fogdist);
// editing
extern void cursorupdate();
extern void toggleedit();
extern void editdrag(bool isdown);
extern void setvdeltaxy(int delta, const block *sel);
extern void editequalisexy(bool isfloor, const block *sel);
extern void edittypexy(int type, const block *sel);
extern void edittexxy(int type, int t, const block *sel);
extern void editheightxy(bool isfloor, int amount, const block *sel);
extern bool noteditmode();
extern void pruneundos(int maxremain = 0);
// renderextras
extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
extern void box(const block *b, float z1, float z2, float z3, float z4);
extern void dot(int x, int y, float z);
extern void linestyle(float width, int r, int g, int b);
extern void newsphere(const OFVector3D *o, float max, int type);
|
|
|
|
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
163
164
165
166
167
168
169
170
|
float widef, int w, int h);
// worldocull
extern void computeraytable(float vx, float vy);
extern int isoccluded(float vx, float vy, float cx, float cy, float csize);
// main
extern void fatal(OFConstantString *s, ...);
// rendertext
extern void draw_text(OFString *string, int left, int top, int gl_num);
extern void draw_textf(
OFConstantString *format, int left, int top, int gl_num, ...);
extern int text_width(OFString *string);
extern void draw_envbox(int t, int fogdist);
// editing
extern void cursorupdate();
extern void toggleedit();
extern void editdrag(bool isdown);
extern void setvdeltaxy(int delta, const block *sel);
extern void editequalisexy(bool isfloor, const block *sel);
extern void edittypexy(int type, const block *sel);
extern void edittexxy(int type, int t, const block *sel);
extern void editheightxy(bool isfloor, int amount, const block *sel);
extern bool noteditmode();
extern void pruneundos(int maxremain);
// renderextras
extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
extern void box(const block *b, float z1, float z2, float z3, float z4);
extern void dot(int x, int y, float z);
extern void linestyle(float width, int r, int g, int b);
extern void newsphere(const OFVector3D *o, float max, int type);
|
︙ | | | ︙ | |
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
// worldio
extern void save_world(OFString *fname);
extern void load_world(OFString *mname);
extern void writemap(OFString *mname, int msize, uchar *mdata);
extern OFData *readmap(OFString *mname);
extern void loadgamerest();
extern void incomingdemodata(uchar *buf, int len, bool extras = false);
extern void demoplaybackstep();
extern void stop();
extern void stopifrecording();
extern void demodamage(int damage, const OFVector3D *o);
extern void demoblend(int damage);
// physics
extern void moveplayer(DynamicEntity *pl, int moveres, bool local);
extern bool collide(DynamicEntity *d, bool spawn, float drop, float rise);
extern void entinmap(DynamicEntity *d);
extern void setentphysics(int mml, int mmr);
extern void physicsframe();
// sound
extern void playsound(int n, const OFVector3D *loc = NULL);
extern void playsoundc(int n);
extern void initsound();
extern void cleansound();
// rendermd2
extern void rendermodel(OFString *mdl, int frame, int range, int tex, float rad,
OFVector3D position, float yaw, float pitch, bool teammate, float scale,
float speed, int snap = 0, int basetime = 0);
@class MapModelInfo;
extern MapModelInfo *getmminfo(int i);
// server
extern void initserver(bool dedicated, int uprate, OFString *sdesc,
OFString *ip, OFString *master, OFString *passwd, int maxcl);
extern void cleanupserver();
|
|
|
|
|
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
// worldio
extern void save_world(OFString *fname);
extern void load_world(OFString *mname);
extern void writemap(OFString *mname, int msize, uchar *mdata);
extern OFData *readmap(OFString *mname);
extern void loadgamerest();
extern void incomingdemodata(uchar *buf, int len, bool extras);
extern void demoplaybackstep();
extern void stop();
extern void stopifrecording();
extern void demodamage(int damage, const OFVector3D *o);
extern void demoblend(int damage);
// physics
extern void moveplayer(DynamicEntity *pl, int moveres, bool local);
extern bool collide(DynamicEntity *d, bool spawn, float drop, float rise);
extern void entinmap(DynamicEntity *d);
extern void setentphysics(int mml, int mmr);
extern void physicsframe();
// sound
extern void playsound(int n, const OFVector3D *loc);
extern void playsoundc(int n);
extern void initsound();
extern void cleansound();
// rendermd2
extern void rendermodel(OFString *mdl, int frame, int range, int tex, float rad,
OFVector3D position, float yaw, float pitch, bool teammate, float scale,
float speed, int snap, int basetime);
@class MapModelInfo;
extern MapModelInfo *getmminfo(int i);
// server
extern void initserver(bool dedicated, int uprate, OFString *sdesc,
OFString *ip, OFString *master, OFString *passwd, int maxcl);
extern void cleanupserver();
|
︙ | | | ︙ | |
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
extern void serverms(int mode, int numplayers, int minremain,
OFString *smapname, int seconds, bool isfull);
extern void servermsinit(OFString *master, OFString *sdesc, bool listen);
extern void sendmaps(int n, OFString *mapname, int mapsize, uchar *mapdata);
extern ENetPacket *recvmap(int n);
// weapon
extern void selectgun(int a = -1, int b = -1, int c = -1);
extern void shoot(DynamicEntity *d, const OFVector3D *to);
extern void shootv(int gun, const OFVector3D *from, const OFVector3D *to,
DynamicEntity *d = 0, bool local = false);
extern void createrays(const OFVector3D *from, const OFVector3D *to);
extern void moveprojectiles(float time);
extern void projreset();
extern OFString *playerincrosshair();
extern int reloadtime(int gun);
// monster
|
|
|
|
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
extern void serverms(int mode, int numplayers, int minremain,
OFString *smapname, int seconds, bool isfull);
extern void servermsinit(OFString *master, OFString *sdesc, bool listen);
extern void sendmaps(int n, OFString *mapname, int mapsize, uchar *mapdata);
extern ENetPacket *recvmap(int n);
// weapon
extern void selectgun(int a, int b, int c);
extern void shoot(DynamicEntity *d, const OFVector3D *to);
extern void shootv(int gun, const OFVector3D *from, const OFVector3D *to,
DynamicEntity *d, bool local);
extern void createrays(const OFVector3D *from, const OFVector3D *to);
extern void moveprojectiles(float time);
extern void projreset();
extern OFString *playerincrosshair();
extern int reloadtime(int gun);
// monster
|
︙ | | | ︙ | |
︙ | | | ︙ | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
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()
{
settag(0, 0);
} // reset for editing or map saving
|
|
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
minx = x;
if (y < miny)
miny = y;
}
}
block b = { minx, miny, maxx - minx + 1, maxy - miny + 1 };
if (maxx)
remip(&b, 0); // remip minimal area of changed geometry
}
void
resettagareas()
{
settag(0, 0);
} // reset for editing or map saving
|
︙ | | | ︙ | |
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
{
if (!tag)
return;
settag(tag, type);
if (!savegame && type != 3)
playsound(S_RUMBLE);
OFString *aliasname =
[OFString stringWithFormat:@"level_trigger_%d", tag];
if (identexists(aliasname))
execute(aliasname);
if (type == 2)
endsp(false);
}
COMMAND(trigger, ARG_2INT)
// main geometric mipmapping routine, recursively rebuild mipmaps within block
|
|
|
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
{
if (!tag)
return;
settag(tag, type);
if (!savegame && type != 3)
playsound(S_RUMBLE, NULL);
OFString *aliasname =
[OFString stringWithFormat:@"level_trigger_%d", tag];
if (identexists(aliasname))
execute(aliasname, true);
if (type == 2)
endsp(false);
}
COMMAND(trigger, ARG_2INT)
// main geometric mipmapping routine, recursively rebuild mipmaps within block
|
︙ | | | ︙ | |
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
// world by 1
void
empty_world(int factor, bool force)
{
if (!force && noteditmode())
return;
cleardlights();
pruneundos();
sqr *oldworld = world;
bool copy = false;
if (oldworld && factor < 0) {
factor = sfactor + 1;
copy = true;
}
if (factor < SMALLEST_FACTOR)
|
|
|
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
// world by 1
void
empty_world(int factor, bool force)
{
if (!force && noteditmode())
return;
cleardlights();
pruneundos(0);
sqr *oldworld = world;
bool copy = false;
if (oldworld && factor < 0) {
factor = sfactor + 1;
copy = true;
}
if (factor < SMALLEST_FACTOR)
|
︙ | | | ︙ | |
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
|
}
calclight();
startmap(@"base/unnamed");
if (oldworld) {
OFFreeMemory(oldworld);
toggleedit();
execute(@"fullbright 1");
}
}
void
mapenlarge()
{
empty_world(-1, false);
|
|
|
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
|
}
calclight();
startmap(@"base/unnamed");
if (oldworld) {
OFFreeMemory(oldworld);
toggleedit();
execute(@"fullbright 1", true);
}
}
void
mapenlarge()
{
empty_world(-1, false);
|
︙ | | | ︙ | |