From 39781ee17b34087d49536dc5faa96878b1a532b3 Mon Sep 17 00:00:00 2001 From: jeefo Date: Tue, 30 Oct 2018 19:19:56 +0300 Subject: [PATCH] Fixed GCC Strict aliasing warning. --- source/basecode.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/basecode.cpp b/source/basecode.cpp index 6f306cf..4df45fa 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -990,12 +990,14 @@ void Bot::pushRadioMessage (int message) { if (yb_communication_type.integer () == 0 || m_numFriendsLeft == 0) { return; } + if (!(g_gameFlags & GAME_SUPPORT_BOT_VOICE) || g_chatterFactory[message].empty () || yb_communication_type.integer () != 2) { m_forceRadio = true; // use radio instead voice } else { m_forceRadio = false; } + m_radioSelect = message; pushMsgQueue (GAME_MSG_RADIO); } @@ -1346,7 +1348,13 @@ int Bot::pickBestWeapon (int *vec, int count, int moneySave) { if (yb_best_weapon_picker_type.integer () == 1) { auto pick = [] (const float factor) -> float { - return (static_cast (((unsigned int &) factor >> 23) & 0xff) - 127) * 0.3010299956639812f; + union { + unsigned int u; + float f; + } cast; + cast.f = factor; + + return (static_cast ((cast.u >> 23) & 0xff) - 127) * 0.3010299956639812f; }; float buyFactor = (m_moneyAmount - static_cast (moneySave)) / (16000.0f - static_cast (moneySave)) * 3.0f;