Make conoutf take an OFString

FossilOrigin-Name: f8f97851f3ec3f0920a95912e7bfe58995f5ca1bcd4c5b5ee3532cb1809eab46
This commit is contained in:
Jonathan Schleifer 2024-08-03 17:02:33 +00:00
parent faf0a4096e
commit 7f42da935a
21 changed files with 240 additions and 221 deletions

View file

@ -13,25 +13,28 @@ int
getclientnum() getclientnum()
{ {
return clientnum; return clientnum;
}; }
bool bool
multiplayer() multiplayer()
{ {
// check not correct on listen server? // check not correct on listen server?
if (clienthost) if (clienthost)
conoutf("operation not available in multiplayer"); conoutf(@"operation not available in multiplayer");
return clienthost != NULL; return clienthost != NULL;
}; }
bool bool
allowedittoggle() allowedittoggle()
{ {
bool allow = !clienthost || gamemode == 1; bool allow = !clienthost || gamemode == 1;
if (!allow) if (!allow)
conoutf("editing in multiplayer requires coopedit mode (1)"); conoutf(@"editing in multiplayer requires coopedit mode (1)");
return allow; return allow;
}; }
VARF(rate, 0, 0, 25000, VARF(rate, 0, 0, 25000,
if (clienthost && (!rate || rate > 1000)) if (clienthost && (!rate || rate > 1000))
@ -51,20 +54,21 @@ throttle()
assert(ENET_PEER_PACKET_THROTTLE_SCALE == 32); assert(ENET_PEER_PACKET_THROTTLE_SCALE == 32);
enet_peer_throttle_configure(clienthost->peers, enet_peer_throttle_configure(clienthost->peers,
throttle_interval * 1000, throttle_accel, throttle_decel); throttle_interval * 1000, throttle_accel, throttle_decel);
}; }
void void
newname(char *name) newname(char *name)
{ {
c2sinit = false; c2sinit = false;
strn0cpy(player1->name, name, 16); strn0cpy(player1->name, name, 16);
}; }
void void
newteam(char *name) newteam(char *name)
{ {
c2sinit = false; c2sinit = false;
strn0cpy(player1->team, name, 5); strn0cpy(player1->team, name, 5);
}; }
COMMANDN(team, newteam, ARG_1STR); COMMANDN(team, newteam, ARG_1STR);
COMMANDN(name, newname, ARG_1STR); COMMANDN(name, newname, ARG_1STR);
@ -73,7 +77,7 @@ void
writeclientinfo(FILE *f) writeclientinfo(FILE *f)
{ {
fprintf(f, "name \"%s\"\nteam \"%s\"\n", player1->name, player1->team); fprintf(f, "name \"%s\"\nteam \"%s\"\n", player1->name, player1->team);
}; }
void void
connects(char *servername) connects(char *servername)
@ -81,10 +85,10 @@ connects(char *servername)
disconnect(1); // reset state disconnect(1); // reset state
addserver(servername); addserver(servername);
conoutf("attempting to connect to %s", servername); conoutf(@"attempting to connect to %s", servername);
ENetAddress address = {ENET_HOST_ANY, CUBE_SERVER_PORT}; ENetAddress address = {ENET_HOST_ANY, CUBE_SERVER_PORT};
if (enet_address_set_host(&address, servername) < 0) { if (enet_address_set_host(&address, servername) < 0) {
conoutf("could not resolve server %s", servername); conoutf(@"could not resolve server %s", servername);
return; return;
}; };
@ -96,10 +100,10 @@ connects(char *servername)
connecting = lastmillis; connecting = lastmillis;
connattempts = 0; connattempts = 0;
} else { } else {
conoutf("could not connect to server"); conoutf(@"could not connect to server");
disconnect(); disconnect();
}; }
}; }
void void
disconnect(int onlyclean, int async) disconnect(int onlyclean, int async)
@ -119,7 +123,7 @@ disconnect(int onlyclean, int async)
}; };
if (clienthost && !connecting) if (clienthost && !connecting)
conoutf("disconnected"); conoutf(@"disconnected");
clienthost = NULL; clienthost = NULL;
connecting = 0; connecting = 0;
connattempts = 0; connattempts = 0;
@ -134,37 +138,38 @@ disconnect(int onlyclean, int async)
if (!onlyclean) { if (!onlyclean) {
stop(); stop();
localconnect(); localconnect();
}; }
}; }
void void
trydisconnect() trydisconnect()
{ {
if (!clienthost) { if (!clienthost) {
conoutf("not connected"); conoutf(@"not connected");
return; return;
}; }
if (connecting) { if (connecting) {
conoutf("aborting connection attempt"); conoutf(@"aborting connection attempt");
disconnect(); disconnect();
return; return;
}; }
conoutf("attempting to disconnect..."); conoutf(@"attempting to disconnect...");
disconnect(0, !disconnecting); disconnect(0, !disconnecting);
}; }
string ctext; string ctext;
void void
toserver(char *text) toserver(char *text)
{ {
conoutf("%s:\f %s", player1->name, text); conoutf(@"%s:\f %s", player1->name, text);
strn0cpy(ctext, text, 80); strn0cpy(ctext, text, 80);
}; }
void void
echo(char *text) echo(char *text)
{ {
conoutf("%s", text); conoutf(@"%s", text);
}; }
COMMAND(echo, ARG_VARI); COMMAND(echo, ARG_VARI);
COMMANDN(say, toserver, ARG_VARI); COMMANDN(say, toserver, ARG_VARI);
@ -186,7 +191,7 @@ addmsg(int rel, int num, int type, ...)
fatal(s); fatal(s);
}; };
if (messages.length() == 100) { if (messages.length() == 100) {
conoutf("command flood protection (type %d)", type); conoutf(@"command flood protection (type %d)", type);
return; return;
}; };
ivector &msg = messages.add(); ivector &msg = messages.add();
@ -197,14 +202,14 @@ addmsg(int rel, int num, int type, ...)
va_start(marker, type); va_start(marker, type);
loopi(num - 1) msg.add(va_arg(marker, int)); loopi(num - 1) msg.add(va_arg(marker, int));
va_end(marker); va_end(marker);
}; }
void void
server_err() server_err()
{ {
conoutf("server network error, disconnecting..."); conoutf(@"server network error, disconnecting...");
disconnect(); disconnect();
}; }
int lastupdate = 0, lastping = 0; int lastupdate = 0, lastping = 0;
string toservermap; string toservermap;
@ -345,11 +350,11 @@ gets2c() // get updates from the server
if (!clienthost) if (!clienthost)
return; return;
if (connecting && lastmillis / 3000 > connecting / 3000) { if (connecting && lastmillis / 3000 > connecting / 3000) {
conoutf("attempting to connect..."); conoutf(@"attempting to connect...");
connecting = lastmillis; connecting = lastmillis;
++connattempts; ++connattempts;
if (connattempts > 3) { if (connattempts > 3) {
conoutf("could not connect to server"); conoutf(@"could not connect to server");
disconnect(); disconnect();
return; return;
}; };
@ -358,14 +363,14 @@ gets2c() // get updates from the server
clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0) clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0)
switch (event.type) { switch (event.type) {
case ENET_EVENT_TYPE_CONNECT: case ENET_EVENT_TYPE_CONNECT:
conoutf("connected to server"); conoutf(@"connected to server");
connecting = 0; connecting = 0;
throttle(); throttle();
break; break;
case ENET_EVENT_TYPE_RECEIVE: case ENET_EVENT_TYPE_RECEIVE:
if (disconnecting) if (disconnecting)
conoutf("attempting to disconnect..."); conoutf(@"attempting to disconnect...");
else else
localservertoclient(event.packet->data, localservertoclient(event.packet->data,
event.packet->dataLength); event.packet->dataLength);

View file

@ -179,7 +179,7 @@ sendmap(char *mapname)
sendstring(mapname, p); sendstring(mapname, p);
putint(p, mapsize); putint(p, mapsize);
if (65535 - (p - start) < 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); free(mapdata);
enet_packet_destroy(packet); enet_packet_destroy(packet);
return; return;
@ -190,7 +190,7 @@ sendmap(char *mapname)
*(ushort *)start = ENET_HOST_TO_NET_16(p - start); *(ushort *)start = ENET_HOST_TO_NET_16(p - start);
enet_packet_resize(packet, p - start); enet_packet_resize(packet, p - start);
sendpackettoserv(packet); sendpackettoserv(packet);
conoutf("sending map %s to server...", mapname); conoutf(@"sending map %s to server...", mapname);
sprintf_sd(msg)( sprintf_sd(msg)(
"[map %s uploaded to server, \"getmap\" to receive it]", mapname); "[map %s uploaded to server, \"getmap\" to receive it]", mapname);
toserver(msg); toserver(msg);
@ -207,7 +207,7 @@ getmap()
*(ushort *)start = ENET_HOST_TO_NET_16(p - start); *(ushort *)start = ENET_HOST_TO_NET_16(p - start);
enet_packet_resize(packet, p - start); enet_packet_resize(packet, p - start);
sendpackettoserv(packet); sendpackettoserv(packet);
conoutf("requesting map from server..."); conoutf(@"requesting map from server...");
} }
COMMAND(sendmap, ARG_1STR); COMMAND(sendmap, ARG_1STR);

