diff options
Diffstat (limited to 'src/server/game/Warden/WardenCheckMgr.cpp')
-rw-r--r-- | src/server/game/Warden/WardenCheckMgr.cpp | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/server/game/Warden/WardenCheckMgr.cpp b/src/server/game/Warden/WardenCheckMgr.cpp index 589b666c035..29f29fe5b88 100644 --- a/src/server/game/Warden/WardenCheckMgr.cpp +++ b/src/server/game/Warden/WardenCheckMgr.cpp @@ -28,7 +28,6 @@ WardenCheckMgr::WardenCheckMgr() { - InternalDataID = 1; } WardenCheckMgr::~WardenCheckMgr() @@ -151,31 +150,48 @@ void WardenCheckMgr::LoadWardenChecks() } while (result->NextRow()); - // Fetch overrides from char db and overwrite default action in CheckStore - QueryResult overrideResult = CharacterDatabase.Query("SELECT wardenId, action FROM warden_action"); + sLog->outString(">> Loaded %u warden checks.", count); + sLog->outString(); +} - uint32 overrideCount = 0; +void WardenCheckMgr::LoadWardenOverrides() +{ + // 0 1 + QueryResult result = CharacterDatabase.Query("SELECT wardenId, action FROM warden_action"); - if (overrideResult) + if (!result) { - do - { - fields = overrideResult->Fetch(); + sLog->outString(">> Loaded 0 Warden action overrides. DB table `warden_action` is empty!"); + sLog->outString(); + return; + } + + Field* fields = result->Fetch(); - uint16 checkId = fields[0].GetUInt16(); + uint32 count = 0; - // Check if override check ID actually exists in current Warden checks - if (checkId > maxCheckId) - sLog->outError("Warden check action override for invalid check (ID: %u, action: %u), skipped", checkId, fields[1].GetUInt8()); - else - CheckStore[fields[0].GetUInt16()]->Action = WardenActions(fields[1].GetUInt8()); + do + { + fields = result->Fetch(); - ++overrideCount; + uint16 checkId = fields[0].GetUInt16(); + uint8 action = fields[1].GetUInt8(); + + // Check if action value is in range (0-2, see WardenActions enum) + if (action > WARDEN_ACTION_BAN) + sLog->outError("Warden check override action out of range (ID: %u, action: %u)", checkId, action); + // Check if check actually exists before accessing the CheckStore vector + else if (checkId > CheckStore.size()) + sLog->outError("Warden check action override for non-existing check (ID: %u, action: %u), skipped", checkId, action); + else + { + CheckStore[checkId]->Action = WardenActions(action); + ++count; } - while (overrideResult->NextRow()); } + while (result->NextRow()); - sLog->outString(">> Loaded %u warden checks and %u action overrides.", count, overrideCount); + sLog->outString(">> Loaded %u warden action overrides.", count); sLog->outString(); } |