Remove all default arguments from protos.h

FossilOrigin-Name: ef1d7e47f7204700ed6e3b1191a1bdcb6e1d0257586183bc6571b8ff92464042
This commit is contained in:
Jonathan Schleifer 2025-03-20 20:38:43 +00:00
parent d9d56601bb
commit 2085a651bd
18 changed files with 81 additions and 69 deletions

View file

@ -124,14 +124,15 @@ padArguments(OFArray<OFString *> *arguments, size_t count)
if (isDown) { if (isDown) {
arguments = padArguments(arguments, 2); arguments = padArguments(arguments, 2);
return ((int(__cdecl *)(int))_function)( return ((int(__cdecl *)(int))_function)(
execute(arguments[1])); execute(arguments[1], isDown));
} }
break; break;
case ARG_2EXP: case ARG_2EXP:
if (isDown) { if (isDown) {
arguments = padArguments(arguments, 3); arguments = padArguments(arguments, 3);
return ((int(__cdecl *)(int, int))_function)( return ((int(__cdecl *)(int, int))_function)(
execute(arguments[1]), execute(arguments[2])); execute(arguments[1], isDown),
execute(arguments[2], isDown));
} }
break; break;
case ARG_1EST: case ARG_1EST:

View file

@ -296,7 +296,7 @@ VARP(minmillis, 0, 5, 1000);
- (void)applicationWillTerminate:(OFNotification *)notification - (void)applicationWillTerminate:(OFNotification *)notification
{ {
stop(); stop();
disconnect(true); disconnect(true, false);
writecfg(); writecfg();
cleangl(); cleangl();
cleansound(); cleansound();
@ -357,11 +357,17 @@ VARP(minmillis, 0, 5, 1000);
} }
@end @end
// failure exit
void void
fatal(OFString *s, OFString *o) // failure exit fatal(OFConstantString *s, ...)
{ {
OFString *msg = va_list args;
[OFString stringWithFormat:@"%@%@ (%s)\n", s, o, SDL_GetError()]; va_start(args, s);
OFMutableString *msg = [[OFMutableString alloc] initWithFormat:s
arguments:args];
va_end(args);
[msg appendFormat:@" (%s)\n", SDL_GetError()];
[Cube.sharedInstance showMessage:msg]; [Cube.sharedInstance showMessage:msg];
[OFApplication terminateWithStatus:1]; [OFApplication terminateWithStatus:1];

View file

@ -251,7 +251,7 @@ updateworld(int millis) // main game update loop
curtime = millis - lastmillis; curtime = millis - lastmillis;
if (sleepwait && lastmillis > sleepwait) { if (sleepwait && lastmillis > sleepwait) {
sleepwait = 0; sleepwait = 0;
execute(sleepcmd); execute(sleepcmd, true);
} }
physicsframe(); physicsframe();
checkquad(curtime); checkquad(curtime);
@ -445,11 +445,11 @@ selfdamage(int damage, int actor, DynamicEntity *act)
player1.state = CS_DEAD; player1.state = CS_DEAD;
player1.pitch = 0; player1.pitch = 0;
player1.roll = 60; player1.roll = 60;
playsound(S_DIE1 + rnd(2)); playsound(S_DIE1 + rnd(2), NULL);
spawnstate(player1); spawnstate(player1);
player1.lastaction = lastmillis; player1.lastaction = lastmillis;
} else } else
playsound(S_PAIN6); playsound(S_PAIN6, NULL);
} }
void void

View file

