From 963190b0729dbbddda78c29db1d25d2f52f3181a Mon Sep 17 00:00:00 2001 From: drian Date: Thu, 15 Apr 2021 11:34:59 +0200 Subject: [PATCH] #215 FreeBSD build fix proposal --- source/src/clientgame.cpp | 8 ++++---- source/src/clients2c.cpp | 2 +- source/src/command.cpp | 2 +- source/src/entities.cpp | 4 ++-- source/src/protocol.h | 2 +- source/src/renderhud.cpp | 8 ++++---- source/src/scoreboard.cpp | 36 ++++++++++++++++++------------------ source/src/server.cpp | 22 +++++++++++----------- 8 files changed, 42 insertions(+), 42 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index b1bfe3da..202aad7b 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -210,7 +210,7 @@ void curmodeattr(char *attr) { if(!strcmp(attr, "team")) { intret(m_teammode); return; } else if(!strcmp(attr, "arena")) { intret(m_arena); return; } - else if(!strcmp(attr, "flag")) { intret(m_flags); return; } + else if(!strcmp(attr, "flag")) { intret(m_genflags); return; } else if(!strcmp(attr, "bot")) { intret(m_botmode); return; } intret(0); } @@ -622,7 +622,7 @@ void showrespawntimer() if(!arenaintermission) return; showhudtimer(5, arenaintermission, "FIGHT!", lastspawnattempt >= arenaintermission && lastmillis < lastspawnattempt+100); } - else if(player1->state==CS_DEAD && m_flags && (!player1->isspectating() || player1->spectatemode==SM_DEATHCAM)) + else if(player1->state==CS_DEAD && m_genflags && (!player1->isspectating() || player1->spectatemode==SM_DEATHCAM)) { int secs = 5; showhudtimer(secs, player1->lastdeath, "READY!", lastspawnattempt >= arenaintermission && lastmillis < lastspawnattempt+100); @@ -833,7 +833,7 @@ bool tryrespawn() } else { - int respawnmillis = player1->lastdeath + (m_arena ? 0 : (m_flags ? 5000 : 2000)); + int respawnmillis = player1->lastdeath + (m_arena ? 0 : (m_genflags ? 5000 : 2000)); if(lastmillis>respawnmillis) { player1->attacking = false; @@ -1166,7 +1166,7 @@ void startmap(const char *name, bool reset, bool norespawn) // called just aft if(m_botmode) BotManager.BeginMap(name); else kickallbots(); clearbounceents(); - preparectf(!m_flags); + preparectf(!m_genflags); suicided = -1; spawncycle = -1; lasthit = 0; diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index d49328ba..d539b99c 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -569,7 +569,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false) d->scopefov = (float)clamp(getint(p), 5, 60); d->address = getint(p); // partial IP address - if(m_flags) loopi(2) + if(m_genflags) loopi(2) { flaginfo &f = flaginfos[i]; if(!f.actor) f.actor = getclient(f.actor_cn); diff --git a/source/src/command.cpp b/source/src/command.cpp index 693ca127..9a3e260d 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -676,7 +676,7 @@ bool exechook(int context, const char *ident, const char *body,...) // execute if(((context & HOOK_TEAM) && !m_teammode) || ((context & HOOK_NOTEAM) && m_teammode) || ((context & HOOK_BOTMODE) && !m_botmode) || - ((context & HOOK_FLAGMODE) && m_flags) || + ((context & HOOK_FLAGMODE) && m_genflags) || ((context & HOOK_ARENA) && m_arena)) return false; // wrong gamemode if(identexists(ident)) { diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 64d56d37..ace8149a 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -228,7 +228,7 @@ void renderentities() } } } - if(m_flags) loopi(2) + if(m_genflags) loopi(2) { flaginfo &f = flaginfos[i]; switch(f.state) @@ -407,7 +407,7 @@ void checkitems(playerent *d) if(isitem(e.type)) v.z += float(e.attr1) / ENTSCALE10; if(d->o.dist(v)<2.5f) trypickup(i, d); } - if(m_flags) loopi(2) + if(m_genflags) loopi(2) { flaginfo &f = flaginfos[i]; entity &e = *f.flagent; diff --git a/source/src/protocol.h b/source/src/protocol.h index 9c27ce46..09500910 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -192,7 +192,7 @@ enum #define m_mp(mode) (m_valid(mode) && (mode)>=0 && (mode)!=7 && (mode)!=8 && (mode)!=12 && ((mode)<18 || (mode)>21)) #define m_demo (gamemode==-1) #define m_coop (gamemode==1) -#define m_flags (m_ctf || m_htf || m_ktf) +#define m_genflags (m_ctf || m_htf || m_ktf) #define m_isdemo(x) ((x) == -1) // single filter modes diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 72621910..45b7fa26 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -522,7 +522,7 @@ void drawradar_showmap(playerent *p, int w, int h) vec rtmp = vec(pl->o).sub(mdd).mul(coordtrans); drawradarent(rtmp.x, rtmp.y, pl->yaw, pl->state==CS_ALIVE ? (isattacking(pl) ? 2 : 0) : 1, spect3rd && d == pl ? 2 : pl_baseteam, iconsize, isattacking(pl), "%s", colorname(pl)); } - if(m_flags) + if(m_genflags) { glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -616,7 +616,7 @@ void drawradar_vicinity(playerent *p, int w, int h) drawradarent(rtmp.x, rtmp.y, pl->yaw, pl->state==CS_ALIVE ? (isattacking(pl) ? 2 : 0) : 1, spect3rd && d == pl ? 2 : pl_baseteam, iconsize, isattacking(pl), "%s", colorname(pl)); } } - if(m_flags) + if(m_genflags) { glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1048,13 +1048,13 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat popfont(); } - if((m_flags || m_teammode) && !hideteamscorehud) + if((m_genflags || m_teammode) && !hideteamscorehud) { glLoadIdentity(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); glColor4f(1.0f, 1.0f, 1.0f, 0.2f); turn_on_transparency(255); - int scores[4], offs = m_flags ? 0 : 2; + int scores[4], offs = m_genflags ? 0 : 2; calcteamscores(scores); const char *cc = scores[offs] > 99 || scores[offs + 1] > 99 ? "31" : "55"; diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index b6aa43c7..2cff0f21 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -97,7 +97,7 @@ struct teamscore frags += d->frags; deaths += d->deaths; points += d->points; - if(m_flags) flagscore += d->flagscore; + if(m_genflags) flagscore += d->flagscore; } void addscore(discscore &d) @@ -105,7 +105,7 @@ struct teamscore frags += d.frags; deaths += d.deaths; points += d.points; - if(m_flags) flagscore += d.flags; + if(m_genflags) flagscore += d.flags; } }; @@ -159,8 +159,8 @@ static int discscorecmp(const discscore *x, const discscore *y) { if(x->team < y->team) return -1; if(x->team > y->team) return 1; - if(m_flags && x->flags > y->flags) return -1; - if(m_flags && x->flags < y->flags) return 1; + if(m_genflags && x->flags > y->flags) return -1; + if(m_genflags && x->flags < y->flags) return 1; if(x->frags > y->frags) return -1; if(x->frags < y->frags) return 1; if(x->deaths > y->deaths) return 1; @@ -191,7 +191,7 @@ void renderdiscscores(int team) if(team_isspect(d.team)) line.textcolor = '4'; const char *clag = team_isspect(d.team) ? "SPECT" : ""; - if(m_flags) line.addcol(sc_flags, "%d", d.flags); + if(m_genflags) line.addcol(sc_flags, "%d", d.flags); line.addcol(sc_frags, "%d", d.frags); line.addcol(sc_deaths, "%d", d.deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(d.frags, d.deaths)); @@ -223,7 +223,7 @@ void renderscore(playerent *d) if(team_isspect(d->team)) line.textcolor = '4'; line.bgcolor = d==player1 ? &localplayerc : NULL; - if(m_flags) line.addcol(sc_flags, "%d", d->flagscore); + if(m_genflags) line.addcol(sc_flags, "%d", d->flagscore); line.addcol(sc_frags, "%d", d->frags); line.addcol(sc_deaths, "%d", d->deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(d->frags, d->deaths)); @@ -234,7 +234,7 @@ void renderscore(playerent *d) } line.addcol(sc_clientnum, "\fs\f%d%d\fr", cncolumncolor, d->clientnum); char flagicon = '\0'; - if(m_flags) //show flag icon at flag carrier with use radaricons font + if(m_genflags) //show flag icon at flag carrier with use radaricons font { loopi(2) { @@ -255,7 +255,7 @@ void renderteamscore(teamscore *t) } sline &line = scorelines.add(); - if(m_flags) line.addcol(sc_flags, "%d", t->flagscore); + if(m_genflags) line.addcol(sc_flags, "%d", t->flagscore); line.addcol(sc_frags, "%d", t->frags); line.addcol(sc_deaths, "%d", t->deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(t->frags, t->deaths)); @@ -282,7 +282,7 @@ void reorderscorecolumns() extern void *scoremenu; sline sscore; - if(m_flags) sscore.addcol(sc_flags, "flags"); + if(m_genflags) sscore.addcol(sc_flags, "flags"); sscore.addcol(sc_frags, "frags"); sscore.addcol(sc_deaths, "deaths"); sscore.addcol(sc_ratio, "ratio"); @@ -331,7 +331,7 @@ void renderscores(void *menu, bool init) renderteamscore(&teamscores[sort ^ i]); renderdiscscores(sort ^ i); } - winner = m_flags ? + winner = m_genflags ? (teamscores[sort].flagscore > teamscores[team_opposite(sort)].flagscore ? sort : -1) : (teamscores[sort].frags > teamscores[team_opposite(sort)].frags ? sort : -1); @@ -344,8 +344,8 @@ void renderscores(void *menu, bool init) { winner = scores[0]->clientnum; if(scores.length() > 1 - && ((m_flags && scores[0]->flagscore == scores[1]->flagscore) - || (!m_flags && scores[0]->frags == scores[1]->frags))) + && ((m_genflags && scores[0]->flagscore == scores[1]->flagscore) + || (!m_genflags && scores[0]->frags == scores[1]->frags))) winner = -1; } } @@ -482,7 +482,7 @@ const char *asciiscores(bool destjpg) addstr(t, e, "\n"); else { - formatstring(text)("\n%sfrags deaths cn%s name\n", m_flags ? "flags " : "", m_teammode ? " team" : ""); + formatstring(text)("\n%sfrags deaths cn%s name\n", m_genflags ? "flags " : "", m_teammode ? " team" : ""); addstr(t, e, text); } loopv(scores) @@ -492,9 +492,9 @@ const char *asciiscores(bool destjpg) formatstring(team)(destjpg ? ", %s" : " %-4s", team_string(d->team, true)); formatstring(flags)(destjpg ? "%d/" : " %4d ", d->flagscore); if(destjpg) - formatstring(text)("%s%s (%s%d/%d)\n", d->name, m_teammode ? team : "", m_flags ? flags : "", d->frags, d->deaths); + formatstring(text)("%s%s (%s%d/%d)\n", d->name, m_teammode ? team : "", m_genflags ? flags : "", d->frags, d->deaths); else - formatstring(text)("%s %4d %4d %2d%s %s%s\n", m_flags ? flags : "", d->frags, d->deaths, d->clientnum, + formatstring(text)("%s %4d %4d %2d%s %s%s\n", m_genflags ? flags : "", d->frags, d->deaths, d->clientnum, m_teammode ? team : "", d->name, d->clientrole==CR_ADMIN ? " (admin)" : d==player1 ? " (you)" : ""); addstr(t, e, text); } @@ -506,15 +506,15 @@ const char *asciiscores(bool destjpg) formatstring(team)(destjpg ? ", %s" : " %-4s", team_string(d.team, true)); formatstring(flags)(destjpg ? "%d/" : " %4d ", d.flags); if(destjpg) - formatstring(text)("%s(disconnected)%s (%s%d/%d)\n", d.name, m_teammode ? team : "", m_flags ? flags : "", d.frags, d.deaths); + formatstring(text)("%s(disconnected)%s (%s%d/%d)\n", d.name, m_teammode ? team : "", m_genflags ? flags : "", d.frags, d.deaths); else - formatstring(text)("%s %4d %4d --%s %s(disconnected)\n", m_flags ? flags : "", d.frags, d.deaths, m_teammode ? team : "", d.name); + formatstring(text)("%s %4d %4d --%s %s(disconnected)\n", m_genflags ? flags : "", d.frags, d.deaths, m_teammode ? team : "", d.name); addstr(t, e, text); } if(destjpg) { extern int minutesremaining; - formatstring(text)("(%sfrags/deaths), %d minute%s remaining\n", m_flags ? "flags/" : "", minutesremaining, minutesremaining == 1 ? "" : "s"); + formatstring(text)("(%sfrags/deaths), %d minute%s remaining\n", m_genflags ? "flags/" : "", minutesremaining, minutesremaining == 1 ? "" : "s"); addstr(t, e, text); } return buf + 8; diff --git a/source/src/server.cpp b/source/src/server.cpp index e3be3ab9..cf6f9c8d 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1280,7 +1280,7 @@ inline void send_item_list(packetbuf &p) putint(p, SV_ITEMLIST); loopv(sg->sents) if(sg->sents[i].spawned) putint(p, i); putint(p, -1); - if(m_flags) loopi(2) putflaginfo(p, i); + if(m_genflags) loopi(2) putflaginfo(p, i); } #include "serverchecks.h" @@ -1492,7 +1492,7 @@ void flagaction(int flag, int action, int actor) int clienthasflag(int cn) { - if(m_flags && valid_client(cn)) + if(m_genflags && valid_client(cn)) { loopi(2) { if(sg->sflaginfos[i].state==CTFF_STOLEN && sg->sflaginfos[i].actor_cn==cn) return i; } } @@ -1918,7 +1918,7 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib, ts.state = CS_DEAD; ts.lastdeath = sg->gamemillis; if(!suic) mlog(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, valid_weapon(gun) ? killmessages[gib ? 1 : 0][gun] : "smurfed", tk ? " their teammate" : "", target->name); - if(m_flags && targethasflag >= 0) + if(m_genflags && targethasflag >= 0) { if(m_ctf) flagaction(targethasflag, tk ? FA_RESET : FA_LOST, -1); @@ -1971,7 +1971,7 @@ void updatesdesc(const char *newdesc, ENetAddress *caller = NULL) int canspawn(client *c) // beware: canspawn() doesn't check m_arena! { if(!c || c->type == ST_EMPTY || !c->isauthed || !team_isvalid(c->team) || - (c->type == ST_TCPIP && (c->state.lastdeath > 0 ? sg->gamemillis - c->state.lastdeath : servmillis - c->connectmillis) < (m_arena ? 0 : (m_flags ? 5000 : 2000))) || + (c->type == ST_TCPIP && (c->state.lastdeath > 0 ? sg->gamemillis - c->state.lastdeath : servmillis - c->connectmillis) < (m_arena ? 0 : (m_genflags ? 5000 : 2000))) || (c->type == ST_TCPIP && (servmillis - c->connectmillis < 1000 + c->state.reconnections * 2000 && sg->gamemillis > 10000 && totalclients > 3 && !team_isspect(c->team)))) return SP_OK_NUM; // equivalent to SP_DENY if(!c->isonrightmap) return SP_WRONGMAP; @@ -3811,7 +3811,7 @@ void process(ENetPacket *packet, int sender, int chan) { int action = getint(p); int flag = getint(p); - if(!m_flags || flag < 0 || flag > 1 || action < 0 || action > FA_NUM) break; + if(!m_genflags || flag < 0 || flag > 1 || action < 0 || action > FA_NUM) break; flagaction(flag, action, sender); break; } @@ -4192,14 +4192,14 @@ void loggamestatus(const char *reason) mlog(ACLOG_INFO, "Game status: %s on %s, %s, %s, %d clients%c %s", modestr(gamemode), sg->smapname, reason ? reason : text, mmfullname(sg->mastermode), totalclients, sg->custom_servdesc ? ',' : '\0', sg->servdesc_current); if(!scl.loggamestatus) return; - mlog(ACLOG_INFO, "cn name %s%s score frag death %sping role host", m_teammode ? "team " : "", m_flags ? "flag " : "", m_teammode ? "tk " : ""); + mlog(ACLOG_INFO, "cn name %s%s score frag death %sping role host", m_teammode ? "team " : "", m_genflags ? "flag " : "", m_teammode ? "tk " : ""); loopv(clients) { client &c = *clients[i]; if(c.type == ST_EMPTY || !c.name[0]) continue; formatstring(text)("%2d %-16s ", c.clientnum, c.name); // cn name if(m_teammode) concatformatstring(text, "%-4s ", team_string(c.team, true)); // teamname (abbreviated) - if(m_flags) concatformatstring(text, "%4d ", c.state.flagscore); // flag + if(m_genflags) concatformatstring(text, "%4d ", c.state.flagscore); // flag concatformatstring(text, "%6d ", c.state.points); // score concatformatstring(text, "%4d %5d", c.state.frags, c.state.deaths); // frag death if(m_teammode) concatformatstring(text, " %2d", c.state.teamkills); // tk @@ -4221,7 +4221,7 @@ void loggamestatus(const char *reason) { if(m_teammode) formatstring(text)("%-4s ", team_string(sc.team, true)); else text[0] = '\0'; - if(m_flags) concatformatstring(text, "%4d ", sc.flagscore); + if(m_genflags) concatformatstring(text, "%4d ", sc.flagscore); mlog(ACLOG_INFO, " %-16s %s%4d %5d%s - disconnected", sc.name, text, sc.frags, sc.deaths, m_teammode ? " -" : ""); if(sc.team != TEAM_SPECT) { @@ -4235,7 +4235,7 @@ void loggamestatus(const char *reason) } if(m_teammode) { - loopi(2) mlog(ACLOG_INFO, "Team %4s:%3d players,%5d frags%c%5d flags", team_string(i), pnum[i], fragscore[i], m_flags ? ',' : '\0', flagscore[i]); + loopi(2) mlog(ACLOG_INFO, "Team %4s:%3d players,%5d frags%c%5d flags", team_string(i), pnum[i], fragscore[i], m_genflags ? ',' : '\0', flagscore[i]); } mlog(ACLOG_INFO, ""); } @@ -4332,7 +4332,7 @@ void serverslice(uint timeout) // main server update, called from cube main lo processevents(); checkitemspawns(diff); bool ktfflagingame = false; - if(m_flags) loopi(2) + if(m_genflags) loopi(2) { sflaginfo &f = sg->sflaginfos[i]; if(f.state == CTFF_DROPPED && sg->gamemillis-f.lastupdate > (m_ctf ? 30000 : 10000)) flagaction(i, FA_RESET, -1); @@ -4615,7 +4615,7 @@ void extinfo_teamscorebuf(ucharbuf &p) { sendstring(team_string(i), p); // team name putint(p, fragscores[i]); // add fragscore per team - putint(p, m_flags ? flagscores[i] : -1); // add flagscore per team + putint(p, m_genflags ? flagscores[i] : -1); // add flagscore per team putint(p, -1); // ? } }