View file

@ -158,7 +158,7 @@ arenarespawn()
if (arenarespawnwait) { if (arenarespawnwait) {
if (arenarespawnwait < lastmillis) { if (arenarespawnwait < lastmillis) {
arenarespawnwait = 0; arenarespawnwait = 0;
conoutf("new round starting... fight!"); conoutf(@"new round starting... fight!");
respawnself(); respawnself();
}; };
} else if (arenadetectwait == 0 || arenadetectwait < lastmillis) { } else if (arenadetectwait == 0 || arenadetectwait < lastmillis) {
@ -171,12 +171,12 @@ arenarespawn()
arenacount(player1, alive, dead, lastteam, oneteam); arenacount(player1, alive, dead, lastteam, oneteam);
if (dead > 0 && (alive <= 1 || (m_teammode && oneteam))) { if (dead > 0 && (alive <= 1 || (m_teammode && oneteam))) {
conoutf( conoutf(
"arena round is over! next round in 5 seconds..."); @"arena round is over! next round in 5 seconds...");
if (alive) if (alive)
conoutf( conoutf(
"team %s is last man standing", lastteam); @"team %s is last man standing", lastteam);
else else
conoutf("everyone died!"); conoutf(@"everyone died!");
arenarespawnwait = lastmillis + 5000; arenarespawnwait = lastmillis + 5000;
arenadetectwait = lastmillis + 10000; arenadetectwait = lastmillis + 10000;
player1->roll = 0; player1->roll = 0;
@ -218,7 +218,7 @@ respawn()
if (player1->state == CS_DEAD) { if (player1->state == CS_DEAD) {
player1->attacking = false; player1->attacking = false;
if (m_arena) { if (m_arena) {
conoutf("waiting for new round to start..."); conoutf(@"waiting for new round to start...");
return; return;
}; };
if (m_sp) { if (m_sp) {
@ -299,8 +299,8 @@ entinmap(dynent *
d->o.x -= dx; d->o.x -= dx;
d->o.y -= dy; d->o.y -= dy;
}; };
conoutf( conoutf(@"can't find entity spawn spot! (%d, %d)", (int)d->o.x,
"can't find entity spawn spot! (%d, %d)", (int)d->o.x, (int)d->o.y); (int)d->o.y);
// leave ent at original pos, possibly stuck // leave ent at original pos, possibly stuck
}; };
@ -422,24 +422,24 @@ selfdamage(int damage, int actor, dynent *act)
// on amount of damage // on amount of damage
if ((player1->health -= damage) <= 0) { if ((player1->health -= damage) <= 0) {
if (actor == -2) { if (actor == -2) {
conoutf("you got killed by %s!", act->name); conoutf(@"you got killed by %s!", act->name);
} else if (actor == -1) { } else if (actor == -1) {
actor = getclientnum(); actor = getclientnum();
conoutf("you suicided!"); conoutf(@"you suicided!");
addmsg(1, 2, SV_FRAGS, --player1->frags); addmsg(1, 2, SV_FRAGS, --player1->frags);
} else { } else {
dynent *a = getclient(actor); dynent *a = getclient(actor);
if (a) { if (a) {
if (isteam(a->team, player1->team)) { if (isteam(a->team, player1->team)) {
conoutf("you got fragged by a teammate " conoutf(@"you got fragged by a "
"(%s)", @"teammate (%s)",
a->name); a->name);
} else { } else {
conoutf( conoutf(
"you got fragged by %s", a->name); @"you got fragged by %s", a->name);
}; }
}; }
}; }
showscores(true); showscores(true);
addmsg(1, 2, SV_DIED, actor); addmsg(1, 2, SV_DIED, actor);
player1->lifesequence++; player1->lifesequence++;
@ -452,8 +452,8 @@ selfdamage(int damage, int actor, dynent *act)
player1->lastaction = lastmillis; player1->lastaction = lastmillis;
} else { } else {
playsound(S_PAIN6); playsound(S_PAIN6);
}; }
}; }
void void
timeupdate(int timeremain) timeupdate(int timeremain)
@ -461,13 +461,13 @@ timeupdate(int timeremain)
if (!timeremain) { if (!timeremain) {
intermission = true; intermission = true;
player1->attacking = false; player1->attacking = false;
conoutf("intermission:"); conoutf(@"intermission:");
conoutf("game has ended!"); conoutf(@"game has ended!");
showscores(true); showscores(true);
} else { } else {
conoutf("time remaining: %d minutes", timeremain); conoutf(@"time remaining: %d minutes", timeremain);
}; }
}; }
dynent * dynent *
getclient(int cn) // ensure valid entity getclient(int cn) // ensure valid entity
@ -479,7 +479,7 @@ getclient(int cn) // ensure valid entity
while (cn >= players.length()) while (cn >= players.length())
players.add(NULL); players.add(NULL);
return players[cn] ? players[cn] : (players[cn] = newdynent()); return players[cn] ? players[cn] : (players[cn] = newdynent());
}; }
void void
initclient() initclient()
@ -493,8 +493,8 @@ startmap(char *name) // called just after a map load
{ {
if (netmapstart() && m_sp) { if (netmapstart() && m_sp) {
gamemode = 0; gamemode = 0;
conoutf("coop sp not supported yet"); conoutf(@"coop sp not supported yet");
}; }
sleepwait = 0; sleepwait = 0;
monsterclear(); monsterclear();
projreset(); projreset();
@ -512,7 +512,7 @@ startmap(char *name) // called just after a map load
showscores(false); showscores(false);
intermission = false; intermission = false;
framesinmap = 0; framesinmap = 0;
conoutf("game mode is %s", modestr(gamemode)); conoutf(@"game mode is %s", modestr(gamemode));
}; };
COMMANDN(map, changemap, ARG_1STR); COMMANDN(map, changemap, ARG_1STR);