@ -94,7 +94,7 @@ writeclientinfo(OFStream *stream)
void void
connects(OFString *servername) connects(OFString *servername)
{ {
disconnect(1); // reset state disconnect(true, false); // reset state
addserver(servername); addserver(servername);
conoutf(@"attempting to connect to %@", servername); conoutf(@"attempting to connect to %@", servername);
@ -113,12 +113,12 @@ connects(OFString *servername)
connattempts = 0; connattempts = 0;
} else { } else {
conoutf(@"could not connect to server"); conoutf(@"could not connect to server");
disconnect(); disconnect(false, false);
} }
} }
void void
disconnect(int onlyclean, int async) disconnect(bool onlyclean, bool async)
{ {
if (clienthost) { if (clienthost) {
if (!connecting && !disconnecting) { if (!connecting && !disconnecting) {
@ -162,7 +162,7 @@ trydisconnect()
} }
if (connecting) { if (connecting) {
conoutf(@"aborting connection attempt"); conoutf(@"aborting connection attempt");
disconnect(); disconnect(false, false);
return; return;
} }
conoutf(@"attempting to disconnect..."); conoutf(@"attempting to disconnect...");
@ -233,7 +233,7 @@ void
server_err() server_err()
{ {
conoutf(@"server network error, disconnecting..."); conoutf(@"server network error, disconnecting...");
disconnect(); disconnect(false, false);
} }
int lastupdate = 0, lastping = 0; int lastupdate = 0, lastping = 0;
@ -382,7 +382,7 @@ gets2c() // get updates from the server
++connattempts; ++connattempts;
if (connattempts > 3) { if (connattempts > 3) {
conoutf(@"could not connect to server"); conoutf(@"could not connect to server");
disconnect(); disconnect(false, false);
return; return;
} }
} }
@ -406,7 +406,7 @@ gets2c() // get updates from the server
case ENET_EVENT_TYPE_DISCONNECT: case ENET_EVENT_TYPE_DISCONNECT:
if (disconnecting) if (disconnecting)
disconnect(); disconnect(false, false);
else else
server_err(); server_err();
return; return;

View file

@ -14,7 +14,7 @@ void
neterr(OFString *s) neterr(OFString *s)
{ {
conoutf(@"illegal network message (%@)", s); conoutf(@"illegal network message (%@)", s);
disconnect(); disconnect(false, false);
} }
void void
@ -67,7 +67,7 @@ localservertoclient(uchar *buf, int len)
{ {
if (ENET_NET_TO_HOST_16(*(ushort *)buf) != len) if (ENET_NET_TO_HOST_16(*(ushort *)buf) != len)
neterr(@"packet length"); neterr(@"packet length");
incomingdemodata(buf, len); incomingdemodata(buf, len, false);
uchar *end = buf + len; uchar *end = buf + len;
uchar *p = buf + 2; uchar *p = buf + 2;
@ -86,7 +86,7 @@ localservertoclient(uchar *buf, int len)
conoutf(@"you are using a different game " conoutf(@"you are using a different game "
@"protocol (you: %d, server: %d)", @"protocol (you: %d, server: %d)",
PROTOCOL_VERSION, prot); PROTOCOL_VERSION, prot);
disconnect(); disconnect(false, false);
return; return;
} }
toservermap = @""; toservermap = @"";
@ -100,7 +100,7 @@ localservertoclient(uchar *buf, int len)
strcmp(text, clientpassword.UTF8String)) { strcmp(text, clientpassword.UTF8String)) {
conoutf(@"you need to set the correct password " conoutf(@"you need to set the correct password "
@"to join this server!"); @"to join this server!");
disconnect(); disconnect(false, false);
return; return;
} }
if (getint(&p) == 1) if (getint(&p) == 1)
@ -221,7 +221,7 @@ localservertoclient(uchar *buf, int len)
e.z = getint(&p) / DMF; e.z = getint(&p) / DMF;
if (gun == GUN_SG) if (gun == GUN_SG)
createrays(&s, &e); createrays(&s, &e);
shootv(gun, &s, &e, d); shootv(gun, &s, &e, d, false);
break; break;
} }

View file

