Fix some compiler warnings and explicitly set C++14 as the standard (#2929)

This commit is contained in:
schell244
2025-02-25 03:15:14 +01:00
committed by GitHub
parent 9e6d4aca5d
commit 8f3cb045cb
12 changed files with 31 additions and 22 deletions
+5 -1
View File
@@ -20,6 +20,10 @@ cmake_minimum_required(VERSION 3.1...3.20)
project(MaNGOS)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Allow -DACE_ROOT, -DTBB_ROOT, etc.
if(${CMAKE_VERSION} VERSION_GREATER "3.11")
cmake_policy(SET CMP0074 NEW)
@@ -62,7 +66,7 @@ if(PREFIX)
get_filename_component(PREFIX_ABSOLUTE ${PREFIX} ABSOLUTE)
set(CMAKE_INSTALL_PREFIX ${PREFIX} CACHE PATH "Install path prefix." FORCE)
else()
set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Install path prefix.")
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Install path prefix.")
endif()
# If win32 put it in the bin dir not lib
-1
View File
@@ -16,7 +16,6 @@ set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} --no-warnings -fexceptions
if(BUILD_FOR_HOST_CPU)
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -march=native")
endif()
set(CMAKE_CXX_STANDARD 14)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(PROFILE_GENERATE)
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fprofile-generate")
@@ -31,6 +31,7 @@
#include <vector>
#include <algorithm>
#include <random>
INSTANTIATE_SINGLETON_1(WardenScanMgr);
@@ -318,7 +319,9 @@ std::vector<std::shared_ptr<Scan const>> WardenScanMgr::GetRandomScans(ScanFlags
}
// randomize the order of matching scans
std::random_shuffle(matches.begin(), matches.end());
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(matches.begin(), matches.end(), g);
// determine how many of the identified scans we can fit into the client's request and response buffers
size_t request = 0, reply = 0;
+1 -1
View File
@@ -30,7 +30,7 @@
#include "Player.h"
#include "ObjectMgr.h"
inline float GetAge(uint64 t) { return float(time(nullptr) - t) / DAY; }
inline float GetAge(uint64 t) { return float(time(nullptr) - t) / float(DAY); }
///////////////////////////////////////////////////////////////////////////////////////////////////
// GM ticket
+1 -1
View File
@@ -826,7 +826,7 @@ void Guild::Roster(WorldSession* session /*= nullptr*/)
data << uint8(itr.second.Level);
data << uint8(itr.second.Class);
data << uint32(itr.second.ZoneId);
data << float(float(time(nullptr) - itr.second.LogoutTime) / DAY);
data << float(float(time(nullptr) - itr.second.LogoutTime) / uint64(DAY));
data << itr.second.Pnote;
data << ((session && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_VIEWOFFNOTE)) ? itr.second.OFFnote : "");
}
+1 -1
View File
@@ -14929,7 +14929,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder)
if (timeDiff > 15 * MINUTE)
soberFactor = 0;
else
soberFactor = 1 - timeDiff / (15.0f * MINUTE);
soberFactor = 1.0f - float(timeDiff) / (15.0f * float(MINUTE));
uint16 newDrunkenValue = uint16(soberFactor * m_drunk);
SetDrunkValue(newDrunkenValue);
+1 -1
View File
@@ -507,7 +507,7 @@ bool PlayerBotMgr::DeleteBot(uint32 playerGUID)
return DeleteBot(iter);
}
bool PlayerBotMgr::DeleteBot(std::map<uint32, std::shared_ptr<PlayerBotEntry>>::iterator iter)
bool PlayerBotMgr::DeleteBot(std::map<uint64, std::shared_ptr<PlayerBotEntry>>::iterator iter)
{
if (iter->second->state == PB_STATE_LOADING)
m_stats.loadingCount--;
+2 -2
View File
@@ -81,7 +81,7 @@ class PlayerBotMgr
bool AddBot(PlayerBotAI* ai);
bool AddBot(uint32 playerGuid, bool chatBot = false, PlayerBotAI* pAI = nullptr);
bool DeleteBot(std::map<uint32, std::shared_ptr<PlayerBotEntry>>::iterator iter);
bool DeleteBot(std::map<uint64, std::shared_ptr<PlayerBotEntry>>::iterator iter);
bool DeleteBot(uint32 playerGuid);
bool AddRandomBot();
@@ -116,7 +116,7 @@ class PlayerBotMgr
uint32 m_maxAccountId;
time_t m_lastBattleBotQueueUpdate;
std::map<uint32 /*pl guid*/, std::shared_ptr<PlayerBotEntry>> m_bots;
std::map<uint64 /*pl guid*/, std::shared_ptr<PlayerBotEntry>> m_bots;
std::map<uint32 /*account*/, uint32> m_tempBots;
PlayerBotStats m_stats;
+4 -4
View File
@@ -961,7 +961,7 @@ void Spell::EffectDummy(SpellEffectIndex effIdx)
switch (m_triggeredByAuraSpell->Id)
{
case 26467: // Persistent Shield
m_caster->CastCustomSpell(unitTarget, 26470, damage, {}, {}, true);
m_caster->CastCustomSpell(unitTarget, 26470, (int32)damage, {}, {}, true);
break;
default:
sLog.Out(LOG_BASIC, LOG_LVL_ERROR, "EffectDummy: Non-handled case for spell 13567 for triggered aura %u", m_triggeredByAuraSpell->Id);
@@ -1120,7 +1120,7 @@ void Spell::EffectDummy(SpellEffectIndex effIdx)
damage = dither(damage * (pPlayer->GetInt32Value(UNIT_FIELD_ATTACK_POWER)) / 100);
if (damage > 0)
pPlayer->CastCustomSpell(pPlayer, 23234, damage, {}, {}, true, nullptr);
pPlayer->CastCustomSpell(pPlayer, 23234, (int32)(damage), {}, {}, true, nullptr);
return;
}
case 20577: // Cannibalize
@@ -1921,7 +1921,7 @@ void Spell::EffectDummy(SpellEffectIndex effIdx)
// found spelldamage coefficients of 0.381% per 0.1 speed and 15.244 per 4.0 speed
// but own calculation say 0.385 gives at most one point difference to published values
float spellDamage = m_caster->SpellBaseDamageBonusDone(m_spellInfo->GetSpellSchoolMask());
float weaponSpeed = (1.0f / IN_MILLISECONDS) * m_CastItem->GetProto()->Delay;
float weaponSpeed = (1.0f / float(IN_MILLISECONDS)) * m_CastItem->GetProto()->Delay;
float totalDamage = (damage + 3.85f * spellDamage) * 0.01f * weaponSpeed;
m_caster->CastCustomSpell(unitTarget, 10444, dither(totalDamage), {}, {}, true, m_CastItem);
@@ -3225,7 +3225,7 @@ void Spell::EffectDistract(SpellEffectIndex effIdx)
unitTarget->ClearUnitState(UNIT_STATE_MOVING);
if (unitTarget->GetTypeId() == TYPEID_UNIT)
unitTarget->GetMotionMaster()->MoveDistract(damage * IN_MILLISECONDS);
unitTarget->GetMotionMaster()->MoveDistract(damage * (uint32)IN_MILLISECONDS);
AddExecuteLogInfo(effIdx, ExecuteLogInfo(unitTarget->GetObjectGuid()));
}
+4 -4
View File
@@ -346,11 +346,11 @@ float Transport::CalculateSegmentPos(float now)
KeyFrame const& frame = *m_currentFrame;
float const speed = float(m_goInfo->moTransport.moveSpeed);
float const accel = float(m_goInfo->moTransport.accelRate);
float timeSinceStop = frame.TimeFrom + (now - (1.0f / IN_MILLISECONDS) * frame.DepartureTime);
float timeUntilStop = frame.TimeTo - (now - (1.0f / IN_MILLISECONDS) * frame.DepartureTime);
float const timeSinceStop = frame.TimeFrom + (now - (1.0f / float(IN_MILLISECONDS)) * float(frame.DepartureTime));
float const timeUntilStop = frame.TimeTo - (now - (1.0f / float(IN_MILLISECONDS)) * float(frame.DepartureTime));
float segmentPos, dist;
float accelTime = m_transportTemplate.accelTime;
float accelDist = m_transportTemplate.accelDist;
float const accelTime = m_transportTemplate.accelTime;
float const accelDist = m_transportTemplate.accelDist;
// calculate from nearest stop, less confusing calculation...
if (timeSinceStop < timeUntilStop)
{
+4 -4
View File
@@ -271,7 +271,7 @@ bool TransportMgr::GenerateWaypoints(GameObjectInfo const* goinfo, TransportTemp
if (keyFrames[0].IsStopFrame())
{
curPathTime = float(keyFrames[0].Node->delay);
keyFrames[0].DepartureTime = uint32(curPathTime * IN_MILLISECONDS);
keyFrames[0].DepartureTime = uint32(curPathTime * (uint32)IN_MILLISECONDS);
}
for (size_t i = 1; i < keyFrames.size(); ++i)
@@ -279,15 +279,15 @@ bool TransportMgr::GenerateWaypoints(GameObjectInfo const* goinfo, TransportTemp
curPathTime += keyFrames[i - 1].TimeTo;
if (keyFrames[i].IsStopFrame())
{
keyFrames[i].ArriveTime = uint32(curPathTime * IN_MILLISECONDS);
keyFrames[i].ArriveTime = uint32(curPathTime * (uint32)IN_MILLISECONDS);
keyFrames[i - 1].NextArriveTime = keyFrames[i].ArriveTime;
curPathTime += float(keyFrames[i].Node->delay);
keyFrames[i].DepartureTime = uint32(curPathTime * IN_MILLISECONDS);
keyFrames[i].DepartureTime = uint32(curPathTime * (uint32)IN_MILLISECONDS);
}
else
{
curPathTime -= keyFrames[i].TimeTo;
keyFrames[i].ArriveTime = uint32(curPathTime * IN_MILLISECONDS);
keyFrames[i].ArriveTime = uint32(curPathTime * (uint32)IN_MILLISECONDS);
keyFrames[i - 1].NextArriveTime = keyFrames[i].ArriveTime;
keyFrames[i].DepartureTime = keyFrames[i].ArriveTime;
}
@@ -25,6 +25,7 @@ EndScriptData */
#include "Group.h"
#include "CreatureGroups.h"
#include "ruins_of_ahnqiraj.h"
#include <random>
instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj(Map* pMap) : ScriptedInstance(pMap)
{
@@ -716,7 +717,9 @@ void instance_ruins_of_ahnqiraj::SpawnNewCrystals(ObjectGuid usedCrystal)
possibleIndexes.push_back(i);
}
std::random_shuffle(possibleIndexes.begin(), possibleIndexes.end());
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(possibleIndexes.begin(), possibleIndexes.end(), g);
while (crystalIndexes.size() < OSSIRIAN_CRYSTAL_NUM_ACTIVE)
{