View file

@ -10,7 +10,7 @@ extern string clientpassword;
void void
neterr(char *s) neterr(char *s)
{ {
conoutf("illegal network message (%s)", s); conoutf(@"illegal network message (%s)", s);
disconnect(); disconnect();
}; };
@ -76,8 +76,8 @@ localservertoclient(
cn = getint(p); cn = getint(p);
int prot = getint(p); int prot = getint(p);
if (prot != PROTOCOL_VERSION) { if (prot != PROTOCOL_VERSION) {
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();
return; return;
@ -90,13 +90,13 @@ localservertoclient(
// on this server, set map // on this server, set map
sgetstr(); sgetstr();
if (text[0] && strcmp(text, clientpassword)) { if (text[0] && strcmp(text, clientpassword)) {
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();
return; return;
}; };
if (getint(p) == 1) { if (getint(p) == 1) {
conoutf("server is FULL, disconnecting.."); conoutf(@"server is FULL, disconnecting..");
}; };
break; break;
}; };
@ -136,7 +136,7 @@ localservertoclient(
case SV_TEXT: case SV_TEXT:
sgetstr(); sgetstr();
conoutf("%s:\f %s", d->name, text); conoutf(@"%s:\f %s", d->name, text);
break; break;
case SV_MAPCHANGE: case SV_MAPCHANGE:
@ -155,7 +155,7 @@ localservertoclient(
if (mapchanged) if (mapchanged)
setspawn(n, true); setspawn(n, true);
break; break;
}; }
case SV_MAPRELOAD: // server requests next map case SV_MAPRELOAD: // server requests next map
{ {
@ -165,7 +165,7 @@ localservertoclient(
getalias(nextmapalias); // look up map in the cycle getalias(nextmapalias); // look up map in the cycle
changemap(map ? map : getclientmap()); changemap(map ? map : getclientmap());
break; break;
}; }
case SV_INITC2S: // another client either connected or changed case SV_INITC2S: // another client either connected or changed
// name/team // name/team
@ -174,26 +174,26 @@ localservertoclient(
if (d->name[0]) // already connected if (d->name[0]) // already connected
{ {
if (strcmp(d->name, text)) if (strcmp(d->name, text))
conoutf("%s is now known as %s", conoutf(@"%s is now known as %s",
d->name, text); d->name, text);
} else // new client } else // new client
{ {
c2sinit = c2sinit =
false; // send new players my info again false; // send new players my info again
conoutf("connected: %s", text); conoutf(@"connected: %s", text);
}; };
strcpy_s(d->name, text); strcpy_s(d->name, text);
sgetstr(); sgetstr();
strcpy_s(d->team, text); strcpy_s(d->team, text);
d->lifesequence = getint(p); d->lifesequence = getint(p);
break; break;
}; }
case SV_CDIS: case SV_CDIS:
cn = getint(p); cn = getint(p);
if (!(d = getclient(cn))) if (!(d = getclient(cn)))
break; break;
conoutf("player %s disconnected", conoutf(@"player %s disconnected",
d->name[0] ? d->name : "[incompatible client]"); d->name[0] ? d->name : "[incompatible client]");
zapdynent(players[cn]); zapdynent(players[cn]);
break; break;
@ -211,7 +211,7 @@ localservertoclient(
createrays(s, e); createrays(s, e);
shootv(gun, s, e, d); shootv(gun, s, e, d);
break; break;
}; }
case SV_DAMAGE: { case SV_DAMAGE: {
int target = getint(p); int target = getint(p);
@ -224,40 +224,40 @@ localservertoclient(
playsound( playsound(
S_PAIN1 + rnd(5), &getclient(target)->o); S_PAIN1 + rnd(5), &getclient(target)->o);
break; break;
}; }
case SV_DIED: { case SV_DIED: {
int actor = getint(p); int actor = getint(p);
if (actor == cn) { if (actor == cn) {
conoutf("%s suicided", d->name); conoutf(@"%s suicided", d->name);
} else if (actor == clientnum) { } else if (actor == clientnum) {
int frags; int frags;
if (isteam(player1->team, d->team)) { if (isteam(player1->team, d->team)) {
frags = -1; frags = -1;
conoutf("you fragged a teammate (%s)", conoutf(@"you fragged a teammate (%s)",
d->name); d->name);
} else { } else {
frags = 1; frags = 1;
conoutf("you fragged %s", d->name); conoutf(@"you fragged %s", d->name);
}; }
addmsg(1, 2, SV_FRAGS, player1->frags += frags); addmsg(1, 2, SV_FRAGS, player1->frags += frags);
} else { } else {
dynent *a = getclient(actor); dynent *a = getclient(actor);
if (a) { if (a) {
if (isteam(a->team, d->name)) { if (isteam(a->team, d->name)) {
conoutf("%s fragged his " conoutf(@"%s fragged his "
"teammate (%s)", @"teammate (%s)",
a->name, d->name); a->name, d->name);
} else { } else {
conoutf("%s fragged %s", conoutf(@"%s fragged %s",
a->name, d->name); a->name, d->name);
}; }
}; }
}; }
playsound(S_DIE1 + rnd(2), &d->o); playsound(S_DIE1 + rnd(2), &d->o);
d->lifesequence++; d->lifesequence++;
break; break;
}; }
case SV_FRAGS: case SV_FRAGS:
players[cn]->frags = getint(p); players[cn]->frags = getint(p);
@ -277,7 +277,7 @@ localservertoclient(
(float)ents[i].z}; (float)ents[i].z};
playsound(S_ITEMSPAWN, &v); playsound(S_ITEMSPAWN, &v);
break; break;
}; }
case SV_ITEMACC: // server acknowledges that I picked up this case SV_ITEMACC: // server acknowledges that I picked up this
// item // item
@ -312,9 +312,9 @@ localservertoclient(
case SV_EDITE: case SV_EDITE:
editequalisexy(v != 0, b); editequalisexy(v != 0, b);
break; break;
}; }
break; break;
}; }
case SV_EDITENT: // coop edit of ent case SV_EDITENT: // coop edit of ent
{ {
@ -334,7 +334,7 @@ localservertoclient(
if (ents[i].type == LIGHT || to == LIGHT) if (ents[i].type == LIGHT || to == LIGHT)
calclight(); calclight();
break; break;
}; }
case SV_PING: case SV_PING:
getint(p); getint(p);
@ -361,18 +361,18 @@ localservertoclient(
case SV_RECVMAP: { case SV_RECVMAP: {
sgetstr(); sgetstr();
conoutf("received map \"%s\" from server, reloading..", conoutf(@"received map \"%s\" from server, reloading..",
text); text);
int mapsize = getint(p); int mapsize = getint(p);
writemap(text, mapsize, p); writemap(text, mapsize, p);
p += mapsize; p += mapsize;
changemapserv(text, gamemode); changemapserv(text, gamemode);
break; break;
}; }
case SV_SERVMSG: case SV_SERVMSG:
sgetstr(); sgetstr();
conoutf("%s", text); conoutf(@"%s", text);
break; break;
case SV_EXT: // so we can messages without breaking previous case SV_EXT: // so we can messages without breaking previous
@ -381,10 +381,10 @@ localservertoclient(
for (int n = getint(p); n; n--) for (int n = getint(p); n; n--)
getint(p); getint(p);
break; break;
}; }
default: default:
neterr("type"); neterr("type");
return; return;
}; }
}; }