@ -123,7 +123,8 @@ parseexp(char *&p, int right)
if (left == '(') { if (left == '(') {
OFString *t; OFString *t;
@try { @try {
t = [OFString stringWithFormat:@"%d", execute(@(s))]; t = [OFString
stringWithFormat:@"%d", execute(@(s), true)];
} @finally { } @finally {
free(s); free(s);
} }
@ -329,7 +330,7 @@ execfile(OFIRI *cfgfile)
return false; return false;
} }
execute(command); execute(command, true);
return true; return true;
} }
@ -407,7 +408,7 @@ intset(OFString *name, int v)
void void
ifthen(OFString *cond, OFString *thenp, OFString *elsep) ifthen(OFString *cond, OFString *thenp, OFString *elsep)
{ {
execute((![cond hasPrefix:@"0"] ? thenp : elsep)); execute((![cond hasPrefix:@"0"] ? thenp : elsep), true);
} }
void void
@ -418,22 +419,22 @@ loopa(OFString *times, OFString *body)
loopi(t) loopi(t)
{ {
intset(@"i", i); intset(@"i", i);
execute(body); execute(body, true);
} }
} }
void void
whilea(OFString *cond, OFString *body) whilea(OFString *cond, OFString *body)
{ {
while (execute(cond)) while (execute(cond, true))
execute(body); execute(body, true);
} }
void void
onrelease(bool on, OFString *body) onrelease(bool on, OFString *body)
{ {
if (!on) if (!on)
execute(body); execute(body, true);
} }
void void

View file

@ -177,7 +177,7 @@ history(int n)
if (!rec && n >= 0 && n < vhistory.count) { if (!rec && n >= 0 && n < vhistory.count) {
rec = true; rec = true;
execute(vhistory[vhistory.count - n - 1]); execute(vhistory[vhistory.count - n - 1], true);
rec = false; rec = false;
} }
} }

View file

@ -37,7 +37,7 @@ bool selset = false;
sqr *s = S(sel->x + x, sel->y + y); \ sqr *s = S(sel->x + x, sel->y + y); \
b; \ b; \
} \ } \
remip(sel); \ remip(sel, 0); \
} }
int cx, cy, ch; int cx, cy, ch;
@ -440,7 +440,7 @@ replace()
} }
} }
block b = { 0, 0, ssize, ssize }; block b = { 0, 0, ssize, ssize };
remip(&b); remip(&b, 0);
} }
void void
@ -518,7 +518,7 @@ void
setvdeltaxy(int delta, const block *sel) setvdeltaxy(int delta, const block *sel)
{ {
loopselxy(s->vdelta = max(s->vdelta + delta, 0)); loopselxy(s->vdelta = max(s->vdelta + delta, 0));
remipmore(sel); remipmore(sel, 0);
} }
void void
@ -563,7 +563,7 @@ arch(int sidedelta, int _a)
(y == 0 || y == sel->ys - 1 ? sidedelta : 0)) (y == 0 || y == sel->ys - 1 ? sidedelta : 0))
: (archverts[sel->ys - 1][y] + : (archverts[sel->ys - 1][y] +
(x == 0 || x == sel->xs - 1 ? sidedelta : 0))); (x == 0 || x == sel->xs - 1 ? sidedelta : 0)));
remipmore(sel); remipmore(sel, 0);
} }
void void
@ -581,7 +581,7 @@ slope(int xd, int yd)
// Ugly hack to make the macro work. // Ugly hack to make the macro work.
block *sel = sel_; block *sel = sel_;
loopselxy(s->vdelta = xd * x + yd * y + off); loopselxy(s->vdelta = xd * x + yd * y + off);
remipmore(sel); remipmore(sel, 0);
} }
void void
@ -596,7 +596,7 @@ perlin(int scale, int seed, int psize)
perlinarea(&sel, scale, seed, psize); perlinarea(&sel, scale, seed, psize);
sel.xs++; sel.xs++;
sel.ys++; sel.ys++;
remipmore(&sel); remipmore(&sel, 0);
sel.xs--; sel.xs--;
sel.ys--; sel.ys--;
} }

View file

