Index: src/client.mm ================================================================== --- src/client.mm +++ src/client.mm @@ -11,29 +11,32 @@ int getclientnum() { return clientnum; -}; +} bool multiplayer() { // check not correct on listen server? if (clienthost) - conoutf("operation not available in multiplayer"); + conoutf(@"operation not available in multiplayer"); + return clienthost != NULL; -}; +} bool allowedittoggle() { bool allow = !clienthost || gamemode == 1; + if (!allow) - conoutf("editing in multiplayer requires coopedit mode (1)"); + conoutf(@"editing in multiplayer requires coopedit mode (1)"); + return allow; -}; +} VARF(rate, 0, 0, 25000, if (clienthost && (!rate || rate > 1000)) enet_host_bandwidth_limit(clienthost, rate, rate)); @@ -49,44 +52,45 @@ if (!clienthost || connecting) return; assert(ENET_PEER_PACKET_THROTTLE_SCALE == 32); enet_peer_throttle_configure(clienthost->peers, throttle_interval * 1000, throttle_accel, throttle_decel); -}; +} void newname(char *name) { c2sinit = false; strn0cpy(player1->name, name, 16); -}; +} + void newteam(char *name) { c2sinit = false; strn0cpy(player1->team, name, 5); -}; +} COMMANDN(team, newteam, ARG_1STR); COMMANDN(name, newname, ARG_1STR); void writeclientinfo(FILE *f) { fprintf(f, "name \"%s\"\nteam \"%s\"\n", player1->name, player1->team); -}; +} void connects(char *servername) { disconnect(1); // reset state addserver(servername); - conoutf("attempting to connect to %s", servername); + conoutf(@"attempting to connect to %s", servername); ENetAddress address = {ENET_HOST_ANY, CUBE_SERVER_PORT}; if (enet_address_set_host(&address, servername) < 0) { - conoutf("could not resolve server %s", servername); + conoutf(@"could not resolve server %s", servername); return; }; clienthost = enet_host_create(NULL, 1, rate, rate); @@ -94,14 +98,14 @@ enet_host_connect(clienthost, &address, 1); enet_host_flush(clienthost); connecting = lastmillis; connattempts = 0; } else { - conoutf("could not connect to server"); + conoutf(@"could not connect to server"); disconnect(); - }; -}; + } +} void disconnect(int onlyclean, int async) { if (clienthost) { @@ -117,11 +121,11 @@ }; enet_host_destroy(clienthost); }; if (clienthost && !connecting) - conoutf("disconnected"); + conoutf(@"disconnected"); clienthost = NULL; connecting = 0; connattempts = 0; disconnecting = 0; clientnum = -1; @@ -132,41 +136,42 @@ localdisconnect(); if (!onlyclean) { stop(); localconnect(); - }; -}; + } +} void trydisconnect() { if (!clienthost) { - conoutf("not connected"); + conoutf(@"not connected"); return; - }; + } if (connecting) { - conoutf("aborting connection attempt"); + conoutf(@"aborting connection attempt"); disconnect(); return; - }; - conoutf("attempting to disconnect..."); + } + conoutf(@"attempting to disconnect..."); disconnect(0, !disconnecting); -}; +} string ctext; void toserver(char *text) { - conoutf("%s:\f %s", player1->name, text); + conoutf(@"%s:\f %s", player1->name, text); strn0cpy(ctext, text, 80); -}; +} + void echo(char *text) { - conoutf("%s", text); -}; + conoutf(@"%s", text); +} COMMAND(echo, ARG_VARI); COMMANDN(say, toserver, ARG_VARI); COMMANDN(connect, connects, ARG_1STR); COMMANDN(disconnect, trydisconnect, ARG_NONE); @@ -184,11 +189,11 @@ sprintf_sd(s)("inconsistant msg size for %d (%d != %d)", type, num, msgsizelookup(type)); fatal(s); }; if (messages.length() == 100) { - conoutf("command flood protection (type %d)", type); + conoutf(@"command flood protection (type %d)", type); return; }; ivector &msg = messages.add(); msg.add(num); msg.add(rel); @@ -195,18 +200,18 @@ msg.add(type); va_list marker; va_start(marker, type); loopi(num - 1) msg.add(va_arg(marker, int)); va_end(marker); -}; +} void server_err() { - conoutf("server network error, disconnecting..."); + conoutf(@"server network error, disconnecting..."); disconnect(); -}; +} int lastupdate = 0, lastping = 0; string toservermap; bool senditemstoserver = false; // after a map change, since server doesn't have map data @@ -343,31 +348,31 @@ { ENetEvent event; if (!clienthost) return; if (connecting && lastmillis / 3000 > connecting / 3000) { - conoutf("attempting to connect..."); + conoutf(@"attempting to connect..."); connecting = lastmillis; ++connattempts; if (connattempts > 3) { - conoutf("could not connect to server"); + 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: - conoutf("connected to server"); + conoutf(@"connected to server"); connecting = 0; throttle(); break; case ENET_EVENT_TYPE_RECEIVE: if (disconnecting) - conoutf("attempting to disconnect..."); + conoutf(@"attempting to disconnect..."); else localservertoclient(event.packet->data, event.packet->dataLength); enet_packet_destroy(event.packet); break; Index: src/clientextras.mm ================================================================== --- src/clientextras.mm +++ src/clientextras.mm @@ -177,11 +177,11 @@ uchar *p = start + 2; putint(p, SV_SENDMAP); sendstring(mapname, p); putint(p, mapsize); if (65535 - (p - start) < mapsize) { - conoutf("map %s is too large to send", mapname); + conoutf(@"map %s is too large to send", mapname); free(mapdata); enet_packet_destroy(packet); return; }; memcpy(p, mapdata, mapsize); @@ -188,11 +188,11 @@ p += mapsize; free(mapdata); *(ushort *)start = ENET_HOST_TO_NET_16(p - start); enet_packet_resize(packet, p - start); sendpackettoserv(packet); - conoutf("sending map %s to server...", mapname); + conoutf(@"sending map %s to server...", mapname); sprintf_sd(msg)( "[map %s uploaded to server, \"getmap\" to receive it]", mapname); toserver(msg); } @@ -205,10 +205,10 @@ uchar *p = start + 2; putint(p, SV_RECVMAP); *(ushort *)start = ENET_HOST_TO_NET_16(p - start); enet_packet_resize(packet, p - start); sendpackettoserv(packet); - conoutf("requesting map from server..."); + conoutf(@"requesting map from server..."); } COMMAND(sendmap, ARG_1STR); COMMAND(getmap, ARG_NONE); Index: src/clientgame.mm ================================================================== --- src/clientgame.mm +++ src/clientgame.mm @@ -156,11 +156,11 @@ arenarespawn() { if (arenarespawnwait) { if (arenarespawnwait < lastmillis) { arenarespawnwait = 0; - conoutf("new round starting... fight!"); + conoutf(@"new round starting... fight!"); respawnself(); }; } else if (arenadetectwait == 0 || arenadetectwait < lastmillis) { arenadetectwait = 0; int alive = 0, dead = 0; @@ -169,16 +169,16 @@ loopv(players) if (players[i]) arenacount(players[i], alive, dead, lastteam, oneteam); arenacount(player1, alive, dead, lastteam, oneteam); if (dead > 0 && (alive <= 1 || (m_teammode && oneteam))) { conoutf( - "arena round is over! next round in 5 seconds..."); + @"arena round is over! next round in 5 seconds..."); if (alive) conoutf( - "team %s is last man standing", lastteam); + @"team %s is last man standing", lastteam); else - conoutf("everyone died!"); + conoutf(@"everyone died!"); arenarespawnwait = lastmillis + 5000; arenadetectwait = lastmillis + 10000; player1->roll = 0; }; }; @@ -216,11 +216,11 @@ respawn() { if (player1->state == CS_DEAD) { player1->attacking = false; if (m_arena) { - conoutf("waiting for new round to start..."); + conoutf(@"waiting for new round to start..."); return; }; if (m_sp) { nextmode = gamemode; changemap(clientmap); @@ -297,12 +297,12 @@ if (collide(d, true, 0, 0)) return; d->o.x -= dx; d->o.y -= dy; }; - conoutf( - "can't find entity spawn spot! (%d, %d)", (int)d->o.x, (int)d->o.y); + conoutf(@"can't find entity spawn spot! (%d, %d)", (int)d->o.x, + (int)d->o.y); // leave ent at original pos, possibly stuck }; int spawncycle = -1; int fixspawn = 2; @@ -420,28 +420,28 @@ : (rnd(2) ? droll : -droll)); // give player a kick depending // on amount of damage if ((player1->health -= damage) <= 0) { if (actor == -2) { - conoutf("you got killed by %s!", act->name); + conoutf(@"you got killed by %s!", act->name); } else if (actor == -1) { actor = getclientnum(); - conoutf("you suicided!"); + conoutf(@"you suicided!"); addmsg(1, 2, SV_FRAGS, --player1->frags); } else { dynent *a = getclient(actor); if (a) { if (isteam(a->team, player1->team)) { - conoutf("you got fragged by a teammate " - "(%s)", + conoutf(@"you got fragged by a " + @"teammate (%s)", a->name); } else { conoutf( - "you got fragged by %s", a->name); - }; - }; - }; + @"you got fragged by %s", a->name); + } + } + } showscores(true); addmsg(1, 2, SV_DIED, actor); player1->lifesequence++; player1->attacking = false; player1->state = CS_DEAD; @@ -450,26 +450,26 @@ playsound(S_DIE1 + rnd(2)); spawnstate(player1); player1->lastaction = lastmillis; } else { playsound(S_PAIN6); - }; -}; + } +} void timeupdate(int timeremain) { if (!timeremain) { intermission = true; player1->attacking = false; - conoutf("intermission:"); - conoutf("game has ended!"); + conoutf(@"intermission:"); + conoutf(@"game has ended!"); showscores(true); } else { - conoutf("time remaining: %d minutes", timeremain); - }; -}; + conoutf(@"time remaining: %d minutes", timeremain); + } +} dynent * getclient(int cn) // ensure valid entity { if (cn < 0 || cn >= MAXCLIENTS) { @@ -477,11 +477,11 @@ return NULL; }; while (cn >= players.length()) players.add(NULL); return players[cn] ? players[cn] : (players[cn] = newdynent()); -}; +} void initclient() { clientmap[0] = 0; @@ -491,12 +491,12 @@ void startmap(char *name) // called just after a map load { if (netmapstart() && m_sp) { gamemode = 0; - conoutf("coop sp not supported yet"); - }; + conoutf(@"coop sp not supported yet"); + } sleepwait = 0; monsterclear(); projreset(); spawncycle = -1; spawnplayer(player1); @@ -510,9 +510,9 @@ setvar("fog", 180); setvar("fogcolour", 0x8099B3); showscores(false); intermission = false; framesinmap = 0; - conoutf("game mode is %s", modestr(gamemode)); + conoutf(@"game mode is %s", modestr(gamemode)); }; COMMANDN(map, changemap, ARG_1STR); Index: src/clients2c.mm ================================================================== --- src/clients2c.mm +++ src/clients2c.mm @@ -8,11 +8,11 @@ extern string clientpassword; void neterr(char *s) { - conoutf("illegal network message (%s)", s); + conoutf(@"illegal network message (%s)", s); disconnect(); }; void changemapserv(char *name, int mode) // forced map change from the server @@ -74,12 +74,12 @@ 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)", + conoutf(@"you are using a different game " + @"protocol (you: %d, server: %d)", PROTOCOL_VERSION, prot); disconnect(); return; }; toservermap[0] = 0; @@ -88,17 +88,17 @@ strcpy_s(toservermap, getclientmap()); // we are the first client // on this server, set map sgetstr(); if (text[0] && strcmp(text, clientpassword)) { - conoutf("you need to set the correct password " - "to join this server!"); + conoutf(@"you need to set the correct password " + @"to join this server!"); disconnect(); return; }; if (getint(p) == 1) { - conoutf("server is FULL, disconnecting.."); + conoutf(@"server is FULL, disconnecting.."); }; break; }; case SV_POS: // position of another client @@ -134,11 +134,11 @@ playsound(getint(p), &d->o); break; case SV_TEXT: sgetstr(); - conoutf("%s:\f %s", d->name, text); + conoutf(@"%s:\f %s", d->name, text); break; case SV_MAPCHANGE: sgetstr(); changemapserv(text, getint(p)); @@ -153,49 +153,49 @@ }; while ((n = getint(p)) != -1) if (mapchanged) setspawn(n, true); break; - }; + } case SV_MAPRELOAD: // server requests next map { getint(p); sprintf_sd(nextmapalias)("nextmap_%s", getclientmap()); char *map = getalias(nextmapalias); // look up map in the cycle changemap(map ? map : getclientmap()); break; - }; + } case SV_INITC2S: // another client either connected or changed // name/team { sgetstr(); if (d->name[0]) // already connected { if (strcmp(d->name, text)) - conoutf("%s is now known as %s", + conoutf(@"%s is now known as %s", d->name, text); } else // new client { c2sinit = false; // send new players my info again - conoutf("connected: %s", text); + conoutf(@"connected: %s", text); }; strcpy_s(d->name, text); sgetstr(); strcpy_s(d->team, text); d->lifesequence = getint(p); break; - }; + } case SV_CDIS: cn = getint(p); if (!(d = getclient(cn))) break; - conoutf("player %s disconnected", + conoutf(@"player %s disconnected", d->name[0] ? d->name : "[incompatible client]"); zapdynent(players[cn]); break; case SV_SHOT: { @@ -209,11 +209,11 @@ 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); @@ -222,44 +222,44 @@ selfdamage(damage, cn, d); } else playsound( S_PAIN1 + rnd(5), &getclient(target)->o); break; - }; + } case SV_DIED: { int actor = getint(p); if (actor == cn) { - conoutf("%s suicided", d->name); + conoutf(@"%s suicided", d->name); } else if (actor == clientnum) { int frags; if (isteam(player1->team, d->team)) { frags = -1; - conoutf("you fragged a teammate (%s)", + conoutf(@"you fragged a teammate (%s)", d->name); } else { frags = 1; - conoutf("you fragged %s", d->name); - }; + conoutf(@"you fragged %s", d->name); + } addmsg(1, 2, SV_FRAGS, player1->frags += frags); } else { dynent *a = getclient(actor); if (a) { if (isteam(a->team, d->name)) { - conoutf("%s fragged his " - "teammate (%s)", + conoutf(@"%s fragged his " + @"teammate (%s)", a->name, d->name); } else { - conoutf("%s fragged %s", + conoutf(@"%s fragged %s", a->name, d->name); - }; - }; - }; + } + } + } playsound(S_DIE1 + rnd(2), &d->o); d->lifesequence++; break; - }; + } case SV_FRAGS: players[cn]->frags = getint(p); break; @@ -275,11 +275,11 @@ break; vec v = {(float)ents[i].x, (float)ents[i].y, (float)ents[i].z}; playsound(S_ITEMSPAWN, &v); break; - }; + } case SV_ITEMACC: // server acknowledges that I picked up this // item realpickup(getint(p), player1); break; @@ -310,13 +310,13 @@ setvdeltaxy(v, b); break; case SV_EDITE: editequalisexy(v != 0, b); break; - }; + } break; - }; + } case SV_EDITENT: // coop edit of ent { uint i = getint(p); while ((uint)ents.length() <= i) @@ -332,11 +332,11 @@ ents[i].attr4 = getint(p); ents[i].spawned = false; if (ents[i].type == LIGHT || to == LIGHT) calclight(); break; - }; + } case SV_PING: getint(p); break; @@ -359,32 +359,32 @@ timeupdate(getint(p)); break; case SV_RECVMAP: { sgetstr(); - conoutf("received map \"%s\" from server, reloading..", + conoutf(@"received map \"%s\" from server, reloading..", text); int mapsize = getint(p); writemap(text, mapsize, p); p += mapsize; changemapserv(text, gamemode); break; - }; + } case SV_SERVMSG: sgetstr(); - conoutf("%s", text); + conoutf(@"%s", text); break; case SV_EXT: // so we can messages without breaking previous // clients/servers, if necessary { for (int n = getint(p); n; n--) getint(p); break; - }; + } default: neterr("type"); return; - }; -}; + } +} Index: src/command.mm ================================================================== --- src/command.mm +++ src/command.mm @@ -52,11 +52,11 @@ } else { if (b.type == ID_ALIAS) b.action = exchangestr(b.action, action); else conoutf( - "cannot redefine builtin %s with an alias", + @"cannot redefine builtin %s with an alias", name); } } } @@ -150,11 +150,11 @@ brak++; else if (c == right) brak--; else if (!c) { p--; - conoutf("missing \"%c\"", right); + conoutf(@"missing \"%c\"", right); return NULL; } } char *s = newstring(word, p - word - 1); if (left == '(') { @@ -209,11 +209,11 @@ return exchangestr(n, ID.action); } } } - conoutf("unknown alias lookup: %s", n + 1); + conoutf(@"unknown alias lookup: %s", n + 1); return n; } int execute(char *p, bool isdown) // all evaluation happens here, recursively @@ -252,11 +252,11 @@ Ident *ID = idents[@(c)]; if (ID == nil) { val = ATOI(c); if (!val && *c != '0') - conoutf("unknown command: %s", c); + conoutf(@"unknown command: %s", c); } else { switch (ID.type) { // game defined commands case ID_COMMAND: // use very ad-hoc function signature, @@ -393,18 +393,19 @@ if (isdown) { if (!w[1][0]) // var with no value // just prints its // current value - conoutf("%s = %d", c, + conoutf(@"%s = %d", c, *ID.storage); else { if (ID.min > ID.max) { - conoutf("variab" - "le is " - "read-" - "only"); + conoutf( + @"variable " + @"is " + @"read-" + @"only"); } else { int i1 = ATOI(w[1]); if (i1 < ID.min || @@ -417,25 +418,38 @@ i1 = i1 < ID.min ? ID.min : ID.max; conoutf( - "va" - "li" - "d " - "ra" - "ng" - "e " - "fo" - "r " - "%s" - " i" - "s " - "%d" - ".." - "%" - "d", + @"v" + @"a" + @"l" + @"i" + @"d" + @" " + @"r" + @"a" + @"n" + @"g" + @"e" + @" " + @"f" + @"o" + @"r" + @" " + @"%" + @"s" + @" " + @"i" + @"s" + @" " + @"%" + @"d" + @"." + @"." + @"%" + @"d", c, ID.min, ID.max); } *ID.storage = @@ -531,11 +545,11 @@ void exec(char *cfgfile) { if (!execfile(cfgfile)) - conoutf("could not read \"%s\"", cfgfile); + conoutf(@"could not read \"%s\"", cfgfile); } void writecfg() { Index: src/console.mm ================================================================== --- src/console.mm +++ src/console.mm @@ -48,22 +48,22 @@ fflush(stdout); #endif }; void -conoutf(const char *s, ...) +conoutf(OFString *str, ...) { - sprintf_sdv(sf, s); - s = sf; + sprintf_sdv(sf, str.UTF8String); + const char *s = sf; int n = 0; while (strlen(s) > WORDWRAP) // cut strings to fit on screen { string t; strn0cpy(t, s, WORDWRAP + 1); conline(t, n++ != 0); s += WORDWRAP; - }; + } conline(s, n != 0); }; void renderconsole() // render buffer taking into account time & scrolling @@ -112,11 +112,11 @@ loopi(numkm) if (strcmp(keyms[i].name, key) == 0) { strcpy_s(keyms[i].action, action); return; }; - conoutf("unknown key \"%s\"", key); + conoutf(@"unknown key \"%s\"", key); }; COMMANDN(bind, bindkey, ARG_2STR); void Index: src/cube.h ================================================================== --- src/cube.h +++ src/cube.h @@ -392,37 +392,37 @@ // nasty macros for registering script functions, abuses globals to avoid // excessive infrastructure #define COMMANDN(name, fun, nargs) \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(#name, ^{ \ addcommand(#name, (void (*)())fun, nargs); \ }); \ } #define COMMAND(name, nargs) COMMANDN(name, name, nargs) #define VARP(name, min, cur, max) \ int name; \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(#name, ^{ \ name = variable(#name, min, cur, max, &name, NULL, true); \ }); \ } #define VAR(name, min, cur, max) \ int name; \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(#name, ^{ \ name = variable(#name, min, cur, max, &name, NULL, false); \ }); \ } #define VARF(name, min, cur, max, body) \ void var_##name(); \ static int name; \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(#name, ^{ \ name = variable( \ #name, min, cur, max, &name, var_##name, false); \ }); \ } \ void var_##name() { body; } @@ -429,11 +429,11 @@ #define VARFP(name, min, cur, max, body) \ void var_##name(); \ static int name; \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(#name, ^{ \ name = \ variable(#name, min, cur, max, &name, var_##name, true); \ }); \ } \ void var_##name() { body; } Index: src/editing.mm ================================================================== --- src/editing.mm +++ src/editing.mm @@ -85,19 +85,19 @@ bool noteditmode() { correctsel(); if (!editmode) - conoutf("this function is only allowed in edit mode"); + conoutf(@"this function is only allowed in edit mode"); return !editmode; }; bool noselection() { if (!selset) - conoutf("no selection"); + conoutf(@"no selection"); return !selset; }; #define EDITSEL \ if (noteditmode() || noselection()) \ @@ -256,11 +256,11 @@ void editundo() { EDITMP; if (undos.empty()) { - conoutf("nothing more to undo"); + conoutf(@"nothing more to undo"); return; }; block *p = undos.pop(); blockpaste(*p); free(p); @@ -280,18 +280,18 @@ void paste() { EDITMP; if (!copybuf) { - conoutf("nothing to paste"); + conoutf(@"nothing to paste"); return; }; sel.xs = copybuf->xs; sel.ys = copybuf->ys; correctsel(); if (!selset || sel.xs != copybuf->xs || sel.ys != copybuf->ys) { - conoutf("incorrect selection"); + conoutf(@"incorrect selection"); return; }; makeundo(); copybuf->x = sel.x; copybuf->y = sel.y; @@ -438,11 +438,11 @@ { 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"); + 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); }; Index: src/entities.mm ================================================================== --- src/entities.mm +++ src/entities.mm @@ -182,14 +182,14 @@ d->armourtype = A_YELLOW; break; case I_QUAD: radditem(n, d->quadmillis); - conoutf("you got the quad!"); + conoutf(@"you got the quad!"); break; - }; -}; + } +} // these functions are called when the client touches the item void additem(int i, int &v, int spawnsec) @@ -199,21 +199,21 @@ { addmsg(1, 3, SV_ITEMPICKUP, i, m_classicsp ? 100000 : spawnsec); // first ask the server for an ack ents[i].spawned = false; // even if someone else gets it first - }; -}; + } +} void teleport(int n, dynent *d) // also used by monsters { int e = -1, tag = ents[n].attr1, beenhere = -1; for (;;) { e = findentity(TELEDEST, e + 1); if (e == beenhere || e < 0) { - conoutf("no teleport destination for tag %d", tag); + conoutf(@"no teleport destination for tag %d", tag); return; }; if (beenhere < 0) beenhere = e; if (ents[e].attr2 == tag) { @@ -330,24 +330,24 @@ checkquad(int time) { if (player1->quadmillis && (player1->quadmillis -= time) < 0) { player1->quadmillis = 0; playsoundc(S_PUPOUT); - conoutf("quad damage is over"); - }; -}; + conoutf(@"quad damage is over"); + } +} void putitems(uchar *&p) // puts items in network stream and also spawns them locally { loopv(ents) if ((ents[i].type >= I_SHELLS && ents[i].type <= I_QUAD) || ents[i].type == CARROT) { putint(p, i); ents[i].spawned = true; - }; -}; + } +} void resetspawns() { loopv(ents) ents[i].spawned = false; Index: src/main.mm ================================================================== --- src/main.mm +++ src/main.mm @@ -104,11 +104,11 @@ char *sdesc = "", *ip = "", *master = NULL, *passwd = ""; islittleendian = *((char *)&islittleendian); processInitQueue(); -#define log(s) conoutf("init: %s", s) +#define log(s) conoutf(@"init: %s", s) log("sdl"); for (int i = 1; i < argc; i++) { char *a = &argv[i][2]; if (argv[i][0] == '-') @@ -142,14 +142,14 @@ break; case 'c': maxcl = atoi(a); break; default: - conoutf("unknown commandline option"); + conoutf(@"unknown commandline option"); } else - conoutf("unknown commandline argument"); + conoutf(@"unknown commandline argument"); }; #ifdef _DEBUG par = SDL_INIT_NOPARACHUTE; fs = 0; Index: src/monster.mm ================================================================== --- src/monster.mm +++ src/monster.mm @@ -3,11 +3,11 @@ #include "cube.h" dvector monsters; int nextmonster, spawnremain, numkilled, monstertotal, mtimestart; -VARF(skill, 1, 3, 10, conoutf("skill is now %d", skill)); +VARF(skill, 1, 3, 10, conoutf(@"skill is now %d", skill)); dvector & getmonsters() { return monsters; @@ -50,11 +50,11 @@ dynent * basicmonster(int type, int yaw, int state, int trigger, int move) { if (type >= NUMMONSTERTYPES) { - conoutf("warning: unknown monster in spawn: %d", type); + conoutf(@"warning: unknown monster in spawn: %d", type); type = 0; }; dynent *m = newdynent(); monstertype *t = &monstertypes[m->mtype = type]; m->eyeheight = 2.0f; @@ -338,22 +338,22 @@ numkilled++; player1->frags = numkilled; playsound(monstertypes[m->mtype].diesound, &m->o); int remain = monstertotal - numkilled; if (remain > 0 && remain <= 5) - conoutf("only %d monster(s) remaining", remain); + conoutf(@"only %d monster(s) remaining", remain); } else { playsound(monstertypes[m->mtype].painsound, &m->o); }; }; void endsp(bool allkilled) { - conoutf( - allkilled ? "you have cleared the map!" : "you reached the exit!"); - conoutf("score: %d kills in %d seconds", numkilled, + conoutf(allkilled ? @"you have cleared the map!" + : @"you reached the exit!"); + conoutf(@"score: %d kills in %d seconds", numkilled, (lastmillis - mtimestart) / 1000); monstertotal = 0; startintermission(); }; @@ -360,11 +360,11 @@ void monsterthink() { if (m_dmsp && spawnremain && lastmillis > nextmonster) { if (spawnremain-- == monstertotal) - conoutf("The invasion has begun!"); + conoutf(@"The invasion has begun!"); nextmonster = lastmillis + 1000; spawnmonster(); }; if (monstertotal && !spawnremain && numkilled == monstertotal) Index: src/protos.h ================================================================== --- src/protos.h +++ src/protos.h @@ -17,11 +17,11 @@ extern void writecfg(); // console extern void keypress(int code, bool isdown, int cooked); extern void renderconsole(); -extern void conoutf(const char *s, ...); +extern void conoutf(OFString *s, ...); extern char *getcurcommand(); extern void writebinds(FILE *f); // init extern void enqueueInit(const char *name, void (^init)(void)); Index: src/rendercubes.mm ================================================================== --- src/rendercubes.mm +++ src/rendercubes.mm @@ -69,11 +69,11 @@ }; void mipstats(int a, int b, int c) { if (showm) - conoutf("1x1/2x2/4x4: %d / %d / %d", a, b, c); + conoutf(@"1x1/2x2/4x4: %d / %d / %d", a, b, c); }; COMMAND(showmip, ARG_NONE); #define stripend() \ Index: src/renderextras.mm ================================================================== --- src/renderextras.mm +++ src/renderextras.mm @@ -208,11 +208,11 @@ loopi(6) { sprintf_sd(name)("packages/%s_%s.jpg", basename, side[i]); int xs, ys; if (!installtex(texnum + i, path(name), xs, ys, true)) - conoutf("could not load sky textures"); + conoutf(@"could not load sky textures"); }; strcpy_s(lastsky, basename); }; COMMAND(loadsky, ARG_1STR); Index: src/rendergl.mm ================================================================== --- src/rendergl.mm +++ src/rendergl.mm @@ -46,12 +46,12 @@ char *exts = (char *)glGetString(GL_EXTENSIONS); if (strstr(exts, "GL_EXT_texture_env_combine")) hasoverbright = true; else - conoutf("WARNING: cannot use overbright lighting, using old " - "lighting model!"); + conoutf(@"WARNING: cannot use overbright lighting, using old " + @"lighting model!"); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize); purgetextures(); @@ -75,15 +75,15 @@ bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp) { SDL_Surface *s = IMG_Load(texname); if (!s) { - conoutf("couldn't load texture %s", texname); + conoutf(@"couldn't load texture %s", texname); return false; }; if (s->format->BitsPerPixel != 24) { - conoutf("texture must be 24bpp: %s", texname); + conoutf(@"texture must be 24bpp: %s", texname); return false; }; // loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = 255-*p; }; glBindTexture(GL_TEXTURE_2D, tnum); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -101,11 +101,11 @@ xs /= 2; ys /= 2; }; void *scaledimg = s->pixels; if (xs != s->w) { - conoutf("warning: quality loss: scaling %s", + conoutf(@"warning: quality loss: scaling %s", texname); // for voodoo cards under linux scaledimg = alloc(xs * ys * 3); gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels, xs, ys, GL_UNSIGNED_BYTE, scaledimg); }; @@ -272,12 +272,12 @@ VARFP(gamma, 30, 100, 300, { float f = gamma / 100.0f; if (SDL_SetGamma(f, f, f) == -1) { conoutf( - "Could not set gamma (card/driver doesn't support it?)"); - conoutf("sdl: %s", SDL_GetError()); + @"Could not set gamma (card/driver doesn't support it?)"); + conoutf(@"sdl: %s", SDL_GetError()); }; }); void transplayer() Index: src/savegamedemo.mm ================================================================== --- src/savegamedemo.mm +++ src/savegamedemo.mm @@ -82,11 +82,11 @@ savestate(char *fn) { stop(); f = gzopen(fn, "wb9"); if (!f) { - conoutf("could not write %s", fn); + conoutf(@"could not write %s", fn); return; }; gzwrite(f, (void *)"CUBESAVE", 8); gzputc(f, islittleendian); gzputi(SAVEGAMEVERSION); @@ -102,37 +102,37 @@ gzputi(players.length()); loopv(players) { gzput(players[i] == NULL); gzwrite(f, players[i], sizeof(dynent)); - }; -}; + } +} void savegame(char *name) { if (!m_classicsp) { - conoutf("can only save classic sp games"); + conoutf(@"can only save classic sp games"); return; - }; + } sprintf_sd(fn)("savegames/%s.csgz", name); savestate(fn); stop(); - conoutf("wrote %s", fn); -}; + conoutf(@"wrote %s", fn); +} void loadstate(char *fn) { stop(); if (multiplayer()) return; f = gzopen(fn, "rb9"); if (!f) { - conoutf("could not open %s", fn); + conoutf(@"could not open %s", fn); return; - }; + } string buf; gzread(f, buf, 8); if (strncmp(buf, "CUBESAVE", 8)) goto out; @@ -146,28 +146,28 @@ nextmode = gzgeti(); changemap(mapname); // continue below once map has been loaded and // client & server have updated return; out: - conoutf("aborting: savegame/demo from a different version of cube or " - "cpu architecture"); + conoutf(@"aborting: savegame/demo from a different version of cube or " + @"cpu architecture"); stop(); -}; +} void loadgame(char *name) { sprintf_sd(fn)("savegames/%s.csgz", name); loadstate(fn); -}; +} void loadgameout() { stop(); - conoutf("loadgame incomplete: savegame from a different version of " - "this map"); + conoutf(@"loadgame incomplete: savegame from a different version of " + @"this map"); }; void loadgamerest() { @@ -210,11 +210,11 @@ dynent *d = getclient(i); assert(d); gzread(f, d, sizeof(dynent)); }; - conoutf("savegame restored"); + conoutf(@"savegame restored"); if (demoloading) startdemo(); else stop(); }; @@ -228,20 +228,20 @@ void record(char *name) { if (m_sp) { - conoutf("cannot record singleplayer games"); + conoutf(@"cannot record singleplayer games"); return; }; int cn = getclientnum(); if (cn < 0) return; sprintf_sd(fn)("demos/%s.cdgz", name); savestate(fn); gzputi(cn); - conoutf("started recording demo to %s", fn); + conoutf(@"started recording demo to %s", fn); demorecording = true; starttime = lastmillis; ddamage = bdamage = 0; }; @@ -280,62 +280,62 @@ bdamage = 0; gzputi(ddamage); if (ddamage) { gzputv(dorig); ddamage = 0; - }; + } // FIXME: add all other client state which is not send through // the network - }; -}; + } +} void demo(char *name) { sprintf_sd(fn)("demos/%s.cdgz", name); loadstate(fn); demoloading = true; -}; +} void stopreset() { - conoutf("demo stopped (%d msec elapsed)", lastmillis - starttime); + conoutf(@"demo stopped (%d msec elapsed)", lastmillis - starttime); stop(); loopv(players) zapdynent(players[i]); disconnect(0, 0); -}; +} VAR(demoplaybackspeed, 10, 100, 1000); int scaletime(int t) { return (int)(t * (100.0f / demoplaybackspeed)) + starttime; -}; +} void readdemotime() { if (gzeof(f) || (playbacktime = gzgeti()) == -1) { stopreset(); return; - }; + } playbacktime = scaletime(playbacktime); -}; +} void startdemo() { democlientnum = gzgeti(); demoplayback = true; starttime = lastmillis; - conoutf("now playing demo"); + conoutf(@"now playing demo"); dynent *d = getclient(democlientnum); assert(d); *d = *player1; readdemotime(); -}; +} VAR(demodelaymsec, 0, 120, 500); void catmulrom( @@ -376,11 +376,11 @@ { while (demoplayback && lastmillis >= playbacktime) { int len = gzgeti(); if (len < 1 || len > MAXTRANS) { conoutf( - "error: huge packet during demo play (%d)", len); + @"error: huge packet during demo play (%d)", len); stopreset(); return; }; uchar buf[MAXTRANS]; gzread(f, buf, len); @@ -481,14 +481,14 @@ { if (demoplayback) stopreset(); else stop(); - conoutf("demo stopped"); + conoutf(@"demo stopped"); }; COMMAND(record, ARG_1STR); COMMAND(demo, ARG_1STR); COMMANDN(stop, stopn, ARG_NONE); COMMAND(savegame, ARG_1STR); COMMAND(loadgame, ARG_1STR); Index: src/serverbrowser.mm ================================================================== --- src/serverbrowser.mm +++ src/serverbrowser.mm @@ -304,11 +304,11 @@ const int MAXUPD = 32000; uchar buf[MAXUPD]; uchar *reply = retrieveservers(buf, MAXUPD); if (!*reply || strstr((char *)reply, "") || strstr((char *)reply, "")) - conoutf("master server not replying"); + conoutf(@"master server not replying"); else { servers.setsize(0); execute((char *)reply); }; servermenu(); Index: src/sound.mm ================================================================== --- src/sound.mm +++ src/sound.mm @@ -61,20 +61,20 @@ { memset(soundlocs, 0, sizeof(soundloc) * MAXCHAN); #ifdef USE_MIXER if (Mix_OpenAudio(SOUNDFREQ, MIX_DEFAULT_FORMAT, 2, soundbufferlen) < 0) { - conoutf("sound init failed (SDL_mixer): %s", + conoutf(@"sound init failed (SDL_mixer): %s", (size_t)Mix_GetError()); nosound = true; }; Mix_AllocateChannels(MAXCHAN); #else if (FSOUND_GetVersion() < FMOD_VERSION) fatal("old FMOD dll"); if (!FSOUND_Init(SOUNDFREQ, MAXCHAN, FSOUND_INIT_GLOBALFOCUS)) { - conoutf("sound init failed (FMOD): %d", FSOUND_GetError()); + conoutf(@"sound init failed (FMOD): %d", FSOUND_GetError()); nosound = true; }; #endif }; @@ -104,11 +104,11 @@ FSOUND_SetVolume( chan, (musicvol * MAXVOL) / 255); FSOUND_SetPaused(chan, false); }; } else { - conoutf("could not play music: %s", sn); + conoutf(@"could not play music: %s", sn); }; #endif }; }; @@ -226,11 +226,11 @@ lastsoundmillis = lastmillis; if (soundsatonce > 5) return; // avoid bursts of sounds with heavy packetloss and in // sp if (n < 0 || n >= samples.length()) { - conoutf("unregistered sound: %d", n); + conoutf(@"unregistered sound: %d", n); return; }; if (!samples[n]) { sprintf_sd(buf)("packages/sounds/%s.wav", snames[n]); @@ -241,11 +241,11 @@ samples[n] = FSOUND_Sample_Load(n, path(buf), FSOUND_LOOP_OFF, 0, 0); #endif if (!samples[n]) { - conoutf("failed to load sample: %s", buf); + conoutf(@"failed to load sample: %s", buf); return; }; }; #ifdef USE_MIXER Index: src/weapon.mm ================================================================== --- src/weapon.mm +++ src/weapon.mm @@ -48,11 +48,11 @@ else s = GUN_FIST; if (s != player1->gunselect) playsoundc(S_WEAPLOAD); player1->gunselect = s; - // conoutf("%s selected", (int)guns[s].name); + // conoutf(@"%s selected", (int)guns[s].name); }; int reloadtime(int gun) { Index: src/world.mm ================================================================== --- src/world.mm +++ src/world.mm @@ -291,15 +291,15 @@ void delent() { int e = closestent(); if (e < 0) { - conoutf("no more entities"); + conoutf(@"no more entities"); return; }; int t = ents[e].type; - conoutf("%s entity deleted", entnames[t]); + conoutf(@"%s entity deleted", entnames[t]); ents[e].type = NOTUSED; addmsg(1, 10, SV_EDITENT, e, NOTUSED, 0, 0, 0, 0, 0, 0, 0); if (t == LIGHT) calclight(); }; @@ -306,11 +306,11 @@ int findtype(char *what) { loopi(MAXENTTYPES) if (strcmp(what, entnames[i]) == 0) return i; - conoutf("unknown entity type \"%s\"", what); + conoutf(@"unknown entity type \"%s\"", what); return NOTUSED; } entity * newentity(int x, int y, int z, char *what, int v1, int v2, int v3, int v4) Index: src/worldio.mm ================================================================== --- src/worldio.mm +++ src/worldio.mm @@ -126,25 +126,25 @@ { setnames(mname); backup(cgzname, bakname); FILE *f = fopen(cgzname, "wb"); if (!f) { - conoutf("could not write map to %s", cgzname); + conoutf(@"could not write map to %s", cgzname); return; }; fwrite(mdata, 1, msize, f); fclose(f); - conoutf("wrote map %s as file %s", mname, cgzname); + conoutf(@"wrote map %s as file %s", mname, cgzname); } uchar * readmap(char *mname, int *msize) { setnames(mname); uchar *mdata = (uchar *)loadfile(cgzname, msize); if (!mdata) { - conoutf("could not read map %s", cgzname); + conoutf(@"could not read map %s", cgzname); return NULL; }; return mdata; } @@ -163,11 +163,11 @@ mname = getclientmap(); setnames(mname); backup(cgzname, bakname); gzFile f = gzopen(cgzname, "wb9"); if (!f) { - conoutf("could not write map to %s", cgzname); + conoutf(@"could not write map to %s", cgzname); return; }; hdr.version = MAPVERSION; hdr.numents = 0; loopv(ents) if (ents[i].type != NOTUSED) hdr.numents++; @@ -235,11 +235,11 @@ }; t = s; }; spurge; gzclose(f); - conoutf("wrote map file %s", cgzname); + conoutf(@"wrote map file %s", cgzname); settagareas(); }; void load_world(char *mname) // still supports all map formats that have existed @@ -249,11 +249,11 @@ cleardlights(); pruneundos(); setnames(mname); gzFile f = gzopen(cgzname, "rb9"); if (!f) { - conoutf("could not read map %s", cgzname); + conoutf(@"could not read map %s", cgzname); return; }; gzread(f, &hdr, sizeof(header) - sizeof(int) * 16); endianswap(&hdr.version, sizeof(int), 4); if (strncmp(hdr.head, "CUBE", 4) != 0) @@ -355,13 +355,13 @@ gzclose(f); calclight(); settagareas(); int xs, ys; loopi(256) if (texuse) lookuptexture(i, xs, ys); - conoutf("read map %s (%d milliseconds)", cgzname, + conoutf(@"read map %s (%d milliseconds)", cgzname, SDL_GetTicks() - lastmillis); - conoutf("%s", hdr.maptitle); + conoutf(@"%s", hdr.maptitle); startmap(mname); loopl(256) { sprintf_sd(aliasname)( "level_trigger_%d", l); // can this be done smarter?