From 25504279d9fc30f34893be6106e3e270748e0e3f Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 6 Jun 2015 16:19:20 +0300 Subject: [PATCH] fixed some clang warnings remove chat string from code --- include/compress.h | 8 ++++---- include/core.h | 4 ++-- include/corelib.h | 2 ++ include/engine/util.h | 2 ++ project/yapb.vcxproj | 4 ++-- source/basecode.cpp | 18 +++++++----------- source/combat.cpp | 2 -- source/interface.cpp | 2 +- source/manager.cpp | 2 +- source/support.cpp | 8 ++++---- 10 files changed, 25 insertions(+), 27 deletions(-) diff --git a/include/compress.h b/include/compress.h index dd8eb2b..200ac5a 100644 --- a/include/compress.h +++ b/include/compress.h @@ -156,7 +156,7 @@ public: m_codeSize = 0; } - int InternalEncode (char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize) + int InternalEncode (const char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize) { int i, bit, length, node, strPtr, lastMatchLength, codeBufferPtr, bufferPtr = 0; byte codeBuffer[17], mask; @@ -257,7 +257,7 @@ public: return m_codeSize; } - int InternalDecode (char *fileName, int headerSize, byte *buffer, int bufferSize) + int InternalDecode (const char *fileName, int headerSize, byte *buffer, int bufferSize) { int i, j, k, node, bit; unsigned int flags; @@ -327,14 +327,14 @@ public: } // external decoder - static int Uncompress (char *fileName, int headerSize, byte *buffer, int bufferSize) + static int Uncompress (const char *fileName, int headerSize, byte *buffer, int bufferSize) { static Compressor compressor = Compressor (); return compressor.InternalDecode (fileName, headerSize, buffer, bufferSize); } // external encoder - static int Compress(char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize) + static int Compress(const char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize) { static Compressor compressor = Compressor (); return compressor.InternalEncode (fileName, header, headerSize, buffer, bufferSize); diff --git a/include/core.h b/include/core.h index cb3aa8a..afdae31 100644 --- a/include/core.h +++ b/include/core.h @@ -1596,7 +1596,7 @@ extern int GetTeam (edict_t *ent); extern float GetShootingConeDeviation (edict_t *ent, Vector *position); extern float GetWaveLength (const char *fileName); -extern bool TryFileOpen (char *fileName); +extern bool TryFileOpen (const char *fileName); extern bool IsDedicatedServer (void); extern bool IsVisible (const Vector &origin, edict_t *ent); extern bool IsAlive (edict_t *ent); @@ -1611,7 +1611,7 @@ extern const char *GetMapName (void); extern const char *GetWaypointDir (void); extern const char *GetModName (void); extern const char *GetField (const char *string, int fieldId, bool endLine = false); -extern char *FormatBuffer (char *format, ...); +extern const char *FormatBuffer (const char *format, ...); extern uint16 GenerateBuildNumber (void); extern Vector GetEntityOrigin (edict_t *ent); diff --git a/include/corelib.h b/include/corelib.h index 104e5eb..d66d0ed 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -21,7 +21,9 @@ #include #include +#if defined (PLATFORM_WIN32) #pragma warning (disable : 4100 4189 4239 4996 4244 383 473 981) +#endif // // Title: Utility Classes Header diff --git a/include/engine/util.h b/include/engine/util.h index e73f930..7951c3c 100644 --- a/include/engine/util.h +++ b/include/engine/util.h @@ -75,7 +75,9 @@ typedef int BOOL; #endif // In case this ever changes +#ifndef M_PI #define M_PI 3.1415926 +#endif // // Conversion among the three types of "entity", including identity-conversions. diff --git a/project/yapb.vcxproj b/project/yapb.vcxproj index 8646888..15a73e0 100644 --- a/project/yapb.vcxproj +++ b/project/yapb.vcxproj @@ -54,12 +54,12 @@ DynamicLibrary - v140_xp + v120_xp false DynamicLibrary - v140_xp + v120_xp false diff --git a/source/basecode.cpp b/source/basecode.cpp index 85d1584..49a48c0 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -1858,7 +1858,7 @@ void Bot::SetConditions (void) float distance = (m_lastEnemy->v.origin - pev->origin).GetLength (); // is enemy to high to throw - if ((m_lastEnemy->v.origin.z > (pev->origin.z + 650.0)) || !(m_lastEnemy->v.flags & FL_ONGROUND | FL_DUCKING)) + if ((m_lastEnemy->v.origin.z > (pev->origin.z + 650.0)) || !(m_lastEnemy->v.flags & (FL_ONGROUND | FL_DUCKING))) distance = FLT_MAX; // just some crazy value // enemy is within a good throwing distance ? @@ -3094,8 +3094,6 @@ void Bot::Think (void) killer->frags++; MDLL_ClientKill (ENT (killer)); - - HudMessage (ENT (killer), true, Vector (g_randGen.Long (33, 255), g_randGen.Long (33, 255), g_randGen.Long (33, 255)), "You was slayed, because of teamkilling a player. Please be careful."); } else if (m_voteMap != 0) // host wants the bots to vote for a map? { @@ -4576,7 +4574,11 @@ void Bot::RunTask (void) break; } - destination = GetEntityOrigin (m_pickupItem); + if (m_pickupType == PICKUP_HOSTAGE) + destination = m_pickupItem->v.origin + pev->view_ofs; + else + destination = GetEntityOrigin (m_pickupItem); + m_destOrigin = destination; m_entity = destination; @@ -5580,15 +5582,11 @@ void Bot::DiscardWeaponForUser (edict_t *user, bool discardC4) { SelectWeaponByName ("weapon_c4"); FakeClientCommand (GetEntity (), "drop"); - - SayText (FormatBuffer ("Here! %s, and now go and setup it!", STRING (user->v.netname))); } else { SelectBestWeapon (); FakeClientCommand (GetEntity (), "drop"); - - SayText (FormatBuffer ("Here the weapon! %s, feel free to use it ;)", STRING (user->v.netname))); } m_pickupItem = NULL; @@ -5604,8 +5602,6 @@ void Bot::DiscardWeaponForUser (edict_t *user, bool discardC4) m_nextBuyTime = GetWorldTime (); } } - else - SayText (FormatBuffer ("Sorry %s, i don't want discard my %s to you!", STRING (user->v.netname), discardC4 ? "bomb" : "weapon")); } void Bot::ResetDoubleJumpState (void) @@ -5954,7 +5950,7 @@ bool Bot::OutOfBombTimer (void) if ((timeLeft < reachTime + 6 && !m_hasDefuser && !hasTeammatesWithDefuserKit) || (timeLeft < reachTime + 2 && m_hasDefuser)) return true; - if (m_hasProgressBar && IsOnFloor () && (m_hasDefuser ? 10.0 : 15.0 > GetBombTimeleft ())) + if (m_hasProgressBar && IsOnFloor () && ((m_hasDefuser ? 10.0 : 15.0) > GetBombTimeleft ())) return true; return false; // return false otherwise diff --git a/source/combat.cpp b/source/combat.cpp index 2bb1f72..d0ec016 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -492,9 +492,7 @@ bool Bot::DoFirePause (float distance, FireDelay *fireDelay) return true; float offset = 0.0f; - const float BurstDistance = 300.0f; - const float DoubleBurstDistance = BurstDistance * 2; if (distance < BurstDistance) // KWo - 09.04.2010 return false; diff --git a/source/interface.cpp b/source/interface.cpp index 1a2fe95..980cb00 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -3135,7 +3135,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t if (buffer) { - CreatePath (FormatBuffer ("%s/dlls", GetModName ())); + CreatePath (const_cast (FormatBuffer ("%s/dlls", GetModName ()))); File fp (gameDLLName, "wb"); if (fp.IsValid ()) diff --git a/source/manager.cpp b/source/manager.cpp index c5916d6..ef7deb8 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -1145,7 +1145,7 @@ void Bot::Kill (void) KeyValueData kv; kv.szClassName = const_cast (g_weaponDefs[m_currentWeapon].className); kv.szKeyName = "damagetype"; - kv.szValue = FormatBuffer ("%d", (1 << 4)); + kv.szValue = const_cast (FormatBuffer ("%d", (1 << 4))); kv.fHandled = FALSE; MDLL_KeyValue (hurtEntity, &kv); diff --git a/source/support.cpp b/source/support.cpp index a25cd48..abc6f04 100644 --- a/source/support.cpp +++ b/source/support.cpp @@ -83,7 +83,7 @@ short FixedSigned16 (float value, float scale) return static_cast (output); } -char *FormatBuffer (char *format, ...) +const char *FormatBuffer (const char *format, ...) { va_list ap; static char staticBuffer[3072]; @@ -823,7 +823,7 @@ bool IsDedicatedServer (void) return (IS_DEDICATED_SERVER () > 0); // ask engine for this } -bool TryFileOpen (char *fileName) +bool TryFileOpen (const char *fileName) { // this function tests if a file exists by attempting to open it @@ -979,7 +979,7 @@ void ServerCommand (const char *format, ...) vsprintf (string, format, ap); va_end (ap); - SERVER_COMMAND (FormatBuffer ("%s\n", string)); // execute command + SERVER_COMMAND (const_cast (FormatBuffer ("%s\n", string))); // execute command } const char *GetMapName (void) @@ -1004,7 +1004,7 @@ bool OpenConfig (const char *fileName, char *errorIfNotExists, File *outFile, bo if (strcmp (fileName, "lang.cfg") == 0 && strcmp (yb_language.GetString (), "en") == 0) return false; - char *languageDependantConfigFile = FormatBuffer ("%s/addons/yapb/config/language/%s_%s", GetModName (), yb_language.GetString (), fileName); + const char *languageDependantConfigFile = FormatBuffer ("%s/addons/yapb/config/language/%s_%s", GetModName (), yb_language.GetString (), fileName); // check is file is exists for this language if (TryFileOpen (languageDependantConfigFile))