@ -54,7 +54,7 @@ renderentities()
(float)S(e.x, e.y)->floor + mmi.zoff + e.attr3, (float)S(e.x, e.y)->floor + mmi.zoff + e.attr3,
e.y), e.y),
(float)((e.attr1 + 7) - (e.attr1 + 7) % 15), 0, (float)((e.attr1 + 7) - (e.attr1 + 7) % 15), 0,
false, 1.0f, 10.0f, mmi.snap); false, 1.0f, 10.0f, mmi.snap, 0);
} else { } else {
if (OUTBORD(e.x, e.y)) if (OUTBORD(e.x, e.y))
continue; continue;

View file

@ -7,7 +7,7 @@ extern void setvar(OFString *name, int i);
extern int getvar(OFString *name); extern int getvar(OFString *name);
extern bool identexists(OFString *name); extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg); extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(OFString *p, bool down = true); extern int execute(OFString *p, bool down);
extern void exec(OFString *cfgfile); extern void exec(OFString *cfgfile);
extern bool execfile(OFIRI *cfgfile); extern bool execfile(OFIRI *cfgfile);
extern void resetcomplete(); extern void resetcomplete();
@ -71,7 +71,7 @@ extern void setarraypointers();
// client // client
extern void localservertoclient(uchar *buf, int len); extern void localservertoclient(uchar *buf, int len);
extern void connects(OFString *servername); extern void connects(OFString *servername);
extern void disconnect(int onlyclean = 0, int async = 0); extern void disconnect(bool onlyclean, bool async);
extern void toserver(OFString *text); extern void toserver(OFString *text);
extern void addmsg(int rel, int num, int type, ...); extern void addmsg(int rel, int num, int type, ...);
extern bool multiplayer(); extern bool multiplayer();
@ -114,10 +114,10 @@ extern void renderscores();
// world // world
extern void setupworld(int factor); extern void setupworld(int factor);
extern void empty_world(int factor, bool force); extern void empty_world(int factor, bool force);
extern void remip(const block *b, int level = 0); extern void remip(const block *b, int level);
extern void remipmore(const block *b, int level = 0); extern void remipmore(const block *b, int level);
extern int closestent(); extern int closestent();
extern int findentity(int type, int index = 0); extern int findentity(int type, int index);
extern void trigger(int tag, int type, bool savegame); extern void trigger(int tag, int type, bool savegame);
extern void resettagareas(); extern void resettagareas();
extern void settagareas(); extern void settagareas();
@ -141,7 +141,7 @@ extern void computeraytable(float vx, float vy);
extern int isoccluded(float vx, float vy, float cx, float cy, float csize); extern int isoccluded(float vx, float vy, float cx, float cy, float csize);
// main // main
extern void fatal(OFString *s, OFString *o = @""); extern void fatal(OFConstantString *s, ...);
// rendertext // rendertext
extern void draw_text(OFString *string, int left, int top, int gl_num); extern void draw_text(OFString *string, int left, int top, int gl_num);
@ -160,7 +160,7 @@ extern void edittypexy(int type, const block *sel);
extern void edittexxy(int type, int t, const block *sel); extern void edittexxy(int type, int t, const block *sel);
extern void editheightxy(bool isfloor, int amount, const block *sel); extern void editheightxy(bool isfloor, int amount, const block *sel);
extern bool noteditmode(); extern bool noteditmode();
extern void pruneundos(int maxremain = 0); extern void pruneundos(int maxremain);
// renderextras // renderextras
extern void line(int x1, int y1, float z1, int x2, int y2, float z2); extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
@ -188,7 +188,7 @@ extern void load_world(OFString *mname);
extern void writemap(OFString *mname, int msize, uchar *mdata); extern void writemap(OFString *mname, int msize, uchar *mdata);
extern OFData *readmap(OFString *mname); extern OFData *readmap(OFString *mname);
extern void loadgamerest(); extern void loadgamerest();
extern void incomingdemodata(uchar *buf, int len, bool extras = false); extern void incomingdemodata(uchar *buf, int len, bool extras);
extern void demoplaybackstep(); extern void demoplaybackstep();
extern void stop(); extern void stop();
extern void stopifrecording(); extern void stopifrecording();
@ -203,7 +203,7 @@ extern void setentphysics(int mml, int mmr);
extern void physicsframe(); extern void physicsframe();
// sound // sound
extern void playsound(int n, const OFVector3D *loc = NULL); extern void playsound(int n, const OFVector3D *loc);
extern void playsoundc(int n); extern void playsoundc(int n);
extern void initsound(); extern void initsound();
extern void cleansound(); extern void cleansound();
@ -211,7 +211,7 @@ extern void cleansound();
// rendermd2 // rendermd2
extern void rendermodel(OFString *mdl, int frame, int range, int tex, float rad, extern void rendermodel(OFString *mdl, int frame, int range, int tex, float rad,
OFVector3D position, float yaw, float pitch, bool teammate, float scale, OFVector3D position, float yaw, float pitch, bool teammate, float scale,
float speed, int snap = 0, int basetime = 0); float speed, int snap, int basetime);
@class MapModelInfo; @class MapModelInfo;
extern MapModelInfo *getmminfo(int i); extern MapModelInfo *getmminfo(int i);
@ -237,10 +237,10 @@ extern void sendmaps(int n, OFString *mapname, int mapsize, uchar *mapdata);
extern ENetPacket *recvmap(int n); extern ENetPacket *recvmap(int n);
// weapon // weapon
extern void selectgun(int a = -1, int b = -1, int c = -1); extern void selectgun(int a, int b, int c);
extern void shoot(DynamicEntity *d, const OFVector3D *to); extern void shoot(DynamicEntity *d, const OFVector3D *to);
extern void shootv(int gun, const OFVector3D *from, const OFVector3D *to, extern void shootv(int gun, const OFVector3D *from, const OFVector3D *to,
DynamicEntity *d = 0, bool local = false); DynamicEntity *d, bool local);
extern void createrays(const OFVector3D *from, const OFVector3D *to); extern void createrays(const OFVector3D *from, const OFVector3D *to);
extern void moveprojectiles(float time); extern void moveprojectiles(float time);
extern void projreset(); extern void projreset();