View file

@ -54,7 +54,7 @@ alias(char *name, char *action)
b.action = exchangestr(b.action, action); b.action = exchangestr(b.action, action);
else else
conoutf( conoutf(
"cannot redefine builtin %s with an alias", @"cannot redefine builtin %s with an alias",
name); name);
} }
} }
@ -152,7 +152,7 @@ parseexp(char *&p, int right) // parse any nested set of () or []
brak--; brak--;
else if (!c) { else if (!c) {
p--; p--;
conoutf("missing \"%c\"", right); conoutf(@"missing \"%c\"", right);
return NULL; return NULL;
} }
} }
@ -211,7 +211,7 @@ lookup(char *n) // find value of ident referenced with $ in exp
} }
} }
conoutf("unknown alias lookup: %s", n + 1); conoutf(@"unknown alias lookup: %s", n + 1);
return n; return n;
} }
@ -254,7 +254,7 @@ execute(char *p, bool isdown) // all evaluation happens here, recursively
if (ID == nil) { if (ID == nil) {
val = ATOI(c); val = ATOI(c);
if (!val && *c != '0') if (!val && *c != '0')
conoutf("unknown command: %s", c); conoutf(@"unknown command: %s", c);
} else { } else {
switch (ID.type) { switch (ID.type) {
// game defined commands // game defined commands
@ -395,14 +395,15 @@ execute(char *p, bool isdown) // all evaluation happens here, recursively
// var with no value // var with no value
// just prints its // just prints its
// current value // current value
conoutf("%s = %d", c, conoutf(@"%s = %d", c,
*ID.storage); *ID.storage);
else { else {
if (ID.min > ID.max) { if (ID.min > ID.max) {
conoutf("variab" conoutf(
"le is " @"variable "
"read-" @"is "
"only"); @"read-"
@"only");
} else { } else {
int i1 = int i1 =
ATOI(w[1]); ATOI(w[1]);
@ -419,21 +420,34 @@ execute(char *p, bool isdown) // all evaluation happens here, recursively
? ID.min ? ID.min
: ID.max; : ID.max;
conoutf( conoutf(
"va" @"v"
"li" @"a"
"d " @"l"
"ra" @"i"
"ng" @"d"
"e " @" "
"fo" @"r"
"r " @"a"
"%s" @"n"
" i" @"g"
"s " @"e"
"%d" @" "
".." @"f"
"%" @"o"
"d", @"r"
@" "
@"%"
@"s"
@" "
@"i"
@"s"
@" "
@"%"
@"d"
@"."
@"."
@"%"
@"d",
c, c,
ID.min, ID.min,
ID.max); ID.max);
@ -533,7 +547,7 @@ void
exec(char *cfgfile) exec(char *cfgfile)
{ {
if (!execfile(cfgfile)) if (!execfile(cfgfile))
conoutf("could not read \"%s\"", cfgfile); conoutf(@"could not read \"%s\"", cfgfile);
} }
void void

View file

@ -50,10 +50,10 @@ conline(const char *sf, bool highlight) // add a line to the console buffer
}; };
void void
conoutf(const char *s, ...) conoutf(OFString *str, ...)
{ {
sprintf_sdv(sf, s); sprintf_sdv(sf, str.UTF8String);
s = sf; const char *s = sf;
int n = 0; int n = 0;
while (strlen(s) > WORDWRAP) // cut strings to fit on screen while (strlen(s) > WORDWRAP) // cut strings to fit on screen
{ {
@ -61,7 +61,7 @@ conoutf(const char *s, ...)
strn0cpy(t, s, WORDWRAP + 1); strn0cpy(t, s, WORDWRAP + 1);
conline(t, n++ != 0); conline(t, n++ != 0);
s += WORDWRAP; s += WORDWRAP;
}; }
conline(s, n != 0); conline(s, n != 0);
}; };
@ -114,7 +114,7 @@ bindkey(char *key, char *action)
strcpy_s(keyms[i].action, action); strcpy_s(keyms[i].action, action);
return; return;
}; };
conoutf("unknown key \"%s\"", key); conoutf(@"unknown key \"%s\"", key);
}; };
COMMANDN(bind, bindkey, ARG_2STR); COMMANDN(bind, bindkey, ARG_2STR);

View file

@ -87,7 +87,7 @@ noteditmode()
{ {
correctsel(); correctsel();
if (!editmode) if (!editmode)
conoutf("this function is only allowed in edit mode"); conoutf(@"this function is only allowed in edit mode");
return !editmode; return !editmode;
}; };
@ -95,7 +95,7 @@ bool
noselection() noselection()
{ {
if (!selset) if (!selset)
conoutf("no selection"); conoutf(@"no selection");
return !selset; return !selset;
}; };
@ -258,7 +258,7 @@ editundo()
{ {
EDITMP; EDITMP;
if (undos.empty()) { if (undos.empty()) {
conoutf("nothing more to undo"); conoutf(@"nothing more to undo");
return; return;
}; };
block *p = undos.pop(); block *p = undos.pop();
@ -282,14 +282,14 @@ paste()
{ {
EDITMP; EDITMP;
if (!copybuf) { if (!copybuf) {
conoutf("nothing to paste"); conoutf(@"nothing to paste");
return; return;
}; };
sel.xs = copybuf->xs; sel.xs = copybuf->xs;
sel.ys = copybuf->ys; sel.ys = copybuf->ys;
correctsel(); correctsel();
if (!selset || sel.xs != copybuf->xs || sel.ys != copybuf->ys) { if (!selset || sel.xs != copybuf->xs || sel.ys != copybuf->ys) {
conoutf("incorrect selection"); conoutf(@"incorrect selection");
return; return;
}; };
makeundo(); makeundo();
@ -440,7 +440,7 @@ edittype(int type)
if (type == CORNER && if (type == CORNER &&
(sel.xs != sel.ys || sel.xs == 3 || sel.xs > 4 && sel.xs != 8 || (sel.xs != sel.ys || sel.xs == 3 || sel.xs > 4 && sel.xs != 8 ||
sel.x & ~-sel.xs || sel.y & ~-sel.ys)) { 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; return;
}; };
edittypexy(type, sel); edittypexy(type, sel);

View file

@ -184,10 +184,10 @@ realpickup(int n, dynent *d)
case I_QUAD: case I_QUAD:
radditem(n, d->quadmillis); radditem(n, d->quadmillis);
conoutf("you got the quad!"); conoutf(@"you got the quad!");
break; break;
}; }
}; }
// these functions are called when the client touches the item // these functions are called when the client touches the item
@ -201,8 +201,8 @@ additem(int i, int &v, int spawnsec)
m_classicsp ? 100000 m_classicsp ? 100000
: spawnsec); // first ask the server for an ack : spawnsec); // first ask the server for an ack
ents[i].spawned = false; // even if someone else gets it first ents[i].spawned = false; // even if someone else gets it first
}; }
}; }
void void
teleport(int n, dynent *d) // also used by monsters teleport(int n, dynent *d) // also used by monsters
@ -211,7 +211,7 @@ teleport(int n, dynent *d) // also used by monsters
for (;;) { for (;;) {
e = findentity(TELEDEST, e + 1); e = findentity(TELEDEST, e + 1);
if (e == beenhere || e < 0) { if (e == beenhere || e < 0) {
conoutf("no teleport destination for tag %d", tag); conoutf(@"no teleport destination for tag %d", tag);
return; return;
}; };
if (beenhere < 0) if (beenhere < 0)
@ -332,9 +332,9 @@ checkquad(int time)
if (player1->quadmillis && (player1->quadmillis -= time) < 0) { if (player1->quadmillis && (player1->quadmillis -= time) < 0) {
player1->quadmillis = 0; player1->quadmillis = 0;
playsoundc(S_PUPOUT); playsoundc(S_PUPOUT);
conoutf("quad damage is over"); conoutf(@"quad damage is over");
}; }
}; }
void void
putitems(uchar *&p) // puts items in network stream and also spawns them locally putitems(uchar *&p) // puts items in network stream and also spawns them locally
@ -344,8 +344,8 @@ putitems(uchar *&p) // puts items in network stream and also spawns them locally
{ {
putint(p, i); putint(p, i);
ents[i].spawned = true; ents[i].spawned = true;
}; }
}; }
void void
resetspawns() resetspawns()

