refactor: replace C-style casts with static_cast and extract toLowerInPlace

Replace ~300 C-style casts ((int), (float), (uint32_t), etc.) with
static_cast across 15 source files. Extract toLowerInPlace() helper in
lua_engine.cpp to replace 72 identical tolower loop patterns.
This commit is contained in:
Kelsi 2026-03-25 11:40:49 -07:00
parent d646a0451d
commit 05f2bedf88
15 changed files with 385 additions and 381 deletions

View file

@ -21,6 +21,10 @@ extern "C" {
namespace wowee::addons {
static void toLowerInPlace(std::string& s) {
toLowerInPlace(s);
}
// Shared GetTime() epoch — all time-returning functions must use this same origin
// so that addon calculations like (start + duration - GetTime()) are consistent.
static const auto kLuaTimeEpoch = std::chrono::steady_clock::now();
@ -133,7 +137,7 @@ static game::Unit* resolveUnit(lua_State* L, const char* unitId) {
auto* gh = getGameHandler(L);
if (!gh || !unitId) return nullptr;
std::string uid(unitId);
for (char& c : uid) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uid);
uint64_t guid = resolveUnitGuid(gh, uid);
if (guid == 0) return nullptr;
@ -162,7 +166,7 @@ static int lua_UnitName(lua_State* L) {
// Fallback: party member name for out-of-range members
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
const auto* pm = findPartyMember(gh, guid);
if (pm && !pm->name.empty()) {
@ -188,7 +192,7 @@ static int lua_UnitHealth(lua_State* L) {
// Fallback: party member stats for out-of-range members
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
const auto* pm = findPartyMember(gh, guid);
lua_pushnumber(L, pm ? pm->curHealth : 0);
@ -204,7 +208,7 @@ static int lua_UnitHealthMax(lua_State* L) {
} else {
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
const auto* pm = findPartyMember(gh, guid);
lua_pushnumber(L, pm ? pm->maxHealth : 0);
@ -220,7 +224,7 @@ static int lua_UnitPower(lua_State* L) {
} else {
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
const auto* pm = findPartyMember(gh, guid);
lua_pushnumber(L, pm ? pm->curPower : 0);
@ -236,7 +240,7 @@ static int lua_UnitPowerMax(lua_State* L) {
} else {
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
const auto* pm = findPartyMember(gh, guid);
lua_pushnumber(L, pm ? pm->maxPower : 0);
@ -252,7 +256,7 @@ static int lua_UnitLevel(lua_State* L) {
} else {
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
const auto* pm = findPartyMember(gh, guid);
lua_pushnumber(L, pm ? pm->level : 0);
@ -269,7 +273,7 @@ static int lua_UnitExists(lua_State* L) {
// Party members in other zones don't have entities but still "exist"
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
lua_pushboolean(L, guid != 0 && findPartyMember(gh, guid) != nullptr);
}
@ -285,7 +289,7 @@ static int lua_UnitIsDead(lua_State* L) {
// Fallback: party member stats for out-of-range members
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
const auto* pm = findPartyMember(gh, guid);
lua_pushboolean(L, pm ? (pm->curHealth == 0 && pm->maxHealth > 0) : 0);
@ -302,7 +306,7 @@ static int lua_UnitClass(lua_State* L) {
"Death Knight","Shaman","Mage","Warlock","","Druid"};
uint8_t classId = 0;
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr == "player") {
classId = gh->getPlayerClass();
} else {
@ -339,7 +343,7 @@ static int lua_UnitIsGhost(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr == "player") {
lua_pushboolean(L, gh->isPlayerGhost());
} else {
@ -366,7 +370,7 @@ static int lua_UnitIsDeadOrGhost(lua_State* L) {
bool dead = (unit && unit->getHealth() == 0);
if (!dead && gh) {
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr == "player") dead = gh->isPlayerGhost() || gh->isPlayerDead();
}
lua_pushboolean(L, dead);
@ -379,7 +383,7 @@ static int lua_UnitIsAFK(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid != 0) {
auto entity = gh->getEntityManager().getEntity(guid);
@ -399,7 +403,7 @@ static int lua_UnitIsDND(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid != 0) {
auto entity = gh->getEntityManager().getEntity(guid);
@ -419,7 +423,7 @@ static int lua_UnitPlayerControlled(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushboolean(L, 0); return 1; }
auto entity = gh->getEntityManager().getEntity(guid);
@ -473,14 +477,14 @@ static int lua_UnitThreatSituation(lua_State* L) {
const char* uid = luaL_optstring(L, 1, "player");
const char* mobUid = luaL_optstring(L, 2, nullptr);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t playerUnitGuid = resolveUnitGuid(gh, uidStr);
if (playerUnitGuid == 0) { lua_pushnumber(L, 0); return 1; }
// If no mob specified, check general combat threat against current target
uint64_t mobGuid = 0;
if (mobUid && *mobUid) {
std::string mStr(mobUid);
for (char& c : mStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(mStr);
mobGuid = resolveUnitGuid(gh, mStr);
}
// Approximate threat: check if the mob is targeting this unit
@ -521,13 +525,13 @@ static int lua_UnitDetailedThreatSituation(lua_State* L) {
const char* uid = luaL_optstring(L, 1, "player");
const char* mobUid = luaL_optstring(L, 2, nullptr);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t unitGuid = resolveUnitGuid(gh, uidStr);
bool isTanking = false;
int status = 0;
if (unitGuid != 0 && mobUid && *mobUid) {
std::string mStr(mobUid);
for (char& c : mStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(mStr);
uint64_t mobGuid = resolveUnitGuid(gh, mStr);
if (mobGuid != 0) {
auto mobEnt = gh->getEntityManager().getEntity(mobGuid);
@ -557,7 +561,7 @@ static int lua_UnitDistanceSquared(lua_State* L) {
if (!gh) { lua_pushnumber(L, 0); lua_pushboolean(L, 0); return 2; }
const char* uid = luaL_checkstring(L, 1);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0 || guid == gh->getPlayerGuid()) { lua_pushnumber(L, 0); lua_pushboolean(L, 0); return 2; }
auto targetEnt = gh->getEntityManager().getEntity(guid);
@ -579,7 +583,7 @@ static int lua_CheckInteractDistance(lua_State* L) {
const char* uid = luaL_checkstring(L, 1);
int distIdx = static_cast<int>(luaL_optnumber(L, 2, 4));
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushboolean(L, 0); return 1; }
auto targetEnt = gh->getEntityManager().getEntity(guid);
@ -613,10 +617,10 @@ static int lua_IsSpellInRange(lua_State* L) {
spellId = static_cast<uint32_t>(strtoul(spellNameOrId, nullptr, 10));
} else {
std::string nameLow(spellNameOrId);
for (char& c : nameLow) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(nameLow);
for (uint32_t sid : gh->getKnownSpells()) {
std::string sn = gh->getSpellName(sid);
for (char& c : sn) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(sn);
if (sn == nameLow) { spellId = sid; break; }
}
}
@ -628,7 +632,7 @@ static int lua_IsSpellInRange(lua_State* L) {
// Resolve target position
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushnil(L); return 1; }
auto targetEnt = gh->getEntityManager().getEntity(guid);
@ -657,7 +661,7 @@ static int lua_UnitGroupRolesAssigned(lua_State* L) {
if (!gh) { lua_pushstring(L, "NONE"); return 1; }
const char* uid = luaL_optstring(L, 1, "player");
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushstring(L, "NONE"); return 1; }
const auto& pd = gh->getPartyData();
@ -681,8 +685,8 @@ static int lua_UnitCanAttack(lua_State* L) {
const char* uid1 = luaL_checkstring(L, 1);
const char* uid2 = luaL_checkstring(L, 2);
std::string u1(uid1), u2(uid2);
for (char& c : u1) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
for (char& c : u2) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(u1);
toLowerInPlace(u2);
uint64_t g1 = resolveUnitGuid(gh, u1);
uint64_t g2 = resolveUnitGuid(gh, u2);
if (g1 == 0 || g2 == 0 || g1 == g2) { lua_pushboolean(L, 0); return 1; }
@ -714,7 +718,7 @@ static int lua_UnitCreatureFamily(lua_State* L) {
if (!gh) { lua_pushnil(L); return 1; }
const char* uid = luaL_optstring(L, 1, "target");
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushnil(L); return 1; }
auto entity = gh->getEntityManager().getEntity(guid);
@ -743,7 +747,7 @@ static int lua_UnitOnTaxi(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr == "player") {
lua_pushboolean(L, gh->isOnTaxiFlight());
} else {
@ -758,7 +762,7 @@ static int lua_UnitSex(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushnumber(L, 1); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid != 0) {
auto entity = gh->getEntityManager().getEntity(guid);
@ -1068,7 +1072,7 @@ static int lua_UnitRace(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushstring(L, "Unknown"); lua_pushstring(L, "Unknown"); lua_pushnumber(L, 0); return 3; }
std::string uid(luaL_optstring(L, 1, "player"));
for (char& c : uid) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uid);
static const char* kRaces[] = {"","Human","Orc","Dwarf","Night Elf","Undead",
"Tauren","Gnome","Troll","","Blood Elf","Draenei"};
uint8_t raceId = 0;
@ -1108,7 +1112,7 @@ static int lua_UnitPowerType(lua_State* L) {
// Fallback: party member stats for out-of-range members
auto* gh = getGameHandler(L);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = gh ? resolveUnitGuid(gh, uidStr) : 0;
const auto* pm = findPartyMember(gh, guid);
if (pm) {
@ -1133,7 +1137,7 @@ static int lua_UnitGUID(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushnil(L); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushnil(L); return 1; }
char buf[32];
@ -1147,7 +1151,7 @@ static int lua_UnitIsPlayer(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
auto entity = guid ? gh->getEntityManager().getEntity(guid) : nullptr;
lua_pushboolean(L, entity && entity->getType() == game::ObjectType::PLAYER);
@ -1249,7 +1253,7 @@ static int lua_UnitAura(lua_State* L, bool wantBuff) {
if (index < 1) { lua_pushnil(L); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
const std::vector<game::AuraSlot>* auras = nullptr;
if (uidStr == "player") auras = &gh->getPlayerAuras();
@ -1453,19 +1457,19 @@ static int lua_CastSpellByName(lua_State* L) {
// Find highest rank of spell by name (same logic as /cast)
std::string nameLow(name);
for (char& c : nameLow) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(nameLow);
uint32_t bestId = 0;
int bestRank = -1;
for (uint32_t sid : gh->getKnownSpells()) {
std::string sn = gh->getSpellName(sid);
for (char& c : sn) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(sn);
if (sn != nameLow) continue;
int rank = 0;
const std::string& rk = gh->getSpellRank(sid);
if (!rk.empty()) {
std::string rkl = rk;
for (char& c : rkl) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(rkl);
if (rkl.rfind("rank ", 0) == 0) {
try { rank = std::stoi(rkl.substr(5)); } catch (...) {}
}
@ -1748,10 +1752,10 @@ static int lua_GetSpellCooldown(lua_State* L) {
} else {
const char* name = luaL_checkstring(L, 1);
std::string nameLow(name);
for (char& c : nameLow) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(nameLow);
for (uint32_t sid : gh->getKnownSpells()) {
std::string sn = gh->getSpellName(sid);
for (char& c : sn) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(sn);
if (sn == nameLow) { spellId = sid; break; }
}
}
@ -1795,7 +1799,7 @@ static int lua_TargetUnit(lua_State* L) {
if (!gh) return 0;
const char* uid = luaL_checkstring(L, 1);
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid != 0) gh->setTarget(guid);
return 0;
@ -1815,7 +1819,7 @@ static int lua_FocusUnit(lua_State* L) {
const char* uid = luaL_optstring(L, 1, nullptr);
if (!uid || !*uid) return 0;
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid != 0) gh->setFocus(guid);
return 0;
@ -1834,7 +1838,7 @@ static int lua_AssistUnit(lua_State* L) {
if (!gh) return 0;
const char* uid = luaL_optstring(L, 1, "target");
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) return 0;
uint64_t theirTarget = getEntityTargetGuid(gh, guid);
@ -1869,7 +1873,7 @@ static int lua_GetRaidTargetIndex(lua_State* L) {
if (!gh) { lua_pushnil(L); return 1; }
const char* uid = luaL_optstring(L, 1, "target");
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushnil(L); return 1; }
uint8_t mark = gh->getEntityRaidMark(guid);
@ -1885,7 +1889,7 @@ static int lua_SetRaidTarget(lua_State* L) {
const char* uid = luaL_optstring(L, 1, "target");
int index = static_cast<int>(luaL_checknumber(L, 2));
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) return 0;
if (index >= 1 && index <= 8)
@ -1929,17 +1933,17 @@ static int lua_GetSpellInfo(lua_State* L) {
const char* name = lua_tostring(L, 1);
if (!name || !*name) { lua_pushnil(L); return 1; }
std::string nameLow(name);
for (char& c : nameLow) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(nameLow);
int bestRank = -1;
for (uint32_t sid : gh->getKnownSpells()) {
std::string sn = gh->getSpellName(sid);
for (char& c : sn) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(sn);
if (sn != nameLow) continue;
int rank = 0;
const std::string& rk = gh->getSpellRank(sid);
if (!rk.empty()) {
std::string rkl = rk;
for (char& c : rkl) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(rkl);
if (rkl.rfind("rank ", 0) == 0) {
try { rank = std::stoi(rkl.substr(5)); } catch (...) {}
}
@ -1979,10 +1983,10 @@ static int lua_GetSpellTexture(lua_State* L) {
const char* name = lua_tostring(L, 1);
if (!name || !*name) { lua_pushnil(L); return 1; }
std::string nameLow(name);
for (char& c : nameLow) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(nameLow);
for (uint32_t sid : gh->getKnownSpells()) {
std::string sn = gh->getSpellName(sid);
for (char& c : sn) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(sn);
if (sn == nameLow) { spellId = sid; break; }
}
}
@ -2642,7 +2646,7 @@ static int lua_GetInventoryItemLink(lua_State* L) {
int slotId = static_cast<int>(luaL_checknumber(L, 2));
if (!gh || slotId < 1 || slotId > 19) { lua_pushnil(L); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr != "player") { lua_pushnil(L); return 1; }
const auto& inv = gh->getInventory();
@ -2667,7 +2671,7 @@ static int lua_GetInventoryItemID(lua_State* L) {
int slotId = static_cast<int>(luaL_checknumber(L, 2));
if (!gh || slotId < 1 || slotId > 19) { lua_pushnil(L); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr != "player") { lua_pushnil(L); return 1; }
const auto& inv = gh->getInventory();
@ -2683,7 +2687,7 @@ static int lua_GetInventoryItemTexture(lua_State* L) {
int slotId = static_cast<int>(luaL_checknumber(L, 2));
if (!gh || slotId < 1 || slotId > 19) { lua_pushnil(L); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr != "player") { lua_pushnil(L); return 1; }
const auto& inv = gh->getInventory();
@ -2722,7 +2726,7 @@ static int lua_UnitXP(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushnumber(L, 0); return 1; }
std::string u(uid);
for (char& c : u) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(u);
if (u == "player") lua_pushnumber(L, gh->getPlayerXp());
else lua_pushnumber(L, 0);
return 1;
@ -2733,7 +2737,7 @@ static int lua_UnitXPMax(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushnumber(L, 1); return 1; }
std::string u(uid);
for (char& c : u) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(u);
if (u == "player") {
uint32_t nlxp = gh->getPlayerNextLevelXp();
lua_pushnumber(L, nlxp > 0 ? nlxp : 1);
@ -3438,7 +3442,7 @@ static int lua_UnitAffectingCombat(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr == "player") {
lua_pushboolean(L, gh->isInCombat());
} else {
@ -3483,7 +3487,7 @@ static int lua_UnitInParty(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr == "player") {
lua_pushboolean(L, gh->isInGroup());
} else {
@ -3504,7 +3508,7 @@ static int lua_UnitInRaid(lua_State* L) {
auto* gh = getGameHandler(L);
if (!gh) { lua_pushboolean(L, 0); return 1; }
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
const auto& pd = gh->getPartyData();
if (pd.groupType != 1) { lua_pushboolean(L, 0); return 1; }
if (uidStr == "player") {
@ -3582,8 +3586,8 @@ static int lua_UnitIsUnit(lua_State* L) {
const char* uid1 = luaL_checkstring(L, 1);
const char* uid2 = luaL_checkstring(L, 2);
std::string u1(uid1), u2(uid2);
for (char& c : u1) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
for (char& c : u2) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(u1);
toLowerInPlace(u2);
uint64_t g1 = resolveUnitGuid(gh, u1);
uint64_t g2 = resolveUnitGuid(gh, u2);
lua_pushboolean(L, g1 != 0 && g1 == g2);
@ -3609,7 +3613,7 @@ static int lua_UnitCreatureType(lua_State* L) {
if (!gh) { lua_pushstring(L, "Unknown"); return 1; }
const char* uid = luaL_optstring(L, 1, "target");
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushstring(L, "Unknown"); return 1; }
auto entity = gh->getEntityManager().getEntity(guid);
@ -3709,10 +3713,10 @@ static int lua_GetSpellLink(lua_State* L) {
const char* name = lua_tostring(L, 1);
if (!name || !*name) { lua_pushnil(L); return 1; }
std::string nameLow(name);
for (char& c : nameLow) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(nameLow);
for (uint32_t sid : gh->getKnownSpells()) {
std::string sn = gh->getSpellName(sid);
for (char& c : sn) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(sn);
if (sn == nameLow) { spellId = sid; break; }
}
}
@ -3737,10 +3741,10 @@ static int lua_IsUsableSpell(lua_State* L) {
const char* name = lua_tostring(L, 1);
if (!name || !*name) { lua_pushboolean(L, 0); lua_pushboolean(L, 0); return 2; }
std::string nameLow(name);
for (char& c : nameLow) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(nameLow);
for (uint32_t sid : gh->getKnownSpells()) {
std::string sn = gh->getSpellName(sid);
for (char& c : sn) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(sn);
if (sn == nameLow) { spellId = sid; break; }
}
}
@ -3816,7 +3820,7 @@ static int lua_UnitClassification(lua_State* L) {
if (!gh) { lua_pushstring(L, "normal"); return 1; }
const char* uid = luaL_optstring(L, 1, "target");
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushstring(L, "normal"); return 1; }
auto entity = gh->getEntityManager().getEntity(guid);
@ -3855,9 +3859,9 @@ static int lua_UnitReaction(lua_State* L) {
if (!unit2) { lua_pushnil(L); return 1; }
// If unit2 is the player, always friendly to self
std::string u1(uid1);
for (char& c : u1) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(u1);
std::string u2(uid2);
for (char& c : u2) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(u2);
uint64_t g1 = resolveUnitGuid(gh, u1);
uint64_t g2 = resolveUnitGuid(gh, u2);
if (g1 == g2) { lua_pushnumber(L, 5); return 1; } // same unit = friendly
@ -3875,7 +3879,7 @@ static int lua_UnitIsConnected(lua_State* L) {
if (!gh) { lua_pushboolean(L, 0); return 1; }
const char* uid = luaL_optstring(L, 1, "player");
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
uint64_t guid = resolveUnitGuid(gh, uidStr);
if (guid == 0) { lua_pushboolean(L, 0); return 1; }
// Player is always connected
@ -4164,7 +4168,7 @@ static int lua_CancelUnitBuff(lua_State* L) {
if (!gh) return 0;
const char* uid = luaL_optstring(L, 1, "player");
std::string uidStr(uid);
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(uidStr);
if (uidStr != "player") return 0; // Can only cancel own buffs
int index = static_cast<int>(luaL_checknumber(L, 2));
const auto& auras = gh->getPlayerAuras();
@ -7474,7 +7478,7 @@ bool LuaEngine::dispatchSlashCommand(const std::string& command, const std::stri
if (!lua_istable(L_, -1)) { lua_pop(L_, 1); return false; }
std::string cmdLower = command;
for (char& c : cmdLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(cmdLower);
lua_pushnil(L_);
while (lua_next(L_, -2) != 0) {
@ -7491,7 +7495,7 @@ bool LuaEngine::dispatchSlashCommand(const std::string& command, const std::stri
lua_getglobal(L_, globalName.c_str());
if (lua_isstring(L_, -1)) {
std::string slashStr = lua_tostring(L_, -1);
for (char& c : slashStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
toLowerInPlace(slashStr);
if (slashStr == cmdLower) {
lua_pop(L_, 1); // pop global
// Call the handler with args

View file

@ -82,7 +82,7 @@ void AuthHandler::requestRealmList() {
return;
}
if (state != AuthState::AUTHENTICATED && state != AuthState::REALM_LIST_RECEIVED) {
LOG_ERROR("Cannot request realm list: not authenticated (state: ", (int)state, ")");
LOG_ERROR("Cannot request realm list: not authenticated (state: ", static_cast<int>(state), ")");
return;
}
@ -182,11 +182,11 @@ void AuthHandler::handleLogonChallengeResponse(network::Packet& packet) {
if (response.result == AuthResult::BUILD_INVALID || response.result == AuthResult::BUILD_UPDATE) {
std::ostringstream ss;
ss << "LOGON_CHALLENGE failed: version mismatch (client v"
<< (int)clientInfo.majorVersion << "."
<< (int)clientInfo.minorVersion << "."
<< (int)clientInfo.patchVersion
<< static_cast<int>(clientInfo.majorVersion) << "."
<< static_cast<int>(clientInfo.minorVersion) << "."
<< static_cast<int>(clientInfo.patchVersion)
<< " build " << clientInfo.build
<< ", auth protocol " << (int)clientInfo.protocolVersion << ")";
<< ", auth protocol " << static_cast<int>(clientInfo.protocolVersion) << ")";
fail(ss.str());
} else {
fail(std::string("LOGON_CHALLENGE failed: ") + getAuthResultString(response.result));
@ -195,14 +195,14 @@ void AuthHandler::handleLogonChallengeResponse(network::Packet& packet) {
}
if (response.securityFlags != 0) {
LOG_WARNING("Server sent security flags: 0x", std::hex, (int)response.securityFlags, std::dec);
LOG_WARNING("Server sent security flags: 0x", std::hex, static_cast<int>(response.securityFlags), std::dec);
if (response.securityFlags & 0x01) LOG_WARNING(" PIN required");
if (response.securityFlags & 0x02) LOG_WARNING(" Matrix card required (not supported)");
if (response.securityFlags & 0x04) LOG_WARNING(" Authenticator required (not supported)");
}
LOG_INFO("Challenge: N=", response.N.size(), "B g=", response.g.size(), "B salt=",
response.salt.size(), "B secFlags=0x", std::hex, (int)response.securityFlags, std::dec);
response.salt.size(), "B secFlags=0x", std::hex, static_cast<int>(response.securityFlags), std::dec);
// Feed SRP with server challenge data
srp->feed(response.B, response.g, response.N, response.salt);
@ -389,7 +389,7 @@ void AuthHandler::handleRealmListResponse(network::Packet& packet) {
const auto& realm = realms[i];
LOG_INFO("Realm ", (i + 1), ": ", realm.name);
LOG_INFO(" Address: ", realm.address);
LOG_INFO(" ID: ", (int)realm.id);
LOG_INFO(" ID: ", static_cast<int>(realm.id));
LOG_INFO(" Population: ", realm.population);
LOG_INFO(" Characters: ", static_cast<int>(realm.characters));
if (realm.hasVersionInfo()) {
@ -421,9 +421,9 @@ void AuthHandler::handlePacket(network::Packet& packet) {
const auto& raw = packet.getData();
std::ostringstream hs;
for (size_t i = 0; i < std::min<size_t>(raw.size(), 40); ++i)
hs << std::hex << std::setfill('0') << std::setw(2) << (int)raw[i];
hs << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(raw[i]);
if (raw.size() > 40) hs << "...";
LOG_INFO("Auth pkt 0x", std::hex, (int)opcodeValue, std::dec,
LOG_INFO("Auth pkt 0x", std::hex, static_cast<int>(opcodeValue), std::dec,
" (", raw.size(), "B): ", hs.str());
}
@ -442,11 +442,11 @@ void AuthHandler::handlePacket(network::Packet& packet) {
}
if (response.result == AuthResult::BUILD_INVALID || response.result == AuthResult::BUILD_UPDATE) {
ss << ": version mismatch (client v"
<< (int)clientInfo.majorVersion << "."
<< (int)clientInfo.minorVersion << "."
<< (int)clientInfo.patchVersion
<< static_cast<int>(clientInfo.majorVersion) << "."
<< static_cast<int>(clientInfo.minorVersion) << "."
<< static_cast<int>(clientInfo.patchVersion)
<< " build " << clientInfo.build
<< ", auth protocol " << (int)clientInfo.protocolVersion << ")";
<< ", auth protocol " << static_cast<int>(clientInfo.protocolVersion) << ")";
} else {
ss << ": " << getAuthResultString(response.result)
<< " (code 0x" << std::hex << std::setw(2) << std::setfill('0')
@ -454,7 +454,7 @@ void AuthHandler::handlePacket(network::Packet& packet) {
}
fail(ss.str());
} else {
LOG_WARNING("Unexpected LOGON_CHALLENGE response in state: ", (int)state);
LOG_WARNING("Unexpected LOGON_CHALLENGE response in state: ", static_cast<int>(state));
}
}
break;
@ -463,7 +463,7 @@ void AuthHandler::handlePacket(network::Packet& packet) {
if (state == AuthState::PROOF_SENT) {
handleLogonProofResponse(packet);
} else {
LOG_WARNING("Unexpected LOGON_PROOF response in state: ", (int)state);
LOG_WARNING("Unexpected LOGON_PROOF response in state: ", static_cast<int>(state));
}
break;
@ -471,12 +471,12 @@ void AuthHandler::handlePacket(network::Packet& packet) {
if (state == AuthState::REALM_LIST_REQUESTED) {
handleRealmListResponse(packet);
} else {
LOG_WARNING("Unexpected REALM_LIST response in state: ", (int)state);
LOG_WARNING("Unexpected REALM_LIST response in state: ", static_cast<int>(state));
}
break;
default:
LOG_WARNING("Unhandled auth opcode: 0x", std::hex, (int)opcodeValue, std::dec);
LOG_WARNING("Unhandled auth opcode: 0x", std::hex, static_cast<int>(opcodeValue), std::dec);
break;
}
}
@ -503,7 +503,7 @@ void AuthHandler::update(float /*deltaTime*/) {
void AuthHandler::setState(AuthState newState) {
if (state != newState) {
LOG_DEBUG("Auth state: ", (int)state, " -> ", (int)newState);
LOG_DEBUG("Auth state: ", static_cast<int>(state), " -> ", static_cast<int>(newState));
state = newState;
}
}

View file

@ -207,7 +207,7 @@ bool LogonChallengeResponseParser::parse(network::Packet& packet, LogonChallenge
LOG_DEBUG(" g size: ", response.g.size(), " bytes");
LOG_DEBUG(" N size: ", response.N.size(), " bytes");
LOG_DEBUG(" salt size: ", response.salt.size(), " bytes");
LOG_DEBUG(" Security flags: ", (int)response.securityFlags);
LOG_DEBUG(" Security flags: ", static_cast<int>(response.securityFlags));
if (response.securityFlags & 0x01) {
LOG_DEBUG(" PIN grid seed: ", response.pinGridSeed);
}
@ -317,10 +317,10 @@ bool LogonProofResponseParser::parse(network::Packet& packet, LogonProofResponse
// Status
response.status = packet.readUInt8();
LOG_INFO("LOGON_PROOF response status: ", (int)response.status);
LOG_INFO("LOGON_PROOF response status: ", static_cast<int>(response.status));
if (response.status != 0) {
LOG_ERROR("LOGON_PROOF failed with status: ", (int)response.status);
LOG_ERROR("LOGON_PROOF failed with status: ", static_cast<int>(response.status));
return true; // Valid packet, but proof failed
}
@ -428,13 +428,13 @@ bool RealmListResponseParser::parse(network::Packet& packet, RealmListResponse&
LOG_DEBUG(" Realm ", static_cast<int>(i), " details:");
LOG_DEBUG(" Name: ", realm.name);
LOG_DEBUG(" Address: ", realm.address);
LOG_DEBUG(" ID: ", (int)realm.id);
LOG_DEBUG(" Icon: ", (int)realm.icon);
LOG_DEBUG(" Lock: ", (int)realm.lock);
LOG_DEBUG(" Flags: ", (int)realm.flags);
LOG_DEBUG(" ID: ", static_cast<int>(realm.id));
LOG_DEBUG(" Icon: ", static_cast<int>(realm.icon));
LOG_DEBUG(" Lock: ", static_cast<int>(realm.lock));
LOG_DEBUG(" Flags: ", static_cast<int>(realm.flags));
LOG_DEBUG(" Population: ", realm.population);
LOG_DEBUG(" Characters: ", (int)realm.characters);
LOG_DEBUG(" Timezone: ", (int)realm.timezone);
LOG_DEBUG(" Characters: ", static_cast<int>(realm.characters));
LOG_DEBUG(" Timezone: ", static_cast<int>(realm.timezone));
response.realms.push_back(realm);
}

View file

@ -3668,8 +3668,8 @@ void Application::spawnPlayerCharacter() {
charFaceId = (activeChar->appearanceBytes >> 8) & 0xFF;
charHairStyleId = (activeChar->appearanceBytes >> 16) & 0xFF;
charHairColorId = (activeChar->appearanceBytes >> 24) & 0xFF;
LOG_INFO("Appearance: skin=", (int)charSkinId, " face=", (int)charFaceId,
" hairStyle=", (int)charHairStyleId, " hairColor=", (int)charHairColorId);
LOG_INFO("Appearance: skin=", static_cast<int>(charSkinId), " face=", static_cast<int>(charFaceId),
" hairStyle=", static_cast<int>(charHairStyleId), " hairColor=", static_cast<int>(charHairColorId));
}
}
@ -3699,7 +3699,7 @@ void Application::spawnPlayerCharacter() {
if (!tex1.empty()) {
bodySkinPath = tex1;
foundSkin = true;
LOG_INFO(" DBC body skin: ", bodySkinPath, " (skin=", (int)charSkinId, ")");
LOG_INFO(" DBC body skin: ", bodySkinPath, " (skin=", static_cast<int>(charSkinId), ")");
}
}
// Section 3 = hair: match variation=hairStyle, color=hairColor
@ -3709,7 +3709,7 @@ void Application::spawnPlayerCharacter() {
if (!hairTexturePath.empty()) {
foundHair = true;
LOG_INFO(" DBC hair texture: ", hairTexturePath,
" (style=", (int)charHairStyleId, " color=", (int)charHairColorId, ")");
" (style=", static_cast<int>(charHairStyleId), " color=", static_cast<int>(charHairColorId), ")");
}
}
// Section 1 = face: match variation=faceId, colorIndex=skinId
@ -3744,8 +3744,8 @@ void Application::spawnPlayerCharacter() {
}
if (!foundHair) {
LOG_WARNING("No DBC hair match for style=", (int)charHairStyleId,
" color=", (int)charHairColorId,
LOG_WARNING("No DBC hair match for style=", static_cast<int>(charHairStyleId),
" color=", static_cast<int>(charHairColorId),
" race=", targetRaceId, " sex=", targetSexId);
}
} else {
@ -4363,7 +4363,7 @@ void Application::buildFactionHostilityMap(uint8_t playerRace) {
}
}
}
LOG_INFO("Faction.dbc: ", hostileParentFactions.size(), " factions hostile to race ", (int)playerRace);
LOG_INFO("Faction.dbc: ", hostileParentFactions.size(), " factions hostile to race ", static_cast<int>(playerRace));
}
// Get player faction template data
@ -4431,7 +4431,7 @@ void Application::buildFactionHostilityMap(uint8_t playerRace) {
uint32_t hostileCount = 0;
for (const auto& [fid, h] : factionMap) { if (h) hostileCount++; }
gameHandler->setFactionHostileMap(std::move(factionMap));
LOG_INFO("Faction hostility for race ", (int)playerRace, " (FT ", playerFtId, "): ",
LOG_INFO("Faction hostility for race ", static_cast<int>(playerRace), " (FT ", playerFtId, "): ",
hostileCount, "/", ftDbc->getRecordCount(),
" hostile (friendGroup=0x", std::hex, playerFriendGroup, ", enemyGroup=0x", playerEnemyGroup, std::dec, ")");
}
@ -5679,7 +5679,7 @@ audio::VoiceType Application::detectVoiceTypeFromDisplayId(uint32_t displayId) c
default: result = audio::VoiceType::GENERIC; break;
}
LOG_INFO("Voice detection: displayId ", displayId, " -> ", raceName, " ", sexName, " (race=", (int)raceId, ", sex=", (int)sexId, ")");
LOG_INFO("Voice detection: displayId ", displayId, " -> ", raceName, " ", sexName, " (race=", static_cast<int>(raceId), ", sex=", static_cast<int>(sexId), ")");
return result;
}
@ -5926,8 +5926,8 @@ void Application::spawnOnlineCreature(uint64_t guid, uint32_t displayId, float x
auto itExtra = humanoidExtraMap_.find(dispData.extraDisplayId);
if (itExtra != humanoidExtraMap_.end()) {
const auto& extra = itExtra->second;
LOG_DEBUG(" Found humanoid extra: raceId=", (int)extra.raceId, " sexId=", (int)extra.sexId,
" hairStyle=", (int)extra.hairStyleId, " hairColor=", (int)extra.hairColorId,
LOG_DEBUG(" Found humanoid extra: raceId=", static_cast<int>(extra.raceId), " sexId=", static_cast<int>(extra.sexId),
" hairStyle=", static_cast<int>(extra.hairStyleId), " hairColor=", static_cast<int>(extra.hairColorId),
" bakeName='", extra.bakeName, "'");
// Collect model texture slot info (type 1 = skin, type 6 = hair)
@ -6459,9 +6459,9 @@ void Application::spawnOnlineCreature(uint64_t guid, uint32_t displayId, float x
if (itFacial != facialHairGeosetMap_.end()) {
const auto& fhg = itFacial->second;
// DBC values are variation indices within each group; add group base
activeGeosets.insert(static_cast<uint16_t>(100 + std::max(fhg.geoset100, (uint16_t)1)));
activeGeosets.insert(static_cast<uint16_t>(300 + std::max(fhg.geoset300, (uint16_t)1)));
activeGeosets.insert(static_cast<uint16_t>(200 + std::max(fhg.geoset200, (uint16_t)1)));
activeGeosets.insert(static_cast<uint16_t>(100 + std::max(fhg.geoset100, static_cast<uint16_t>(1))));
activeGeosets.insert(static_cast<uint16_t>(300 + std::max(fhg.geoset300, static_cast<uint16_t>(1))));
activeGeosets.insert(static_cast<uint16_t>(200 + std::max(fhg.geoset200, static_cast<uint16_t>(1))));
} else {
activeGeosets.insert(101); // Default group 1: no extra
activeGeosets.insert(201); // Default group 2: no facial hair
@ -6658,7 +6658,7 @@ void Application::spawnOnlineCreature(uint64_t guid, uint32_t displayId, float x
}
}
}
LOG_DEBUG("Set humanoid geosets: hair=", (int)hairGeoset,
LOG_DEBUG("Set humanoid geosets: hair=", static_cast<int>(hairGeoset),
" sleeves=", geosetSleeves, " pants=", geosetPants,
" boots=", geosetBoots, " gloves=", geosetGloves);
@ -7095,7 +7095,7 @@ void Application::spawnOnlinePlayer(uint64_t guid,
std::string m2Path = game::getPlayerModelPath(race, gender);
if (m2Path.empty()) {
LOG_WARNING("spawnOnlinePlayer: unknown race/gender for guid 0x", std::hex, guid, std::dec,
" race=", (int)raceId, " gender=", (int)genderId);
" race=", static_cast<int>(raceId), " gender=", static_cast<int>(genderId));
return;
}
@ -7173,9 +7173,9 @@ void Application::spawnOnlinePlayer(uint64_t guid,
if (const auto* md = charRenderer->getModelData(modelId)) {
for (size_t ti = 0; ti < md->textures.size(); ti++) {
uint32_t t = md->textures[ti].type;
if (t == 1 && slots.skin < 0) slots.skin = (int)ti;
else if (t == 6 && slots.hair < 0) slots.hair = (int)ti;
else if (t == 8 && slots.underwear < 0) slots.underwear = (int)ti;
if (t == 1 && slots.skin < 0) slots.skin = static_cast<int>(ti);
else if (t == 6 && slots.hair < 0) slots.hair = static_cast<int>(ti);
else if (t == 8 && slots.underwear < 0) slots.underwear = static_cast<int>(ti);
}
}
playerTextureSlotsByModelId_[modelId] = slots;

View file

@ -1569,7 +1569,7 @@ void GameHandler::registerOpcodeHandlers() {
uint8_t result = packet.readUInt8();
lastCharDeleteResult_ = result;
bool success = (result == 0x00 || result == 0x47);
LOG_INFO("SMSG_CHAR_DELETE result: ", (int)result, success ? " (success)" : " (failed)");
LOG_INFO("SMSG_CHAR_DELETE result: ", static_cast<int>(result), success ? " (success)" : " (failed)");
requestCharacterList();
if (charDeleteCallback_) charDeleteCallback_(success);
};
@ -1680,7 +1680,7 @@ void GameHandler::registerOpcodeHandlers() {
std::string ignName = packet.readString();
if (!ignName.empty() && ignGuid != 0) ignoreCache[ignName] = ignGuid;
}
LOG_DEBUG("SMSG_IGNORE_LIST: loaded ", (int)ignCount, " ignored players");
LOG_DEBUG("SMSG_IGNORE_LIST: loaded ", static_cast<int>(ignCount), " ignored players");
};
dispatchTable_[Opcode::MSG_RANDOM_ROLL] = [this](network::Packet& packet) { if (state == WorldState::IN_WORLD) handleRandomRoll(packet); };
@ -2038,7 +2038,7 @@ void GameHandler::registerOpcodeHandlers() {
pendingLootRoll_.voteMask = voteMask;
pendingLootRoll_.rollStartedAt = std::chrono::steady_clock::now();
LOG_INFO("SMSG_LOOT_START_ROLL: item=", itemId, " (", pendingLootRoll_.itemName,
") slot=", slot, " voteMask=0x", std::hex, (int)voteMask, std::dec);
") slot=", slot, " voteMask=0x", std::hex, static_cast<int>(voteMask), std::dec);
fireAddonEvent("START_LOOT_ROLL", {std::to_string(slot), std::to_string(countdown)});
};
@ -3986,7 +3986,7 @@ void GameHandler::registerOpcodeHandlers() {
if (packet.getSize() - packet.getReadPos() < 8) return;
uint32_t duration = packet.readUInt32();
uint32_t spellId = packet.readUInt32();
LOG_DEBUG("SMSG_TOTEM_CREATED: slot=", (int)slot,
LOG_DEBUG("SMSG_TOTEM_CREATED: slot=", static_cast<int>(slot),
" spellId=", spellId, " duration=", duration, "ms");
if (slot < NUM_TOTEM_SLOTS) {
activeTotemSlots_[slot].spellId = spellId;
@ -4410,7 +4410,7 @@ void GameHandler::registerOpcodeHandlers() {
if (auto* sfx = renderer->getUiSoundManager())
sfx->playError();
}
LOG_WARNING("SMSG_SELL_ITEM error: ", (int)result, " (", msg, ")");
LOG_WARNING("SMSG_SELL_ITEM error: ", static_cast<int>(result), " (", msg, ")");
}
}
};
@ -4420,7 +4420,7 @@ void GameHandler::registerOpcodeHandlers() {
if ((packet.getSize() - packet.getReadPos()) >= 1) {
uint8_t error = packet.readUInt8();
if (error != 0) {
LOG_WARNING("SMSG_INVENTORY_CHANGE_FAILURE: error=", (int)error);
LOG_WARNING("SMSG_INVENTORY_CHANGE_FAILURE: error=", static_cast<int>(error));
// After error byte: item_guid1(8) + item_guid2(8) + bag_slot(1) = 17 bytes
uint32_t requiredLevel = 0;
if (packet.getSize() - packet.getReadPos() >= 17) {
@ -5470,7 +5470,7 @@ void GameHandler::registerOpcodeHandlers() {
}
}
LOG_DEBUG("MSG_INSPECT_ARENA_TEAMS: guid=0x", std::hex, inspGuid, std::dec,
" teams=", (int)teamCount);
" teams=", static_cast<int>(teamCount));
};
// auctionId(u32) + action(u32) + error(u32) + itemEntry(u32) + randomPropertyId(u32) + ...
// action: 0=sold/won, 1=expired, 2=bid placed on your auction
@ -5816,7 +5816,7 @@ void GameHandler::registerOpcodeHandlers() {
zoneId, levelMin, levelMax);
addSystemChatMessage(buf);
LOG_INFO("SMSG_MEETINGSTONE_SETQUEUE: zone=", zoneId,
" levels=", (int)levelMin, "-", (int)levelMax);
" levels=", static_cast<int>(levelMin), "-", static_cast<int>(levelMax));
}
packet.setReadPos(packet.getSize());
};
@ -5865,7 +5865,7 @@ void GameHandler::registerOpcodeHandlers() {
const char* msg = (reason < 4) ? kMeetingstoneErrors[reason]
: "Meeting Stone: Could not join group.";
addSystemChatMessage(msg);
LOG_INFO("SMSG_MEETINGSTONE_JOINFAILED: reason=", (int)reason);
LOG_INFO("SMSG_MEETINGSTONE_JOINFAILED: reason=", static_cast<int>(reason));
}
};
// Player was removed from the meeting stone queue (left, or group disbanded)
@ -5949,7 +5949,7 @@ void GameHandler::registerOpcodeHandlers() {
// Status 1 = no open ticket (default/no ticket)
gmTicketActive_ = false;
gmTicketText_.clear();
LOG_DEBUG("SMSG_GMTICKET_GETTICKET: no open ticket (status=", (int)gmStatus, ")");
LOG_DEBUG("SMSG_GMTICKET_GETTICKET: no open ticket (status=", static_cast<int>(gmStatus), ")");
}
packet.setReadPos(packet.getSize());
};
@ -7002,8 +7002,8 @@ void GameHandler::registerOpcodeHandlers() {
if (modeGuid == petGuid_) {
petCommand_ = static_cast<uint8_t>(mode & 0xFF);
petReact_ = static_cast<uint8_t>((mode >> 8) & 0xFF);
LOG_DEBUG("SMSG_PET_MODE: command=", (int)petCommand_,
" react=", (int)petReact_);
LOG_DEBUG("SMSG_PET_MODE: command=", static_cast<int>(petCommand_),
" react=", static_cast<int>(petReact_));
}
}
packet.setReadPos(packet.getSize());
@ -7054,7 +7054,7 @@ void GameHandler::registerOpcodeHandlers() {
uint8_t reason = (packet.getSize() - packet.getReadPos() >= 1)
? packet.readUInt8() : 0;
LOG_DEBUG("SMSG_PET_CAST_FAILED: spell=", spellId,
" reason=", (int)reason);
" reason=", static_cast<int>(reason));
if (reason != 0) {
const char* reasonStr = getSpellCastResultString(reason);
const std::string& sName = getSpellName(spellId);
@ -7354,7 +7354,7 @@ void GameHandler::registerOpcodeHandlers() {
addSystemChatMessage(isSafe ? "You are in the battlefield zone (safe area)."
: "You have entered the battlefield!");
if (onQueue) addSystemChatMessage("You are in the battlefield queue.");
LOG_INFO("SMSG_BATTLEFIELD_MGR_ENTERED: isSafe=", (int)isSafe, " onQueue=", (int)onQueue);
LOG_INFO("SMSG_BATTLEFIELD_MGR_ENTERED: isSafe=", static_cast<int>(isSafe), " onQueue=", static_cast<int>(onQueue));
}
packet.setReadPos(packet.getSize());
};
@ -7404,8 +7404,8 @@ void GameHandler::registerOpcodeHandlers() {
: "Battlefield queue request failed.";
addSystemChatMessage(std::string("Battlefield: ") + msg);
}
LOG_INFO("SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE: accepted=", (int)accepted,
" result=", (int)result);
LOG_INFO("SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE: accepted=", static_cast<int>(accepted),
" result=", static_cast<int>(result));
packet.setReadPos(packet.getSize());
};
// uint64 battlefieldGuid + uint8 remove
@ -7418,7 +7418,7 @@ void GameHandler::registerOpcodeHandlers() {
if (remove) {
addSystemChatMessage("You will be removed from the battlefield shortly.");
}
LOG_INFO("SMSG_BATTLEFIELD_MGR_EJECT_PENDING: remove=", (int)remove);
LOG_INFO("SMSG_BATTLEFIELD_MGR_EJECT_PENDING: remove=", static_cast<int>(remove));
}
packet.setReadPos(packet.getSize());
};
@ -7439,7 +7439,7 @@ void GameHandler::registerOpcodeHandlers() {
: "You have been ejected from the battlefield.";
addSystemChatMessage(msg);
if (relocated) addSystemChatMessage("You have been relocated outside the battlefield.");
LOG_INFO("SMSG_BATTLEFIELD_MGR_EJECTED: reason=", reason, " relocated=", (int)relocated);
LOG_INFO("SMSG_BATTLEFIELD_MGR_EJECTED: reason=", reason, " relocated=", static_cast<int>(relocated));
}
bfMgrActive_ = false;
bfMgrInvitePending_ = false;
@ -8370,7 +8370,7 @@ void GameHandler::handleCharEnum(network::Packet& packet) {
LOG_INFO(" GUID: 0x", std::hex, character.guid, std::dec);
LOG_INFO(" ", getRaceName(character.race), " ",
getClassName(character.characterClass));
LOG_INFO(" Level ", (int)character.level);
LOG_INFO(" Level ", static_cast<int>(character.level));
}
}
@ -8528,7 +8528,7 @@ void GameHandler::handleCharLoginFailed(network::Packet& packet) {
};
const char* msg = (reason < 9) ? reasonNames[reason] : "Unknown reason";
LOG_ERROR("SMSG_CHARACTER_LOGIN_FAILED: reason=", (int)reason, " (", msg, ")");
LOG_ERROR("SMSG_CHARACTER_LOGIN_FAILED: reason=", static_cast<int>(reason), " (", msg, ")");
// Allow the player to re-select a character
setState(WorldState::CHAR_LIST_RECEIVED);
@ -8540,7 +8540,7 @@ void GameHandler::handleCharLoginFailed(network::Packet& packet) {
void GameHandler::selectCharacter(uint64_t characterGuid) {
if (state != WorldState::CHAR_LIST_RECEIVED) {
LOG_WARNING("Cannot select character in state: ", (int)state);
LOG_WARNING("Cannot select character in state: ", static_cast<int>(state));
return;
}
@ -8557,7 +8557,7 @@ void GameHandler::selectCharacter(uint64_t characterGuid) {
for (const auto& character : characters) {
if (character.guid == characterGuid) {
LOG_INFO("Character: ", character.name);
LOG_INFO("Level ", (int)character.level, " ",
LOG_INFO("Level ", static_cast<int>(character.level), " ",
getRaceName(character.race), " ",
getClassName(character.characterClass));
playerRace_ = character.race;
@ -9382,7 +9382,7 @@ void GameHandler::handleWardenData(network::Packet& packet) {
pos += 4;
uint8_t readLen = decrypted[pos++];
LOG_WARNING("Warden: MEM offset=0x", [&]{char s[12];snprintf(s,12,"%08x",offset);return std::string(s);}(),
" len=", (int)readLen,
" len=", static_cast<int>(readLen),
(strIdx ? " module=\"" + moduleName + "\"" : ""));
if (offset == 0x00CF0BC8 && readLen == 4 && wardenMemory_ && wardenMemory_->isLoaded()) {
uint32_t now = static_cast<uint32_t>(
@ -9401,9 +9401,9 @@ void GameHandler::handleWardenData(network::Packet& packet) {
else if (offset >= 0x827000 && offset < 0x883000) region = ".data(raw)";
else if (offset >= 0x883000 && offset < 0xD06000) region = ".data(BSS)";
bool allZero = true;
for (int i = 0; i < (int)readLen; i++) { if (memBuf[i] != 0) { allZero = false; break; } }
for (int i = 0; i < static_cast<int>(readLen); i++) { if (memBuf[i] != 0) { allZero = false; break; } }
std::string hexDump;
for (int i = 0; i < (int)readLen; i++) { char hx[4]; snprintf(hx,4,"%02x ",memBuf[i]); hexDump += hx; }
for (int i = 0; i < static_cast<int>(readLen); i++) { char hx[4]; snprintf(hx,4,"%02x ",memBuf[i]); hexDump += hx; }
LOG_WARNING("Warden: MEM_CHECK served: [", hexDump, "] region=", region,
(allZero && offset >= 0x883000 ? " \xe2\x98\x85""BSS_ZERO\xe2\x98\x85" : ""));
if (offset == 0x7FFE026C && readLen == 12)
@ -9463,7 +9463,7 @@ void GameHandler::handleWardenData(network::Packet& packet) {
uint8_t pageResult = found ? 0x4A : 0x00;
LOG_WARNING("Warden: ", pageName, " offset=0x",
[&]{char s[12];snprintf(s,12,"%08x",off);return std::string(s);}(),
" patLen=", (int)patLen, " found=", found ? "yes" : "no",
" patLen=", static_cast<int>(patLen), " found=", found ? "yes" : "no",
turtleFallback ? " (turtle-fallback)" : "");
pos += kPageSize;
resultData.push_back(pageResult);
@ -9737,7 +9737,7 @@ void GameHandler::handleWardenData(network::Packet& packet) {
pos += 4;
uint8_t readLen = decrypted[pos++];
LOG_WARNING("Warden: (sync) MEM offset=0x", [&]{char s[12];snprintf(s,12,"%08x",offset);return std::string(s);}(),
" len=", (int)readLen,
" len=", static_cast<int>(readLen),
moduleName.empty() ? "" : (" module=\"" + moduleName + "\""));
// Lazy-load WoW.exe PE image on first MEM_CHECK
@ -9831,7 +9831,7 @@ void GameHandler::handleWardenData(network::Packet& packet) {
uint8_t len2 = (decrypted.data()+pos)[28];
LOG_WARNING("Warden: (sync) PAGE_A offset=0x",
[&]{char s[12];snprintf(s,12,"%08x",off2);return std::string(s);}(),
" patLen=", (int)len2,
" patLen=", static_cast<int>(len2),
" result=0x", [&]{char s[4];snprintf(s,4,"%02x",pageResult);return std::string(s);}());
} else {
LOG_WARNING("Warden: (sync) PAGE_A (short ", consume, "b) result=0x",
@ -10073,8 +10073,8 @@ void GameHandler::handleWardenData(network::Packet& packet) {
break;
default:
LOG_DEBUG("Warden: Unknown opcode 0x", std::hex, (int)wardenOpcode, std::dec,
" (state=", (int)wardenState_, ", size=", decrypted.size(), ")");
LOG_DEBUG("Warden: Unknown opcode 0x", std::hex, static_cast<int>(wardenOpcode), std::dec,
" (state=", static_cast<int>(wardenState_), ", size=", decrypted.size(), ")");
break;
}
}
@ -10338,7 +10338,7 @@ uint32_t GameHandler::nextMovementTimestampMs() {
void GameHandler::sendMovement(Opcode opcode) {
if (state != WorldState::IN_WORLD) {
LOG_WARNING("Cannot send movement in state: ", (int)state);
LOG_WARNING("Cannot send movement in state: ", static_cast<int>(state));
return;
}
@ -11661,7 +11661,7 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem
uint8_t newForm = static_cast<uint8_t>((val >> 24) & 0xFF);
if (newForm != shapeshiftFormId_) {
shapeshiftFormId_ = newForm;
LOG_INFO("Shapeshift form changed: ", (int)newForm);
LOG_INFO("Shapeshift form changed: ", static_cast<int>(newForm));
if (addonEventCallback_) {
fireAddonEvent("UPDATE_SHAPESHIFT_FORM", {});
fireAddonEvent("UPDATE_SHAPESHIFT_FORMS", {});
@ -12474,7 +12474,7 @@ void GameHandler::handleDestroyObject(network::Packet& packet) {
void GameHandler::sendChatMessage(ChatType type, const std::string& message, const std::string& target) {
if (state != WorldState::IN_WORLD) {
LOG_WARNING("Cannot send chat in state: ", (int)state);
LOG_WARNING("Cannot send chat in state: ", static_cast<int>(state));
return;
}
@ -13324,7 +13324,7 @@ void GameHandler::setStandState(uint8_t standState) {
auto packet = StandStateChangePacket::build(standState);
socket->send(packet);
LOG_INFO("Changed stand state to: ", (int)standState);
LOG_INFO("Changed stand state to: ", static_cast<int>(standState));
}
void GameHandler::toggleHelm() {
@ -14226,8 +14226,8 @@ void GameHandler::handleNameQueryResponse(network::Packet& packet) {
pendingNameQueries.erase(data.guid);
LOG_INFO("Name query response: guid=0x", std::hex, data.guid, std::dec,
" found=", (int)data.found, " name='", data.name, "'",
" race=", (int)data.race, " class=", (int)data.classId);
" found=", static_cast<int>(data.found), " name='", data.name, "'",
" race=", static_cast<int>(data.race), " class=", static_cast<int>(data.classId));
if (data.isValid()) {
playerNameCache[data.guid] = data.name;
@ -14549,7 +14549,7 @@ void GameHandler::handleInspectResults(network::Packet& packet) {
}
LOG_INFO("SMSG_TALENTS_INFO type=0: unspent=", unspentTalents,
" groups=", (int)talentGroupCount, " active=", (int)activeTalentGroup,
" groups=", static_cast<int>(talentGroupCount), " active=", static_cast<int>(activeTalentGroup),
" learned=", learnedTalents_[activeTalentGroup].size());
return;
}
@ -14645,7 +14645,7 @@ void GameHandler::handleInspectResults(network::Packet& packet) {
}
LOG_INFO("Inspect results for ", playerName, ": ", totalTalents, " talents, ",
unspentTalents, " unspent, ", (int)talentGroupCount, " specs");
unspentTalents, " unspent, ", static_cast<int>(talentGroupCount), " specs");
if (addonEventCallback_) {
char guidBuf[32];
snprintf(guidBuf, sizeof(guidBuf), "0x%016llX", (unsigned long long)guid);
@ -17079,7 +17079,7 @@ void GameHandler::handleArenaTeamEvent(network::Packet& packet) {
break;
}
addSystemChatMessage(msg);
LOG_INFO("Arena team event: ", (int)event, " ", param1, " ", param2);
LOG_INFO("Arena team event: ", static_cast<int>(event), " ", param1, " ", param2);
}
void GameHandler::handleArenaTeamStats(network::Packet& packet) {
@ -17217,14 +17217,14 @@ void GameHandler::handlePvpLogData(network::Packet& packet) {
if (bgScoreboard_.isArena) {
LOG_INFO("Arena log: ", bgScoreboard_.players.size(), " players, hasWinner=",
bgScoreboard_.hasWinner, " winner=", (int)bgScoreboard_.winner,
bgScoreboard_.hasWinner, " winner=", static_cast<int>(bgScoreboard_.winner),
" team0='", bgScoreboard_.arenaTeams[0].teamName,
"' ratingChange=", (int32_t)bgScoreboard_.arenaTeams[0].ratingChange,
" team1='", bgScoreboard_.arenaTeams[1].teamName,
"' ratingChange=", (int32_t)bgScoreboard_.arenaTeams[1].ratingChange);
} else {
LOG_INFO("PvP log: ", bgScoreboard_.players.size(), " players, hasWinner=",
bgScoreboard_.hasWinner, " winner=", (int)bgScoreboard_.winner);
bgScoreboard_.hasWinner, " winner=", static_cast<int>(bgScoreboard_.winner));
}
}
@ -18339,7 +18339,7 @@ void GameHandler::handlePetSpells(network::Packet& packet) {
done:
LOG_INFO("SMSG_PET_SPELLS: petGuid=0x", std::hex, petGuid_, std::dec,
" react=", (int)petReact_, " command=", (int)petCommand_,
" react=", static_cast<int>(petReact_), " command=", static_cast<int>(petCommand_),
" spells=", petSpellList_.size());
if (addonEventCallback_) {
fireAddonEvent("UNIT_PET", {"player"});
@ -18376,7 +18376,7 @@ void GameHandler::togglePetSpellAutocast(uint32_t spellId) {
petAutocastSpells_.insert(spellId);
else
petAutocastSpells_.erase(spellId);
LOG_DEBUG("togglePetSpellAutocast: spellId=", spellId, " autocast=", (int)newState);
LOG_DEBUG("togglePetSpellAutocast: spellId=", spellId, " autocast=", static_cast<int>(newState));
}
void GameHandler::renamePet(const std::string& newName) {
@ -18451,7 +18451,7 @@ void GameHandler::handleListStabledPets(network::Packet& packet) {
stableWindowOpen_ = true;
LOG_INFO("MSG_LIST_STABLED_PETS: stableMasterGuid=0x", std::hex, stableMasterGuid_, std::dec,
" petCount=", (int)petCount, " numSlots=", (int)stableNumSlots_);
" petCount=", static_cast<int>(petCount), " numSlots=", static_cast<int>(stableNumSlots_));
for (const auto& p : stabledPets_) {
LOG_DEBUG(" Pet: number=", p.petNumber, " entry=", p.entry,
" level=", p.level, " name='", p.name, "' displayId=", p.displayId,
@ -19008,8 +19008,8 @@ void GameHandler::handleLearnedSpell(network::Packet& packet) {
// Found the talent! Update the rank for the active spec
uint8_t newRank = rank + 1; // rank is 0-indexed in array, but stored as 1-indexed
learnedTalents_[activeTalentSpec_][talentId] = newRank;
LOG_INFO("Talent learned: id=", talentId, " rank=", (int)newRank,
" (spell ", spellId, ") in spec ", (int)activeTalentSpec_);
LOG_INFO("Talent learned: id=", talentId, " rank=", static_cast<int>(newRank),
" (spell ", spellId, ") in spec ", static_cast<int>(activeTalentSpec_));
isTalentSpell = true;
if (addonEventCallback_) {
fireAddonEvent("CHARACTER_POINTS_CHANGED", {});
@ -19203,7 +19203,7 @@ void GameHandler::handleTalentsInfo(network::Packet& packet) {
static_cast<uint8_t>(unspentTalents > 255 ? 255 : unspentTalents);
LOG_INFO("handleTalentsInfo: unspent=", unspentTalents,
" groups=", (int)talentGroupCount, " active=", (int)activeTalentGroup,
" groups=", static_cast<int>(talentGroupCount), " active=", static_cast<int>(activeTalentGroup),
" learned=", learnedTalents_[activeTalentGroup].size());
// Fire talent-related events for addons
@ -19236,12 +19236,12 @@ void GameHandler::learnTalent(uint32_t talentId, uint32_t requestedRank) {
void GameHandler::switchTalentSpec(uint8_t newSpec) {
if (newSpec > 1) {
LOG_WARNING("Invalid talent spec: ", (int)newSpec);
LOG_WARNING("Invalid talent spec: ", static_cast<int>(newSpec));
return;
}
if (newSpec == activeTalentSpec_) {
LOG_INFO("Already on spec ", (int)newSpec);
LOG_INFO("Already on spec ", static_cast<int>(newSpec));
return;
}
@ -19253,12 +19253,12 @@ void GameHandler::switchTalentSpec(uint8_t newSpec) {
if (state == WorldState::IN_WORLD && socket) {
auto pkt = ActivateTalentGroupPacket::build(static_cast<uint32_t>(newSpec));
socket->send(pkt);
LOG_INFO("Sent CMSG_SET_ACTIVE_TALENT_GROUP_OBSOLETE: group=", (int)newSpec);
LOG_INFO("Sent CMSG_SET_ACTIVE_TALENT_GROUP_OBSOLETE: group=", static_cast<int>(newSpec));
}
activeTalentSpec_ = newSpec;
LOG_INFO("Switched to talent spec ", (int)newSpec,
" (unspent=", (int)unspentTalentPoints_[newSpec],
LOG_INFO("Switched to talent spec ", static_cast<int>(newSpec),
" (unspent=", static_cast<int>(unspentTalentPoints_[newSpec]),
", learned=", learnedTalents_[newSpec].size(), ")");
std::string msg = "Switched to spec " + std::to_string(newSpec + 1);
@ -20433,7 +20433,7 @@ void GameHandler::selectGossipOption(uint32_t optionId) {
for (const auto& opt : currentGossip.options) {
if (opt.id != optionId) continue;
LOG_INFO(" matched option: id=", opt.id, " icon=", (int)opt.icon, " text='", opt.text, "'");
LOG_INFO(" matched option: id=", opt.id, " icon=", static_cast<int>(opt.icon), " text='", opt.text, "'");
// Icon-based NPC interaction fallbacks
// Some servers need the specific activate packet in addition to gossip select
@ -20474,7 +20474,7 @@ void GameHandler::selectGossipOption(uint32_t optionId) {
auto pkt = ListInventoryPacket::build(currentGossip.npcGuid);
socket->send(pkt);
LOG_INFO("Sent CMSG_LIST_INVENTORY (gossip) to npc=0x", std::hex, currentGossip.npcGuid, std::dec,
" vendor=", (int)isVendor, " repair=", (int)isArmorer);
" vendor=", static_cast<int>(isVendor), " repair=", static_cast<int>(isArmorer));
}
if (textLower.find("make this inn your home") != std::string::npos ||
@ -20895,7 +20895,7 @@ void GameHandler::applyPackedKillCountsFromFields(QuestLogEntry& quest) {
if (counts[i] == 0 && quest.killCounts.count(entryKey)) continue;
quest.killCounts[entryKey] = {counts[i], obj.required};
LOG_DEBUG("Quest ", quest.questId, " objective[", i, "]: npcOrGo=",
obj.npcOrGoId, " count=", (int)counts[i], "/", obj.required);
obj.npcOrGoId, " count=", static_cast<int>(counts[i]), "/", obj.required);
}
// Apply item objective counts (only available in WotLK stride+3 positions 4-5).
@ -21450,8 +21450,8 @@ void GameHandler::unequipToBackpack(EquipSlot equipSlot) {
uint8_t dstBag = 0xFF;
uint8_t dstSlot = static_cast<uint8_t>(23 + freeSlot);
LOG_INFO("UnequipToBackpack: equipSlot=", (int)srcSlot,
" -> backpackIndex=", freeSlot, " (dstSlot=", (int)dstSlot, ")");
LOG_INFO("UnequipToBackpack: equipSlot=", static_cast<int>(srcSlot),
" -> backpackIndex=", freeSlot, " (dstSlot=", static_cast<int>(dstSlot), ")");
auto packet = SwapItemPacket::build(dstBag, dstSlot, srcBag, srcSlot);
socket->send(packet);
@ -21459,8 +21459,8 @@ void GameHandler::unequipToBackpack(EquipSlot equipSlot) {
void GameHandler::swapContainerItems(uint8_t srcBag, uint8_t srcSlot, uint8_t dstBag, uint8_t dstSlot) {
if (!socket || !socket->isConnected()) return;
LOG_INFO("swapContainerItems: src(bag=", (int)srcBag, " slot=", (int)srcSlot,
") -> dst(bag=", (int)dstBag, " slot=", (int)dstSlot, ")");
LOG_INFO("swapContainerItems: src(bag=", static_cast<int>(srcBag), " slot=", static_cast<int>(srcSlot),
") -> dst(bag=", static_cast<int>(dstBag), " slot=", static_cast<int>(dstSlot), ")");
auto packet = SwapItemPacket::build(dstBag, dstSlot, srcBag, srcSlot);
socket->send(packet);
}
@ -21485,8 +21485,8 @@ void GameHandler::swapBagSlots(int srcBagIndex, int dstBagIndex) {
if (socket && socket->isConnected()) {
uint8_t srcSlot = static_cast<uint8_t>(19 + srcBagIndex);
uint8_t dstSlot = static_cast<uint8_t>(19 + dstBagIndex);
LOG_INFO("swapBagSlots: bag ", srcBagIndex, " (slot ", (int)srcSlot,
") <-> bag ", dstBagIndex, " (slot ", (int)dstSlot, ")");
LOG_INFO("swapBagSlots: bag ", srcBagIndex, " (slot ", static_cast<int>(srcSlot),
") <-> bag ", dstBagIndex, " (slot ", static_cast<int>(dstSlot), ")");
auto packet = SwapItemPacket::build(255, dstSlot, 255, srcSlot);
socket->send(packet);
}
@ -21503,8 +21503,8 @@ void GameHandler::destroyItem(uint8_t bag, uint8_t slot, uint8_t count) {
packet.writeUInt8(bag);
packet.writeUInt8(slot);
packet.writeUInt32(static_cast<uint32_t>(count));
LOG_DEBUG("Destroy item request: bag=", (int)bag, " slot=", (int)slot,
" count=", (int)count, " wire=0x", std::hex, kCmsgDestroyItem, std::dec);
LOG_DEBUG("Destroy item request: bag=", static_cast<int>(bag), " slot=", static_cast<int>(slot),
" count=", static_cast<int>(count), " wire=0x", std::hex, kCmsgDestroyItem, std::dec);
socket->send(packet);
}
@ -21517,8 +21517,8 @@ void GameHandler::splitItem(uint8_t srcBag, uint8_t srcSlot, uint8_t count) {
if (freeBp >= 0) {
uint8_t dstBag = 0xFF;
uint8_t dstSlot = static_cast<uint8_t>(23 + freeBp);
LOG_INFO("splitItem: src(bag=", (int)srcBag, " slot=", (int)srcSlot,
") count=", (int)count, " -> dst(bag=0xFF slot=", (int)dstSlot, ")");
LOG_INFO("splitItem: src(bag=", static_cast<int>(srcBag), " slot=", static_cast<int>(srcSlot),
") count=", static_cast<int>(count), " -> dst(bag=0xFF slot=", static_cast<int>(dstSlot), ")");
auto packet = SplitItemPacket::build(srcBag, srcSlot, dstBag, dstSlot, count);
socket->send(packet);
return;
@ -21530,9 +21530,9 @@ void GameHandler::splitItem(uint8_t srcBag, uint8_t srcSlot, uint8_t count) {
if (inventory.getBagSlot(b, s).empty()) {
uint8_t dstBag = static_cast<uint8_t>(19 + b);
uint8_t dstSlot = static_cast<uint8_t>(s);
LOG_INFO("splitItem: src(bag=", (int)srcBag, " slot=", (int)srcSlot,
") count=", (int)count, " -> dst(bag=", (int)dstBag,
" slot=", (int)dstSlot, ")");
LOG_INFO("splitItem: src(bag=", static_cast<int>(srcBag), " slot=", static_cast<int>(srcSlot),
") count=", static_cast<int>(count), " -> dst(bag=", static_cast<int>(dstBag),
" slot=", static_cast<int>(dstSlot), ")");
auto packet = SplitItemPacket::build(srcBag, srcSlot, dstBag, dstSlot, count);
socket->send(packet);
return;
@ -21615,7 +21615,7 @@ void GameHandler::useItemInBag(int bagIndex, int slotIndex) {
auto packet = packetParsers_
? packetParsers_->buildUseItem(wowBag, static_cast<uint8_t>(slotIndex), itemGuid, useSpellId)
: UseItemPacket::build(wowBag, static_cast<uint8_t>(slotIndex), itemGuid, useSpellId);
LOG_INFO("useItemInBag: sending CMSG_USE_ITEM, bag=", (int)wowBag, " slot=", slotIndex,
LOG_INFO("useItemInBag: sending CMSG_USE_ITEM, bag=", static_cast<int>(wowBag), " slot=", slotIndex,
" packetSize=", packet.getSize());
socket->send(packet);
} else if (itemGuid == 0) {
@ -21640,7 +21640,7 @@ void GameHandler::openItemInBag(int bagIndex, int slotIndex) {
if (state != WorldState::IN_WORLD || !socket) return;
uint8_t wowBag = static_cast<uint8_t>(19 + bagIndex);
auto packet = OpenItemPacket::build(wowBag, static_cast<uint8_t>(slotIndex));
LOG_INFO("openItemInBag: CMSG_OPEN_ITEM bag=", (int)wowBag, " slot=", slotIndex);
LOG_INFO("openItemInBag: CMSG_OPEN_ITEM bag=", static_cast<int>(wowBag), " slot=", slotIndex);
socket->send(packet);
}
@ -22101,8 +22101,8 @@ void GameHandler::handleTrainerList(network::Packet& packet) {
" 25312=", knownSpells.count(25312u));
for (size_t i = 0; i < std::min(size_t(5), currentTrainerList_.spells.size()); ++i) {
const auto& s = currentTrainerList_.spells[i];
LOG_DEBUG(" Spell[", i, "]: id=", s.spellId, " state=", (int)s.state,
" cost=", s.spellCost, " reqLvl=", (int)s.reqLevel,
LOG_DEBUG(" Spell[", i, "]: id=", s.spellId, " state=", static_cast<int>(s.state),
" cost=", s.spellCost, " reqLvl=", static_cast<int>(s.reqLevel),
" chain=(", s.chainNode1, ",", s.chainNode2, ",", s.chainNode3, ")");
}
@ -22115,7 +22115,7 @@ void GameHandler::handleTrainerList(network::Packet& packet) {
}
void GameHandler::trainSpell(uint32_t spellId) {
LOG_INFO("trainSpell called: spellId=", spellId, " state=", (int)state, " socket=", (socket ? "yes" : "no"));
LOG_INFO("trainSpell called: spellId=", spellId, " state=", static_cast<int>(state), " socket=", (socket ? "yes" : "no"));
if (state != WorldState::IN_WORLD || !socket) {
LOG_WARNING("trainSpell: Not in world or no socket connection");
return;
@ -23780,7 +23780,7 @@ void GameHandler::handleFriendList(network::Packet& packet) {
auto rem = [&]() { return packet.getSize() - packet.getReadPos(); };
if (rem() < 1) return;
uint8_t count = packet.readUInt8();
LOG_INFO("SMSG_FRIEND_LIST: ", (int)count, " entries");
LOG_INFO("SMSG_FRIEND_LIST: ", static_cast<int>(count), " entries");
// Rebuild friend contacts (keep ignores from previous contact_ entries)
contacts_.erase(std::remove_if(contacts_.begin(), contacts_.end(),
@ -23802,10 +23802,10 @@ void GameHandler::handleFriendList(network::Packet& packet) {
if (nit != playerNameCache.end()) {
name = nit->second;
friendsCache[name] = guid;
LOG_INFO(" Friend: ", name, " status=", (int)status);
LOG_INFO(" Friend: ", name, " status=", static_cast<int>(status));
} else {
LOG_INFO(" Friend guid=0x", std::hex, guid, std::dec,
" status=", (int)status, " (name pending)");
" status=", static_cast<int>(status), " (name pending)");
queryPlayerName(guid);
}
ContactEntry entry;
@ -23965,11 +23965,11 @@ void GameHandler::handleFriendStatus(network::Packet& packet) {
addSystemChatMessage(playerName + " is ignoring you.");
break;
default:
LOG_INFO("Friend status: ", (int)data.status, " for ", playerName);
LOG_INFO("Friend status: ", static_cast<int>(data.status), " for ", playerName);
break;
}
LOG_INFO("Friend status update: ", playerName, " status=", (int)data.status);
LOG_INFO("Friend status update: ", playerName, " status=", static_cast<int>(data.status));
fireAddonEvent("FRIENDLIST_UPDATE", {});
}
@ -24023,7 +24023,7 @@ void GameHandler::handleLogoutResponse(network::Packet& packet) {
addSystemChatMessage("Logging out in 20 seconds...");
logoutCountdown_ = 20.0f;
}
LOG_INFO("Logout response: success, instant=", (int)data.instant);
LOG_INFO("Logout response: success, instant=", static_cast<int>(data.instant));
fireAddonEvent("PLAYER_LOGOUT", {});
} else {
// Failure
@ -24052,7 +24052,7 @@ uint32_t GameHandler::generateClientSeed() {
void GameHandler::setState(WorldState newState) {
if (state != newState) {
LOG_DEBUG("World state: ", (int)state, " -> ", (int)newState);
LOG_DEBUG("World state: ", static_cast<int>(state), " -> ", static_cast<int>(newState));
state = newState;
}
}
@ -25007,7 +25007,7 @@ void GameHandler::handleGuildBankList(network::Packet& packet) {
if (item.itemEntry != 0) ensureItemInfo(item.itemEntry);
}
LOG_INFO("SMSG_GUILD_BANK_LIST: tab=", (int)data.tabId,
LOG_INFO("SMSG_GUILD_BANK_LIST: tab=", static_cast<int>(data.tabId),
" items=", data.tabItems.size(),
" tabs=", data.tabs.size(),
" money=", data.money);
@ -25114,7 +25114,7 @@ void GameHandler::handleAuctionHello(network::Packet& packet) {
auctionOwnerResults_ = AuctionListResult{};
auctionBidderResults_ = AuctionListResult{};
LOG_INFO("MSG_AUCTION_HELLO: auctioneer=0x", std::hex, data.auctioneerGuid, std::dec,
" house=", data.auctionHouseId, " enabled=", (int)data.enabled);
" house=", data.auctionHouseId, " enabled=", static_cast<int>(data.enabled));
}
void GameHandler::handleAuctionListResult(network::Packet& packet) {
@ -25216,7 +25216,7 @@ void GameHandler::handleItemTextQueryResponse(network::Packet& packet) {
itemText_ = packet.readString();
itemTextOpen_= !itemText_.empty();
}
LOG_DEBUG("SMSG_ITEM_TEXT_QUERY_RESPONSE: isEmpty=", (int)isEmpty,
LOG_DEBUG("SMSG_ITEM_TEXT_QUERY_RESPONSE: isEmpty=", static_cast<int>(isEmpty),
" len=", itemText_.size());
}
@ -25547,7 +25547,7 @@ void GameHandler::handleTradeStatusExtended(network::Packet& packet) {
if (s.occupied && s.itemId != 0) queryItemInfo(s.itemId, 0);
}
LOG_DEBUG("SMSG_TRADE_STATUS_EXTENDED: isSelf=", (int)isSelf,
LOG_DEBUG("SMSG_TRADE_STATUS_EXTENDED: isSelf=", static_cast<int>(isSelf),
" myGold=", myTradeGold_, " peerGold=", peerTradeGold_);
}

View file

@ -196,7 +196,7 @@ bool ClassicPacketParsers::parseMovementBlock(network::Packet& packet, UpdateBlo
uint8_t updateFlags = packet.readUInt8();
block.updateFlags = static_cast<uint16_t>(updateFlags);
LOG_DEBUG(" [Classic] UpdateFlags: 0x", std::hex, (int)updateFlags, std::dec);
LOG_DEBUG(" [Classic] UpdateFlags: 0x", std::hex, static_cast<int>(updateFlags), std::dec);
const uint8_t UPDATEFLAG_TRANSPORT = 0x02;
const uint8_t UPDATEFLAG_MELEE_ATTACKING = 0x04;
@ -613,13 +613,13 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
}
const uint8_t rawHitCount = packet.readUInt8();
if (rawHitCount > 128) {
LOG_WARNING("[Classic] Spell go: hitCount capped (requested=", (int)rawHitCount, ")");
LOG_WARNING("[Classic] Spell go: hitCount capped (requested=", static_cast<int>(rawHitCount), ")");
}
if (rem() < static_cast<size_t>(rawHitCount) + 1u) {
static uint32_t badHitCountTrunc = 0;
++badHitCountTrunc;
if (badHitCountTrunc <= 10 || (badHitCountTrunc % 100) == 0) {
LOG_WARNING("[Classic] Spell go: invalid hitCount/remaining (hits=", (int)rawHitCount,
LOG_WARNING("[Classic] Spell go: invalid hitCount/remaining (hits=", static_cast<int>(rawHitCount),
" remaining=", rem(), " occurrence=", badHitCountTrunc, ")");
}
traceFailure("invalid_hit_count", packet.getReadPos(), rawHitCount);
@ -654,7 +654,7 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
};
if (!parseHitList(false) && !parseHitList(true)) {
LOG_WARNING("[Classic] Spell go: truncated hit targets at index 0/", (int)rawHitCount);
LOG_WARNING("[Classic] Spell go: truncated hit targets at index 0/", static_cast<int>(rawHitCount));
traceFailure("truncated_hit_target", packet.getReadPos(), rawHitCount);
packet.setReadPos(startPos);
return false;
@ -673,7 +673,7 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
}
const uint8_t rawMissCount = packet.readUInt8();
if (rawMissCount > 128) {
LOG_WARNING("[Classic] Spell go: missCount capped (requested=", (int)rawMissCount, ")");
LOG_WARNING("[Classic] Spell go: missCount capped (requested=", static_cast<int>(rawMissCount), ")");
traceFailure("miss_count_capped", packet.getReadPos() - 1, rawMissCount);
}
if (rem() < static_cast<size_t>(rawMissCount) * 2u) {
@ -695,7 +695,7 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
static uint32_t badMissCountTrunc = 0;
++badMissCountTrunc;
if (badMissCountTrunc <= 10 || (badMissCountTrunc % 100) == 0) {
LOG_WARNING("[Classic] Spell go: invalid missCount/remaining (misses=", (int)rawMissCount,
LOG_WARNING("[Classic] Spell go: invalid missCount/remaining (misses=", static_cast<int>(rawMissCount),
" remaining=", rem(), " occurrence=", badMissCountTrunc, ")");
}
traceFailure("invalid_miss_count", packet.getReadPos(), rawMissCount);
@ -727,7 +727,7 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
packet.setReadPos(missEntryPos);
if (!parseMissEntry(m, true)) {
LOG_WARNING("[Classic] Spell go: truncated miss targets at index ", i,
"/", (int)rawMissCount);
"/", static_cast<int>(rawMissCount));
traceFailure("truncated_miss_target", packet.getReadPos(), i);
truncatedMissTargets = true;
break;
@ -735,7 +735,7 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
}
if (rem() < 1) {
LOG_WARNING("[Classic] Spell go: missing missType at miss index ", i,
"/", (int)rawMissCount);
"/", static_cast<int>(rawMissCount));
traceFailure("missing_miss_type", packet.getReadPos(), i);
truncatedMissTargets = true;
break;
@ -744,7 +744,7 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
if (m.missType == 11) {
if (rem() < 1) {
LOG_WARNING("[Classic] Spell go: truncated reflect payload at miss index ", i,
"/", (int)rawMissCount);
"/", static_cast<int>(rawMissCount));
traceFailure("truncated_reflect", packet.getReadPos(), i);
truncatedMissTargets = true;
break;
@ -774,8 +774,8 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
// any subsequent fields (e.g. castFlags extras) are not misaligned.
skipClassicSpellCastTargets(packet, &data.targetGuid);
LOG_DEBUG("[Classic] Spell go: spell=", data.spellId, " hits=", (int)data.hitCount,
" misses=", (int)data.missCount);
LOG_DEBUG("[Classic] Spell go: spell=", data.spellId, " hits=", static_cast<int>(data.hitCount),
" misses=", static_cast<int>(data.missCount));
return true;
}
@ -1011,8 +1011,8 @@ bool ClassicPacketParsers::parseNameQueryResponse(network::Packet& packet, NameQ
data.found = 0;
LOG_DEBUG("[Classic] Name query response: ", data.name,
" (race=", (int)data.race, " gender=", (int)data.gender,
" class=", (int)data.classId, ")");
" (race=", static_cast<int>(data.race), " gender=", static_cast<int>(data.gender),
" class=", static_cast<int>(data.classId), ")");
return !data.name.empty();
}
@ -1028,7 +1028,7 @@ bool ClassicPacketParsers::parseCastFailed(network::Packet& packet, CastFailedDa
// WotLK enum starts at 0=SUCCESS, 1=AFFECTING_COMBAT.
// Shift +1 to align with WotLK result strings.
data.result = vanillaResult + 1;
LOG_DEBUG("[Classic] Cast failed: spell=", data.spellId, " vanillaResult=", (int)vanillaResult);
LOG_DEBUG("[Classic] Cast failed: spell=", data.spellId, " vanillaResult=", static_cast<int>(vanillaResult));
return true;
}
@ -1044,7 +1044,7 @@ bool ClassicPacketParsers::parseCastResult(network::Packet& packet, uint32_t& sp
uint8_t vanillaResult = packet.readUInt8();
// Shift +1: Vanilla result 0=AFFECTING_COMBAT maps to WotLK result 1=AFFECTING_COMBAT
result = vanillaResult + 1;
LOG_DEBUG("[Classic] Cast result: spell=", spellId, " vanillaResult=", (int)vanillaResult);
LOG_DEBUG("[Classic] Cast result: spell=", spellId, " vanillaResult=", static_cast<int>(vanillaResult));
return true;
}
@ -1068,12 +1068,12 @@ bool ClassicPacketParsers::parseCharEnum(network::Packet& packet, CharEnumRespon
// Cap count to prevent excessive memory allocation
constexpr uint8_t kMaxCharacters = 32;
if (count > kMaxCharacters) {
LOG_WARNING("[Classic] Character count ", (int)count, " exceeds max ", (int)kMaxCharacters,
LOG_WARNING("[Classic] Character count ", static_cast<int>(count), " exceeds max ", static_cast<int>(kMaxCharacters),
", capping");
count = kMaxCharacters;
}
LOG_INFO("[Classic] Parsing SMSG_CHAR_ENUM: ", (int)count, " characters");
LOG_INFO("[Classic] Parsing SMSG_CHAR_ENUM: ", static_cast<int>(count), " characters");
response.characters.clear();
response.characters.reserve(count);
@ -1085,7 +1085,7 @@ bool ClassicPacketParsers::parseCharEnum(network::Packet& packet, CharEnumRespon
// + flags(4) + firstLogin(1) + pet(12) + equipment(20*5)
constexpr size_t kMinCharacterSize = 8 + 1 + 1 + 1 + 1 + 4 + 1 + 1 + 4 + 4 + 12 + 4 + 4 + 1 + 12 + 100;
if (packet.getReadPos() + kMinCharacterSize > packet.getSize()) {
LOG_WARNING("[Classic] Character enum packet truncated at character ", (int)(i + 1),
LOG_WARNING("[Classic] Character enum packet truncated at character ", static_cast<int>(i + 1),
", pos=", packet.getReadPos(), " needed=", kMinCharacterSize,
" size=", packet.getSize());
break;
@ -1142,9 +1142,9 @@ bool ClassicPacketParsers::parseCharEnum(network::Packet& packet, CharEnumRespon
character.equipment.push_back(item);
}
LOG_DEBUG(" Character ", (int)(i + 1), ": ", character.name,
LOG_DEBUG(" Character ", static_cast<int>(i + 1), ": ", character.name,
" (", getRaceName(character.race), " ", getClassName(character.characterClass),
" level ", (int)character.level, " zone ", character.zoneId, ")");
" level ", static_cast<int>(character.level), " zone ", character.zoneId, ")");
response.characters.push_back(character);
}
@ -1563,7 +1563,7 @@ bool ClassicPacketParsers::parseMailList(network::Packet& packet,
if (remaining < 1) return false;
uint8_t count = packet.readUInt8();
LOG_INFO("SMSG_MAIL_LIST_RESULT (Classic): count=", (int)count);
LOG_INFO("SMSG_MAIL_LIST_RESULT (Classic): count=", static_cast<int>(count));
inbox.clear();
inbox.reserve(count);
@ -1932,7 +1932,7 @@ bool TurtlePacketParsers::parseMovementBlock(network::Packet& packet, UpdateBloc
uint8_t updateFlags = packet.readUInt8();
block.updateFlags = static_cast<uint16_t>(updateFlags);
LOG_DEBUG(" [Turtle] UpdateFlags: 0x", std::hex, (int)updateFlags, std::dec);
LOG_DEBUG(" [Turtle] UpdateFlags: 0x", std::hex, static_cast<int>(updateFlags), std::dec);
const uint8_t UPDATEFLAG_TRANSPORT = 0x02;
const uint8_t UPDATEFLAG_MELEE_ATTACKING = 0x04;

View file

@ -37,7 +37,7 @@ bool TbcPacketParsers::parseMovementBlock(network::Packet& packet, UpdateBlock&
uint8_t updateFlags = packet.readUInt8();
block.updateFlags = static_cast<uint16_t>(updateFlags);
LOG_DEBUG(" [TBC] UpdateFlags: 0x", std::hex, (int)updateFlags, std::dec);
LOG_DEBUG(" [TBC] UpdateFlags: 0x", std::hex, static_cast<int>(updateFlags), std::dec);
// TBC UpdateFlag bit values (same as lower byte of WotLK):
// 0x01 = SELF
@ -317,12 +317,12 @@ bool TbcPacketParsers::parseCharEnum(network::Packet& packet, CharEnumResponse&
// Cap count to prevent excessive memory allocation
constexpr uint8_t kMaxCharacters = 32;
if (count > kMaxCharacters) {
LOG_WARNING("[TBC] Character count ", (int)count, " exceeds max ", (int)kMaxCharacters,
LOG_WARNING("[TBC] Character count ", static_cast<int>(count), " exceeds max ", static_cast<int>(kMaxCharacters),
", capping");
count = kMaxCharacters;
}
LOG_INFO("[TBC] Parsing SMSG_CHAR_ENUM: ", (int)count, " characters");
LOG_INFO("[TBC] Parsing SMSG_CHAR_ENUM: ", static_cast<int>(count), " characters");
response.characters.clear();
response.characters.reserve(count);
@ -334,7 +334,7 @@ bool TbcPacketParsers::parseCharEnum(network::Packet& packet, CharEnumResponse&
// + flags(4) + firstLogin(1) + pet(12) + equipment(20*9)
constexpr size_t kMinCharacterSize = 8 + 1 + 1 + 1 + 1 + 4 + 1 + 1 + 4 + 4 + 12 + 4 + 4 + 1 + 12 + 180;
if (packet.getReadPos() + kMinCharacterSize > packet.getSize()) {
LOG_WARNING("[TBC] Character enum packet truncated at character ", (int)(i + 1),
LOG_WARNING("[TBC] Character enum packet truncated at character ", static_cast<int>(i + 1),
", pos=", packet.getReadPos(), " needed=", kMinCharacterSize,
" size=", packet.getSize());
break;
@ -391,9 +391,9 @@ bool TbcPacketParsers::parseCharEnum(network::Packet& packet, CharEnumResponse&
character.equipment.push_back(item);
}
LOG_DEBUG(" Character ", (int)(i + 1), ": ", character.name,
LOG_DEBUG(" Character ", static_cast<int>(i + 1), ": ", character.name,
" (", getRaceName(character.race), " ", getClassName(character.characterClass),
" level ", (int)character.level, " zone ", character.zoneId, ")");
" level ", static_cast<int>(character.level), " zone ", character.zoneId, ")");
response.characters.push_back(character);
}
@ -710,7 +710,7 @@ bool TbcPacketParsers::parseMonsterMove(network::Packet& packet, MonsterMoveData
}
LOG_DEBUG("[TBC] MonsterMove: guid=0x", std::hex, data.guid, std::dec,
" type=", (int)data.moveType, " dur=", data.duration, "ms",
" type=", static_cast<int>(data.moveType), " dur=", data.duration, "ms",
" dest=(", data.destX, ",", data.destY, ",", data.destZ, ")");
return true;
}
@ -1162,7 +1162,7 @@ bool TbcPacketParsers::parseMailList(network::Packet& packet, std::vector<MailMe
if (remaining < 1) return false;
uint8_t count = packet.readUInt8();
LOG_INFO("SMSG_MAIL_LIST_RESULT (TBC): count=", (int)count);
LOG_INFO("SMSG_MAIL_LIST_RESULT (TBC): count=", static_cast<int>(count));
inbox.clear();
inbox.reserve(count);
@ -1361,7 +1361,7 @@ bool TbcPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& data)
const uint8_t rawHitCount = packet.readUInt8();
if (rawHitCount > 128) {
LOG_WARNING("[TBC] Spell go: hitCount capped (requested=", (int)rawHitCount, ")");
LOG_WARNING("[TBC] Spell go: hitCount capped (requested=", static_cast<int>(rawHitCount), ")");
}
const uint8_t storedHitLimit = std::min<uint8_t>(rawHitCount, 128);
data.hitTargets.reserve(storedHitLimit);
@ -1369,7 +1369,7 @@ bool TbcPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& data)
for (uint16_t i = 0; i < rawHitCount; ++i) {
if (packet.getReadPos() + 8 > packet.getSize()) {
LOG_WARNING("[TBC] Spell go: truncated hit targets at index ", i,
"/", (int)rawHitCount);
"/", static_cast<int>(rawHitCount));
truncatedTargets = true;
break;
}
@ -1392,14 +1392,14 @@ bool TbcPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& data)
const uint8_t rawMissCount = packet.readUInt8();
if (rawMissCount > 128) {
LOG_WARNING("[TBC] Spell go: missCount capped (requested=", (int)rawMissCount, ")");
LOG_WARNING("[TBC] Spell go: missCount capped (requested=", static_cast<int>(rawMissCount), ")");
}
const uint8_t storedMissLimit = std::min<uint8_t>(rawMissCount, 128);
data.missTargets.reserve(storedMissLimit);
for (uint16_t i = 0; i < rawMissCount; ++i) {
if (packet.getReadPos() + 9 > packet.getSize()) {
LOG_WARNING("[TBC] Spell go: truncated miss targets at index ", i,
"/", (int)rawMissCount);
"/", static_cast<int>(rawMissCount));
truncatedTargets = true;
break;
}
@ -1409,7 +1409,7 @@ bool TbcPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& data)
if (m.missType == 11) { // SPELL_MISS_REFLECT
if (packet.getReadPos() + 1 > packet.getSize()) {
LOG_WARNING("[TBC] Spell go: truncated reflect payload at miss index ", i,
"/", (int)rawMissCount);
"/", static_cast<int>(rawMissCount));
truncatedTargets = true;
break;
}
@ -1429,8 +1429,8 @@ bool TbcPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& data)
// any subsequent fields are not misaligned for ground-targeted AoE spells.
skipTbcSpellCastTargets(packet, &data.targetGuid);
LOG_DEBUG("[TBC] Spell go: spell=", data.spellId, " hits=", (int)data.hitCount,
" misses=", (int)data.missCount);
LOG_DEBUG("[TBC] Spell go: spell=", data.spellId, " hits=", static_cast<int>(data.hitCount),
" misses=", static_cast<int>(data.missCount));
return true;
}
@ -1463,7 +1463,7 @@ bool TbcPacketParsers::parseCastFailed(network::Packet& packet, CastFailedData&
data.castCount = 0; // not present in TBC
data.spellId = packet.readUInt32();
data.result = packet.readUInt8(); // same enum as WotLK
LOG_DEBUG("[TBC] Cast failed: spell=", data.spellId, " result=", (int)data.result);
LOG_DEBUG("[TBC] Cast failed: spell=", data.spellId, " result=", static_cast<int>(data.result));
return true;
}

View file

@ -403,7 +403,7 @@ glm::vec3 TransportManager::evalTimedCatmullRom(const TransportPath& path, uint3
uint32_t t1Ms = path.points[p1Idx].tMs;
uint32_t t2Ms = path.points[p2Idx].tMs;
uint32_t segmentDurationMs = (t2Ms > t1Ms) ? (t2Ms - t1Ms) : 1;
float t = (float)(pathTimeMs - t1Ms) / (float)segmentDurationMs;
float t = (float)(pathTimeMs - t1Ms) / static_cast<float>(segmentDurationMs);
t = glm::clamp(t, 0.0f, 1.0f);
// Catmull-Rom spline formula
@ -480,7 +480,7 @@ glm::quat TransportManager::orientationFromTangent(const TransportPath& path, ui
uint32_t t1Ms = path.points[p1Idx].tMs;
uint32_t t2Ms = path.points[p2Idx].tMs;
uint32_t segmentDurationMs = (t2Ms > t1Ms) ? (t2Ms - t1Ms) : 1;
float t = (float)(pathTimeMs - t1Ms) / (float)segmentDurationMs;
float t = (float)(pathTimeMs - t1Ms) / static_cast<float>(segmentDurationMs);
t = glm::clamp(t, 0.0f, 1.0f);
// Tangent of Catmull-Rom spline (derivative)

View file

@ -460,7 +460,7 @@ bool CharEnumParser::parse(network::Packet& packet, CharEnumResponse& response)
// Read character count
uint8_t count = packet.readUInt8();
LOG_INFO("Parsing SMSG_CHAR_ENUM: ", (int)count, " characters");
LOG_INFO("Parsing SMSG_CHAR_ENUM: ", static_cast<int>(count), " characters");
response.characters.clear();
response.characters.reserve(count);
@ -475,7 +475,7 @@ bool CharEnumParser::parse(network::Packet& packet, CharEnumResponse& response)
// petDisplayModel(4) + petLevel(4) + petFamily(4) + 23items*(dispModel(4)+invType(1)+enchant(4)) = 207 bytes
const size_t minCharacterSize = 8 + 1 + 1 + 1 + 1 + 4 + 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4 + (23 * 9);
if (packet.getReadPos() + minCharacterSize > packet.getSize()) {
LOG_WARNING("CharEnumParser: truncated character at index ", (int)i);
LOG_WARNING("CharEnumParser: truncated character at index ", static_cast<int>(i));
break;
}
@ -484,14 +484,14 @@ bool CharEnumParser::parse(network::Packet& packet, CharEnumResponse& response)
// Read name (null-terminated string) - validate before reading
if (packet.getReadPos() >= packet.getSize()) {
LOG_WARNING("CharEnumParser: no bytes for name at index ", (int)i);
LOG_WARNING("CharEnumParser: no bytes for name at index ", static_cast<int>(i));
break;
}
character.name = packet.readString();
// Validate remaining bytes before reading fixed-size fields
if (packet.getReadPos() + 1 > packet.getSize()) {
LOG_WARNING("CharEnumParser: truncated before race/class/gender at index ", (int)i);
LOG_WARNING("CharEnumParser: truncated before race/class/gender at index ", static_cast<int>(i));
character.race = Race::HUMAN;
character.characterClass = Class::WARRIOR;
character.gender = Gender::MALE;
@ -595,9 +595,9 @@ bool CharEnumParser::parse(network::Packet& packet, CharEnumResponse& response)
character.equipment.push_back(item);
}
LOG_DEBUG(" Character ", (int)(i + 1), ": ", character.name,
LOG_DEBUG(" Character ", static_cast<int>(i + 1), ": ", character.name,
" (", getRaceName(character.race), " ", getClassName(character.characterClass),
" level ", (int)character.level, " zone ", character.zoneId, ")");
" level ", static_cast<int>(character.level), " zone ", character.zoneId, ")");
response.characters.push_back(character);
}
@ -672,7 +672,7 @@ bool AccountDataTimesParser::parse(network::Packet& packet, AccountDataTimesData
LOG_DEBUG("Parsed SMSG_ACCOUNT_DATA_TIMES:");
LOG_DEBUG(" Server time: ", data.serverTime);
LOG_DEBUG(" Unknown: ", (int)data.unknown);
LOG_DEBUG(" Unknown: ", static_cast<int>(data.unknown));
LOG_DEBUG(" Mask: 0x", std::hex, mask, std::dec, " slotsInPacket=", slotWords);
for (size_t i = 0; i < slotWords; ++i) {
@ -1255,8 +1255,8 @@ bool UpdateObjectParser::parseUpdateFields(network::Packet& packet, UpdateBlock&
? ((block.objectType == ObjectType::PLAYER) ? 55 : 10)
: 55; // VALUES: allow PLAYER-sized masks
if (blockCount > maxExpectedBlocks) {
LOG_WARNING("UpdateObjectParser: suspicious maskBlockCount=", (int)blockCount,
" for objectType=", (int)block.objectType,
LOG_WARNING("UpdateObjectParser: suspicious maskBlockCount=", static_cast<int>(blockCount),
" for objectType=", static_cast<int>(block.objectType),
" guid=0x", std::hex, block.guid, std::dec,
" updateFlags=0x", std::hex, block.updateFlags, std::dec,
" moveFlags=0x", std::hex, block.moveFlags, std::dec,
@ -1265,7 +1265,7 @@ bool UpdateObjectParser::parseUpdateFields(network::Packet& packet, UpdateBlock&
uint32_t fieldsCapacity = blockCount * 32;
LOG_DEBUG(" UPDATE MASK PARSE:");
LOG_DEBUG(" maskBlockCount = ", (int)blockCount);
LOG_DEBUG(" maskBlockCount = ", static_cast<int>(blockCount));
LOG_DEBUG(" fieldsCapacity (blocks * 32) = ", fieldsCapacity);
// Read update mask into a reused scratch buffer to avoid per-block allocations.
@ -1349,7 +1349,7 @@ bool UpdateObjectParser::parseUpdateBlock(network::Packet& packet, UpdateBlock&
uint8_t updateTypeVal = packet.readUInt8();
block.updateType = static_cast<UpdateType>(updateTypeVal);
LOG_DEBUG("Update block: type=", (int)updateTypeVal);
LOG_DEBUG("Update block: type=", static_cast<int>(updateTypeVal));
switch (block.updateType) {
case UpdateType::VALUES: {
@ -1381,7 +1381,7 @@ bool UpdateObjectParser::parseUpdateBlock(network::Packet& packet, UpdateBlock&
if (packet.getReadPos() >= packet.getSize()) return false;
uint8_t objectTypeVal = packet.readUInt8();
block.objectType = static_cast<ObjectType>(objectTypeVal);
LOG_DEBUG(" Object type: ", (int)objectTypeVal);
LOG_DEBUG(" Object type: ", static_cast<int>(objectTypeVal));
// Parse movement if present
bool hasMovement = parseMovementBlock(packet, block);
@ -1406,7 +1406,7 @@ bool UpdateObjectParser::parseUpdateBlock(network::Packet& packet, UpdateBlock&
}
default:
LOG_WARNING("Unknown update type: ", (int)updateTypeVal);
LOG_WARNING("Unknown update type: ", static_cast<int>(updateTypeVal));
return false;
}
}
@ -1737,7 +1737,7 @@ bool MessageChatParser::parse(network::Packet& packet, MessageChatData& data) {
LOG_DEBUG(" Channel: ", data.channelName);
}
LOG_DEBUG(" Message: ", data.message);
LOG_DEBUG(" Chat tag: 0x", std::hex, (int)data.chatTag, std::dec);
LOG_DEBUG(" Chat tag: 0x", std::hex, static_cast<int>(data.chatTag), std::dec);
return true;
}
@ -2004,7 +2004,7 @@ bool FriendStatusParser::parse(network::Packet& packet, FriendStatusData& data)
}
}
}
LOG_DEBUG("Parsed SMSG_FRIEND_STATUS: status=", (int)data.status, " guid=0x", std::hex, data.guid, std::dec);
LOG_DEBUG("Parsed SMSG_FRIEND_STATUS: status=", static_cast<int>(data.status), " guid=0x", std::hex, data.guid, std::dec);
return true;
}
@ -2047,7 +2047,7 @@ bool LogoutResponseParser::parse(network::Packet& packet, LogoutResponseData& da
data.result = packet.readUInt32();
data.instant = packet.readUInt8();
LOG_DEBUG("Parsed SMSG_LOGOUT_RESPONSE: result=", data.result, " instant=", (int)data.instant);
LOG_DEBUG("Parsed SMSG_LOGOUT_RESPONSE: result=", data.result, " instant=", static_cast<int>(data.instant));
return true;
}
@ -2058,7 +2058,7 @@ bool LogoutResponseParser::parse(network::Packet& packet, LogoutResponseData& da
network::Packet StandStateChangePacket::build(uint8_t state) {
network::Packet packet(wireOpcode(Opcode::CMSG_STANDSTATECHANGE));
packet.writeUInt32(state);
LOG_DEBUG("Built CMSG_STANDSTATECHANGE: state=", (int)state);
LOG_DEBUG("Built CMSG_STANDSTATECHANGE: state=", static_cast<int>(state));
return packet;
}
@ -2083,8 +2083,8 @@ network::Packet SetActionButtonPacket::build(uint8_t button, uint8_t type, uint3
packet.writeUInt16(static_cast<uint16_t>(id));
packet.writeUInt8(classicType);
packet.writeUInt8(0); // misc
LOG_DEBUG("Built CMSG_SET_ACTION_BUTTON (Classic): button=", (int)button,
" id=", id, " type=", (int)classicType);
LOG_DEBUG("Built CMSG_SET_ACTION_BUTTON (Classic): button=", static_cast<int>(button),
" id=", id, " type=", static_cast<int>(classicType));
} else {
// TBC/WotLK: type in bits 2431, id in bits 023; packed=0 clears slot
uint8_t packedType = 0x00; // spell
@ -2092,7 +2092,7 @@ network::Packet SetActionButtonPacket::build(uint8_t button, uint8_t type, uint3
if (type == 3 /* MACRO */) packedType = 0x40;
uint32_t packed = (id == 0) ? 0 : (static_cast<uint32_t>(packedType) << 24) | (id & 0x00FFFFFF);
packet.writeUInt32(packed);
LOG_DEBUG("Built CMSG_SET_ACTION_BUTTON (TBC/WotLK): button=", (int)button,
LOG_DEBUG("Built CMSG_SET_ACTION_BUTTON (TBC/WotLK): button=", static_cast<int>(button),
" packed=0x", std::hex, packed, std::dec);
}
return packet;
@ -2510,7 +2510,7 @@ bool GuildEventParser::parse(network::Packet& packet, GuildEventData& data) {
if ((packet.getSize() - packet.getReadPos()) >= 8) {
data.guid = packet.readUInt64();
}
LOG_INFO("Parsed SMSG_GUILD_EVENT: type=", (int)data.eventType, " strings=", (int)data.numStrings);
LOG_INFO("Parsed SMSG_GUILD_EVENT: type=", static_cast<int>(data.eventType), " strings=", static_cast<int>(data.numStrings));
return true;
}
@ -2591,7 +2591,7 @@ network::Packet RaidTargetUpdatePacket::build(uint8_t targetIndex, uint64_t targ
network::Packet packet(wireOpcode(Opcode::MSG_RAID_TARGET_UPDATE));
packet.writeUInt8(targetIndex);
packet.writeUInt64(targetGuid);
LOG_DEBUG("Built MSG_RAID_TARGET_UPDATE, index: ", (uint32_t)targetIndex, ", guid: 0x", std::hex, targetGuid, std::dec);
LOG_DEBUG("Built MSG_RAID_TARGET_UPDATE, index: ", static_cast<uint32_t>(targetIndex), ", guid: 0x", std::hex, targetGuid, std::dec);
return packet;
}
@ -2636,14 +2636,14 @@ network::Packet SetTradeItemPacket::build(uint8_t tradeSlot, uint8_t bag, uint8_
packet.writeUInt8(tradeSlot);
packet.writeUInt8(bag);
packet.writeUInt8(bagSlot);
LOG_DEBUG("Built CMSG_SET_TRADE_ITEM slot=", (int)tradeSlot, " bag=", (int)bag, " bagSlot=", (int)bagSlot);
LOG_DEBUG("Built CMSG_SET_TRADE_ITEM slot=", static_cast<int>(tradeSlot), " bag=", static_cast<int>(bag), " bagSlot=", static_cast<int>(bagSlot));
return packet;
}
network::Packet ClearTradeItemPacket::build(uint8_t tradeSlot) {
network::Packet packet(wireOpcode(Opcode::CMSG_CLEAR_TRADE_ITEM));
packet.writeUInt8(tradeSlot);
LOG_DEBUG("Built CMSG_CLEAR_TRADE_ITEM slot=", (int)tradeSlot);
LOG_DEBUG("Built CMSG_CLEAR_TRADE_ITEM slot=", static_cast<int>(tradeSlot));
return packet;
}
@ -2768,8 +2768,8 @@ bool NameQueryResponseParser::parse(network::Packet& packet, NameQueryResponseDa
data.gender = packet.readUInt8();
data.classId = packet.readUInt8();
LOG_DEBUG("Name query response: ", data.name, " (race=", (int)data.race,
" class=", (int)data.classId, ")");
LOG_DEBUG("Name query response: ", data.name, " (race=", static_cast<int>(data.race),
" class=", static_cast<int>(data.classId), ")");
return true;
}
@ -3284,7 +3284,7 @@ bool MonsterMoveParser::parse(network::Packet& packet, MonsterMoveData& data) {
}
LOG_DEBUG("MonsterMove: guid=0x", std::hex, data.guid, std::dec,
" type=", (int)data.moveType, " dur=", data.duration, "ms",
" type=", static_cast<int>(data.moveType), " dur=", data.duration, "ms",
" dest=(", data.destX, ",", data.destY, ",", data.destZ, ")");
return true;
@ -3387,7 +3387,7 @@ bool MonsterMoveParser::parseVanilla(network::Packet& packet, MonsterMoveData& d
}
LOG_DEBUG("MonsterMove(turtle): guid=0x", std::hex, data.guid, std::dec,
" type=", (int)data.moveType, " dur=", data.duration, "ms",
" type=", static_cast<int>(data.moveType), " dur=", data.duration, "ms",
" dest=(", data.destX, ",", data.destY, ",", data.destZ, ")");
return true;
@ -3785,7 +3785,7 @@ bool CastFailedParser::parse(network::Packet& packet, CastFailedData& data) {
data.castCount = packet.readUInt8();
data.spellId = packet.readUInt32();
data.result = packet.readUInt8();
LOG_INFO("Cast failed: spell=", data.spellId, " result=", (int)data.result);
LOG_INFO("Cast failed: spell=", data.spellId, " result=", static_cast<int>(data.result));
return true;
}
@ -3902,7 +3902,7 @@ bool SpellGoParser::parse(network::Packet& packet, SpellGoData& data) {
const uint8_t rawHitCount = packet.readUInt8();
if (rawHitCount > 128) {
LOG_WARNING("Spell go: hitCount capped (requested=", (int)rawHitCount, ")");
LOG_WARNING("Spell go: hitCount capped (requested=", static_cast<int>(rawHitCount), ")");
}
const uint8_t storedHitLimit = std::min<uint8_t>(rawHitCount, 128);
@ -3912,7 +3912,7 @@ bool SpellGoParser::parse(network::Packet& packet, SpellGoData& data) {
for (uint16_t i = 0; i < rawHitCount; ++i) {
// WotLK 3.3.5a hit targets are full uint64 GUIDs (not PackedGuid).
if (packet.getSize() - packet.getReadPos() < 8) {
LOG_WARNING("Spell go: truncated hit targets at index ", i, "/", (int)rawHitCount);
LOG_WARNING("Spell go: truncated hit targets at index ", i, "/", static_cast<int>(rawHitCount));
truncatedTargets = true;
break;
}
@ -3949,15 +3949,15 @@ bool SpellGoParser::parse(network::Packet& packet, SpellGoData& data) {
if (i == missCountPos - 1) hexCtx += "[";
if (i == missCountPos) hexCtx += "] ";
}
LOG_WARNING("Spell go: suspect missCount=", (int)rawMissCount,
" spell=", data.spellId, " hits=", (int)data.hitCount,
LOG_WARNING("Spell go: suspect missCount=", static_cast<int>(rawMissCount),
" spell=", data.spellId, " hits=", static_cast<int>(data.hitCount),
" castFlags=0x", std::hex, data.castFlags, std::dec,
" missCountPos=", missCountPos, " pktSize=", packet.getSize(),
" ctx=", hexCtx);
}
if (rawMissCount > 128) {
LOG_WARNING("Spell go: missCount capped (requested=", (int)rawMissCount,
") spell=", data.spellId, " hits=", (int)data.hitCount,
LOG_WARNING("Spell go: missCount capped (requested=", static_cast<int>(rawMissCount),
") spell=", data.spellId, " hits=", static_cast<int>(data.hitCount),
" remaining=", packet.getSize() - packet.getReadPos());
}
const uint8_t storedMissLimit = std::min<uint8_t>(rawMissCount, 128);
@ -3967,8 +3967,8 @@ bool SpellGoParser::parse(network::Packet& packet, SpellGoData& data) {
// WotLK 3.3.5a miss targets are full uint64 GUIDs + uint8 missType.
// REFLECT additionally appends uint8 reflectResult.
if (packet.getSize() - packet.getReadPos() < 9) { // 8 GUID + 1 missType
LOG_WARNING("Spell go: truncated miss targets at index ", i, "/", (int)rawMissCount,
" spell=", data.spellId, " hits=", (int)data.hitCount);
LOG_WARNING("Spell go: truncated miss targets at index ", i, "/", static_cast<int>(rawMissCount),
" spell=", data.spellId, " hits=", static_cast<int>(data.hitCount));
truncatedTargets = true;
break;
}
@ -3977,7 +3977,7 @@ bool SpellGoParser::parse(network::Packet& packet, SpellGoData& data) {
m.missType = packet.readUInt8();
if (m.missType == 11) { // SPELL_MISS_REFLECT
if (packet.getSize() - packet.getReadPos() < 1) {
LOG_WARNING("Spell go: truncated reflect payload at miss index ", i, "/", (int)rawMissCount);
LOG_WARNING("Spell go: truncated reflect payload at miss index ", i, "/", static_cast<int>(rawMissCount));
truncatedTargets = true;
break;
}
@ -3993,7 +3993,7 @@ bool SpellGoParser::parse(network::Packet& packet, SpellGoData& data) {
// rather than discarding the entire spell. The server already applied effects;
// we just need the hit list for UI feedback (combat text, health bars).
if (truncatedTargets) {
LOG_DEBUG("Spell go: salvaging ", (int)data.hitCount, " hits despite miss truncation");
LOG_DEBUG("Spell go: salvaging ", static_cast<int>(data.hitCount), " hits despite miss truncation");
packet.setReadPos(packet.getSize()); // consume remaining bytes
return true;
}
@ -4042,8 +4042,8 @@ bool SpellGoParser::parse(network::Packet& packet, SpellGoData& data) {
}
}
LOG_DEBUG("Spell go: spell=", data.spellId, " hits=", (int)data.hitCount,
" misses=", (int)data.missCount);
LOG_DEBUG("Spell go: spell=", data.spellId, " hits=", static_cast<int>(data.hitCount),
" misses=", static_cast<int>(data.missCount));
return true;
}
@ -4182,7 +4182,7 @@ bool GroupInviteResponseParser::parse(network::Packet& packet, GroupInviteRespon
data.canAccept = packet.readUInt8();
// Note: inviterName is a string, which is always safe to read even if empty
data.inviterName = packet.readString();
LOG_INFO("Group invite from: ", data.inviterName, " (canAccept=", (int)data.canAccept, ")");
LOG_INFO("Group invite from: ", data.inviterName, " (canAccept=", static_cast<int>(data.canAccept), ")");
return true;
}
@ -4294,7 +4294,7 @@ bool PartyCommandResultParser::parse(network::Packet& packet, PartyCommandResult
}
data.result = static_cast<PartyResult>(packet.readUInt32());
LOG_DEBUG("Party command result: ", (int)data.result);
LOG_DEBUG("Party command result: ", static_cast<int>(data.result));
return true;
}
@ -4409,7 +4409,7 @@ bool LootResponseParser::parse(network::Packet& packet, LootResponseData& data,
// Short failure packet — no gold/item data follows.
avail = packet.getSize() - packet.getReadPos();
if (avail < 5) {
LOG_DEBUG("LootResponseParser: lootType=", (int)data.lootType, " (empty/failure response)");
LOG_DEBUG("LootResponseParser: lootType=", static_cast<int>(data.lootType), " (empty/failure response)");
return false;
}
@ -4458,7 +4458,7 @@ bool LootResponseParser::parse(network::Packet& packet, LootResponseData& data,
}
}
LOG_DEBUG("Loot response: ", (int)itemCount, " regular + ", (int)questItemCount,
LOG_DEBUG("Loot response: ", static_cast<int>(itemCount), " regular + ", static_cast<int>(questItemCount),
" quest items, ", data.gold, " copper");
return true;
}
@ -4990,7 +4990,7 @@ bool ListInventoryParser::parse(network::Packet& packet, ListInventoryData& data
const size_t bytesPerItemWithExt = 32;
bool hasExtendedCost = false;
if (remaining < static_cast<size_t>(itemCount) * bytesPerItemNoExt) {
LOG_WARNING("ListInventoryParser: truncated packet (items=", (int)itemCount,
LOG_WARNING("ListInventoryParser: truncated packet (items=", static_cast<int>(itemCount),
", remaining=", remaining, ")");
return false;
}
@ -5002,7 +5002,7 @@ bool ListInventoryParser::parse(network::Packet& packet, ListInventoryData& data
for (uint8_t i = 0; i < itemCount; ++i) {
const size_t perItemBytes = hasExtendedCost ? bytesPerItemWithExt : bytesPerItemNoExt;
if (packet.getSize() - packet.getReadPos() < perItemBytes) {
LOG_WARNING("ListInventoryParser: item ", (int)i, " truncated");
LOG_WARNING("ListInventoryParser: item ", static_cast<int>(i), " truncated");
return false;
}
VendorItem item;
@ -5017,7 +5017,7 @@ bool ListInventoryParser::parse(network::Packet& packet, ListInventoryData& data
data.items.push_back(item);
}
LOG_DEBUG("Vendor inventory: ", (int)itemCount, " items (extendedCost: ", hasExtendedCost ? "yes" : "no", ")");
LOG_DEBUG("Vendor inventory: ", static_cast<int>(itemCount), " items (extendedCost: ", hasExtendedCost ? "yes" : "no", ")");
return true;
}
@ -5138,8 +5138,8 @@ bool TalentsInfoParser::parse(network::Packet& packet, TalentsInfoData& data) {
return false;
}
LOG_INFO("SMSG_TALENTS_INFO: spec=", (int)data.talentSpec,
" unspent=", (int)data.unspentPoints,
LOG_INFO("SMSG_TALENTS_INFO: spec=", static_cast<int>(data.talentSpec),
" unspent=", static_cast<int>(data.unspentPoints),
" talentCount=", talentCount,
" entryCount=", entryCount);
@ -5157,7 +5157,7 @@ bool TalentsInfoParser::parse(network::Packet& packet, TalentsInfoData& data) {
uint8_t rank = packet.readUInt8();
data.talents.push_back({id, rank});
LOG_INFO(" Entry: id=", id, " rank=", (int)rank);
LOG_INFO(" Entry: id=", id, " rank=", static_cast<int>(rank));
}
// Parse glyph tail: glyphSlots + glyphIds[]
@ -5170,11 +5170,11 @@ bool TalentsInfoParser::parse(network::Packet& packet, TalentsInfoData& data) {
// Sanity check: Wrath has 6 glyph slots, cap at 12 for safety
if (glyphSlots > 12) {
LOG_WARNING("SMSG_TALENTS_INFO: glyphSlots too large (", (int)glyphSlots, "), clamping to 12");
LOG_WARNING("SMSG_TALENTS_INFO: glyphSlots too large (", static_cast<int>(glyphSlots), "), clamping to 12");
glyphSlots = 12;
}
LOG_INFO(" GlyphSlots: ", (int)glyphSlots);
LOG_INFO(" GlyphSlots: ", static_cast<int>(glyphSlots));
data.glyphs.clear();
data.glyphs.reserve(glyphSlots);
@ -5389,7 +5389,7 @@ bool PacketParsers::parseMailList(network::Packet& packet, std::vector<MailMessa
uint8_t shownCount = packet.readUInt8();
(void)totalCount;
LOG_INFO("SMSG_MAIL_LIST_RESULT (WotLK): total=", totalCount, " shown=", (int)shownCount);
LOG_INFO("SMSG_MAIL_LIST_RESULT (WotLK): total=", totalCount, " shown=", static_cast<int>(shownCount));
inbox.clear();
inbox.reserve(shownCount);
@ -5593,14 +5593,14 @@ bool GuildBankListParser::parse(network::Packet& packet, GuildBankData& data) {
uint8_t tabCount = packet.readUInt8();
// Cap at 8 (normal guild bank tab limit in WoW)
if (tabCount > 8) {
LOG_WARNING("GuildBankListParser: tabCount capped (requested=", (int)tabCount, ")");
LOG_WARNING("GuildBankListParser: tabCount capped (requested=", static_cast<int>(tabCount), ")");
tabCount = 8;
}
data.tabs.resize(tabCount);
for (uint8_t i = 0; i < tabCount; ++i) {
// Validate before reading strings
if (packet.getReadPos() >= packet.getSize()) {
LOG_WARNING("GuildBankListParser: truncated tab at index ", (int)i);
LOG_WARNING("GuildBankListParser: truncated tab at index ", static_cast<int>(i));
break;
}
data.tabs[i].tabName = packet.readString();
@ -5624,7 +5624,7 @@ bool GuildBankListParser::parse(network::Packet& packet, GuildBankData& data) {
for (uint8_t i = 0; i < numSlots; ++i) {
// Validate minimum bytes before reading slot (slotId(1) + itemEntry(4) = 5)
if (packet.getReadPos() + 5 > packet.getSize()) {
LOG_WARNING("GuildBankListParser: truncated slot at index ", (int)i);
LOG_WARNING("GuildBankListParser: truncated slot at index ", static_cast<int>(i));
break;
}
GuildBankItemSlot slot;

View file

@ -332,24 +332,24 @@ void WorldSocket::send(const Packet& packet) {
rd8(skin) && rd8(face) && rd8(hairStyle) && rd8(hairColor) && rd8(facial) && rd8(outfit);
if (ok) {
LOG_INFO("CMSG_CHAR_CREATE payload: name='", name,
"' race=", (int)race, " class=", (int)cls, " gender=", (int)gender,
" skin=", (int)skin, " face=", (int)face,
" hairStyle=", (int)hairStyle, " hairColor=", (int)hairColor,
" facial=", (int)facial, " outfit=", (int)outfit,
"' race=", static_cast<int>(race), " class=", static_cast<int>(cls), " gender=", static_cast<int>(gender),
" skin=", static_cast<int>(skin), " face=", static_cast<int>(face),
" hairStyle=", static_cast<int>(hairStyle), " hairColor=", static_cast<int>(hairColor),
" facial=", static_cast<int>(facial), " outfit=", static_cast<int>(outfit),
" payloadLen=", payloadLen);
// Persist to disk so we can compare TX vs DB even if the console scrolls away.
std::ofstream f("charcreate_payload.log", std::ios::app);
if (f.is_open()) {
f << "name='" << name << "'"
<< " race=" << (int)race
<< " class=" << (int)cls
<< " gender=" << (int)gender
<< " skin=" << (int)skin
<< " face=" << (int)face
<< " hairStyle=" << (int)hairStyle
<< " hairColor=" << (int)hairColor
<< " facial=" << (int)facial
<< " outfit=" << (int)outfit
<< " race=" << static_cast<int>(race)
<< " class=" << static_cast<int>(cls)
<< " gender=" << static_cast<int>(gender)
<< " skin=" << static_cast<int>(skin)
<< " face=" << static_cast<int>(face)
<< " hairStyle=" << static_cast<int>(hairStyle)
<< " hairColor=" << static_cast<int>(hairColor)
<< " facial=" << static_cast<int>(facial)
<< " outfit=" << static_cast<int>(outfit)
<< " payloadLen=" << payloadLen
<< "\n";
}

View file

@ -117,7 +117,7 @@ void AssetManager::shutdown() {
LOG_INFO("Shutting down asset manager");
if (fileCacheHits + fileCacheMisses > 0) {
float hitRate = (float)fileCacheHits / (fileCacheHits + fileCacheMisses) * 100.0f;
float hitRate = static_cast<float>(fileCacheHits) / (fileCacheHits + fileCacheMisses) * 100.0f;
LOG_INFO("File cache stats: ", fileCacheHits, " hits, ", fileCacheMisses, " misses (",
(int)hitRate, "% hit rate), ", fileCacheTotalBytes / 1024 / 1024, " MB cached");
}

View file

@ -253,7 +253,7 @@ void BLPLoader::decompressDXT3(const uint8_t* src, uint8_t* dst, int width, int
// First 8 bytes: 4-bit alpha values
uint64_t alphaBlock = 0;
for (int i = 0; i < 8; i++) {
alphaBlock |= (uint64_t)block[i] << (i * 8);
alphaBlock |= static_cast<uint64_t>(block[i]) << (i * 8);
}
// Color block (same as DXT1) starts at byte 8
@ -336,7 +336,7 @@ void BLPLoader::decompressDXT5(const uint8_t* src, uint8_t* dst, int width, int
// Alpha indices (48 bits for 16 pixels, 3 bits each)
uint64_t alphaIndices = 0;
for (int i = 2; i < 8; i++) {
alphaIndices |= (uint64_t)block[i] << ((i - 2) * 8);
alphaIndices |= static_cast<uint64_t>(block[i]) << ((i - 2) * 8);
}
// Color block (same as DXT1) starts at byte 8

View file

@ -1583,7 +1583,7 @@ void Renderer::setMounted(uint32_t mountInstId, uint32_t mountDisplayId, float h
int bestScore = -999;
for (uint32_t id : loops) {
int sc = 0;
sc += scoreNear((int)id, 38); // classic hint
sc += scoreNear(static_cast<int>(id), 38); // classic hint
const auto* s = findSeqById(id);
if (s) sc += (s->duration >= 500 && s->duration <= 800) ? 5 : 0;
if (sc > bestScore) {
@ -1607,10 +1607,10 @@ void Renderer::setMounted(uint32_t mountInstId, uint32_t mountDisplayId, float h
// Start window
if (seq.duration >= 450 && seq.duration <= 1100) {
int sc = 0;
if (loop) sc += scoreNear((int)seq.id, (int)loop);
if (loop) sc += scoreNear(static_cast<int>(seq.id), static_cast<int>(loop));
// Chain bonus: if this start points at loop or near it
if (loop && (seq.nextAnimation == (int16_t)loop || seq.aliasNext == loop)) sc += 30;
if (loop && scoreNear(seq.nextAnimation, (int)loop) > 0) sc += 10;
if (loop && (seq.nextAnimation == static_cast<int16_t>(loop) || seq.aliasNext == loop)) sc += 30;
if (loop && scoreNear(seq.nextAnimation, static_cast<int>(loop)) > 0) sc += 10;
// Penalize "stop/brake-ish": very long blendTime can be a stop transition
if (seq.blendTime > 400) sc -= 5;
@ -1623,9 +1623,9 @@ void Renderer::setMounted(uint32_t mountInstId, uint32_t mountDisplayId, float h
// End window
if (seq.duration >= 650 && seq.duration <= 1600) {
int sc = 0;
if (loop) sc += scoreNear((int)seq.id, (int)loop);
if (loop) sc += scoreNear(static_cast<int>(seq.id), static_cast<int>(loop));
// Chain bonus: end often points to run/stand or has no next
if (seq.nextAnimation == (int16_t)runId || seq.nextAnimation == (int16_t)standId) sc += 10;
if (seq.nextAnimation == static_cast<int16_t>(runId) || seq.nextAnimation == static_cast<int16_t>(standId)) sc += 10;
if (seq.nextAnimation < 0) sc += 5; // no chain sometimes = terminal
if (sc > bestEnd) {
bestEnd = sc;
@ -1698,7 +1698,7 @@ void Renderer::setMounted(uint32_t mountInstId, uint32_t mountDisplayId, float h
if (!isLoop && (hasFrequency || hasReplay) && isStationary && reasonableDuration &&
!isDeathOrWound && !isAttackOrCombat && !isSpecial) {
// Bonus: chains back to stand (indicates idle behavior)
bool chainsToStand = (seq.nextAnimation == (int16_t)mountAnims_.stand) ||
bool chainsToStand = (seq.nextAnimation == static_cast<int16_t>(mountAnims_.stand)) ||
(seq.aliasNext == mountAnims_.stand) ||
(seq.nextAnimation == -1);

View file

@ -9415,7 +9415,7 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
float cd = slot.cooldownRemaining;
if (cd >= 60.0f)
ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f),
"Cooldown: %d min %d sec", (int)cd/60, (int)cd%60);
"Cooldown: %d min %d sec", static_cast<int>(cd)/60, static_cast<int>(cd)%60);
else
ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f), "Cooldown: %.1f sec", cd);
}
@ -9431,7 +9431,7 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
float cd = macroCooldownRemaining;
if (cd >= 60.0f)
ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f),
"Cooldown: %d min %d sec", (int)cd/60, (int)cd%60);
"Cooldown: %d min %d sec", static_cast<int>(cd)/60, static_cast<int>(cd)%60);
else
ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f), "Cooldown: %.1f sec", cd);
}
@ -9494,7 +9494,7 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
float cd = slot.cooldownRemaining;
if (cd >= 60.0f)
ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f),
"Cooldown: %d min %d sec", (int)cd/60, (int)cd%60);
"Cooldown: %d min %d sec", static_cast<int>(cd)/60, static_cast<int>(cd)%60);
else
ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f), "Cooldown: %.1f sec", cd);
}
@ -9533,9 +9533,9 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
char cdText[16];
float cd = effCdRemaining;
if (cd >= 3600.0f) snprintf(cdText, sizeof(cdText), "%dh", (int)cd / 3600);
else if (cd >= 60.0f) snprintf(cdText, sizeof(cdText), "%dm%ds", (int)cd / 60, (int)cd % 60);
else if (cd >= 5.0f) snprintf(cdText, sizeof(cdText), "%ds", (int)cd);
if (cd >= 3600.0f) snprintf(cdText, sizeof(cdText), "%dh", static_cast<int>(cd) / 3600);
else if (cd >= 60.0f) snprintf(cdText, sizeof(cdText), "%dm%ds", static_cast<int>(cd) / 60, static_cast<int>(cd) % 60);
else if (cd >= 5.0f) snprintf(cdText, sizeof(cdText), "%ds", static_cast<int>(cd));
else snprintf(cdText, sizeof(cdText), "%.1f", cd);
ImVec2 textSize = ImGui::CalcTextSize(cdText);
float tx = cx - textSize.x * 0.5f;
@ -10766,7 +10766,7 @@ void GameScreen::renderCooldownTracker(game::GameHandler& gameHandler) {
// Name (truncated) + remaining time
char timeStr[16];
if (cd.remaining >= 60.0f)
snprintf(timeStr, sizeof(timeStr), "%dm%ds", (int)cd.remaining / 60, (int)cd.remaining % 60);
snprintf(timeStr, sizeof(timeStr), "%dm%ds", static_cast<int>(cd.remaining) / 60, static_cast<int>(cd.remaining) % 60);
else
snprintf(timeStr, sizeof(timeStr), "%.0fs", cd.remaining);
@ -12692,7 +12692,7 @@ void GameScreen::renderPartyFrames(game::GameHandler& gameHandler) {
snprintf(hpText, sizeof(hpText), "OOR");
} else if (maxHp >= 10000) {
snprintf(hpText, sizeof(hpText), "%dk/%dk",
(int)hp / 1000, (int)maxHp / 1000);
static_cast<int>(hp) / 1000, static_cast<int>(maxHp) / 1000);
} else {
snprintf(hpText, sizeof(hpText), "%u/%u", hp, maxHp);
}
@ -13107,18 +13107,18 @@ void GameScreen::renderRepToasts(float deltaTime) {
ImVec2 br(toastX + toastW, toastY + toastH);
// Background
draw->AddRectFilled(tl, br, IM_COL32(15, 15, 20, (int)(alpha * 200)), 4.0f);
draw->AddRectFilled(tl, br, IM_COL32(15, 15, 20, static_cast<int>(alpha * 200)), 4.0f);
// Border: green for gain, red for loss
ImU32 borderCol = (e.delta > 0)
? IM_COL32(80, 200, 80, (int)(alpha * 220))
: IM_COL32(200, 60, 60, (int)(alpha * 220));
? IM_COL32(80, 200, 80, static_cast<int>(alpha * 220))
: IM_COL32(200, 60, 60, static_cast<int>(alpha * 220));
draw->AddRect(tl, br, borderCol, 4.0f, 0, 1.5f);
// Delta text: "+250" or "-250"
char deltaBuf[16];
snprintf(deltaBuf, sizeof(deltaBuf), "%+d", e.delta);
ImU32 deltaCol = (e.delta > 0) ? IM_COL32(80, 220, 80, (int)(alpha * 255))
: IM_COL32(220, 70, 70, (int)(alpha * 255));
ImU32 deltaCol = (e.delta > 0) ? IM_COL32(80, 220, 80, static_cast<int>(alpha * 255))
: IM_COL32(220, 70, 70, static_cast<int>(alpha * 255));
draw->AddText(font, fontSize, ImVec2(tl.x + 6.0f, tl.y + (toastH - fontSize) * 0.5f),
deltaCol, deltaBuf);
@ -13126,7 +13126,7 @@ void GameScreen::renderRepToasts(float deltaTime) {
char nameBuf[64];
snprintf(nameBuf, sizeof(nameBuf), "%s (%s)", e.factionName.c_str(), standingLabel(e.standing));
draw->AddText(font, fontSize * 0.85f, ImVec2(tl.x + 44.0f, tl.y + (toastH - fontSize * 0.85f) * 0.5f),
IM_COL32(210, 210, 210, (int)(alpha * 220)), nameBuf);
IM_COL32(210, 210, 210, static_cast<int>(alpha * 220)), nameBuf);
}
}
@ -13169,26 +13169,26 @@ void GameScreen::renderQuestCompleteToasts(float deltaTime) {
ImVec2 br(toastX + toastW, toastY + toastH);
// Background + gold border (quest completion)
draw->AddRectFilled(tl, br, IM_COL32(20, 18, 8, (int)(alpha * 210)), 5.0f);
draw->AddRect(tl, br, IM_COL32(220, 180, 30, (int)(alpha * 230)), 5.0f, 0, 1.5f);
draw->AddRectFilled(tl, br, IM_COL32(20, 18, 8, static_cast<int>(alpha * 210)), 5.0f);
draw->AddRect(tl, br, IM_COL32(220, 180, 30, static_cast<int>(alpha * 230)), 5.0f, 0, 1.5f);
// Scroll icon placeholder (gold diamond)
float iconCx = tl.x + 18.0f;
float iconCy = tl.y + toastH * 0.5f;
draw->AddCircleFilled(ImVec2(iconCx, iconCy), 7.0f, IM_COL32(210, 170, 20, (int)(alpha * 230)));
draw->AddCircle (ImVec2(iconCx, iconCy), 7.0f, IM_COL32(255, 220, 50, (int)(alpha * 200)));
draw->AddCircleFilled(ImVec2(iconCx, iconCy), 7.0f, IM_COL32(210, 170, 20, static_cast<int>(alpha * 230)));
draw->AddCircle (ImVec2(iconCx, iconCy), 7.0f, IM_COL32(255, 220, 50, static_cast<int>(alpha * 200)));
// "Quest Complete" header in gold
const char* header = "Quest Complete";
draw->AddText(font, fontSize * 0.78f,
ImVec2(tl.x + 34.0f, tl.y + 4.0f),
IM_COL32(240, 200, 40, (int)(alpha * 240)), header);
IM_COL32(240, 200, 40, static_cast<int>(alpha * 240)), header);
// Quest title in off-white
const char* titleStr = e.title.empty() ? "Unknown Quest" : e.title.c_str();
draw->AddText(font, fontSize * 0.82f,
ImVec2(tl.x + 34.0f, tl.y + toastH * 0.5f + 1.0f),
IM_COL32(220, 215, 195, (int)(alpha * 220)), titleStr);
IM_COL32(220, 215, 195, static_cast<int>(alpha * 220)), titleStr);
}
}
@ -13237,16 +13237,16 @@ void GameScreen::renderZoneToasts(float deltaTime) {
ImVec2 tl(toastX, toastY);
ImVec2 br(toastX + toastW, toastY + toastH);
draw->AddRectFilled(tl, br, IM_COL32(10, 10, 16, (int)(alpha * 200)), 6.0f);
draw->AddRect(tl, br, IM_COL32(160, 140, 80, (int)(alpha * 220)), 6.0f, 0, 1.2f);
draw->AddRectFilled(tl, br, IM_COL32(10, 10, 16, static_cast<int>(alpha * 200)), 6.0f);
draw->AddRect(tl, br, IM_COL32(160, 140, 80, static_cast<int>(alpha * 220)), 6.0f, 0, 1.2f);
float cx = tl.x + toastW * 0.5f;
draw->AddText(font, 11.0f,
ImVec2(cx - hdrSz.x * 0.5f, tl.y + 5.0f),
IM_COL32(180, 170, 120, (int)(alpha * 200)), header);
IM_COL32(180, 170, 120, static_cast<int>(alpha * 200)), header);
draw->AddText(font, 14.0f,
ImVec2(cx - nameSz.x * 0.5f, tl.y + toastH * 0.5f + 1.0f),
IM_COL32(255, 230, 140, (int)(alpha * 240)), e.zoneName.c_str());
IM_COL32(255, 230, 140, static_cast<int>(alpha * 240)), e.zoneName.c_str());
}
}
@ -13301,18 +13301,18 @@ void GameScreen::renderAreaTriggerToasts(float deltaTime, game::GameHandler& gam
ImVec2 tl(toastX, toastY);
ImVec2 br(toastX + toastW, toastY + toastH);
draw->AddRectFilled(tl, br, IM_COL32(8, 12, 22, (int)(alpha * 190)), 5.0f);
draw->AddRect(tl, br, IM_COL32(100, 160, 220, (int)(alpha * 200)), 5.0f, 0, 1.0f);
draw->AddRectFilled(tl, br, IM_COL32(8, 12, 22, static_cast<int>(alpha * 190)), 5.0f);
draw->AddRect(tl, br, IM_COL32(100, 160, 220, static_cast<int>(alpha * 200)), 5.0f, 0, 1.0f);
float cx = tl.x + toastW * 0.5f;
// Shadow
draw->AddText(font, 13.0f,
ImVec2(cx - txtSz.x * 0.5f + 1, tl.y + (toastH - txtSz.y) * 0.5f + 1),
IM_COL32(0, 0, 0, (int)(alpha * 180)), t.text.c_str());
IM_COL32(0, 0, 0, static_cast<int>(alpha * 180)), t.text.c_str());
// Text in light blue
draw->AddText(font, 13.0f,
ImVec2(cx - txtSz.x * 0.5f, tl.y + (toastH - txtSz.y) * 0.5f),
IM_COL32(180, 220, 255, (int)(alpha * 240)), t.text.c_str());
IM_COL32(180, 220, 255, static_cast<int>(alpha * 240)), t.text.c_str());
}
}
@ -14616,7 +14616,7 @@ void GameScreen::renderGuildRoster(game::GameHandler& gameHandler) {
for (const auto& m : roster.members) {
if (m.online) ++onlineCount;
}
ImGui::Text("%d members (%d online)", (int)roster.members.size(), onlineCount);
ImGui::Text("%d members (%d online)", static_cast<int>(roster.members.size()), onlineCount);
ImGui::Separator();
const auto& rankNames = gameHandler.getGuildRankNames();
@ -17239,7 +17239,7 @@ void GameScreen::renderTrainerWindow(game::GameHandler& gameHandler) {
}
if (logCount < 3) {
LOG_INFO("Trainer button debug: spellId=", spell->spellId,
" alreadyKnown=", alreadyKnown, " state=", (int)spell->state,
" alreadyKnown=", alreadyKnown, " state=", static_cast<int>(spell->state),
" prereqsMet=", prereqsMet, " (", prereq1Met, ",", prereq2Met, ",", prereq3Met, ")",
" levelMet=", levelMet,
" reqLevel=", spell->reqLevel, " playerLevel=", playerLevel,
@ -22855,10 +22855,10 @@ void GameScreen::renderDingEffect() {
// Slight black outline for readability
draw->AddText(font, fontSize, ImVec2(tx + 2, ty + 2),
IM_COL32(0, 0, 0, (int)(alpha * 180)), buf);
IM_COL32(0, 0, 0, static_cast<int>(alpha * 180)), buf);
// Gold text
draw->AddText(font, fontSize, ImVec2(tx, ty),
IM_COL32(255, 210, 0, (int)(alpha * 255)), buf);
IM_COL32(255, 210, 0, static_cast<int>(alpha * 255)), buf);
// Stat gains below the main text (shown only if server sent deltas)
bool hasStatGains = (dingHpDelta_ > 0 || dingManaDelta_ > 0 ||
@ -22878,7 +22878,7 @@ void GameScreen::renderDingEffect() {
if (dingManaDelta_ > 0)
written += snprintf(statBuf + written, sizeof(statBuf) - written,
"+%u Mana ", dingManaDelta_);
for (int i = 0; i < 5 && written < (int)sizeof(statBuf) - 1; ++i) {
for (int i = 0; i < 5 && written < static_cast<int>(sizeof(statBuf)) - 1; ++i) {
if (dingStats_[i] > 0)
written += snprintf(statBuf + written, sizeof(statBuf) - written,
"+%u %s ", dingStats_[i], kStatLabels[i]);
@ -22891,9 +22891,9 @@ void GameScreen::renderDingEffect() {
ImVec2 ssz = font->CalcTextSizeA(smallSize, FLT_MAX, 0.0f, statBuf);
float stx = cx - ssz.x * 0.5f;
draw->AddText(font, smallSize, ImVec2(stx + 1, yOff + 1),
IM_COL32(0, 0, 0, (int)(alpha * 160)), statBuf);
IM_COL32(0, 0, 0, static_cast<int>(alpha * 160)), statBuf);
draw->AddText(font, smallSize, ImVec2(stx, yOff),
IM_COL32(100, 220, 100, (int)(alpha * 230)), statBuf);
IM_COL32(100, 220, 100, static_cast<int>(alpha * 230)), statBuf);
}
}
}
@ -22944,8 +22944,8 @@ void GameScreen::renderAchievementToast() {
// Background panel (gold border, dark fill)
ImVec2 tl(toastX, toastY);
ImVec2 br(toastX + TOAST_W, toastY + TOAST_H);
draw->AddRectFilled(tl, br, IM_COL32(30, 20, 10, (int)(alpha * 230)), 6.0f);
draw->AddRect(tl, br, IM_COL32(200, 170, 50, (int)(alpha * 255)), 6.0f, 0, 2.0f);
draw->AddRectFilled(tl, br, IM_COL32(30, 20, 10, static_cast<int>(alpha * 230)), 6.0f);
draw->AddRect(tl, br, IM_COL32(200, 170, 50, static_cast<int>(alpha * 255)), 6.0f, 0, 2.0f);
// Title
ImFont* font = ImGui::GetFont();
@ -22955,9 +22955,9 @@ void GameScreen::renderAchievementToast() {
float titleW = font->CalcTextSizeA(titleSize, FLT_MAX, 0.0f, title).x;
float titleX = toastX + (TOAST_W - titleW) * 0.5f;
draw->AddText(font, titleSize, ImVec2(titleX + 1, toastY + 8 + 1),
IM_COL32(0, 0, 0, (int)(alpha * 180)), title);
IM_COL32(0, 0, 0, static_cast<int>(alpha * 180)), title);
draw->AddText(font, titleSize, ImVec2(titleX, toastY + 8),
IM_COL32(255, 215, 0, (int)(alpha * 255)), title);
IM_COL32(255, 215, 0, static_cast<int>(alpha * 255)), title);
// Achievement name (falls back to ID if name not available)
char idBuf[256];
@ -22971,7 +22971,7 @@ void GameScreen::renderAchievementToast() {
float idW = font->CalcTextSizeA(bodySize, FLT_MAX, 0.0f, idBuf).x;
float idX = toastX + (TOAST_W - idW) * 0.5f;
draw->AddText(font, bodySize, ImVec2(idX, toastY + 28),
IM_COL32(220, 200, 150, (int)(alpha * 255)), idBuf);
IM_COL32(220, 200, 150, static_cast<int>(alpha * 255)), idBuf);
}
// ---------------------------------------------------------------------------
@ -23028,22 +23028,22 @@ void GameScreen::renderDiscoveryToast() {
// "Discovered!" in gold
draw->AddText(font, headerSize, ImVec2(headerX + 1, headerY + 1),
IM_COL32(0, 0, 0, (int)(alpha * 160)), header);
IM_COL32(0, 0, 0, static_cast<int>(alpha * 160)), header);
draw->AddText(font, headerSize, ImVec2(headerX, headerY),
IM_COL32(255, 215, 0, (int)(alpha * 255)), header);
IM_COL32(255, 215, 0, static_cast<int>(alpha * 255)), header);
// Area name in white
draw->AddText(font, nameSize, ImVec2(nameX + 1, nameY + 1),
IM_COL32(0, 0, 0, (int)(alpha * 160)), discoveryToastName_.c_str());
IM_COL32(0, 0, 0, static_cast<int>(alpha * 160)), discoveryToastName_.c_str());
draw->AddText(font, nameSize, ImVec2(nameX, nameY),
IM_COL32(255, 255, 255, (int)(alpha * 255)), discoveryToastName_.c_str());
IM_COL32(255, 255, 255, static_cast<int>(alpha * 255)), discoveryToastName_.c_str());
// XP gain in light green (if any)
if (xpBuf[0] != '\0') {
draw->AddText(font, xpSize, ImVec2(xpX + 1, xpY + 1),
IM_COL32(0, 0, 0, (int)(alpha * 140)), xpBuf);
IM_COL32(0, 0, 0, static_cast<int>(alpha * 140)), xpBuf);
draw->AddText(font, xpSize, ImVec2(xpX, xpY),
IM_COL32(100, 220, 100, (int)(alpha * 230)), xpBuf);
IM_COL32(100, 220, 100, static_cast<int>(alpha * 230)), xpBuf);
}
}
@ -23590,15 +23590,15 @@ void GameScreen::renderZoneText(game::GameHandler& gameHandler) {
// "Entering:" in gold
draw->AddText(font, headerSize, ImVec2(headerX + 1, headerY + 1),
IM_COL32(0, 0, 0, (int)(alpha * 160)), header);
IM_COL32(0, 0, 0, static_cast<int>(alpha * 160)), header);
draw->AddText(font, headerSize, ImVec2(headerX, headerY),
IM_COL32(255, 215, 0, (int)(alpha * 255)), header);
IM_COL32(255, 215, 0, static_cast<int>(alpha * 255)), header);
// Zone name in white
draw->AddText(font, nameSize, ImVec2(nameX + 1, nameY + 1),
IM_COL32(0, 0, 0, (int)(alpha * 160)), zoneTextName_.c_str());
IM_COL32(0, 0, 0, static_cast<int>(alpha * 160)), zoneTextName_.c_str());
draw->AddText(font, nameSize, ImVec2(nameX, nameY),
IM_COL32(255, 255, 255, (int)(alpha * 255)), zoneTextName_.c_str());
IM_COL32(255, 255, 255, static_cast<int>(alpha * 255)), zoneTextName_.c_str());
}
// ---------------------------------------------------------------------------
@ -23937,14 +23937,14 @@ void GameScreen::renderDungeonFinderWindow(game::GameHandler& gameHandler) {
// Find current index
int curIdx = 0;
for (int i = 0; i < (int)(sizeof(kDungeons)/sizeof(kDungeons[0])); ++i) {
for (int i = 0; i < static_cast<int>(sizeof(kDungeons)/sizeof(kDungeons[0])); ++i) {
if (kDungeons[i].id == lfgSelectedDungeon_) { curIdx = i; break; }
}
ImGui::SetNextItemWidth(-1);
if (ImGui::BeginCombo("##dungeon", kDungeons[curIdx].name)) {
uint8_t lastCat = 255;
for (int i = 0; i < (int)(sizeof(kDungeons)/sizeof(kDungeons[0])); ++i) {
for (int i = 0; i < static_cast<int>(sizeof(kDungeons)/sizeof(kDungeons[0])); ++i) {
if (kDungeons[i].cat != lastCat && kCatHeaders[kDungeons[i].cat]) {
if (lastCat != 255) ImGui::Separator();
ImGui::TextDisabled("%s", kCatHeaders[kDungeons[i].cat]);
@ -24642,7 +24642,7 @@ void GameScreen::renderCombatLog(game::GameHandler& gameHandler) {
: ImVec4(1.0f, 0.15f, 0.15f, 1.0f);
break;
default:
snprintf(desc, sizeof(desc), "Combat event (type %d, amount %d)", (int)e.type, e.amount);
snprintf(desc, sizeof(desc), "Combat event (type %d, amount %d)", static_cast<int>(e.type), e.amount);
color = ImVec4(0.7f, 0.7f, 0.7f, 1.0f);
break;
}
@ -24701,7 +24701,7 @@ void GameScreen::renderAchievementWindow(game::GameHandler& gameHandler) {
if (ImGui::BeginTabBar("##achtabs")) {
// --- Earned tab ---
char earnedLabel[32];
snprintf(earnedLabel, sizeof(earnedLabel), "Earned (%u)###earned", (unsigned)earned.size());
snprintf(earnedLabel, sizeof(earnedLabel), "Earned (%u)###earned", static_cast<unsigned>(earned.size()));
if (ImGui::BeginTabItem(earnedLabel)) {
if (earned.empty()) {
ImGui::TextDisabled("No achievements earned yet.");
@ -24765,7 +24765,7 @@ void GameScreen::renderAchievementWindow(game::GameHandler& gameHandler) {
// --- Criteria progress tab ---
char critLabel[32];
snprintf(critLabel, sizeof(critLabel), "Criteria (%u)###crit", (unsigned)criteria.size());
snprintf(critLabel, sizeof(critLabel), "Criteria (%u)###crit", static_cast<unsigned>(criteria.size()));
if (ImGui::BeginTabItem(critLabel)) {
// Lazy-load AchievementCriteria.dbc for descriptions
struct CriteriaEntry { uint32_t achievementId; uint64_t quantity; std::string description; };
@ -25027,7 +25027,7 @@ void GameScreen::renderThreatWindow(game::GameHandler& gameHandler) {
if (isPlayer && rank == 1) col = ImVec4(1.0f, 0.3f, 0.3f, 1.0f); // red — you have aggro
// Threat bar
float pct = (maxThreat > 0) ? (float)entry.threat / (float)maxThreat : 0.0f;
float pct = (maxThreat > 0) ? static_cast<float>(entry.threat) / static_cast<float>(maxThreat) : 0.0f;
ImGui::PushStyleColor(ImGuiCol_PlotHistogram,
isPlayer ? ImVec4(0.8f, 0.2f, 0.2f, 0.7f) : ImVec4(0.2f, 0.5f, 0.8f, 0.5f));
char barLabel[48];
@ -25359,7 +25359,7 @@ void GameScreen::renderInspectWindow(game::GameHandler& gameHandler) {
}
if (result->talentGroups > 1) {
ImGui::SameLine();
ImGui::TextDisabled(" Dual spec (active %u)", (unsigned)result->activeTalentGroup + 1);
ImGui::TextDisabled(" Dual spec (active %u)", static_cast<unsigned>(result->activeTalentGroup) + 1);
}
ImGui::Separator();

View file

@ -748,7 +748,7 @@ void TalentScreen::renderGlyphs(game::GameHandler& gameHandler) {
if (!name.empty()) {
ImGui::TextColored(ImVec4(0.9f, 0.9f, 0.9f, 1.0f), "%s", name.c_str());
} else {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "Glyph #%u", (uint32_t)glyphId);
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "Glyph #%u", static_cast<uint32_t>(glyphId));
}
};