diff --git a/src/base/hash_libtomcrypt.cpp b/src/base/hash_libtomcrypt.cpp index 7cd7456ad..165422cd7 100644 --- a/src/base/hash_libtomcrypt.cpp +++ b/src/base/hash_libtomcrypt.cpp @@ -63,7 +63,7 @@ static u32 Gamma1(u32 x) { return Rot(x, 17) ^ Rot(x, 19) ^ Sh(x, 10); } static void sha_compress(sha256_state *md, const unsigned char *buf) { - u32 S[8], W[64], t0, t1, t; + u32 S[8], W[64], t; int i; // Copy state into S @@ -80,12 +80,13 @@ static void sha_compress(sha256_state *md, const unsigned char *buf) // Compress #define RND(a, b, c, d, e, f, g, h, i) \ + do \ { \ - t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ - t1 = Sigma0(a) + Maj(a, b, c); \ - d += t0; \ - h = t0 + t1; \ - } + u32 t0 = (h) + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ + u32 t1 = Sigma0(a) + Maj(a, b, c); \ + (d) += t0; \ + (h) = t0 + t1; \ + } while(0) for(i = 0; i < 64; ++i) { diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 76eb2d99a..fd8c0e41c 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -4406,6 +4406,7 @@ void CClient::RegisterCommands() #define CONSOLE_COMMAND(name, params, flags, callback, userdata, help) m_pConsole->Register(name, params, flags, 0, 0, help); #include +#undef CONSOLE_COMMAND } static CClient *CreateClient() diff --git a/src/engine/shared/config.cpp b/src/engine/shared/config.cpp index 48301a23f..027e79cf4 100644 --- a/src/engine/shared/config.cpp +++ b/src/engine/shared/config.cpp @@ -82,13 +82,13 @@ bool CConfigManager::Save() char aEscapeBuf[1024 * 2]; #define MACRO_CONFIG_INT(Name, ScriptName, def, min, max, flags, desc) \ - if((flags)&CFGFLAG_SAVE && g_Config.m_##Name != def) \ + if((flags)&CFGFLAG_SAVE && g_Config.m_##Name != (def)) \ { \ str_format(aLineBuf, sizeof(aLineBuf), "%s %i", #ScriptName, g_Config.m_##Name); \ WriteLine(aLineBuf); \ } #define MACRO_CONFIG_COL(Name, ScriptName, def, flags, desc) \ - if((flags)&CFGFLAG_SAVE && g_Config.m_##Name != def) \ + if((flags)&CFGFLAG_SAVE && g_Config.m_##Name != (def)) \ { \ str_format(aLineBuf, sizeof(aLineBuf), "%s %u", #ScriptName, g_Config.m_##Name); \ WriteLine(aLineBuf); \ diff --git a/src/engine/shared/huffman.cpp b/src/engine/shared/huffman.cpp index 47d9c3f6a..d25ae2b74 100644 --- a/src/engine/shared/huffman.cpp +++ b/src/engine/shared/huffman.cpp @@ -132,19 +132,25 @@ int CHuffman::Compress(const void *pInput, int InputSize, void *pOutput, int Out { // this macro loads a symbol for a byte into bits and bitcount #define HUFFMAN_MACRO_LOADSYMBOL(Sym) \ - Bits |= m_aNodes[Sym].m_Bits << Bitcount; \ - Bitcount += m_aNodes[Sym].m_NumBits; + do \ + { \ + Bits |= m_aNodes[Sym].m_Bits << Bitcount; \ + Bitcount += m_aNodes[Sym].m_NumBits; \ + } while(0) // this macro writes the symbol stored in bits and bitcount to the dst pointer #define HUFFMAN_MACRO_WRITE() \ - while(Bitcount >= 8) \ + do \ { \ - *pDst++ = (unsigned char)(Bits & 0xff); \ - if(pDst == pDstEnd) \ - return -1; \ - Bits >>= 8; \ - Bitcount -= 8; \ - } + while(Bitcount >= 8) \ + { \ + *pDst++ = (unsigned char)(Bits & 0xff); \ + if(pDst == pDstEnd) \ + return -1; \ + Bits >>= 8; \ + Bitcount -= 8; \ + } \ + } while(0) // setup buffer pointers const unsigned char *pSrc = (const unsigned char *)pInput; @@ -165,23 +171,23 @@ int CHuffman::Compress(const void *pInput, int InputSize, void *pOutput, int Out while(pSrc != pSrcEnd) { // {B} load the symbol - HUFFMAN_MACRO_LOADSYMBOL(Symbol) + HUFFMAN_MACRO_LOADSYMBOL(Symbol); // {C} fetch next symbol, this is done here because it will reduce dependency in the code Symbol = *pSrc++; // {B} write the symbol loaded at - HUFFMAN_MACRO_WRITE() + HUFFMAN_MACRO_WRITE(); } // write the last symbol loaded from {C} or {A} in the case of only 1 byte input buffer - HUFFMAN_MACRO_LOADSYMBOL(Symbol) - HUFFMAN_MACRO_WRITE() + HUFFMAN_MACRO_LOADSYMBOL(Symbol); + HUFFMAN_MACRO_WRITE(); } // write EOF symbol - HUFFMAN_MACRO_LOADSYMBOL(HUFFMAN_EOF_SYMBOL) - HUFFMAN_MACRO_WRITE() + HUFFMAN_MACRO_LOADSYMBOL(HUFFMAN_EOF_SYMBOL); + HUFFMAN_MACRO_WRITE(); // write out the last bits *pDst++ = Bits; diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 3770fd71d..8d3da304f 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -32,6 +32,7 @@ CChat::CChat() #define CHAT_COMMAND(name, params, flags, callback, userdata, help) RegisterCommand(name, params, flags, help); #include +#undef CHAT_COMMAND std::sort(m_vCommands.begin(), m_vCommands.end()); m_Mode = MODE_NONE; diff --git a/src/game/gamecore.h b/src/game/gamecore.h index 661020d04..087071c08 100644 --- a/src/game/gamecore.h +++ b/src/game/gamecore.h @@ -44,7 +44,7 @@ public: CTuningParams() { const float TicksPerSecond = 50.0f; -#define MACRO_TUNING_PARAM(Name, ScriptName, Value, Description) m_##Name.Set((int)(Value * 100.0f)); +#define MACRO_TUNING_PARAM(Name, ScriptName, Value, Description) m_##Name.Set((int)((Value)*100.0f)); #include "tuning.h" #undef MACRO_TUNING_PARAM } diff --git a/src/game/mapbugs.cpp b/src/game/mapbugs.cpp index 1cf55bbfe..3e9aee8b9 100644 --- a/src/game/mapbugs.cpp +++ b/src/game/mapbugs.cpp @@ -78,7 +78,7 @@ int CMapBugs::Update(const char *pBug) int Bug = -1; if(false) {} // NOLINT(readability-simplify-boolean-expr) #define MAPBUG(constname, string) \ - else if(str_comp(pBug, string) == 0) { Bug = constname; } + else if(str_comp(pBug, string) == 0) { Bug = (constname); } #include "mapbugs_list.h" #undef MAPBUG if(Bug == -1) diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index f8a1f14c9..3f8412a5c 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -256,18 +256,18 @@ void CGameContext::ConRules(IConsole::IResult *pResult, void *pUserData) "Be nice."); Printed = true; } -#define _RL(n) g_Config.m_SvRulesLine##n +#define GET_SERVER_RULE_LINE(n) g_Config.m_SvRulesLine##n char *pRuleLines[] = { - _RL(1), - _RL(2), - _RL(3), - _RL(4), - _RL(5), - _RL(6), - _RL(7), - _RL(8), - _RL(9), - _RL(10), + GET_SERVER_RULE_LINE(1), + GET_SERVER_RULE_LINE(2), + GET_SERVER_RULE_LINE(3), + GET_SERVER_RULE_LINE(4), + GET_SERVER_RULE_LINE(5), + GET_SERVER_RULE_LINE(6), + GET_SERVER_RULE_LINE(7), + GET_SERVER_RULE_LINE(8), + GET_SERVER_RULE_LINE(9), + GET_SERVER_RULE_LINE(10), }; for(auto &pRuleLine : pRuleLines) {