From 678c25e02ce1a70ddba5af9c9e53dd4d8555b3de Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 1 Sep 2019 22:05:44 -0500 Subject: [PATCH] Simplify error logging --- common/eqemu_logsys.cpp | 17 +--- zone/aa.cpp | 12 +-- zone/attack.cpp | 10 +- zone/aura.cpp | 2 +- zone/bot.cpp | 10 +- zone/bot_command.cpp | 14 +-- zone/bot_database.cpp | 4 +- zone/client.cpp | 4 +- zone/client_packet.cpp | 186 +++++++++++++++++------------------ zone/client_process.cpp | 2 +- zone/command.cpp | 10 +- zone/corpse.cpp | 2 +- zone/effects.cpp | 2 +- zone/embparser_api.cpp | 2 +- zone/embxs.cpp | 2 +- zone/entity.cpp | 16 +-- zone/exp.cpp | 19 ++-- zone/forage.cpp | 22 ++--- zone/groups.cpp | 35 ++++--- zone/guild_mgr.cpp | 12 +-- zone/heal_rotation.cpp | 50 +++++----- zone/horse.cpp | 6 +- zone/inventory.cpp | 22 ++--- zone/merc.cpp | 8 +- zone/mob_ai.cpp | 2 +- zone/net.cpp | 36 +++---- zone/npc.cpp | 4 +- zone/object.cpp | 8 +- zone/pathfinder_waypoint.cpp | 6 +- zone/pets.cpp | 8 +- zone/raids.cpp | 28 +++--- zone/spawn2.cpp | 8 +- zone/spell_effects.cpp | 2 +- zone/spells.cpp | 94 ++++++++++++------ zone/tasks.cpp | 47 ++++----- zone/titles.cpp | 2 +- zone/tradeskills.cpp | 81 ++++++++------- zone/trading.cpp | 12 +-- zone/tribute.cpp | 36 +++---- zone/waypoints.cpp | 6 +- zone/worldserver.cpp | 20 ++-- zone/zone.cpp | 64 ++++++------ zone/zonedb.cpp | 61 ++++++------ zone/zoning.cpp | 24 ++--- 44 files changed, 532 insertions(+), 486 deletions(-) diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index e3ade3520..c2d786d94 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -544,13 +544,7 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name) return; } - Log( - Logs::General, - Logs::Status, - "Starting File Log 'logs/%s_%i.log'", - platform_file_name.c_str(), - getpid() - ); + LogInfo("Starting File Log [logs/{}_{}.log]", platform_file_name.c_str(), getpid()); /** * Make directory if not exists @@ -570,18 +564,11 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name) /** * All other processes */ - if (platform_file_name.empty()) { return; } - Log( - Logs::General, - Logs::Status, - "Starting File Log 'logs/%s_%i.log'", - platform_file_name.c_str(), - getpid() - ); + LogInfo("Starting File Log [logs/{}_{}.log]", platform_file_name.c_str(), getpid()); /** * Open file pointer diff --git a/zone/aa.cpp b/zone/aa.cpp index 425fe6457..ce396c74a 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -84,7 +84,7 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u const NPCType *npc_type = database.LoadNPCTypesData(pet.npc_id); if (npc_type == nullptr) { //log write - Log(Logs::General, Logs::Error, "Unknown npc type for swarm pet spell id: %d", spell_id); + LogError("Unknown npc type for swarm pet spell id: [{}]", spell_id); Message(0, "Unable to find pet!"); return; } @@ -183,7 +183,7 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid const NPCType *npc_type = database.LoadNPCTypesData(typesid); if(npc_type == nullptr) { //log write - Log(Logs::General, Logs::Error, "Unknown npc type for swarm pet type id: %d", typesid); + LogError("Unknown npc type for swarm pet type id: [{}]", typesid); Message(0,"Unable to find pet!"); return; } @@ -1655,7 +1655,7 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_mapid] = std::unique_ptr(ability); } } else { - Log(Logs::General, Logs::Error, "Failed to load Alternate Advancement Abilities"); + LogError("Failed to load Alternate Advancement Abilities"); return false; } @@ -1690,7 +1690,7 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_mapid] = std::unique_ptr(rank); } } else { - Log(Logs::General, Logs::Error, "Failed to load Alternate Advancement Ability Ranks"); + LogError("Failed to load Alternate Advancement Ability Ranks"); return false; } @@ -1717,7 +1717,7 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map= 11 - Log(Logs::General, Logs::Error, "Error in Bot::acmod(): Agility: %i, Level: %i",agility,level); + LogError("Error in Bot::acmod(): Agility: [{}], Level: [{}]",agility,level); #endif return 0; } @@ -2351,7 +2351,7 @@ void Bot::AI_Process() { Mob* delete_me = HealRotationTarget(); if (AIHealRotation(HealRotationTarget(), UseHealRotationFastHeals())) { #if (EQDEBUG >= 12) - Log(Logs::General, Logs::Error, "Bot::AI_Process() - Casting succeeded (m: %s, t: %s) : AdvHR(true)", GetCleanName(), ((delete_me) ? (delete_me->GetCleanName()) : ("nullptr"))); + LogError("Bot::AI_Process() - Casting succeeded (m: [{}], t: [{}]) : AdvHR(true)", GetCleanName(), ((delete_me) ? (delete_me->GetCleanName()) : ("nullptr"))); #endif m_member_of_heal_rotation->SetMemberIsCasting(this); m_member_of_heal_rotation->UpdateTargetHealingStats(HealRotationTarget()); @@ -2359,7 +2359,7 @@ void Bot::AI_Process() { } else { #if (EQDEBUG >= 12) - Log(Logs::General, Logs::Error, "Bot::AI_Process() - Casting failed (m: %s, t: %s) : AdvHR(false)", GetCleanName(), ((delete_me) ? (delete_me->GetCleanName()) : ("nullptr"))); + LogError("Bot::AI_Process() - Casting failed (m: [{}], t: [{}]) : AdvHR(false)", GetCleanName(), ((delete_me) ? (delete_me->GetCleanName()) : ("nullptr"))); #endif m_member_of_heal_rotation->SetMemberIsCasting(this, false); AdvanceHealRotation(false); @@ -4315,7 +4315,7 @@ void Bot::AddToHateList(Mob* other, uint32 hate, int32 damage, bool iYellForHelp bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, bool IsFromSpell, ExtraAttackOptions *opts) { if (!other) { SetTarget(nullptr); - Log(Logs::General, Logs::Error, "A null Mob object was passed to Bot::Attack for evaluation!"); + LogError("A null Mob object was passed to Bot::Attack for evaluation!"); return false; } @@ -8223,7 +8223,7 @@ bool Bot::CheckLoreConflict(const EQEmu::ItemData* item) { bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, float iRange, uint32 iSpellTypes) { if((iSpellTypes & SPELL_TYPES_DETRIMENTAL) != 0) { - Log(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); + LogError("Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); return false; } diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 31270cc0f..df995edf9 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -1061,7 +1061,7 @@ private: std::string query = "SELECT `short_name`, `long_name` FROM `zone` WHERE '' NOT IN (`short_name`, `long_name`)"; auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "load_teleport_zone_names() - Error in zone names query: %s", results.ErrorMessage().c_str()); + LogError("load_teleport_zone_names() - Error in zone names query: [{}]", results.ErrorMessage().c_str()); return; } @@ -1090,7 +1090,7 @@ private: static void status_report() { Log(Logs::General, Logs::Commands, "load_bot_command_spells(): - 'RuleI(Bots, CommandSpellRank)' set to %i.", RuleI(Bots, CommandSpellRank)); if (bot_command_spells.empty()) { - Log(Logs::General, Logs::Error, "load_bot_command_spells() - 'bot_command_spells' is empty."); + LogError("load_bot_command_spells() - 'bot_command_spells' is empty"); return; } @@ -1497,21 +1497,21 @@ void bot_command_deinit(void) int bot_command_add(std::string bot_command_name, const char *desc, int access, BotCmdFuncPtr function) { if (bot_command_name.empty()) { - Log(Logs::General, Logs::Error, "bot_command_add() - Bot command added with empty name string - check bot_command.cpp."); + LogError("bot_command_add() - Bot command added with empty name string - check bot_command.cpp"); return -1; } if (function == nullptr) { - Log(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' added without a valid function pointer - check bot_command.cpp.", bot_command_name.c_str()); + LogError("bot_command_add() - Bot command [{}] added without a valid function pointer - check bot_command.cpp", bot_command_name.c_str()); return -1; } if (bot_command_list.count(bot_command_name) != 0) { - Log(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' is a duplicate bot command name - check bot_command.cpp.", bot_command_name.c_str()); + LogError("bot_command_add() - Bot command [{}] is a duplicate bot command name - check bot_command.cpp", bot_command_name.c_str()); return -1; } for (auto iter : bot_command_list) { if (iter.second->function != function) continue; - Log(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' equates to an alias of '%s' - check bot_command.cpp.", bot_command_name.c_str(), iter.first.c_str()); + LogError("bot_command_add() - Bot command [{}] equates to an alias of [{}] - check bot_command.cpp", bot_command_name.c_str(), iter.first.c_str()); return -1; } @@ -1570,7 +1570,7 @@ int bot_command_real_dispatch(Client *c, const char *message) } if(cur->function == nullptr) { - Log(Logs::General, Logs::Error, "Bot command '%s' has a null function\n", cstr.c_str()); + LogError("Bot command [{}] has a null function\n", cstr.c_str()); return(-1); } else { //dispatch C++ bot command diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index 29d0f37e9..487d42285 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -1121,7 +1121,7 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQEmu::InventoryProfile& invent (uint32)atoul(row[14]) ); if (!item_inst) { - Log(Logs::General, Logs::Error, "Warning: bot_id '%i' has an invalid item_id '%i' in inventory slot '%i'", bot_id, item_id, slot_id); + LogError("Warning: bot_id [{}] has an invalid item_id [{}] in inventory slot [{}]", bot_id, item_id, slot_id); continue; } @@ -1174,7 +1174,7 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQEmu::InventoryProfile& invent item_inst->SetOrnamentHeroModel((uint32)atoul(row[8])); if (inventory_inst.PutItem(slot_id, *item_inst) == INVALID_INDEX) - Log(Logs::General, Logs::Error, "Warning: Invalid slot_id for item in inventory: bot_id = '%i', item_id = '%i', slot_id = '%i'", bot_id, item_id, slot_id); + LogError("Warning: Invalid slot_id for item in inventory: bot_id = [{}], item_id = [{}], slot_id = [{}]", bot_id, item_id, slot_id); safe_delete(item_inst); } diff --git a/zone/client.cpp b/zone/client.cpp index 4b3947af3..4301141d7 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -6234,7 +6234,7 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid PetRecord record; if(!database.GetPetEntry(spells[spell_id].teleport_zone, &record)) { - Log(Logs::General, Logs::Error, "Unknown doppelganger spell id: %d, check pets table", spell_id); + LogError("Unknown doppelganger spell id: [{}], check pets table", spell_id); Message(Chat::Red, "Unable to find data for pet %s", spells[spell_id].teleport_zone); return; } @@ -6248,7 +6248,7 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid const NPCType *npc_type = database.LoadNPCTypesData(pet.npc_id); if(npc_type == nullptr) { - Log(Logs::General, Logs::Error, "Unknown npc type for doppelganger spell id: %d", spell_id); + LogError("Unknown npc type for doppelganger spell id: [{}]", spell_id); Message(0,"Unable to find pet!"); return; } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 65da2b7a3..744bab927 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -946,8 +946,8 @@ void Client::Handle_Connect_OP_ClientError(const EQApplicationPacket *app) } // Client reporting error to server ClientError_Struct* error = (ClientError_Struct*)app->pBuffer; - Log(Logs::General, Logs::Error, "Client error: %s", error->character_name); - Log(Logs::General, Logs::Error, "Error message: %s", error->message); + LogError("Client error: [{}]", error->character_name); + LogError("Error message: [{}]", error->message); Message(Chat::Red, error->message); #if (EQDEBUG>=5) DumpPacket(app); @@ -1085,7 +1085,7 @@ void Client::Handle_Connect_OP_SendTributes(const EQApplicationPacket *app) void Client::Handle_Connect_OP_SetServerFilter(const EQApplicationPacket *app) { if (app->size != sizeof(SetServerFilter_Struct)) { - Log(Logs::General, Logs::Error, "Received invalid sized OP_SetServerFilter"); + LogError("Received invalid sized OP_SetServerFilter"); DumpPacket(app); return; } @@ -1424,7 +1424,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) } if (!database.LoadAlternateAdvancement(this)) { - Log(Logs::General, Logs::Error, "Error loading AA points for %s", GetName()); + LogError("Error loading AA points for [{}]", GetName()); } if (SPDAT_RECORDS > 0) { @@ -1556,7 +1556,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) p_timers.SetCharID(CharacterID()); if (!p_timers.Load(&database)) { - Log(Logs::General, Logs::Error, "Unable to load ability timers from the database for %s (%i)!", GetCleanName(), CharacterID()); + LogError("Unable to load ability timers from the database for [{}] ([{}])!", GetCleanName(), CharacterID()); } /* Load Spell Slot Refresh from Currently Memoried Spells */ @@ -1793,7 +1793,7 @@ void Client::Handle_OP_AdventureInfoRequest(const EQApplicationPacket *app) { if (app->size < sizeof(EntityId_Struct)) { - Log(Logs::General, Logs::Error, "Handle_OP_AdventureInfoRequest had a packet that was too small."); + LogError("Handle_OP_AdventureInfoRequest had a packet that was too small"); return; } EntityId_Struct* ent = (EntityId_Struct*)app->pBuffer; @@ -1848,7 +1848,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) { if (app->size != sizeof(Adventure_Purchase_Struct)) { - Log(Logs::General, Logs::Error, "OP size error: OP_AdventureMerchantPurchase expected:%i got:%i", sizeof(Adventure_Purchase_Struct), app->size); + LogError("OP size error: OP_AdventureMerchantPurchase expected:[{}] got:[{}]", sizeof(Adventure_Purchase_Struct), app->size); return; } @@ -2028,7 +2028,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) { if (app->size != sizeof(AdventureMerchant_Struct)) { - Log(Logs::General, Logs::Error, "OP size error: OP_AdventureMerchantRequest expected:%i got:%i", sizeof(AdventureMerchant_Struct), app->size); + LogError("OP size error: OP_AdventureMerchantRequest expected:[{}] got:[{}]", sizeof(AdventureMerchant_Struct), app->size); return; } std::stringstream ss(std::stringstream::in | std::stringstream::out); @@ -2250,7 +2250,7 @@ void Client::Handle_OP_AdventureRequest(const EQApplicationPacket *app) { if (app->size < sizeof(AdventureRequest_Struct)) { - Log(Logs::General, Logs::Error, "Handle_OP_AdventureRequest had a packet that was too small."); + LogError("Handle_OP_AdventureRequest had a packet that was too small"); return; } @@ -2389,7 +2389,7 @@ void Client::Handle_OP_AdventureStatsRequest(const EQApplicationPacket *app) void Client::Handle_OP_AggroMeterLockTarget(const EQApplicationPacket *app) { if (app->size < sizeof(uint32)) { - Log(Logs::General, Logs::Error, "Handle_OP_AggroMeterLockTarget had a packet that was too small."); + LogError("Handle_OP_AggroMeterLockTarget had a packet that was too small"); return; } @@ -2809,7 +2809,7 @@ void Client::Handle_OP_Animation(const EQApplicationPacket *app) void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app) { if (app->size != sizeof(ApplyPoison_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_ApplyPoison, size=%i, expected %i", app->size, sizeof(ApplyPoison_Struct)); + LogError("Wrong size: OP_ApplyPoison, size=[{}], expected [{}]", app->size, sizeof(ApplyPoison_Struct)); DumpPacket(app); return; } @@ -3000,7 +3000,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) { old_aug = tobe_auged->GetAugment(in_augment->augment_index); if (!old_aug || old_aug->GetItem()->AugDistiller != 0) { - Log(Logs::General, Logs::Error, "Player tried to safely remove an augment without a distiller."); + LogError("Player tried to safely remove an augment without a distiller"); Message(Chat::Red, "Error: Missing an augmentation distiller for safely removing this augment."); return; } @@ -3011,20 +3011,20 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) if (!old_aug) { - Log(Logs::General, Logs::Error, "Player tried to safely remove a nonexistent augment."); + LogError("Player tried to safely remove a nonexistent augment"); Message(Chat::Red, "Error: No augment found in slot %i for safely removing.", in_augment->augment_index); return; } else if (solvent->GetItem()->ID != old_aug->GetItem()->AugDistiller) { - Log(Logs::General, Logs::Error, "Player tried to safely remove an augment with the wrong distiller (item %u vs expected %u).", solvent->GetItem()->ID, old_aug->GetItem()->AugDistiller); + LogError("Player tried to safely remove an augment with the wrong distiller (item [{}] vs expected [{}])", solvent->GetItem()->ID, old_aug->GetItem()->AugDistiller); Message(Chat::Red, "Error: Wrong augmentation distiller for safely removing this augment."); return; } } else if (solvent->GetItem()->ItemType != EQEmu::item::ItemTypePerfectedAugmentationDistiller) { - Log(Logs::General, Logs::Error, "Player tried to safely remove an augment with a non-distiller item."); + LogError("Player tried to safely remove an augment with a non-distiller item"); Message(Chat::Red, "Error: Invalid augmentation distiller for safely removing this augment."); return; } @@ -3038,7 +3038,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) if (!new_aug) // Shouldn't get the OP code without the augment on the user's cursor, but maybe it's h4x. { - Log(Logs::General, Logs::Error, "AugmentItem OpCode with 'Insert' or 'Swap' action received, but no augment on client's cursor."); + LogError("AugmentItem OpCode with 'Insert' or 'Swap' action received, but no augment on client's cursor"); Message(Chat::Red, "Error: No augment found on cursor for inserting."); return; } @@ -3105,7 +3105,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) // This is a swap. Return the old aug to the player's cursor. if (!PutItemInInventory(EQEmu::invslot::slotCursor, *itemTwoToPush, true)) { - Log(Logs::General, Logs::Error, "Problem returning old augment to player's cursor after augmentation swap."); + LogError("Problem returning old augment to player's cursor after augmentation swap"); Message(Chat::Yellow, "Error: Failed to retrieve old augment after augmentation swap!"); } } @@ -3176,7 +3176,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) // Replace it with the unaugmented item if (!PutItemInInventory(item_slot, *itemOneToPush, true)) { - Log(Logs::General, Logs::Error, "Problem returning equipment item to player's inventory after safe augment removal."); + LogError("Problem returning equipment item to player's inventory after safe augment removal"); Message(Chat::Yellow, "Error: Failed to return item after de-augmentation!"); } @@ -3190,7 +3190,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) // Drop the removed augment on the player's cursor if (!PutItemInInventory(EQEmu::invslot::slotCursor, *itemTwoToPush, true)) { - Log(Logs::General, Logs::Error, "Problem returning augment to player's cursor after safe removal."); + LogError("Problem returning augment to player's cursor after safe removal"); Message(Chat::Yellow, "Error: Failed to return augment after removal from item!"); return; } @@ -3230,7 +3230,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) if (!PutItemInInventory(item_slot, *itemOneToPush, true)) { - Log(Logs::General, Logs::Error, "Problem returning equipment item to player's inventory after augment deletion."); + LogError("Problem returning equipment item to player's inventory after augment deletion"); Message(Chat::Yellow, "Error: Failed to return item after destroying augment!"); } } @@ -3259,7 +3259,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) { if (app->size != 4) { - Log(Logs::General, Logs::Error, "OP size error: OP_AutoAttack expected:4 got:%i", app->size); + LogError("OP size error: OP_AutoAttack expected:4 got:[{}]", app->size); return; } @@ -3648,7 +3648,7 @@ void Client::Handle_OP_BazaarSearch(const EQApplicationPacket *app) } else { Log(Logs::Detail, Logs::Trading, "Malformed BazaarSearch_Struct packe, Action %it received, ignoring..."); - Log(Logs::General, Logs::Error, "Malformed BazaarSearch_Struct packet received, ignoring...\n"); + LogError("Malformed BazaarSearch_Struct packet received, ignoring\n"); } return; @@ -3733,13 +3733,13 @@ void Client::Handle_OP_Begging(const EQApplicationPacket *app) void Client::Handle_OP_Bind_Wound(const EQApplicationPacket *app) { if (app->size != sizeof(BindWound_Struct)) { - Log(Logs::General, Logs::Error, "Size mismatch for Bind wound packet"); + LogError("Size mismatch for Bind wound packet"); DumpPacket(app); } BindWound_Struct* bind_in = (BindWound_Struct*)app->pBuffer; Mob* bindmob = entity_list.GetMob(bind_in->to); if (!bindmob) { - Log(Logs::General, Logs::Error, "Bindwound on non-exsistant mob from %s", this->GetName()); + LogError("Bindwound on non-exsistant mob from [{}]", this->GetName()); } else { Log(Logs::General, Logs::None, "BindWound in: to:\'%s\' from=\'%s\'", bindmob->GetName(), GetName()); @@ -3850,7 +3850,7 @@ void Client::Handle_OP_BoardBoat(const EQApplicationPacket *app) // this sends unclean mob name, so capped at 64 // a_boat006 if (app->size <= 5 || app->size > 64) { - Log(Logs::General, Logs::Error, "Size mismatch in OP_BoardBoad. Expected greater than 5 less than 64, got %i", app->size); + LogError("Size mismatch in OP_BoardBoad. Expected greater than 5 less than 64, got [{}]", app->size); DumpPacket(app); return; } @@ -3873,7 +3873,7 @@ void Client::Handle_OP_Buff(const EQApplicationPacket *app) { if (app->size != sizeof(SpellBuffPacket_Struct)) { - Log(Logs::General, Logs::Error, "Size mismatch in OP_Buff. expected %i got %i", sizeof(SpellBuffPacket_Struct), app->size); + LogError("Size mismatch in OP_Buff. expected [{}] got [{}]", sizeof(SpellBuffPacket_Struct), app->size); DumpPacket(app); return; } @@ -3991,7 +3991,7 @@ void Client::Handle_OP_CancelTask(const EQApplicationPacket *app) void Client::Handle_OP_CancelTrade(const EQApplicationPacket *app) { if (app->size != sizeof(CancelTrade_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_CancelTrade, size=%i, expected %i", app->size, sizeof(CancelTrade_Struct)); + LogError("Wrong size: OP_CancelTrade, size=[{}], expected [{}]", app->size, sizeof(CancelTrade_Struct)); return; } Mob* with = trade->With(); @@ -4250,7 +4250,7 @@ void Client::Handle_OP_ClearSurname(const EQApplicationPacket *app) void Client::Handle_OP_ClickDoor(const EQApplicationPacket *app) { if (app->size != sizeof(ClickDoor_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_ClickDoor, size=%i, expected %i", app->size, sizeof(ClickDoor_Struct)); + LogError("Wrong size: OP_ClickDoor, size=[{}], expected [{}]", app->size, sizeof(ClickDoor_Struct)); return; } ClickDoor_Struct* cd = (ClickDoor_Struct*)app->pBuffer; @@ -4335,11 +4335,11 @@ void Client::Handle_OP_ClickObjectAction(const EQApplicationPacket *app) object->Close(); } else { - Log(Logs::General, Logs::Error, "Unsupported action %d in OP_ClickObjectAction", oos->open); + LogError("Unsupported action [{}] in OP_ClickObjectAction", oos->open); } } else { - Log(Logs::General, Logs::Error, "Invalid object %d in OP_ClickObjectAction", oos->drop_id); + LogError("Invalid object [{}] in OP_ClickObjectAction", oos->drop_id); } } @@ -4356,8 +4356,8 @@ void Client::Handle_OP_ClickObjectAction(const EQApplicationPacket *app) void Client::Handle_OP_ClientError(const EQApplicationPacket *app) { ClientError_Struct* error = (ClientError_Struct*)app->pBuffer; - Log(Logs::General, Logs::Error, "Client error: %s", error->character_name); - Log(Logs::General, Logs::Error, "Error message:%s", error->message); + LogError("Client error: [{}]", error->character_name); + LogError("Error message:[{}]", error->message); return; } @@ -4847,7 +4847,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) { if (app->size != sizeof(Consume_Struct)) { - Log(Logs::General, Logs::Error, "OP size error: OP_Consume expected:%i got:%i", sizeof(Consume_Struct), app->size); + LogError("OP size error: OP_Consume expected:[{}] got:[{}]", sizeof(Consume_Struct), app->size); return; } Consume_Struct* pcs = (Consume_Struct*)app->pBuffer; @@ -4884,7 +4884,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) EQEmu::ItemInstance *myitem = GetInv().GetItem(pcs->slot); if (myitem == nullptr) { - Log(Logs::General, Logs::Error, "Consuming from empty slot %d", pcs->slot); + LogError("Consuming from empty slot [{}]", pcs->slot); return; } @@ -4896,7 +4896,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) Consume(eat_item, EQEmu::item::ItemTypeDrink, pcs->slot, (pcs->auto_consumed == 0xffffffff)); } else { - Log(Logs::General, Logs::Error, "OP_Consume: unknown type, type:%i", (int)pcs->type); + LogError("OP_Consume: unknown type, type:[{}]", (int)pcs->type); return; } if (m_pp.hunger_level > 50000) @@ -4917,7 +4917,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) void Client::Handle_OP_ControlBoat(const EQApplicationPacket *app) { if (app->size != sizeof(ControlBoat_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_ControlBoat, size=%i, expected %i", app->size, sizeof(ControlBoat_Struct)); + LogError("Wrong size: OP_ControlBoat, size=[{}], expected [{}]", app->size, sizeof(ControlBoat_Struct)); return; } ControlBoat_Struct* cbs = (ControlBoat_Struct*)app->pBuffer; @@ -5922,7 +5922,7 @@ void Client::Handle_OP_GMBecomeNPC(const EQApplicationPacket *app) return; } if (app->size != sizeof(BecomeNPC_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GMBecomeNPC, size=%i, expected %i", app->size, sizeof(BecomeNPC_Struct)); + LogError("Wrong size: OP_GMBecomeNPC, size=[{}], expected [{}]", app->size, sizeof(BecomeNPC_Struct)); return; } //entity_list.QueueClients(this, app, false); @@ -5974,7 +5974,7 @@ void Client::Handle_OP_GMEmoteZone(const EQApplicationPacket *app) return; } if (app->size != sizeof(GMEmoteZone_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GMEmoteZone, size=%i, expected %i", app->size, sizeof(GMEmoteZone_Struct)); + LogError("Wrong size: OP_GMEmoteZone, size=[{}], expected [{}]", app->size, sizeof(GMEmoteZone_Struct)); return; } GMEmoteZone_Struct* gmez = (GMEmoteZone_Struct*)app->pBuffer; @@ -6007,7 +6007,7 @@ void Client::Handle_OP_GMFind(const EQApplicationPacket *app) return; } if (app->size != sizeof(GMSummon_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GMFind, size=%i, expected %i", app->size, sizeof(GMSummon_Struct)); + LogError("Wrong size: OP_GMFind, size=[{}], expected [{}]", app->size, sizeof(GMSummon_Struct)); return; } //Break down incoming @@ -6072,7 +6072,7 @@ void Client::Handle_OP_GMHideMe(const EQApplicationPacket *app) return; } if (app->size != sizeof(SpawnAppearance_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GMHideMe, size=%i, expected %i", app->size, sizeof(SpawnAppearance_Struct)); + LogError("Wrong size: OP_GMHideMe, size=[{}], expected [{}]", app->size, sizeof(SpawnAppearance_Struct)); return; } SpawnAppearance_Struct* sa = (SpawnAppearance_Struct*)app->pBuffer; @@ -6122,7 +6122,7 @@ void Client::Handle_OP_GMKill(const EQApplicationPacket *app) return; } if (app->size != sizeof(GMKill_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GMKill, size=%i, expected %i", app->size, sizeof(GMKill_Struct)); + LogError("Wrong size: OP_GMKill, size=[{}], expected [{}]", app->size, sizeof(GMKill_Struct)); return; } GMKill_Struct* gmk = (GMKill_Struct *)app->pBuffer; @@ -6189,7 +6189,7 @@ void Client::Handle_OP_GMLastName(const EQApplicationPacket *app) void Client::Handle_OP_GMNameChange(const EQApplicationPacket *app) { if (app->size != sizeof(GMName_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GMNameChange, size=%i, expected %i", app->size, sizeof(GMName_Struct)); + LogError("Wrong size: OP_GMNameChange, size=[{}], expected [{}]", app->size, sizeof(GMName_Struct)); return; } const GMName_Struct* gmn = (const GMName_Struct *)app->pBuffer; @@ -6442,7 +6442,7 @@ void Client::Handle_OP_GMZoneRequest2(const EQApplicationPacket *app) return; } if (app->size < sizeof(uint32)) { - Log(Logs::General, Logs::Error, "OP size error: OP_GMZoneRequest2 expected:%i got:%i", sizeof(uint32), app->size); + LogError("OP size error: OP_GMZoneRequest2 expected:[{}] got:[{}]", sizeof(uint32), app->size); return; } @@ -6664,7 +6664,7 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) } else { - Log(Logs::General, Logs::Error, "Failed to remove player from group. Unable to find player named %s in player group", gd->name2); + LogError("Failed to remove player from group. Unable to find player named [{}] in player group", gd->name2); } } if (LFP) @@ -6812,7 +6812,7 @@ void Client::Handle_OP_GroupMakeLeader(const EQApplicationPacket *app) void Client::Handle_OP_GroupMentor(const EQApplicationPacket *app) { if (app->size != sizeof(GroupMentor_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GroupMentor, size=%i, expected %i", app->size, sizeof(GroupMentor_Struct)); + LogError("Wrong size: OP_GroupMentor, size=[{}], expected [{}]", app->size, sizeof(GroupMentor_Struct)); DumpPacket(app); return; } @@ -6848,7 +6848,7 @@ void Client::Handle_OP_GroupMentor(const EQApplicationPacket *app) void Client::Handle_OP_GroupRoles(const EQApplicationPacket *app) { if (app->size != sizeof(GroupRole_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GroupRoles, size=%i, expected %i", app->size, sizeof(GroupRole_Struct)); + LogError("Wrong size: OP_GroupRoles, size=[{}], expected [{}]", app->size, sizeof(GroupRole_Struct)); DumpPacket(app); return; } @@ -6942,7 +6942,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) } if (app->size < sizeof(uint32)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_GuildBank, size=%i, expected %i", app->size, sizeof(uint32)); + LogError("Wrong size: OP_GuildBank, size=[{}], expected [{}]", app->size, sizeof(uint32)); DumpPacket(app); return; } @@ -6968,7 +6968,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { if ((Action != GuildBankDeposit) && (Action != GuildBankViewItem) && (Action != GuildBankWithdraw)) { - Log(Logs::General, Logs::Error, "Suspected hacking attempt on guild bank from %s", GetName()); + LogError("Suspected hacking attempt on guild bank from [{}]", GetName()); GuildBankAck(); @@ -7129,7 +7129,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) if (!IsGuildBanker() && !GuildBanks->AllowedToWithdraw(GuildID(), gbwis->Area, gbwis->SlotID, GetName())) { - Log(Logs::General, Logs::Error, "Suspected attempted hack on the guild bank from %s", GetName()); + LogError("Suspected attempted hack on the guild bank from [{}]", GetName()); GuildBankAck(); @@ -7200,7 +7200,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { Message(Chat::Red, "Unexpected GuildBank action."); - Log(Logs::General, Logs::Error, "Received unexpected guild bank action code %i from %s", Action, GetName()); + LogError("Received unexpected guild bank action code [{}] from [{}]", Action, GetName()); } } } @@ -8125,7 +8125,7 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) { if (app->size != sizeof(InspectResponse_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_InspectAnswer, size=%i, expected %i", app->size, sizeof(InspectResponse_Struct)); + LogError("Wrong size: OP_InspectAnswer, size=[{}], expected [{}]", app->size, sizeof(InspectResponse_Struct)); return; } @@ -8170,7 +8170,7 @@ void Client::Handle_OP_InspectMessageUpdate(const EQApplicationPacket *app) { if (app->size != sizeof(InspectMessage_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_InspectMessageUpdate, size=%i, expected %i", app->size, sizeof(InspectMessage_Struct)); + LogError("Wrong size: OP_InspectMessageUpdate, size=[{}], expected [{}]", app->size, sizeof(InspectMessage_Struct)); return; } @@ -8184,7 +8184,7 @@ void Client::Handle_OP_InspectRequest(const EQApplicationPacket *app) { if (app->size != sizeof(Inspect_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_InspectRequest, size=%i, expected %i", app->size, sizeof(Inspect_Struct)); + LogError("Wrong size: OP_InspectRequest, size=[{}], expected [{}]", app->size, sizeof(Inspect_Struct)); return; } @@ -8307,7 +8307,7 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) void Client::Handle_OP_ItemLinkResponse(const EQApplicationPacket *app) { if (app->size != sizeof(LDONItemViewRequest_Struct)) { - Log(Logs::General, Logs::Error, "OP size error: OP_ItemLinkResponse expected:%i got:%i", sizeof(LDONItemViewRequest_Struct), app->size); + LogError("OP size error: OP_ItemLinkResponse expected:[{}] got:[{}]", sizeof(LDONItemViewRequest_Struct), app->size); return; } LDONItemViewRequest_Struct* item = (LDONItemViewRequest_Struct*)app->pBuffer; @@ -8522,7 +8522,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) using EQEmu::spells::CastingSlot; if (app->size != sizeof(ItemVerifyRequest_Struct)) { - Log(Logs::General, Logs::Error, "OP size error: OP_ItemVerifyRequest expected:%i got:%i", sizeof(ItemVerifyRequest_Struct), app->size); + LogError("OP size error: OP_ItemVerifyRequest expected:[{}] got:[{}]", sizeof(ItemVerifyRequest_Struct), app->size); return; } @@ -8989,7 +8989,7 @@ void Client::Handle_OP_LFGGetMatchesRequest(const EQApplicationPacket *app) { if (app->size != sizeof(LFGGetMatchesRequest_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_LFGGetMatchesRequest, size=%i, expected %i", app->size, sizeof(LFGGetMatchesRequest_Struct)); + LogError("Wrong size: OP_LFGGetMatchesRequest, size=[{}], expected [{}]", app->size, sizeof(LFGGetMatchesRequest_Struct)); DumpPacket(app); return; } @@ -9151,7 +9151,7 @@ void Client::Handle_OP_LFPCommand(const EQApplicationPacket *app) { if (app->size != sizeof(LFP_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_LFPCommand, size=%i, expected %i", app->size, sizeof(LFP_Struct)); + LogError("Wrong size: OP_LFPCommand, size=[{}], expected [{}]", app->size, sizeof(LFP_Struct)); DumpPacket(app); return; } @@ -9188,7 +9188,7 @@ void Client::Handle_OP_LFPCommand(const EQApplicationPacket *app) // This should not happen. The client checks if you are in a group and will not let you put LFP on if // you are not the leader. if (!g->IsLeader(this)) { - Log(Logs::General, Logs::Error, "Client sent LFP on for character %s who is grouped but not leader.", GetName()); + LogError("Client sent LFP on for character [{}] who is grouped but not leader", GetName()); return; } // Fill the LFPMembers array with the rest of the group members, excluding ourself @@ -9213,7 +9213,7 @@ void Client::Handle_OP_LFPGetMatchesRequest(const EQApplicationPacket *app) { if (app->size != sizeof(LFPGetMatchesRequest_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_LFPGetMatchesRequest, size=%i, expected %i", app->size, sizeof(LFPGetMatchesRequest_Struct)); + LogError("Wrong size: OP_LFPGetMatchesRequest, size=[{}], expected [{}]", app->size, sizeof(LFPGetMatchesRequest_Struct)); DumpPacket(app); return; } @@ -9267,7 +9267,7 @@ void Client::Handle_OP_Logout(const EQApplicationPacket *app) void Client::Handle_OP_LootItem(const EQApplicationPacket *app) { if (app->size != sizeof(LootingItem_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_LootItem, size=%i, expected %i", app->size, sizeof(LootingItem_Struct)); + LogError("Wrong size: OP_LootItem, size=[{}], expected [{}]", app->size, sizeof(LootingItem_Struct)); return; } @@ -9773,7 +9773,7 @@ void Client::Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app) void Client::Handle_OP_MoveCoin(const EQApplicationPacket *app) { if (app->size != sizeof(MoveCoin_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size on OP_MoveCoin. Got: %i, Expected: %i", app->size, sizeof(MoveCoin_Struct)); + LogError("Wrong size on OP_MoveCoin. Got: [{}], Expected: [{}]", app->size, sizeof(MoveCoin_Struct)); DumpPacket(app); return; } @@ -9789,7 +9789,7 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app) } if (app->size != sizeof(MoveItem_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_MoveItem, size=%i, expected %i", app->size, sizeof(MoveItem_Struct)); + LogError("Wrong size: OP_MoveItem, size=[{}], expected [{}]", app->size, sizeof(MoveItem_Struct)); return; } @@ -9934,7 +9934,7 @@ void Client::Handle_OP_OpenTributeMaster(const EQApplicationPacket *app) void Client::Handle_OP_PDeletePetition(const EQApplicationPacket *app) { if (app->size < 2) { - Log(Logs::General, Logs::Error, "Wrong size: OP_PDeletePetition, size=%i, expected %i", app->size, 2); + LogError("Wrong size: OP_PDeletePetition, size=[{}], expected [{}]", app->size, 2); return; } if (petition_list.DeletePetitionByCharName((char*)app->pBuffer)) @@ -9947,7 +9947,7 @@ void Client::Handle_OP_PDeletePetition(const EQApplicationPacket *app) void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) { if (app->size != sizeof(PetCommand_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_PetCommands, size=%i, expected %i", app->size, sizeof(PetCommand_Struct)); + LogError("Wrong size: OP_PetCommands, size=[{}], expected [{}]", app->size, sizeof(PetCommand_Struct)); return; } char val1[20] = { 0 }; @@ -10564,7 +10564,7 @@ void Client::Handle_OP_PetitionBug(const EQApplicationPacket *app) void Client::Handle_OP_PetitionCheckIn(const EQApplicationPacket *app) { if (app->size != sizeof(Petition_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_PetitionCheckIn, size=%i, expected %i", app->size, sizeof(Petition_Struct)); + LogError("Wrong size: OP_PetitionCheckIn, size=[{}], expected [{}]", app->size, sizeof(Petition_Struct)); return; } Petition_Struct* inpet = (Petition_Struct*)app->pBuffer; @@ -10608,7 +10608,7 @@ void Client::Handle_OP_PetitionCheckout(const EQApplicationPacket *app) void Client::Handle_OP_PetitionDelete(const EQApplicationPacket *app) { if (app->size != sizeof(PetitionUpdate_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_PetitionDelete, size=%i, expected %i", app->size, sizeof(PetitionUpdate_Struct)); + LogError("Wrong size: OP_PetitionDelete, size=[{}], expected [{}]", app->size, sizeof(PetitionUpdate_Struct)); return; } auto outapp = new EQApplicationPacket(OP_PetitionUpdate, sizeof(PetitionUpdate_Struct)); @@ -10703,7 +10703,7 @@ void Client::Handle_OP_PickPocket(const EQApplicationPacket *app) { if (app->size != sizeof(PickPocket_Struct)) { - Log(Logs::General, Logs::Error, "Size mismatch for Pick Pocket packet"); + LogError("Size mismatch for Pick Pocket packet"); DumpPacket(app); } @@ -11071,7 +11071,7 @@ void Client::Handle_OP_QueryUCSServerStatus(const EQApplicationPacket *app) void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) { if (app->size < sizeof(RaidGeneral_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_RaidCommand, size=%i, expected at least %i", app->size, sizeof(RaidGeneral_Struct)); + LogError("Wrong size: OP_RaidCommand, size=[{}], expected at least [{}]", app->size, sizeof(RaidGeneral_Struct)); DumpPacket(app); return; } @@ -11690,7 +11690,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) void Client::Handle_OP_RandomReq(const EQApplicationPacket *app) { if (app->size != sizeof(RandomReq_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_RandomReq, size=%i, expected %i", app->size, sizeof(RandomReq_Struct)); + LogError("Wrong size: OP_RandomReq, size=[{}], expected [{}]", app->size, sizeof(RandomReq_Struct)); return; } const RandomReq_Struct* rndq = (const RandomReq_Struct*)app->pBuffer; @@ -11719,7 +11719,7 @@ void Client::Handle_OP_RandomReq(const EQApplicationPacket *app) void Client::Handle_OP_ReadBook(const EQApplicationPacket *app) { if (app->size != sizeof(BookRequest_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_ReadBook, size=%i, expected %i", app->size, sizeof(BookRequest_Struct)); + LogError("Wrong size: OP_ReadBook, size=[{}], expected [{}]", app->size, sizeof(BookRequest_Struct)); return; } BookRequest_Struct* book = (BookRequest_Struct*)app->pBuffer; @@ -11787,7 +11787,7 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) auto item = database.GetItem(tsf->some_id); if (!item) { - Log(Logs::General, Logs::Error, "Invalid container ID: %d. GetItem returned null. Defaulting to BagSlots = 10.\n", tsf->some_id); + LogError("Invalid container ID: [{}]. GetItem returned null. Defaulting to BagSlots = 10.\n", tsf->some_id); combineObjectSlots = 10; } else @@ -11861,7 +11861,7 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app) auto item = database.GetItem(rss->some_id); if (!item) { - Log(Logs::General, Logs::Error, "Invalid container ID: %d. GetItem returned null. Defaulting to BagSlots = 10.\n", rss->some_id); + LogError("Invalid container ID: [{}]. GetItem returned null. Defaulting to BagSlots = 10.\n", rss->some_id); combineObjectSlots = 10; } else @@ -12159,7 +12159,7 @@ void Client::Handle_OP_Sacrifice(const EQApplicationPacket *app) Sacrifice_Struct *ss = (Sacrifice_Struct*)app->pBuffer; if (!PendingSacrifice) { - Log(Logs::General, Logs::Error, "Unexpected OP_Sacrifice reply"); + LogError("Unexpected OP_Sacrifice reply"); DumpPacket(app); return; } @@ -12202,7 +12202,7 @@ void Client::Handle_OP_SelectTribute(const EQApplicationPacket *app) //we should enforce being near a real tribute master to change this //but im not sure how I wanna do that right now. if (app->size != sizeof(SelectTributeReq_Struct)) - Log(Logs::General, Logs::Error, "Invalid size on OP_SelectTribute packet"); + LogError("Invalid size on OP_SelectTribute packet"); else { SelectTributeReq_Struct *t = (SelectTributeReq_Struct *)app->pBuffer; SendTributeDetails(t->client_id, t->tribute_id); @@ -12354,7 +12354,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) } if (app->size < 1) { - Log(Logs::General, Logs::Error, "Wrong size: OP_SetStartCity, size=%i, expected %i", app->size, 1); + LogError("Wrong size: OP_SetStartCity, size=[{}], expected [{}]", app->size, 1); DumpPacket(app); return; } @@ -12368,7 +12368,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) m_pp.class_, m_pp.deity, m_pp.race); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "No valid start zones found for /setstartcity"); + LogError("No valid start zones found for /setstartcity"); return; } @@ -12443,7 +12443,7 @@ void Client::Handle_OP_SetTitle(const EQApplicationPacket *app) void Client::Handle_OP_Shielding(const EQApplicationPacket *app) { if (app->size != sizeof(Shielding_Struct)) { - Log(Logs::General, Logs::Error, "OP size error: OP_Shielding expected:%i got:%i", sizeof(Shielding_Struct), app->size); + LogError("OP size error: OP_Shielding expected:[{}] got:[{}]", sizeof(Shielding_Struct), app->size); return; } if (GetClass() != WARRIOR) @@ -12704,7 +12704,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) SendItemPacket(freeslotid, inst, ItemPacketTrade); } else if (!stacked) { - Log(Logs::General, Logs::Error, "OP_ShopPlayerBuy: item->ItemClass Unknown! Type: %i", item->ItemClass); + LogError("OP_ShopPlayerBuy: item->ItemClass Unknown! Type: [{}]", item->ItemClass); } QueuePacket(outapp); if (inst && tmpmer_used) { @@ -12997,7 +12997,7 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app) { if (app->size != sizeof(Merchant_Click_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_ShopRequest, size=%i, expected %i", app->size, sizeof(Merchant_Click_Struct)); + LogError("Wrong size: OP_ShopRequest, size=[{}], expected [{}]", app->size, sizeof(Merchant_Click_Struct)); return; } @@ -13204,7 +13204,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) } else { - Log(Logs::Detail, Logs::Error, "Client %s :: unknown appearance %i", name, (int)sa->parameter); + LogError("Client [{}] :: unknown appearance [{}]", name, (int)sa->parameter); return; } @@ -13226,7 +13226,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) m_pp.anon = 0; } else { - Log(Logs::Detail, Logs::Error, "Client %s :: unknown Anon/Roleplay Switch %i", name, (int)sa->parameter); + LogError("Client [{}] :: unknown Anon/Roleplay Switch [{}]", name, (int)sa->parameter); return; } entity_list.QueueClients(this, app, true); @@ -13295,7 +13295,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) void Client::Handle_OP_Split(const EQApplicationPacket *app) { if (app->size != sizeof(Split_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_Split, size=%i, expected %i", app->size, sizeof(Split_Struct)); + LogError("Wrong size: OP_Split, size=[{}], expected [{}]", app->size, sizeof(Split_Struct)); return; } // The client removes the money on its own, but we have to @@ -13425,7 +13425,7 @@ void Client::Handle_OP_SwapSpell(const EQApplicationPacket *app) void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) { if (app->size != sizeof(ClientTarget_Struct)) { - Log(Logs::General, Logs::Error, "OP size error: OP_TargetMouse expected:%i got:%i", sizeof(ClientTarget_Struct), app->size); + LogError("OP size error: OP_TargetMouse expected:[{}] got:[{}]", sizeof(ClientTarget_Struct), app->size); return; } @@ -13706,7 +13706,7 @@ void Client::Handle_OP_Track(const EQApplicationPacket *app) CheckIncreaseSkill(EQEmu::skills::SkillTracking, nullptr, 15); if (!entity_list.MakeTrackPacket(this)) - Log(Logs::General, Logs::Error, "Unable to generate OP_Track packet requested by client."); + LogError("Unable to generate OP_Track packet requested by client"); return; } @@ -13895,7 +13895,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) void Client::Handle_OP_TradeBusy(const EQApplicationPacket *app) { if (app->size != sizeof(TradeBusy_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_TradeBusy, size=%i, expected %i", app->size, sizeof(TradeBusy_Struct)); + LogError("Wrong size: OP_TradeBusy, size=[{}], expected [{}]", app->size, sizeof(TradeBusy_Struct)); return; } // Trade request recipient is cancelling the trade due to being busy @@ -14041,7 +14041,7 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Unknown TraderStruct code of: %i\n", ints->Code); - Log(Logs::General, Logs::Error, "Unknown TraderStruct code of: %i\n", ints->Code); + LogError("Unknown TraderStruct code of: [{}]\n", ints->Code); } } else if (app->size == sizeof(TraderStatus_Struct)) @@ -14077,7 +14077,7 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) } else { Log(Logs::Detail, Logs::Trading, "Unknown size for OP_Trader: %i\n", app->size); - Log(Logs::General, Logs::Error, "Unknown size for OP_Trader: %i\n", app->size); + LogError("Unknown size for OP_Trader: [{}]\n", app->size); DumpPacket(app); return; } @@ -14092,7 +14092,7 @@ void Client::Handle_OP_TraderBuy(const EQApplicationPacket *app) // Client has elected to buy an item from a Trader // if (app->size != sizeof(TraderBuy_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_TraderBuy, size=%i, expected %i", app->size, sizeof(TraderBuy_Struct)); + LogError("Wrong size: OP_TraderBuy, size=[{}], expected [{}]", app->size, sizeof(TraderBuy_Struct)); return; } @@ -14113,7 +14113,7 @@ void Client::Handle_OP_TraderBuy(const EQApplicationPacket *app) void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app) { if (app->size != sizeof(TradeRequest_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_TradeRequest, size=%i, expected %i", app->size, sizeof(TradeRequest_Struct)); + LogError("Wrong size: OP_TradeRequest, size=[{}], expected [{}]", app->size, sizeof(TradeRequest_Struct)); return; } // Client requesting a trade session from an npc/client @@ -14149,7 +14149,7 @@ void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app) void Client::Handle_OP_TradeRequestAck(const EQApplicationPacket *app) { if (app->size != sizeof(TradeRequest_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size: OP_TradeRequestAck, size=%i, expected %i", app->size, sizeof(TradeRequest_Struct)); + LogError("Wrong size: OP_TradeRequestAck, size=[{}], expected [{}]", app->size, sizeof(TradeRequest_Struct)); return; } // Trade request recipient is acknowledging they are able to trade @@ -14283,7 +14283,7 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app) else { Log(Logs::Detail, Logs::Trading, "Unknown size for OP_TraderShop: %i\n", app->size); - Log(Logs::General, Logs::Error, "Unknown size for OP_TraderShop: %i\n", app->size); + LogError("Unknown size for OP_TraderShop: [{}]\n", app->size); DumpPacket(app); return; } @@ -14425,7 +14425,7 @@ void Client::Handle_OP_TributeToggle(const EQApplicationPacket *app) Log(Logs::Detail, Logs::Tribute, "Received OP_TributeToggle of length %d", app->size); if (app->size != sizeof(uint32)) - Log(Logs::General, Logs::Error, "Invalid size on OP_TributeToggle packet"); + LogError("Invalid size on OP_TributeToggle packet"); else { uint32 *val = (uint32 *)app->pBuffer; ToggleTribute(*val ? true : false); @@ -14439,7 +14439,7 @@ void Client::Handle_OP_TributeUpdate(const EQApplicationPacket *app) //sent when the client changes their tribute settings... if (app->size != sizeof(TributeInfo_Struct)) - Log(Logs::General, Logs::Error, "Invalid size on OP_TributeUpdate packet"); + LogError("Invalid size on OP_TributeUpdate packet"); else { TributeInfo_Struct *t = (TributeInfo_Struct *)app->pBuffer; ChangeTributeSettings(t); diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 7ebe002c5..d0f91c726 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1052,7 +1052,7 @@ void Client::OPMemorizeSpell(const EQApplicationPacket* app) { if(app->size != sizeof(MemorizeSpell_Struct)) { - Log(Logs::General, Logs::Error, "Wrong size on OP_MemorizeSpell. Got: %i, Expected: %i", app->size, sizeof(MemorizeSpell_Struct)); + LogError("Wrong size on OP_MemorizeSpell. Got: [{}], Expected: [{}]", app->size, sizeof(MemorizeSpell_Struct)); DumpPacket(app); return; } diff --git a/zone/command.cpp b/zone/command.cpp index e8689ffb2..162fe06ac 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -519,21 +519,21 @@ void command_deinit(void) int command_add(std::string command_name, const char *desc, int access, CmdFuncPtr function) { if (command_name.empty()) { - Log(Logs::General, Logs::Error, "command_add() - Command added with empty name string - check command.cpp."); + LogError("command_add() - Command added with empty name string - check command.cpp"); return -1; } if (function == nullptr) { - Log(Logs::General, Logs::Error, "command_add() - Command '%s' added without a valid function pointer - check command.cpp.", command_name.c_str()); + LogError("command_add() - Command [{}] added without a valid function pointer - check command.cpp", command_name.c_str()); return -1; } if (commandlist.count(command_name) != 0) { - Log(Logs::General, Logs::Error, "command_add() - Command '%s' is a duplicate command name - check command.cpp.", command_name.c_str()); + LogError("command_add() - Command [{}] is a duplicate command name - check command.cpp", command_name.c_str()); return -1; } for (auto iter = commandlist.begin(); iter != commandlist.end(); ++iter) { if (iter->second->function != function) continue; - Log(Logs::General, Logs::Error, "command_add() - Command '%s' equates to an alias of '%s' - check command.cpp.", command_name.c_str(), iter->first.c_str()); + LogError("command_add() - Command [{}] equates to an alias of [{}] - check command.cpp", command_name.c_str(), iter->first.c_str()); return -1; } @@ -591,7 +591,7 @@ int command_realdispatch(Client *c, const char *message) } if(cur->function == nullptr) { - Log(Logs::General, Logs::Error, "Command '%s' has a null function\n", cstr.c_str()); + LogError("Command [{}] has a null function\n", cstr.c_str()); return(-1); } else { //dispatch C++ command diff --git a/zone/corpse.cpp b/zone/corpse.cpp index e3a5eb80e..91bc304af 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -836,7 +836,7 @@ bool Corpse::Process() { Log(Logs::General, Logs::None, "Tagged %s player corpse has buried.", this->GetName()); } else { - Log(Logs::General, Logs::Error, "Unable to bury %s player corpse.", this->GetName()); + LogError("Unable to bury [{}] player corpse", this->GetName()); return true; } } diff --git a/zone/effects.cpp b/zone/effects.cpp index 25923b35f..ba82cf3f0 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -435,7 +435,7 @@ bool Client::TrainDiscipline(uint32 itemid) { const EQEmu::ItemData *item = database.GetItem(itemid); if(item == nullptr) { Message(Chat::Red, "Unable to find the tome you turned in!"); - Log(Logs::General, Logs::Error, "Unable to find turned in tome id %lu\n", (unsigned long)itemid); + LogError("Unable to find turned in tome id [{}]\n", (unsigned long)itemid); return(false); } diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 4934ac212..b0db3039f 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -3747,7 +3747,7 @@ EXTERN_C XS(boot_quest) { file[255] = '\0'; if (items != 1) - Log(Logs::General, Logs::Error, "boot_quest does not take any arguments."); + LogError("boot_quest does not take any arguments"); char buf[128]; //shouldent have any function names longer than this. diff --git a/zone/embxs.cpp b/zone/embxs.cpp index 3816850db..b9013335b 100644 --- a/zone/embxs.cpp +++ b/zone/embxs.cpp @@ -68,7 +68,7 @@ EXTERN_C XS(boot_qc) file[255] = '\0'; if(items != 1) - Log(Logs::General, Logs::Error, "boot_qc does not take any arguments."); + LogError("boot_qc does not take any arguments"); char buf[128]; //shouldent have any function names longer than this. diff --git a/zone/entity.cpp b/zone/entity.cpp index 2a1c76101..507bc87e3 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -76,12 +76,12 @@ Entity::~Entity() Client *Entity::CastToClient() { if (this == 0x00) { - Log(Logs::General, Logs::Error, "CastToClient error (nullptr)"); + LogError("CastToClient error (nullptr)"); return 0; } #ifdef _EQDEBUG if (!IsClient()) { - Log(Logs::General, Logs::Error, "CastToClient error (not client)"); + LogError("CastToClient error (not client)"); return 0; } #endif @@ -93,7 +93,7 @@ NPC *Entity::CastToNPC() { #ifdef _EQDEBUG if (!IsNPC()) { - Log(Logs::General, Logs::Error, "CastToNPC error (Not NPC)"); + LogError("CastToNPC error (Not NPC)"); return 0; } #endif @@ -377,7 +377,7 @@ void EntityList::CheckGroupList (const char *fname, const int fline) { if (*it == nullptr) { - Log(Logs::General, Logs::Error, "nullptr group, %s:%i", fname, fline); + LogError("nullptr group, [{}]:[{}]", fname, fline); } } } @@ -540,12 +540,12 @@ void EntityList::MobProcess() zone->StartShutdownTimer(); Group *g = GetGroupByMob(mob); if(g) { - Log(Logs::General, Logs::Error, "About to delete a client still in a group."); + LogError("About to delete a client still in a group"); g->DelMember(mob); } Raid *r = entity_list.GetRaidByClient(mob->CastToClient()); if(r) { - Log(Logs::General, Logs::Error, "About to delete a client still in a raid."); + LogError("About to delete a client still in a raid"); r->MemberZoned(mob->CastToClient()); } entity_list.RemoveClient(id); @@ -817,7 +817,7 @@ void EntityList::CheckSpawnQueue() auto it = npc_list.find(ns->spawn.spawnId); if (it == npc_list.end()) { // We must of despawned, hope that's the reason! - Log(Logs::General, Logs::Error, "Error in EntityList::CheckSpawnQueue: Unable to find NPC for spawnId '%u'", ns->spawn.spawnId); + LogError("Error in EntityList::CheckSpawnQueue: Unable to find NPC for spawnId [{}]", ns->spawn.spawnId); } else { NPC *pnpc = it->second; @@ -2877,7 +2877,7 @@ char *EntityList::MakeNameUnique(char *name) return name; } } - Log(Logs::General, Logs::Error, "Fatal error in EntityList::MakeNameUnique: Unable to find unique name for '%s'", name); + LogError("Fatal error in EntityList::MakeNameUnique: Unable to find unique name for [{}]", name); char tmp[64] = "!"; strn0cpy(&tmp[1], name, sizeof(tmp) - 1); strcpy(name, tmp); diff --git a/zone/exp.cpp b/zone/exp.cpp index 23593f644..7af85ee1c 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -765,7 +765,7 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { void Client::SetLevel(uint8 set_level, bool command) { if (GetEXPForLevel(set_level) == 0xFFFFFFFF) { - Log(Logs::General, Logs::Error, "Client::SetLevel() GetEXPForLevel(%i) = 0xFFFFFFFF", set_level); + LogError("Client::SetLevel() GetEXPForLevel([{}]) = 0xFFFFFFFF", set_level); return; } @@ -1131,15 +1131,16 @@ uint32 Client::GetCharMaxLevelFromQGlobal() { return 0; } -uint32 Client::GetCharMaxLevelFromBucket() { - uint32 char_id = this->CharacterID(); - std::string query = StringFormat("SELECT value FROM data_buckets WHERE `key` = '%i-CharMaxLevel'", char_id); - auto results = database.QueryDatabase(query); +uint32 Client::GetCharMaxLevelFromBucket() +{ + uint32 char_id = this->CharacterID(); + std::string query = StringFormat("SELECT value FROM data_buckets WHERE `key` = '%i-CharMaxLevel'", char_id); + auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Data bucket for CharMaxLevel for char ID %i failed.", char_id); - return 0; - } - + LogError("Data bucket for CharMaxLevel for char ID [{}] failed", char_id); + return 0; + } + if (results.RowCount() > 0) { auto row = results.begin(); return atoi(row[0]); diff --git a/zone/forage.cpp b/zone/forage.cpp index 12d2f61a1..3c69dce19 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -62,17 +62,17 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) { return 0; } - uint8 index = 0; - for (auto row = results.begin(); row != results.end(); ++row, ++index) { - if (index >= FORAGE_ITEM_LIMIT) - break; - - item[index] = atoi(row[0]); - chance[index] = atoi(row[1]) + chancepool; - Log(Logs::General, Logs::Error, "Possible Forage: %d with a %d chance", item[index], chance[index]); - chancepool = chance[index]; - } + uint8 index = 0; + for (auto row = results.begin(); row != results.end(); ++row, ++index) { + if (index >= FORAGE_ITEM_LIMIT) { + break; + } + item[index] = atoi(row[0]); + chance[index] = atoi(row[1]) + chancepool; + LogError("Possible Forage: [{}] with a [{}] chance", item[index], chance[index]); + chancepool = chance[index]; + } if(chancepool == 0 || index < 1) return 0; @@ -413,7 +413,7 @@ void Client::ForageItem(bool guarantee) { const EQEmu::ItemData* food_item = database.GetItem(foragedfood); if(!food_item) { - Log(Logs::General, Logs::Error, "nullptr returned from database.GetItem in ClientForageItem"); + LogError("nullptr returned from database.GetItem in ClientForageItem"); return; } diff --git a/zone/groups.cpp b/zone/groups.cpp index cef37fbda..b5bab9a67 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -1177,10 +1177,15 @@ bool Group::LearnMembers() { if (!results.Success()) return false; - if (results.RowCount() == 0) { - Log(Logs::General, Logs::Error, "Error getting group members for group %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); - return false; - } + if (results.RowCount() == 0) { + LogError( + "Error getting group members for group [{}]: [{}]", + (unsigned long) GetID(), + results.ErrorMessage().c_str() + ); + + return false; + } int memberIndex = 0; for(auto row = results.begin(); row != results.end(); ++row) { @@ -1566,7 +1571,7 @@ void Group::DelegateMainTank(const char *NewMainTankName, uint8 toggle) MainTankName.c_str(), GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to set group main tank: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to set group main tank: [{}]\n", results.ErrorMessage().c_str()); } } @@ -1612,7 +1617,7 @@ void Group::DelegateMainAssist(const char *NewMainAssistName, uint8 toggle) MainAssistName.c_str(), GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to set group main assist: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to set group main assist: [{}]\n", results.ErrorMessage().c_str()); } } @@ -1659,7 +1664,7 @@ void Group::DelegatePuller(const char *NewPullerName, uint8 toggle) PullerName.c_str(), GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to set group main puller: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to set group main puller: [{}]\n", results.ErrorMessage().c_str()); } @@ -1810,7 +1815,7 @@ void Group::UnDelegateMainTank(const char *OldMainTankName, uint8 toggle) std::string query = StringFormat("UPDATE group_leaders SET maintank = '' WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to clear group main tank: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to clear group main tank: [{}]\n", results.ErrorMessage().c_str()); if(!toggle) { for(uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i) { @@ -1859,7 +1864,7 @@ void Group::UnDelegateMainAssist(const char *OldMainAssistName, uint8 toggle) std::string query = StringFormat("UPDATE group_leaders SET assist = '' WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to clear group main assist: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to clear group main assist: [{}]\n", results.ErrorMessage().c_str()); if(!toggle) { @@ -1887,7 +1892,7 @@ void Group::UnDelegatePuller(const char *OldPullerName, uint8 toggle) std::string query = StringFormat("UPDATE group_leaders SET puller = '' WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to clear group main puller: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to clear group main puller: [{}]\n", results.ErrorMessage().c_str()); if(!toggle) { for(uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i) { @@ -1970,7 +1975,7 @@ void Group::SetGroupMentor(int percent, char *name) mentoree_name.c_str(), mentor_percent, GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to set group mentor: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to set group mentor: [{}]\n", results.ErrorMessage().c_str()); } void Group::ClearGroupMentor() @@ -1981,7 +1986,7 @@ void Group::ClearGroupMentor() std::string query = StringFormat("UPDATE group_leaders SET mentoree = '', mentor_percent = 0 WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to clear group mentor: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to clear group mentor: [{}]\n", results.ErrorMessage().c_str()); } void Group::NotifyAssistTarget(Client *c) @@ -2051,7 +2056,7 @@ void Group::DelegateMarkNPC(const char *NewNPCMarkerName) NewNPCMarkerName, GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to set group mark npc: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to set group mark npc: [{}]\n", results.ErrorMessage().c_str()); } void Group::NotifyMarkNPC(Client *c) @@ -2132,7 +2137,7 @@ void Group::UnDelegateMarkNPC(const char *OldNPCMarkerName) std::string query = StringFormat("UPDATE group_leaders SET marknpc = '' WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to clear group marknpc: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to clear group marknpc: [{}]\n", results.ErrorMessage().c_str()); } @@ -2149,7 +2154,7 @@ void Group::SaveGroupLeaderAA() safe_delete_array(queryBuffer); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to store LeadershipAA: [{}]\n", results.ErrorMessage().c_str()); } diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index eacfcb474..76af85149 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -261,7 +261,7 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { switch(pack->opcode) { case ServerOP_RefreshGuild: { if(pack->size != sizeof(ServerGuildRefresh_Struct)) { - Log(Logs::General, Logs::Error, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildRefresh_Struct)); + LogError("Received ServerOP_RefreshGuild of incorrect size [{}], expected [{}]", pack->size, sizeof(ServerGuildRefresh_Struct)); return; } ServerGuildRefresh_Struct *s = (ServerGuildRefresh_Struct *) pack->pBuffer; @@ -295,7 +295,7 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { case ServerOP_GuildCharRefresh: { if(pack->size != sizeof(ServerGuildCharRefresh_Struct)) { - Log(Logs::General, Logs::Error, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildCharRefresh_Struct)); + LogError("Received ServerOP_RefreshGuild of incorrect size [{}], expected [{}]", pack->size, sizeof(ServerGuildCharRefresh_Struct)); return; } ServerGuildCharRefresh_Struct *s = (ServerGuildCharRefresh_Struct *) pack->pBuffer; @@ -364,7 +364,7 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { case ServerOP_DeleteGuild: { if(pack->size != sizeof(ServerGuildID_Struct)) { - Log(Logs::General, Logs::Error, "Received ServerOP_DeleteGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildID_Struct)); + LogError("Received ServerOP_DeleteGuild of incorrect size [{}], expected [{}]", pack->size, sizeof(ServerGuildID_Struct)); return; } ServerGuildID_Struct *s = (ServerGuildID_Struct *) pack->pBuffer; @@ -683,7 +683,7 @@ void GuildBankManager::SendGuildBank(Client *c) if(Iterator == Banks.end()) { - Log(Logs::General, Logs::Error, "Unable to find guild bank for guild ID %i", c->GuildID()); + LogError("Unable to find guild bank for guild ID [{}]", c->GuildID()); return; } @@ -856,7 +856,7 @@ bool GuildBankManager::AddItem(uint32 GuildID, uint8 Area, uint32 ItemID, int32 if(Iterator == Banks.end()) { - Log(Logs::General, Logs::Error, "Unable to find guild bank for guild ID %i", GuildID); + LogError("Unable to find guild bank for guild ID [{}]", GuildID); return false; } @@ -902,7 +902,7 @@ bool GuildBankManager::AddItem(uint32 GuildID, uint8 Area, uint32 ItemID, int32 if(Slot < 0) { - Log(Logs::General, Logs::Error, "No space to add item to the guild bank."); + LogError("No space to add item to the guild bank"); return false; } diff --git a/zone/heal_rotation.cpp b/zone/heal_rotation.cpp index 489d1ab45..55d0c1e1d 100644 --- a/zone/heal_rotation.cpp +++ b/zone/heal_rotation.cpp @@ -170,7 +170,7 @@ bool HealRotation::ClearMemberPool() m_active_heal_target = false; if (!ClearTargetPool()) - Log(Logs::General, Logs::Error, "HealRotation::ClearTargetPool() failed to clear m_target_pool (size: %u)", m_target_pool.size()); + LogError("HealRotation::ClearTargetPool() failed to clear m_target_pool (size: [{}])", m_target_pool.size()); auto clear_list = const_cast&>(m_member_pool); for (auto member_iter : clear_list) @@ -871,37 +871,37 @@ void HealRotation::bias_targets() m_casting_target_poke = true; #if (EQDEBUG >= 12) - Log(Logs::General, Logs::Error, "HealRotation::bias_targets() - *** Post-processing state ***"); - Log(Logs::General, Logs::Error, "HealRotation Settings:"); - Log(Logs::General, Logs::Error, "HealRotation::m_interval_ms = %u", m_interval_ms); - Log(Logs::General, Logs::Error, "HealRotation::m_next_cast_time_ms = %u (current_time: %u, time_diff: %i)", m_next_cast_time_ms, Timer::GetCurrentTime(), ((int32)Timer::GetCurrentTime() - (int32)m_next_cast_time_ms)); - Log(Logs::General, Logs::Error, "HealRotation::m_next_poke_time_ms = %u (current_time: %u, time_diff: %i)", m_next_poke_time_ms, Timer::GetCurrentTime(), ((int32)Timer::GetCurrentTime() - (int32)m_next_poke_time_ms)); - Log(Logs::General, Logs::Error, "HealRotation::m_fast_heals = %s", ((m_fast_heals) ? ("true") : ("false"))); - Log(Logs::General, Logs::Error, "HealRotation::m_adaptive_targeting = %s", ((m_adaptive_targeting) ? ("true") : ("false"))); - Log(Logs::General, Logs::Error, "HealRotation::m_casting_override = %s", ((m_casting_override) ? ("true") : ("false"))); - Log(Logs::General, Logs::Error, "HealRotation::m_casting_target_poke = %s", ((m_casting_target_poke) ? ("true") : ("false"))); - Log(Logs::General, Logs::Error, "HealRotation::m_active_heal_target = %s", ((m_active_heal_target) ? ("true") : ("false"))); - Log(Logs::General, Logs::Error, "HealRotation::m_is_active = %s", ((m_is_active) ? ("true") : ("false"))); - Log(Logs::General, Logs::Error, "HealRotation::m_member_list.size() = %i", m_member_pool.size()); - Log(Logs::General, Logs::Error, "HealRotation::m_cycle_list.size() = %i", m_cycle_pool.size()); - Log(Logs::General, Logs::Error, "HealRotation::m_target_list.size() = %i", m_target_pool.size()); - if (m_member_pool.size()) { Log(Logs::General, Logs::Error, "(std::shared_ptr::use_count() = %i", m_member_pool.front()->MemberOfHealRotation()->use_count()); } - else { Log(Logs::General, Logs::Error, "(std::shared_ptr::use_count() = unknown (0)"); } - Log(Logs::General, Logs::Error, "HealRotation Members:"); + LogError("HealRotation::bias_targets() - *** Post-processing state ***"); + LogError("HealRotation Settings:"); + LogError("HealRotation::m_interval_ms = [{}]", m_interval_ms); + LogError("HealRotation::m_next_cast_time_ms = [{}] (current_time: [{}], time_diff: [{}])", m_next_cast_time_ms, Timer::GetCurrentTime(), ((int32)Timer::GetCurrentTime() - (int32)m_next_cast_time_ms)); + LogError("HealRotation::m_next_poke_time_ms = [{}] (current_time: [{}], time_diff: [{}])", m_next_poke_time_ms, Timer::GetCurrentTime(), ((int32)Timer::GetCurrentTime() - (int32)m_next_poke_time_ms)); + LogError("HealRotation::m_fast_heals = [{}]", ((m_fast_heals) ? ("true") : ("false"))); + LogError("HealRotation::m_adaptive_targeting = [{}]", ((m_adaptive_targeting) ? ("true") : ("false"))); + LogError("HealRotation::m_casting_override = [{}]", ((m_casting_override) ? ("true") : ("false"))); + LogError("HealRotation::m_casting_target_poke = [{}]", ((m_casting_target_poke) ? ("true") : ("false"))); + LogError("HealRotation::m_active_heal_target = [{}]", ((m_active_heal_target) ? ("true") : ("false"))); + LogError("HealRotation::m_is_active = [{}]", ((m_is_active) ? ("true") : ("false"))); + LogError("HealRotation::m_member_list.size() = [{}]", m_member_pool.size()); + LogError("HealRotation::m_cycle_list.size() = [{}]", m_cycle_pool.size()); + LogError("HealRotation::m_target_list.size() = [{}]", m_target_pool.size()); + if (m_member_pool.size()) { LogError("(std::shared_ptr::use_count() = [{}]", m_member_pool.front()->MemberOfHealRotation()->use_count()); } + else { LogError("(std::shared_ptr::use_count() = unknown (0)"); } + LogError("HealRotation Members:"); int member_index = 0; for (auto mlist_iter : m_member_pool) { if (!mlist_iter) { continue; } - Log(Logs::General, Logs::Error, "(%i) %s (hrcast: %c)", (++member_index), mlist_iter->GetCleanName(), ((mlist_iter->AmICastingForHealRotation())?('T'):('F'))); + LogError("([{}]) [{}] (hrcast: [{}])", (++member_index), mlist_iter->GetCleanName(), ((mlist_iter->AmICastingForHealRotation())?('T'):('F'))); } - if (!member_index) { Log(Logs::General, Logs::Error, "(0) None"); } - Log(Logs::General, Logs::Error, "HealRotation Cycle:"); + if (!member_index) { LogError("(0) None"); } + LogError("HealRotation Cycle:"); int cycle_index = 0; for (auto clist_iter : m_cycle_pool) { if (!clist_iter) { continue; } - Log(Logs::General, Logs::Error, "(%i) %s", (++cycle_index), clist_iter->GetCleanName()); + LogError("([{}]) [{}]", (++cycle_index), clist_iter->GetCleanName()); } - if (!cycle_index) { Log(Logs::General, Logs::Error, "(0) None"); } - Log(Logs::General, Logs::Error, "HealRotation Targets: (sort type: %u)", sort_type); + if (!cycle_index) { LogError("(0) None"); } + LogError("HealRotation Targets: (sort type: [{}])", sort_type); int target_index = 0; for (auto tlist_iter : m_target_pool) { @@ -920,7 +920,7 @@ void HealRotation::bias_targets() tlist_iter->HealRotationHealFrequency(), tlist_iter->HealRotationExtendedHealFrequency()); } - if (!target_index) { Log(Logs::General, Logs::Error, "(0) None (hp: 0.0\%, at: 0, dontheal: F, crit(base): F(F), safe(base): F(F), hcnt(ext): 0(0), hfreq(ext): 0.0(0.0))"); } + if (!target_index) { LogError("(0) None (hp: 0.0\%, at: 0, dontheal: F, crit(base): F(F), safe(base): F(F), hcnt(ext): 0(0), hfreq(ext): 0.0(0.0))"); } #endif } diff --git a/zone/horse.cpp b/zone/horse.cpp index 3871b355d..484b67149 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -79,8 +79,8 @@ const NPCType *Horse::BuildHorseType(uint16 spell_id) { } if (results.RowCount() != 1) { - Log(Logs::General, Logs::Error, "No Database entry for mount: %s, check the horses table", fileName); - return nullptr; + LogError("No Database entry for mount: [{}], check the horses table", fileName); + return nullptr; } auto row = results.begin(); @@ -122,7 +122,7 @@ void Client::SummonHorse(uint16 spell_id) { return; } if(!Horse::IsHorseSpell(spell_id)) { - Log(Logs::General, Logs::Error, "%s tried to summon an unknown horse, spell id %d", GetName(), spell_id); + LogError("[{}] tried to summon an unknown horse, spell id [{}]", GetName(), spell_id); return; } diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 500663491..dbc37f1d2 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -625,21 +625,21 @@ void Client::DropItem(int16 slot_id, bool recurse) (inst->GetItem() ? inst->GetItem()->Name : "null data"), inst->GetID(), (inst->IsDroppable(false) ? "true" : "false")); if (!inst->IsDroppable(false)) - Log(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); + LogError("Non-droppable item being processed for drop by [{}]", GetCleanName()); for (auto iter1 : *inst->GetContents()) { // depth 1 Log(Logs::General, Logs::Inventory, "-depth: 1, Item: '%s' (id: %u), IsDroppable: %s", (iter1.second->GetItem() ? iter1.second->GetItem()->Name : "null data"), iter1.second->GetID(), (iter1.second->IsDroppable(false) ? "true" : "false")); if (!iter1.second->IsDroppable(false)) - Log(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); + LogError("Non-droppable item being processed for drop by [{}]", GetCleanName()); for (auto iter2 : *iter1.second->GetContents()) { // depth 2 Log(Logs::General, Logs::Inventory, "--depth: 2, Item: '%s' (id: %u), IsDroppable: %s", (iter2.second->GetItem() ? iter2.second->GetItem()->Name : "null data"), iter2.second->GetID(), (iter2.second->IsDroppable(false) ? "true" : "false")); if (!iter2.second->IsDroppable(false)) - Log(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); + LogError("Non-droppable item being processed for drop by [{}]", GetCleanName()); } } } @@ -1672,7 +1672,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { //verify shared bank transactions in the database if (src_inst && src_slot_id >= EQEmu::invslot::SHARED_BANK_BEGIN && src_slot_id <= EQEmu::invbag::SHARED_BANK_BAGS_END) { if(!database.VerifyInventory(account_id, src_slot_id, src_inst)) { - Log(Logs::General, Logs::Error, "Player %s on account %s was found exploiting the shared bank.\n", GetName(), account_name); + LogError("Player [{}] on account [{}] was found exploiting the shared bank.\n", GetName(), account_name); DeleteItemInInventory(dst_slot_id,0,true); return(false); } @@ -1687,7 +1687,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } if (dst_inst && dst_slot_id >= EQEmu::invslot::SHARED_BANK_BEGIN && dst_slot_id <= EQEmu::invbag::SHARED_BANK_BAGS_END) { if(!database.VerifyInventory(account_id, dst_slot_id, dst_inst)) { - Log(Logs::General, Logs::Error, "Player %s on account %s was found exploting the shared bank.\n", GetName(), account_name); + LogError("Player [{}] on account [{}] was found exploting the shared bank.\n", GetName(), account_name); DeleteItemInInventory(src_slot_id,0,true); return(false); } @@ -3122,10 +3122,10 @@ void Client::SetBandolier(const EQApplicationPacket *app) Log(Logs::Detail, Logs::Inventory, "returning item %s in weapon slot %i to inventory", InvItem->GetItem()->Name, WeaponSlot); if (MoveItemToInventory(InvItem)) { database.SaveInventory(character_id, 0, WeaponSlot); - Log(Logs::General, Logs::Error, "returning item %s in weapon slot %i to inventory", InvItem->GetItem()->Name, WeaponSlot); + LogError("returning item [{}] in weapon slot [{}] to inventory", InvItem->GetItem()->Name, WeaponSlot); } else { - Log(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); + LogError("Char: [{}], ERROR returning [{}] to inventory", GetName(), InvItem->GetItem()->Name); } safe_delete(InvItem); } @@ -3159,7 +3159,7 @@ void Client::SetBandolier(const EQApplicationPacket *app) if(InvItem) { // If there was already an item in that weapon slot that we replaced, find a place to put it if (!MoveItemToInventory(InvItem)) { - Log(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); + LogError("Char: [{}], ERROR returning [{}] to inventory", GetName(), InvItem->GetItem()->Name); } safe_delete(InvItem); } @@ -3176,7 +3176,7 @@ void Client::SetBandolier(const EQApplicationPacket *app) database.SaveInventory(character_id, 0, WeaponSlot); } else { - Log(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); + LogError("Char: [{}], ERROR returning [{}] to inventory", GetName(), InvItem->GetItem()->Name); } safe_delete(InvItem); } @@ -3394,7 +3394,7 @@ bool Client::InterrogateInventory(Client* requester, bool log, bool silent, bool log = true; if (log) { - Log(Logs::General, Logs::Error, "Client::InterrogateInventory() called for %s by %s with an error state of %s", GetName(), requester->GetName(), (error ? "TRUE" : "FALSE")); + LogError("Client::InterrogateInventory() called for [{}] by [{}] with an error state of [{}]", GetName(), requester->GetName(), (error ? "TRUE" : "FALSE")); } if (!silent) { requester->Message(Chat::Default, "--- Inventory Interrogation Report for %s (requested by: %s, error state: %s) ---", GetName(), requester->GetName(), (error ? "TRUE" : "FALSE")); @@ -3415,7 +3415,7 @@ bool Client::InterrogateInventory(Client* requester, bool log, bool silent, bool } if (log) { - Log(Logs::General, Logs::Error, "Target interrogate inventory flag: %s", (GetInterrogateInvState() ? "TRUE" : "FALSE")); + LogError("Target interrogate inventory flag: [{}]", (GetInterrogateInvState() ? "TRUE" : "FALSE")); Log(Logs::Detail, Logs::None, "[CLIENT] Client::InterrogateInventory() -- End"); } if (!silent) { diff --git a/zone/merc.cpp b/zone/merc.cpp index c48c3fb66..0e7ff6006 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1914,7 +1914,7 @@ bool EntityList::Merc_AICheckCloseBeneficialSpells(Merc* caster, uint8 iChance, // according to Rogean, Live NPCs will just cast through walls/floors, no problem.. // // This check was put in to address an idle-mob CPU issue - Log(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); + LogError("Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); return(false); } @@ -4494,7 +4494,7 @@ bool Merc::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, boo { if (!other) { SetTarget(nullptr); - Log(Logs::General, Logs::Error, "A null Mob object was passed to Merc::Attack() for evaluation!"); + LogError("A null Mob object was passed to Merc::Attack() for evaluation!"); return false; } @@ -6181,7 +6181,7 @@ void NPC::LoadMercTypes() { auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in NPC::LoadMercTypes()"); + LogError("Error in NPC::LoadMercTypes()"); return; } @@ -6214,7 +6214,7 @@ void NPC::LoadMercs() { if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in NPC::LoadMercTypes()"); + LogError("Error in NPC::LoadMercTypes()"); return; } diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index de7cc68dd..ff936493e 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -385,7 +385,7 @@ bool EntityList::AICheckCloseBeneficialSpells(NPC* caster, uint8 iChance, float // according to Rogean, Live NPCs will just cast through walls/floors, no problem.. // // This check was put in to address an idle-mob CPU issue - Log(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); + LogError("Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); return(false); } diff --git a/zone/net.cpp b/zone/net.cpp index c6b4635bf..24fe390d4 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -147,7 +147,7 @@ int main(int argc, char** argv) { LogInfo("Loading server configuration.."); if (!ZoneConfig::LoadConfig()) { - Log(Logs::General, Logs::Error, "Loading server configuration failed."); + LogError("Loading server configuration failed"); return 1; } Config = ZoneConfig::get(); @@ -232,7 +232,7 @@ int main(int argc, char** argv) { Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { - Log(Logs::General, Logs::Error, "Cannot continue without a database connection."); + LogError("Cannot continue without a database connection"); return 1; } @@ -261,16 +261,16 @@ int main(int argc, char** argv) { * Setup nice signal handlers */ if (signal(SIGINT, CatchSignal) == SIG_ERR) { - Log(Logs::General, Logs::Error, "Could not set signal handler"); + LogError("Could not set signal handler"); return 1; } if (signal(SIGTERM, CatchSignal) == SIG_ERR) { - Log(Logs::General, Logs::Error, "Could not set signal handler"); + LogError("Could not set signal handler"); return 1; } #ifndef WIN32 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { - Log(Logs::General, Logs::Error, "Could not set signal handler"); + LogError("Could not set signal handler"); return 1; } #endif @@ -293,35 +293,35 @@ int main(int argc, char** argv) { LogInfo("Loading items"); if (!database.LoadItems(hotfix_name)) { - Log(Logs::General, Logs::Error, "Loading items FAILED!"); - Log(Logs::General, Logs::Error, "Failed. But ignoring error and going on..."); + LogError("Loading items failed!"); + LogError("Failed. But ignoring error and going on.."); } LogInfo("Loading npc faction lists"); if (!database.LoadNPCFactionLists(hotfix_name)) { - Log(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!"); + LogError("Loading npcs faction lists failed!"); return 1; } LogInfo("Loading loot tables"); if (!database.LoadLoot(hotfix_name)) { - Log(Logs::General, Logs::Error, "Loading loot FAILED!"); + LogError("Loading loot failed!"); return 1; } LogInfo("Loading skill caps"); if (!database.LoadSkillCaps(std::string(hotfix_name))) { - Log(Logs::General, Logs::Error, "Loading skill caps FAILED!"); + LogError("Loading skill caps failed!"); return 1; } LogInfo("Loading spells"); if (!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) { - Log(Logs::General, Logs::Error, "Loading spells FAILED!"); + LogError("Loading spells failed!"); return 1; } LogInfo("Loading base data"); if (!database.LoadBaseData(hotfix_name)) { - Log(Logs::General, Logs::Error, "Loading base data FAILED!"); + LogError("Loading base data failed!"); return 1; } @@ -342,12 +342,12 @@ int main(int argc, char** argv) { LogInfo("Loading profanity list"); if (!EQEmu::ProfanityManager::LoadProfanityList(&database)) - Log(Logs::General, Logs::Error, "Loading profanity list FAILED!"); + LogError("Loading profanity list failed!"); LogInfo("Loading commands"); int retval = command_init(); if (retval<0) - Log(Logs::General, Logs::Error, "Command loading FAILED"); + LogError("Command loading failed"); else LogInfo("{} commands loaded", retval); @@ -357,7 +357,7 @@ int main(int argc, char** argv) { if (database.GetVariable("RuleSet", tmp)) { LogInfo("Loading rule set [{}]", tmp.c_str()); if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str(), false)) { - Log(Logs::General, Logs::Error, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str()); + LogError("Failed to load ruleset [{}], falling back to defaults", tmp.c_str()); } } else { @@ -377,13 +377,13 @@ int main(int argc, char** argv) { Log(Logs::General, Logs::Zone_Server, "Loading bot commands"); int botretval = bot_command_init(); if (botretval<0) - Log(Logs::General, Logs::Error, "Bot command loading FAILED"); + LogError("Bot command loading failed"); else Log(Logs::General, Logs::Zone_Server, "%d bot commands loaded", botretval); Log(Logs::General, Logs::Zone_Server, "Loading bot spell casting chances"); if (!database.botdb.LoadBotSpellCastingChances()) - Log(Logs::General, Logs::Error, "Bot spell casting chances loading FAILED"); + LogError("Bot spell casting chances loading failed"); #endif if (RuleB(TaskSystem, EnableTaskSystem)) { @@ -423,7 +423,7 @@ int main(int argc, char** argv) { LogInfo("Entering sleep mode"); } else if (!Zone::Bootup(database.GetZoneID(zone_name), instance_id, true)) { - Log(Logs::General, Logs::Error, "Zone Bootup failed :: Zone::Bootup"); + LogError("Zone Bootup failed :: Zone::Bootup"); zone = 0; } diff --git a/zone/npc.cpp b/zone/npc.cpp index 759d6ffe0..62e579677 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -617,11 +617,11 @@ void NPC::QueryLoot(Client* to) int item_count = 0; for (auto cur = itemlist.begin(); cur != itemlist.end(); ++cur, ++item_count) { if (!(*cur)) { - Log(Logs::General, Logs::Error, "NPC::QueryLoot() - ItemList error, null item"); + LogError("NPC::QueryLoot() - ItemList error, null item"); continue; } if (!(*cur)->item_id || !database.GetItem((*cur)->item_id)) { - Log(Logs::General, Logs::Error, "NPC::QueryLoot() - Database error, invalid item"); + LogError("NPC::QueryLoot() - Database error, invalid item"); continue; } diff --git a/zone/object.cpp b/zone/object.cpp index dd0f53506..1ca10ba33 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -339,7 +339,7 @@ const EQEmu::ItemInstance* Object::GetItem(uint8 index) { void Object::PutItem(uint8 index, const EQEmu::ItemInstance* inst) { if (index > 9) { - Log(Logs::General, Logs::Error, "Object::PutItem: Invalid index specified (%i)", index); + LogError("Object::PutItem: Invalid index specified ([{}])", index); return; } @@ -647,7 +647,7 @@ uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& ob safe_delete_array(object_name); auto results = QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Unable to insert object: %s", results.ErrorMessage().c_str()); + LogError("Unable to insert object: [{}]", results.ErrorMessage().c_str()); return 0; } @@ -686,7 +686,7 @@ void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Objec safe_delete_array(object_name); auto results = QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Unable to update object: %s", results.ErrorMessage().c_str()); + LogError("Unable to update object: [{}]", results.ErrorMessage().c_str()); return; } @@ -730,7 +730,7 @@ void ZoneDatabase::DeleteObject(uint32 id) std::string query = StringFormat("DELETE FROM object WHERE id = %i", id); auto results = QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Unable to delete object: %s", results.ErrorMessage().c_str()); + LogError("Unable to delete object: [{}]", results.ErrorMessage().c_str()); } } diff --git a/zone/pathfinder_waypoint.cpp b/zone/pathfinder_waypoint.cpp index 83d924499..886ca197f 100644 --- a/zone/pathfinder_waypoint.cpp +++ b/zone/pathfinder_waypoint.cpp @@ -251,7 +251,7 @@ void PathfinderWaypoint::Load(const std::string &filename) { if (strncmp(Magic, "EQEMUPATH", 9)) { - Log(Logs::General, Logs::Error, "Bad Magic String in .path file."); + LogError("Bad Magic String in .path file"); fclose(f); return; } @@ -271,7 +271,7 @@ void PathfinderWaypoint::Load(const std::string &filename) { return; } else { - Log(Logs::General, Logs::Error, "Unsupported path file version."); + LogError("Unsupported path file version"); fclose(f); return; } @@ -306,7 +306,7 @@ void PathfinderWaypoint::LoadV2(FILE *f, const PathFileHeader &header) auto &node = m_impl->Nodes[i]; if (PathNodes[i].Neighbours[j].id > MaxNodeID) { - Log(Logs::General, Logs::Error, "Path Node %i, Neighbour %i (%i) out of range.", i, j, PathNodes[i].Neighbours[j].id); + LogError("Path Node [{}], Neighbour [{}] ([{}]) out of range", i, j, PathNodes[i].Neighbours[j].id); m_impl->PathFileValid = false; } diff --git a/zone/pets.cpp b/zone/pets.cpp index 6f8c5d44e..438509b77 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -213,7 +213,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, PetRecord record; if(!database.GetPoweredPetEntry(pettype, act_power, &record)) { Message(Chat::Red, "Unable to find data for pet %s", pettype); - Log(Logs::General, Logs::Error, "Unable to find data for pet %s, check pets table.", pettype); + LogError("Unable to find data for pet [{}], check pets table", pettype); return; } @@ -221,7 +221,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, const NPCType *base = database.LoadNPCTypesData(record.npc_type); if(base == nullptr) { Message(Chat::Red, "Unable to load NPC data for pet %s", pettype); - Log(Logs::General, Logs::Error, "Unable to load NPC data for pet %s (NPC ID %d), check pets and npc_types tables.", pettype, record.npc_type); + LogError("Unable to load NPC data for pet [{}] (NPC ID [{}]), check pets and npc_types tables", pettype, record.npc_type); return; } @@ -374,7 +374,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, npc_type->helmtexture = monster->helmtexture; npc_type->herosforgemodel = monster->herosforgemodel; } else - Log(Logs::General, Logs::Error, "Error loading NPC data for monster summoning pet (NPC ID %d)", monsterid); + LogError("Error loading NPC data for monster summoning pet (NPC ID [{}])", monsterid); } @@ -665,7 +665,7 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) { if (results.RowCount() != 1) { // invalid set reference, it doesn't exist - Log(Logs::General, Logs::Error, "Error in GetBasePetItems equipment set '%d' does not exist", curset); + LogError("Error in GetBasePetItems equipment set [{}] does not exist", curset); return false; } diff --git a/zone/raids.cpp b/zone/raids.cpp index 9b5485f40..d985f9e7b 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -103,7 +103,7 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo auto results = database.QueryDatabase(query); if(!results.Success()) { - Log(Logs::General, Logs::Error, "Error inserting into raid members: %s", results.ErrorMessage().c_str()); + LogError("Error inserting into raid members: [{}]", results.ErrorMessage().c_str()); } LearnMembers(); @@ -266,12 +266,12 @@ void Raid::SetRaidLeader(const char *wasLead, const char *name) std::string query = StringFormat("UPDATE raid_members SET israidleader = 0 WHERE name = '%s'", wasLead); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); + LogError("Set Raid Leader error: [{}]\n", results.ErrorMessage().c_str()); query = StringFormat("UPDATE raid_members SET israidleader = 1 WHERE name = '%s'", name); results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); + LogError("Set Raid Leader error: [{}]\n", results.ErrorMessage().c_str()); strn0cpy(leadername, name, 64); @@ -304,7 +304,7 @@ void Raid::SaveGroupLeaderAA(uint32 gid) safe_delete_array(queryBuffer); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to store LeadershipAA: [{}]\n", results.ErrorMessage().c_str()); } void Raid::SaveRaidLeaderAA() @@ -318,7 +318,7 @@ void Raid::SaveRaidLeaderAA() safe_delete_array(queryBuffer); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to store LeadershipAA: [{}]\n", results.ErrorMessage().c_str()); } void Raid::UpdateGroupAAs(uint32 gid) @@ -1455,10 +1455,14 @@ void Raid::GetRaidDetails() if (!results.Success()) return; - if (results.RowCount() == 0) { - Log(Logs::General, Logs::Error, "Error getting raid details for raid %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); - return; - } + if (results.RowCount() == 0) { + LogError( + "Error getting raid details for raid [{}]: [{}]", + (unsigned long) GetID(), + results.ErrorMessage().c_str() + ); + return; + } auto row = results.begin(); @@ -1488,7 +1492,7 @@ bool Raid::LearnMembers() return false; if(results.RowCount() == 0) { - Log(Logs::General, Logs::Error, "Error getting raid members for raid %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); + LogError("Error getting raid members for raid [{}]: [{}]", (unsigned long)GetID(), results.ErrorMessage().c_str()); disbandCheck = true; return false; } @@ -1750,7 +1754,7 @@ void Raid::SetGroupMentor(uint32 group_id, int percent, char *name) name, percent, group_id, GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to set raid group mentor: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to set raid group mentor: [{}]\n", results.ErrorMessage().c_str()); } void Raid::ClearGroupMentor(uint32 group_id) @@ -1765,7 +1769,7 @@ void Raid::ClearGroupMentor(uint32 group_id) group_id, GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Unable to clear raid group mentor: %s\n", results.ErrorMessage().c_str()); + LogError("Unable to clear raid group mentor: [{}]\n", results.ErrorMessage().c_str()); } // there isn't a nice place to add this in another function, unlike groups diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 93c955d4e..6b6a020cb 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -1029,10 +1029,10 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in event.condition_id = atoi(row[1]); event.period = atoi(row[2]); - if(event.period == 0) { - Log(Logs::General, Logs::Error, "Refusing to load spawn event #%d because it has a period of 0\n", event.id); - continue; - } + if (event.period == 0) { + LogError("Refusing to load spawn event #[{}] because it has a period of 0\n", event.id); + continue; + } event.next.minute = atoi(row[3]); event.next.hour = atoi(row[4]); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index cc9ead157..8091cc969 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -1810,7 +1810,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove } else { MessageString(Chat::LightBlue, TARGET_NOT_FOUND); - Log(Logs::General, Logs::Error, "%s attempted to cast spell id %u with spell effect SE_SummonCorpse, but could not cast target into a Client object.", GetCleanName(), spell_id); + LogError("[{}] attempted to cast spell id [{}] with spell effect SE_SummonCorpse, but could not cast target into a Client object", GetCleanName(), spell_id); } } diff --git a/zone/spells.cpp b/zone/spells.cpp index 406739acf..0ac3250d7 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -285,7 +285,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, if (itm && (itm->GetItem()->Click.Type == EQEmu::item::ItemEffectEquipClick) && item_slot > EQEmu::invslot::EQUIPMENT_END){ if (CastToClient()->ClientVersion() < EQEmu::versions::ClientVersion::SoF) { // They are attempting to cast a must equip clicky without having it equipped - Log(Logs::General, Logs::Error, "HACKER: %s (account: %s) attempted to click an equip-only effect on item %s (id: %d) without equiping it!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); + LogError("HACKER: [{}] (account: [{}]) attempted to click an equip-only effect on item [{}] (id: [{}]) without equiping it!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); database.SetHackerFlag(CastToClient()->AccountName(), CastToClient()->GetCleanName(), "Clicking equip-only item without equiping it"); } else { @@ -5200,28 +5200,50 @@ bool Client::SpellGlobalCheck(uint16 spell_id, uint32 char_id) { query = StringFormat("SELECT value FROM quest_globals " "WHERE charid = %i AND name = '%s'", - char_id, spell_global_name.c_str()); - results = database.QueryDatabase(query); - if (!results.Success()) { - Log(Logs::General, Logs::Error, "Spell ID %i query of spell_globals with Name: '%s' Value: '%i' failed", spell_id, spell_global_name.c_str(), spell_global_value); - return false; - } + char_id, spell_global_name.c_str()); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogError( + "Spell ID [{}] query of spell_globals with Name: [{}] Value: [{}] failed", + spell_id, + spell_global_name.c_str(), + spell_global_value + ); - if (results.RowCount() != 1) { - Log(Logs::General, Logs::Error, "Char ID: %i does not have the Qglobal Name: '%s' for Spell ID %i", char_id, spell_global_name.c_str(), spell_id); - return false; - } + return false; + } - row = results.begin(); - global_value = atoi(row[0]); - if (global_value == spell_global_value) - return true; // If the values match from both tables, allow the spell to be scribed - else if (global_value > spell_global_value) - return true; // Check if the qglobal value is greater than the require spellglobal value + if (results.RowCount() != 1) { + LogError( + "Char ID: [{}] does not have the Qglobal Name: [{}] for Spell ID [{}]", + char_id, + spell_global_name.c_str(), + spell_id + ); - // If no matching result found in qglobals, don't scribe this spell - Log(Logs::General, Logs::Error, "Char ID: %i Spell_globals Name: '%s' Value: '%i' did not match QGlobal Value: '%i' for Spell ID %i", char_id, spell_global_name.c_str(), spell_global_value, global_value, spell_id); - return false; + return false; + } + + row = results.begin(); + global_value = atoi(row[0]); + if (global_value == spell_global_value) { + return true; // If the values match from both tables, allow the spell to be scribed + } + else if (global_value > spell_global_value) { + return true; + } // Check if the qglobal value is greater than the require spellglobal value + + // If no matching result found in qglobals, don't scribe this spell + LogError( + "Char ID: [{}] SpellGlobals Name: [{}] Value: [{}] did not match QGlobal Value: [{}] for Spell ID [{}]", + char_id, + spell_global_name.c_str(), + spell_global_value, + global_value, + spell_id + ); + + return false; } bool Client::SpellBucketCheck(uint16 spell_id, uint32 char_id) { @@ -5241,18 +5263,30 @@ bool Client::SpellBucketCheck(uint16 spell_id, uint32 char_id) { spell_bucket_value = atoi(row[1]); if (spell_bucket_name.empty()) return true; - - query = StringFormat("SELECT value FROM data_buckets WHERE `key` = '%i-%s'", char_id, spell_bucket_name.c_str()); + + query = StringFormat("SELECT value FROM data_buckets WHERE `key` = '%i-%s'", char_id, spell_bucket_name.c_str()); results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Spell bucket %s for spell ID %i for char ID %i failed.", spell_bucket_name.c_str(), spell_id, char_id); - return false; - } + LogError( + "Spell bucket [{}] for spell ID [{}] for char ID [{}] failed", + spell_bucket_name.c_str(), + spell_id, + char_id + ); - if (results.RowCount() != 1) { - Log(Logs::General, Logs::Error, "Spell bucket %s does not exist for spell ID %i for char ID %i.", spell_bucket_name.c_str(), spell_id, char_id); - return false; - } + return false; + } + + if (results.RowCount() != 1) { + LogError( + "Spell bucket [{}] does not exist for spell ID [{}] for char ID [{}]", + spell_bucket_name.c_str(), + spell_id, + char_id + ); + + return false; + } row = results.begin(); @@ -5264,7 +5298,7 @@ bool Client::SpellBucketCheck(uint16 spell_id, uint32 char_id) { return true; // Check if the data bucket value is greater than the required spell bucket value // If no matching result found in spell buckets, don't scribe this spell - Log(Logs::General, Logs::Error, "Spell bucket %s for spell ID %i for char ID %i did not match value %i.", spell_bucket_name.c_str(), spell_id, char_id, spell_bucket_value); + LogError("Spell bucket [{}] for spell ID [{}] for char ID [{}] did not match value [{}]", spell_bucket_name.c_str(), spell_id, char_id, spell_bucket_value); return false; } diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 9137898c3..bad983481 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -54,31 +54,34 @@ TaskManager::~TaskManager() { } } -bool TaskManager::LoadTaskSets() { +bool TaskManager::LoadTaskSets() +{ // Clear all task sets in memory. Done so we can reload them on the fly if required by just calling // this method again. - for(int i=0; i 0 AND `id` < %i " - "AND `taskid` >= 0 AND `taskid` < %i " - "ORDER BY `id`, `taskid` ASC", - MAXTASKSETS, MAXTASKS); - auto results = database.QueryDatabase(query); - if (!results.Success()) { - Log(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadTaskSets: %s", results.ErrorMessage().c_str()); + std::string query = StringFormat( + "SELECT `id`, `taskid` from `tasksets` " + "WHERE `id` > 0 AND `id` < %i " + "AND `taskid` >= 0 AND `taskid` < %i " + "ORDER BY `id`, `taskid` ASC", + MAXTASKSETS, MAXTASKS + ); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("Error in TaskManager::LoadTaskSets: [{}]", results.ErrorMessage().c_str()); return false; - } + } for (auto row = results.begin(); row != results.end(); ++row) { - int taskSet = atoi(row[0]); - int taskID = atoi(row[1]); + int taskSet = atoi(row[0]); + int taskID = atoi(row[1]); - TaskSets[taskSet].push_back(taskID); - Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Adding TaskID %4i to TaskSet %4i", taskID, taskSet); - } + TaskSets[taskSet].push_back(taskID); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Adding TaskID %4i to TaskSet %4i", taskID, taskSet); + } return true; } @@ -130,7 +133,7 @@ bool TaskManager::LoadTasks(int singleTask) auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); return false; } @@ -188,7 +191,7 @@ bool TaskManager::LoadTasks(int singleTask) singleTask, MAXACTIVITIESPERTASK); results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); return false; } @@ -318,7 +321,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) state->ActiveTasks[task].AcceptedTime); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); } else { state->ActiveTasks[task].Updated = false; } @@ -362,7 +365,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); continue; } @@ -398,7 +401,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) StringFormat(completedTaskQuery, characterID, state->CompletedTasks[i].CompletedTime, taskID, -1); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); continue; } @@ -416,7 +419,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) taskID, j); results = database.QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str()); } } diff --git a/zone/titles.cpp b/zone/titles.cpp index 033edd144..7b4537b88 100644 --- a/zone/titles.cpp +++ b/zone/titles.cpp @@ -349,7 +349,7 @@ void Client::EnableTitle(int titleSet) { CharacterID(), titleSet); auto results = database.QueryDatabase(query); if(!results.Success()) - Log(Logs::General, Logs::Error, "Error in EnableTitle query for titleset %i and charid %i", titleSet, CharacterID()); + LogError("Error in EnableTitle query for titleset [{}] and charid [{}]", titleSet, CharacterID()); } diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 9230871c8..cb48a500c 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -42,7 +42,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme { if (!user || !in_augment) { - Log(Logs::General, Logs::Error, "Client or AugmentItem_Struct not set in Object::HandleAugmentation"); + LogError("Client or AugmentItem_Struct not set in Object::HandleAugmentation"); return; } @@ -89,7 +89,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme if(!container) { - Log(Logs::General, Logs::Error, "Player tried to augment an item without a container set."); + LogError("Player tried to augment an item without a container set"); user->Message(Chat::Red, "Error: This item is not a container!"); return; } @@ -169,7 +169,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme bool isSolvent = auged_with->GetItem()->ItemType == EQEmu::item::ItemTypeAugmentationSolvent; if (!isSolvent && auged_with->GetItem()->ItemType != EQEmu::item::ItemTypeAugmentationDistiller) { - Log(Logs::General, Logs::Error, "Player tried to remove an augment without a solvent or distiller."); + LogError("Player tried to remove an augment without a solvent or distiller"); user->Message(Chat::Red, "Error: Missing an augmentation solvent or distiller for removing this augment."); return; @@ -179,7 +179,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme if (aug) { if (!isSolvent && auged_with->GetItem()->ID != aug->GetItem()->AugDistiller) { - Log(Logs::General, Logs::Error, "Player tried to safely remove an augment with the wrong distiller (item %u vs expected %u).", auged_with->GetItem()->ID, aug->GetItem()->AugDistiller); + LogError("Player tried to safely remove an augment with the wrong distiller (item [{}] vs expected [{}])", auged_with->GetItem()->ID, aug->GetItem()->AugDistiller); user->Message(Chat::Red, "Error: Wrong augmentation distiller for safely removing this augment."); return; } @@ -252,7 +252,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Object *worldo) { if (!user || !in_combine) { - Log(Logs::General, Logs::Error, "Client or NewCombine_Struct not set in Object::HandleCombine"); + LogError("Client or NewCombine_Struct not set in Object::HandleCombine"); return; } @@ -433,7 +433,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob if(success && spec.replace_container) { if(worldcontainer){ //should report this error, but we dont have the recipe ID, so its not very useful - Log(Logs::General, Logs::Error, "Replace container combine executed in a world container."); + LogError("Replace container combine executed in a world container"); } else user->DeleteItemInInventory(in_combine->container_slot, 0, true); @@ -459,7 +459,7 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac //ask the database for the recipe to make sure it exists... DBTradeskillRecipe_Struct spec; if (!database.GetTradeRecipe(rac->recipe_id, rac->object_type, rac->some_id, user->CharacterID(), &spec)) { - Log(Logs::General, Logs::Error, "Unknown recipe for HandleAutoCombine: %u\n", rac->recipe_id); + LogError("Unknown recipe for HandleAutoCombine: [{}]\n", rac->recipe_id); user->QueuePacket(outapp); safe_delete(outapp); return; @@ -488,14 +488,14 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac } if(results.RowCount() < 1) { - Log(Logs::General, Logs::Error, "Error in HandleAutoCombine: no components returned"); + LogError("Error in HandleAutoCombine: no components returned"); user->QueuePacket(outapp); safe_delete(outapp); return; } if(results.RowCount() > 10) { - Log(Logs::General, Logs::Error, "Error in HandleAutoCombine: too many components returned (%u)", results.RowCount()); + LogError("Error in HandleAutoCombine: too many components returned ([{}])", results.RowCount()); user->QueuePacket(outapp); safe_delete(outapp); return; @@ -706,7 +706,7 @@ void Client::TradeskillSearchResults(const std::string &query, unsigned long obj return; //search gave no results... not an error if(results.ColumnCount() != 6) { - Log(Logs::General, Logs::Error, "Error in TradeskillSearchResults query '%s': Invalid column count in result", query.c_str()); + LogError("Error in TradeskillSearchResults query [{}]: Invalid column count in result", query.c_str()); return; } @@ -756,12 +756,12 @@ void Client::SendTradeskillDetails(uint32 recipe_id) { } if(results.RowCount() < 1) { - Log(Logs::General, Logs::Error, "Error in SendTradeskillDetails: no components returned"); + LogError("Error in SendTradeskillDetails: no components returned"); return; } if(results.RowCount() > 10) { - Log(Logs::General, Logs::Error, "Error in SendTradeskillDetails: too many components returned (%u)", results.RowCount()); + LogError("Error in SendTradeskillDetails: too many components returned ([{}])", results.RowCount()); return; } @@ -1146,8 +1146,8 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_ buf2.c_str(), containers.c_str(), count, sum); auto results = QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in GetTradeRecipe search, query: %s", query.c_str()); - Log(Logs::General, Logs::Error, "Error in GetTradeRecipe search, error: %s", results.ErrorMessage().c_str()); + LogError("Error in GetTradeRecipe search, query: [{}]", query.c_str()); + LogError("Error in GetTradeRecipe search, error: [{}]", results.ErrorMessage().c_str()); return false; } @@ -1168,7 +1168,7 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_ //length limit on buf2 if(index == 214) { //Maximum number of recipe matches (19 * 215 = 4096) - Log(Logs::General, Logs::Error, "GetTradeRecipe warning: Too many matches. Unable to search all recipe entries. Searched %u of %u possible entries.", index + 1, results.RowCount()); + LogError("GetTradeRecipe warning: Too many matches. Unable to search all recipe entries. Searched [{}] of [{}] possible entries", index + 1, results.RowCount()); break; } } @@ -1180,8 +1180,8 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_ "AND sum(tre.item_id * tre.componentcount) = %u", buf2.c_str(), count, sum); results = QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str()); - Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); + LogError("Error in GetTradeRecipe, re-query: [{}]", query.c_str()); + LogError("Error in GetTradeRecipe, error: [{}]", results.ErrorMessage().c_str()); return false; } } @@ -1189,36 +1189,45 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_ if (results.RowCount() < 1) return false; - if(results.RowCount() > 1) { + if (results.RowCount() > 1) { //The recipe is not unique, so we need to compare the container were using. uint32 containerId = 0; - if(some_id) //Standard container + if (some_id) { //Standard container containerId = some_id; - else if(c_type)//World container + } + else if (c_type) {//World container containerId = c_type; - else //Invalid container + } + else { //Invalid container return false; + } - query = StringFormat("SELECT tre.recipe_id " - "FROM tradeskill_recipe_entries AS tre " - "WHERE tre.recipe_id IN (%s) " - "AND tre.item_id = %u;", buf2.c_str(), containerId); - results = QueryDatabase(query); + query = StringFormat( + "SELECT tre.recipe_id " + "FROM tradeskill_recipe_entries AS tre " + "WHERE tre.recipe_id IN (%s) " + "AND tre.item_id = %u;", buf2.c_str(), containerId + ); + results = QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str()); - Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); + LogError("Error in GetTradeRecipe, re-query: [{}]", query.c_str()); + LogError("Error in GetTradeRecipe, error: [{}]", results.ErrorMessage().c_str()); return false; } - if(results.RowCount() == 0) { //Recipe contents matched more than 1 recipe, but not in this container - Log(Logs::General, Logs::Error, "Combine error: Incorrect container is being used!"); + if (results.RowCount() == 0) { //Recipe contents matched more than 1 recipe, but not in this container + LogError("Combine error: Incorrect container is being used!"); return false; } - if (results.RowCount() > 1) //Recipe contents matched more than 1 recipe in this container - Log(Logs::General, Logs::Error, "Combine error: Recipe is not unique! %u matches found for container %u. Continuing with first recipe match.", results.RowCount(), containerId); - + if (results.RowCount() > 1) { //Recipe contents matched more than 1 recipe in this container + LogError( + "Combine error: Recipe is not unique! [{}] matches found for container [{}]. Continuing with first recipe match", + results.RowCount(), + containerId + ); + } } auto row = results.begin(); @@ -1288,8 +1297,8 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id char_id, (unsigned long)recipe_id, containers.c_str()); auto results = QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, query: %s", query.c_str()); - Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); + LogError("Error in GetTradeRecipe, query: [{}]", query.c_str()); + LogError("Error in GetTradeRecipe, error: [{}]", results.ErrorMessage().c_str()); return false; } @@ -1324,7 +1333,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id } if(results.RowCount() < 1 && !spec->quest) { - Log(Logs::General, Logs::Error, "Error in GetTradeRecept success: no success items returned"); + LogError("Error in GetTradeRecept success: no success items returned"); return false; } diff --git a/zone/trading.cpp b/zone/trading.cpp index 2d8f03e4f..f3d3db86c 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -2619,7 +2619,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { Quantity = i; break; } - Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + LogError("Unexpected error while moving item from seller to buyer"); Message(Chat::Red, "Internal error while processing transaction."); return; } @@ -2627,7 +2627,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { EQEmu::ItemInstance* ItemToTransfer = m_inv.PopItem(SellerSlot); if(!ItemToTransfer || !Buyer->MoveItemToInventory(ItemToTransfer, true)) { - Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + LogError("Unexpected error while moving item from seller to buyer"); Message(Chat::Red, "Internal error while processing transaction."); if(ItemToTransfer) @@ -2665,7 +2665,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { int16 SellerSlot = m_inv.HasItem(ItemID, 1, invWhereWorn|invWherePersonal|invWhereCursor); if (SellerSlot == INVALID_INDEX) { - Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + LogError("Unexpected error while moving item from seller to buyer"); Message(Chat::Red, "Internal error while processing transaction."); return; } @@ -2673,7 +2673,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { EQEmu::ItemInstance* ItemToTransfer = m_inv.PopItem(SellerSlot); if(!ItemToTransfer) { - Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + LogError("Unexpected error while moving item from seller to buyer"); Message(Chat::Red, "Internal error while processing transaction."); return; } @@ -2685,7 +2685,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { QuantityMoved += ItemToTransfer->GetCharges(); if(!Buyer->MoveItemToInventory(ItemToTransfer, true)) { - Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + LogError("Unexpected error while moving item from seller to buyer"); Message(Chat::Red, "Internal error while processing transaction."); safe_delete(ItemToTransfer); return; @@ -2720,7 +2720,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { ItemToTransfer->SetCharges(QuantityToRemoveFromStack); if(!Buyer->MoveItemToInventory(ItemToTransfer, true)) { - Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + LogError("Unexpected error while moving item from seller to buyer"); Message(Chat::Red, "Internal error while processing transaction."); safe_delete(ItemToTransfer); return; diff --git a/zone/tribute.cpp b/zone/tribute.cpp index a52d5d1d6..3e80f5446 100644 --- a/zone/tribute.cpp +++ b/zone/tribute.cpp @@ -220,7 +220,7 @@ void Client::ChangeTributeSettings(TributeInfo_Struct *t) { void Client::SendTributeDetails(uint32 client_id, uint32 tribute_id) { if(tribute_list.count(tribute_id) != 1) { - Log(Logs::General, Logs::Error, "Details request for invalid tribute %lu", (unsigned long)tribute_id); + LogError("Details request for invalid tribute [{}]", (unsigned long)tribute_id); return; } TributeData &td = tribute_list[tribute_id]; @@ -409,28 +409,28 @@ bool ZoneDatabase::LoadTributes() { return false; } - for (auto row = results.begin(); row != results.end(); ++row) { - uint32 id = atoul(row[0]); + for (auto row = results.begin(); row != results.end(); ++row) { + uint32 id = atoul(row[0]); - if(tribute_list.count(id) != 1) { - Log(Logs::General, Logs::Error, "Error in LoadTributes: unknown tribute %lu in tribute_levels", (unsigned long)id); - continue; - } + if (tribute_list.count(id) != 1) { + LogError("Error in LoadTributes: unknown tribute [{}] in tribute_levels", (unsigned long) id); + continue; + } - TributeData &cur = tribute_list[id]; + TributeData &cur = tribute_list[id]; - if(cur.tier_count >= MAX_TRIBUTE_TIERS) { - Log(Logs::General, Logs::Error, "Error in LoadTributes: on tribute %lu: more tiers defined than permitted", (unsigned long)id); - continue; - } + if (cur.tier_count >= MAX_TRIBUTE_TIERS) { + LogError("Error in LoadTributes: on tribute [{}]: more tiers defined than permitted", (unsigned long) id); + continue; + } - TributeLevel_Struct &s = cur.tiers[cur.tier_count]; + TributeLevel_Struct &s = cur.tiers[cur.tier_count]; - s.level = atoul(row[1]); - s.cost = atoul(row[2]); - s.tribute_item_id = atoul(row[3]); - cur.tier_count++; - } + s.level = atoul(row[1]); + s.cost = atoul(row[2]); + s.tribute_item_id = atoul(row[3]); + cur.tier_count++; + } return true; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index fed40169e..c84540020 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -132,7 +132,7 @@ void NPC::ResumeWandering() } else { - Log(Logs::General, Logs::Error, "NPC not paused - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); + LogError("NPC not paused - can't resume wandering: [{}]", (unsigned long)GetNPCTypeID()); return; } @@ -147,7 +147,7 @@ void NPC::ResumeWandering() } else { - Log(Logs::General, Logs::Error, "NPC not on grid - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); + LogError("NPC not on grid - can't resume wandering: [{}]", (unsigned long)GetNPCTypeID()); } return; } @@ -169,7 +169,7 @@ void NPC::PauseWandering(int pausetime) } } else { - Log(Logs::General, Logs::Error, "NPC not on grid - can't pause wandering: %lu", (unsigned long)GetNPCTypeID()); + LogError("NPC not on grid - can't pause wandering: [{}]", (unsigned long)GetNPCTypeID()); } return; } diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index e6c3a8665..05403ed33 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -428,7 +428,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } } else - Log(Logs::General, Logs::Error, "WhoAllReturnStruct: Could not get return struct!"); + LogError("WhoAllReturnStruct: Could not get return struct!"); break; } case ServerOP_EmoteMessage: { @@ -827,7 +827,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_RefreshCensorship: { if (!EQEmu::ProfanityManager::LoadProfanityList(&database)) - Log(Logs::General, Logs::Error, "Received request to refresh the profanity list..but, the action failed"); + LogError("Received request to refresh the profanity list..but, the action failed"); break; } case ServerOP_ChangeWID: { @@ -1436,7 +1436,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) if (NewCorpse) NewCorpse->Spawn(); else - Log(Logs::General, Logs::Error, "Unable to load player corpse id %u for zone %s.", s->player_corpse_id, zone->GetShortName()); + LogError("Unable to load player corpse id [{}] for zone [{}]", s->player_corpse_id, zone->GetShortName()); break; } @@ -1944,32 +1944,32 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) std::string hotfix_name = std::string((char*)pack->pBuffer); LogInfo("Loading items"); if (!database.LoadItems(hotfix_name)) { - Log(Logs::General, Logs::Error, "Loading items FAILED!"); + LogError("Loading items failed!"); } LogInfo("Loading npc faction lists"); if (!database.LoadNPCFactionLists(hotfix_name)) { - Log(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!"); + LogError("Loading npcs faction lists failed!"); } LogInfo("Loading loot tables"); if (!database.LoadLoot(hotfix_name)) { - Log(Logs::General, Logs::Error, "Loading loot FAILED!"); + LogError("Loading loot failed!"); } LogInfo("Loading skill caps"); if (!database.LoadSkillCaps(std::string(hotfix_name))) { - Log(Logs::General, Logs::Error, "Loading skill caps FAILED!"); + LogError("Loading skill caps failed!"); } LogInfo("Loading spells"); if (!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) { - Log(Logs::General, Logs::Error, "Loading spells FAILED!"); + LogError("Loading spells failed!"); } LogInfo("Loading base data"); if (!database.LoadBaseData(hotfix_name)) { - Log(Logs::General, Logs::Error, "Loading base data FAILED!"); + LogError("Loading base data failed!"); } break; } @@ -2190,7 +2190,7 @@ uint32 WorldServer::NextGroupID() { if (cur_groupid >= last_groupid) { //this is an error... This means that 50 groups were created before //1 packet could make the zone->world->zone trip... so let it error. - Log(Logs::General, Logs::Error, "Ran out of group IDs before the server sent us more."); + LogError("Ran out of group IDs before the server sent us more"); return(0); } if (cur_groupid > (last_groupid - /*50*/995)) { diff --git a/zone/zone.cpp b/zone/zone.cpp index 16b15aa20..5d154b6a4 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -560,18 +560,18 @@ void Zone::LoadMercTemplates(){ merc_templates.clear(); std::string query = "SELECT `class_id`, `proficiency_id`, `stance_id`, `isdefault` FROM " "`merc_stance_entries` ORDER BY `class_id`, `proficiency_id`, `stance_id`"; - auto results = database.QueryDatabase(query); + auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadMercTemplates()"); + LogError("Error in ZoneDatabase::LoadMercTemplates()"); } else { for (auto row = results.begin(); row != results.end(); ++row) { MercStanceInfo tempMercStanceInfo; - tempMercStanceInfo.ClassID = atoi(row[0]); + tempMercStanceInfo.ClassID = atoi(row[0]); tempMercStanceInfo.ProficiencyID = atoi(row[1]); - tempMercStanceInfo.StanceID = atoi(row[2]); - tempMercStanceInfo.IsDefault = atoi(row[3]); + tempMercStanceInfo.StanceID = atoi(row[2]); + tempMercStanceInfo.IsDefault = atoi(row[3]); merc_stances.push_back(tempMercStanceInfo); } @@ -583,11 +583,11 @@ void Zone::LoadMercTemplates(){ "AS CostFormula, MTem.clientversion, MTem.merc_npc_type_id " "FROM merc_types MTyp, merc_templates MTem, merc_subtypes MS " "WHERE MTem.merc_type_id = MTyp.merc_type_id AND MTem.merc_subtype_id = MS.merc_subtype_id " - "ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id;"; - results = database.QueryDatabase(query); - if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadMercTemplates()"); - return; + "ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id;"; + results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("Error in ZoneDatabase::LoadMercTemplates()"); + return; } for (auto row = results.begin(); row != results.end(); ++row) { @@ -630,7 +630,7 @@ void Zone::LoadLevelEXPMods(){ const std::string query = "SELECT level, exp_mod, aa_exp_mod FROM level_exp_mods"; auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadEXPLevelMods()"); + LogError("Error in ZoneDatabase::LoadEXPLevelMods()"); return; } @@ -652,11 +652,11 @@ void Zone::LoadMercSpells(){ "FROM merc_spell_lists msl, merc_spell_list_entries msle " "WHERE msle.merc_spell_list_id = msl.merc_spell_list_id " "ORDER BY msl.class_id, msl.proficiency_id, msle.spell_type, msle.minlevel, msle.slot;"; - auto results = database.QueryDatabase(query); - if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in Zone::LoadMercSpells()"); - return; - } + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("Error in Zone::LoadMercSpells()"); + return; + } for (auto row = results.begin(); row != results.end(); ++row) { uint32 classid; @@ -744,7 +744,7 @@ void Zone::LoadZoneDoors(const char* zone, int16 version) auto dlist = new Door[count]; if(!database.LoadDoors(count, dlist, zone, version)) { - Log(Logs::General, Logs::Error, "... Failed to load doors."); + LogError(" Failed to load doors"); delete[] dlist; return; } @@ -812,7 +812,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) Log(Logs::General, Logs::None, "Loaded a graveyard for zone %s: graveyard zoneid is %u at %s.", short_name, graveyard_zoneid(), to_string(m_Graveyard).c_str()); } else { - Log(Logs::General, Logs::Error, "Unable to load the graveyard id %i for zone %s.", graveyard_id(), short_name); + LogError("Unable to load the graveyard id [{}] for zone [{}]", graveyard_id(), short_name); } } if (long_name == 0) { @@ -917,38 +917,38 @@ bool Zone::Init(bool iStaticZone) { Log(Logs::General, Logs::Status, "Loading spawn conditions..."); if(!spawn_conditions.LoadSpawnConditions(short_name, instanceid)) { - Log(Logs::General, Logs::Error, "Loading spawn conditions failed, continuing without them."); + LogError("Loading spawn conditions failed, continuing without them"); } Log(Logs::General, Logs::Status, "Loading static zone points..."); if (!database.LoadStaticZonePoints(&zone_point_list, short_name, GetInstanceVersion())) { - Log(Logs::General, Logs::Error, "Loading static zone points failed."); + LogError("Loading static zone points failed"); return false; } Log(Logs::General, Logs::Status, "Loading spawn groups..."); if (!database.LoadSpawnGroups(short_name, GetInstanceVersion(), &spawn_group_list)) { - Log(Logs::General, Logs::Error, "Loading spawn groups failed."); + LogError("Loading spawn groups failed"); return false; } Log(Logs::General, Logs::Status, "Loading spawn2 points..."); if (!database.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion())) { - Log(Logs::General, Logs::Error, "Loading spawn2 points failed."); + LogError("Loading spawn2 points failed"); return false; } Log(Logs::General, Logs::Status, "Loading player corpses..."); if (!database.LoadCharacterCorpses(zoneid, instanceid)) { - Log(Logs::General, Logs::Error, "Loading player corpses failed."); + LogError("Loading player corpses failed"); return false; } Log(Logs::General, Logs::Status, "Loading traps..."); if (!database.LoadTraps(short_name, GetInstanceVersion())) { - Log(Logs::General, Logs::Error, "Loading traps failed."); + LogError("Loading traps failed"); return false; } @@ -958,13 +958,13 @@ bool Zone::Init(bool iStaticZone) { Log(Logs::General, Logs::Status, "Loading ground spawns..."); if (!LoadGroundSpawns()) { - Log(Logs::General, Logs::Error, "Loading ground spawns failed. continuing."); + LogError("Loading ground spawns failed. continuing"); } Log(Logs::General, Logs::Status, "Loading World Objects from DB..."); if (!LoadZoneObjects()) { - Log(Logs::General, Logs::Error, "Loading World Objects failed. continuing."); + LogError("Loading World Objects failed. continuing"); } Log(Logs::General, Logs::Status, "Flushing old respawn timers..."); @@ -1027,27 +1027,27 @@ void Zone::ReloadStaticData() { Log(Logs::General, Logs::Status, "Reloading static zone points..."); zone_point_list.Clear(); if (!database.LoadStaticZonePoints(&zone_point_list, GetShortName(), GetInstanceVersion())) { - Log(Logs::General, Logs::Error, "Loading static zone points failed."); + LogError("Loading static zone points failed"); } Log(Logs::General, Logs::Status, "Reloading traps..."); entity_list.RemoveAllTraps(); if (!database.LoadTraps(GetShortName(), GetInstanceVersion())) { - Log(Logs::General, Logs::Error, "Reloading traps failed."); + LogError("Reloading traps failed"); } Log(Logs::General, Logs::Status, "Reloading ground spawns..."); if (!LoadGroundSpawns()) { - Log(Logs::General, Logs::Error, "Reloading ground spawns failed. continuing."); + LogError("Reloading ground spawns failed. continuing"); } entity_list.RemoveAllObjects(); Log(Logs::General, Logs::Status, "Reloading World Objects from DB..."); if (!LoadZoneObjects()) { - Log(Logs::General, Logs::Error, "Reloading World Objects failed. continuing."); + LogError("Reloading World Objects failed. continuing"); } entity_list.RemoveAllDoors(); @@ -1082,7 +1082,7 @@ bool Zone::LoadZoneCFG(const char* filename, uint16 instance_id) if(!database.GetZoneCFG(database.GetZoneID(filename), 0, &newzone_data, can_bind, can_combat, can_levitate, can_castoutdoor, is_city, is_hotzone, allow_mercs, max_movement_update_range, zone_type, default_ruleset, &map_name)) { - Log(Logs::General, Logs::Error, "Error loading the Zone Config."); + LogError("Error loading the Zone Config"); return false; } } @@ -1919,7 +1919,7 @@ void Zone::LoadZoneBlockedSpells(uint32 zone_id) if (zone_total_blocked_spells > 0) { blocked_spells = new ZoneSpellsBlocked[zone_total_blocked_spells]; if (!database.LoadBlockedSpells(zone_total_blocked_spells, blocked_spells, zone_id)) { - Log(Logs::General, Logs::Error, "... Failed to load blocked spells."); + LogError(" Failed to load blocked spells"); ClearBlockedSpells(); } } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 91f456768..9780ea4cb 100755 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -681,17 +681,20 @@ void ZoneDatabase::GetEventLogs(const char* name,char* target,uint32 account_id, void ZoneDatabase::LoadWorldContainer(uint32 parentid, EQEmu::ItemInstance* container) { if (!container) { - Log(Logs::General, Logs::Error, "Programming error: LoadWorldContainer passed nullptr pointer"); + LogError("Programming error: LoadWorldContainer passed nullptr pointer"); return; } - std::string query = StringFormat("SELECT bagidx, itemid, charges, augslot1, augslot2, augslot3, augslot4, augslot5, augslot6 " - "FROM object_contents WHERE parentid = %i", parentid); - auto results = QueryDatabase(query); - if (!results.Success()) { - Log(Logs::General, Logs::Error, "Error in DB::LoadWorldContainer: %s", results.ErrorMessage().c_str()); - return; - } + std::string query = StringFormat( + "SELECT bagidx, itemid, charges, augslot1, augslot2, augslot3, augslot4, augslot5, augslot6 " + "FROM object_contents WHERE parentid = %i", parentid + ); + + auto results = QueryDatabase(query); + if (!results.Success()) { + LogError("Error in DB::LoadWorldContainer: [{}]", results.ErrorMessage().c_str()); + return; + } for (auto row = results.begin(); row != results.end(); ++row) { uint8 index = (uint8)atoi(row[0]); @@ -754,7 +757,7 @@ void ZoneDatabase::SaveWorldContainer(uint32 zone_id, uint32 parent_id, const EQ augslot[0], augslot[1], augslot[2], augslot[3], augslot[4], augslot[5]); auto results = QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Error in ZoneDatabase::SaveWorldContainer: %s", results.ErrorMessage().c_str()); + LogError("Error in ZoneDatabase::SaveWorldContainer: [{}]", results.ErrorMessage().c_str()); } @@ -766,7 +769,7 @@ void ZoneDatabase::DeleteWorldContainer(uint32 parent_id, uint32 zone_id) std::string query = StringFormat("DELETE FROM object_contents WHERE parentid = %i AND zoneid = %i", parent_id, zone_id); auto results = QueryDatabase(query); if (!results.Success()) - Log(Logs::General, Logs::Error, "Error in ZoneDatabase::DeleteWorldContainer: %s", results.ErrorMessage().c_str()); + LogError("Error in ZoneDatabase::DeleteWorldContainer: [{}]", results.ErrorMessage().c_str()); } @@ -2295,7 +2298,7 @@ bool ZoneDatabase::RestoreCharacterInvSnapshot(uint32 character_id, uint32 times // we should know what we're doing by the time we call this function..but, // this is to prevent inventory deletions where no timestamp entries exists if (!ValidateCharacterInvSnapshotTimestamp(character_id, timestamp)) { - Log(Logs::General, Logs::Error, "ZoneDatabase::RestoreCharacterInvSnapshot() called for id: %u without valid snapshot entries @ %u", character_id, timestamp); + LogError("ZoneDatabase::RestoreCharacterInvSnapshot() called for id: [{}] without valid snapshot entries @ [{}]", character_id, timestamp); return false; } @@ -3113,12 +3116,12 @@ void ZoneDatabase::SaveMercBuffs(Merc *merc) { Buffs_Struct *buffs = merc->GetBuffs(); // Remove any existing buff saves - std::string query = StringFormat("DELETE FROM merc_buffs WHERE MercId = %u", merc->GetMercID()); - auto results = database.QueryDatabase(query); - if(!results.Success()) { - Log(Logs::General, Logs::Error, "Error While Deleting Merc Buffs before save: %s", results.ErrorMessage().c_str()); - return; - } + std::string query = StringFormat("DELETE FROM merc_buffs WHERE MercId = %u", merc->GetMercID()); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("Error While Deleting Merc Buffs before save: [{}]", results.ErrorMessage().c_str()); + return; + } for (int buffCount = 0; buffCount <= BUFF_COUNT; buffCount++) { if(buffs[buffCount].spellid == 0 || buffs[buffCount].spellid == SPELL_UNKNOWN) @@ -3142,7 +3145,7 @@ void ZoneDatabase::SaveMercBuffs(Merc *merc) { buffs[buffCount].caston_z, buffs[buffCount].ExtraDIChance); results = database.QueryDatabase(query); if(!results.Success()) { - Log(Logs::General, Logs::Error, "Error Saving Merc Buffs: %s", results.ErrorMessage().c_str()); + LogError("Error Saving Merc Buffs: [{}]", results.ErrorMessage().c_str()); break; } } @@ -3161,7 +3164,7 @@ void ZoneDatabase::LoadMercBuffs(Merc *merc) { merc->GetMercID()); auto results = database.QueryDatabase(query); if(!results.Success()) { - Log(Logs::General, Logs::Error, "Error Loading Merc Buffs: %s", results.ErrorMessage().c_str()); + LogError("Error Loading Merc Buffs: [{}]", results.ErrorMessage().c_str()); return; } @@ -3206,7 +3209,7 @@ void ZoneDatabase::LoadMercBuffs(Merc *merc) { query = StringFormat("DELETE FROM merc_buffs WHERE MercId = %u", merc->GetMercID()); results = database.QueryDatabase(query); if(!results.Success()) - Log(Logs::General, Logs::Error, "Error Loading Merc Buffs: %s", results.ErrorMessage().c_str()); + LogError("Error Loading Merc Buffs: [{}]", results.ErrorMessage().c_str()); } @@ -3222,14 +3225,14 @@ bool ZoneDatabase::DeleteMerc(uint32 merc_id) { auto results = database.QueryDatabase(query); if(!results.Success()) { - Log(Logs::General, Logs::Error, "Error Deleting Merc Buffs: %s", results.ErrorMessage().c_str()); + LogError("Error Deleting Merc Buffs: [{}]", results.ErrorMessage().c_str()); } query = StringFormat("DELETE FROM mercs WHERE MercID = '%u'", merc_id); results = database.QueryDatabase(query); if(!results.Success()) { - Log(Logs::General, Logs::Error, "Error Deleting Merc: %s", results.ErrorMessage().c_str()); + LogError("Error Deleting Merc: [{}]", results.ErrorMessage().c_str()); return false; } @@ -3247,7 +3250,7 @@ void ZoneDatabase::LoadMercEquipment(Merc *merc) { merc->GetLevel(), merc->GetLevel()); auto results = database.QueryDatabase(query); if(!results.Success()) { - Log(Logs::General, Logs::Error, "Error Loading Merc Inventory: %s", results.ErrorMessage().c_str()); + LogError("Error Loading Merc Inventory: [{}]", results.ErrorMessage().c_str()); return; } @@ -4602,11 +4605,11 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z if (!corpse) continue; - entity_list.AddCorpse(corpse); - corpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); - corpse->Spawn(); - if (!UnburyCharacterCorpse(corpse->GetCorpseDBID(), dest_zone_id, dest_instance_id, position)) - Log(Logs::General, Logs::Error, "Unable to unbury a summoned player corpse for character id %u.", char_id); + entity_list.AddCorpse(corpse); + corpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); + corpse->Spawn(); + if (!UnburyCharacterCorpse(corpse->GetCorpseDBID(), dest_zone_id, dest_instance_id, position)) + LogError("Unable to unbury a summoned player corpse for character id [{}]", char_id); } return corpse; @@ -4645,7 +4648,7 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id ++CorpseCount; } else{ - Log(Logs::General, Logs::Error, "Unable to construct a player corpse for character id %u.", char_id); + LogError("Unable to construct a player corpse for character id [{}]", char_id); } } diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 800ee8cd2..9a9d7889a 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -97,7 +97,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //Todo cheat detection Message(Chat::Red, "Invalid unsolicited zone request."); - Log(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%d'.", GetName(), target_zone_id); + LogError("Zoning [{}]: Invalid unsolicited zone request to zone id [{}]", GetName(), target_zone_id); SendZoneCancel(zc); return; } @@ -129,7 +129,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //if we didnt get a zone point, or its to a different zone, //then we assume this is invalid. if(!zone_point || zone_point->target_zone_id != target_zone_id) { - Log(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%d'.", GetName(), target_zone_id); + LogError("Zoning [{}]: Invalid unsolicited zone request to zone id [{}]", GetName(), target_zone_id); //todo cheat detection SendZoneCancel(zc); return; @@ -160,7 +160,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { if(target_zone_name == nullptr) { //invalid zone... Message(Chat::Red, "Invalid target zone ID."); - Log(Logs::General, Logs::Error, "Zoning %s: Unable to get zone name for zone id '%d'.", GetName(), target_zone_id); + LogError("Zoning [{}]: Unable to get zone name for zone id [{}]", GetName(), target_zone_id); SendZoneCancel(zc); return; } @@ -173,7 +173,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { if(!database.GetSafePoints(target_zone_name, database.GetInstanceVersion(target_instance_id), &safe_x, &safe_y, &safe_z, &minstatus, &minlevel, flag_needed)) { //invalid zone... Message(Chat::Red, "Invalid target zone while getting safe points."); - Log(Logs::General, Logs::Error, "Zoning %s: Unable to get safe coordinates for zone '%s'.", GetName(), target_zone_name); + LogError("Zoning [{}]: Unable to get safe coordinates for zone [{}]", GetName(), target_zone_name); SendZoneCancel(zc); return; } @@ -253,7 +253,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //could not find a valid reason for them to be zoning, stop it. //todo cheat detection - Log(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%s'. Not near a zone point.", GetName(), target_zone_name); + LogError("Zoning [{}]: Invalid unsolicited zone request to zone id [{}]. Not near a zone point", GetName(), target_zone_name); SendZoneCancel(zc); return; default: @@ -288,7 +288,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //we have successfully zoned DoZoneSuccess(zc, target_zone_id, target_instance_id, dest_x, dest_y, dest_z, dest_h, ignorerestrictions); } else { - Log(Logs::General, Logs::Error, "Zoning %s: Rules prevent this char from zoning into '%s'", GetName(), target_zone_name); + LogError("Zoning [{}]: Rules prevent this char from zoning into [{}]", GetName(), target_zone_name); SendZoneError(zc, myerror); } } @@ -313,7 +313,7 @@ void Client::SendZoneCancel(ZoneChange_Struct *zc) { void Client::SendZoneError(ZoneChange_Struct *zc, int8 err) { - Log(Logs::General, Logs::Error, "Zone %i is not available because target wasn't found or character insufficent level", zc->zoneID); + LogError("Zone [{}] is not available because target wasn't found or character insufficent level", zc->zoneID); EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_ZoneChange, sizeof(ZoneChange_Struct)); @@ -471,7 +471,7 @@ void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm); break; default: - Log(Logs::General, Logs::Error, "Client::ProcessMovePC received a reguest to perform an unsupported client zone operation."); + LogError("Client::ProcessMovePC received a reguest to perform an unsupported client zone operation"); break; } } @@ -547,7 +547,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z SetHeading(heading); break; default: - Log(Logs::General, Logs::Error, "Client::ZonePC() received a reguest to perform an unsupported client zone operation."); + LogError("Client::ZonePC() received a reguest to perform an unsupported client zone operation"); ReadyToZone = false; break; } @@ -777,7 +777,7 @@ void Client::SetZoneFlag(uint32 zone_id) { std::string query = StringFormat("INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)", CharacterID(), zone_id); auto results = database.QueryDatabase(query); if(!results.Success()) - Log(Logs::General, Logs::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), results.ErrorMessage().c_str()); + LogError("MySQL Error while trying to set zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str()); } void Client::ClearZoneFlag(uint32 zone_id) { @@ -790,7 +790,7 @@ void Client::ClearZoneFlag(uint32 zone_id) { std::string query = StringFormat("DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d", CharacterID(), zone_id); auto results = database.QueryDatabase(query); if(!results.Success()) - Log(Logs::General, Logs::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), results.ErrorMessage().c_str()); + LogError("MySQL Error while trying to clear zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str()); } @@ -800,7 +800,7 @@ void Client::LoadZoneFlags() { std::string query = StringFormat("SELECT zoneID from zone_flags WHERE charID=%d", CharacterID()); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log(Logs::General, Logs::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), results.ErrorMessage().c_str()); + LogError("MySQL Error while trying to load zone flags for [{}]: [{}]", GetName(), results.ErrorMessage().c_str()); return; }