View file

@ -106,7 +106,7 @@ main(int argc, char **argv)
processInitQueue(); processInitQueue();
#define log(s) conoutf("init: %s", s) #define log(s) conoutf(@"init: %s", s)
log("sdl"); log("sdl");
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
@ -144,10 +144,10 @@ main(int argc, char **argv)
maxcl = atoi(a); maxcl = atoi(a);
break; break;
default: default:
conoutf("unknown commandline option"); conoutf(@"unknown commandline option");
} }
else else
conoutf("unknown commandline argument"); conoutf(@"unknown commandline argument");
}; };
#ifdef _DEBUG #ifdef _DEBUG

View file

@ -5,7 +5,7 @@
dvector monsters; dvector monsters;
int nextmonster, spawnremain, numkilled, monstertotal, mtimestart; 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 & dvector &
getmonsters() getmonsters()
@ -52,7 +52,7 @@ dynent *
basicmonster(int type, int yaw, int state, int trigger, int move) basicmonster(int type, int yaw, int state, int trigger, int move)
{ {
if (type >= NUMMONSTERTYPES) { if (type >= NUMMONSTERTYPES) {
conoutf("warning: unknown monster in spawn: %d", type); conoutf(@"warning: unknown monster in spawn: %d", type);
type = 0; type = 0;
}; };
dynent *m = newdynent(); dynent *m = newdynent();
@ -340,7 +340,7 @@ monsterpain(dynent *m, int damage, dynent *d)
playsound(monstertypes[m->mtype].diesound, &m->o); playsound(monstertypes[m->mtype].diesound, &m->o);
int remain = monstertotal - numkilled; int remain = monstertotal - numkilled;
if (remain > 0 && remain <= 5) if (remain > 0 && remain <= 5)
conoutf("only %d monster(s) remaining", remain); conoutf(@"only %d monster(s) remaining", remain);
} else { } else {
playsound(monstertypes[m->mtype].painsound, &m->o); playsound(monstertypes[m->mtype].painsound, &m->o);
}; };
@ -349,9 +349,9 @@ monsterpain(dynent *m, int damage, dynent *d)
void void
endsp(bool allkilled) endsp(bool allkilled)
{ {
conoutf( conoutf(allkilled ? @"you have cleared the map!"
allkilled ? "you have cleared the map!" : "you reached the exit!"); : @"you reached the exit!");
conoutf("score: %d kills in %d seconds", numkilled, conoutf(@"score: %d kills in %d seconds", numkilled,
(lastmillis - mtimestart) / 1000); (lastmillis - mtimestart) / 1000);
monstertotal = 0; monstertotal = 0;
startintermission(); startintermission();
@ -362,7 +362,7 @@ monsterthink()
{ {
if (m_dmsp && spawnremain && lastmillis > nextmonster) { if (m_dmsp && spawnremain && lastmillis > nextmonster) {
if (spawnremain-- == monstertotal) if (spawnremain-- == monstertotal)
conoutf("The invasion has begun!"); conoutf(@"The invasion has begun!");
nextmonster = lastmillis + 1000; nextmonster = lastmillis + 1000;
spawnmonster(); spawnmonster();
}; };

View file

@ -19,7 +19,7 @@ extern void writecfg();
// console // console
extern void keypress(int code, bool isdown, int cooked); extern void keypress(int code, bool isdown, int cooked);
extern void renderconsole(); extern void renderconsole();
extern void conoutf(const char *s, ...); extern void conoutf(OFString *s, ...);
extern char *getcurcommand(); extern char *getcurcommand();
extern void writebinds(FILE *f); extern void writebinds(FILE *f);

View file

@ -71,7 +71,7 @@ void
mipstats(int a, int b, int c) mipstats(int a, int b, int c)
{ {
if (showm) 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); COMMAND(showmip, ARG_NONE);

View file

@ -210,7 +210,7 @@ loadsky(char *basename)
sprintf_sd(name)("packages/%s_%s.jpg", basename, side[i]); sprintf_sd(name)("packages/%s_%s.jpg", basename, side[i]);
int xs, ys; int xs, ys;
if (!installtex(texnum + i, path(name), xs, ys, true)) 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); strcpy_s(lastsky, basename);
}; };

View file

@ -48,8 +48,8 @@ gl_init(int w, int h)
if (strstr(exts, "GL_EXT_texture_env_combine")) if (strstr(exts, "GL_EXT_texture_env_combine"))
hasoverbright = true; hasoverbright = true;
else else
conoutf("WARNING: cannot use overbright lighting, using old " conoutf(@"WARNING: cannot use overbright lighting, using old "
"lighting model!"); @"lighting model!");
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize);
@ -77,11 +77,11 @@ installtex(int tnum, char *texname, int &xs, int &ys, bool clamp)
{ {
SDL_Surface *s = IMG_Load(texname); SDL_Surface *s = IMG_Load(texname);
if (!s) { if (!s) {
conoutf("couldn't load texture %s", texname); conoutf(@"couldn't load texture %s", texname);
return false; return false;
}; };
if (s->format->BitsPerPixel != 24) { if (s->format->BitsPerPixel != 24) {
conoutf("texture must be 24bpp: %s", texname); conoutf(@"texture must be 24bpp: %s", texname);
return false; return false;
}; };
// loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = 255-*p; }; // loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = 255-*p; };
@ -103,7 +103,7 @@ installtex(int tnum, char *texname, int &xs, int &ys, bool clamp)
}; };
void *scaledimg = s->pixels; void *scaledimg = s->pixels;
if (xs != s->w) { if (xs != s->w) {
conoutf("warning: quality loss: scaling %s", conoutf(@"warning: quality loss: scaling %s",
texname); // for voodoo cards under linux texname); // for voodoo cards under linux
scaledimg = alloc(xs * ys * 3); scaledimg = alloc(xs * ys * 3);
gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels, gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels,
@ -274,8 +274,8 @@ VARFP(gamma, 30, 100, 300, {
float f = gamma / 100.0f; float f = gamma / 100.0f;
if (SDL_SetGamma(f, f, f) == -1) { if (SDL_SetGamma(f, f, f) == -1) {
conoutf( conoutf(
"Could not set gamma (card/driver doesn't support it?)"); @"Could not set gamma (card/driver doesn't support it?)");
conoutf("sdl: %s", SDL_GetError()); conoutf(@"sdl: %s", SDL_GetError());
}; };
}); });

View file

@ -84,7 +84,7 @@ savestate(char *fn)
stop(); stop();
f = gzopen(fn, "wb9"); f = gzopen(fn, "wb9");
if (!f) { if (!f) {
conoutf("could not write %s", fn); conoutf(@"could not write %s", fn);
return; return;
}; };
gzwrite(f, (void *)"CUBESAVE", 8); gzwrite(f, (void *)"CUBESAVE", 8);
@ -104,21 +104,21 @@ savestate(char *fn)
{ {
gzput(players[i] == NULL); gzput(players[i] == NULL);
gzwrite(f, players[i], sizeof(dynent)); gzwrite(f, players[i], sizeof(dynent));
}; }
}; }
void void
savegame(char *name) savegame(char *name)
{ {
if (!m_classicsp) { if (!m_classicsp) {
conoutf("can only save classic sp games"); conoutf(@"can only save classic sp games");
return; return;
}; }
sprintf_sd(fn)("savegames/%s.csgz", name); sprintf_sd(fn)("savegames/%s.csgz", name);
savestate(fn); savestate(fn);
stop(); stop();
conoutf("wrote %s", fn); conoutf(@"wrote %s", fn);
}; }
void void
loadstate(char *fn) loadstate(char *fn)
@ -128,9 +128,9 @@ loadstate(char *fn)
return; return;
f = gzopen(fn, "rb9"); f = gzopen(fn, "rb9");
if (!f) { if (!f) {
conoutf("could not open %s", fn); conoutf(@"could not open %s", fn);
return; return;
}; }
string buf; string buf;
gzread(f, buf, 8); gzread(f, buf, 8);
@ -148,24 +148,24 @@ loadstate(char *fn)
// client & server have updated // client & server have updated
return; return;
out: out:
conoutf("aborting: savegame/demo from a different version of cube or " conoutf(@"aborting: savegame/demo from a different version of cube or "
"cpu architecture"); @"cpu architecture");
stop(); stop();
}; }
void void
loadgame(char *name) loadgame(char *name)
{ {
sprintf_sd(fn)("savegames/%s.csgz", name); sprintf_sd(fn)("savegames/%s.csgz", name);
loadstate(fn); loadstate(fn);
}; }
void void
loadgameout() loadgameout()
{ {
stop(); stop();
conoutf("loadgame incomplete: savegame from a different version of " conoutf(@"loadgame incomplete: savegame from a different version of "
"this map"); @"this map");
}; };
void void
@ -212,7 +212,7 @@ loadgamerest()
gzread(f, d, sizeof(dynent)); gzread(f, d, sizeof(dynent));
}; };
conoutf("savegame restored"); conoutf(@"savegame restored");
if (demoloading) if (demoloading)
startdemo(); startdemo();
else else
@ -230,7 +230,7 @@ void
record(char *name) record(char *name)
{ {
if (m_sp) { if (m_sp) {
conoutf("cannot record singleplayer games"); conoutf(@"cannot record singleplayer games");
return; return;
}; };
int cn = getclientnum(); int cn = getclientnum();
@ -239,7 +239,7 @@ record(char *name)
sprintf_sd(fn)("demos/%s.cdgz", name); sprintf_sd(fn)("demos/%s.cdgz", name);
savestate(fn); savestate(fn);
gzputi(cn); gzputi(cn);
conoutf("started recording demo to %s", fn); conoutf(@"started recording demo to %s", fn);
demorecording = true; demorecording = true;
starttime = lastmillis; starttime = lastmillis;
ddamage = bdamage = 0; ddamage = bdamage = 0;
@ -282,11 +282,11 @@ incomingdemodata(uchar *buf, int len, bool extras)
if (ddamage) { if (ddamage) {
gzputv(dorig); gzputv(dorig);
ddamage = 0; ddamage = 0;
}; }
// FIXME: add all other client state which is not send through // FIXME: add all other client state which is not send through
// the network // the network
}; }
}; }
void void
demo(char *name) demo(char *name)
@ -294,23 +294,23 @@ demo(char *name)
sprintf_sd(fn)("demos/%s.cdgz", name); sprintf_sd(fn)("demos/%s.cdgz", name);
loadstate(fn); loadstate(fn);
demoloading = true; demoloading = true;
}; }
void void
stopreset() stopreset()
{ {
conoutf("demo stopped (%d msec elapsed)", lastmillis - starttime); conoutf(@"demo stopped (%d msec elapsed)", lastmillis - starttime);
stop(); stop();
loopv(players) zapdynent(players[i]); loopv(players) zapdynent(players[i]);
disconnect(0, 0); disconnect(0, 0);
}; }
VAR(demoplaybackspeed, 10, 100, 1000); VAR(demoplaybackspeed, 10, 100, 1000);
int int
scaletime(int t) scaletime(int t)
{ {
return (int)(t * (100.0f / demoplaybackspeed)) + starttime; return (int)(t * (100.0f / demoplaybackspeed)) + starttime;
}; }
void void
readdemotime() readdemotime()
@ -318,9 +318,9 @@ readdemotime()
if (gzeof(f) || (playbacktime = gzgeti()) == -1) { if (gzeof(f) || (playbacktime = gzgeti()) == -1) {
stopreset(); stopreset();
return; return;
}; }
playbacktime = scaletime(playbacktime); playbacktime = scaletime(playbacktime);
}; }
void void
startdemo() startdemo()
@ -328,12 +328,12 @@ startdemo()
democlientnum = gzgeti(); democlientnum = gzgeti();
demoplayback = true; demoplayback = true;
starttime = lastmillis; starttime = lastmillis;
conoutf("now playing demo"); conoutf(@"now playing demo");
dynent *d = getclient(democlientnum); dynent *d = getclient(democlientnum);
assert(d); assert(d);
*d = *player1; *d = *player1;
readdemotime(); readdemotime();
}; }
VAR(demodelaymsec, 0, 120, 500); VAR(demodelaymsec, 0, 120, 500);
@ -378,7 +378,7 @@ demoplaybackstep()
int len = gzgeti(); int len = gzgeti();
if (len < 1 || len > MAXTRANS) { if (len < 1 || len > MAXTRANS) {
conoutf( conoutf(
"error: huge packet during demo play (%d)", len); @"error: huge packet during demo play (%d)", len);
stopreset(); stopreset();
return; return;
}; };
@ -483,7 +483,7 @@ stopn()
stopreset(); stopreset();
else else
stop(); stop();
conoutf("demo stopped"); conoutf(@"demo stopped");
}; };
COMMAND(record, ARG_1STR); COMMAND(record, ARG_1STR);

