diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 78318210..48c82615 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1077,7 +1077,8 @@ void scallvote(char *type, char *arg1, char *arg2) if(type && inmainloop) { int t = atoi(type); - switch (t) { + switch (t) + { case SA_MAP: // FIXME { string n; @@ -1088,7 +1089,8 @@ void scallvote(char *type, char *arg1, char *arg2) case SA_KICK: case SA_BAN: { - if ( !arg2 || strlen(arg2) <= 3 ) { + if ( !arg2 || strlen(arg2) <= 3 ) + { conoutf(_("\f3invalid reason")); break; } diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 0c451dbe..38fad4a9 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -259,14 +259,16 @@ void showhudextras(char hudextras, char value){ case HE_FLAGCOVERED: outf("\f5%s",strcaps("you covered the flag", caps)); break; case HE_COVER: - if (teamworkid >= 0) { + if (teamworkid >= 0) + { playerent *p = getclient(teamworkid); if (!p || p == player1) teamworkid = -1; else outf("\f5you covered %s",p->name); break; } default: { - if (value >= HE_NUM) { + if (value >= HE_NUM) + { teamworkid = value - HE_NUM; playerent *p = getclient(teamworkid); if (!p || p == player1) teamworkid = -1; @@ -345,7 +347,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) { playerent *d = getclient(getint(p)); if(d) d->lastvoicecom = lastmillis; - if(!d || !(d->muted || d->ignored)) { + if(!d || !(d->muted || d->ignored)) + { int t = getint(p); if ( voicecomsounds == 1 || (voicecomsounds == 2 && m_teammode) ) audiomgr.playsound(t, SP_HIGH); } @@ -353,7 +356,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) } case SV_VOICECOM: { - if(!d || !(d->muted || d->ignored)) { + if(!d || !(d->muted || d->ignored)) + { int t = getint(p); if ( voicecomsounds == 1 ) audiomgr.playsound(t, SP_HIGH); } @@ -522,8 +526,10 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) case SV_SPAWNSTATE: { - if ( !good_map() ) { + if ( !good_map() ) + { loopi(6+2*NUMGUNS) getint(p); + conoutf(_("map deemed unplayable - fix it before you can spawn")); break; } @@ -1026,7 +1032,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) { int type = getint(p); int vcn = -1, n_yes = 0, n_no = 0; - if ( type == -1 ) { + if ( type == -1 ) + { d = getclient(vcn = getint(p)); n_yes = getint(p); n_no = getint(p); @@ -1068,7 +1075,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } displayvote(v); - if (vcn >= 0) { + if (vcn >= 0) + { loopi(n_yes) votecount(VOTE_YES); loopi(n_no) votecount(VOTE_NO); } diff --git a/source/src/entities.cpp b/source/src/entities.cpp index fef19383..0c52e2c7 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -304,8 +304,10 @@ void resetspawns(int type) } } -void setspawn(int i, bool on) { - if(ents.inrange(i)) { +void setspawn(int i, bool on) +{ + if(ents.inrange(i)) + { ents[i].twice = (ents[i].type == I_GRENADE && ents[i].spawned && on ? true : false); ents[i].spawned = on; if (on) ents[i].lastmillis = lastmillis; // to control trypickup spam diff --git a/source/src/main.cpp b/source/src/main.cpp index 6cd42447..8d56e5c1 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -969,9 +969,7 @@ int main(int argc, char **argv) if(needsautoscreenshot) makeautoscreenshot(); #ifdef _DEBUG - if(millis>lastflush+60000) { - fflush(stdout); lastflush = millis; - } + if(millis>lastflush+60000) { fflush(stdout); lastflush = millis; } #endif } diff --git a/source/src/physics.cpp b/source/src/physics.cpp index f81f6bf4..4cb7deac 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -775,7 +775,8 @@ void mousemove(int odx, int ody) } float dx = odx, dy = ody; int dt = totalmillis - mousemillis; - if ( mfilter > 0.0 && dt ) { + if ( mfilter > 0.0 && dt ) + { float k = curtime * mfilter; fdx = dx = ( dt*dx + fdx*k )/( dt + k ); fdy = dy = ( dt*dy + fdy*k )/( dt + k ); diff --git a/source/src/rendercubes.cpp b/source/src/rendercubes.cpp index c50707be..107810bb 100644 --- a/source/src/rendercubes.cpp +++ b/source/src/rendercubes.cpp @@ -25,7 +25,7 @@ struct strips { vector first; vector count; }; struct stripbatch { int tex; - strips tris, tristrips, quads; + strips tris, tristrips, quads; }; stripbatch skystrips = { DEFAULT_SKY }; @@ -80,7 +80,7 @@ void addstrip(int type, int tex, int start, int n) { if(minimap) return; sb = &skystrips; - loopi(n) skyfloor = min(skyfloor, verts[start + i].z); + loopi(n) skyfloor = min(skyfloor, verts[start + i].z); } else { @@ -105,7 +105,8 @@ void addstrip(int type, int tex, int start, int n) // leaves of all these functions, and are part of the cpu bottleneck on really slow // machines, hence the macros. -#define vert(v1, v2, v3, ls, t1, t2) { \ +#define vert(v1, v2, v3, ls, t1, t2) \ +{ \ vertex &v = verts.add(); \ v.u = t1; v.v = t2; \ v.x = (float)(v1); v.y = (float)(v2); v.z = (float)(v3); \ @@ -127,7 +128,7 @@ VARP(texturescale, 16, 32, 64); #define TEXTURESCALE float(texturescale) int striptype = 0, striptex, oh, oy, ox, odir; // the o* vars are used by the stripification -int ol1r, ol1g, ol1b, ol2r, ol2g, ol2b; +int ol1r, ol1g, ol1b, ol2r, ol2g, ol2b; float ofloor, oceil; bool ohf; int firstindex; @@ -141,14 +142,16 @@ COMMAND(showmip, ARG_NONE); VAR(mergestrips, 0, 1, 1); #define stripend(verts) \ - if(striptype) { \ + if(striptype) \ + { \ int type = GL_TRIANGLE_STRIP, len = verts.length()-firstindex; \ - if(mergestrips) switch(len) { \ + if(mergestrips) switch(len) \ + { \ case 3: type = GL_TRIANGLES; break; \ case 4: type = GL_QUADS; swap(verts.last(), verts[verts.length()-2]); break; \ - } \ - addstrip(type, striptex, firstindex, len); \ - striptype = 0; \ + } \ + addstrip(type, striptex, firstindex, len); \ + striptype = 0; \ } void finishstrips() { stripend(verts); } @@ -200,7 +203,7 @@ void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l4, sqr int lighterr = lighterror*2; if((abs(ol1r-l3->r)r)g)g)b)b)b)b)r)g)b) shadowverts; @@ -438,7 +441,8 @@ static void rendershadowstrips() xtraverts += shadowverts.length(); } -#define shadowvert(v1, v2, v3) { \ +#define shadowvert(v1, v2, v3) \ +{ \ shadowvertex &v = shadowverts.add(); \ v.x = (float)(v1); v.y = (float)(v2); v.z = (float)(v3); \ } diff --git a/source/src/server.cpp b/source/src/server.cpp index a66035a4..4aa24ae0 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -355,14 +355,17 @@ void sendextras() { if ( gamemillis < nextsendscore ) return; int count = 0, list[MAXCLIENTS]; - loopv(clients) { + loopv(clients) + { client &c = *clients[i]; if ( c.type!=ST_TCPIP || !c.isauthed || !(c.md.updated && c.md.upmillis < gamemillis) ) continue; - if ( c.md.combosend ) { + if ( c.md.combosend ) + { sendf(c.clientnum, 1, "ri2", SV_HUDEXTRAS, min(c.md.combo,c.md.combofrags)-1 + HE_COMBO); c.md.combosend = false; } - if ( c.md.dpt ) { + if ( c.md.dpt ) + { list[count] = i; count++; } @@ -1310,7 +1313,8 @@ bool serverpickup(int i, int sender) // server side item pickup, acknowl } sendf(-1, 1, "ri3", SV_ITEMACC, i, sender); cl->state.pickup(sents[i].type); - if (e.twice) { + if (e.twice) + { sendf(-1, 1, "ri3", SV_ITEMACC, i, sender); // FIXME cl->state.pickup(sents[i].type); } @@ -1331,7 +1335,8 @@ void checkitemspawns(int diff) sents[i].spawntime = 0; sents[i].spawned = true; sendf(-1, 1, "ri2", SV_ITEMSPAWN, i); - if (m_lss && sents[i].type == I_GRENADE && rnd(101) > 66 ) { + if (m_lss && sents[i].type == I_GRENADE && rnd(101) > 66 ) + { sents[i].twice = true; sendf(-1, 1, "ri2", SV_ITEMSPAWN, i); // FIXME } @@ -1595,7 +1600,8 @@ bool balanceteams(int ftr) // pro vs noobs never more int h = 0, l = 1; if ( tscore[1] > tscore[0] ) { h = 1; l = 0; } if ( 2 * tscore[h] < 3 * tscore[l] ) return true; - if ( tscore[h] > 3 * tscore[l] && tscore[h] > 50 * totalclients ) { + if ( tscore[h] > 3 * tscore[l] && tscore[h] > 50 * totalclients ) + { // sendf(-1, 1, "ri2", SV_SERVERMODE, sendservermode(false) | AT_SHUFFLE); shuffleteams(); return true; @@ -1605,7 +1611,8 @@ bool balanceteams(int ftr) // pro vs noobs never more int besth = 0, hid = -1; int bestdiff = 0, bestpair[2] = {-1, -1}; - if ( tsize[h] - tsize[l] > 0 ) { // the h team has more players, so we will force only one player + if ( tsize[h] - tsize[l] > 0 ) // the h team has more players, so we will force only one player + { loopv(clients) if( clients[i]->type!=ST_EMPTY ) { client *c = clients[i]; // loop for h @@ -1613,13 +1620,15 @@ bool balanceteams(int ftr) // pro vs noobs never more if( c->isauthed && c->team == h && !c->state.forced && clienthasflag(i) < 0 ) { // do not exchange in the way that weaker team becomes the stronger or the change is less than 20% effective - if ( 2 * c->eff_score <= diffscore && 10 * c->eff_score >= diffscore && c->eff_score > besth ) { + if ( 2 * c->eff_score <= diffscore && 10 * c->eff_score >= diffscore && c->eff_score > besth ) + { besth = c->eff_score; hid = i; } } } - if ( hid >= 0 ) { + if ( hid >= 0 ) + { updateclientteam(hid, l, ftr); clients[hid]->at3_lastforce = gamemillis; clients[hid]->state.forced = true; @@ -1637,7 +1646,8 @@ bool balanceteams(int ftr) // pro vs noobs never more if( cj->isauthed && cj->team == l && !cj->state.forced && clienthasflag(j) < 0 ) { int pairdiff = 2 * (c->eff_score - cj->eff_score); - if ( pairdiff <= diffscore && 5 * pairdiff >= diffscore && pairdiff > bestdiff ) { + if ( pairdiff <= diffscore && 5 * pairdiff >= diffscore && pairdiff > bestdiff ) + { bestdiff = pairdiff; bestpair[h] = i; bestpair[l] = j; @@ -1646,7 +1656,8 @@ bool balanceteams(int ftr) // pro vs noobs never more } } } - if ( bestpair[h] >= 0 && bestpair[l] >= 0 ) { + if ( bestpair[h] >= 0 && bestpair[l] >= 0 ) + { updateclientteam(bestpair[h], l, ftr); updateclientteam(bestpair[l], h, ftr); clients[bestpair[h]]->at3_lastforce = clients[bestpair[l]]->at3_lastforce = gamemillis; @@ -1730,14 +1741,18 @@ bool refillteams(bool now, int ftr) // force only minimal amounts of players } if(diffnum < 2) { - if ( ( gamemillis - lastbalance ) > waitbalance && ( gamelimit - gamemillis ) > 4 * 60 * 1000 ) { - if ( balanceteams (ftr) ) { + if ( ( gamemillis - lastbalance ) > waitbalance && ( gamelimit - gamemillis ) > 4 * 60 * 1000 ) + { + if ( balanceteams (ftr) ) + { waitbalance = 2 * 60 * 1000; switched = true; } else waitbalance = 20 * 1000; lastbalance = gamemillis; - } else if ( lastbalance > gamemillis ) { + } + else if ( lastbalance > gamemillis ) + { lastbalance = 0; waitbalance = 2 * 60 * 1000; } @@ -2190,7 +2205,8 @@ void disconnect_client(int n, int reason) void sendwhois(int sender, int cn) { if( !valid_client(sender) ) return; - if ( cn == -1 && clients[sender]->role == CR_ADMIN ) { + if ( cn == -1 && clients[sender]->role == CR_ADMIN ) + { loopv(clients) if ( valid_client(i) && clients[i]->type == ST_TCPIP && i != sender ) sendwhois(sender, i); return; } @@ -2391,7 +2407,7 @@ int checktype(int type, client *cl) SV_CLIENT }; // only allow edit messages in coop-edit mode static int edittypes[] = { SV_EDITENT, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE, SV_NEWMAP }; - if(cl) + if(cl) { loopi(sizeof(servtypes)/sizeof(int)) if(type == servtypes[i]) return -1; loopi(sizeof(edittypes)/sizeof(int)) if(type == edittypes[i]) return smode==GMODE_COOPEDIT ? type : -1; @@ -2517,7 +2533,8 @@ void process(ENetPacket *packet, int sender, int chan) if(packet->flags&ENET_PACKET_FLAG_RELIABLE) reliablemessages = true; #define QUEUE_MSG { if(cl->type==ST_TCPIP) while(curmsgmessages.add(p.buf[curmsg++]); } - #define QUEUE_BUF(body) { \ + #define QUEUE_BUF(body) \ + { \ if(cl->type==ST_TCPIP) \ { \ curmsg = p.length(); \ @@ -2561,8 +2578,8 @@ void process(ENetPacket *packet, int sender, int chan) if(*text) { bool canspeech = forbiddenlist.canspeech(text); - if(!spamdetect(cl, text) && canspeech) - { // team chat + if(!spamdetect(cl, text) && canspeech) // team chat + { logline(ACLOG_INFO, "[%s] %s%s says to team %s: '%s'", cl->hostname, type == SV_TEAMTEXTME ? "(me) " : "", cl->name, team_string(cl->team), text); sendteamtext(text, sender, type); } @@ -2570,11 +2587,13 @@ void process(ENetPacket *packet, int sender, int chan) { logline(ACLOG_INFO, "[%s] %s%s says to team %s: '%s', %s", cl->hostname, type == SV_TEAMTEXTME ? "(me) " : "", cl->name, team_string(cl->team), text, canspeech ? "SPAM detected" : "Forbidden speech"); - if (canspeech) { + if (canspeech) + { sendservmsg("\f3please do not spam", sender); if ( cl->spamcount > SPAMMAXREPEAT + 2 ) disconnect_client(cl->clientnum, DISC_ABUSE); } - else { + else + { sendservmsg("\f3watch your language!", sender); kick_abuser(cl->clientnum, cl->badmillis, cl->badspeech, 3); } @@ -2594,14 +2613,14 @@ void process(ENetPacket *packet, int sender, int chan) bool canspeech = forbiddenlist.canspeech(text); if(!spamdetect(cl, text) && canspeech) { - if(mastermode != MM_MATCH || !matchteamsize || team_isactive(cl->team) || (cl->team == TEAM_SPECT && cl->role == CR_ADMIN)) - { // common chat + if(mastermode != MM_MATCH || !matchteamsize || team_isactive(cl->team) || (cl->team == TEAM_SPECT && cl->role == CR_ADMIN)) // common chat + { logline(ACLOG_INFO, "[%s] %s%s says: '%s'", cl->hostname, type == SV_TEXTME ? "(me) " : "", cl->name, text); if(cl->type==ST_TCPIP) while(mid1messages.add(p.buf[mid1++]); QUEUE_STR(text); } - else - { // spect chat + else // spect chat + { logline(ACLOG_INFO, "[%s] %s%s says to team %s: '%s'", cl->hostname, type == SV_TEAMTEXTME ? "(me) " : "", cl->name, team_string(cl->team), text); sendteamtext(text, sender, type == SV_TEXTME ? SV_TEAMTEXTME : SV_TEAMTEXT); } @@ -2610,11 +2629,13 @@ void process(ENetPacket *packet, int sender, int chan) { logline(ACLOG_INFO, "[%s] %s%s says: '%s', %s", cl->hostname, type == SV_TEXTME ? "(me) " : "", cl->name, text, canspeech ? "SPAM detected" : "Forbidden speech"); - if (canspeech) { + if (canspeech) + { sendservmsg("\f3please do not spam", sender); if ( cl->spamcount > SPAMMAXREPEAT + 2 ) disconnect_client(cl->clientnum, DISC_ABUSE); } - else { + else + { sendservmsg("\f3watch your language!", sender); kick_abuser(cl->clientnum, cl->badmillis, cl->badspeech, 3); } @@ -2628,7 +2649,8 @@ void process(ENetPacket *packet, int sender, int chan) { int s = getint(p); /* spam filter */ - if ( servmillis > cl->mute ) { // client is not muted + if ( servmillis > cl->mute ) // client is not muted + { if( s < S_AFFIRMATIVE || s > S_NICESHOT ) cl->mute = servmillis + 10000; // vc is invalid else if ( cl->lastvc + 4000 < servmillis ) { if ( cl->spam > 0 ) cl->spam -= (servmillis - cl->lastvc) / 4000; } // no vc in the last 4 seconds else cl->spam++; // the guy is spamming @@ -2656,8 +2678,8 @@ void process(ENetPacket *packet, int sender, int chan) bool spawn = false; if(team_isspect(cl->team)) { - if(numclients() < 2 && !m_demo && mastermode != MM_MATCH) - { // spawn on empty servers + if(numclients() < 2 && !m_demo && mastermode != MM_MATCH) // spawn on empty servers + { spawn = updateclientteam(cl->clientnum, TEAM_ANYACTIVE, FTR_INFO); } } diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp index 139fce93..02be1948 100644 --- a/source/src/serverbrowser.cpp +++ b/source/src/serverbrowser.cpp @@ -1353,7 +1353,8 @@ void updatefrommaster(int force) clearservers(); if ( !strncmp(data.getbuf(), "addserver", 9) ) cllock = false; // the ms could reply other thing... but currently, this is useless - if ( !cllock ) { + if ( !cllock ) + { execute(data.getbuf()); if(curserver) addserver(curname, curport, curweight); } diff --git a/source/src/serverfiles.h b/source/src/serverfiles.h index b51c55fd..3324573c 100644 --- a/source/src/serverfiles.h +++ b/source/src/serverfiles.h @@ -584,7 +584,8 @@ struct serverforbiddenlist : serverconfigfile int n = 0; string s1, s2; char *c1 = s1, *c2 = s2; - if (num < 100 && (n = sscanf(s,"%s %s",s1,s2)) > 0 ) { // no warnings + if (num < 100 && (n = sscanf(s,"%s %s",s1,s2)) > 0 ) // no warnings + { strncpy(entries[num][0],c1,FORBIDDENSIZE); if ( n > 1 ) strncpy(entries[num][1],c2,FORBIDDENSIZE); else entries[num][1][0]='\0'; diff --git a/source/src/texture.cpp b/source/src/texture.cpp index 7a0b927c..9234988f 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -337,7 +337,8 @@ GLuint loadsurface(const char *texname, int &xs, int &ys, int &bpp, int clamp = if(!s) s = IMG_Load(findfile(file, "rb")); if(!s) { conoutf("couldn't load texture %s", texname); return 0; } s = fixsurfaceformat(s); - if (brightskin) { + if (brightskin) + { Uint8 x = 0; if(strstr(texname,"playermodel") && (x = fixcolor(s)) > 35) fixcolor(s,false,x,35); else if(strstr(texname,"skin") && strstr(texname,"weapon") && (x = fixcolor(s)) > 40 ) fixcolor(s,false,x,40); diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 37e98b6f..2593059d 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -117,7 +117,8 @@ mapstats *loadmapstats(const char *filename, bool getlayout) if(s.hdr.version<=2) { f->getchar(); f->getchar(); } break; } - if ( type != SOLID && diff > 6 ) { + if ( type != SOLID && diff > 6 ) + { Marea += n; Mvolume += diff * n; } @@ -130,7 +131,8 @@ mapstats *loadmapstats(const char *filename, bool getlayout) if(getlayout) { DELETEA(maplayout); - if (testlayout) { + if (testlayout) + { maplayout_factor = testlayout_factor; int layoutsize = 1 << (testlayout_factor * 2); maplayout = new char[layoutsize + 256]; diff --git a/source/src/tools.h b/source/src/tools.h index dda1ac81..21762efd 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -138,7 +138,8 @@ inline char *strcaps(const char *s, bool on) static char r[128]; char *c = (char *)s, *o = r; int n = 0; - while( *c!='\0' && n < 127) { + while( *c!='\0' && n < 127) + { *o = caps(*c); n++; o++; c++; } @@ -146,10 +147,12 @@ inline char *strcaps(const char *s, bool on) return r; } -inline bool issimilar (char s, char d) { +inline bool issimilar (char s, char d) +{ s = tolower(s); d = tolower(d); if ( s == d ) return true; - switch (d) { + switch (d) + { case 'a': if ( s == '@' || s == '4' ) return true; break; case 'c': if ( s == 'k' ) return true; break; case 'e': if ( s == '3' ) return true; break; @@ -167,12 +170,15 @@ inline bool findpattern (char *s, char *d) // returns true if there is more than int len, hit = 0; if (!d || (len = strlen(d)) < 1) return false; char *dp = d, *s_end = s + strlen(s); - while (s != s_end) { - if ( *s == ' ' ) { // spaces separate words + while (s != s_end) + { + if ( *s == ' ' ) // spaces separate words + { if ( !issimilar(*(s+1),*dp) ) { dp = d; hit = 0; } // d e t e c t i t } else if ( issimilar(*s,*dp) ) { dp++; hit++; } // hit! - else if ( hit > 0 ) { // this is not a pair, but there is a previous pattern + else if ( hit > 0 ) // this is not a pair, but there is a previous pattern + { if (*s == '.' || *s == *(s-1) || issimilar(*(s+1),*dp) ); // separator or typo (do nothing) else if ( issimilar(*(s+1),*(dp+1)) || *s == '*' ) dp++; // wild card or typo else hit--; // maybe this is nothing diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 15e2818f..b3d912e2 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -614,7 +614,8 @@ bool load_world(char *mname) // still supports all map formats that have s->tag = (hdr.version>=5) ? f->getchar() : 0; } } - if ( type != SOLID && diff > 6 ) { + if ( type != SOLID && diff > 6 ) + { Ma += n; Mv += diff * n; }