View file

@ -23,7 +23,7 @@ delayedload(MD2 *m)
OFIRI *IRI1 = [baseIRI IRIByAppendingPathComponent:@"tris.md2"]; OFIRI *IRI1 = [baseIRI IRIByAppendingPathComponent:@"tris.md2"];
if (![m loadWithIRI:IRI1]) if (![m loadWithIRI:IRI1])
fatal(@"loadmodel: ", IRI1.string); fatal(@"loadmodel: %@", IRI1.string);
OFIRI *IRI2 = [baseIRI IRIByAppendingPathComponent:@"skin.jpg"]; OFIRI *IRI2 = [baseIRI IRIByAppendingPathComponent:@"skin.jpg"];
int xs, ys; int xs, ys;

View file

@ -351,7 +351,7 @@ stopreset()
conoutf(@"demo stopped (%d msec elapsed)", lastmillis - starttime); conoutf(@"demo stopped (%d msec elapsed)", lastmillis - starttime);
stop(); stop();
[players removeAllObjects]; [players removeAllObjects];
disconnect(0, 0); disconnect(false, false);
} }
VAR(demoplaybackspeed, 10, 100, 1000); VAR(demoplaybackspeed, 10, 100, 1000);

View file

@ -273,7 +273,7 @@ updatefrommaster()
conoutf(@"master server not replying"); conoutf(@"master server not replying");
else { else {
[servers removeAllObjects]; [servers removeAllObjects];
execute(@((char *)reply)); execute(@((char *)reply), true);
} }
servermenu(); servermenu();
} }

View file

@ -140,10 +140,17 @@ localservertoclient(uchar *buf, int len)
} }
void void
fatal(OFString *s, OFString *o) fatal(OFConstantString *s, ...)
{ {
cleanupserver(); cleanupserver();
[OFStdOut writeFormat:@"servererror: %@\n", s];
va_list args;
va_start(args, s);
OFString *msg = [[OFString alloc] initWithFormat:s arguments:args];
va_end(args);
[OFStdOut writeFormat:@"servererror: %@\n", msg];
exit(1); exit(1);
} }

