diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp index a2d17f68..3fd0215e 100644 --- a/source/src/audiomanager.cpp +++ b/source/src/audiomanager.cpp @@ -372,7 +372,7 @@ VARP(mapsoundrefresh, 0, 10, 1000); void audiomanager::mutesound(int n, int off) { - bool mute = (off == 0); + bool mute = (off == 0); if(!gamesounds.inrange(n)) { conoutf("\f3could not %s sound #%d", mute ? "silence" : "unmute", n); @@ -399,7 +399,7 @@ void audiomanager::writesoundconfig(stream *f) void voicecom(char *sound, char *text) { if(!sound || !sound[0]) return; - if(!text || !text[0]) return; + if(!text || !text[0]) return; static int last = 0; if(!last || lastmillis-last > 2000) { @@ -751,30 +751,30 @@ audiomanager audiomgr; COMMANDF(sound, ARG_1INT, (int n) { - audiomgr.playsound(n); + audiomgr.playsound(n); }); COMMANDF(applymapsoundchanges, ARG_NONE, (){ - audiomgr.applymapsoundchanges(); + audiomgr.applymapsoundchanges(); }); COMMANDF(unmuteallsounds, ARG_NONE, () { - audiomgr.unmuteallsounds(); + audiomgr.unmuteallsounds(); }); COMMANDF(mutesound, ARG_2INT, (int n, int off) { - audiomgr.mutesound(n, off); + audiomgr.mutesound(n, off); }); ICOMMANDF(soundmuted, ARG_1EXP, (int n) { - return audiomgr.soundmuted(n); + return audiomgr.soundmuted(n); }); COMMANDF(mapsoundreset, ARG_NONE, () { - audiomgr.mapsoundreset(); + audiomgr.mapsoundreset(); }); VARF(soundchannels, 4, 32, 1024, audiomgr.setchannels(soundchannels); ); @@ -783,26 +783,26 @@ VARFP(soundvol, 0, 128, 255, audiomgr.setlistenervol(soundvol); ); COMMANDF(registersound, ARG_4STR, (char *name, char *vol, char *loop, char *audibleradius) { - audiomgr.addsound(name, atoi(vol), -1, atoi(loop) != 0, gamesounds, true, atoi(audibleradius)); + audiomgr.addsound(name, atoi(vol), -1, atoi(loop) != 0, gamesounds, true, atoi(audibleradius)); }); COMMANDF(mapsound, ARG_2STR, (char *name, char *maxuses) { - audiomgr.addsound(name, 255, atoi(maxuses), true, mapsounds, false, 0); + audiomgr.addsound(name, 255, atoi(maxuses), true, mapsounds, false, 0); }); COMMANDF(registermusic, ARG_1STR, (char *name) { - audiomgr.registermusic(name); + audiomgr.registermusic(name); }); COMMANDF(musicpreload, ARG_1INT, (int id) { - audiomgr.musicpreload(id); + audiomgr.musicpreload(id); }); COMMANDF(music, ARG_3STR, (char *name, char *millis, char *cmd) { - audiomgr.music(name, millis, cmd); + audiomgr.music(name, millis, cmd); }); diff --git a/source/src/bot/ac_bot_ai.cpp b/source/src/bot/ac_bot_ai.cpp index 0cdd0d74..f5f551d4 100644 --- a/source/src/bot/ac_bot_ai.cpp +++ b/source/src/bot/ac_bot_ai.cpp @@ -35,8 +35,8 @@ weaponinfo_s WeaponInfoTable[MAX_WEAPONS] = bool CACBot::ChoosePreferredWeapon() { - short bestWeapon = m_pMyEnt->gunselect; - short bestWeaponScore = 0; + short bestWeapon = m_pMyEnt->gunselect; + short bestWeaponScore = 0; short sWeaponScore; float flDist = GetDistance(m_pMyEnt->enemy->o); @@ -59,7 +59,7 @@ bool CACBot::ChoosePreferredWeapon() if((flDist >= WeaponInfoTable[i].flMinDesiredDistance) && (flDist <= WeaponInfoTable[i].flMaxDesiredDistance)) { - // In desired range for this weapon + // In desired range for this weapon sWeaponScore += 5; // Increase score much if(i == GUN_PISTOL || WeaponInfoTable[i].eWeaponType == TYPE_MELEE) @@ -118,10 +118,10 @@ bool CACBot::ChoosePreferredWeapon() } if(sWeaponScore > bestWeaponScore) - { - bestWeaponScore = sWeaponScore; - bestWeapon = i; - } + { + bestWeaponScore = sWeaponScore; + bestWeapon = i; + } } if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_ROCKET) @@ -180,28 +180,28 @@ entity *CACBot::SearchForEnts(bool bUseWPs, float flRange, float flMaxHeight) sMaxAmmo = ammostats[GUN_PISTOL].max; bInteresting = (m_pMyEnt->ammo[GUN_PISTOL]ammo[GUN_PISTOL]; - break; + break; case I_AMMO: sMaxAmmo = ammostats[m_pMyEnt->primary].max; bInteresting = (m_pMyEnt->ammo[m_pMyEnt->primary]ammo[m_pMyEnt->primary]; - break; - case I_GRENADE: + break; + case I_GRENADE: sMaxAmmo = ammostats[GUN_GRENADE].max; bInteresting = (m_pMyEnt->mag[GUN_GRENADE]health < sMaxAmmo); - sAmmo = m_pMyEnt->health; - break; + bInteresting = (m_pMyEnt->health < sMaxAmmo); + sAmmo = m_pMyEnt->health; + break; case I_HELMET: - case I_ARMOUR: - sMaxAmmo = powerupstats[I_ARMOUR-I_HEALTH].max; - bInteresting = (m_pMyEnt->armour < sMaxAmmo); - sAmmo = m_pMyEnt->armour; - break; + case I_ARMOUR: + sMaxAmmo = powerupstats[I_ARMOUR-I_HEALTH].max; + bInteresting = (m_pMyEnt->armour < sMaxAmmo); + sAmmo = m_pMyEnt->armour; + break; case I_AKIMBO: bInteresting = !m_pMyEnt->akimbo; sAmmo = -1; diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp index 24366fea..22e8f9fe 100644 --- a/source/src/bot/bot_ai.cpp +++ b/source/src/bot/bot_ai.cpp @@ -745,12 +745,12 @@ int CBot::GetShootDelay() void CBot::CheckReload() // reload gun if no enemies are around { if(m_pMyEnt->mag[m_pMyEnt->weaponsel->type] >= WeaponInfoTable[m_pMyEnt->weaponsel->type].sMinDesiredAmmo) return; // do not reload if mindesiredammo is satisfied - if(m_pMyEnt->enemy && m_pMyEnt->mag[m_pMyEnt->weaponsel->type]) + if(m_pMyEnt->enemy && m_pMyEnt->mag[m_pMyEnt->weaponsel->type]) { return; // ignore the enemy, if no ammo in mag. } - tryreload(m_pMyEnt); - return; + tryreload(m_pMyEnt); + return; } void CBot::CheckScope() @@ -813,7 +813,7 @@ void CBot::MainAI() } else if (CheckHunt() && HuntEnemy()) { - CheckReload(); + CheckReload(); CheckScope(); AddDebugText("Hunting to %s", m_pHuntTarget->name); m_eCurrentBotState = STATE_HUNT; @@ -821,7 +821,7 @@ void CBot::MainAI() // Heading to an interesting entity(ammo, armour etc) else if (CheckItems()) { - CheckReload(); + CheckReload(); AddDebugText("has ent"); m_eCurrentBotState = STATE_ENT; } @@ -833,7 +833,7 @@ void CBot::MainAI() } else // Normal navigation { - CheckReload(); + CheckReload(); if (m_eCurrentBotState != STATE_NORMAL) { m_vGoal = g_vecZero; @@ -1954,9 +1954,9 @@ void CBot::HearSound(int n, vec *o) if (m_pMyEnt->enemy) return; - //fixmebot + //fixmebot // Is the sound not interesting? - if(n == S_DIE1 || n == S_DIE2) return; + if(n == S_DIE1 || n == S_DIE2) return; int soundvol = m_pBotSkill->iMaxHearVolume - (int)(GetDistance(*o)*3*m_pBotSkill->iMaxHearVolume/255); diff --git a/source/src/bot/bot_util.h b/source/src/bot/bot_util.h index ef33931d..2a50f563 100644 --- a/source/src/bot/bot_util.h +++ b/source/src/bot/bot_util.h @@ -247,8 +247,8 @@ public: } node_s *GetFirst(void) { - return pNodeList; - }; + return pNodeList; + }; node_s *GetLast(void) { return pLastNode; }; void EditEntry(C OrigEntry, C NewVal) @@ -281,7 +281,7 @@ public: DeleteAllNodes(); }; - //fixmebot +//fixmebot //private: node_s *pNodeList; node_s *pLastNode; diff --git a/source/src/bot/bot_waypoint.cpp b/source/src/bot/bot_waypoint.cpp index 8371ef25..3260bc48 100644 --- a/source/src/bot/bot_waypoint.cpp +++ b/source/src/bot/bot_waypoint.cpp @@ -277,7 +277,7 @@ bool CWaypointClass::LoadWaypoints() conoutf("Waypoints for map %s loaded", (m_szMapName)); - testx = m_Waypoints[1][1].pNodeList; + testx = m_Waypoints[1][1].pNodeList; return true; } @@ -1934,7 +1934,7 @@ COMMAND(wpload, ARG_NONE); void wpclear(void) { - WaypointClass.Clear(); + WaypointClass.Clear(); } COMMAND(wpclear, ARG_NONE); diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index 5e7be26b..f6d759fb 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -316,7 +316,7 @@ void CBotManager::RenderBots() { /*drawblue = (m_sp || isteam(player1->team, bots[i]->team)); renderclient(bots[i], drawblue, "playermodels/counterterrorist", 1.6f);*/ - renderclient(bots[i]); + renderclient(bots[i]); } } } @@ -978,9 +978,9 @@ botent *CBotManager::CreateBot(const char *team, const char *skill, const char * bool botmode() { - if(m_botmode) return true; - conoutf("the current game mode does not support bots"); - return false; + if(m_botmode) return true; + conoutf("the current game mode does not support bots"); + return false; } // Bot manager class end @@ -997,7 +997,7 @@ COMMAND(addbot, ARG_3STR); void addnbot(char *arg1, char *arg2, char *arg3) { - if(!botmode()) return; + if(!botmode()) return; if (!arg1 || !arg1[0]) return; int i = atoi(arg1); @@ -1050,7 +1050,7 @@ COMMAND(idlebots, ARG_1INT); void drawbeamtobots() { - if(!botmode()) return; + if(!botmode()) return; loopv(bots) { if (bots[i]) @@ -1062,7 +1062,7 @@ COMMAND(drawbeamtobots, ARG_NONE); void kickbot(const char *szName) { - if(!botmode()) return; + if(!botmode()) return; if (!szName || !(*szName)) return; @@ -1127,7 +1127,7 @@ COMMAND(togglegrap, ARG_NONE); void togglebotview(char *bot) { - if(!botmode()) return; + if(!botmode()) return; /** Disable in arena modes, this command causes the game to go in an "infinite loop" due to player1 automatically suiciding thus causing a new round to begin. diff --git a/source/src/client.cpp b/source/src/client.cpp index 261c6f83..06ff4dba 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -571,7 +571,7 @@ void gets2c() // get updates from the server break; case ENET_EVENT_TYPE_RECEIVE: - { + { extern packetqueue pktlogger; pktlogger.queue(event.packet); @@ -580,10 +580,10 @@ void gets2c() // get updates from the server // destroyed in logger //enet_packet_destroy(event.packet); break; - } + } case ENET_EVENT_TYPE_DISCONNECT: - { + { extern const char *disc_reason(int reason); if(event.data>=DISC_NUM) event.data = DISC_NONE; if(event.peer==connpeer) @@ -597,7 +597,7 @@ void gets2c() // get updates from the server disconnect(); } return; - } + } default: break; @@ -641,19 +641,19 @@ void genauthkey(const char *secret) void saveauthkeys() { - if(authkeys.length()) - { - stream *f = openfile("config/auth.cfg", "w"); - if(!f) { conoutf("failed to open config/auth.cfg for writing"); return; } - loopv(authkeys) - { - authkey *a = authkeys[i]; - f->printf("authkey \"%s\" \"%s\" \"%s\"\n", a->name, a->key, a->desc); - } - conoutf("saved authkeys to config/auth.cfg"); - delete f; - } - else conoutf("you need to use 'addauthkey USER KEY DESC' first; one DESC 'public', one DESC empty(=private)"); + if(authkeys.length()) + { + stream *f = openfile("config/auth.cfg", "w"); + if(!f) { conoutf("failed to open config/auth.cfg for writing"); return; } + loopv(authkeys) + { + authkey *a = authkeys[i]; + f->printf("authkey \"%s\" \"%s\" \"%s\"\n", a->name, a->key, a->desc); + } + conoutf("saved authkeys to config/auth.cfg"); + delete f; + } + else conoutf("you need to use 'addauthkey USER KEY DESC' first; one DESC 'public', one DESC empty(=private)"); } bool tryauth(const char *desc) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index ad13b8f6..d76ef0f3 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -18,30 +18,30 @@ COMMAND(mode, ARG_1INT); void setbottimeout(int m, int t) { - if(m==1 || m==2) - { - if(t>0 && t<61) - { - switch(m) - { - case 1: - { - extern int botmatch_dm_minremain; - botmatch_dm_minremain = t; - break; - } - case 2: - { - extern int botmatch_tm_minremain; - botmatch_tm_minremain = t; - break; - } - default: break; - } - } - else conoutf(_("\f3Error: \f5valid range for time is 1-60")); - } - else conoutf(_("\f3Error: \f5mode needs to be 1 for FFA or 2 for team modes")); + if(m==1 || m==2) + { + if(t>0 && t<61) + { + switch(m) + { + case 1: + { + extern int botmatch_dm_minremain; + botmatch_dm_minremain = t; + break; + } + case 2: + { + extern int botmatch_tm_minremain; + botmatch_tm_minremain = t; + break; + } + default: break; + } + } + else conoutf(_("\f3Error: \f5valid range for time is 1-60")); + } + else conoutf(_("\f3Error: \f5mode needs to be 1 for FFA or 2 for team modes")); } COMMAND(setbottimeout, ARG_2INT); @@ -66,8 +66,8 @@ extern bool sendmapidenttoserver; void setskin(playerent *pl, int skin, int team) { - if(!pl) return; - pl->setskin(team, skin); + if(!pl) return; + pl->setskin(team, skin); } extern char *global_name; @@ -203,7 +203,7 @@ void newname(const char *name) } else conoutf(_("your name is: %s"), player1->name); //alias(_("curname"), player1->name); // WTF? stef went crazy - this isn't something to translate either. - alias("curname", player1->name); + alias("curname", player1->name); } int teamatoi(const char *name) @@ -240,12 +240,12 @@ void benchme() int _setskin(char *s, int t) { - if(s && *s) + if(s && *s) { setskin(player1, atoi(s), t); addmsg(SV_SWITCHSKIN, "rii", player1->skin(0), player1->skin(1)); } - return player1->skin(t); + return player1->skin(t); } ICOMMANDF(skin_cla, ARG_1EST, (char *s) { return _setskin(s, TEAM_CLA); }); @@ -438,7 +438,7 @@ void spawnstate(playerent *d) // reset player state not persistent setscope(false); setburst(false); } - if(d->deaths==0) d->resetstats(); + if(d->deaths==0) d->resetstats(); } playerent *newplayerent() // create a new blank player @@ -490,8 +490,8 @@ void movelocalplayer() { if(lastmillis-player1->lastpain<2000) { - player1->move = player1->strafe = 0; - moveplayer(player1, 10, false); + player1->move = player1->strafe = 0; + moveplayer(player1, 10, false); } } else if(!intermission) @@ -632,14 +632,14 @@ COMMANDN(resetsleeps, resetsleep_, ARG_NONE); void updateworld(int curtime, int lastmillis) // main game update loop { // process command sleeps - loopv(sleeps) + loopv(sleeps) { if(lastmillis - sleeps[i].millis >= sleeps[i].wait) { char *cmd = sleeps[i].cmd; sleeps[i].cmd = NULL; - execute(cmd); - delete[] cmd; + execute(cmd); + delete[] cmd; if(sleeps[i].cmd || !sleeps.inrange(i)) break; sleeps.remove(i--); } @@ -834,29 +834,29 @@ VARP(hitsound, 0, 0, 1); // client kill messages void setkillmessage(int gun, bool gib, const char *message) { - if(!message || !*message) - { - result(killmessage(gun, gib)); - return; - } + if(!message || !*message) + { + result(killmessage(gun, gib)); + return; + } - if(gun < 0 || gun >= NUMGUNS) - { - conoutf("invalid gun specified"); - return; - } - - copystring(killmessages[gib?1:0][gun], message, sizeof(killmessages[gib?1:0][gun])); + if(gun < 0 || gun >= NUMGUNS) + { + conoutf("invalid gun specified"); + return; + } + + copystring(killmessages[gib?1:0][gun], message, sizeof(killmessages[gib?1:0][gun])); } void fragmessage(const char *gun, const char *message) { - setkillmessage(atoi(gun), false, message); + setkillmessage(atoi(gun), false, message); } void gibmessage(const char *gun, const char *message) { - setkillmessage(atoi(gun), true, message); + setkillmessage(atoi(gun), true, message); } COMMAND(fragmessage, ARG_2STR); @@ -881,9 +881,9 @@ void writekillmsgcfg() void dodamage(int damage, playerent *pl, playerent *actor, int gun, bool gib, bool local) { - if(pl->state != CS_ALIVE || intermission) return; - pl->respawnoffset = pl->lastpain = lastmillis; - // could the author of the FIXME below please elaborate what's to fix?! (ft:2011mar28) + if(pl->state != CS_ALIVE || intermission) return; + pl->respawnoffset = pl->lastpain = lastmillis; + // could the author of the FIXME below please elaborate what's to fix?! (ft:2011mar28) // I suppose someone wanted to play the hitsound for player1 or spectated player (lucas:2011may22) playerent *h = player1->isspectating() && player1->followplayercn >= 0 && (player1->spectatemode == SM_FOLLOW1ST || player1->spectatemode == SM_FOLLOW3RD || player1->spectatemode == SM_FOLLOW3RD_TRANSPARENT) ? getclient(player1->followplayercn) : NULL; if(!h) h = player1; @@ -932,7 +932,7 @@ void dokill(playerent *pl, playerent *act, bool gib, int gun) string pname, aname, death; copystring(pname, pl==player1 ? "you" : colorname(pl)); copystring(aname, act==player1 ? "you" : colorname(act)); - copystring(death, killmessage(gun, gib)); + copystring(death, killmessage(gun, gib)); void (*outf)(const char *s, ...) = (pl == player1 || act == player1) ? hudoutf : conoutf; if(pl==act) @@ -1039,7 +1039,7 @@ void silenttimeupdate(int milliscur, int millismax) void timeupdate(int milliscur, int millismax) { - bool display = lastmillis - lastgametimeupdate > 1000; // avoid double-output + bool display = lastmillis - lastgametimeupdate > 1000; // avoid double-output silenttimeupdate(milliscur, millismax); @@ -1456,11 +1456,11 @@ void callvote(int type, const char *arg1, const char *arg2) break; } sendpackettoserv(1, p.finalize()); - if(identexists("onCallVote")) - { - defformatstring(runas)("%s %d %d [%s] [%s]", "onCallVote", type, -1, arg1, arg2); - execute(runas); - } + if(identexists("onCallVote")) + { + defformatstring(runas)("%s %d %d [%s] [%s]", "onCallVote", type, -1, arg1, arg2); + execute(runas); + } } else conoutf(_("%c3invalid vote"), CC); } @@ -1696,15 +1696,15 @@ playerent *updatefollowplayer(int shiftdirection) void setfollowplayer(int cn) { - // silently ignores invalid player-cn value passed - if(players.inrange(cn)) - { - if(!(m_teammode && player1->team != TEAM_SPECT && !watchingdemo && team_base(players[cn]->team) != team_base(player1->team))) - { - if(player1->followplayercn != players[cn]->clientnum) addmsg(SV_SPECTCN, "ri", cn); - player1->followplayercn = cn; - } - } + // silently ignores invalid player-cn value passed + if(players.inrange(cn)) + { + if(!(m_teammode && player1->team != TEAM_SPECT && !watchingdemo && team_base(players[cn]->team) != team_base(player1->team))) + { + if(player1->followplayercn != players[cn]->clientnum) addmsg(SV_SPECTCN, "ri", cn); + player1->followplayercn = cn; + } + } } // set new spect mode diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 33d9b40e..66427ec0 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -362,20 +362,20 @@ int lastspawn = 0; void onCallVote(int type, int vcn, char *text, char *a) { - if(identexists("onCallVote")) - { - defformatstring(runas)("%s %d %d [%s] [%s]", "onCallVote", type, vcn, text, a); - execute(runas); - } + if(identexists("onCallVote")) + { + defformatstring(runas)("%s %d %d [%s] [%s]", "onCallVote", type, vcn, text, a); + execute(runas); + } } void onChangeVote(int mod, int id) { - if(identexists("onChangeVote")) - { - defformatstring(runas)("%s %d %d", "onChangeVote", mod, id); - execute(runas); - } + if(identexists("onChangeVote")) + { + defformatstring(runas)("%s %d %d", "onChangeVote", mod, id); + execute(runas); + } } VARP(voicecomsounds, 0, 1, 2); @@ -410,7 +410,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) if(prot!=CUR_PROTOCOL_VERSION && !(watchingdemo && prot == -PROTOCOL_VERSION)) { conoutf(_("%c3incompatible game protocol (local protocol: %d :: server protocol: %d)"), CC, CUR_PROTOCOL_VERSION, prot); - conoutf("\f3if this occurs a lot, obtain an upgrade from \f1http://assault.cubers.net"); + conoutf("\f3if this occurs a lot, obtain an upgrade from \f1http://assault.cubers.net"); if(watchingdemo) conoutf("breaking loop : \f3this demo is using a different protocol\f5 : end it now!"); // SVN-WiP-bug: causes endless retry loop else! else disconnect(); return; @@ -714,7 +714,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) d->weapons[GUN_GRENADE]->attackfx(from, to, nademillis); d->weapons[GUN_GRENADE]->reloading = 0; } - if(d!=player1) d->pstatshots[GUN_GRENADE]++; //NEW + if(d!=player1) d->pstatshots[GUN_GRENADE]++; //NEW break; } @@ -1004,11 +1004,11 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) flagdropped(flag, x, y, z); break; } - case CTFF_INBASE: - flaginbase(flag); - break; - case CTFF_IDLE: - flagidle(flag); + case CTFF_INBASE: + flaginbase(flag); + break; + case CTFF_IDLE: + flagidle(flag); break; } break; @@ -1215,44 +1215,44 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) onCallVote(type, vcn, text, a); if (vcn >= 0) { - loopi(n_yes) votecount(VOTE_YES); - loopi(n_no) votecount(VOTE_NO); - } + loopi(n_yes) votecount(VOTE_YES); + loopi(n_no) votecount(VOTE_NO); + } extern int vote(int); if (d == player1) vote(VOTE_YES); break; } case SV_CALLVOTESUC: - { - callvotesuc(); - onChangeVote( 0, -1); - break; - } + { + callvotesuc(); + onChangeVote( 0, -1); + break; + } case SV_CALLVOTEERR: - { - int errn = getint(p); + { + int errn = getint(p); callvoteerr(errn); - onChangeVote( 1, errn); + onChangeVote( 1, errn); break; - } + } case SV_VOTE: - { - int vote = getint(p); + { + int vote = getint(p); votecount(vote); - onChangeVote( 2, vote); + onChangeVote( 2, vote); break; - } + } case SV_VOTERESULT: - { - int vres = getint(p); + { + int vres = getint(p); voteresult(vres); - onChangeVote( 3, vres); + onChangeVote( 3, vres); break; - } + } case SV_WHOISINFO: { @@ -1288,7 +1288,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) curdemofile = newstring(demofile); player1->resetspec(); player1->state = CS_SPECTATE; - player1->team = TEAM_SPECT; + player1->team = TEAM_SPECT; } else { @@ -1316,7 +1316,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) void setDemoFilenameFormat(char *fmt) { - extern string demofilenameformat; + extern string demofilenameformat; if(fmt && fmt[0]!='\0') { copystring(demofilenameformat, fmt); @@ -1325,7 +1325,7 @@ void setDemoFilenameFormat(char *fmt) COMMANDN(demonameformat, setDemoFilenameFormat, ARG_1STR); void setDemoTimestampFormat(char *fmt) { - extern string demotimestampformat; + extern string demotimestampformat; if(fmt && fmt[0]!='\0') { copystring(demotimestampformat, fmt); @@ -1334,8 +1334,8 @@ void setDemoTimestampFormat(char *fmt) COMMANDN(demotimeformat, setDemoTimestampFormat, ARG_1STR); void setDemoTimeLocal(int truth) { - extern int demotimelocal; - demotimelocal = truth == 0 ? 0 : 1; + extern int demotimelocal; + demotimelocal = truth == 0 ? 0 : 1; } COMMANDN(demotimelocal, setDemoTimeLocal, ARG_1INT); void getdemonameformat() { extern string demofilenameformat; result(demofilenameformat); } COMMAND(getdemonameformat, ARG_NONE); @@ -1377,7 +1377,7 @@ const char *parseDemoFilename(char *srvfinfo) void receivefile(uchar *data, int len) { - static char text[MAXTRANS]; + static char text[MAXTRANS]; ucharbuf p(data, len); int type = getint(p); data += p.length(); @@ -1388,16 +1388,16 @@ void receivefile(uchar *data, int len) { getstring(text, p); extern string demosubpath; - defformatstring(demofn)("%s", parseDemoFilename(text)); + defformatstring(demofn)("%s", parseDemoFilename(text)); defformatstring(fname)("demos/%s%s.dmo", demosubpath, demofn); copystring(demosubpath, ""); data += strlen(text); int demosize = getint(p); if(p.remaining() < demosize) - { - p.forceoverread(); - break; - } + { + p.forceoverread(); + break; + } path(fname); stream *demo = openrawfile(fname, "wb"); if(!demo) diff --git a/source/src/command.cpp b/source/src/command.cpp index e449f392..ac9d4ed3 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -309,27 +309,26 @@ COMMANDN(getalias, _getalias, ARG_1STR); void _getvar(char *name) { - string resstr; - resstr[0] = '\0'; + string resstr; + resstr[0] = '\0'; ident *id = idents->access(name); if(id) - { - switch(id->type) - { - case ID_VAR: - formatstring(resstr)("%d", *id->storage.i); - break; - case ID_FVAR: - formatstring(resstr)("%.3f", *id->storage.f); - break; - case ID_SVAR: - formatstring(resstr)("%s", *id->storage.s); - break; - - default: break; - } - } - result(resstr); + { + switch(id->type) + { + case ID_VAR: + formatstring(resstr)("%d", *id->storage.i); + break; + case ID_FVAR: + formatstring(resstr)("%.3f", *id->storage.f); + break; + case ID_SVAR: + formatstring(resstr)("%s", *id->storage.s); + break; + default: break; + } + } + result(resstr); } COMMANDN(getvar, _getvar, ARG_1STR); COMMANDN(isIdent, identexists, ARG_1EST); @@ -467,211 +466,211 @@ vector seer_t2; // timestamp of last n3 (10) level-2 calls #endif char *executeret(const char *p) // all evaluation happens here, recursively { - if(!p || !p[0]) return NULL; - bool noproblem = true; + if(!p || !p[0]) return NULL; + bool noproblem = true; #if 0 - if(execcontext>IEXC_CFG) // only PROMPT and MAP-CFG are checked for this, fooling with core/cfg at your own risk! - { - seer_count++; - if(seer_count>=100) - { - seer_index = (seer_index+1)%10; - long long cts = (long long) time(NULL); - if(seer_t1.length()>=10) seer_t1[seer_index] = cts; - seer_t1.add(cts); - int lc = (seer_index+11)%10; - if(lc<=seer_t1.length()) - { - int dt = seer_t1[seer_index] - seer_t1[lc]; - if(abs(dt)<2) - { - conoutf("SCRIPT EXECUTION warning [%d:%s]", &p, p); - seer_t2.add(seer_t1[seer_index]); - if(seer_t2.length() >= 10) - { - if(seer_t2[0] == seer_t2.last()) - { - conoutf("SCRIPT EXECUTION in danger of crashing the client - dropping script [%s].", p); - noproblem = false; - seer_t2.shrink(0); - seer_t1.shrink(0); - seer_index = 0; - } - } - } - } - seer_count = 0; - } - } + if(execcontext>IEXC_CFG) // only PROMPT and MAP-CFG are checked for this, fooling with core/cfg at your own risk! + { + seer_count++; + if(seer_count>=100) + { + seer_index = (seer_index+1)%10; + long long cts = (long long) time(NULL); + if(seer_t1.length()>=10) seer_t1[seer_index] = cts; + seer_t1.add(cts); + int lc = (seer_index+11)%10; + if(lc<=seer_t1.length()) + { + int dt = seer_t1[seer_index] - seer_t1[lc]; + if(abs(dt)<2) + { + conoutf("SCRIPT EXECUTION warning [%d:%s]", &p, p); + seer_t2.add(seer_t1[seer_index]); + if(seer_t2.length() >= 10) + { + if(seer_t2[0] == seer_t2.last()) + { + conoutf("SCRIPT EXECUTION in danger of crashing the client - dropping script [%s].", p); + noproblem = false; + seer_t2.shrink(0); + seer_t1.shrink(0); + seer_index = 0; + } + } + } + } + seer_count = 0; + } + } #endif const int MAXWORDS = 25; // limit, remove char *w[MAXWORDS]; char *retval = NULL; #define setretval(v) { char *rv = v; if(rv) retval = rv; } - if(noproblem) // if the "seer"-algorithm doesn't object - { - for(bool cont = true; cont;) // for each ; seperated statement - { + if(noproblem) // if the "seer"-algorithm doesn't object + { + for(bool cont = true; cont;) // for each ; seperated statement + { if(loop_level && loop_skip) break; - int numargs = MAXWORDS, infix = 0; - loopi(MAXWORDS) // collect all argument values - { - w[i] = (char *)""; - if(i>numargs) continue; - char *s = parseword(p, i, infix); // parse and evaluate exps - if(s) w[i] = s; - else numargs = i; - } + int numargs = MAXWORDS, infix = 0; + loopi(MAXWORDS) // collect all argument values + { + w[i] = (char *)""; + if(i>numargs) continue; + char *s = parseword(p, i, infix); // parse and evaluate exps + if(s) w[i] = s; + else numargs = i; + } - p += strcspn(p, ";\n\0"); - cont = *p++!=0; // more statements if this isn't the end of the string - const char *c = w[0]; - if(!*c) continue; // empty statement + p += strcspn(p, ";\n\0"); + cont = *p++!=0; // more statements if this isn't the end of the string + const char *c = w[0]; + if(!*c) continue; // empty statement - DELETEA(retval); + DELETEA(retval); - if(infix) - { - switch(infix) - { - case '=': - DELETEA(w[1]); - swap(w[0], w[1]); - c = "alias"; - break; - } - } + if(infix) + { + switch(infix) + { + case '=': + DELETEA(w[1]); + swap(w[0], w[1]); + c = "alias"; + break; + } + } - ident *id = idents->access(c); - if(!id) - { - if(!isdigit(*c) && ((*c!='+' && *c!='-' && *c!='.') || !isdigit(c[1]))) - { - conoutf("unknown command: %s", c); - scripterr(); - } - setretval(newstring(c)); - } - else - { - if(!allowidentaccess(id)) - { - conoutf("not allowed in this execution context: %s", id->name); - scripterr(); - continue; - } + ident *id = idents->access(c); + if(!id) + { + if(!isdigit(*c) && ((*c!='+' && *c!='-' && *c!='.') || !isdigit(c[1]))) + { + conoutf("unknown command: %s", c); + scripterr(); + } + setretval(newstring(c)); + } + else + { + if(!allowidentaccess(id)) + { + conoutf("not allowed in this execution context: %s", id->name); + scripterr(); + continue; + } - switch(id->type) - { - case ID_COMMAND: // game defined commands - switch(id->narg) // use very ad-hoc function signature, and just call it - { - case ARG_1INT: ((void (__cdecl *)(int))id->fun)(ATOI(w[1])); break; - case ARG_2INT: ((void (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2])); break; - case ARG_3INT: ((void (__cdecl *)(int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3])); break; - case ARG_4INT: ((void (__cdecl *)(int, int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3]), ATOI(w[4])); break; - case ARG_NONE: ((void (__cdecl *)())id->fun)(); break; - case ARG_1STR: ((void (__cdecl *)(char *))id->fun)(w[1]); break; - case ARG_2STR: ((void (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; - case ARG_3STR: ((void (__cdecl *)(char *, char *, char*))id->fun)(w[1], w[2], w[3]); break; - case ARG_4STR: ((void (__cdecl *)(char *, char *, char*, char*))id->fun)(w[1], w[2], w[3], w[4]); break; - case ARG_5STR: ((void (__cdecl *)(char *, char *, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5]); break; - case ARG_6STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6]); break; - case ARG_7STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6], w[7]); break; - case ARG_8STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6], w[7], w[8]); break; + switch(id->type) + { + case ID_COMMAND: // game defined commands + switch(id->narg) // use very ad-hoc function signature, and just call it + { + case ARG_1INT: ((void (__cdecl *)(int))id->fun)(ATOI(w[1])); break; + case ARG_2INT: ((void (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2])); break; + case ARG_3INT: ((void (__cdecl *)(int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3])); break; + case ARG_4INT: ((void (__cdecl *)(int, int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3]), ATOI(w[4])); break; + case ARG_NONE: ((void (__cdecl *)())id->fun)(); break; + case ARG_1STR: ((void (__cdecl *)(char *))id->fun)(w[1]); break; + case ARG_2STR: ((void (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; + case ARG_3STR: ((void (__cdecl *)(char *, char *, char*))id->fun)(w[1], w[2], w[3]); break; + case ARG_4STR: ((void (__cdecl *)(char *, char *, char*, char*))id->fun)(w[1], w[2], w[3], w[4]); break; + case ARG_5STR: ((void (__cdecl *)(char *, char *, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5]); break; + case ARG_6STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6]); break; + case ARG_7STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6], w[7]); break; + case ARG_8STR: ((void (__cdecl *)(char *, char *, char*, char*, char*, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5], w[6], w[7], w[8]); break; #ifndef STANDALONE - case ARG_DOWN: ((void (__cdecl *)(bool))id->fun)(addreleaseaction(id->name)!=NULL); break; + case ARG_DOWN: ((void (__cdecl *)(bool))id->fun)(addreleaseaction(id->name)!=NULL); break; #endif - case ARG_1EXP: intret(((int (__cdecl *)(int))id->fun)(ATOI(w[1]))); break; - case ARG_2EXP: intret(((int (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2]))); break; - case ARG_1EXPF: floatret(((float (__cdecl *)(float))id->fun)(atof(w[1]))); break; - case ARG_2EXPF: floatret(((float (__cdecl *)(float, float))id->fun)(atof(w[1]), atof(w[2]))); break; - case ARG_1EST: intret(((int (__cdecl *)(char *))id->fun)(w[1])); break; - case ARG_2EST: intret(((int (__cdecl *)(char *, char *))id->fun)(w[1], w[2])); break; - case ARG_IVAL: intret(((int (__cdecl *)())id->fun)()); break; - case ARG_FVAL: floatret(((float (__cdecl *)())id->fun)()); break; - case ARG_SVAL: result(((const char * (__cdecl *)())id->fun)()); break; - case ARG_VARI: ((void (__cdecl *)(char **, int))id->fun)(&w[1], numargs-1); break; - case ARG_CONC: - case ARG_CONCW: - { - char *r = conc(w+1, numargs-1, id->narg==ARG_CONC); - ((void (__cdecl *)(char *))id->fun)(r); - delete[] r; - break; - } - } - setretval(commandret); - commandret = NULL; - break; + case ARG_1EXP: intret(((int (__cdecl *)(int))id->fun)(ATOI(w[1]))); break; + case ARG_2EXP: intret(((int (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2]))); break; + case ARG_1EXPF: floatret(((float (__cdecl *)(float))id->fun)(atof(w[1]))); break; + case ARG_2EXPF: floatret(((float (__cdecl *)(float, float))id->fun)(atof(w[1]), atof(w[2]))); break; + case ARG_1EST: intret(((int (__cdecl *)(char *))id->fun)(w[1])); break; + case ARG_2EST: intret(((int (__cdecl *)(char *, char *))id->fun)(w[1], w[2])); break; + case ARG_IVAL: intret(((int (__cdecl *)())id->fun)()); break; + case ARG_FVAL: floatret(((float (__cdecl *)())id->fun)()); break; + case ARG_SVAL: result(((const char * (__cdecl *)())id->fun)()); break; + case ARG_VARI: ((void (__cdecl *)(char **, int))id->fun)(&w[1], numargs-1); break; + case ARG_CONC: + case ARG_CONCW: + { + char *r = conc(w+1, numargs-1, id->narg==ARG_CONC); + ((void (__cdecl *)(char *))id->fun)(r); + delete[] r; + break; + } + } + setretval(commandret); + commandret = NULL; + break; - case ID_VAR: // game defined variables - if(!w[1][0]) conoutf("%s = %d", c, *id->storage.i); // var with no value just prints its current value - else if(id->minval>id->maxval) conoutf("variable %s is read-only", id->name); - else - { - int i1 = ATOI(w[1]); - if(i1minval || i1>id->maxval) - { - i1 = i1minval ? id->minval : id->maxval; // clamp to valid range - conoutf("valid range for %s is %d..%d", id->name, id->minval, id->maxval); - } - *id->storage.i = i1; - if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available - } - break; + case ID_VAR: // game defined variables + if(!w[1][0]) conoutf("%s = %d", c, *id->storage.i); // var with no value just prints its current value + else if(id->minval>id->maxval) conoutf("variable %s is read-only", id->name); + else + { + int i1 = ATOI(w[1]); + if(i1minval || i1>id->maxval) + { + i1 = i1minval ? id->minval : id->maxval; // clamp to valid range + conoutf("valid range for %s is %d..%d", id->name, id->minval, id->maxval); + } + *id->storage.i = i1; + if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available + } + break; - case ID_FVAR: // game defined variables - if(!w[1][0]) conoutf("%s = %s", c, floatstr(*id->storage.f)); // var with no value just prints its current value - else if(id->minvalf>id->maxvalf) conoutf("variable %s is read-only", id->name); - else - { - float f1 = atof(w[1]); - if(f1minvalf || f1>id->maxvalf) - { - f1 = f1minvalf ? id->minvalf : id->maxvalf; // clamp to valid range - conoutf("valid range for %s is %s..%s", id->name, floatstr(id->minvalf), floatstr(id->maxvalf)); - //scripterr(); // Why throw this error here when it's not done for ID_VAR above? Only difference is datatype, both are "valid range errors". // Bukz 2011june04 - } - *id->storage.f = f1; - if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available - } - break; + case ID_FVAR: // game defined variables + if(!w[1][0]) conoutf("%s = %s", c, floatstr(*id->storage.f)); // var with no value just prints its current value + else if(id->minvalf>id->maxvalf) conoutf("variable %s is read-only", id->name); + else + { + float f1 = atof(w[1]); + if(f1minvalf || f1>id->maxvalf) + { + f1 = f1minvalf ? id->minvalf : id->maxvalf; // clamp to valid range + conoutf("valid range for %s is %s..%s", id->name, floatstr(id->minvalf), floatstr(id->maxvalf)); + //scripterr(); // Why throw this error here when it's not done for ID_VAR above? Only difference is datatype, both are "valid range errors". // Bukz 2011june04 + } + *id->storage.f = f1; + if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available + } + break; - case ID_SVAR: // game defined variables - if(!w[1][0]) conoutf(strchr(*id->storage.s, '"') ? "%s = [%s]" : "%s = \"%s\"", c, *id->storage.s); // var with no value just prints its current value - else - { - *id->storage.s = exchangestr(*id->storage.s, newstring(w[1])); - if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available - } - break; + case ID_SVAR: // game defined variables + if(!w[1][0]) conoutf(strchr(*id->storage.s, '"') ? "%s = [%s]" : "%s = \"%s\"", c, *id->storage.s); // var with no value just prints its current value + else + { + *id->storage.s = exchangestr(*id->storage.s, newstring(w[1])); + if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available + } + break; - case ID_ALIAS: // alias, also used as functions and (global) variables - delete[] w[0]; - static vector argids; - for(int i = 1; i argids.length()) - { - defformatstring(argname)("arg%d", i); - argids.add(newident(argname, IEXC_CORE)); - } - pushident(*argids[i-1], w[i]); // set any arguments as (global) arg values so functions can access them - } - _numargs = numargs-1; - char *wasexecuting = id->executing; - id->executing = id->action; - setretval(executeret(id->action)); - if(id->executing!=id->action && id->executing!=wasexecuting) delete[] id->executing; - id->executing = wasexecuting; - for(int i = 1; i argids; + for(int i = 1; i argids.length()) + { + defformatstring(argname)("arg%d", i); + argids.add(newident(argname, IEXC_CORE)); + } + pushident(*argids[i-1], w[i]); // set any arguments as (global) arg values so functions can access them + } + _numargs = numargs-1; + char *wasexecuting = id->executing; + id->executing = id->action; + setretval(executeret(id->action)); + if(id->executing!=id->action && id->executing!=wasexecuting) delete[] id->executing; + id->executing = wasexecuting; + for(int i = 1; iaddress.host; - formatstring(r)("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); - break; - } - case 2: // HOST - { - char hn[1024]; - formatstring(r)("%s", (enet_address_get_host(&curpeer->address, hn, sizeof(hn))==0) ? hn : "unknown"); - break; - } - case 3: // PORT - { - formatstring(r)("%d", curpeer->address.port); - break; - } - case 4: // STATE - { + formatstring(r)("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + break; + } + case 2: // HOST + { + char hn[1024]; + formatstring(r)("%s", (enet_address_get_host(&curpeer->address, hn, sizeof(hn))==0) ? hn : "unknown"); + break; + } + case 3: // PORT + { + formatstring(r)("%d", curpeer->address.port); + break; + } + case 4: // STATE + { const char *statenames[] = { "disconnected", @@ -1589,27 +1588,27 @@ const char *currentserver(int i) // [client version] }; if(curpeer->state>=0 && curpeer->statestate]); - break; // 5 == Connected (compare ../enet/include/enet/enet.h +165) - } - // CAUTION: the following are only filled if the serverbrowser was used or the scoreboard shown - // SERVERNAME - case 5: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->name); break; } - // DESCRIPTION (3) - case 6: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->sdesc); break; } - case 7: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->description); break; } - // CAUTION: the following is only the last full-description _seen_ in the serverbrowser! - case 8: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->full); break; } - // just IP & PORT as default response - always available, no lookup-delay either - default: - { + break; // 5 == Connected (compare ../enet/include/enet/enet.h +165) + } + // CAUTION: the following are only filled if the serverbrowser was used or the scoreboard shown + // SERVERNAME + case 5: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->name); break; } + // DESCRIPTION (3) + case 6: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->sdesc); break; } + case 7: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->description); break; } + // CAUTION: the following is only the last full-description _seen_ in the serverbrowser! + case 8: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->full); break; } + // just IP & PORT as default response - always available, no lookup-delay either + default: + { uchar *ip = (uchar *)&curpeer->address.host; - formatstring(r)("%d.%d.%d.%d %d", ip[0], ip[1], ip[2], ip[3], curpeer->address.port); - break; - } - } - } - copystring(curSRVinfo, r); - return curSRVinfo; + formatstring(r)("%d.%d.%d.%d %d", ip[0], ip[1], ip[2], ip[3], curpeer->address.port); + break; + } + } + } + copystring(curSRVinfo, r); + return curSRVinfo; } COMMANDF(curserver, ARG_1INT, (int i) { result(currentserver(i)); }); diff --git a/source/src/console.cpp b/source/src/console.cpp index 1b949fbd..419953f1 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -313,11 +313,11 @@ void pasteconsole(char *dst) concatstring(dst, cb); GlobalUnlock(cb); CloseClipboard(); - #elif defined(__APPLE__) - extern void mac_pasteconsole(char *commandbuf); + #elif defined(__APPLE__) + extern void mac_pasteconsole(char *commandbuf); - mac_pasteconsole(dst); - #else + mac_pasteconsole(dst); + #else SDL_SysWMinfo wminfo; SDL_VERSION(&wminfo.version); wminfo.subsystem = SDL_SYSWM_X11; diff --git a/source/src/cube.h b/source/src/cube.h index 2634c680..b74d0bd5 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -50,7 +50,7 @@ extern int hwtexsize, hwmaxaniso; extern int numspawn[3], maploaded, numflagspawn[2]; extern int verbose; -#include "protos.h" // external function decls +#include "protos.h" // external function decls #define AC_VERSION 1111 #define AC_MASTER_URI "assault.cubers.net" diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 44ed2523..429be5d1 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -43,7 +43,7 @@ void toggleedit(bool force) else { //put call to clear/restart gamemode - player1->attacking = false; + player1->attacking = false; } keyrepeat(editmode); selset = false; @@ -255,15 +255,15 @@ void paste() // Count the walls of type "type" contained in the current selection int countwalls(int type) { - int counter = 0; - EDITSELMP 0; - if(type < 0 || type >= MAXTYPE) - { - conoutf("invalid type"); - return 0; - } - loopselxy(if(s->type==type) counter++) - return counter; + int counter = 0; + EDITSELMP 0; + if(type < 0 || type >= MAXTYPE) + { + conoutf("invalid type"); + return 0; + } + loopselxy(if(s->type==type) counter++) + return counter; } void tofronttex() // maintain most recently used of the texture lists when applying texture diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 9141f967..040ab779 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -80,22 +80,22 @@ COMMAND(showedithide, ARG_NONE); void setedithide(char *text) // FIXME: human indexing inside { eh_ents.setsize(0); - if(text && text[0] != '\0') - { - const char *s = strtok(text, " "); - do - { - bool k = false; - int sn = -1; - int tn = atoi(s); - loopi(MAXENTTYPES) if(!strcmp(entnames[i], s)) sn = i; - if(sn!=-1) { loopv(eh_ents) { if(eh_ents[i]==sn) { k = true; } } } - else sn = tn; - if(!k) { if(sn>0 && sn0 && snspawned = false; - f.ack = false; - addmsg(SV_FLAGACTION, "rii", FA_RETURN, f.team); + flaginfo &f = flaginfos[fln]; + f.flagent->spawned = false; + f.ack = false; + addmsg(SV_FLAGACTION, "rii", FA_RETURN, f.team); } void flagscore(int fln) { - flaginfo &f = flaginfos[fln]; - f.ack = false; - addmsg(SV_FLAGACTION, "rii", FA_SCORE, f.team); + flaginfo &f = flaginfos[fln]; + f.ack = false; + addmsg(SV_FLAGACTION, "rii", FA_SCORE, f.team); } // flag ent actions from the net void flagstolen(int flag, int act) { - playerent *actor = act == getclientnum() ? player1 : getclient(act); - flaginfo &f = flaginfos[flag]; - f.actor = actor; // could be NULL if we just connected - f.actor_cn = act; - f.flagent->spawned = false; - f.ack = true; + playerent *actor = act == getclientnum() ? player1 : getclient(act); + flaginfo &f = flaginfos[flag]; + f.actor = actor; // could be NULL if we just connected + f.actor_cn = act; + f.flagent->spawned = false; + f.ack = true; } void flagdropped(int flag, float x, float y, float z) { - flaginfo &f = flaginfos[flag]; + flaginfo &f = flaginfos[flag]; if(OUTBORD(x, y)) return; // valid pos bounceent p; p.rotspeed = 0.0f; @@ -555,23 +555,23 @@ void flagdropped(int flag, float x, float y, float z) f.pos.y = round(p.o.y); f.pos.z = round(p.o.z); if(f.pos.z < hdr.waterlevel) f.pos.z = (short) hdr.waterlevel; - f.flagent->spawned = true; - f.ack = true; + f.flagent->spawned = true; + f.ack = true; } void flaginbase(int flag) { - flaginfo &f = flaginfos[flag]; - f.actor = NULL; f.actor_cn = -1; + flaginfo &f = flaginfos[flag]; + f.actor = NULL; f.actor_cn = -1; f.pos = vec(f.flagent->x, f.flagent->y, f.flagent->z); - f.flagent->spawned = true; - f.ack = true; + f.flagent->spawned = true; + f.ack = true; } void flagidle(int flag) { flaginbase(flag); - flaginfos[flag].flagent->spawned = false; + flaginfos[flag].flagent->spawned = false; } void entstats(void) diff --git a/source/src/entity.h b/source/src/entity.h index 7bf09915..7c3cc24f 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -356,23 +356,23 @@ public: // 4-level armour - tiered approach: 16%, 33%, 37%, 41% // Please update ./ac_website/htdocs/docs/introduction.html if this changes. int armoursection = 0; - int ad = damage; - if(armour > 25) armoursection = 1; - if(armour > 50) armoursection = 2; - if(armour > 75) armoursection = 3; - switch(armoursection) - { - case 0: ad = (int) (16.0f/25.0f * armour); break; // 16 - case 1: ad = (int) (17.0f/25.0f * armour) - 1; break; // 33 - case 2: ad = (int) (4.0f/25.0f * armour) + 25; break; // 37 - case 3: ad = (int) (4.0f/25.0f * armour) + 25; break; // 41 - default: break; - } - int rd = (int) (ad * damage/100.0f); - armour -= rd; - damage -= rd; - health -= damage; - return damage; + int ad = damage; + if(armour > 25) armoursection = 1; + if(armour > 50) armoursection = 2; + if(armour > 75) armoursection = 3; + switch(armoursection) + { + case 0: ad = (int) (16.0f/25.0f * armour); break; // 16 + case 1: ad = (int) (17.0f/25.0f * armour) - 1; break; // 33 + case 2: ad = (int) (4.0f/25.0f * armour) + 25; break; // 37 + case 3: ad = (int) (4.0f/25.0f * armour) + 25; break; // 41 + default: break; + } + int rd = (int) (ad * damage/100.0f); + armour -= rd; + damage -= rd; + health -= damage; + return damage; } }; @@ -618,7 +618,7 @@ struct medalsst {bool assigned; int cn; int item;}; extern char killmessages[2][NUMGUNS][MAXKILLMSGLEN]; inline const char *killmessage(int gun, bool gib = false) { - if(gun<0 || gun>=NUMGUNS) return ""; + if(gun<0 || gun>=NUMGUNS) return ""; return killmessages[gib?1:0][gun]; } diff --git a/source/src/hudgun.h b/source/src/hudgun.h index 76ce22d4..54c8eaf5 100644 --- a/source/src/hudgun.h +++ b/source/src/hudgun.h @@ -13,7 +13,7 @@ struct weaponmove vec pos; int anim, basetime; - weaponmove() : k_rot(0), kick(0), anim(0), basetime(0) { pos.x = pos.y = pos.z = 0.0f; } + weaponmove() : k_rot(0), kick(0), anim(0), basetime(0) { pos.x = pos.y = pos.z = 0.0f; } void calcmove(vec aimdir, int lastaction, playerent *p) { diff --git a/source/src/i18n.h b/source/src/i18n.h index ab2bd12a..79ae6aa4 100644 --- a/source/src/i18n.h +++ b/source/src/i18n.h @@ -3,15 +3,15 @@ // localization manager struct i18nmanager { - const char *domain; + const char *domain; const char *basepath; - char *locale; + char *locale; - i18nmanager(const char *domain, const char *basepath); // initialize locale system - + i18nmanager(const char *domain, const char *basepath); // initialize locale system + }; enum { CF_NONE = 0, CF_OK, CF_FAIL, CF_SIZE }; -#define FONTSTART 33 -#define FONTCHARS 94 +#define FONTSTART 33 +#define FONTCHARS 94 diff --git a/source/src/jpegenc.h b/source/src/jpegenc.h index 787a4d74..8478930a 100644 --- a/source/src/jpegenc.h +++ b/source/src/jpegenc.h @@ -224,7 +224,7 @@ class jpegenc void init_all(int qfactor); public: - jpegenc() + jpegenc() { bytenew = 0; bytepos = 7; @@ -356,65 +356,65 @@ WORD jpegenc::mask[16] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 409 void jpegenc::write_APP0info() //Nothing to overwrite for APP0info { - writeword(APP0info.marker); - writeword(APP0info.length); - writebyte('J'); - writebyte('F'); - writebyte('I'); - writebyte('F'); - writebyte(0); - writebyte(APP0info.versionhi); - writebyte(APP0info.versionlo); - writebyte(APP0info.xyunits); - writeword(APP0info.xdensity); - writeword(APP0info.ydensity); - writebyte(APP0info.thumbnwidth); - writebyte(APP0info.thumbnheight); + writeword(APP0info.marker); + writeword(APP0info.length); + writebyte('J'); + writebyte('F'); + writebyte('I'); + writebyte('F'); + writebyte(0); + writebyte(APP0info.versionhi); + writebyte(APP0info.versionlo); + writebyte(APP0info.xyunits); + writeword(APP0info.xdensity); + writeword(APP0info.ydensity); + writebyte(APP0info.thumbnwidth); + writebyte(APP0info.thumbnheight); } void jpegenc::write_SOF0info() { - writeword(SOF0info.marker); - writeword(SOF0info.length); - writebyte(SOF0info.precision); - writeword(SOF0info.height); //Image height - writeword(SOF0info.width); //Image width - writebyte(SOF0info.nrofcomponents); - writebyte(SOF0info.IdY); - writebyte(SOF0info.HVY); - writebyte(SOF0info.QTY); - writebyte(SOF0info.IdCb); - writebyte(SOF0info.HVCb); - writebyte(SOF0info.QTCb); - writebyte(SOF0info.IdCr); - writebyte(SOF0info.HVCr); - writebyte(SOF0info.QTCr); + writeword(SOF0info.marker); + writeword(SOF0info.length); + writebyte(SOF0info.precision); + writeword(SOF0info.height); //Image height + writeword(SOF0info.width); //Image width + writebyte(SOF0info.nrofcomponents); + writebyte(SOF0info.IdY); + writebyte(SOF0info.HVY); + writebyte(SOF0info.QTY); + writebyte(SOF0info.IdCb); + writebyte(SOF0info.HVCb); + writebyte(SOF0info.QTCb); + writebyte(SOF0info.IdCr); + writebyte(SOF0info.HVCr); + writebyte(SOF0info.QTCr); } void jpegenc::write_DQTinfo() { - BYTE i; - writeword(DQTinfo.marker); - writeword(DQTinfo.length); - writebyte(DQTinfo.QTYinfo); - for (i=0; i<64; i++) + BYTE i; + writeword(DQTinfo.marker); + writeword(DQTinfo.length); + writebyte(DQTinfo.QTYinfo); + for (i=0; i<64; i++) writebyte(DQTinfo.Ytable[i]); - writebyte(DQTinfo.QTCbinfo); + writebyte(DQTinfo.QTCbinfo); for (i=0; i<64; i++) writebyte(DQTinfo.Cbtable[i]); } void jpegenc::set_quant_table(BYTE *basic_table, BYTE scale_factor, BYTE *newtable) { - BYTE i; - long temp; - for (i=0; i<64; i++) - { - temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; - if (temp <= 0L) temp = 1L; - if (temp > 255L) temp = 255L; - newtable[zigzag[i]] = (BYTE) temp; - } + BYTE i; + long temp; + for (i=0; i<64; i++) + { + temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; + if (temp <= 0L) temp = 1L; + if (temp > 255L) temp = 255L; + newtable[zigzag[i]] = (BYTE) temp; + } } void jpegenc::set_DQTinfo(int quality) @@ -424,395 +424,395 @@ void jpegenc::set_DQTinfo(int quality) if (quality > 100) quality = 100; if (quality < 50) quality = 5000 / quality; else quality = 200 - quality*2; - DQTinfo.marker = 0xFFDB; - DQTinfo.length = 132; - DQTinfo.QTYinfo = 0; - DQTinfo.QTCbinfo = 1; - set_quant_table(std_luminance_qt, quality, DQTinfo.Ytable); - set_quant_table(std_chrominance_qt, quality, DQTinfo.Cbtable); + DQTinfo.marker = 0xFFDB; + DQTinfo.length = 132; + DQTinfo.QTYinfo = 0; + DQTinfo.QTCbinfo = 1; + set_quant_table(std_luminance_qt, quality, DQTinfo.Ytable); + set_quant_table(std_chrominance_qt, quality, DQTinfo.Cbtable); } void jpegenc::write_DHTinfo() { - BYTE i; - writeword(DHTinfo.marker); - writeword(DHTinfo.length); - writebyte(DHTinfo.HTYDCinfo); - for (i=0; i<16; i++) - writebyte(DHTinfo.YDC_nrcodes[i]); - for (i=0; i<12; i++) - writebyte(DHTinfo.YDC_values[i]); - writebyte(DHTinfo.HTYACinfo); - for (i=0; i<16; i++) - writebyte(DHTinfo.YAC_nrcodes[i]); - for (i=0; i<162; i++) - writebyte(DHTinfo.YAC_values[i]); - writebyte(DHTinfo.HTCbDCinfo); - for (i=0; i<16; i++) - writebyte(DHTinfo.CbDC_nrcodes[i]); - for (i=0; i<12; i++) - writebyte(DHTinfo.CbDC_values[i]); - writebyte(DHTinfo.HTCbACinfo); - for (i=0; i<16; i++) - writebyte(DHTinfo.CbAC_nrcodes[i]); - for (i=0; i<162; i++) - writebyte(DHTinfo.CbAC_values[i]); + BYTE i; + writeword(DHTinfo.marker); + writeword(DHTinfo.length); + writebyte(DHTinfo.HTYDCinfo); + for (i=0; i<16; i++) + writebyte(DHTinfo.YDC_nrcodes[i]); + for (i=0; i<12; i++) + writebyte(DHTinfo.YDC_values[i]); + writebyte(DHTinfo.HTYACinfo); + for (i=0; i<16; i++) + writebyte(DHTinfo.YAC_nrcodes[i]); + for (i=0; i<162; i++) + writebyte(DHTinfo.YAC_values[i]); + writebyte(DHTinfo.HTCbDCinfo); + for (i=0; i<16; i++) + writebyte(DHTinfo.CbDC_nrcodes[i]); + for (i=0; i<12; i++) + writebyte(DHTinfo.CbDC_values[i]); + writebyte(DHTinfo.HTCbACinfo); + for (i=0; i<16; i++) + writebyte(DHTinfo.CbAC_nrcodes[i]); + for (i=0; i<162; i++) + writebyte(DHTinfo.CbAC_values[i]); } void jpegenc::set_DHTinfo() { - BYTE i; - DHTinfo.marker = 0xFFC4; - DHTinfo.length = 0x01A2; - DHTinfo.HTYDCinfo = 0; - for (i=0; i<16; i++) - DHTinfo.YDC_nrcodes[i] = std_dc_luminance_nrcodes[i+1]; - for (i=0; i<12; i++) - DHTinfo.YDC_values[i] = std_dc_luminance_values[i]; - DHTinfo.HTYACinfo = 0x10; - for (i=0; i<16; i++) - DHTinfo.YAC_nrcodes[i] = std_ac_luminance_nrcodes[i+1]; - for (i=0; i<162; i++) - DHTinfo.YAC_values[i] = std_ac_luminance_values[i]; - DHTinfo.HTCbDCinfo = 1; - for (i=0; i<16; i++) - DHTinfo.CbDC_nrcodes[i] = std_dc_chrominance_nrcodes[i+1]; - for (i=0; i<12; i++) - DHTinfo.CbDC_values[i] = std_dc_chrominance_values[i]; - DHTinfo.HTCbACinfo = 0x11; - for (i=0; i<16; i++) - DHTinfo.CbAC_nrcodes[i] = std_ac_chrominance_nrcodes[i+1]; - for (i=0; i<162; i++) - DHTinfo.CbAC_values[i] = std_ac_chrominance_values[i]; + BYTE i; + DHTinfo.marker = 0xFFC4; + DHTinfo.length = 0x01A2; + DHTinfo.HTYDCinfo = 0; + for (i=0; i<16; i++) + DHTinfo.YDC_nrcodes[i] = std_dc_luminance_nrcodes[i+1]; + for (i=0; i<12; i++) + DHTinfo.YDC_values[i] = std_dc_luminance_values[i]; + DHTinfo.HTYACinfo = 0x10; + for (i=0; i<16; i++) + DHTinfo.YAC_nrcodes[i] = std_ac_luminance_nrcodes[i+1]; + for (i=0; i<162; i++) + DHTinfo.YAC_values[i] = std_ac_luminance_values[i]; + DHTinfo.HTCbDCinfo = 1; + for (i=0; i<16; i++) + DHTinfo.CbDC_nrcodes[i] = std_dc_chrominance_nrcodes[i+1]; + for (i=0; i<12; i++) + DHTinfo.CbDC_values[i] = std_dc_chrominance_values[i]; + DHTinfo.HTCbACinfo = 0x11; + for (i=0; i<16; i++) + DHTinfo.CbAC_nrcodes[i] = std_ac_chrominance_nrcodes[i+1]; + for (i=0; i<162; i++) + DHTinfo.CbAC_values[i] = std_ac_chrominance_values[i]; } void jpegenc::write_SOSinfo() //Nothing to overwrite for SOSinfo { - writeword(SOSinfo.marker); - writeword(SOSinfo.length); - writebyte(SOSinfo.nrofcomponents); - writebyte(SOSinfo.IdY); - writebyte(SOSinfo.HTY); - writebyte(SOSinfo.IdCb); - writebyte(SOSinfo.HTCb); - writebyte(SOSinfo.IdCr); - writebyte(SOSinfo.HTCr); - writebyte(SOSinfo.Ss); - writebyte(SOSinfo.Se); - writebyte(SOSinfo.Bf); + writeword(SOSinfo.marker); + writeword(SOSinfo.length); + writebyte(SOSinfo.nrofcomponents); + writebyte(SOSinfo.IdY); + writebyte(SOSinfo.HTY); + writebyte(SOSinfo.IdCb); + writebyte(SOSinfo.HTCb); + writebyte(SOSinfo.IdCr); + writebyte(SOSinfo.HTCr); + writebyte(SOSinfo.Ss); + writebyte(SOSinfo.Se); + writebyte(SOSinfo.Bf); } void jpegenc::write_comment(BYTE *comment) { - WORD i, length; - writeword(0xFFFE); - length = strlen((const char *)comment); - writeword(length + 2); - for (i=0; i= 0) - { - if (value & mask[posval]) - bytenew |= mask[bytepos]; - posval--; - bytepos--; - if (bytepos < 0) - { - if (bytenew == 0xFF) - { - writebyte(0xFF); - writebyte(0); - } - else writebyte(bytenew); + WORD value; + SBYTE posval; + value = bs.value; + posval = bs.length - 1; + while (posval >= 0) + { + if (value & mask[posval]) + bytenew |= mask[bytepos]; + posval--; + bytepos--; + if (bytepos < 0) + { + if (bytenew == 0xFF) + { + writebyte(0xFF); + writebyte(0); + } + else writebyte(bytenew); - bytepos = 7; - bytenew = 0; - } - } + bytepos = 7; + bytenew = 0; + } + } } void jpegenc::compute_Huffman_table(BYTE *nrcodes, BYTE *std_table, bitstring *HT) { - BYTE k,j; - BYTE pos_in_table; - WORD codevalue; - codevalue = 0; - pos_in_table = 0; - for (k=1; k<=16; k++) - { - for (j=1; j<=nrcodes[k]; j++) - { - HT[std_table[pos_in_table]].value = codevalue; - HT[std_table[pos_in_table]].length = k; - pos_in_table++; - codevalue++; - } - codevalue <<= 1; - } + BYTE k,j; + BYTE pos_in_table; + WORD codevalue; + codevalue = 0; + pos_in_table = 0; + for (k=1; k<=16; k++) + { + for (j=1; j<=nrcodes[k]; j++) + { + HT[std_table[pos_in_table]].value = codevalue; + HT[std_table[pos_in_table]].length = k; + pos_in_table++; + codevalue++; + } + codevalue <<= 1; + } } void jpegenc::init_Huffman_tables() { - compute_Huffman_table(std_dc_luminance_nrcodes, std_dc_luminance_values, YDC_HT); - compute_Huffman_table(std_ac_luminance_nrcodes, std_ac_luminance_values, YAC_HT); - compute_Huffman_table(std_dc_chrominance_nrcodes, std_dc_chrominance_values, CbDC_HT); - compute_Huffman_table(std_ac_chrominance_nrcodes, std_ac_chrominance_values, CbAC_HT); + compute_Huffman_table(std_dc_luminance_nrcodes, std_dc_luminance_values, YDC_HT); + compute_Huffman_table(std_ac_luminance_nrcodes, std_ac_luminance_values, YAC_HT); + compute_Huffman_table(std_dc_chrominance_nrcodes, std_dc_chrominance_values, CbDC_HT); + compute_Huffman_table(std_ac_chrominance_nrcodes, std_ac_chrominance_values, CbAC_HT); } void jpegenc::exitmessage(const char *error_message) { - printf("%s\n",error_message); - exit(EXIT_FAILURE); + printf("%s\n",error_message); + exit(EXIT_FAILURE); } void jpegenc::set_numbers_category_and_bitcode() { - SDWORD nr; - SDWORD nrlower, nrupper; - BYTE cat; - category_alloc = (BYTE *)malloc(65535*sizeof(BYTE)); - if (category_alloc == NULL) exitmessage("Not enough memory."); - category = category_alloc + 32767; - bitcode_alloc=(bitstring *)malloc(65535*sizeof(bitstring)); - if (bitcode_alloc==NULL) exitmessage("Not enough memory."); - bitcode = bitcode_alloc + 32767; - nrlower = 1; - nrupper = 2; - for (cat=1; cat<=15; cat++) - { - for (nr=nrlower; nr= 0; ctr--) - { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - dataptr[0] = tmp10 + tmp11; - dataptr[4] = tmp10 - tmp11; - z1 = (tmp12 + tmp13) * ((float) 0.707106781); - dataptr[2] = tmp13 + z1; - dataptr[6] = tmp13 - z1; - tmp10 = tmp4 + tmp5; - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - z5 = (tmp10 - tmp12) * ((float) 0.382683433); - z2 = ((float) 0.541196100) * tmp10 + z5; - z4 = ((float) 1.306562965) * tmp12 + z5; - z3 = tmp11 * ((float) 0.707106781); - z11 = tmp7 + z3; - z13 = tmp7 - z3; - dataptr[5] = z13 + z2; - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - dataptr += 8; - } - dataptr = datafloat; - for (ctr = 7; ctr >= 0; ctr--) - { - tmp0 = dataptr[0] + dataptr[56]; - tmp7 = dataptr[0] - dataptr[56]; - tmp1 = dataptr[8] + dataptr[48]; - tmp6 = dataptr[8] - dataptr[48]; - tmp2 = dataptr[16] + dataptr[40]; - tmp5 = dataptr[16] - dataptr[40]; - tmp3 = dataptr[24] + dataptr[32]; - tmp4 = dataptr[24] - dataptr[32]; - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - dataptr[0] = tmp10 + tmp11; - dataptr[32] = tmp10 - tmp11; - z1 = (tmp12 + tmp13) * ((float) 0.707106781); - dataptr[16] = tmp13 + z1; - dataptr[48] = tmp13 - z1; - tmp10 = tmp4 + tmp5; - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - z5 = (tmp10 - tmp12) * ((float) 0.382683433); - z2 = ((float) 0.541196100) * tmp10 + z5; - z4 = ((float) 1.306562965) * tmp12 + z5; - z3 = tmp11 * ((float) 0.707106781); - z11 = tmp7 + z3; - z13 = tmp7 - z3; - dataptr[40] = z13 + z2; - dataptr[24] = z13 - z2; - dataptr[8] = z11 + z4; - dataptr[56] = z11 - z4; - dataptr++; - } - for (i = 0; i < 64; i++) - { - temp = datafloat[i] * fdtbl[i]; - outdata[i] = (SWORD) ((SWORD)(temp + 16384.5) - 16384); - } + float tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + float tmp10, tmp11, tmp12, tmp13; + float z1, z2, z3, z4, z5, z11, z13; + float *dataptr; + float datafloat[64]; + float temp; + SBYTE ctr; + BYTE i; + for (i=0; i<64; i++) datafloat[i] = data[i]; + dataptr = datafloat; + for (ctr = 7; ctr >= 0; ctr--) + { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + dataptr[0] = tmp10 + tmp11; + dataptr[4] = tmp10 - tmp11; + z1 = (tmp12 + tmp13) * ((float) 0.707106781); + dataptr[2] = tmp13 + z1; + dataptr[6] = tmp13 - z1; + tmp10 = tmp4 + tmp5; + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + z5 = (tmp10 - tmp12) * ((float) 0.382683433); + z2 = ((float) 0.541196100) * tmp10 + z5; + z4 = ((float) 1.306562965) * tmp12 + z5; + z3 = tmp11 * ((float) 0.707106781); + z11 = tmp7 + z3; + z13 = tmp7 - z3; + dataptr[5] = z13 + z2; + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + dataptr += 8; + } + dataptr = datafloat; + for (ctr = 7; ctr >= 0; ctr--) + { + tmp0 = dataptr[0] + dataptr[56]; + tmp7 = dataptr[0] - dataptr[56]; + tmp1 = dataptr[8] + dataptr[48]; + tmp6 = dataptr[8] - dataptr[48]; + tmp2 = dataptr[16] + dataptr[40]; + tmp5 = dataptr[16] - dataptr[40]; + tmp3 = dataptr[24] + dataptr[32]; + tmp4 = dataptr[24] - dataptr[32]; + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + dataptr[0] = tmp10 + tmp11; + dataptr[32] = tmp10 - tmp11; + z1 = (tmp12 + tmp13) * ((float) 0.707106781); + dataptr[16] = tmp13 + z1; + dataptr[48] = tmp13 - z1; + tmp10 = tmp4 + tmp5; + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + z5 = (tmp10 - tmp12) * ((float) 0.382683433); + z2 = ((float) 0.541196100) * tmp10 + z5; + z4 = ((float) 1.306562965) * tmp12 + z5; + z3 = tmp11 * ((float) 0.707106781); + z11 = tmp7 + z3; + z13 = tmp7 - z3; + dataptr[40] = z13 + z2; + dataptr[24] = z13 - z2; + dataptr[8] = z11 + z4; + dataptr[56] = z11 - z4; + dataptr++; + } + for (i = 0; i < 64; i++) + { + temp = datafloat[i] * fdtbl[i]; + outdata[i] = (SWORD) ((SWORD)(temp + 16384.5) - 16384); + } } void jpegenc::process_DU(SBYTE *ComponentDU,float *fdtbl,SWORD *DC, bitstring *HTDC,bitstring *HTAC) { - bitstring EOB = HTAC[0x00]; - bitstring M16zeroes = HTAC[0xF0]; - BYTE i; - BYTE startpos; - BYTE end0pos; - BYTE nrzeroes; - BYTE nrmarker; - SWORD Diff; - fdct_and_quantization(ComponentDU, fdtbl, DU_DCT); - for (i=0; i<64; i++) DU[zigzag[i]]=DU_DCT[i]; - Diff = DU[0] - *DC; - *DC = DU[0]; - if (Diff == 0) writebits(HTDC[0]); - else - { - writebits(HTDC[category[Diff]]); - writebits(bitcode[Diff]); - } - for (end0pos=63; (end0pos>0)&&(DU[end0pos]==0); end0pos--) ; - i = 1; - while (i <= end0pos) - { - startpos = i; - for (; (DU[i]==0) && (i<=end0pos); i++) ; - nrzeroes = i - startpos; - if (nrzeroes >= 16) - { - for (nrmarker=1; nrmarker<=nrzeroes/16; nrmarker++) writebits(M16zeroes); - nrzeroes = nrzeroes%16; - } - writebits(HTAC[nrzeroes*16+category[DU[i]]]); - writebits(bitcode[DU[i]]); - i++; - } - if (end0pos != 63) writebits(EOB); + bitstring EOB = HTAC[0x00]; + bitstring M16zeroes = HTAC[0xF0]; + BYTE i; + BYTE startpos; + BYTE end0pos; + BYTE nrzeroes; + BYTE nrmarker; + SWORD Diff; + fdct_and_quantization(ComponentDU, fdtbl, DU_DCT); + for (i=0; i<64; i++) DU[zigzag[i]]=DU_DCT[i]; + Diff = DU[0] - *DC; + *DC = DU[0]; + if (Diff == 0) writebits(HTDC[0]); + else + { + writebits(HTDC[category[Diff]]); + writebits(bitcode[Diff]); + } + for (end0pos=63; (end0pos>0)&&(DU[end0pos]==0); end0pos--) ; + i = 1; + while (i <= end0pos) + { + startpos = i; + for (; (DU[i]==0) && (i<=end0pos); i++) ; + nrzeroes = i - startpos; + if (nrzeroes >= 16) + { + for (nrmarker=1; nrmarker<=nrzeroes/16; nrmarker++) writebits(M16zeroes); + nrzeroes = nrzeroes%16; + } + writebits(HTAC[nrzeroes*16+category[DU[i]]]); + writebits(bitcode[DU[i]]); + i++; + } + if (end0pos != 63) writebits(EOB); } void jpegenc::load_data_units_from_RGB_buffer(WORD xpos, WORD ypos) { - BYTE x, y; - BYTE pos = 0; - DWORD location; - BYTE R, G, B; - location = ypos * width + xpos; - for (y=0; y<8; y++) - { - for (x=0; x<8; x++) - { - R = RGB_buffer[location].R; - G = RGB_buffer[location].G; - B = RGB_buffer[location].B; - YDU[pos] = Y(R,G,B); - CbDU[pos] = Cb(R,G,B); - CrDU[pos] = Cr(R,G,B); - location++; - pos++; - } - location += width - 8; - } + BYTE x, y; + BYTE pos = 0; + DWORD location; + BYTE R, G, B; + location = ypos * width + xpos; + for (y=0; y<8; y++) + { + for (x=0; x<8; x++) + { + R = RGB_buffer[location].R; + G = RGB_buffer[location].G; + B = RGB_buffer[location].B; + YDU[pos] = Y(R,G,B); + CbDU[pos] = Cb(R,G,B); + CrDU[pos] = Cr(R,G,B); + location++; + pos++; + } + location += width - 8; + } } void jpegenc::main_encoder() { - SWORD DCY = 0, DCCb = 0, DCCr = 0; - WORD xpos, ypos; - for (ypos=0; ypos= 0) - { - fillbits.length = bytepos + 1; - fillbits.value = (1<<(bytepos+1)) - 1; - writebits(fillbits); - } - writeword(0xFFD9); + if (bytepos >= 0) + { + fillbits.length = bytepos + 1; + fillbits.value = (1<<(bytepos+1)) - 1; + writebits(fillbits); + } + writeword(0xFFD9); - //free(RGB_buffer); - free(category_alloc); - free(bitcode_alloc); - fclose(fp_jpeg_stream); - return 0; + //free(RGB_buffer); + free(category_alloc); + free(bitcode_alloc); + fclose(fp_jpeg_stream); + return 0; }; #endif diff --git a/source/src/master.cpp b/source/src/master.cpp index 7435f728..c11ea6ea 100644 --- a/source/src/master.cpp +++ b/source/src/master.cpp @@ -587,7 +587,7 @@ bool checkclientinput(client &c) { confauth(c, id, val); } - // :for AUTH + // :for AUTH c.inputpos = &c.input[c.inputpos] - end; memmove(c.input, end, c.inputpos); diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 71aef1af..15434344 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -435,24 +435,24 @@ struct mitemmaploadmanual : mitemmanual glEnable(GL_BLEND); if(maptitle[0]) // 2011feb09:ft: TODO - this would be better as bottom line in the menu, just need to ensure it doesn't make the menu change width all the time! { - int mlil = maploaditemlength; - string showt; - string restt; - restt[0] = '\0'; - filtertext(showt, maptitle, 1); - if(mlil && mlil != 255) // 0 && 255 are 'off' - { - int tl = strlen(showt); - if(tl>mlil) - { - int cr = 0; - int mr = min(max(0, tl-mlil), mlil); - for(cr=0;cr0) { restt[cr+1] = '\0'; showt[mlil] = '\0'; } - } - } + int mlil = maploaditemlength; + string showt; + string restt; + restt[0] = '\0'; + filtertext(showt, maptitle, 1); + if(mlil && mlil != 255) // 0 && 255 are 'off' + { + int tl = strlen(showt); + if(tl>mlil) + { + int cr = 0; + int mr = min(max(0, tl-mlil), mlil); + for(cr=0;cr0) { restt[cr+1] = '\0'; showt[mlil] = '\0'; } + } + } draw_text(showt, 1*FONTH/2, VIRTH - FONTH/2); - draw_text(restt, 3*FONTH/2, VIRTH + FONTH/2); + draw_text(restt, 3*FONTH/2, VIRTH + FONTH/2); } //if(mapstats[0]) draw_text(mapstats, x, y+ys+5*FONTH/2); } @@ -792,7 +792,7 @@ void *addmenu(const char *name, const char *title, bool allowinput, void (__cdec menu.keyfunc = keyfunc; menu.initaction = NULL; menu.usefont = NULL; - menu.allowblink = false; + menu.allowblink = false; menu.dirlist = NULL; menu.forwardkeys = forwardkeys; lastmenu = &menu; @@ -872,9 +872,9 @@ void setmenufont(char *usefont) void setmenublink(int truth) { - if(!lastmenu) return; - gmenu &m = *(gmenu *)lastmenu; - m.allowblink = truth != 0; + if(!lastmenu) return; + gmenu &m = *(gmenu *)lastmenu; + m.allowblink = truth != 0; } void menuinit(char *initaction) @@ -923,8 +923,8 @@ void menuitemmapload(char *name, char *text) { if(!lastmenu) return; string caction; - if(!text || text[0]=='\0') formatstring(caction)("map %s", name); - else formatstring(caction)("%s", text); + if(!text || text[0]=='\0') formatstring(caction)("map %s", name); + else formatstring(caction)("%s", text); lastmenu->items.add(new mitemmapload(lastmenu, newstring(name), newstring(name), newstring(caction), NULL, NULL, NULL)); } @@ -1138,7 +1138,7 @@ void rendermenumdl() glRotatef(90, -1, 0, 0); glScalef(1, -1, 1); - bool isplayermodel = !strncmp(m.mdl, "playermodels", strlen("playermodels")); + bool isplayermodel = !strncmp(m.mdl, "playermodels", strlen("playermodels")); vec pos; if(isplayermodel) pos = vec(2.0f, 1.2f, -0.4f); @@ -1159,7 +1159,7 @@ void rendermenumdl() a[0].name = "weapons/subgun/world"; a[0].tag = "tag_weapon"; } - rendermodel(isplayermodel ? "playermodels" : m.mdl, m.anim|ANIM_DYNALLOC, tex, -1, pos, yaw, 0, 0, 0, NULL, a, m.scale ? m.scale/25.0f : 1.0f); + rendermodel(isplayermodel ? "playermodels" : m.mdl, m.anim|ANIM_DYNALLOC, tex, -1, pos, yaw, 0, 0, 0, NULL, a, m.scale ? m.scale/25.0f : 1.0f); glPopMatrix(); } @@ -1248,9 +1248,9 @@ void gmenu::init() void gmenu::render() { - extern bool ignoreblinkingbit; + extern bool ignoreblinkingbit; if(usefont) pushfont(usefont); - if(!allowblink) ignoreblinkingbit = true; + if(!allowblink) ignoreblinkingbit = true; const char *t = title; if(!t) { @@ -1352,7 +1352,7 @@ void gmenu::render() } if(usefont) popfont(); // setfont("default"); - ignoreblinkingbit = false; + ignoreblinkingbit = false; } void gmenu::renderbg(int x1, int y1, int x2, int y2, bool border) diff --git a/source/src/openal.cpp b/source/src/openal.cpp index 693d573a..a55a9a36 100644 --- a/source/src/openal.cpp +++ b/source/src/openal.cpp @@ -23,7 +23,7 @@ source::~source() void source::lock() { locked = true; - DEBUG("source locked, " << lastmillis); + DEBUG("source locked, " << lastmillis); } void source::unlock() @@ -32,7 +32,7 @@ void source::unlock() owner = NULL; stop(); buffer(0); - DEBUG("source unlocked, " << lastmillis); + DEBUG("source unlocked, " << lastmillis); } void source::reset() @@ -94,10 +94,10 @@ bool source::delete_() bool source::buffer(ALuint buf_id) { alclearerr(); -#ifdef __APPLE__ // weird bug +#ifdef __APPLE__ // weird bug if (buf_id) #endif - alSourcei(id, AL_BUFFER, buf_id); + alSourcei(id, AL_BUFFER, buf_id); return !ALERR; } @@ -378,20 +378,20 @@ void alclearerr() bool alerr(bool msg, int line) { - ALenum er = alGetError(); - if(er && msg) - { - const char *desc = "unknown"; - switch(er) - { - case AL_INVALID_NAME: desc = "invalid name"; break; - case AL_INVALID_ENUM: desc = "invalid enum"; break; - case AL_INVALID_VALUE: desc = "invalid value"; break; - case AL_INVALID_OPERATION: desc = "invalid operation"; break; - case AL_OUT_OF_MEMORY: desc = "out of memory"; break; - } - if(line) conoutf("\f3OpenAL Error (%X): %s, line %d", er, desc, line); - else conoutf("\f3OpenAL Error (%X): %s", er, desc); - } + ALenum er = alGetError(); + if(er && msg) + { + const char *desc = "unknown"; + switch(er) + { + case AL_INVALID_NAME: desc = "invalid name"; break; + case AL_INVALID_ENUM: desc = "invalid enum"; break; + case AL_INVALID_VALUE: desc = "invalid value"; break; + case AL_INVALID_OPERATION: desc = "invalid operation"; break; + case AL_OUT_OF_MEMORY: desc = "out of memory"; break; + } + if(line) conoutf("\f3OpenAL Error (%X): %s, line %d", er, desc, line); + else conoutf("\f3OpenAL Error (%X): %s", er, desc); + } return er > 0; } diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 27149539..69d6490b 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -280,7 +280,7 @@ void resizephysent(physent *pl, int moveres, int curtime, float min, float max) const float speed = curtime*pl->maxspeed/(water ? 2000.0f : 1000.0f); float h = pl->eyeheightvel * speed / moveres; - loopi(moveres) + loopi(moveres) { pl->eyeheight += h; pl->o.z += h; @@ -346,7 +346,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) if(pl->onfloor) // apply friction { pl->vel.mul(fpsfric-1); - pl->vel.div(fpsfric); + pl->vel.div(fpsfric); } else // apply gravity { @@ -482,12 +482,12 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) } const float gravity = 20.0f; - float dropf = (gravity-1)+pl->timeinair/15.0f; // incorrect, but works fine + float dropf = (gravity-1)+pl->timeinair/15.0f; // incorrect, but works fine if(water) { dropf = 5; pl->timeinair = 0; } // float slowly down in water if(pl->onladder) { dropf = 0; pl->timeinair = 0; } - drop = dropf*curtime/gravity/100/moveres; // at high fps, gravity kicks in too fast - rise = speed/moveres/1.2f; // extra smoothness when lifting up stairs + drop = dropf*curtime/gravity/100/moveres; // at high fps, gravity kicks in too fast + rise = speed/moveres/1.2f; // extra smoothness when lifting up stairs if(pl->maxspeed-16.0f>0.5f) pl += 0xF0F0; } } diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index f2ed8490..28a4e261 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -782,7 +782,7 @@ void drawminimap(int w, int h) camera1->pitch = -90; camera1->yaw = 0; int orthd = 2 + gdim/2; - glViewport(2, 2, size-2, size-2); // !not wsize here + glViewport(2, 2, size-2, size-2); // !not wsize here glClearDepth(0.0); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // stencil added 2010jul22 diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 410e4ad4..feb6a22a 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -93,7 +93,7 @@ void drawscope(bool preload) { static Texture *scopetex = NULL; if(!scopetex) scopetex = textureload("packages/misc/scope.png", 3); - if(preload) return; + if(preload) return; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindTexture(GL_TEXTURE_2D, scopetex->id); glColor3ub(255, 255, 255); @@ -192,7 +192,7 @@ void drawcrosshair(playerent *p, int n, color *c, float size) if(crosshair->bpp==32) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else glBlendFunc(GL_ONE, GL_ONE); - glBindTexture(GL_TEXTURE_2D, crosshair->id); + glBindTexture(GL_TEXTURE_2D, crosshair->id); glColor3ub(255,255,255); if(c) glColor3f(c->r, c->g, c->b); else if(crosshairfx || n==CROSSHAIR_TEAMMATE) @@ -349,7 +349,7 @@ struct hudmessages : consolebuffer { if(!conlines.length()) return; glLoadIdentity(); - glOrtho(0, VIRTW*0.9f, VIRTH*0.9f, 0, -1, 1); + glOrtho(0, VIRTW*0.9f, VIRTH*0.9f, 0, -1, 1); int dispmillis = arenaintermission ? 6000 : 3000; loopi(min(conlines.length(), 3)) if(totalmillis-conlines[i].milliso).sub(mdd).mul(coordtrans).add(cod); - if(team_isactive(p->team)) drawradarent(ppv.x+displace, ppv.y+displace, p->yaw, p->state==CS_ALIVE ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player - loopv(players) // other players - { - playerent *pl = players[i]; - if(!pl || pl==p || !isteam(p->team, pl->team) || !team_isactive(pl->team)) continue; - vec rtmp = vec(pl->o).sub(mdd).mul(coordtrans).add(cod); - drawradarent(rtmp.x+displace, rtmp.y+displace, pl->yaw, pl->state==CS_ALIVE ? (isattacking(pl) ? 2 : 0) : 1, team_base(pl->team), iconsize, isattacking(pl), "%s", colorname(pl)); - } - if(m_flags) - { - glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - loopi(2) // flag items - { - flaginfo &f = flaginfos[i]; - entity *e = f.flagent; - if(!e) continue; - if(e->x == -1 && e-> y == -1) continue; // flagdummies - vec pos = vec(e->x, e->y, 0).sub(mdd).mul(coordtrans).add(cod); - vec cpos = vec(f.pos.x, f.pos.y, f.pos.z).sub(mdd).mul(coordtrans).add(cod); - drawradarent(pos.x+displace, pos.y+displace, camera1->yaw, m_ktf ? 2 : f.team, 3, iconsize, false); // draw bases - if(f.state!=CTFF_STOLEN && !(m_ktf && f.state == CTFF_IDLE)) - { - drawradarent(cpos.x+displace, cpos.y+displace, 0, 3, m_ktf ? 2 : f.team, iconsize, false); // draw on entity pos - } - if(m_ktf && f.state == CTFF_IDLE) continue; - if(f.state==CTFF_STOLEN) - { - float d2c = 1.6f * radarentsize/16.0f; - vec apos(d2c, -d2c, 0); - if(f.actor) - { - apos.add(f.actor->o); - bool tm = i != team_base(p->team); - if(m_htf) tm = !tm; - else if(m_ktf) tm = true; - if(tm) - { - apos.sub(mdd).mul(coordtrans).add(cod); - drawradarent(apos.x+displace, apos.y+displace, 0, 3, m_ktf ? 2 : f.team, iconsize, true); // draw near flag thief - } - } - } - } - } - glEnable(GL_BLEND); - glPopMatrix(); + vec centerpos(VIRTW/2 , VIRTH/2, 0.0f); + if(showmapbackdrop) + { + glDisable(GL_TEXTURE_2D); + if(showmapbackdrop==2) glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_COLOR); + loopi(2) + { + int cg = i?(showmapbackdrop==2?((int)(255*(100-showmapbackdroptransparency)/100.0f)):0):(showmapbackdrop==2?((int)(255*(100-showmapbackdroptransparency)/100.0f)):64); + int co = i?0:4; + glColor3ub(cg, cg, cg); + glBegin(GL_QUADS); + glVertex2f( centerpos.x - halfviewsize - co, centerpos.y + halfviewsize + co); + glVertex2f( centerpos.x + halfviewsize + co, centerpos.y + halfviewsize + co); + glVertex2f( centerpos.x + halfviewsize + co, centerpos.y - halfviewsize - co); + glVertex2f( centerpos.x - halfviewsize - co, centerpos.y - halfviewsize - co); + glEnd(); + } + glColor3ub(255,255,255); + glEnable(GL_TEXTURE_2D); + } + glTranslatef(centerpos.x - halfviewsize, centerpos.y - halfviewsize , 0); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); + quad(minimaptex, 0, 0, radarviewsize, 0.0f, 0.0f, 1.0f); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_BLEND); + vec mdd(mapdims[0], mapdims[1], 0); + vec cod(offx+0.5f, offy+0.5f, 0); + vec ppv = vec(p->o).sub(mdd).mul(coordtrans).add(cod); + if(team_isactive(p->team)) drawradarent(ppv.x+displace, ppv.y+displace, p->yaw, p->state==CS_ALIVE ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player + loopv(players) // other players + { + playerent *pl = players[i]; + if(!pl || pl==p || !isteam(p->team, pl->team) || !team_isactive(pl->team)) continue; + vec rtmp = vec(pl->o).sub(mdd).mul(coordtrans).add(cod); + drawradarent(rtmp.x+displace, rtmp.y+displace, pl->yaw, pl->state==CS_ALIVE ? (isattacking(pl) ? 2 : 0) : 1, team_base(pl->team), iconsize, isattacking(pl), "%s", colorname(pl)); + } + if(m_flags) + { + glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + loopi(2) // flag items + { + flaginfo &f = flaginfos[i]; + entity *e = f.flagent; + if(!e) continue; + if(e->x == -1 && e-> y == -1) continue; // flagdummies + vec pos = vec(e->x, e->y, 0).sub(mdd).mul(coordtrans).add(cod); + vec cpos = vec(f.pos.x, f.pos.y, f.pos.z).sub(mdd).mul(coordtrans).add(cod); + drawradarent(pos.x+displace, pos.y+displace, camera1->yaw, m_ktf ? 2 : f.team, 3, iconsize, false); // draw bases + if(f.state!=CTFF_STOLEN && !(m_ktf && f.state == CTFF_IDLE)) + { + drawradarent(cpos.x+displace, cpos.y+displace, 0, 3, m_ktf ? 2 : f.team, iconsize, false); // draw on entity pos + } + if(m_ktf && f.state == CTFF_IDLE) continue; + if(f.state==CTFF_STOLEN) + { + float d2c = 1.6f * radarentsize/16.0f; + vec apos(d2c, -d2c, 0); + if(f.actor) + { + apos.add(f.actor->o); + bool tm = i != team_base(p->team); + if(m_htf) tm = !tm; + else if(m_ktf) tm = true; + if(tm) + { + apos.sub(mdd).mul(coordtrans).add(cod); + drawradarent(apos.x+displace, apos.y+displace, 0, 3, m_ktf ? 2 : f.team, iconsize, true); // draw near flag thief + } + } + } + } + } + glEnable(GL_BLEND); + glPopMatrix(); } void drawradar_vicinity(playerent *p, int w, int h) { extern GLuint minimaptex; - //extern int minimaplastsize; - int gdim = max(mapdims[4], mapdims[5]); + //extern int minimaplastsize; + int gdim = max(mapdims[4], mapdims[5]); float radarviewsize = min(VIRTW,VIRTH)/5; float halfviewsize = radarviewsize/2.0f; float iconsize = radarentsize/0.4f; // Gibstick suggested: radarentsize*radarviewsize*0.015 - float scaler = gdim/100.0f; - float scaleh = radarheight/(2.0f*gdim); - float scaled = radarviewsize/float(radarheight); + float scaler = gdim/100.0f; + float scaleh = radarheight/(2.0f*gdim); + float scaled = radarviewsize/float(radarheight); float offd = abs(mapdims[5]-mapdims[4])/2.0f; if(!gdim) { gdim = ssize/2; offd = 0; } float offx = gdim==mapdims[5]?offd:0; float offy = gdim==mapdims[4]?offd:0; - vec rtr = vec(mapdims[0]-offx, mapdims[1]-offy, 0); - vec rsd = vec(mapdims[0]+mapdims[4]/2, mapdims[1]+mapdims[5]/2, 0); - float d2s = radarheight/2.0f; - glColor3f(1.0f, 1.0f, 1.0f); + vec rtr = vec(mapdims[0]-offx, mapdims[1]-offy, 0); + vec rsd = vec(mapdims[0]+mapdims[4]/2, mapdims[1]+mapdims[5]/2, 0); + float d2s = radarheight/2.0f; + glColor3f(1.0f, 1.0f, 1.0f); glPushMatrix(); - vec centerpos(VIRTW-halfviewsize-72, halfviewsize+64, 0); - glTranslatef(centerpos.x, centerpos.y, 0); - glRotatef(-camera1->yaw, 0, 0, 1); - glTranslatef(-halfviewsize, -halfviewsize, 0); - vec d4rc = vec(p->o).sub(rsd).normalize().mul(scaler); - vec usecenter = vec(p->o).sub(rtr).sub(d4rc); - if(showradarvalues) - { - conoutf("vicinity @ gdim = %d | scaleh = %.2f", gdim, scaleh); - conoutf("offd: %.2f [%.2f:%.2f]", offd, offx, offy); - conoutf("RTR: %.2f %.2f", rtr.x, rtr.y); - conoutf("RSD: %.2f %.2f", rsd.x, rsd.y); - conoutf("P.O: %.2f %.2f", p->o.x, p->o.y); - conoutf("U4C: %.2f %.2f | %.2f %.2f", usecenter.x, usecenter.y, usecenter.x/gdim, usecenter.y/gdim); - //showradarvalues = 0; - } - glDisable(GL_BLEND); - circle(minimaptex, halfviewsize, halfviewsize, halfviewsize, usecenter.x/(float)gdim, usecenter.y/(float)gdim, scaleh, 31); - glTranslatef(halfviewsize, halfviewsize, 0); - if(team_isactive(p->team)) drawradarent(0, 0, p->yaw, p->state==CS_ALIVE ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player - loopv(players) // other players - { - playerent *pl = players[i]; - if(!pl || pl==p || !isteam(p->team, pl->team) || !team_isactive(pl->team)) continue; - vec rtmp = vec(pl->o).sub(p->o); - bool isok = rtmp.magnitude() < d2s; - if(isok) - { - rtmp.mul(scaled); - drawradarent(rtmp.x, rtmp.y, pl->yaw, pl->state==CS_ALIVE ? (isattacking(pl) ? 2 : 0) : 1, team_base(pl->team), iconsize, isattacking(pl), "%s", colorname(pl)); - } - } - if(m_flags) - { - glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - float d2c = 1.6f * radarentsize/16.0f; - loopi(2) // flag items - { - flaginfo &f = flaginfos[i]; - entity *e = f.flagent; - if(!e) continue; - if(e->x == -1 && e-> y == -1) continue; // flagdummies - vec pos = vec(e->x, e->y, 0).sub(p->o); - vec cpos = vec(f.pos.x, f.pos.y, f.pos.z).sub(p->o); - //if(showradarvalues) { conoutf("dist2F[%d]: %.2f|%.2f || %.2f|%.2f", i, pos.x, pos.y, cpos.x, cpos.y); } - if(pos.magnitude() < d2s) - { - pos.mul(scaled); - drawradarent(pos.x, pos.y, 0, m_ktf ? 2 : f.team, 3, iconsize, false); // draw bases [circle doesn't need rotating] - } - if(f.state!=CTFF_STOLEN && !(m_ktf && f.state == CTFF_IDLE)) - { - if(cpos.magnitude() < d2s) - { - cpos.mul(scaled);//.add(vec(d2c,-d2c,0)); - //cpos.mul(scaled).add(vec(4*d2c,-4*d2c,0)); - drawradarent(cpos.x, cpos.y, camera1->yaw, 3, m_ktf ? 2 : f.team, iconsize, false); // draw on entity pos - } - } - if(m_ktf && f.state == CTFF_IDLE) continue; - if(f.state==CTFF_STOLEN) - { - vec apos(d2c, -d2c, 0); - if(f.actor) - { - apos.add(f.actor->o); - bool tm = i != team_base(p->team); - if(m_htf) tm = !tm; - else if(m_ktf) tm = true; - if(tm) - { - apos.sub(p->o); - if(apos.magnitude() < d2s) - { - apos.mul(scaled); - drawradarent(apos.x, apos.y, camera1->yaw, 3, m_ktf ? 2 : f.team, iconsize, true); // draw near flag thief - } - } - } - } - } - } - showradarvalues = 0; // DEBUG - also see two bits commented-out above - glEnable(GL_BLEND); - glPopMatrix(); - // eye candy: - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor3f(1, 1, 1); - static Texture *bordertex = NULL; - if(!bordertex) bordertex = textureload("packages/misc/compass-base.png", 3); - quad(bordertex->id, centerpos.x-halfviewsize-16, centerpos.y-halfviewsize-16, radarviewsize+32, 0, 0, 1, 1); - if(!hidecompass) - { - static Texture *compasstex = NULL; - if(!compasstex) compasstex = textureload("packages/misc/compass-rose.png", 3); - glPushMatrix(); - glTranslatef(centerpos.x, centerpos.y, 0); - glRotatef(-camera1->yaw, 0, 0, 1); - quad(compasstex->id, -halfviewsize-8, -halfviewsize-8, radarviewsize+16, 0, 0, 1, 1); - glPopMatrix(); - } + vec centerpos(VIRTW-halfviewsize-72, halfviewsize+64, 0); + glTranslatef(centerpos.x, centerpos.y, 0); + glRotatef(-camera1->yaw, 0, 0, 1); + glTranslatef(-halfviewsize, -halfviewsize, 0); + vec d4rc = vec(p->o).sub(rsd).normalize().mul(scaler); + vec usecenter = vec(p->o).sub(rtr).sub(d4rc); + if(showradarvalues) + { + conoutf("vicinity @ gdim = %d | scaleh = %.2f", gdim, scaleh); + conoutf("offd: %.2f [%.2f:%.2f]", offd, offx, offy); + conoutf("RTR: %.2f %.2f", rtr.x, rtr.y); + conoutf("RSD: %.2f %.2f", rsd.x, rsd.y); + conoutf("P.O: %.2f %.2f", p->o.x, p->o.y); + conoutf("U4C: %.2f %.2f | %.2f %.2f", usecenter.x, usecenter.y, usecenter.x/gdim, usecenter.y/gdim); + //showradarvalues = 0; + } + glDisable(GL_BLEND); + circle(minimaptex, halfviewsize, halfviewsize, halfviewsize, usecenter.x/(float)gdim, usecenter.y/(float)gdim, scaleh, 31); + glTranslatef(halfviewsize, halfviewsize, 0); + if(team_isactive(p->team)) drawradarent(0, 0, p->yaw, p->state==CS_ALIVE ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player + loopv(players) // other players + { + playerent *pl = players[i]; + if(!pl || pl==p || !isteam(p->team, pl->team) || !team_isactive(pl->team)) continue; + vec rtmp = vec(pl->o).sub(p->o); + bool isok = rtmp.magnitude() < d2s; + if(isok) + { + rtmp.mul(scaled); + drawradarent(rtmp.x, rtmp.y, pl->yaw, pl->state==CS_ALIVE ? (isattacking(pl) ? 2 : 0) : 1, team_base(pl->team), iconsize, isattacking(pl), "%s", colorname(pl)); + } + } + if(m_flags) + { + glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + float d2c = 1.6f * radarentsize/16.0f; + loopi(2) // flag items + { + flaginfo &f = flaginfos[i]; + entity *e = f.flagent; + if(!e) continue; + if(e->x == -1 && e-> y == -1) continue; // flagdummies + vec pos = vec(e->x, e->y, 0).sub(p->o); + vec cpos = vec(f.pos.x, f.pos.y, f.pos.z).sub(p->o); + //if(showradarvalues) { conoutf("dist2F[%d]: %.2f|%.2f || %.2f|%.2f", i, pos.x, pos.y, cpos.x, cpos.y); } + if(pos.magnitude() < d2s) + { + pos.mul(scaled); + drawradarent(pos.x, pos.y, 0, m_ktf ? 2 : f.team, 3, iconsize, false); // draw bases [circle doesn't need rotating] + } + if(f.state!=CTFF_STOLEN && !(m_ktf && f.state == CTFF_IDLE)) + { + if(cpos.magnitude() < d2s) + { + cpos.mul(scaled);//.add(vec(d2c,-d2c,0)); + //cpos.mul(scaled).add(vec(4*d2c,-4*d2c,0)); + drawradarent(cpos.x, cpos.y, camera1->yaw, 3, m_ktf ? 2 : f.team, iconsize, false); // draw on entity pos + } + } + if(m_ktf && f.state == CTFF_IDLE) continue; + if(f.state==CTFF_STOLEN) + { + vec apos(d2c, -d2c, 0); + if(f.actor) + { + apos.add(f.actor->o); + bool tm = i != team_base(p->team); + if(m_htf) tm = !tm; + else if(m_ktf) tm = true; + if(tm) + { + apos.sub(p->o); + if(apos.magnitude() < d2s) + { + apos.mul(scaled); + drawradarent(apos.x, apos.y, camera1->yaw, 3, m_ktf ? 2 : f.team, iconsize, true); // draw near flag thief + } + } + } + } + } + } + showradarvalues = 0; // DEBUG - also see two bits commented-out above + glEnable(GL_BLEND); + glPopMatrix(); + // eye candy: + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor3f(1, 1, 1); + static Texture *bordertex = NULL; + if(!bordertex) bordertex = textureload("packages/misc/compass-base.png", 3); + quad(bordertex->id, centerpos.x-halfviewsize-16, centerpos.y-halfviewsize-16, radarviewsize+32, 0, 0, 1, 1); + if(!hidecompass) + { + static Texture *compasstex = NULL; + if(!compasstex) compasstex = textureload("packages/misc/compass-rose.png", 3); + glPushMatrix(); + glTranslatef(centerpos.x, centerpos.y, 0); + glRotatef(-camera1->yaw, 0, 0, 1); + quad(compasstex->id, -halfviewsize-8, -halfviewsize-8, radarviewsize+16, 0, 0, 1, 1); + glPopMatrix(); + } } void drawradar(playerent *p, int w, int h) { - if(showmap) drawradar_showmap(p,w,h); - else drawradar_vicinity(p,w,h); + if(showmap) drawradar_showmap(p,w,h); + else drawradar_vicinity(p,w,h); } void drawteamicons(int w, int h, bool spect) @@ -674,7 +674,7 @@ void drawscores() float vw=VIRTW*7/4,vh=VIRTH*7/4; glPushAttrib(GL_COLOR_BUFFER_BIT); glLoadIdentity(); - glOrtho(0, vw, vh, 0, -1, 1); + glOrtho(0, vw, vh, 0, -1, 1); int left = vw/4, top = vh/4; blendbox(left, top, left*3, top*3, true, -1); top+=10;left+=10;const float txtdx=160,txtdy=30,medalsdy=130; @@ -787,7 +787,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat extern void r_accuracy(); if (!is_spect) r_accuracy(); if(!hideconsole) renderconsole(); - formatstring(enginestateinfo)("%d %d %d %d %d", curfps, lod_factor(), nquads, curvert, xtraverts); + formatstring(enginestateinfo)("%d %d %d %d %d", curfps, lod_factor(), nquads, curvert, xtraverts); if(showstats) { if(showstats==2) @@ -843,14 +843,14 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat { if(dbgpos) { - pushfont("mono"); + pushfont("mono"); defformatstring(o_x)("%05.2f X", player1->o.x); draw_text(o_x, VIRTW*2 - ( text_width(o_x) + FONTH ), VIRTH*2 - 10*FONTH/2); defformatstring(o_y)("%05.2f Y", player1->o.y); draw_text(o_y, VIRTW*2 - ( text_width(o_y) + FONTH ), VIRTH*2 - 8*FONTH/2); defformatstring(o_z)("%05.2f Z", player1->o.z); draw_text(o_z, VIRTW*2 - ( text_width(o_z) + FONTH ), VIRTH*2 - 6*FONTH/2); - popfont(); + popfont(); } defformatstring(c_val)("fps %d", curfps); draw_text(c_val, VIRTW*2 - ( text_width(c_val) + FONTH ), VIRTH*2 - 3*FONTH/2); @@ -923,7 +923,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat /* * / glLoadIdentity(); - glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1); + glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1); const int tbMSGleft = (VIRTW*3/2)*5/6; const int tbMSGtop = (VIRTH*3/2)*7/8; draw_textf("!TEST BUILD!", tbMSGleft, tbMSGtop); diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index e7848f73..b8b185f0 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -339,11 +339,11 @@ VAR(dbgmbatch, 0, 0, 1); VARP(popdeadplayers, 0, 0, 1); void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, float yaw, float pitch, float speed, int basetime, playerent *d, modelattach *a, float scale) { - if(popdeadplayers && d && a) - { - int acv = anim&ANIM_INDEX; - if( acv == ANIM_DECAY || acv == ANIM_LYING_DEAD || acv == ANIM_CROUCH_DEATH || acv == ANIM_DEATH ) return; - } + if(popdeadplayers && d && a) + { + int acv = anim&ANIM_INDEX; + if( acv == ANIM_DECAY || acv == ANIM_LYING_DEAD || acv == ANIM_CROUCH_DEATH || acv == ANIM_DEATH ) return; + } model *m = loadmodel(mdl); if(!m || (stenciling && (m->shadowdist <= 0 || anim&ANIM_TRANSLUCENT))) return; diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp index 2611d2a4..d48b13fa 100644 --- a/source/src/renderparticles.cpp +++ b/source/src/renderparticles.cpp @@ -480,7 +480,7 @@ void render_particles(int time, int typemask) } else { - if(pt.gr) p->o.z -= ((lastmillis-p->millis)/3.0f)*time/(pt.gr*10000); + if(pt.gr) p->o.z -= ((lastmillis-p->millis)/3.0f)*time/(pt.gr*10000); if(pt.type==PT_PART || pt.type==PT_BLOOD) { p->o.add(vec(p->d).mul(time/20000.0f)); diff --git a/source/src/server.cpp b/source/src/server.cpp index 762401bb..19b34c5a 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -511,11 +511,11 @@ const char *getDemoFilename(int gmode, int mplay, int mdrop, int tstamp, char *s case 'S': formatstring(cfspp)("%d", mplay); break; case 'w': { - time_t t = tstamp; - struct tm * timeinfo; - timeinfo = demotimelocal ? localtime(&t) : gmtime (&t); - strftime(cfspp, sizeof(string) - 1, demotimestampformat, timeinfo); - break; + time_t t = tstamp; + struct tm * timeinfo; + timeinfo = demotimelocal ? localtime(&t) : gmtime (&t); + strftime(cfspp, sizeof(string) - 1, demotimestampformat, timeinfo); + break; } default: logline(ACLOG_INFO, "bad formatstring: demonameformat @ %d", cc); cc-=1; break; // don't drop the bad char } @@ -1363,11 +1363,11 @@ int numplayers() int spawntime(int type) { int np = numplayers(); - np = np<3 ? 4 : (np>4 ? 2 : 3); // Some spawn times are dependent on the number of players. + np = np<3 ? 4 : (np>4 ? 2 : 3); // Some spawn times are dependent on the number of players. int sec = 0; switch(type) { - // Please update ./ac_website/htdocs/docs/introduction.html if these times change. + // Please update ./ac_website/htdocs/docs/introduction.html if these times change. case I_CLIPS: case I_AMMO: sec = np*2; break; case I_GRENADE: sec = np + 5; break; @@ -2351,9 +2351,9 @@ void authsucceeded(uint id) client *cl = findauth(id); if(!cl) return; cl->authreq = 0; - logline(ACLOG_INFO, "player authenticated: %s", cl->name); - defformatstring(auth4u)("player authenticated: %s", cl->name); - sendf(-1, 1, "ris", SV_SERVMSG, auth4u); + logline(ACLOG_INFO, "player authenticated: %s", cl->name); + defformatstring(auth4u)("player authenticated: %s", cl->name); + sendf(-1, 1, "ris", SV_SERVMSG, auth4u); //setmaster(cl, true, "", ci->authname);//TODO? compare to sauerbraten } @@ -3470,7 +3470,7 @@ void process(ENetPacket *packet, int sender, int chan) // description: writes a custom string to the server log // access: requires admin privileges // usage: /serverextension driAn::writelog "your log message here.." - // note: There is a 49 character limit. The server will ignore messages with 50+ characters. + // note: There is a 49 character limit. The server will ignore messages with 50+ characters. getstring(text, p, n); if(valid_client(sender) && clients[sender]->role==CR_ADMIN) diff --git a/source/src/server.h b/source/src/server.h index 5e82970a..d9577a54 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -444,7 +444,7 @@ const char *messagenames[SV_NUM] = const char *entnames[MAXENTTYPES] = { "none?", - "light", "playerstart", "pistol", "ammobox","grenades", + "light", "playerstart", "pistol", "ammobox","grenades", "health", "helmet", "armour", "akimbo", "mapmodel", "trigger", "ladder", "ctf-flag", "sound", "clip", "plclip" }; diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp index 46ab7834..9eb195f2 100644 --- a/source/src/serverbrowser.cpp +++ b/source/src/serverbrowser.cpp @@ -679,11 +679,11 @@ int sicompare(serverinfo **ap, serverinfo **bp) if(a->numplayers > b->numplayers) return -dir; break; case SBS_MAXPL: // maxplayers - if(a->maxclients < b->maxclients) return dir; + if(a->maxclients < b->maxclients) return dir; if(a->maxclients > b->maxclients) return -dir; break; case SBS_MINREM: // minutes remaining - if(a->minremain < b->minremain) return dir; + if(a->minremain < b->minremain) return dir; if(a->minremain > b->minremain) return -dir; break; case SBS_DESC: // description @@ -693,7 +693,7 @@ int sicompare(serverinfo **ap, serverinfo **bp) filtertext(bd, b->sdesc); if(!ad[0] && bd[0]) return dir; if(ad[0] && !bd[0]) return -dir; - int mdir = dir * strcasecmp(ad, bd); + int mdir = dir * strcasecmp(ad, bd); if(mdir) return mdir; break; } @@ -1042,8 +1042,8 @@ void refreshservers(void *menu, bool init) { if(si.protocol!=PROTOCOL_VERSION) { - if(!showonlygoodservers) formatstring(si.full)("%s:%d [%s]", si.name, si.port, si.protocol<0 ? "modded version" : (si.protocol= NUMGUNS) - { - logline(ACLOG_INFO, " error in line %i, invalid gun : %i", line, gun); - errors++; - } - if(strlen(message)>MAXKILLMSGLEN) - { - logline(ACLOG_INFO, " error in line %i, too long message : string length is %i, max allowed i %i", line, strlen(message), MAXKILLMSGLEN); - errors++; - } - if(!errors) - { - if(fragmsg) - { - formatstring(killmessages[0][gun])("%s", message); - logline(ACLOG_VERBOSE, " added msg '%s' for frags with weapon %i ", message, gun); - } - else - { - formatstring(killmessages[1][gun])("%s", message); - logline(ACLOG_VERBOSE, " added msg '%s' for gibs with weapon %i ", message, gun); - } - } + if(end) message[end-message] = '\0'; + else + { + if(hasquotes) + { + logline(ACLOG_INFO, " error in line %i, ending quote missing (%s)", line, message); + errors++; + } + } + + if(gun < 0 || gun >= NUMGUNS) + { + logline(ACLOG_INFO, " error in line %i, invalid gun : %i", line, gun); + errors++; + } + if(strlen(message)>MAXKILLMSGLEN) + { + logline(ACLOG_INFO, " error in line %i, too long message : string length is %i, max allowed i %i", line, strlen(message), MAXKILLMSGLEN); + errors++; + } + if(!errors) + { + if(fragmsg) + { + formatstring(killmessages[0][gun])("%s", message); + logline(ACLOG_VERBOSE, " added msg '%s' for frags with weapon %i ", message, gun); + } + else + { + formatstring(killmessages[1][gun])("%s", message); + logline(ACLOG_VERBOSE, " added msg '%s' for gibs with weapon %i ", message, gun); + } + } s = NULL; - line++; - } - } - } - } + line++; + } + } + } + } }; diff --git a/source/src/serverms.cpp b/source/src/serverms.cpp index 21f12c0a..fee15fc4 100644 --- a/source/src/serverms.cpp +++ b/source/src/serverms.cpp @@ -333,8 +333,8 @@ void servermsinit(const char *master, const char *ip, int infoport, bool listen) copystring(mastername, master); disconnectmaster(); - if(listen) - { + if(listen) + { ENetAddress address = { ENET_HOST_ANY, infoport }; if(*ip) { @@ -358,5 +358,5 @@ void servermsinit(const char *master, const char *ip, int infoport, bool listen) } if(lansock == ENET_SOCKET_NULL) logline(ACLOG_WARNING, "could not create LAN server info socket"); else enet_socket_set_option(lansock, ENET_SOCKOPT_NONBLOCK, 1); - } + } } diff --git a/source/src/sound.h b/source/src/sound.h index 1b669832..4f374854 100644 --- a/source/src/sound.h +++ b/source/src/sound.h @@ -2,8 +2,8 @@ enum -{ // To avoid a lot of work, possible bugs and allow backward compatibility for players own custom - // cfg files, it's best not to change the listed sound order, instead, just add to it. +{ // To avoid a lot of work, possible bugs and allow backward compatibility for players own custom + // cfg files, it's best not to change the listed sound order, instead, just add to it. S_JUMP = 0, S_SOFTLAND, S_HARDLAND, S_BULLETAIR1, S_BULLETAIR2, S_BULLETHIT, S_BULLETWATERHIT, @@ -24,7 +24,7 @@ enum S_FLAGDROP, S_FLAGPICKUP, S_FLAGRETURN, S_FLAGSCORE, S_GRENADEPULL, S_GRENADETHROW, S_GRENADEBOUNCE1, S_GRENADEBOUNCE2, S_RAKIMBO, S_GUNCHANGE, - S_HITSOUND, + S_HITSOUND, S_GIB, S_HEADSHOT, S_CALLVOTE, S_VOTEPASS, S_VOTEFAIL, S_FOOTSTEPS, S_FOOTSTEPSCROUCH, S_WATERFOOTSTEPS, S_WATERFOOTSTEPSCROUCH, @@ -69,7 +69,7 @@ enum S_THANKS2, S_AWESOME1, S_AWESOME2, - S_ITEMHELMET, // begin: Sounds for AssaultCube v1.1.0.4 onwards + S_ITEMHELMET, // begin: Sounds for AssaultCube v1.1.0.4 onwards S_HEARTBEAT, S_NULL }; @@ -281,12 +281,12 @@ public: class camerareference : public worldobjreference { public: - camerareference(); + camerareference(); - worldobjreference *clone() const; - const vec ¤tposition() const; - bool nodistance(); - bool operator==(const worldobjreference &other); + worldobjreference *clone() const; + const vec ¤tposition() const; + bool nodistance(); + bool operator==(const worldobjreference &other); }; @@ -374,7 +374,7 @@ class audiomanager { bool nosound; float currentpitch; - vector musics; + vector musics; ALCdevice *device; ALCcontext *context; @@ -386,7 +386,7 @@ public: audiomanager(); - // init & setup + // init & setup void initsound(); void preloadmapsound(entity &e); void preloadmapsounds(); @@ -396,25 +396,25 @@ public: void setchannels(int num); void setlistenervol(int vol); int addsound(char *name, int vol, int maxuses, bool loop, vector &sounds, bool load, int audibleradius); - void registermusic(char *name); + void registermusic(char *name); void mutesound(int n, int off); - void unmuteallsounds(); - int soundmuted(int n); + void unmuteallsounds(); + int soundmuted(int n); - // cleanup + // cleanup void soundcleanup(); void clearworldsounds(bool fullclean = true); - void mapsoundreset(); + void mapsoundreset(); void stopsound(); - // music handling - void music(char *name, char *millis, char *cmd); - void musicpreload(int id); + // music handling + void music(char *name, char *millis, char *cmd); + void musicpreload(int id); void musicsuggest(int id, int millis, bool rndofs); void musicfadeout(int id); void setmusicvol(int musicvol); - // sound handling + // sound handling location *_playsound(int n, const worldobjreference &r, int priority, float offset = 0.0f, bool loop = false); void playsound(int n, int priority = SP_NORMAL); void playsound(int n, class physent *p, int priority = SP_NORMAL); @@ -422,16 +422,16 @@ public: void playsound(int n, const vec *v, int priority = SP_NORMAL); void playsoundname(char *s, const vec *loc, int vol); void playsoundc(int n, physent *p = NULL, int priority = SP_NORMAL); - void sound(int n); - int findsound(char *name, int vol, vector &sounds); + void sound(int n); + int findsound(char *name, int vol, vector &sounds); void detachsounds(class playerent *owner); - // update + // update void updateplayerfootsteps(class playerent *p); location *updateloopsound(int sound, bool active, float vol = 1.0f); void updateaudio(); - // misc + // misc void writesoundconfig(stream *f); }; diff --git a/source/src/soundlocation.cpp b/source/src/soundlocation.cpp index 2ab8efa9..9c8e65eb 100644 --- a/source/src/soundlocation.cpp +++ b/source/src/soundlocation.cpp @@ -176,7 +176,7 @@ void location::update() case AL_PAUSED: case AL_INITIAL: stale = true; - DEBUG("location is stale"); + DEBUG("location is stale"); break; } } diff --git a/source/src/soundscheduler.cpp b/source/src/soundscheduler.cpp index c5ea501c..3a37ccbf 100644 --- a/source/src/soundscheduler.cpp +++ b/source/src/soundscheduler.cpp @@ -148,15 +148,15 @@ void sourcescheduler::releasesource(source *src) if(!src) return; - DEBUG("unlocking source"); - - src->unlock(); + DEBUG("unlocking source"); + + src->unlock(); if(sources.length() > numsoundchannels) { sources.removeobj(src); delete src; - DEBUG("source deleted"); + DEBUG("source deleted"); } } diff --git a/source/src/texture.cpp b/source/src/texture.cpp index f0406821..16a1441e 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -446,30 +446,30 @@ Texture *textureload(const char *name, int clamp, bool mipmap, bool canreduce, f Texture *createtexturefromsurface(const char *name, SDL_Surface *s) { - string pname; - copystring(pname, name); - path(pname); - Texture *t = textures.access(pname); - if(!t) - { - char *key = newstring(pname); - t = &textures[key]; - t->name = key; - } + string pname; + copystring(pname, name); + path(pname); + Texture *t = textures.access(pname); + if(!t) + { + char *key = newstring(pname); + t = &textures[key]; + t->name = key; + } - GLuint tnum; - glGenTextures(1, &tnum); - GLenum format = texformat(s->format->BitsPerPixel); - createtexture(tnum, s->w, s->h, s->pixels, 0, true, false, format); + GLuint tnum; + glGenTextures(1, &tnum); + GLenum format = texformat(s->format->BitsPerPixel); + createtexture(tnum, s->w, s->h, s->pixels, 0, true, false, format); - t->xs = s->w; - t->ys = s->h; - t->bpp = s->format->BitsPerPixel; - t->clamp = 0; - t->mipmap = true; - t->canreduce = false; - t->id = tnum; - return t; + t->xs = s->w; + t->ys = s->h; + t->bpp = s->format->BitsPerPixel; + t->clamp = 0; + t->mipmap = true; + t->canreduce = false; + t->id = tnum; + return t; } struct Slot diff --git a/source/src/tools.cpp b/source/src/tools.cpp index bf84ce18..e5bc197d 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -74,8 +74,8 @@ mapstats *loadmapstats(const char *filename, bool getlayout) entposs[i * 3] = e.x; entposs[i * 3 + 1] = e.y; entposs[i * 3 + 2] = e.z + e.attr1; } DELETEA(testlayout); - int minfloor = 0; - int maxceil = 0; + int minfloor = 0; + int maxceil = 0; if(s.hdr.sfactor <= LARGEST_FACTOR && s.hdr.sfactor >= SMALLEST_FACTOR) { testlayout_factor = s.hdr.sfactor; @@ -113,8 +113,8 @@ mapstats *loadmapstats(const char *filename, bool getlayout) if(floor >= ceil && ceil > -128) floor = ceil - 1; // for pre 12_13 diff = ceil - floor; if(type == FHF) floor = -128; - if(floor!=-128 && floormaxceil) maxceil = ceil; + if(floor!=-128 && floormaxceil) maxceil = ceil; f->getchar(); f->getchar(); if(s.hdr.version>=2) f->getchar(); if(s.hdr.version>=5) f->getchar(); @@ -164,8 +164,8 @@ mapstats *loadmapstats(const char *filename, bool getlayout) if(cwy > mapdims[3]) mapdims[3] = cwy; } loopk(2) mapdims[k+4] = mapdims[k+2] - mapdims[k]; - mapdims[6] = minfloor; - mapdims[7] = maxceil; + mapdims[6] = minfloor; + mapdims[7] = maxceil; } } delete f; diff --git a/source/src/tools.h b/source/src/tools.h index dc96ab82..bb6dfeb8 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -769,23 +769,23 @@ template struct ringbuf // ease time measurement struct stopwatch { - int millis; + int millis; - stopwatch() : millis(-1) {} + stopwatch() : millis(-1) {} - void start() - { - millis = SDL_GetTicks(); - } + void start() + { + millis = SDL_GetTicks(); + } - // returns elapsed time - int stop() - { - ASSERT(millis >= 0); - int time = SDL_GetTicks() - millis; - millis = -1; - return time; - } + // returns elapsed time + int stop() + { + ASSERT(millis >= 0); + int time = SDL_GetTicks() - millis; + millis = -1; + return time; + } }; #endif @@ -798,10 +798,10 @@ inline char *newstringbuf(const char *s) { return newstring(s, MAXSTRLEN- #ifndef STANDALONE inline const char *_gettext(const char *msgid) { - if(msgid && msgid[0] != '\0') - return gettext(msgid); - else - return ""; + if(msgid && msgid[0] != '\0') + return gettext(msgid); + else + return ""; } #endif diff --git a/source/src/winserviceinstaller.h b/source/src/winserviceinstaller.h index 5f4b7f3a..d7f7d961 100644 --- a/source/src/winserviceinstaller.h +++ b/source/src/winserviceinstaller.h @@ -38,7 +38,7 @@ public: CloseServiceHandle(svc); return installed ? 1 : 0; } - + int Install() { if(!scm) return -1; diff --git a/source/src/wizard.cpp b/source/src/wizard.cpp index 89f36883..603e81e8 100644 --- a/source/src/wizard.cpp +++ b/source/src/wizard.cpp @@ -99,7 +99,7 @@ int wizardmain(int argc, char **argv) #endif - printf("\nWriting your configuration to %s ... ", outfile); fflush(stdout); + printf("\nWriting your configuration to %s ... ", outfile); fflush(stdout); argstr.add('\0'); @@ -130,7 +130,7 @@ int wizardmain(int argc, char **argv) vector path; databuf cwd = path.reserve(MAX_PATH); - if(!_getcwd(cwd.buf, MAX_PATH)) + if(!_getcwd(cwd.buf, MAX_PATH)) { printf("Failed!\n"); printf("Could not get current working directory: %u\n", (uint)GetLastError()); @@ -177,11 +177,11 @@ int wizardmain(int argc, char **argv) #endif - printf("Please press ENTER now to start your server...\n"); + printf("Please press ENTER now to start your server...\n"); fgetc(stdin); - printf("Starting the AC server ...\n"); + printf("Starting the AC server ...\n"); argstr.insert(0, relpath, strlen(relpath)); system(argstr.getbuf()); - return EXIT_SUCCESS; + return EXIT_SUCCESS; } diff --git a/source/src/worldlight.cpp b/source/src/worldlight.cpp index 4794c7c1..b1311556 100644 --- a/source/src/worldlight.cpp +++ b/source/src/worldlight.cpp @@ -53,7 +53,7 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1 sqr *s = S(x>>PRECBITS, y>>PRECBITS); s->r = min((l>>PRECBITS)+s->r, 255); s->g = min((g>>PRECBITS)+s->g, 255); - s->b = min((b>>PRECBITS)+s->b, 255); + s->b = min((b>>PRECBITS)+s->b, 255); if(SOLID(s)) return; x += stepx; y += stepy; @@ -76,12 +76,12 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1 if(OUTBORD(x>>PRECBITS, y>>PRECBITS)) return; - if(hdr.ambient > 0xFF) loopi(steps) + if(hdr.ambient > 0xFF) loopi(steps) { sqr *s = S(x>>PRECBITS, y>>PRECBITS); s->r = min((l>>PRECBITS)+s->r, 255); - s->g = min((l>>PRECBITS)+s->g, 255); - s->b = min((l>>PRECBITS)+s->b, 255); + s->g = min((l>>PRECBITS)+s->g, 255); + s->b = min((l>>PRECBITS)+s->b, 255); if(SOLID(s)) return; x += stepx; y += stepy; @@ -162,19 +162,19 @@ VARF(ambient, 0, 0, 0xFFFFFF, if(!noteditmode("ambient")) { hdr.ambient = ambien void calclight() { - bvec acol((hdr.ambient>>16)&0xFF, (hdr.ambient>>8)&0xFF, hdr.ambient&0xFF); - if(!acol.x && !acol.y) + bvec acol((hdr.ambient>>16)&0xFF, (hdr.ambient>>8)&0xFF, hdr.ambient&0xFF); + if(!acol.x && !acol.y) { if(!acol.z) acol.z = 10; acol.x = acol.y = acol.z; } - else if(!maxtmus) acol.x = acol.y = acol.z = max(max(acol.x, acol.y), acol.z); // the old (white) light code, here for the few people with old video cards that don't support overbright + else if(!maxtmus) acol.x = acol.y = acol.z = max(max(acol.x, acol.y), acol.z); // the old (white) light code, here for the few people with old video cards that don't support overbright loop(x,ssize) loop(y,ssize) { sqr *s = S(x,y); - s->r = acol.x; - s->g = acol.y; - s->b = acol.z; + s->r = acol.x; + s->g = acol.y; + s->b = acol.z; } loopv(ents)