From eb60302e67ee38e94b053ac2f304b6482c19ef84 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Wed, 14 May 2014 22:54:37 +0200 Subject: [PATCH] cleanup - fix possible crash in conc (but it's still an ugly hack) - fix noob usage of strcmp - flag some memory leaks (it would be nice, if the author(s) would clean up the mess himself) - fix crash in substr - whitespace cleanup there are plenty more memory leaks in command.cpp - for example, every goto in cubescript does not clean up anything --- config/autoexec.cfg | 0 config/compatibility.cfg | 2 +- config/convert_mapconfig.sh | 2 +- config/defaults.cfg | 4 +- config/faq.cfg | 4 +- config/firstrun.cfg | 2 +- config/font_default.cfg | 2 +- config/forbidden.cfg | 2 +- config/keymap.cfg | 2 +- config/locale.cfg | 2 +- config/menus.cfg | 0 config/menus_edit.cfg | 2 +- config/menus_voicecom.cfg | 2 +- config/prefabs.cfg | 0 config/resetbinds.cfg | 4 +- config/servercmdline.txt | 4 +- config/serverinfo_en.txt | 2 +- config/sounds.cfg | 0 config/survival.cfg | 4 +- source/src/bot/ac_bot_ai.cpp | 4 +- source/src/bot/bot_ai.cpp | 6 +- source/src/bot/bot_util.cpp | 110 +++++++++++++++---------------- source/src/bot/bot_waypoint.h | 24 +++---- source/src/bot/botmanager.cpp | 11 +--- source/src/client.cpp | 2 +- source/src/clientgame.cpp | 6 +- source/src/command.cpp | 21 +++--- source/src/console.h | 32 ++++----- source/src/crypto.cpp | 6 +- source/src/editing.cpp | 4 +- source/src/entity.h | 8 +-- source/src/geom.h | 4 +- source/src/hudgun.h | 24 +++---- source/src/i18n.h | 2 +- source/src/main.cpp | 4 +- source/src/model.h | 2 +- source/src/oggstream.cpp | 36 +++++----- source/src/renderhud.cpp | 8 +-- source/src/rendermodel.cpp | 4 +- source/src/rndmap.cpp | 2 +- source/src/scoreboard.cpp | 4 +- source/src/serverbrowser.cpp | 4 +- source/src/servercontroller.h | 22 +++---- source/src/serverevents.h | 2 +- source/src/serverfiles.h | 6 +- source/src/shadow.cpp | 6 +- source/src/soundlocation.cpp | 26 ++++---- source/src/soundscheduler.cpp | 16 ++--- source/src/stream.cpp | 2 +- source/src/texture.cpp | 2 +- source/src/tristrip.h | 30 ++++----- source/src/varray.h | 2 +- source/src/weapon.cpp | 2 +- source/src/winserviceinstaller.h | 2 +- source/src/worldio.cpp | 2 +- source/src/worldocull.cpp | 4 +- source/src/worldrender.cpp | 8 +-- 57 files changed, 246 insertions(+), 254 deletions(-) mode change 100755 => 100644 config/autoexec.cfg mode change 100755 => 100644 config/keymap.cfg mode change 100755 => 100644 config/menus.cfg mode change 100755 => 100644 config/prefabs.cfg mode change 100755 => 100644 config/sounds.cfg diff --git a/config/autoexec.cfg b/config/autoexec.cfg old mode 100755 new mode 100644 diff --git a/config/compatibility.cfg b/config/compatibility.cfg index 78fc3244..6295ad2e 100644 --- a/config/compatibility.cfg +++ b/config/compatibility.cfg @@ -26,7 +26,7 @@ const orderscorecolumns [ sc_score 5; sc_lag 6; sc_ratio -1; - ] [ + ] [ sc_flags 0; sc_frags 1; sc_deaths 2; diff --git a/config/convert_mapconfig.sh b/config/convert_mapconfig.sh index 2a706cd6..7f611dab 100644 --- a/config/convert_mapconfig.sh +++ b/config/convert_mapconfig.sh @@ -123,7 +123,7 @@ for file in $*; do echo "Converting mapmodels..." sed -i '/^mapmodel/s/\/jcdpc\/laptop/1' $file sed -i '/^mapmodel/s/\/toca\/cardboardbox/1' $file - sed -i '/^mapmodel/s/\/ratboy\/toca_cardboardbox_reskin/1' $file + sed -i '/^mapmodel/s/\/ratboy\/toca_cardboardbox_reskin/1' $file sed -i '/^mapmodel/s/\/jcdpc\/hanginglamp/1' $file sed -i '/^mapmodel/s/\/jcdpc\/ventflap/1' $file sed -i '/^mapmodel/s/\/ratboy\/toca_milkcrate_blue/1' $file diff --git a/config/defaults.cfg b/config/defaults.cfg index 061eb086..adc5020f 100644 --- a/config/defaults.cfg +++ b/config/defaults.cfg @@ -4,7 +4,7 @@ name "unarmed" // Change your name! loadcrosshair default.png // Choose another crosshair, see ./packages/crosshairs/ loadcrosshair teammate.png teammate // Teammate crosshair. -loadcrosshair red_dot.png scope // Scope crosshair. +loadcrosshair red_dot.png scope // Scope crosshair. skin_cla (rnd 4) // Change your look. skin_rvsf (rnd 6) autoreload 1 // Reload the guns automatically by default. @@ -34,4 +34,4 @@ survDamageEffects = 1 autosavemap = 0 timeBetAutoSaves = 300000 numAutoSaveBackups = 3 -menuBotGameLength = 15 \ No newline at end of file +menuBotGameLength = 15 diff --git a/config/faq.cfg b/config/faq.cfg index 98682152..46943fa4 100644 --- a/config/faq.cfg +++ b/config/faq.cfg @@ -87,13 +87,13 @@ faqAnswer_8 = [ ] genFaq = [ - loop i (listlen $faqQuestions) [ + loop i (listlen $faqQuestions) [ if (= (mod $i 2) 0) [ menuitem (concatword (yellow) (format [#%1: ] (+ $i 1)) (at $faqQuestions $i)) -1 ] [ menuitem (concatword (c D) (format [#%1: ] (+ $i 1)) (at $faqQuestions $i)) -1 ] - + tmpMenuAlias = (getalias (format faqAnswer_%1 (+ $i 1))) loop o (listlen $tmpMenuAlias) [ if (strstr (at $tmpMenuAlias $o) "http://") [ diff --git a/config/firstrun.cfg b/config/firstrun.cfg index 11919dd8..66d87aca 100644 --- a/config/firstrun.cfg +++ b/config/firstrun.cfg @@ -17,4 +17,4 @@ const delayed_firstrun [ sleep 1000 delayed_firstrun -persistidents 1 \ No newline at end of file +persistidents 1 diff --git a/config/font_default.cfg b/config/font_default.cfg index e78c4ecc..e7f84408 100644 --- a/config/font_default.cfg +++ b/config/font_default.cfg @@ -95,4 +95,4 @@ fontchar 276 448 37 64 // z fontchar 320 448 35 64 // { fontchar 366 448 20 64 // | fontchar 397 448 35 64 // } -fontchar 443 448 43 64 // ~ \ No newline at end of file +fontchar 443 448 43 64 // ~ diff --git a/config/forbidden.cfg b/config/forbidden.cfg index 388550ff..06034320 100644 --- a/config/forbidden.cfg +++ b/config/forbidden.cfg @@ -24,4 +24,4 @@ pussy filho puta // "whore" or "slut" in portugese. redtube porntube -youporn \ No newline at end of file +youporn diff --git a/config/keymap.cfg b/config/keymap.cfg old mode 100755 new mode 100644 index 713d5be4..1c289b00 --- a/config/keymap.cfg +++ b/config/keymap.cfg @@ -147,4 +147,4 @@ keymap 246 OE keymap 228 AE // :: added for de support -exec config/resetbinds.cfg \ No newline at end of file +exec config/resetbinds.cfg diff --git a/config/locale.cfg b/config/locale.cfg index d149944d..f74adb3c 100644 --- a/config/locale.cfg +++ b/config/locale.cfg @@ -7,4 +7,4 @@ _ = [ result (gettext $arg1) ] -persistidents 1 \ No newline at end of file +persistidents 1 diff --git a/config/menus.cfg b/config/menus.cfg old mode 100755 new mode 100644 diff --git a/config/menus_edit.cfg b/config/menus_edit.cfg index 481b160e..390c8d19 100644 --- a/config/menus_edit.cfg +++ b/config/menus_edit.cfg @@ -497,4 +497,4 @@ menuitemcheckbox (_ [Enable auto save map: ]) "$autosavemap" [ autosavemap = $ar menuitemslider (_ [Time between auto saves (in minutes): ]) 2 60 "(div $timeBetAutoSaves 60000)" 1 [] [ timeBetAutoSaves = (* $arg1 60000) ] menuitemtextinput (_ [Make a map backup (.BAK) every: ]) "$numAutoSaveBackups" [ numAutoSaveBackups = $arg1 ] [ if (! $showedBAKinfo) [ echo This setting effects the number of autosavemaps between making a map backup file. "(.BAK)"; showedBAKinfo = 1 ] ] 4 -persistidents 1 \ No newline at end of file +persistidents 1 diff --git a/config/menus_voicecom.cfg b/config/menus_voicecom.cfg index fefd5d46..e2b5be62 100644 --- a/config/menus_voicecom.cfg +++ b/config/menus_voicecom.cfg @@ -67,4 +67,4 @@ genvcitem [Nice shot] niceshot 1 genvcitem [Thanks! "Thanks, man"] [thanks_1 thanks_2] 2 genvcitem [Awesome Awesome!] [awesome_1 awesome_2] 3 -persistidents 1 \ No newline at end of file +persistidents 1 diff --git a/config/prefabs.cfg b/config/prefabs.cfg old mode 100755 new mode 100644 diff --git a/config/resetbinds.cfg b/config/resetbinds.cfg index 6dda235a..a5fd8b3c 100644 --- a/config/resetbinds.cfg +++ b/config/resetbinds.cfg @@ -85,7 +85,7 @@ bind J [] bind K [] editbind K [ if $old_editbinds corner [ if (countwalls 1) [ solid 0 ] corner ] ] // Toggle corner/non-solid bind L [] -editbind L [ showmenu Lightning ] +editbind L [ showmenu Lightning ] bind M [] editbind M [ domodifier 6 ] bind N quickanswer @@ -108,7 +108,7 @@ bind Z [] editbind Z [ domodifier 2 ] bind DELETE [] editbind DELETE [ edittex 0 -1 ] -bind KP0 [ weapon 4 1 ] +bind KP0 [ weapon 4 1 ] bind KP1 [] bind KP2 [] bind KP3 [] diff --git a/config/servercmdline.txt b/config/servercmdline.txt index 73801010..de823fbe 100644 --- a/config/servercmdline.txt +++ b/config/servercmdline.txt @@ -85,9 +85,9 @@ // 3 WARNING: log only messages of level WARNING and above // 4 ERROR: log only messages of level ERROR // 5 do not write to the log -// -A // Restricts voting for a map/mode to admins. This switch can be used several times. +// -A // Restricts voting for a map/mode to admins. This switch can be used several times. -// these switches control the naming of demos (see -W) +// these switches control the naming of demos (see -W) // --demofilenameformat="%Mmin_%G_%w_%H_%n" // default: "%w_%h_%n_%Mmin_%G" // --demotimestampformat="%H%M_%Y%m%d" // default: "%Y%m%d_%H%M" // --demotimelocal=1 // default: 0 diff --git a/config/serverinfo_en.txt b/config/serverinfo_en.txt index 1fcc5ee1..cceb5abb 100644 --- a/config/serverinfo_en.txt +++ b/config/serverinfo_en.txt @@ -10,7 +10,7 @@ // who are innocently affect by an IP range ban. // You can also use this page to advertize your clan or provide contact // information for recruiting. -// +// // Don't use more than 80 characters per line. You can use colors and TABs. // Color usage: \f plus a corresponding number/character. // The available colors are: 0: green, 1: blue, 2: yellow, 3: red, 4: gray, 5: white, diff --git a/config/sounds.cfg b/config/sounds.cfg old mode 100755 new mode 100644 diff --git a/config/survival.cfg b/config/survival.cfg index 24522e4e..ca853150 100644 --- a/config/survival.cfg +++ b/config/survival.cfg @@ -35,11 +35,11 @@ const survOnKill [ survTimeBetKills = (- (millis) $startSurvMillis) // ] [ add2list survTimeBetKills (- (millis) $survLastKill) ] // Other kills survLastKill = (millis) // Update last kill - ] [ + ] [ if (= $arg2 (player1 cn)) [ add2list tmpSurvSets (concat $arg1 $arg2 $arg3 $arg4 (player $arg1 name)) // Player1 was target, pass arguments/data along for use in the after game results/stats messages. ] - ] + ] ] const survOnHit [ diff --git a/source/src/bot/ac_bot_ai.cpp b/source/src/bot/ac_bot_ai.cpp index f5f551d4..84874caa 100644 --- a/source/src/bot/ac_bot_ai.cpp +++ b/source/src/bot/ac_bot_ai.cpp @@ -46,7 +46,7 @@ bool CACBot::ChoosePreferredWeapon() { sWeaponScore = 0; // Minimal score for a weapon sWeaponScore = i > 1 ? 5 : 0; // Primary are usually better - + if (!m_pMyEnt->mag[i] && WeaponInfoTable[i].eWeaponType != TYPE_MELEE) { continue; @@ -127,7 +127,7 @@ bool CACBot::ChoosePreferredWeapon() if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_ROCKET) { m_bShootAtFeet = true; - + } if(lastmillis > m_iChangeWeaponDelay) { diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp index 32c18b3c..1ded4097 100644 --- a/source/src/bot/bot_ai.cpp +++ b/source/src/bot/bot_ai.cpp @@ -127,7 +127,7 @@ bool CBot::FindEnemy(void) { m_pMyEnt->enemy = player1; } - + return m_pMyEnt->enemy != NULL; } @@ -2035,7 +2035,7 @@ bool CBot::IsInFOV(const vec &o) dir = forward; dir.z = 0; // Make 2D - // ideal direction + // ideal direction target = o; target.sub(m_pMyEnt->o); target.z = 0.0f; // Make 2D @@ -2045,5 +2045,5 @@ bool CBot::IsInFOV(const vec &o) flAngle = acos(flDot/(target.magnitude() * dir.magnitude())); return m_pBotSkill->iFov/2.0f >= flAngle/RAD; -} +} // Code of CBot - End diff --git a/source/src/bot/bot_util.cpp b/source/src/bot/bot_util.cpp index 151e330a..d30e6494 100644 --- a/source/src/bot/bot_util.cpp +++ b/source/src/bot/bot_util.cpp @@ -6,7 +6,7 @@ // // Author: // -// +// // // @@ -34,7 +34,7 @@ long lrand (void) // credits go to Ray Gardner for his fast implementation of minimal random // number generators // http://c.snippets.org/snip_lister.php?fname=rg_rand.c - + // compose the two 16-bit parts of the long integer and assemble them static unsigned long lrand_lo, lrand_hi; lrand_lo = 16807 * (long) (lseed & 0xFFFF); // low part @@ -48,7 +48,7 @@ long lrand (void) lrand_lo &= LRAND_MAX; // then get rid of the disturbing bit lrand_lo++; // and increase it a bit (to avoid overflow problems, I suppose) } - + lrand_lo += lrand_hi >> 15; // now do twisted maths to generate the next seed // is the resulting number greater than LRAND_MAX (half the capacity) ? @@ -69,9 +69,9 @@ void lsrand (unsigned long initial_seed) // usually initialized with the time of day, and time is a value that // changes slowly, we bump the seed twice to have it in a more // random state for future calls of the random number generator. - + // fill in the initial seed of the random number generator - lseed = (long) initial_seed; + lseed = (long) initial_seed; lseed = lrand (); // bump it once lseed = lrand (); // bump it twice return; // that's all folks @@ -81,9 +81,9 @@ long RandomLong (long from, long to) { // this function returns a random integer number between (and including) // the starting and ending values passed by parameters from and to. - if (to <= from) + if (to <= from) return (from); - + return (from + lrand () / (LRAND_MAX / (to - from + 1))); } @@ -91,10 +91,10 @@ float RandomFloat (float from, float to) { // this function returns a random floating-point number between (and including) // the starting and ending values passed by parameters from and to. - + if (to <= from) return (from); - + return (from + (float) lrand () / (LRAND_MAX / (to - from))); } @@ -110,42 +110,42 @@ void AnglesToVectors(vec angles, vec &forward, vec &right, vec &up) float cos_pitch; float cos_yaw; float cos_roll; - + // For some reason this has to be done :) // Me = math n00b angles.x = -angles.x; angles.y -= 90; - + // compute the sin and cosine of the pitch component angle = angles.x * degrees_to_radians; sin_pitch = sinf (angle); cos_pitch = cosf (angle); - + // compute the sin and cosine of the yaw component angle = angles.y * degrees_to_radians; sin_yaw = sinf (angle); cos_yaw = cosf (angle); - + // compute the sin and cosine of the roll component angle = angles.z * degrees_to_radians; sin_roll = sinf (angle); cos_roll = cosf (angle); - + // build the FORWARD vector forward.x = cos_pitch * cos_yaw; forward.y = cos_pitch * sin_yaw; forward.z = -sin_pitch; - + // build the RIGHT vector right.x = -(-(sin_roll * sin_pitch * cos_yaw) - (cos_roll * -sin_yaw)); right.y = -(-(sin_roll * sin_pitch * sin_yaw) - (cos_roll * cos_yaw)); right.z = -(sin_roll * cos_pitch); - + // build the UPWARDS vector up.x = ((cos_roll * sin_pitch * cos_yaw) - (sin_roll * -sin_yaw)); up.y = ((cos_roll * sin_pitch * sin_yaw) - (sin_roll * cos_yaw)); up.z = cos_roll * cos_pitch; - + return; } @@ -175,30 +175,30 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult { tr->end = from; tr->collided = false; - + static float flNearestDist, flDist; static vec v; static bool solid; - + flNearestDist = 9999.0f; - + if(OUTBORD((int)from.x, (int)from.y)) return; - + // Check if the 'line' collides with entities like mapmodels loopv(ents) { entity &e = ents[i]; if(e.type!=MAPMODEL) continue; // Only check map models for now - + mapmodelinfo &mmi = getmminfo(e.attr2); if(!&mmi || !mmi.h) continue; - + float lo = (float)(S(e.x, e.y)->floor+mmi.zoff+e.attr3); float hi = lo+mmi.h; - float z = (fabs(from.z-lo) < fabs(from.z-hi)) ? lo : hi; - makevec(&v, e.x, e.y, z); - flDist = GetDistance(from, v); - + float z = (fabs(from.z-lo) < fabs(from.z-hi)) ? lo : hi; + makevec(&v, e.x, e.y, z); + flDist = GetDistance(from, v); + if ((flDist < flNearestDist) && (intersect(&e, from, to, &tr->end))) { flNearestDist = GetDistance(from, tr->end); @@ -213,9 +213,9 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult { playerent *d = players[i]; if(!d || (d==pTracer) || (d->state != CS_ALIVE)) continue; // Only check valid players - - flDist = GetDistance(from, d->o); - + + flDist = GetDistance(from, d->o); + if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end))) { flNearestDist = flDist; @@ -227,23 +227,23 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult playerent *d = player1; // Shortcut if (d && (d!=pTracer) && !BotManager.m_pBotToView && (d->state == CS_ALIVE)) { - flDist = GetDistance(from, d->o); - + flDist = GetDistance(from, d->o); + if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end))) { flNearestDist = flDist; tr->collided = true; } - } + } } - - + + float dx = to.x-from.x; - float dy = to.y-from.y; + float dy = to.y-from.y; int steps = (int)(sqrt(dx*dx+dy*dy)/0.9); if(!steps) // If from and to are on the same cube... { - if (GetDistance(from, to) < flNearestDist) + if (GetDistance(from, to) < flNearestDist) { tr->end = to; sqr *s = S(int(from.x), int(from.y)); @@ -257,12 +257,12 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult } return; } - + float x = from.x; float y = from.y; int i = 0; vec endcube = from; - + // Now check if the 'line' is hit by a cube while(itype==CHF) ceil += s->vdelta/4.0f; float rz = from.z-((from.z-to.z)*(i/(float)steps)); if(rzceil) break; - + endcube.x = x; endcube.y = y; endcube.z = rz; @@ -285,7 +285,7 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult y += dy/(float)steps; i++; } - + if ((i>=steps) && !tr->collided) { tr->end = to; @@ -305,7 +305,7 @@ float GetDistance(vec v1, vec v2) if ((v1.x == 0) && (v2.x == 0) && (v1.y == 0) && (v2.y == 0) && (v1.z == 0) && (v2.z == 0)) return 0.0f; - + return v1.dist(v2); } @@ -314,7 +314,7 @@ float Get2DDistance(vec v1, vec v2) { if ((v1.x == 0) && (v2.x == 0) && (v1.y == 0) && (v2.y == 0)) return 0.0f; - + v1.z = v2.z = 0.0f; return v1.dist(v2); } @@ -333,7 +333,7 @@ bool IsVisible(vec v1, vec v2, dynent *tracer, bool SkipTags) vec PredictPos(vec pos, vec vel, float Time) { float flVelLength = vel.magnitude(); - + if (flVelLength <= 1.0) return pos; // don't bother with low velocities... @@ -378,7 +378,7 @@ vec Normalize(vec v) { float flLen = sqrt(v.x*v.x + v.y*v.y + v.z*v.z); static vec v_norm = g_vecZero; - if (flLen == 0) + if (flLen == 0) { v_norm.x=0;v_norm.y=0;v_norm.z=1; } @@ -392,7 +392,7 @@ vec Normalize(vec v) float GetYawDiff(float curyaw, vec v1, vec v2) { - float yaw = -(float)atan2(v2.x - v1.x, v2.y - v1.y)/PI*180+180; + float yaw = -(float)atan2(v2.x - v1.x, v2.y - v1.y)/PI*180+180; return yaw-curyaw; } @@ -414,20 +414,20 @@ int GetDirection(const vec &angles, const vec &v1, const vec &v2) tmp.z = 0.0f; // Make 2D tmp = Normalize(tmp); forward.z = 0; // Make 2D - + flDot = tmp.dot(forward); cross = CrossProduct(tmp, forward); - + int Dir = DIR_NONE; - + if (cross.z > 0.1f) Dir |= LEFT; else if (cross.z < -0.1f) Dir |= RIGHT; if (flDot < -0.1f) Dir |= BACKWARD; else if (flDot > 0.1f) Dir |= FORWARD; - + if (v1.z > v2.z) Dir |= DOWN; if (v1.z < v2.z) Dir |= UP; - + return Dir; } @@ -456,14 +456,14 @@ const char *SkillNrToSkillName(short skillnr) else if (skillnr == 2) return "medium"; else if (skillnr == 3) return "worse"; else if (skillnr == 4) return "bad"; - + return NULL; } bool IsInGame(dynent *d) { if (!d) return false; - + if (d->type==ENT_BOT) { loopv(bots) @@ -480,11 +480,11 @@ bool IsInGame(dynent *d) { loopv(players) { -#ifdef VANILLA_CUBE +#ifdef VANILLA_CUBE if (!players[i] || (players[i]->state == CS_DEDHOST)) continue; #elif defined(AC_CUBE) if (!players[i]) continue; -#endif +#endif if (players[i] == d) return true; } diff --git a/source/src/bot/bot_waypoint.h b/source/src/bot/bot_waypoint.h index d96f80de..5ee0dbdb 100644 --- a/source/src/bot/bot_waypoint.h +++ b/source/src/bot/bot_waypoint.h @@ -44,27 +44,27 @@ struct waypoint_version_1_s int iFlags; vec v_origin; TLinkedList ConnectedWPs; - + // A* stuff float f, g; waypoint_version_1_s *pParent; - + // Construction - waypoint_version_1_s(void) : iFlags(0), f(0.0f), g(0.0f), pParent(NULL) { }; + waypoint_version_1_s(void) : iFlags(0), f(0.0f), g(0.0f), pParent(NULL) { }; }; struct node_s { - vec v_origin; + vec v_origin; int iFlags; short sTriggerNr; short sYaw; short sCost; // Base and static cost TLinkedList ConnectedWPs; TLinkedList ConnectedWPsWithMe; - + TLinkedList FailedGoalList; - + // Construction node_s(void) : iFlags(0), sTriggerNr(0), sYaw(-1), sCost(10) { }; node_s(const vec &o, const int &f, const short t=0, const short y=-1) : v_origin(o), @@ -80,11 +80,11 @@ struct waypoint_s short g[2]; waypoint_s *pParent[2]; bool bIsOpen[2], bIsClosed[2]; - + // Construction waypoint_s(void) : pNode(NULL) { bIsOpen[0] = bIsOpen[1] = bIsClosed[0] = bIsClosed[1] = false; pParent[0] = pParent[1] = NULL; - g[0] = g[1] = 0; }; + g[0] = g[1] = 0; }; }; class CWaypointClass @@ -98,7 +98,7 @@ protected: vec m_vLastCreatedWP; float m_fPathDrawTime; char m_szMapName[32]; - + #ifdef WP_FLOOD bool m_bFlooding; // True if flooding map with waypoints bool m_bFilteringNodes; @@ -106,9 +106,9 @@ protected: int m_iCurFloodX, m_iCurFloodY; int m_iFloodSize; int m_iFilteredNodes; -#endif +#endif friend class CBot; - + public: TLinkedList m_Waypoints[MAX_MAP_GRIDS][MAX_MAP_GRIDS]; int m_iWaypointCount; // number of waypoints currently in use @@ -153,7 +153,7 @@ public: void CalcCost(node_s *pNode); void ReCalcCosts(void); - + #ifdef WP_FLOOD // Flood functions virtual void StartFlood(void); diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index 6edc4163..782365f6 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -1313,16 +1313,7 @@ COMMANDF(testvisible, "i", (int *dir) { testvisible(*dir); }); void mapsize(void) { - switch(ssize) - { - case 128: intret(7); break; - case 256: intret(8); break; - case 512: intret(9); break; - case 1024: intret(10); break; - case 2048: intret(11); break; - case 4096: intret(12); break; - default: intret(6); break; - } + intret(sfactor); } COMMAND(mapsize, ""); diff --git a/source/src/client.cpp b/source/src/client.cpp index fbae6f07..816244ff 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -920,7 +920,7 @@ int pckserversort(pckserver **a, pckserver **b) { if((*a)->ping < 0) return ((*b)->ping < 0) ? 0 : 1; if((*b)->ping < 0) return -1; - + return (*a)->ping == (*b)->ping ? 0 : ((*a)->ping < (*b)->ping ? -1 : 1); } diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 7e20ad58..dffb6c76 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1407,9 +1407,9 @@ void callvote(int type, const char *arg1, const char *arg2, const char *arg3) break; default: - - - + + + putint(p, atoi(arg1)); break; } diff --git a/source/src/command.cpp b/source/src/command.cpp index 2f220502..f238ad08 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -438,7 +438,7 @@ char *conc(char **w, int n, bool space) { strcat(r, w[i]); // make string-list out of all arguments if(i==n-1) break; - bool col = w[i][0] == '\f' && w[i][2] == '\0'; + bool col = w[i][0] == '\f' && w[i][1] && w[i][2] == '\0'; if(space && !col) strcat(r, " "); } return r; @@ -1128,7 +1128,7 @@ void looplist(char *list, char *var, char *body) if(loop_break) { loop_break = false; - break; + break; // FIXME (leaking memory) } } popident(*id); @@ -1282,11 +1282,11 @@ char *strreplace(char *dest, const char *source, const char *search, const char int stringsort(const char **a, const char **b) { return strcmp(*a, *b); } void sortlist(char *list) - { +{ char* buf; buf = new char [strlen(list)]; strcpy(buf, ""); //output - if(strcmp(list, "") == 0) + if(*list == '\0') { //no input result(buf); @@ -1295,7 +1295,7 @@ void sortlist(char *list) } vector elems; - explodelist(list, elems); + explodelist(list, elems); // FIXME (leaking memory) elems.sort(stringsort); strcpy(buf, elems[0]); @@ -1314,7 +1314,7 @@ void sortlist(char *list) char* buf; buf = new char [strlen(list)]; strcpy(buf, ""); //output - if(strcmp(list, "") == 0) + if(*list == '\0') { // no input result(buf); @@ -1328,12 +1328,12 @@ void sortlist(char *list) vector swap; explodelist(v, swap); - if (strcmp(v, "") == 0 || //no input - swap.length()%2 != 0) //incorrect input + if(*v == '\0' || //no input + swap.length()%2 != 0) //incorrect input { result(buf); delete [] buf; - return; + return; // FIXME (leaking memory) } char tmp[255]; strcpy (tmp, ""); @@ -1357,6 +1357,7 @@ void sortlist(char *list) result(buf); //result delete [] buf; + // FIXME (leaking memory) } COMMANDN(c, colora, "s"); @@ -1606,7 +1607,7 @@ void substr_(char *fs, int *pa, int *len) if(ia>fslen || ia < 0 || ilen < 0) return; if(!ilen) ilen = fslen-ia; - (fs+ia)[ilen] = '\0'; + if(ilen >= 0 && ilen < int(strlen(fs+ia))) (fs+ia)[ilen] = '\0'; result(fs+ia); } diff --git a/source/src/console.h b/source/src/console.h index 274ac6d0..1de97b9a 100644 --- a/source/src/console.h +++ b/source/src/console.h @@ -22,7 +22,7 @@ template struct consolebuffer while(conlines.length() > maxlines) delete[] conlines.pop().line; } - virtual ~consolebuffer() + virtual ~consolebuffer() { while(conlines.length()) delete[] conlines.pop().line; } @@ -52,13 +52,13 @@ struct textinputbuffer case SDLK_KP_ENTER: break; - case SDLK_HOME: - if(strlen(buf)) pos = 0; - break; + case SDLK_HOME: + if(strlen(buf)) pos = 0; + break; - case SDLK_END: - pos = -1; - break; + case SDLK_END: + pos = -1; + break; case SDLK_DELETE: { @@ -91,7 +91,7 @@ struct textinputbuffer case SDLK_v: extern void pasteconsole(char *dst); #ifdef __APPLE__ -#define MOD_KEYS (KMOD_LMETA|KMOD_RMETA) +#define MOD_KEYS (KMOD_LMETA|KMOD_RMETA) #else #define MOD_KEYS (KMOD_LCTRL|KMOD_RCTRL) #endif @@ -111,7 +111,7 @@ struct textinputbuffer if(len+1 < sizeof(buf)) { if(pos < 0) buf[len] = unicode; - else + else { memmove(&buf[pos+1], &buf[pos], len - pos); buf[pos++] = unicode; @@ -146,13 +146,13 @@ struct textinputbuffer_wip case SDLK_KP_ENTER: break; - case SDLK_HOME: - if(strlen(buf)) pos = 0; - break; + case SDLK_HOME: + if(strlen(buf)) pos = 0; + break; - case SDLK_END: - pos = -1; - break; + case SDLK_END: + pos = -1; + break; case SDLK_DELETE: { @@ -211,7 +211,7 @@ struct textinputbuffer_wip case SDLK_v: extern void pasteconsole(char *dst); #ifdef __APPLE__ -#define MOD_KEYS (KMOD_LMETA|KMOD_RMETA) +#define MOD_KEYS (KMOD_LMETA|KMOD_RMETA) #else #define MOD_KEYS (KMOD_LCTRL|KMOD_RCTRL) #endif diff --git a/source/src/crypto.cpp b/source/src/crypto.cpp index b0443a4c..44041bed 100644 --- a/source/src/crypto.cpp +++ b/source/src/crypto.cpp @@ -845,9 +845,9 @@ bool checkchallenge(const char *answerstr, void *correct) ////////////////////////// crypto rand //////////////////////////////////////// -#define N (624) -#define M (397) -#define K (0x9908B0DFU) +#define N (624) +#define M (397) +#define K (0x9908B0DFU) static uint state[N]; static int next = N; diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 877bebab..d527c323 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -403,9 +403,9 @@ void editdrag(bool isdown) lasty = cy; lasth = ch; tofronttex(); - + bool ctrlpressed = false; - + if (identexists("newselkeys")) { extern vector keyms; diff --git a/source/src/entity.h b/source/src/entity.h index e118d16d..567dab6d 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -387,15 +387,15 @@ public: case 3: ad = (int) (4.0f/25.0f * armour) + 25; break; // 41 default: break; } - + //ra - reduced armor //rd - reduced damage int ra = (int) (ad * damage/100.0f); int rd = ra-(ra*(gi.piercing/100.0f)); //Who cares about rounding errors anyways? - + armour -= ra; damage -= rd; - + health -= damage; return damage; } @@ -672,4 +672,4 @@ struct package package() : name(NULL), type(-1), number(0), pending(false), source(NULL), curl(NULL) {} }; -#endif \ No newline at end of file +#endif diff --git a/source/src/geom.h b/source/src/geom.h index 977a3b21..269fee5c 100644 --- a/source/src/geom.h +++ b/source/src/geom.h @@ -86,7 +86,7 @@ struct vec float magnitude() const { return sqrtf(squaredlen()); } vec &normalize() { div(magnitude()); return *this; } - // should NOT be used + // should NOT be used float fmag() const { return fSqrt(squaredlen()); } float ufmag() const { return ufSqrt(squaredlen()); } float fmagxy() const { return fSqrt(x*x + y*y); } @@ -365,7 +365,7 @@ struct glmatrixf { return vec(v[12], v[13], v[14]); } - + float determinant() const; void adjoint(const glmatrixf &m); bool invert(const glmatrixf &m, float mindet = 1.0e-10f); diff --git a/source/src/hudgun.h b/source/src/hudgun.h index c7275c6e..b2c29063 100644 --- a/source/src/hudgun.h +++ b/source/src/hudgun.h @@ -1,8 +1,8 @@ VARP(nosway, 0, 0, 1); VARP(swayspeeddiv, 1, 105, 1000); -VARP(swaymovediv, 1, 200, 1000); +VARP(swaymovediv, 1, 200, 1000); VARP(swayupspeeddiv, 1, 105, 1000); -VARP(swayupmovediv, 1, 200, 1000); +VARP(swayupmovediv, 1, 200, 1000); struct weaponmove { @@ -12,14 +12,14 @@ struct weaponmove float k_rot, kick; vec pos; int anim, basetime; - + 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) { kick = k_rot = 0.0f; pos = p->o; - + if(!nosway) { float k = pow(0.7f, (lastmillis-lastsway)/10.0f); @@ -56,12 +56,12 @@ struct weaponmove anim = ANIM_GUN_IDLE; basetime = lastaction; - int timediff = lastmillis-lastaction, + int timediff = lastmillis-lastaction, animtime = min(p->weaponsel->gunwait, (int)p->weaponsel->info.attackdelay); vec sway = aimdir; float progress = 0.0f; float k_back = 0.0f; - + if(p->weaponsel==p->lastattackweapon) { progress = max(0.0f, min(1.0f, timediff/(float)animtime)); @@ -70,13 +70,13 @@ struct weaponmove if(p->crouching) kick *= 0.75f; if(p->lastaction) anim = p->weaponsel->modelanim(); } - + if(p->weaponsel->info.mdl_kick_rot || p->weaponsel->info.mdl_kick_back) { k_rot = p->weaponsel->info.mdl_kick_rot*kick; k_back = p->weaponsel->info.mdl_kick_back*kick/10; } - + if(nosway) sway.x = sway.y = sway.z = 0; else { @@ -84,23 +84,23 @@ struct weaponmove float swayupspeed = cosf((float)swaymillis/swayupspeeddiv)/(swayupmovediv/10.0f); float plspeed = min(1.0f, sqrtf(p->vel.x*p->vel.x + p->vel.y*p->vel.y)); - + swayspeed *= plspeed/2; swayupspeed *= plspeed/2; swap(sway.x, sway.y); sway.y = -sway.y; - + swayupspeed = fabs(swayupspeed); // sway a semicirle only sway.z = 1.0f; - + sway.x *= swayspeed; sway.y *= swayspeed; sway.z *= swayupspeed; if(p->crouching) sway.mul(0.75f); } - + pos.x -= aimdir.x*k_back+sway.x; pos.y -= aimdir.y*k_back+sway.y; pos.z -= aimdir.z*k_back+sway.z; diff --git a/source/src/i18n.h b/source/src/i18n.h index 585ac123..80a73476 100644 --- a/source/src/i18n.h +++ b/source/src/i18n.h @@ -8,7 +8,7 @@ struct i18nmanager char *locale; i18nmanager(const char *domain, const char *basepath); // initialize locale system - + }; extern char *lang; diff --git a/source/src/main.cpp b/source/src/main.cpp index 284c26fe..ee490743 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -1306,7 +1306,7 @@ int main(int argc, char **argv) // in the screenshot regardless of which frame buffer is current if (!minimized) { - gl_drawframe(screen->w, screen->h, fpshighfps ? fps/highfps : 1.0f), fps); + gl_drawframe(screen->w, screen->h, fpshighfps ? fps/highfps : 1.0f), fps); } addsleep(0, "screenshot"); needsautoscreenshot = false; @@ -1330,4 +1330,4 @@ int main(int argc, char **argv) } VAR(version, 1, AC_VERSION, 0); -VAR(protocol, 1, PROTOCOL_VERSION, 0); \ No newline at end of file +VAR(protocol, 1, PROTOCOL_VERSION, 0); diff --git a/source/src/model.h b/source/src/model.h index db4b42cc..ea840ae3 100644 --- a/source/src/model.h +++ b/source/src/model.h @@ -45,7 +45,7 @@ struct model float alphatest, translucency, scale, radius, shadowdist; vec translate; int cachelimit, batch; - + //model() : cullface(true), vertexlight(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {} model() : cullface(true), vertexlight(false), alphablend(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {} virtual ~model() {} diff --git a/source/src/oggstream.cpp b/source/src/oggstream.cpp index fa640a66..f99fc2d0 100644 --- a/source/src/oggstream.cpp +++ b/source/src/oggstream.cpp @@ -32,12 +32,12 @@ static long oggcallbacktell(void *datasource) return s ? s->tell() : -1; } -ov_callbacks oggcallbacks = { oggcallbackread, oggcallbackseek, oggcallbackclose, oggcallbacktell }; +ov_callbacks oggcallbacks = { oggcallbackread, oggcallbackseek, oggcallbackclose, oggcallbacktell }; // ogg audio streaming oggstream::oggstream() : valid(false), isopen(false), src(NULL) -{ +{ reset(); // grab a source and keep it during the whole lifetime @@ -55,7 +55,7 @@ oggstream::oggstream() : valid(false), isopen(false), src(NULL) src = NULL; } } - + if(!src) return; alclearerr(); @@ -63,12 +63,12 @@ oggstream::oggstream() : valid(false), isopen(false), src(NULL) valid = !ALERR; } -oggstream::~oggstream() -{ +oggstream::~oggstream() +{ reset(); if(src) sourcescheduler::instance().releasesource(src); - + if(alIsBuffer(bufferids[0]) || alIsBuffer(bufferids[1])) { alclearerr(); @@ -91,13 +91,13 @@ void oggstream::reset() format = AL_NONE; // reset file handler - if(isopen) + if(isopen) { isopen = !ov_clear(&oggfile); } info = NULL; totalseconds = 0.0f; - + // default settings startmillis = endmillis = startfademillis = endfademillis = 0; gain = 1.0f; // reset gain but not volume setting @@ -108,7 +108,7 @@ bool oggstream::open(const char *f) { ASSERT(valid); if(!f) return false; - if(playing() || isopen) reset(); + if(playing() || isopen) reset(); const char *exts[] = { "", ".wav", ".ogg" }; string filepath; @@ -163,7 +163,7 @@ bool oggstream::stream(ALuint bufid) else if (bytes < 0) return false; else break; // done } - + if(size==0) { if(looping && !ov_pcm_seek(&oggfile, 0)) continue; // try again to replay @@ -174,7 +174,7 @@ bool oggstream::stream(ALuint bufid) alBufferData(bufid, format, pcm, size, info->rate); return !ALERR; } - + return false; } @@ -182,7 +182,7 @@ bool oggstream::update() { ASSERT(valid); if(!isopen || !playing()) return false; - + // update buffer queue ALint processed; bool active = true; @@ -231,20 +231,20 @@ bool oggstream::update() return active; } -bool oggstream::playing() -{ +bool oggstream::playing() +{ ASSERT(valid); return src->playing(); } -void oggstream::updategain() -{ +void oggstream::updategain() +{ ASSERT(valid); src->gain(gain*volume); } void oggstream::setgain(float g) -{ +{ ASSERT(valid); gain = g; updategain(); @@ -279,7 +279,7 @@ bool oggstream::playback(bool looping) this->looping = looping; if(!stream(bufferids[0]) || !stream(bufferids[1])) return false; if(!startmillis && !endmillis && !startfademillis && !endfademillis) setgain(1.0f); - + updategain(); src->queuebuffers(2, bufferids); src->play(); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 2f018c3d..68323c1a 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -263,16 +263,16 @@ void loadcrosshair(char *c, char *name) } return; } - + int n = -1; - + for (int i = 0; i < CROSSHAIR_NUM; i++) { if(strcmp(crosshairnames[i], name) == 0) { n = i; break; } } - + if (n < 0 || n >= CROSSHAIR_NUM) return; - + crosshairs[n] = loadcrosshairtexture(c); } diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 671bb3d2..53265f7c 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -45,12 +45,12 @@ void mdlalphatest(int *alphatest) COMMAND(mdlalphatest, "i"); void mdlalphablend(int *alphablend) //ALX Alpha channel models -{ +{ checkmdl; loadingmodel->alphablend = *alphablend!=0; } COMMAND(mdlalphablend, "i"); - + void mdlscale(int *percent) { checkmdl; diff --git a/source/src/rndmap.cpp b/source/src/rndmap.cpp index c72a4dc6..9240a3d2 100644 --- a/source/src/rndmap.cpp +++ b/source/src/rndmap.cpp @@ -60,7 +60,7 @@ void perlinarea(block &b, int scale, int seed, int psize) for(int y = b.y; y<=b.y+b.ys; y++) for(int x = b.x; x<=b.x+b.xs; x++) { sqr *s = S(x,y); - if(!SOLID(s) && x!=b.x+b.xs && y!=b.y+b.ys) s->type = FHF; + if(!SOLID(s) && x!=b.x+b.xs && y!=b.y+b.ys) s->type = FHF; s->vdelta = (int)(perlinnoise_2D(x/((float)scale)+seed, y/((float)scale)+seed, 1000, 0.01f)*50+25); if(s->vdelta>128) s->vdelta = 0; } diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index 1cbbb433..6f0d51c6 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -323,7 +323,7 @@ void renderscores(void *menu, bool init) winner = m_flags ? (teamscores[sort].flagscore > teamscores[team_opposite(sort)].flagscore ? sort : -1) : (teamscores[sort].frags > teamscores[team_opposite(sort)].frags ? sort : -1); - + } else { // ffa mode @@ -361,7 +361,7 @@ void renderscores(void *menu, bool init) if(!minutesremaining) { concatstring(modeline, ", intermission"); - + if (m_teammode) // Add in the winning team { switch(winner) diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp index da58ed7f..6b1d6340 100644 --- a/source/src/serverbrowser.cpp +++ b/source/src/serverbrowser.cpp @@ -1299,7 +1299,7 @@ void retrieveservers(vector &data) if(mastertype == AC_MASTER_HTTP) { CURL *curl = curl_easy_init(); - + char *pname = curl_easy_escape(curl, global_name, 0); string request; sprintf(request, "http://%s/retrieve.do?action=list&name=%s&version=%d&build=%d", mastername, pname, AC_VERSION, getbuildtype()|(1<<16)); @@ -1406,7 +1406,7 @@ void retrieveservers(vector &data) if(timeout > RETRIEVELIMIT) break; } if(data.length()) data.add('\0'); - enet_socket_destroy(sock); + enet_socket_destroy(sock); } } diff --git a/source/src/servercontroller.h b/source/src/servercontroller.h index 675ea4ec..911e1655 100644 --- a/source/src/servercontroller.h +++ b/source/src/servercontroller.h @@ -19,15 +19,15 @@ struct winservice : servercontroller HANDLE stopevent; const char *name; - winservice(const char *name) : name(name) - { - callbacks::svc = this; + winservice(const char *name) : name(name) + { + callbacks::svc = this; statushandle = 0; }; - ~winservice() - { - if(status.dwCurrentState != SERVICE_STOPPED) stop(); + ~winservice() + { + if(status.dwCurrentState != SERVICE_STOPPED) stop(); callbacks::svc = NULL; } @@ -39,10 +39,10 @@ struct winservice : servercontroller } void keepalive() - { + { if(statushandle) { - report(SERVICE_RUNNING, 0); + report(SERVICE_RUNNING, 0); handleevents(); } }; @@ -54,7 +54,7 @@ struct winservice : servercontroller report(SERVICE_STOP_PENDING, 0); if(stopevent) CloseHandle(stopevent); status.dwControlsAccepted &= ~(SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN); - report(SERVICE_STOPPED, 0); + report(SERVICE_STOPPED, 0); } } @@ -108,7 +108,7 @@ struct winservice : servercontroller extern int main(int argc, char **argv); return main(argc, argv); } - + struct callbacks { @@ -121,7 +121,7 @@ struct winservice : servercontroller { HANDLE eventsrc = RegisterEventSource(NULL, "AC Server"); if(eventsrc) - { + { int eventid = ((error ? 0x11 : 0x1) << 10) & (0x1 << 9) & (FACILITY_NULL << 6) & 0x1; // TODO: create event definitions LPCTSTR msgs[1] = { msg }; int r = ReportEvent(eventsrc, error ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE, 0, 4, NULL, 1, 0, msgs, NULL); diff --git a/source/src/serverevents.h b/source/src/serverevents.h index 0e18ff12..e61f5ca5 100644 --- a/source/src/serverevents.h +++ b/source/src/serverevents.h @@ -75,7 +75,7 @@ void processevent(client *c, shotevent &e) int numhits_c = (h.info & 0x0000FF00) >> 8, numhits_m = (h.info & 0x00FF0000) >> 16, numhits_o = (h.info & 0xFF000000) >> 24; tothits_c += numhits_c; tothits_m += numhits_m; tothits_o += numhits_o; rays = numhits_c + numhits_m + numhits_o; - + if(rays < 1 || tothits_c > SGRAYS || tothits_m > SGRAYS || tothits_o > SGRAYS || bonusdist > SGDMGBONUS) continue; gib = rays == maxrays; diff --git a/source/src/serverfiles.h b/source/src/serverfiles.h index 756760a5..87a92a12 100644 --- a/source/src/serverfiles.h +++ b/source/src/serverfiles.h @@ -905,7 +905,7 @@ struct killmessagesfile : serverconfigfile { l = p; p += strlen(p) + 1; l = strtok(l, sep); - + char *message; if(l) { @@ -916,7 +916,7 @@ struct killmessagesfile : serverconfigfile { int errors = 0; int gun = atoi(s); - + s += strlen(s) + 1; while(s[0] == ' ') s++; int hasquotes = strspn(s, "\""); @@ -931,7 +931,7 @@ struct killmessagesfile : serverconfigfile if(end) break; } if(end) message[end-message] = '\0'; - + if(gun < 0 || gun >= NUMGUNS) { logline(ACLOG_INFO, " error in line %i, invalid gun : %i", line, gun); diff --git a/source/src/shadow.cpp b/source/src/shadow.cpp index 85e68996..14ed3b91 100644 --- a/source/src/shadow.cpp +++ b/source/src/shadow.cpp @@ -83,7 +83,7 @@ static void extrudeshadowtiles(int x1, int y1, int x2, int y2, int x3, int y3) } fracl = 0; } - if(x2 > x3 || y1 == cy) + if(x2 > x3 || y1 == cy) { if(x2 > rx) rx = x2; drx = x3 - rx; dry = y3 - cy; @@ -160,7 +160,7 @@ bool addshadowbox(const vec &bbmin, const vec &bbmax, const vec &extrude, const loopi(8) { vec4 &p = v[i]; - mat.transform(vec(i&1 ? bbmax.x : bbmin.x, i&2 ? bbmax.y : bbmin.y, i&4 ? bbmax.z : bbmin.z), p); + mat.transform(vec(i&1 ? bbmax.x : bbmin.x, i&2 ? bbmax.y : bbmin.y, i&4 ? bbmax.z : bbmin.z), p); if(p.z >= -p.w) { float x = p.x / p.w, y = p.y / p.w; @@ -177,7 +177,7 @@ bool addshadowbox(const vec &bbmin, const vec &bbmax, const vec &extrude, const if(front < 8 || ev.z < -ev.w) loopi(8) { const vec4 &p = v[i]; - if(p.z >= -p.w) + if(p.z >= -p.w) { if(ev.z >= -ev.w) continue; float t = ev.z/(ev.z - p.z), diff --git a/source/src/soundlocation.cpp b/source/src/soundlocation.cpp index 9c8e65eb..7b15a08a 100644 --- a/source/src/soundlocation.cpp +++ b/source/src/soundlocation.cpp @@ -9,8 +9,8 @@ int warn_about_unregistered_sound = 0; location::location(int sound, const worldobjreference &r, int priority) : cfg(NULL), src(NULL), ref(NULL), stale(false), playmillis(0) { vector &sounds = (r.type==worldobjreference::WR_ENTITY ? mapsounds : gamesounds); - if(!sounds.inrange(sound)) - { + if(!sounds.inrange(sound)) + { if (lastmillis - warn_about_unregistered_sound > 30 * 1000) // delay message to every 30 secs so console is not spammed. { // occurs when a map contains an ambient sound entity, but sound entity is not found in map cfg file. @@ -28,12 +28,12 @@ location::location(int sound, const worldobjreference &r, int priority) : cfg(NU if((r.type==worldobjreference::WR_ENTITY && cfg->maxuses >= 0 && cfg->uses >= cfg->maxuses) || cfg->muted || (cfg->audibleradius && dist>cfg->audibleradius)) // check max-use limits and audible radius { stale = true; - return; + return; } // assign buffer sbuffer *buf = cfg->buf; - if(!buf || !buf->id) + if(!buf || !buf->id) { stale = true; return; @@ -53,10 +53,10 @@ location::location(int sound, const worldobjreference &r, int priority) : cfg(NU attachworldobjreference(r); } -location::~location() +location::~location() { if(src) sourcescheduler::instance().releasesource(src); - if(cfg) cfg->ondetach(); + if(cfg) cfg->ondetach(); if(ref) { ref->detach(); @@ -75,7 +75,7 @@ void location::attachworldobjreference(const worldobjreference &r) ref->detach(); DELETEP(ref); } - ref = r.clone(); + ref = r.clone(); evaluateworldobjref(); ref->attach(); } @@ -91,7 +91,7 @@ void location::onsourcereassign(source *s) { if(s==src) { - stale = true; + stale = true; src = NULL; } } @@ -133,7 +133,7 @@ void location::updatepos() if(ref->nodistance()) { // own distance model for entities/mapsounds: linear & clamping - + const float innerradius = float(eref.ent->attr3); // full gain area / size property const float outerradius = float(eref.ent->attr2); // fading gain area / radius property @@ -175,7 +175,7 @@ void location::update() case AL_STOPPED: case AL_PAUSED: case AL_INITIAL: - stale = true; + stale = true; DEBUG("location is stale"); break; } @@ -216,7 +216,7 @@ float location::offset() return src->secoffset(); } -void location::drop() +void location::drop() { src->stop(); stale = true; // drop from collection on next update cycle @@ -226,7 +226,7 @@ void location::drop() // location collection location *locvector::find(int sound, worldobjreference *ref, const vector &soundcollection /* = gamesounds*/) -{ +{ if(sound<0 || sound>=soundcollection.length()) return NULL; loopi(ulen) if(buf[i] && !buf[i]->stale) { @@ -279,7 +279,7 @@ void locvector::updatelocations() // force pitch across all locations void locvector::forcepitch(float pitch) { - loopv(*this) + loopv(*this) { location *l = buf[i]; if(!l) continue; diff --git a/source/src/soundscheduler.cpp b/source/src/soundscheduler.cpp index 3a37ccbf..b9d0ca1c 100644 --- a/source/src/soundscheduler.cpp +++ b/source/src/soundscheduler.cpp @@ -61,7 +61,7 @@ void sourcescheduler::reset() source *sourcescheduler::newsource(int priority, const vec &o) { - if(!sources.length()) + if(!sources.length()) { DEBUG("empty source collection"); return NULL; @@ -72,9 +72,9 @@ source *sourcescheduler::newsource(int priority, const vec &o) // reserve some sources for sounds of higher priority int reserved = (SP_HIGHEST-priority)*soundschedreserve; DEBUGVAR(reserved); - + // search unused source - loopv(sources) + loopv(sources) { if(!sources[i]->locked && reserved--<=0) { @@ -84,7 +84,7 @@ source *sourcescheduler::newsource(int priority, const vec &o) } } - if(!src) + if(!src) { DEBUG("no empty source found"); @@ -108,7 +108,7 @@ source *sourcescheduler::newsource(int priority, const vec &o) { source *s = sources[i]; if(s->priority==SP_HIGHEST) continue; // highest priority sounds can't be replaced - + const vec & otherpos = s->position(); float otherdist = otherpos.iszero() ? 0.0f : camera1->o.dist(otherpos); float otherscore = (s->priority*soundschedpriorityscore) - (otherdist*soundscheddistancescore) + soundschedoldbonus; @@ -128,7 +128,7 @@ source *sourcescheduler::newsource(int priority, const vec &o) } } - if(!src) + if(!src) { DEBUG("sound aborted, no channel takeover possible"); return NULL; @@ -147,9 +147,9 @@ void sourcescheduler::releasesource(source *src) ASSERT(src->locked); // detect double release if(!src) return; - + DEBUG("unlocking source"); - + src->unlock(); if(sources.length() > numsoundchannels) diff --git a/source/src/stream.cpp b/source/src/stream.cpp index 5bfa9670..6fc653e1 100644 --- a/source/src/stream.cpp +++ b/source/src/stream.cpp @@ -337,7 +337,7 @@ bool preparedir(const char *destination) dirs.add(newstring(dir)); copystring(dir, parentdir(dir)); } - + loopvrev(dirs) if(!createdir(dirs[i])) return false; return true; } diff --git a/source/src/texture.cpp b/source/src/texture.cpp index fe5240ea..69379304 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -872,4 +872,4 @@ void guidetoggle() } } -COMMAND(guidetoggle, ""); \ No newline at end of file +COMMAND(guidetoggle, ""); diff --git a/source/src/tristrip.h b/source/src/tristrip.h index 55393427..3bd4161e 100644 --- a/source/src/tristrip.h +++ b/source/src/tristrip.h @@ -11,7 +11,7 @@ struct tristrip GLsizei count; drawcall() {} - drawcall(GLenum type, GLuint start, GLsizei count = 0) : type(type), start(start), minvert(~0U), maxvert(0), count(count) {} + drawcall(GLenum type, GLuint start, GLsizei count = 0) : type(type), start(start), minvert(~0U), maxvert(0), count(count) {} }; enum @@ -34,13 +34,13 @@ struct tristrip } if(dbgts && old==UNUSED) conoutf("excessive links"); return false; - } - + } + void unlink(ushort neighbor, ushort unused = UNUSED) { loopi(3) if(n[i]==neighbor) n[i] = unused; } - + int numlinks() const { int num = 0; loopi(3) if(n[i]=1 ? 3-i : i]); return; } - int from = findedge(first, triangles[cur]), + int from = findedge(first, triangles[cur]), to = findedge(first, triangles[cur], first.v[from]); - if(from+1!=to) swap(from, to); + if(from+1!=to) swap(from, to); strip.add(first.v[(to+1)%3]); if(reverse) swap(from, to); strip.add(first.v[from]); @@ -252,7 +252,7 @@ struct tristrip if(!strips.empty() && degen) { strips.dup(); strips.add(strip[0]); } else draws.add(drawcall(GL_TRIANGLE_STRIP, strips.length())); drawcall &d = draws.last(); - loopv(strip) + loopv(strip) { ushort index = strip[i]; strips.add(index); @@ -264,7 +264,7 @@ struct tristrip if(prims && !singles.empty()) { drawcall &d = draws.add(drawcall(GL_TRIANGLES, strips.length())); - loopv(singles) + loopv(singles) { ushort index = singles[i]; strips.add(index); @@ -280,4 +280,4 @@ struct tristrip static inline uint hthash(const tristrip::edge &x) { return x.from^x.to; } static inline bool htcmp(const tristrip::edge &x, const tristrip::edge &y) { return x.from==y.from && x.to==y.to; } - + diff --git a/source/src/varray.h b/source/src/varray.h index bb32bb39..6966ac79 100644 --- a/source/src/varray.h +++ b/source/src/varray.h @@ -54,7 +54,7 @@ namespace varray template static inline void attribv(const T *v) { - data.put((const uchar *)v, N*sizeof(T)); + data.put((const uchar *)v, N*sizeof(T)); } extern int end(); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 508d25ce..eaf7e94d 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -189,7 +189,7 @@ void createrays(vec &from, vec &to) // create random spread of rays for the shot int rndmul = rnd(wrange); float veclen = base + rndmul/100.0f; p.mul( veclen ); - + p.rotate( 2*M_PI/SGRAYS * i + rnddir , dir ); vec rray = vec(to); float nvl = veclen / ( ( SGCObase / 100.0f ) + ( SGCOrange / 100.0f ) ); diff --git a/source/src/winserviceinstaller.h b/source/src/winserviceinstaller.h index d7f7d961..028ec5e1 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/worldio.cpp b/source/src/worldio.cpp index cc20f1b3..75b0207a 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -590,4 +590,4 @@ bool load_world(char *mname) // still supports all map formats that have return true; } -COMMANDN(savemap, save_world, "s"); \ No newline at end of file +COMMANDN(savemap, save_world, "s"); diff --git a/source/src/worldocull.cpp b/source/src/worldocull.cpp index 57c30b0b..5e696f2f 100644 --- a/source/src/worldocull.cpp +++ b/source/src/worldocull.cpp @@ -80,7 +80,7 @@ static inline float ca(float x, float y) { return x>y ? y/x : 2-x/y; } static inline float ma(float x, float y) { return x==0 ? (y>0 ? 2 : -2) : y/x; } #endif -int isoccluded(float vx, float vy, float cx, float cy, float csize) // v = viewer, c = cube to test +int isoccluded(float vx, float vy, float cx, float cy, float csize) // v = viewer, c = cube to test { // ABC // D E @@ -127,7 +127,7 @@ int isoccluded(float vx, float vy, float cx, float cy, float csize) // v = v float dist = xdist+ydist-1; // 1 needed? int si = int(h*(NUMRAYS/8))+NUMRAYS; // get indexes into occlusion map from angles - int ei = int(l*(NUMRAYS/8))+NUMRAYS+1; + int ei = int(l*(NUMRAYS/8))+NUMRAYS+1; if(ei<=si) ei += NUMRAYS; for(int i = si; i<=ei; i++) diff --git a/source/src/worldrender.cpp b/source/src/worldrender.cpp index fb149502..e15c3f46 100644 --- a/source/src/worldrender.cpp +++ b/source/src/worldrender.cpp @@ -74,7 +74,7 @@ int stats[LARGEST_FACTOR]; // detect those cases where a higher mip solid has a visible wall next to lower mip cubes // (used for wall rendering below) -bool issemi(int mip, int x, int y, int x1, int y1, int x2, int y2) +bool issemi(int mip, int x, int y, int x1, int y1, int x2, int y2) { if(!(mip--)) return true; sqr *w = wmip[mip]; @@ -121,18 +121,18 @@ void render_seg_new(float vx, float vy, float vh, int mip, int x, int y, int xs, { SWS(w,ox,oy,mfactor)->occluded = isoccluded(camera1->o.x, camera1->o.y, (float)(ox<>mip; int pvy = (int)vy>>mip; if(pvx>=0 && pvy>=0 && pvxoccluded = 0; + //SWS(w,vxx,vyy,mfactor)->occluded = 0; SWS(w, pvx, pvy, mfactor)->occluded = 0; // player cell never occluded } #define df(x) s->floor-(x->vdelta/4.0f) #define dc(x) s->ceil+(x->vdelta/4.0f) - + // loop through the rect 3 times (for floor/ceil/walls seperately, to facilitate dynamic stripify) // for each we skip occluded cubes (occlusion at higher mip levels is a big time saver!). // during the first loop (ceil) we collect cubes that lie within the lower mip rect and are