View file

@ -306,7 +306,7 @@ updatefrommaster()
uchar *reply = retrieveservers(buf, MAXUPD); uchar *reply = retrieveservers(buf, MAXUPD);
if (!*reply || strstr((char *)reply, "<html>") || if (!*reply || strstr((char *)reply, "<html>") ||
strstr((char *)reply, "<HTML>")) strstr((char *)reply, "<HTML>"))
conoutf("master server not replying"); conoutf(@"master server not replying");
else { else {
servers.setsize(0); servers.setsize(0);
execute((char *)reply); execute((char *)reply);

View file

@ -63,7 +63,7 @@ initsound()
#ifdef USE_MIXER #ifdef USE_MIXER
if (Mix_OpenAudio(SOUNDFREQ, MIX_DEFAULT_FORMAT, 2, soundbufferlen) < if (Mix_OpenAudio(SOUNDFREQ, MIX_DEFAULT_FORMAT, 2, soundbufferlen) <
0) { 0) {
conoutf("sound init failed (SDL_mixer): %s", conoutf(@"sound init failed (SDL_mixer): %s",
(size_t)Mix_GetError()); (size_t)Mix_GetError());
nosound = true; nosound = true;
}; };
@ -72,7 +72,7 @@ initsound()
if (FSOUND_GetVersion() < FMOD_VERSION) if (FSOUND_GetVersion() < FMOD_VERSION)
fatal("old FMOD dll"); fatal("old FMOD dll");
if (!FSOUND_Init(SOUNDFREQ, MAXCHAN, FSOUND_INIT_GLOBALFOCUS)) { 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; nosound = true;
}; };
#endif #endif
@ -106,7 +106,7 @@ music(char *name)
FSOUND_SetPaused(chan, false); FSOUND_SetPaused(chan, false);
}; };
} else { } else {
conoutf("could not play music: %s", sn); conoutf(@"could not play music: %s", sn);
}; };
#endif #endif
}; };
@ -228,7 +228,7 @@ playsound(int n, vec *loc)
return; // avoid bursts of sounds with heavy packetloss and in return; // avoid bursts of sounds with heavy packetloss and in
// sp // sp
if (n < 0 || n >= samples.length()) { if (n < 0 || n >= samples.length()) {
conoutf("unregistered sound: %d", n); conoutf(@"unregistered sound: %d", n);
return; return;
}; };
@ -243,7 +243,7 @@ playsound(int n, vec *loc)
#endif #endif
if (!samples[n]) { if (!samples[n]) {
conoutf("failed to load sample: %s", buf); conoutf(@"failed to load sample: %s", buf);
return; return;
}; };
}; };

