mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-28 09:33:52 +00:00
fix: resolve infinite recursion, operator precedence bugs, and compiler warnings
- isPreWotlk() was calling itself instead of checking expansion (infinite recursion) - luaReturnNil/Zero/False were calling themselves instead of pushing Lua values - hasRemaining(N) * M had wrong operator precedence (should be hasRemaining(N * M)) - Misleading indentation in PARTY_LEADER_CHANGED handler (fireAddonEvent always fires) - Remove unused standalone hasFullPackedGuid() (superseded by Packet method) - Suppress unused-parameter warnings in fish/cancel-auto-repeat lambdas - Remove unused settings default variables
This commit is contained in:
parent
33f8a63c99
commit
be694be558
3 changed files with 11 additions and 27 deletions
|
|
@ -26,9 +26,9 @@ static void toLowerInPlace(std::string& s) {
|
|||
}
|
||||
|
||||
// Lua return helpers — used 200+ times as guard/fallback returns
|
||||
static int luaReturnNil(lua_State* L) { return luaReturnNil(L); }
|
||||
static int luaReturnZero(lua_State* L) { return luaReturnZero(L); }
|
||||
static int luaReturnFalse(lua_State* L){ return luaReturnFalse(L); }
|
||||
static int luaReturnNil(lua_State* L) { lua_pushnil(L); return 1; }
|
||||
static int luaReturnZero(lua_State* L) { lua_pushnumber(L, 0); return 1; }
|
||||
static int luaReturnFalse(lua_State* L){ lua_pushboolean(L, 0); return 1; }
|
||||
|
||||
// Shared GetTime() epoch — all time-returning functions must use this same origin
|
||||
// so that addon calculations like (start + duration - GetTime()) are consistent.
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ bool isClassicLikeExpansion() {
|
|||
}
|
||||
|
||||
bool isPreWotlk() {
|
||||
return isPreWotlk();
|
||||
return isClassicLikeExpansion() || isActiveExpansion("tbc");
|
||||
}
|
||||
|
||||
bool envFlagEnabled(const char* key, bool defaultValue = false) {
|
||||
|
|
@ -3508,8 +3508,8 @@ void GameHandler::registerOpcodeHandlers() {
|
|||
}
|
||||
if (!leaderName.empty())
|
||||
addSystemChatMessage(leaderName + " is now the group leader.");
|
||||
fireAddonEvent("PARTY_LEADER_CHANGED", {});
|
||||
fireAddonEvent("GROUP_ROSTER_UPDATE", {});
|
||||
fireAddonEvent("PARTY_LEADER_CHANGED", {});
|
||||
fireAddonEvent("GROUP_ROSTER_UPDATE", {});
|
||||
};
|
||||
|
||||
// Gameobject / page text
|
||||
|
|
@ -3846,15 +3846,15 @@ void GameHandler::registerOpcodeHandlers() {
|
|||
}
|
||||
}
|
||||
};
|
||||
dispatchTable_[Opcode::SMSG_FISH_NOT_HOOKED] = [this](network::Packet& packet) {
|
||||
dispatchTable_[Opcode::SMSG_FISH_NOT_HOOKED] = [this](network::Packet& /*packet*/) {
|
||||
addSystemChatMessage("Your fish got away.");
|
||||
};
|
||||
dispatchTable_[Opcode::SMSG_FISH_ESCAPED] = [this](network::Packet& packet) {
|
||||
dispatchTable_[Opcode::SMSG_FISH_ESCAPED] = [this](network::Packet& /*packet*/) {
|
||||
addSystemChatMessage("Your fish escaped!");
|
||||
};
|
||||
|
||||
// ---- Auto-repeat / auras / dispel / totem ----
|
||||
dispatchTable_[Opcode::SMSG_CANCEL_AUTO_REPEAT] = [this](network::Packet& packet) {
|
||||
dispatchTable_[Opcode::SMSG_CANCEL_AUTO_REPEAT] = [this](network::Packet& /*packet*/) {
|
||||
// Server signals to stop a repeating spell (wand/shoot); no client action needed
|
||||
};
|
||||
dispatchTable_[Opcode::SMSG_AURA_UPDATE] = [this](network::Packet& packet) {
|
||||
|
|
@ -18132,7 +18132,7 @@ void GameHandler::handlePetSpells(network::Packet& packet) {
|
|||
petCommand_ = packet.readUInt8(); // 0=stay, 1=follow, 2=attack, 3=dismiss
|
||||
|
||||
// 10 × uint32 action bar slots
|
||||
if (!packet.hasRemaining(PET_ACTION_BAR_SLOTS) * 4u) goto done;
|
||||
if (!packet.hasRemaining(PET_ACTION_BAR_SLOTS * 4u)) goto done;
|
||||
for (int i = 0; i < PET_ACTION_BAR_SLOTS; ++i) {
|
||||
petActionSlots_[i] = packet.readUInt32();
|
||||
}
|
||||
|
|
@ -20387,7 +20387,7 @@ void GameHandler::handleQuestPoiQueryResponse(network::Packet& packet) {
|
|||
packet.readUInt32(); // unk2
|
||||
const uint32_t pointCount = packet.readUInt32();
|
||||
if (pointCount == 0) continue;
|
||||
if (!packet.hasRemaining(pointCount) * 8) return;
|
||||
if (!packet.hasRemaining(pointCount * 8)) return;
|
||||
// Compute centroid of the poi region to place a minimap marker.
|
||||
float sumX = 0.0f, sumY = 0.0f;
|
||||
for (uint32_t pt = 0; pt < pointCount; ++pt) {
|
||||
|
|
|
|||
|
|
@ -20,22 +20,6 @@ namespace {
|
|||
return static_cast<uint16_t>(((v & 0xFF00u) >> 8) | ((v & 0x00FFu) << 8));
|
||||
}
|
||||
|
||||
bool hasFullPackedGuid(const wowee::network::Packet& packet) {
|
||||
if (!packet.hasData()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& rawData = packet.getData();
|
||||
const uint8_t mask = rawData[packet.getReadPos()];
|
||||
size_t guidBytes = 1;
|
||||
for (int bit = 0; bit < 8; ++bit) {
|
||||
if ((mask & (1u << bit)) != 0) {
|
||||
++guidBytes;
|
||||
}
|
||||
}
|
||||
return packet.hasRemaining(guidBytes);
|
||||
}
|
||||
|
||||
const char* updateTypeName(wowee::game::UpdateType type) {
|
||||
using wowee::game::UpdateType;
|
||||
switch (type) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue