From 397c441fed4282b1b7f3150a031c15bcaec8efe5 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Fri, 16 Sep 2016 17:35:47 +0200 Subject: [PATCH] more verbose error messages for disabled commands --- source/src/audiomanager.cpp | 9 ++++-- source/src/client.cpp | 8 +++--- source/src/clientgame.cpp | 18 ++++++------ source/src/command.cpp | 2 +- source/src/editing.cpp | 52 ++++++++++++++++------------------ source/src/entities.cpp | 2 +- source/src/main.cpp | 2 +- source/src/physics.cpp | 2 +- source/src/protos.h | 5 +++- source/src/renderhud.cpp | 4 +-- source/src/rendermodel.cpp | 9 ++++-- source/src/renderparticles.cpp | 2 +- source/src/scoreboard.cpp | 16 +++++------ source/src/texture.cpp | 9 ++++-- source/src/weapon.cpp | 2 +- source/src/world.cpp | 13 +++++---- source/src/worldio.cpp | 9 ++---- 17 files changed, 86 insertions(+), 78 deletions(-) diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp index 419f10ea..e34c2590 100644 --- a/source/src/audiomanager.cpp +++ b/source/src/audiomanager.cpp @@ -878,7 +878,8 @@ void reloadmapsoundconfig() void deletemapsoundslot(int *n, char *opt) // delete mapsound slot - only if unused or "purge" is specified { - if(noteditmode("deletemapsoundslot") || multiplayer(true) || !mapconfigdata.mapsoundlines.inrange(*n)) return; + EDITMP("deletemapsoundslot"); + if(!mapconfigdata.mapsoundlines.inrange(*n)) return; bool purgeall = !strcmp(opt, "purge"), slotused = false; loopv(ents) if(ents[i].type == SOUND && ents[i].attr1 == *n) slotused = true; if(!purgeall && slotused) { conoutf("mapsound slot #%d is in use: can't delete", *n); return; } @@ -909,8 +910,9 @@ COMMAND(deletemapsoundslot, "is"); void editmapsoundslot(int *n, char *name, char *maxuses) // edit slot parameters != "" { + EDITMP("editmapsoundslot"); string res = ""; - if(!noteditmode("editmapsoundslot") && !multiplayer(true) && mapconfigdata.mapsoundlines.inrange(*n)) + if(mapconfigdata.mapsoundlines.inrange(*n)) { mapsoundline &msl = mapconfigdata.mapsoundlines[*n]; if(*name || *maxuses) @@ -1011,7 +1013,8 @@ void sortmapsoundslots(char **args, int numargs) else { conoutf("sortmapsoundslots: unknown argument \"%s\"", args[i]); unknownarg = true; } } - if(noteditmode("sortmapsoundslots") || multiplayer(true) || unknownarg || mapconfigdata.mapsoundlines.length() < 3) return; + EDITMP("sortmapsoundslots"); + if(unknownarg || mapconfigdata.mapsoundlines.length() < 3) return; vector tempslots; loopv(mapconfigdata.mapsoundlines) diff --git a/source/src/client.cpp b/source/src/client.cpp index 44cf3ca8..ab4416d0 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -14,10 +14,10 @@ extern int searchlan; int getclientnum() { return player1 ? player1->clientnum : -1; } -bool multiplayer(bool msg) +bool multiplayer(const char *op) { // check not correct on listen server? - if(curpeer && msg) conoutf("operation not available in multiplayer"); + if(curpeer && op) conoutf("%s%s%s not available in multiplayer", *op ? "\"" : "", *op ? op : "operation", *op ? "\"" : ""); return curpeer!=NULL; } @@ -809,7 +809,7 @@ void deleteservermap(char *mapname) string demosubpath; void getdemo(int *idx, char *dsp) { - if(!multiplayer(false)) + if(!multiplayer(NULL)) { conoutf("\f3Getting demo from server is not available in singleplayer"); return; @@ -823,7 +823,7 @@ void getdemo(int *idx, char *dsp) void listdemos() { - if(!multiplayer(false)) + if(!multiplayer(NULL)) { conoutf("\f3Listing demos from server is not available in singleplayer"); return; diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index a496572c..10db784f 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -250,7 +250,7 @@ void playerinfo(int *cn, const char *attr) playerent *p = clientnum < 0 ? player1 : getclient(clientnum); if(!p) { - if(!m_botmode && multiplayer(false)) // bot clientnums are still glitchy, causing this message to sometimes appear in offline/singleplayer when it shouldn't??? -Bukz 2012may + if(!m_botmode && multiplayer(NULL)) // bot clientnums are still glitchy, causing this message to sometimes appear in offline/singleplayer when it shouldn't??? -Bukz 2012may conoutf("invalid clientnum cn: %d attr: %s", clientnum, attr); return; } @@ -757,7 +757,7 @@ inline const char * spawn_message() else return "3You must be on the correct map to spawn. Type /getmap to download it."; } else if (m_coop) return "3Type /getmap or send a map and vote for it to start co-op edit."; - else if (multiplayer(false)) return "4Awaiting permission to spawn. \f2DON'T PANIC!"; + else if (multiplayer(NULL)) return "4Awaiting permission to spawn. \f2DON'T PANIC!"; else return ""; // theres no waiting for permission in sp // Despite its many glaring (and occasionally fatal) inaccuracies, AssaultCube itself has outsold the // Encyclopedia Galactica because it is slightly cheaper, and because it has the words "Don't Panic" @@ -768,7 +768,7 @@ int waiting_permission = 0; bool tryrespawn() { - if ( m_mp(gamemode) && multiplayer(false) && bad_map() ) + if(m_mp(gamemode) && multiplayer(NULL) && bad_map()) { hudoutf("This map is not supported in multiplayer. Read the docs about map quality/dimensions."); } @@ -1157,7 +1157,7 @@ void startmap(const char *name, bool reset, bool norespawn) // called just aft bool noflags = (m_ctf || m_ktf) && !clentstats.hasflags; if(*clientmap) conoutf("game mode is \"%s\"%s", modestr(gamemode, modeacronyms > 0), noflags ? " - \f2but there are no flag bases on this map" : ""); - if(showmodedescriptions && (multiplayer(false) || m_botmode)) + if(showmodedescriptions && (multiplayer(NULL) || m_botmode)) { loopv(gmdescs) if(gmdescs[i].mode == gamemode) conoutf("\f1%s", gmdescs[i].desc); } @@ -1428,9 +1428,9 @@ void scallvote(int *type, const char *arg1, const char *arg2) case SA_KICK: case SA_BAN: { - if (!arg1 || !isdigit(arg1[0]) || !arg2 || strlen(arg2) <= 3 || !multiplayer(false)) + if (!arg1 || !isdigit(arg1[0]) || !arg2 || strlen(arg2) <= 3 || !multiplayer(NULL)) { - if(!multiplayer(false)) + if(!multiplayer(NULL)) conoutf("\f3%s is not available in singleplayer.", t == SA_BAN ? "Ban" : "Kick"); else if(arg1 && !isdigit(arg1[0])) conoutf("\f3invalid vote"); else conoutf("\f3invalid reason"); @@ -1499,7 +1499,7 @@ void voteresult(int v) curvote->result = v; curvote->millis = totalmillis + 5000; conoutf("vote %s", v == VOTE_YES ? "passed" : "failed"); - if(multiplayer(false)) audiomgr.playsound(v == VOTE_YES ? S_VOTEPASS : S_VOTEFAIL, SP_HIGH); + if(multiplayer(NULL)) audiomgr.playsound(v == VOTE_YES ? S_VOTEPASS : S_VOTEFAIL, SP_HIGH); exechook(HOOK_SP_MP, "onVoteEnd", ""); votepending = 0; } @@ -1515,7 +1515,7 @@ const char *modestrings[] = void setnext(char *mode, char *map) { - if(!multiplayer(false)) { //RR 10/12/12 - Is this the action we want? + if(!multiplayer(NULL)) { //RR 10/12/12 - Is this the action we want? conoutf("You cannot use setnext in singleplayer."); return; } @@ -1546,7 +1546,7 @@ COMMAND(setnext, "ss"); void gonext(int *arg1) { - if(calledvote || !multiplayer(false)) return; + if(calledvote || !multiplayer(NULL)) return; packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_CALLVOTE); putint(p, SA_MAP); diff --git a/source/src/command.cpp b/source/src/command.cpp index 17df3573..5a53f6ba 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -770,7 +770,7 @@ int execute(const char *p) #ifndef STANDALONE bool exechook(int context, const char *ident, const char *body,...) // execute cubescript hook if available and allowed in current context/gamemode { // always use one of HOOK_SP_MP, HOOK_SP or HOOK_MP and then OR them (as needed) with HOOK_TEAM, HOOK_NOTEAM, HOOK_BOTMODE, HOOK_FLAGMODE, HOOK_ARENA - if(multiplayer(false) && (context & HOOK_FLAGMASK) != HOOK_MP && (context & HOOK_FLAGMASK) != HOOK_SP_MP) return false; // hook is singleplayer-only + if(multiplayer(NULL) && (context & HOOK_FLAGMASK) != HOOK_MP && (context & HOOK_FLAGMASK) != HOOK_SP_MP) return false; // hook is singleplayer-only if(((context & HOOK_TEAM) && !m_teammode) || ((context & HOOK_NOTEAM) && m_teammode) || ((context & HOOK_BOTMODE) && !m_botmode) || diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 0f4ec3e0..439b17b1 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -132,10 +132,6 @@ char *editinfo() } -#define EDITSEL if(noteditmode("EDITSEL") || noselection()) return -#define EDITSELMP if(noteditmode("EDITSELMP") || noselection() || multiplayer()) return -#define EDITMP if(noteditmode("EDITMP") || multiplayer()) return - // multiple sels // add a selection to the list @@ -427,7 +423,7 @@ COMMAND(gotoposition, "sssss"); void editundo() { - EDITMP; + EDITMP("undo"); if(undos.empty()) { conoutf("nothing more to undo"); return; } block *p = undos.pop(); undolevel--; @@ -443,7 +439,7 @@ void gotoundolevel(char *lev) { if(*lev && isdigit(*lev)) { - EDITMP; + EDITMP("undolevel"); int n = ATOI(lev); while(undolevel > n && undos.length() > 0) editundo(); } @@ -453,7 +449,7 @@ COMMANDN(undolevel, gotoundolevel, "s"); void editredo() { - EDITMP; + EDITMP("redo"); if(redos.empty()) { conoutf("nothing more to redo"); return; } block *p = redos.pop(); undos.add(blockcopy(*p)); @@ -565,7 +561,7 @@ void resetcopybuffers() void copy() { - EDITSELMP; + EDITSELMP("copy"); resetcopybuffers(); copytexconfig = texconfig_copy(); @@ -580,7 +576,7 @@ COMMAND(copy, ""); void paste() { - EDITSELMP; + EDITSELMP("paste"); if(!copybuffers.length()) { conoutf("nothing to paste"); return; } uchar usedslots[256] = { 0 }, *texmap = NULL; @@ -684,7 +680,7 @@ void editheightxy(bool isfloor, int amount, block &sel) void editheight(int *flr, int *amount) { - EDITSEL; + EDITSEL("editheight"); bool isfloor = *flr==0; loopv(sels) { @@ -754,7 +750,7 @@ void edittexxy(int type, int t, block &sel) void edittex(int *type, int *dir) { - EDITSEL; + EDITSEL("edittex"); if(*type < 0 || *type > 3) return; if(*type != lasttype) { tofronttex(); lasttype = *type; } int atype = *type == 3 ? 1 : *type; @@ -774,7 +770,7 @@ COMMAND(edittex, "ii"); void settex(int *texture, int *type) { - EDITSEL; + EDITSEL("settex"); if(*type < 0 || *type > 3) return; int atype = *type == 3 ? 1 : *type; int t = -1; @@ -799,7 +795,7 @@ COMMAND(settex, "ii"); void replace() { - EDITSELMP; + EDITSELMP("replace"); loop(x,ssize) loop(y,ssize) { sqr *s = S(x, y); @@ -824,7 +820,7 @@ void edittypexy(int type, block &sel) void edittype(int type) { - EDITSEL; + EDITSEL("solid|corner|heightfield"); loopv(sels) { block &sel = sels[i]; @@ -864,7 +860,7 @@ void editequalisexy(bool isfloor, block &sel) void equalize(int *flr) { bool isfloor = *flr==0; - EDITSEL; + EDITSEL("equalize"); loopv(sels) { block &sel = sels[i]; @@ -882,7 +878,7 @@ void setvdeltaxy(int delta, block &sel) void setvdelta(int *delta) { - EDITSEL; + EDITSEL("vdelta"); loopv(sels) { setvdeltaxy(*delta, sels[i]); @@ -918,7 +914,7 @@ void archxy(int sidedelta, int *averts, block &sel) void arch(int *sidedelta) { - EDITSEL; + EDITSEL("arch"); loopv(sels) { block &sel = sels[i]; @@ -946,7 +942,7 @@ void slopexy(int xd, int yd, block &sel) void slope(int *xd, int *yd) { - EDITSEL; + EDITSEL("slope"); loopv(sels) { block &sel = sels[i]; @@ -965,7 +961,7 @@ void stairsxy(int xd, int yd, block &sel) void stairs(int *xd, int *yd) { - EDITSEL; + EDITSEL("stairs"); loopv(sels) { block &sel = sels[i]; @@ -977,7 +973,7 @@ COMMAND(stairs, "ii"); void perlin(int *scale, int *seed, int *psize) { - EDITSELMP; + EDITSELMP("perlin"); loopv(sels) { block sel = sels[i]; @@ -1010,7 +1006,7 @@ void edittagxy(int orv, int andv, block &sel) void edittag(int *tag) { - EDITSEL; + EDITSEL("edittag"); loopv(sels) { edittagxy(*tag, 0, sels[i]); @@ -1025,7 +1021,7 @@ void edittagclip(char *tag) if(tolower(*tag) == 'n') nt = 0; // "none", "nil, "nop" else if(!strncasecmp(tag, "pl", 2)) nt = TAGPLCLIP; // "playerclip", "plclip", "pl" else if(isalpha(*tag)) nt = TAGCLIP; // "clip", "all", "full", "hippo" - EDITSEL; + EDITSEL("edittagclip"); loopv(sels) { edittagxy(nt, TAGTRIGGERMASK, sels[i]); @@ -1036,14 +1032,14 @@ COMMAND(edittagclip, "s"); void newent(char *what, float *a1, float *a2, float *a3, float *a4) { - EDITSEL; + EDITSEL("newent"); loopv(sels) newentity(-1, sels[i].x, sels[i].y, (int)camera1->o.z, what, *a1, *a2, *a3, *a4); } COMMAND(newent, "sffff"); void movemap(int *xop, int *yop, int *zop) // move whole map { - EDITMP; + EDITMP("movemap"); int xo = *xop, yo = *yop, zo = *zop; if(!worldbordercheck(MINBORD + max(-xo, 0), MINBORD + max(xo, 0), MINBORD + max(-yo, 0), MINBORD + max(yo, 0), max(zo, 0), max(-zo, 0))) { @@ -1113,7 +1109,7 @@ void selfliprotate(block &sel, int dir) void selectionrotate(int *dir) { - EDITSEL; + EDITSEL("selectionrotate"); *dir &= 3; if(!*dir) return; loopv(sels) @@ -1130,7 +1126,7 @@ COMMAND(selectionrotate, "i"); void selectionflip(char *axis) { - EDITSEL; + EDITSEL("selectionflip"); char c = toupper(*axis); if(c != 'X' && c != 'Y') return; int dir = c == 'X' ? 11 : 12; @@ -1144,7 +1140,7 @@ COMMAND(selectionflip, "s"); void selectionwalk(char *action, char *beginsel, char *endsel) { - EDITSELMP; + EDITSELMP("selectionwalk"); if(*action) { const char *localvars[] = { "sw_cursel", "sw_abs_x", "sw_abs_y", "sw_rel_x", "sw_rel_y", "sw_type", "sw_floor", "sw_ceil", "sw_wtex", "sw_ftex", "sw_ctex", "sw_utex", "sw_vdelta", "sw_tag", "sw_r", "sw_g", "sw_b", "" }; @@ -1190,7 +1186,7 @@ COMMAND(selectionwalk, "sss"); void transformclipentities() // transforms all clip entities to tag clips, if they are big enough (so, that no player could be above or below them) { // (hardcoded factor ENTSCALE10 for attr1 and ENTSCALE5 for attr2-4) - EDITMP; + EDITMP("transformclipentities"); int total = 0, thisrun, bonus = 5; do { diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 4f724d3d..0aa9fa8f 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -486,7 +486,7 @@ void checkitems(playerent *d) void spawnallitems() // spawns items locally { - loopv(ents) if(ents[i].fitsmode(gamemode) || (multiplayer(false) && gamespeed!=100 && (i=-1))) + loopv(ents) if(ents[i].fitsmode(gamemode) || (multiplayer(NULL) && gamespeed!=100 && (i=-1))) { ents[i].spawned = true; ents[i].lastmillis = lastmillis; diff --git a/source/src/main.cpp b/source/src/main.cpp index e472ea07..d2a50c6f 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -1253,7 +1253,7 @@ int main(int argc, char **argv) limitfps(millis, totalmillis); int elapsed = millis-totalmillis; entropy_add_byte(elapsed); - if(multiplayer(false)) curtime = elapsed; + if(multiplayer(NULL)) curtime = elapsed; else { static int timeerr = 0; diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 0c7f6f75..debd9e02 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -796,7 +796,7 @@ void physicsframe() // optimally schedule physics frames inside the gra physframetime = clamp((PHYSFRAMETIME*gamespeed)/100, 1, PHYSFRAMETIME); physsteps = (diff + physframetime - 1)/physframetime; lastphysframe += physsteps * physframetime; - if(!multiplayer(false) && physsteps > 1000) physsteps = 1000; + if(!multiplayer(NULL) && physsteps > 1000) physsteps = 1000; } } diff --git a/source/src/protos.h b/source/src/protos.h index a4a1436d..81598640 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -500,7 +500,7 @@ extern void disconnect(int onlyclean = 0, int async = 0); extern void cleanupclient(); extern void toserver(char *text); extern void addmsg(int type, const char *fmt = NULL, ...); -extern bool multiplayer(bool msg = true); +extern bool multiplayer(const char *op = ""); extern bool allowedittoggle(); extern void sendpackettoserv(int chan, ENetPacket *packet); extern void gets2c(); @@ -712,6 +712,9 @@ extern void text_startcolumns(); extern void text_endcolumns(); // editing +#define EDITSEL(x) if(noteditmode(x) || noselection()) return +#define EDITSELMP(x) if(noteditmode(x) || noselection() || multiplayer(x)) return +#define EDITMP(x) if(noteditmode(x) || multiplayer(x)) return extern void cursorupdate(); extern void toggleedit(bool force = false); extern void reseteditor(); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 016fed6c..b4795633 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -957,7 +957,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat if(gametimedisplay) draw_text(gtime, (VIRTW-225-10)*2 - (text_width(gtime)/2 + FONTH/2), 20); } - if(hidevote < 2 && multiplayer(false)) + if(hidevote < 2 && multiplayer(NULL)) { extern votedisplayinfo *curvote; @@ -997,7 +997,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1); const int left = (VIRTW)*3/2, top = (VIRTH*3/2)*3/4; draw_textf("SPACE to change view", left - (text_width("SCROLL to change player") + FONTH/2), top); - if(multiplayer(false) || watchingdemo) draw_textf("SCROLL to change player", left - (text_width("SCROLL to change player") + FONTH/2), top+80); + if(multiplayer(NULL) || watchingdemo) draw_textf("SCROLL to change player", left - (text_width("SCROLL to change player") + FONTH/2), top+80); } extern void renderhudtexturepreviews(); diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 2c50af69..655df888 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -166,7 +166,8 @@ COMMAND(mapmodelslotusage, "i"); void deletemapmodelslot(int *n, char *opt) // delete mapmodel slot - only if unused or "purge" is specified { - if(noteditmode("deletemapmodelslot") || multiplayer(true) || !mapmodels.inrange(*n)) return; + EDITMP("deletemapmodelslot"); + if(!mapmodels.inrange(*n)) return; bool purgeall = !strcmp(opt, "purge"); if(!purgeall) loopv(ents) if(ents[i].type == MAPMODEL && ents[i].attr2 == *n) { conoutf("mapmodel slot #%d is in use: can't delete", *n); return; } int deld = 0; @@ -194,7 +195,8 @@ COMMAND(deletemapmodelslot, "is"); void editmapmodelslot(int *n, char *rad, char *h, char *zoff, char *scale, char *name) // edit slot parameters != "" { string res = ""; - if(!noteditmode("editmapmodelslot") && !multiplayer(true) && mapmodels.inrange(*n)) + EDITMP("editmapmodelslot"); + if(mapmodels.inrange(*n)) { mapmodelinfo &mmi = mapmodels[*n]; if(*rad || *h || *zoff || *scale || *name) @@ -252,7 +254,8 @@ void sortmapmodelslots(char **args, int numargs) else { conoutf("sortmapmodelslots: unknown argument \"%s\"", args[i]); unknownarg = true; } } - if(noteditmode("sortmapmodelslots") || multiplayer(true) || unknownarg || mapmodels.length() < 3) return; + EDITMP("sortmapmodelslots"); + if(unknownarg || mapmodels.length() < 3) return; vector tempslots; loopv(mapmodels) diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp index fb1a91b4..efb37a96 100644 --- a/source/src/renderparticles.cpp +++ b/source/src/renderparticles.cpp @@ -662,7 +662,7 @@ VARP(bulletairsounddestrad, 0, 8, 1000); void addshotline(dynent *pl, const vec &from, const vec &to) { if(pl == player1 || !shotlinettl || !shotline) return; - bool fx = shotlinettl > 0 && (player1->isspectating() || !multiplayer(false)); // allow fx only in spect mode and locally + bool fx = shotlinettl > 0 && (player1->isspectating() || !multiplayer(NULL)); // allow fx only in spect mode and locally if(rnd(3) && !fx) return; // show all shotlines when fx enabled int start = (camera1->o.dist(to) <= 10.0f) ? 8 : 5; diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index 343cea13..d27d7073 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -192,7 +192,7 @@ void renderdiscscores(int team) line.addcol(sc_frags, "%d", d.frags); line.addcol(sc_deaths, "%d", d.deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(d.frags, d.deaths)); - if(multiplayer(false) || watchingdemo) line.addcol(sc_score, "%d", max(d.points, 0)); + if(multiplayer(NULL) || watchingdemo) line.addcol(sc_score, "%d", max(d.points, 0)); line.addcol(sc_lag, "%s", clag); line.addcol(sc_clientnum, "DISC"); line.addcol(sc_name, "%s", d.name); @@ -212,7 +212,7 @@ void renderscore(playerent *d) else if (d->state==CS_LAGGED || (d->ping > 999 && d->plag > 99)) copystring(lagping, "LAG"); else { - if(multiplayer(false)) formatstring(lagping)("%s/%s", colorpj(d->plag), colorping(d->ping)); + if(multiplayer(NULL)) formatstring(lagping)("%s/%s", colorpj(d->plag), colorping(d->ping)); else formatstring(lagping)("%d/%d", d->plag, d->ping); } const char *ign = d->ignored ? " (ignored)" : (d->muted ? " (muted)" : ""); @@ -224,7 +224,7 @@ void renderscore(playerent *d) line.addcol(sc_frags, "%d", d->frags); line.addcol(sc_deaths, "%d", d->deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(d->frags, d->deaths)); - if(multiplayer(false) || watchingdemo) + if(multiplayer(NULL) || watchingdemo) { line.addcol(sc_score, "%d", max(d->points, 0)); line.addcol(sc_lag, "%s", lagping); @@ -256,7 +256,7 @@ void renderteamscore(teamscore *t) line.addcol(sc_frags, "%d", t->frags); line.addcol(sc_deaths, "%d", t->deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(t->frags, t->deaths)); - if(multiplayer(false) || watchingdemo) + if(multiplayer(NULL) || watchingdemo) { line.addcol(sc_score, "%d", max(t->points, 0)); line.addcol(sc_lag); @@ -283,7 +283,7 @@ void reorderscorecolumns() sscore.addcol(sc_frags, "frags"); sscore.addcol(sc_deaths, "deaths"); sscore.addcol(sc_ratio, "ratio"); - if(multiplayer(false) || watchingdemo) + if(multiplayer(NULL) || watchingdemo) { sscore.addcol(sc_score, "score"); sscore.addcol(sc_lag, "pj/ping"); @@ -366,7 +366,7 @@ void renderscores(void *menu, bool init) extern int minutesremaining, gametimedisplay; extern string gtime; - if((gamemode>1 || (gamemode==0 && (multiplayer(false) || watchingdemo))) && minutesremaining >= 0) + if((gamemode>1 || (gamemode==0 && (multiplayer(NULL) || watchingdemo))) && minutesremaining >= 0) { if(!minutesremaining) { @@ -398,7 +398,7 @@ void renderscores(void *menu, bool init) } } - if(multiplayer(false)) + if(multiplayer(NULL)) { serverinfo *s = getconnectedserverinfo(); if(s) @@ -463,7 +463,7 @@ const char *asciiscores(bool destjpg) formatstring(text)("\n\"%s\" on map %s", modestr(gamemode, 0), getclientmap()); addstr(buf, text); } - if(multiplayer(false)) + if(multiplayer(NULL)) { serverinfo *s = getconnectedserverinfo(); if(s) diff --git a/source/src/texture.cpp b/source/src/texture.cpp index 9eddc6a2..64420cda 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -1081,7 +1081,8 @@ COMMAND(textureslotusage, "i"); void deletetextureslot(int *n, char *opt, char *_replace) // delete texture slot - only if unused or "purge" is specified { - if(noteditmode("deletetextureslot") || multiplayer(true) || !slots.inrange(*n)) return; + EDITMP("deletetextureslot"); + if(!slots.inrange(*n)) return; bool purgeall = !strcmp(opt, "purge"); bool mmused = false; loopv(ents) if(ents[i].type == MAPMODEL && ents[i].attr4 == *n) mmused = true; @@ -1138,7 +1139,8 @@ COMMAND(deletetextureslot, "iss"); void edittextureslot(int *n, char *scale, char *name) // edit slot parameters != "" { string res = ""; - if(!noteditmode("edittextureslot") && !multiplayer(true) && slots.inrange(*n)) + EDITMP("edittextureslot"); + if(slots.inrange(*n)) { Slot &s = slots[*n]; if(*scale || *name) @@ -1258,7 +1260,8 @@ void sorttextureslots(char **args, int numargs) } while(presort.length() < 5) presort.add(presort.length()); - if(noteditmode("sorttextureslots") || multiplayer(true) || unknownarg || slots.length() < 5) return; + EDITMP("sorttextureslots"); + if(unknownarg || slots.length() < 5) return; int used[256] = { 0 }; textureslotusagemapmodels(used); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index e52c3b51..7568a550 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -491,7 +491,7 @@ void movebounceents() void clearbounceents() { if(gamespeed==100); - else if(multiplayer(false)) bounceents.add((bounceent *)player1); + else if(multiplayer(NULL)) bounceents.add((bounceent *)player1); loopv(bounceents) if(bounceents[i]) { delete bounceents[i]; bounceents.remove(i--); } } diff --git a/source/src/world.cpp b/source/src/world.cpp index bb5b83fe..278fea91 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -407,7 +407,7 @@ COMMAND(entset, "sffff"); void clearents(char *name) { int type = findtype(name); - if(noteditmode("clearents") || multiplayer()) return; + EDITMP("clearents"); bool found = false; loopv(ents) { @@ -434,7 +434,8 @@ COMMAND(clearents, "s"); void deleteentity(char *ns) { int n = ATOI(ns); - if(noteditmode("deleteentity") || multiplayer(true) || !*ns || !ents.inrange(n)) return; + EDITMP("deleteentity"); + if(!*ns || !ents.inrange(n)) return; entity &e = ents[n]; int t = e.type; if(t == SOUND) deletesoundentity(e); @@ -450,7 +451,8 @@ COMMAND(deleteentity, "s"); void addentity(char *what) // type { int type = findtype(what); - if(noteditmode("addentity") || multiplayer(true) || type == NOTUSED) return; + EDITMP("addentity"); + if(type == NOTUSED) return; entity e((int)camera1->o.x, (int)camera1->o.y, (int)camera1->o.z, type, 0, 0, 0, 0); e.spawned = true; intret(ents.length()); @@ -465,7 +467,8 @@ void editentity(char **args, int numargs) // index x y z a1 a2 a3 a4 ... if(numargs > 0) { int n = ATOI(args[0]); - if(noteditmode("editentity") || multiplayer(true) || !*args[0] || !ents.inrange(n)) return; + EDITMP("editentity"); + if(!*args[0] || !ents.inrange(n)) return; entity &e = ents[n]; bool edit = false; for(int i = 1; i < numargs; i++) if(*args[i]) edit = true; // only arguments other than empty strings can edit anything - otherwise we're just browsing @@ -849,7 +852,7 @@ void mapmrproper(bool manual) block b = { 0, 0, ssize, ssize }; if(manual) { - if(noteditmode("mapmrproper") || multiplayer()) return; + EDITMP("mapmrproper"); makeundo(b); } remip(b); diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 9ca3452a..572d5b48 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -482,7 +482,7 @@ COMMANDF(clearvantagepoint, "", () { if(!noteditmode("clearvantagepoint") && !mu void setvantagepoint() { - if(noteditmode("setvantagepoint") || multiplayer()) return; + EDITMP("setvantagepoint"); clearvantagepoint(); short p[5]; storeposition(p); @@ -1054,7 +1054,7 @@ int load_world(char *mname) // still supports all map formats that have e COMMANDF(loadmap, "s", (char *mapname) { - intret(!multiplayer() ? load_world(mapname) : -42); + intret(!multiplayer("loadmap") ? load_world(mapname) : -42); }); // support reading and writing binary data in config files @@ -1226,9 +1226,6 @@ struct xmap static vector xmaps; static xmap *bak, *xmjigsaw; // only bak needs to be deleted before reuse -#define SPEDIT if(noteditmode("xmap") || multiplayer()) return // only allowed in non-coop editmode -#define SPEDITDIFF if(noteditmode("xmap") || multiplayer() || nodiff()) return // only allowed in non-coop editmode after xmap_diff - bool validxmapname(const char *nick) { if(validmapname(nick)) return true; conoutf("sry, %s is not a valid xmap nickname", nick); return false; } void xmapdelete(xmap *&xm) // make sure, we don't point to deleted xmaps @@ -1325,7 +1322,7 @@ COMMANDF(xmap_rename, "ss", (const char *oldnick, const char *newnick) // re COMMANDF(xmap_restore, "s", (const char *nick) // use xmap as current map { - SPEDIT; + EDITMP("xmap_restore"); if(*nick) { xmap *xm = getxmapbynick(nick);