View file

@ -50,7 +50,7 @@ selectgun(int a, int b, int c)
if (s != player1->gunselect) if (s != player1->gunselect)
playsoundc(S_WEAPLOAD); playsoundc(S_WEAPLOAD);
player1->gunselect = s; player1->gunselect = s;
// conoutf("%s selected", (int)guns[s].name); // conoutf(@"%s selected", (int)guns[s].name);
}; };
int int

View file

@ -293,11 +293,11 @@ delent()
{ {
int e = closestent(); int e = closestent();
if (e < 0) { if (e < 0) {
conoutf("no more entities"); conoutf(@"no more entities");
return; return;
}; };
int t = ents[e].type; int t = ents[e].type;
conoutf("%s entity deleted", entnames[t]); conoutf(@"%s entity deleted", entnames[t]);
ents[e].type = NOTUSED; ents[e].type = NOTUSED;
addmsg(1, 10, SV_EDITENT, e, NOTUSED, 0, 0, 0, 0, 0, 0, 0); addmsg(1, 10, SV_EDITENT, e, NOTUSED, 0, 0, 0, 0, 0, 0, 0);
if (t == LIGHT) if (t == LIGHT)
@ -308,7 +308,7 @@ int
findtype(char *what) findtype(char *what)
{ {
loopi(MAXENTTYPES) if (strcmp(what, entnames[i]) == 0) return i; loopi(MAXENTTYPES) if (strcmp(what, entnames[i]) == 0) return i;
conoutf("unknown entity type \"%s\"", what); conoutf(@"unknown entity type \"%s\"", what);
return NOTUSED; return NOTUSED;
} }

View file

@ -128,12 +128,12 @@ writemap(char *mname, int msize, uchar *mdata)
backup(cgzname, bakname); backup(cgzname, bakname);
FILE *f = fopen(cgzname, "wb"); FILE *f = fopen(cgzname, "wb");
if (!f) { if (!f) {
conoutf("could not write map to %s", cgzname); conoutf(@"could not write map to %s", cgzname);
return; return;
}; };
fwrite(mdata, 1, msize, f); fwrite(mdata, 1, msize, f);
fclose(f); fclose(f);
conoutf("wrote map %s as file %s", mname, cgzname); conoutf(@"wrote map %s as file %s", mname, cgzname);
} }
uchar * uchar *
@ -142,7 +142,7 @@ readmap(char *mname, int *msize)
setnames(mname); setnames(mname);
uchar *mdata = (uchar *)loadfile(cgzname, msize); uchar *mdata = (uchar *)loadfile(cgzname, msize);
if (!mdata) { if (!mdata) {
conoutf("could not read map %s", cgzname); conoutf(@"could not read map %s", cgzname);
return NULL; return NULL;
}; };
return mdata; return mdata;
@ -165,7 +165,7 @@ save_world(char *mname)
backup(cgzname, bakname); backup(cgzname, bakname);
gzFile f = gzopen(cgzname, "wb9"); gzFile f = gzopen(cgzname, "wb9");
if (!f) { if (!f) {
conoutf("could not write map to %s", cgzname); conoutf(@"could not write map to %s", cgzname);
return; return;
}; };
hdr.version = MAPVERSION; hdr.version = MAPVERSION;
@ -237,7 +237,7 @@ save_world(char *mname)
}; };
spurge; spurge;
gzclose(f); gzclose(f);
conoutf("wrote map file %s", cgzname); conoutf(@"wrote map file %s", cgzname);
settagareas(); settagareas();
}; };
@ -251,7 +251,7 @@ load_world(char *mname) // still supports all map formats that have existed
setnames(mname); setnames(mname);
gzFile f = gzopen(cgzname, "rb9"); gzFile f = gzopen(cgzname, "rb9");
if (!f) { if (!f) {
conoutf("could not read map %s", cgzname); conoutf(@"could not read map %s", cgzname);
return; return;
}; };
gzread(f, &hdr, sizeof(header) - sizeof(int) * 16); gzread(f, &hdr, sizeof(header) - sizeof(int) * 16);
@ -357,9 +357,9 @@ load_world(char *mname) // still supports all map formats that have existed
settagareas(); settagareas();
int xs, ys; int xs, ys;
loopi(256) if (texuse) lookuptexture(i, 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); SDL_GetTicks() - lastmillis);
conoutf("%s", hdr.maptitle); conoutf(@"%s", hdr.maptitle);
startmap(mname); startmap(mname);
loopl(256) loopl(256)
{ {