View file

@ -159,7 +159,7 @@ void
playsoundc(int n) playsoundc(int n)
{ {
addmsg(0, 2, SV_SOUND, n); addmsg(0, 2, SV_SOUND, n);
playsound(n); playsound(n, NULL);
} }
int soundsatonce = 0, lastsoundmillis = 0; int soundsatonce = 0, lastsoundmillis = 0;

View file

@ -42,7 +42,7 @@ settag(int tag, int type)
} }
block b = { minx, miny, maxx - minx + 1, maxy - miny + 1 }; block b = { minx, miny, maxx - minx + 1, maxy - miny + 1 };
if (maxx) if (maxx)
remip(&b); // remip minimal area of changed geometry remip(&b, 0); // remip minimal area of changed geometry
} }
void void
@ -70,13 +70,13 @@ trigger(int tag, int type, bool savegame)
settag(tag, type); settag(tag, type);
if (!savegame && type != 3) if (!savegame && type != 3)
playsound(S_RUMBLE); playsound(S_RUMBLE, NULL);
OFString *aliasname = OFString *aliasname =
[OFString stringWithFormat:@"level_trigger_%d", tag]; [OFString stringWithFormat:@"level_trigger_%d", tag];
if (identexists(aliasname)) if (identexists(aliasname))
execute(aliasname); execute(aliasname, true);
if (type == 2) if (type == 2)
endsp(false); endsp(false);
@ -457,7 +457,7 @@ empty_world(int factor, bool force)
if (!force && noteditmode()) if (!force && noteditmode())
return; return;
cleardlights(); cleardlights();
pruneundos(); pruneundos(0);
sqr *oldworld = world; sqr *oldworld = world;
bool copy = false; bool copy = false;
if (oldworld && factor < 0) { if (oldworld && factor < 0) {
@ -516,7 +516,7 @@ empty_world(int factor, bool force)
if (oldworld) { if (oldworld) {
OFFreeMemory(oldworld); OFFreeMemory(oldworld);
toggleedit(); toggleedit();
execute(@"fullbright 1"); execute(@"fullbright 1", true);
} }
} }

View file

@ -262,7 +262,7 @@ load_world(OFString *mname) // still supports all map formats that have existed
{ {
stopifrecording(); stopifrecording();
cleardlights(); cleardlights();
pruneundos(); pruneundos(0);
setnames(mname); setnames(mname);
gzFile f = gzFile f =
gzopen([cgzname cStringWithEncoding:OFLocale.encoding], "rb9"); gzopen([cgzname cStringWithEncoding:OFLocale.encoding], "rb9");
@ -350,13 +350,10 @@ load_world(OFString *mname) // still supports all map formats that have existed
break; break;
} }
default: { default: {
if (type < 0 || type >= MAXTYPE) { if (type < 0 || type >= MAXTYPE)
OFString *t = [OFString fatal(@"while reading map: type out of range: "
stringWithFormat:@"%d @ %d", type, k]; @"%d @ %d",
fatal(@"while reading map: type out of " type, k);
@"range: ",
t);
}
s->type = type; s->type = type;
s->floor = gzgetc(f); s->floor = gzgetc(f);
s->ceil = gzgetc(f); s->ceil = gzgetc(f);

View file

@ -165,7 +165,7 @@ postlightarea(block &a) // median filter, smooths out random noise in light and
median(b); median(b);
} }
remip(&a); remip(&a, 0);
} }
void void
@ -268,5 +268,5 @@ blockpaste(const block *b)
for (int x = b->x; x < b->xs + b->x; x++) for (int x = b->x; x < b->xs + b->x; x++)
for (int y = b->y; y < b->ys + b->y; y++) for (int y = b->y; y < b->ys + b->y; y++)
*S(x, y) = *q++; *S(x, y) = *q++;
remipmore(b); remipmore(b, 0);
} }