From aab04a0df85a5ba4639dbd5a3b598a55f4b298d9 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Wed, 15 Nov 2023 01:46:43 -0300 Subject: [PATCH 1/3] update --- .../scripts/actions/other/outfit_memorial.lua | 4 +- data/libs/functions/player.lua | 2 +- data/libs/functions/quests.lua | 16 +- data/libs/hireling_lib.lua | 2 +- data/modules/scripts/blessings/blessings.lua | 2 +- .../scripts/daily_reward/daily_reward.lua | 12 +- data/modules/scripts/gamestore/init.lua | 50 +-- .../network/network_message_functions.cpp | 5 +- src/server/network/message/networkmessage.cpp | 8 +- src/server/network/message/networkmessage.hpp | 2 +- src/server/network/protocol/protocolgame.cpp | 310 +++++++++--------- src/server/network/protocol/protocollogin.cpp | 12 +- .../network/protocol/protocolstatus.cpp | 28 +- 13 files changed, 227 insertions(+), 226 deletions(-) diff --git a/data-otservbr-global/scripts/actions/other/outfit_memorial.lua b/data-otservbr-global/scripts/actions/other/outfit_memorial.lua index d722bb13274..6061d5f11b9 100644 --- a/data-otservbr-global/scripts/actions/other/outfit_memorial.lua +++ b/data-otservbr-global/scripts/actions/other/outfit_memorial.lua @@ -39,7 +39,7 @@ function outfitMemorial.onUse(player, item, fromPosition, target, toPosition, is for i = 1, 3 do response:addU16(#goldenOutfitCache[i]) for j = 1, #goldenOutfitCache[i] do - response:addString(goldenOutfitCache[i][j]) + response:addString(goldenOutfitCache[i][j], "outfitMemorial.onUse - goldenOutfitCache[i][j]") end end @@ -52,7 +52,7 @@ function outfitMemorial.onUse(player, item, fromPosition, target, toPosition, is for i = 1, 3 do response:addU16(#royalOutfitCache[i]) for j = 1, #royalOutfitCache[i] do - response:addString(royalOutfitCache[i][j]) + response:addString(royalOutfitCache[i][j], "outfitMemorial.onUse - royalOutfitCache[i][j]") end end diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index c2bdde967f6..613f1c02a8c 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -64,7 +64,7 @@ function Player.sendExtendedOpcode(self, opcode, buffer) local networkMessage = NetworkMessage() networkMessage:addByte(0x32) networkMessage:addByte(opcode) - networkMessage:addString(buffer) + networkMessage:addString(buffer, "Player.sendExtendedOpcode - buffer") networkMessage:sendToPlayer(self) networkMessage:delete() return true diff --git a/data/libs/functions/quests.lua b/data/libs/functions/quests.lua index 66414115eaf..02487c55031 100644 --- a/data/libs/functions/quests.lua +++ b/data/libs/functions/quests.lua @@ -297,7 +297,7 @@ function Player.sendQuestLog(self) for questId = 1, #Quests do if self:questIsStarted(questId) then msg:addU16(questId) - msg:addString(Quests[questId].name .. (self:questIsCompleted(questId) and " (completed)" or "")) + msg:addString(Quests[questId].name .. (self:questIsCompleted(questId) and " (completed)" or ""), "Player.sendQuestLog") msg:addByte(self:questIsCompleted(questId)) end end @@ -319,8 +319,8 @@ function Player.sendQuestLine(self, questId) if self:getClient().version >= 1200 then msg:addU16(self:getMissionId(questId, missionId)) end - msg:addString(self:getMissionName(questId, missionId)) - msg:addString(self:getMissionDescription(questId, missionId)) + msg:addString(self:getMissionName(questId, missionId), "Player.sendQuestLine - self:getMissionName(questId, missionId)") + msg:addString(self:getMissionDescription(questId, missionId), "Player.sendQuestLine - self:getMissionDescription(questId, missionId)") end end end @@ -338,9 +338,9 @@ function Player.sendTrackedQuests(self, remainingQuests, missions) msg:addByte(#missions) for _, mission in ipairs(missions) do msg:addU16(mission.missionId) - msg:addString(mission.questName) - msg:addString(mission.missionName) - msg:addString(mission.missionDesc) + msg:addString(mission.questName, "Player.sendTrackedQuests - mission.questName") + msg:addString(mission.missionName, "Player.sendTrackedQuests - mission.missionName") + msg:addString(mission.missionDesc, "Player.sendTrackedQuests - mission.missionDesc") end msg:sendToPlayer(self) msg:delete() @@ -351,8 +351,8 @@ function Player.sendUpdateTrackedQuest(self, mission) msg:addByte(0xD0) msg:addByte(0x00) msg:addU16(mission.missionId) - msg:addString(mission.missionName) - msg:addString(mission.missionDesc) + msg:addString(mission.missionName, "Player.sendUpdateTrackedQuest - mission.missionName") + msg:addString(mission.missionDesc, "Player.sendUpdateTrackedQuest - mission.missionDesc") msg:sendToPlayer(self) msg:delete() end diff --git a/data/libs/hireling_lib.lua b/data/libs/hireling_lib.lua index beadcdb6cf1..e460d266823 100644 --- a/data/libs/hireling_lib.lua +++ b/data/libs/hireling_lib.lua @@ -617,7 +617,7 @@ function Player:sendHirelingOutfitWindow(hireling) msg:addU16(#availableOutfits) for _, outfit in ipairs(availableOutfits) do msg:addU16(outfit.lookType) - msg:addString(outfit.name) + msg:addString(outfit.name, "Player:sendHirelingOutfitWindow - outfit.name") msg:addByte(0x00) -- addons msg:addByte(0x00) -- Store bool end diff --git a/data/modules/scripts/blessings/blessings.lua b/data/modules/scripts/blessings/blessings.lua index b4494c24003..ea2183ea0a5 100644 --- a/data/modules/scripts/blessings/blessings.lua +++ b/data/modules/scripts/blessings/blessings.lua @@ -183,7 +183,7 @@ Blessings.sendBlessDialog = function(player) for i = 1, historyAmount do msg:addU32(os.time()) -- timestamp msg:addByte(0) -- Color message (1 - Red | 0 = White loss) - msg:addString("Blessing Purchased") -- History message + msg:addString("Blessing Purchased", "Blessings.sendBlessDialog - Blessing Purchased") -- History message end msg:sendToPlayer(player) diff --git a/data/modules/scripts/daily_reward/daily_reward.lua b/data/modules/scripts/daily_reward/daily_reward.lua index 640ec0b2203..de4116f7ed3 100644 --- a/data/modules/scripts/daily_reward/daily_reward.lua +++ b/data/modules/scripts/daily_reward/daily_reward.lua @@ -367,7 +367,7 @@ function Player.sendOpenRewardWall(self, shrine) msg:addByte(self:getDayStreak()) -- current reward? day = 0, day 1, ... this should be resetted to 0 every week imo if DailyReward.isRewardTaken(self:getId()) then -- state (player already took reward? but just make sure noone wpe) msg:addByte(1) - msg:addString("Sorry, you have already taken your daily reward or you are unable to collect it.") -- Unknown message + msg:addString("Sorry, you have already taken your daily reward or you are unable to collect it.", "Player.sendOpenRewardWall - Sorry, you have already taken your daily reward or you are unable to collect it.") -- Unknown message if self:getJokerTokens() > 0 then msg:addByte(1) msg:addU16(self:getJokerTokens()) @@ -529,7 +529,7 @@ function Player.sendError(self, error) local msg = NetworkMessage() msg:addByte(ServerPackets.ShowDialog) msg:addByte(0x14) - msg:addString(error) + msg:addString(error, "Player.sendError - error") msg:sendToPlayer(self) end @@ -562,7 +562,7 @@ function Player.sendRewardHistory(self) for k, entry in ipairs(entries) do msg:addU32(entry.timestamp) msg:addByte(0) -- (self:isPremium() and 0 or 0) - msg:addString(entry.description) + msg:addString(entry.description, "Player.sendRewardHistory - entry.description") msg:addU16(entry.daystreak + 1) end msg:sendToPlayer(self) @@ -595,7 +595,7 @@ function Player.readDailyReward(self, msg, currentDay, state) local itemName = itemType:getArticle() .. " " .. itemType:getName() local itemWeight = itemType:getWeight() msg:addU16(itemId) - msg:addString(itemName) + msg:addString(itemName, "Player.readDailyReward - itemName") msg:addU32(itemWeight) end end @@ -605,7 +605,7 @@ function Player.readDailyReward(self, msg, currentDay, state) -- for i = 1, #rewards.things do -- msg:addByte(DAILY_REWARD_SYSTEM_TYPE_OTHER) -- type -- msg:addU16(rewards.things[i].id * 100) - -- msg:addString(rewards.things[i].name) + -- msg:addString(rewards.things[i].name, "Player.readDailyReward - rewards.things[i].name") -- msg:addByte(rewards.things[i].quantity) -- end elseif type == DAILY_REWARD_TYPE_PREY_REROLL then @@ -636,7 +636,7 @@ function Player.sendDailyReward(self) local maxBonus = 7 msg:addByte(maxBonus - 1) for i = 2, maxBonus do - msg:addString(DailyReward.strikeBonuses[i].text) + msg:addString(DailyReward.strikeBonuses[i].text, "Player.sendDailyReward - DailyReward.strikeBonuses[i].text") msg:addByte(i) end msg:addByte(1) -- Unknown diff --git a/data/modules/scripts/gamestore/init.lua b/data/modules/scripts/gamestore/init.lua index 7f0f2a80ca8..5ccc6ca39f2 100644 --- a/data/modules/scripts/gamestore/init.lua +++ b/data/modules/scripts/gamestore/init.lua @@ -575,9 +575,9 @@ function openStore(playerId) GameStoreCategories, GameStoreCount = GameStore.Categories, #GameStore.Categories end local addCategory = function(category) - msg:addString(category.name) + msg:addString(category.name, "openStore - category.name") if oldProtocol then - msg:addString(category.description) + msg:addString(category.description, "openStore - category.description") end msg:addByte(category.state or GameStore.States.STATE_NONE) @@ -585,13 +585,13 @@ function openStore(playerId) msg:addByte(size) for _, icon in ipairs(category.icons) do if size > 0 then - msg:addString(icon) + msg:addString(icon, "openStore - icon") size = size - 1 end end if category.parent then - msg:addString(category.parent) + msg:addString(category.parent, "openStore - category.parent") else msg:addU16(0) end @@ -611,7 +611,7 @@ function sendOfferDescription(player, offerId, description) local msg = NetworkMessage() msg:addByte(0xEA) msg:addU32(offerId) - msg:addString(description) + msg:addString(description, "sendOfferDescription - description") msg:sendToPlayer(player) end @@ -782,7 +782,7 @@ function sendShowStoreOffers(playerId, category, redirectId) local msg = NetworkMessage() local haveSaleOffer = 0 msg:addByte(GameStore.SendingPackets.S_StoreOffers) - msg:addString(category.name) + msg:addString(category.name, "sendShowStoreOffers - category.name") local categoryLimit = 65535 if oldProtocol then @@ -849,7 +849,7 @@ function sendShowStoreOffers(playerId, category, redirectId) msg:addU16(#disableReasons) for _, reason in ipairs(disableReasons) do - msg:addString(reason) + msg:addString(reason, "sendShowStoreOffers - reason") end if count > categoryLimit then @@ -860,7 +860,7 @@ function sendShowStoreOffers(playerId, category, redirectId) for name, offer in pairs(offers) do if count > 0 then count = count - 1 - msg:addString(name) + msg:addString(name, "sendShowStoreOffers - name") msg:addByte(#offer.offers) sendOfferDescription(player, offer.id and offer.id or 0xFFFF, offer.description) for _, off in ipairs(offer.offers) do @@ -905,7 +905,7 @@ function sendShowStoreOffers(playerId, category, redirectId) msg:addByte(type) if type == GameStore.ConverType.SHOW_NONE then - msg:addString(offer.icons[1]) + msg:addString(offer.icons[1], "sendShowStoreOffers - offer.icons[1]") elseif type == GameStore.ConverType.SHOW_MOUNT then local mount = Mount(offer.id) msg:addU16(mount:getClientId()) @@ -971,7 +971,7 @@ function sendShowStoreOffersOnOldProtocol(playerId, category) local msg = NetworkMessage() local haveSaleOffer = 0 msg:addByte(GameStore.SendingPackets.S_StoreOffers) - msg:addString(category.name) + msg:addString(category.name, "sendShowStoreOffersOnOldProtocol - category.name") if not category.offers then msg:addU16(0) @@ -1017,8 +1017,8 @@ function sendShowStoreOffersOnOldProtocol(playerId, category) local disabled, disabledReason = player:canBuyOffer(offer).disabled, player:canBuyOffer(offer).disabledReason local offerPrice = offer.type == GameStore.OfferTypes.OFFER_TYPE_EXPBOOST and GameStore.ExpBoostValues[player:getStorageValue(GameStore.Storages.expBoostCount)] or (newPrice or offer.price or 0xFFFF) msg:addU32(offer.id and offer.id or 0xFFFF) - msg:addString(name) - msg:addString(offer.description or GameStore.getDefaultDescription(offer.type, offer.count)) + msg:addString(name, "sendShowStoreOffersOnOldProtocol - name") + msg:addString(offer.description or GameStore.getDefaultDescription(offer.type, offer.count), "sendShowStoreOffersOnOldProtocol - offer.description or GameStore.getDefaultDescription(offer.type, offer.count)") msg:addU32(offerPrice) if offer.state then if offer.state == GameStore.States.STATE_SALE then @@ -1040,20 +1040,20 @@ function sendShowStoreOffersOnOldProtocol(playerId, category) msg:addByte(disabled) if disabled == 1 then - msg:addString(disabledReason) + msg:addString(disabledReason, "sendShowStoreOffersOnOldProtocol - disabledReason") end if offer.type == GameStore.OfferTypes.OFFER_TYPE_MOUNT then msg:addByte(1) - msg:addString((offer.name):gsub("% ", "_") .. ".png") + msg:addString((offer.name):gsub("% ", "_") .. ".png", "sendShowStoreOffersOnOldProtocol - (offer.name).png") elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_OUTFIT then msg:addByte(2) - msg:addString(offer.icons[1]) - msg:addString(offer.icons[2]) + msg:addString(offer.icons[1], "sendShowStoreOffersOnOldProtocol - offer.icons[1]") + msg:addString(offer.icons[2], "sendShowStoreOffersOnOldProtocol - offer.icons[2]") else msg:addByte(#offer.icons) for k, icon in ipairs(offer.icons) do - msg:addString(icon) + msg:addString(icon, "sendShowStoreOffersOnOldProtocol - icon") end end @@ -1094,7 +1094,7 @@ function sendStoreTransactionHistory(playerId, page, entriesPerPage) if not oldProtocol then msg:addByte(0x0) -- 0 = transferable tibia coin, 1 = normal tibia coin end - msg:addString(entry.description) + msg:addString(entry.description, "sendStoreTransactionHistory - entry.description") if not oldProtocol then msg:addByte(0) -- details end @@ -1112,7 +1112,7 @@ function sendStorePurchaseSuccessful(playerId, message) local msg = NetworkMessage() msg:addByte(GameStore.SendingPackets.S_CompletePurchase) msg:addByte(0x00) - msg:addString(message) + msg:addString(message, "sendStorePurchaseSuccessful - message") if oldProtocol then -- Send all coins can be used for buy store offers local totalCoins = player:getTibiaCoins() + player:getTransferableCoins() @@ -1134,7 +1134,7 @@ function sendStoreError(playerId, errorType, message) msg:addByte(GameStore.SendingPackets.S_StoreError) msg:addByte(errorType) - msg:addString(message) + msg:addString(message, "sendStoreError - message") msg:sendToPlayer(player) end @@ -2085,7 +2085,7 @@ function sendHomePage(playerId) local msg = NetworkMessage() msg:addByte(GameStore.SendingPackets.S_StoreOffers) - msg:addString("Home") + msg:addString("Home", "sendHomePage - Home") msg:addU32(0x0) -- Redirect ID (not used here) msg:addByte(0x0) -- Window Type msg:addByte(0x0) -- Collections Size @@ -2111,13 +2111,13 @@ function sendHomePage(playerId) msg:addU16(#disableReasons) for _, reason in ipairs(disableReasons) do - msg:addString(reason) + msg:addString(reason, "sendHomePage - reason") end msg:addU16(#homeOffers) -- offers for p, offer in pairs(homeOffers) do - msg:addString(offer.name) + msg:addString(offer.name, "sendHomePage - offer.name") msg:addByte(0x1) -- ? msg:addU32(offer.id or 0) -- id msg:addU16(0x1) @@ -2137,7 +2137,7 @@ function sendHomePage(playerId) msg:addByte(type) if type == GameStore.ConverType.SHOW_NONE then - msg:addString(offer.icons[1]) + msg:addString(offer.icons[1], "sendHomePage - offer.icons[1]") elseif type == GameStore.ConverType.SHOW_MOUNT then local mount = Mount(offer.id) msg:addU16(mount:getClientId()) @@ -2163,7 +2163,7 @@ function sendHomePage(playerId) local banner = HomeBanners msg:addByte(#banner.images) for m, image in ipairs(banner.images) do - msg:addString(image) + msg:addString(image, "sendHomePage - image") msg:addByte(0x04) -- Banner Type (offer) msg:addU32(0x00) -- Offer Id msg:addByte(0) diff --git a/src/lua/functions/core/network/network_message_functions.cpp b/src/lua/functions/core/network/network_message_functions.cpp index a0f02631a1c..13d8ceca7fe 100644 --- a/src/lua/functions/core/network/network_message_functions.cpp +++ b/src/lua/functions/core/network/network_message_functions.cpp @@ -191,11 +191,12 @@ int NetworkMessageFunctions::luaNetworkMessageAdd64(lua_State* L) { } int NetworkMessageFunctions::luaNetworkMessageAddString(lua_State* L) { - // networkMessage:addString(string) + // networkMessage:addString(string, function) const std::string &string = getString(L, 2); + const std::string &function = getString(L, 3); const auto &message = getUserdataShared(L, 1); if (message) { - message->addString(string); + message->addString(string, function); pushBoolean(L, true); } else { lua_pushnil(L); diff --git a/src/server/network/message/networkmessage.cpp b/src/server/network/message/networkmessage.cpp index 457e3b32be0..9c10b4907df 100644 --- a/src/server/network/message/networkmessage.cpp +++ b/src/server/network/message/networkmessage.cpp @@ -40,17 +40,17 @@ Position NetworkMessage::getPosition() { return pos; } -void NetworkMessage::addString(const std::string &value) { +void NetworkMessage::addString(const std::string &value, const std::string &function) { size_t stringLen = value.length(); if (value.empty()) { - g_logger().debug("[NetworkMessage::addString] - Value string is empty"); + g_logger().debug("[NetworkMessage::addString] - Value string is empty, function '{}'", function); } if (!canAdd(stringLen + 2)) { - g_logger().error("[NetworkMessage::addString] - NetworkMessage size is wrong: {}", stringLen); + g_logger().error("[NetworkMessage::addString] - NetworkMessage size is wrong: {}, function '{}'", stringLen, function); return; } if (stringLen > NETWORKMESSAGE_MAXSIZE) { - g_logger().error("[NetworkMessage::addString] - Exceded NetworkMessage max size: {}, actually size: {}", NETWORKMESSAGE_MAXSIZE, stringLen); + g_logger().error("[NetworkMessage::addString] - Exceded NetworkMessage max size: {}, actually size: {}, function '{}'", NETWORKMESSAGE_MAXSIZE, stringLen, function); return; } diff --git a/src/server/network/message/networkmessage.hpp b/src/server/network/message/networkmessage.hpp index 3635475a8d7..3051e87bb22 100644 --- a/src/server/network/message/networkmessage.hpp +++ b/src/server/network/message/networkmessage.hpp @@ -90,7 +90,7 @@ class NetworkMessage { void addBytes(const char* bytes, size_t size); void addPaddingBytes(size_t n); - void addString(const std::string &value); + void addString(const std::string &value, const std::string &function); void addDouble(double value, uint8_t precision = 2); diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index dc6cea87b90..a49a434039c 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -228,7 +228,7 @@ namespace { g_logger().debug("Sendding category number '{}', category name '{}'", static_cast(value), magic_enum::enum_name(value).data()); msg.addByte(static_cast(value)); - msg.addString(toStartCaseWithSpace(magic_enum::enum_name(value).data())); + msg.addString(toStartCaseWithSpace(magic_enum::enum_name(value).data()), "void sendContainerCategory - toStartCaseWithSpace(magic_enum::enum_name(value).data())"); } } } // namespace @@ -551,7 +551,7 @@ void ProtocolGame::login(const std::string &name, uint32_t accountId, OperatingS auto output = OutputMessagePool::getOutputMessage(); output->addByte(0x16); - output->addString(ss.str()); + output->addString(ss.str(), "ProtocolGame::login - ss.str()"); output->addByte(retryTime); send(output); disconnect(); @@ -795,7 +795,7 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage &msg) { auto output = OutputMessagePool::getOutputMessage(); output->addByte(0x14); - output->addString(ss.str()); + output->addString(ss.str(), "ProtocolGame::onRecvFirstMessage - ss.str()"); send(output); g_dispatcher().scheduleEvent(1000, std::bind(&ProtocolGame::disconnect, getThis()), "ProtocolGame::disconnect"); return; @@ -835,7 +835,7 @@ void ProtocolGame::onConnect() { void ProtocolGame::disconnectClient(const std::string &message) const { auto output = OutputMessagePool::getOutputMessage(); output->addByte(0x14); - output->addString(message); + output->addString(message, "ProtocolGame::disconnectClient - message"); send(output); disconnect(); } @@ -1987,10 +1987,10 @@ void ProtocolGame::sendItemInspection(uint16_t itemId, uint8_t itemCount, std::s const ItemType &it = Item::items[itemId]; if (item) { - msg.addString(item->getName()); + msg.addString(item->getName(), "ProtocolGame::sendItemInspection - item->getName()"); AddItem(msg, item); } else { - msg.addString(it.name); + msg.addString(it.name, "ProtocolGame::sendItemInspection - it.name"); AddItem(msg, it.id, itemCount, 0); } msg.addByte(0); @@ -1998,8 +1998,8 @@ void ProtocolGame::sendItemInspection(uint16_t itemId, uint8_t itemCount, std::s auto descriptions = Item::getDescriptions(it, item); msg.addByte(descriptions.size()); for (const auto &description : descriptions) { - msg.addString(description.first); - msg.addString(description.second); + msg.addString(description.first, "ProtocolGame::sendItemInspection - description.first"); + msg.addString(description.second, "ProtocolGame::sendItemInspection - description.second"); } writeToOutputBuffer(msg); } @@ -2081,8 +2081,8 @@ void ProtocolGame::sendHighscores(const std::vector &charact msg.addByte(0x00); // No data available msg.addByte(1); // Worlds - msg.addString(g_configManager().getString(SERVER_NAME)); // First World - msg.addString(g_configManager().getString(SERVER_NAME)); // Selected World + msg.addString(g_configManager().getString(SERVER_NAME), "ProtocolGame::sendHighscores - g_configManager().getString(SERVER_NAME)"); // First World + msg.addString(g_configManager().getString(SERVER_NAME), "ProtocolGame::sendHighscores - g_configManager().getString(SERVER_NAME)"); // Selected World msg.addByte(0); // Game World Category: 0xFF(-1) - Selected World msg.addByte(0); // BattlEye World Type @@ -2092,7 +2092,7 @@ void ProtocolGame::sendHighscores(const std::vector &charact msg.skipBytes(1); // Vocation Count msg.add(0xFFFFFFFF); // All Vocations - hardcoded - msg.addString("(all)"); // All Vocations - hardcoded + msg.addString("(all)", "ProtocolGame::sendHighscores - (all)"); // All Vocations - hardcoded uint32_t selectedVocation = 0xFFFFFFFF; const auto vocationsMap = g_vocations().getVocations(); @@ -2100,7 +2100,7 @@ void ProtocolGame::sendHighscores(const std::vector &charact const Vocation &vocation = it.second; if (vocation.getFromVocation() == static_cast(vocation.getId())) { msg.add(vocation.getFromVocation()); // Vocation Id - msg.addString(vocation.getVocName()); // Vocation Name + msg.addString(vocation.getVocName(), "ProtocolGame::sendHighscores - vocation.getVocName()"); // Vocation Name ++vocations; if (vocation.getFromVocation() == vocationId) { selectedVocation = vocationId; @@ -2125,7 +2125,7 @@ void ProtocolGame::sendHighscores(const std::vector &charact msg.addByte(sizeof(highscoreCategories) / sizeof(HighscoreCategory)); // Category Count for (HighscoreCategory &category : highscoreCategories) { msg.addByte(category.id); // Category Id - msg.addString(category.name); // Category Name + msg.addString(category.name, "ProtocolGame::sendHighscores - category.name"); // Category Name if (category.id == categoryId) { selectedCategory = categoryId; } @@ -2138,10 +2138,10 @@ void ProtocolGame::sendHighscores(const std::vector &charact msg.addByte(characters.size()); // Character Count for (const HighscoreCharacter &character : characters) { msg.add(character.rank); // Rank - msg.addString(character.name); // Character Name - msg.addString(""); // Probably Character Title(not visible in window) + msg.addString(character.name, "ProtocolGame::sendHighscores - character.name"); // Character Name + msg.addString("", "ProtocolGame::sendHighscores - empty"); // Probably Character Title(not visible in window) msg.addByte(character.vocation); // Vocation Id - msg.addString(g_configManager().getString(SERVER_NAME)); // World + msg.addString(g_configManager().getString(SERVER_NAME), "ProtocolGame::sendHighscores - g_configManager().getString(SERVER_NAME)"); // World msg.add(character.level); // Level msg.addByte((player->getGUID() == character.id)); // Player Indicator Boolean msg.add(character.points); // Points @@ -2205,7 +2205,7 @@ void ProtocolGame::parseBestiarysendRaces() { BestClass = mtype->info.bestiaryClass; } } - msg.addString(BestClass); + msg.addString(BestClass, "ProtocolGame::parseBestiarysendRaces - BestClass"); msg.add(count); uint16_t unlockedCount = g_iobestiary().getBestiaryRaceUnlocked(player, static_cast(i)); msg.add(unlockedCount); @@ -2257,7 +2257,7 @@ void ProtocolGame::parseBestiarysendMonsterData(NetworkMessage &msg) { NetworkMessage newmsg; newmsg.addByte(0xd7); newmsg.add(raceId); - newmsg.addString(Class); + newmsg.addString(Class, "ProtocolGame::parseBestiarysendMonsterData - Class"); newmsg.addByte(currentLevel); newmsg.add(killCounter); @@ -2298,7 +2298,7 @@ void ProtocolGame::parseBestiarysendMonsterData(NetworkMessage &msg) { newmsg.addByte(difficult); newmsg.addByte(0); // 1 if special event - 0 if regular loot (?) if (shouldAddItem == true) { - newmsg.addString(loot.name); + newmsg.addString(loot.name, "ProtocolGame::parseBestiarysendMonsterData - loot.name"); newmsg.addByte(loot.countmax > 0 ? 0x1 : 0x0); } } @@ -2331,7 +2331,7 @@ void ProtocolGame::parseBestiarysendMonsterData(NetworkMessage &msg) { } newmsg.add(1); - newmsg.addString(mtype->info.bestiaryLocations); + newmsg.addString(mtype->info.bestiaryLocations, "ProtocolGame::parseBestiarysendMonsterData - mtype->info.bestiaryLocations"); } if (currentLevel > 3) { @@ -2409,7 +2409,7 @@ void ProtocolGame::sendTeamFinderList() { uint8_t status = 0; uint16_t membersSize = 0; msg.add(leader->getGUID()); - msg.addString(leader->getName()); + msg.addString(leader->getName(), "ProtocolGame::sendTeamFinderList - leader->getName()"); msg.add(teamAssemble->minLevel); msg.add(teamAssemble->maxLevel); msg.addByte(teamAssemble->vocationIDs); @@ -2515,7 +2515,7 @@ void ProtocolGame::sendLeaderTeamFinder(bool reset) { } msg.add(leader->getGUID()); - msg.addString(leader->getName()); + msg.addString(leader->getName(), "ProtocolGame::sendLeaderTeamFinder - leader->getName()"); msg.add(leader->getLevel()); msg.addByte(leader->getVocation()->getClientId()); msg.addByte(3); @@ -2526,7 +2526,7 @@ void ProtocolGame::sendLeaderTeamFinder(bool reset) { continue; } msg.add(member->getGUID()); - msg.addString(member->getName()); + msg.addString(member->getName(), "ProtocolGame::sendLeaderTeamFinder - member->getName()"); msg.add(member->getLevel()); msg.addByte(member->getVocation()->getClientId()); msg.addByte(memberPair.second); @@ -2792,8 +2792,8 @@ void ProtocolGame::BestiarysendCharms() { msg.addByte(charmList.size()); for (const auto &c_type : charmList) { msg.addByte(c_type->id); - msg.addString(c_type->name); - msg.addString(c_type->description); + msg.addString(c_type->name, "ProtocolGame::BestiarysendCharms - c_type->name"); + msg.addString(c_type->description, "ProtocolGame::BestiarysendCharms - c_type->description"); msg.addByte(0); // Unknown msg.add(c_type->points); if (g_iobestiary().hasCharmUnlockedRuneBit(c_type, player->getUnlockedRunesBit())) { @@ -2865,7 +2865,7 @@ void ProtocolGame::parseBestiarysendCreatures(NetworkMessage &msg) { } NetworkMessage newmsg; newmsg.addByte(0xd6); - newmsg.addString(text); + newmsg.addString(text, "ProtocolGame::parseBestiarysendCreatures - text"); newmsg.add(race.size()); std::map creaturesKilled = g_iobestiary().getBestiaryKillCountByMonsterIDs(player, race); @@ -3085,7 +3085,7 @@ void ProtocolGame::parseSeekInContainer(NetworkMessage &msg) { void ProtocolGame::sendOpenPrivateChannel(const std::string &receiver) { NetworkMessage msg; msg.addByte(0xAD); - msg.addString(receiver); + msg.addString(receiver, "ProtocolGame::sendOpenPrivateChannel - receiver"); writeToOutputBuffer(msg); } @@ -3105,7 +3105,7 @@ void ProtocolGame::sendChannelEvent(uint16_t channelId, const std::string &playe NetworkMessage msg; msg.addByte(0xF3); msg.add(channelId); - msg.addString(playerName); + msg.addString(playerName, "ProtocolGame::sendChannelEvent - playerName"); msg.addByte(channelEvent); writeToOutputBuffer(msg); } @@ -3299,7 +3299,7 @@ void ProtocolGame::sendAddMarker(const Position &pos, uint8_t markType, const st msg.addPosition(pos); msg.addByte(markType); - msg.addString(desc); + msg.addString(desc, "ProtocolGame::sendAddMarker - desc"); writeToOutputBuffer(msg); } @@ -3324,13 +3324,13 @@ void ProtocolGame::sendCyclopediaCharacterBaseInformation() { msg.addByte(0xDA); msg.addByte(CYCLOPEDIA_CHARACTERINFO_BASEINFORMATION); msg.addByte(0x00); - msg.addString(player->getName()); - msg.addString(player->getVocation()->getVocName()); + msg.addString(player->getName(), "ProtocolGame::sendCyclopediaCharacterBaseInformation - player->getName()"); + msg.addString(player->getVocation()->getVocName(), "ProtocolGame::sendCyclopediaCharacterBaseInformation - player->getVocation()->getVocName()"); msg.add(player->getLevel()); AddOutfit(msg, player->getDefaultOutfit(), false); msg.addByte(0x00); // hide stamina - msg.addString(""); // character title + msg.addString("", "ProtocolGame::sendCyclopediaCharacterBaseInformation - empty"); // character title writeToOutputBuffer(msg); } @@ -3570,7 +3570,7 @@ void ProtocolGame::sendCyclopediaCharacterRecentDeaths(uint16_t page, uint16_t p msg.add(entries.size()); for (const RecentDeathEntry &entry : entries) { msg.add(entry.timestamp); - msg.addString(entry.cause); + msg.addString(entry.cause, "ProtocolGame::sendCyclopediaCharacterRecentDeaths - entry.cause"); } writeToOutputBuffer(msg); } @@ -3589,7 +3589,7 @@ void ProtocolGame::sendCyclopediaCharacterRecentPvPKills(uint16_t page, uint16_t msg.add(entries.size()); for (const RecentPvPKillEntry &entry : entries) { msg.add(entry.timestamp); - msg.addString(entry.description); + msg.addString(entry.description, "ProtocolGame::sendCyclopediaCharacterRecentPvPKills - entry.description"); msg.addByte(entry.status); } writeToOutputBuffer(msg); @@ -3654,7 +3654,7 @@ void ProtocolGame::sendCyclopediaCharacterOutfitsMounts() { ++outfitSize; msg.add(outfit->lookType); - msg.addString(outfit->name); + msg.addString(outfit->name, "ProtocolGame::sendCyclopediaCharacterOutfitsMounts - outfit->name"); msg.addByte(addons); if (from == "store") { msg.addByte(CYCLOPEDIA_CHARACTERINFO_OUTFITTYPE_STORE); @@ -3685,7 +3685,7 @@ void ProtocolGame::sendCyclopediaCharacterOutfitsMounts() { ++mountSize; msg.add(mount->clientId); - msg.addString(mount->name); + msg.addString(mount->name, "ProtocolGame::sendCyclopediaCharacterOutfitsMounts - mount->name"); if (type == "store") { msg.addByte(CYCLOPEDIA_CHARACTERINFO_OUTFITTYPE_STORE); } else if (type == "quest") { @@ -3714,7 +3714,7 @@ void ProtocolGame::sendCyclopediaCharacterOutfitsMounts() { } ++familiarsSize; msg.add(familiar.lookType); - msg.addString(familiar.name); + msg.addString(familiar.name, "ProtocolGame::sendCyclopediaCharacterOutfitsMounts - familiar.name"); if (type == "quest") { msg.addByte(CYCLOPEDIA_CHARACTERINFO_OUTFITTYPE_QUEST); } else { @@ -3775,19 +3775,19 @@ void ProtocolGame::sendCyclopediaCharacterInspection() { ++inventoryItems; msg.addByte(slot); - msg.addString(inventoryItem->getName()); + msg.addString(inventoryItem->getName(), "ProtocolGame::sendCyclopediaCharacterInspection - inventoryItem->getName()"); AddItem(msg, inventoryItem); msg.addByte(0); auto descriptions = Item::getDescriptions(Item::items[inventoryItem->getID()], inventoryItem); msg.addByte(descriptions.size()); for (const auto &description : descriptions) { - msg.addString(description.first); - msg.addString(description.second); + msg.addString(description.first, "ProtocolGame::sendCyclopediaCharacterInspection - description.first"); + msg.addString(description.second, "ProtocolGame::sendCyclopediaCharacterInspection - description.second"); } } } - msg.addString(player->getName()); + msg.addString(player->getName(), "ProtocolGame::sendCyclopediaCharacterInspection - player->getName()"); AddOutfit(msg, player->getDefaultOutfit(), false); // Player overall summary @@ -3797,28 +3797,28 @@ void ProtocolGame::sendCyclopediaCharacterInspection() { // Level description playerDescriptionSize++; - msg.addString("Level"); + msg.addString("Level", "ProtocolGame::sendCyclopediaCharacterInspection - Level"); // Vocation description playerDescriptionSize++; - msg.addString(std::to_string(player->getLevel())); - msg.addString("Vocation"); - msg.addString(player->getVocation()->getVocName()); + msg.addString(std::to_string(player->getLevel()), "ProtocolGame::sendCyclopediaCharacterInspection - std::to_string(player->getLevel())"); + msg.addString("Vocation", "ProtocolGame::sendCyclopediaCharacterInspection - Vocation"); + msg.addString(player->getVocation()->getVocName(), "ProtocolGame::sendCyclopediaCharacterInspection - player->getVocation()->getVocName()"); // Loyalty title if (player->getLoyaltyTitle().length() != 0) { playerDescriptionSize++; - msg.addString("Loyalty Title"); - msg.addString(player->getLoyaltyTitle()); + msg.addString("Loyalty Title", "ProtocolGame::sendCyclopediaCharacterInspection - Loyalty Title"); + msg.addString(player->getLoyaltyTitle(), "ProtocolGame::sendCyclopediaCharacterInspection - player->getLoyaltyTitle()"); } // Outfit description playerDescriptionSize++; - msg.addString("Outfit"); + msg.addString("Outfit", "ProtocolGame::sendCyclopediaCharacterInspection - Outfit"); if (const auto outfit = Outfits::getInstance().getOutfitByLookType(player->getSex(), player->getDefaultOutfit().lookType)) { - msg.addString(outfit->name); + msg.addString(outfit->name, "ProtocolGame::sendCyclopediaCharacterInspection - outfit->name"); } else { - msg.addString("unknown"); + msg.addString("unknown", "ProtocolGame::sendCyclopediaCharacterInspection - unknown"); } msg.setBufferPosition(startInventory); @@ -3848,7 +3848,7 @@ void ProtocolGame::sendCyclopediaCharacterBadges() { // IsPremium (GOD has always 'Premium') msg.addByte(player->isPremium() ? 0x01 : 0x00); // Character loyalty title - msg.addString(player->getLoyaltyTitle()); + msg.addString(player->getLoyaltyTitle(), "ProtocolGame::sendCyclopediaCharacterBadges - player->getLoyaltyTitle()"); // Enable badges msg.addByte(0x00); // Todo badges loop @@ -4094,7 +4094,7 @@ void ProtocolGame::sendTextMessage(const TextMessage &message) { default: break; } - msg.addString(message.text); + msg.addString(message.text, "ProtocolGame::sendTextMessage - message.text"); writeToOutputBuffer(msg); } @@ -4109,9 +4109,9 @@ void ProtocolGame::sendCreatePrivateChannel(uint16_t channelId, const std::strin NetworkMessage msg; msg.addByte(0xB2); msg.add(channelId); - msg.addString(channelName); + msg.addString(channelName, "ProtocolGame::sendCreatePrivateChannel - channelName"); msg.add(0x01); - msg.addString(player->getName()); + msg.addString(player->getName(), "ProtocolGame::sendCreatePrivateChannel - player->getName()"); msg.add(0x00); writeToOutputBuffer(msg); } @@ -4124,7 +4124,7 @@ void ProtocolGame::sendChannelsDialog() { msg.addByte(list.size()); for (const auto &channel : list) { msg.add(channel->getId()); - msg.addString(channel->getName()); + msg.addString(channel->getName(), "ProtocolGame::sendChannelsDialog - channel->getName()"); } writeToOutputBuffer(msg); @@ -4135,12 +4135,12 @@ void ProtocolGame::sendChannel(uint16_t channelId, const std::string &channelNam msg.addByte(0xAC); msg.add(channelId); - msg.addString(channelName); + msg.addString(channelName, "ProtocolGame::sendChannel - channelName"); if (channelUsers) { msg.add(channelUsers->size()); for (const auto &it : *channelUsers) { - msg.addString(it.second->getName()); + msg.addString(it.second->getName(), "ProtocolGame::sendChannel - it.second->getName()"); } } else { msg.add(0x00); @@ -4149,7 +4149,7 @@ void ProtocolGame::sendChannel(uint16_t channelId, const std::string &channelNam if (invitedUsers) { msg.add(invitedUsers->size()); for (const auto &it : *invitedUsers) { - msg.addString(it.second->getName()); + msg.addString(it.second->getName(), "ProtocolGame::sendChannel - it.second->getName()"); } } else { msg.add(0x00); @@ -4161,11 +4161,11 @@ void ProtocolGame::sendChannelMessage(const std::string &author, const std::stri NetworkMessage msg; msg.addByte(0xAA); msg.add(0x00); - msg.addString(author); + msg.addString(author, "ProtocolGame::sendChannelMessage - author"); msg.add(0x00); msg.addByte(type); msg.add(channel); - msg.addString(text); + msg.addString(text, "ProtocolGame::sendChannelMessage - text"); writeToOutputBuffer(msg); } @@ -4206,10 +4206,10 @@ void ProtocolGame::sendContainer(uint8_t cid, std::shared_ptr contain if (container->getID() == ITEM_BROWSEFIELD) { AddItem(msg, ITEM_BAG, 1, container->getTier()); - msg.addString("Browse Field"); + msg.addString("Browse Field", "ProtocolGame::sendContainer - Browse Field"); } else { AddItem(msg, container); - msg.addString(container->getName()); + msg.addString(container->getName(), "ProtocolGame::sendContainer - container->getName()"); } const auto itemsStoreInboxToSend = container->getStoreInboxFilteredItems(); @@ -4336,7 +4336,7 @@ void ProtocolGame::sendLootStats(std::shared_ptr item, uint8_t count) { NetworkMessage msg; msg.addByte(0xCF); AddItem(msg, lootedItem); - msg.addString(lootedItem->getName()); + msg.addString(lootedItem->getName(), "ProtocolGame::sendLootStats - lootedItem->getName()"); item->setIsLootTrackeable(false); writeToOutputBuffer(msg); @@ -4346,11 +4346,11 @@ void ProtocolGame::sendLootStats(std::shared_ptr item, uint8_t count) { void ProtocolGame::sendShop(std::shared_ptr npc) { NetworkMessage msg; msg.addByte(0x7A); - msg.addString(npc->getName()); + msg.addString(npc->getName(), "ProtocolGame::sendShop - npc->getName()"); if (!oldProtocol) { msg.add(npc->getCurrency()); - msg.addString(std::string()); // Currency name + msg.addString(std::string(), "ProtocolGame::sendShop - std::string()"); // Currency name } std::vector shoplist = npc->getShopItemVector(); @@ -4615,7 +4615,7 @@ void ProtocolGame::sendMarketBrowseItem(uint16_t itemId, const MarketOfferList & } else { msg.add(static_cast(offer.price)); } - msg.addString(offer.playerName); + msg.addString(offer.playerName, "ProtocolGame::sendMarketBrowseItem - offer.playerName"); } msg.add(sellOffers.size()); @@ -4628,7 +4628,7 @@ void ProtocolGame::sendMarketBrowseItem(uint16_t itemId, const MarketOfferList & } else { msg.add(static_cast(offer.price)); } - msg.addString(offer.playerName); + msg.addString(offer.playerName, "ProtocolGame::sendMarketBrowseItem - offer.playerName"); } updateCoinBalance(); @@ -4657,7 +4657,7 @@ void ProtocolGame::sendMarketAcceptOffer(const MarketOfferEx &offer) { } else { msg.add(static_cast(offer.price)); } - msg.addString(offer.playerName); + msg.addString(offer.playerName, "ProtocolGame::sendMarketAcceptOffer - offer.playerName"); msg.add(0x00); } else { msg.add(0x00); @@ -4670,7 +4670,7 @@ void ProtocolGame::sendMarketAcceptOffer(const MarketOfferEx &offer) { } else { msg.add(static_cast(offer.price)); } - msg.addString(offer.playerName); + msg.addString(offer.playerName "ProtocolGame::sendMarketAcceptOffer - offer.playerName"); } writeToOutputBuffer(msg); @@ -5091,7 +5091,7 @@ void ProtocolGame::sendForgeHistory(uint8_t page) { auto action = magic_enum::enum_integer(history.actionType); msg.add(static_cast(history.createdAt)); msg.addByte(action); - msg.addString(history.description); + msg.addString(history.description, "ProtocolGame::sendForgeHistory - history.description"); msg.addByte((history.bonus >= 1 && history.bonus < 8) ? 0x01 : 0x00); } } @@ -5121,7 +5121,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { } if (it.armor != 0) { - msg.addString(std::to_string(it.armor)); + msg.addString(std::to_string(it.armor), "ProtocolGame::sendMarketDetail - std::to_string(it.armor)"); } else { msg.add(0x00); } @@ -5149,21 +5149,21 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { } ss << static_cast(it.shootRange) << " fields"; } - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()"); } else if (!it.isRanged() && it.attack != 0) { if (it.abilities && it.abilities->elementType != COMBAT_NONE && it.abilities->elementDamage != 0) { std::ostringstream ss; ss << it.attack << " physical +" << it.abilities->elementDamage << ' ' << getCombatName(it.abilities->elementType); - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()"); } else { - msg.addString(std::to_string(it.attack)); + msg.addString(std::to_string(it.attack), "ProtocolGame::sendMarketDetail - std::to_string(it.attack)"); } } else { msg.add(0x00); } if (it.isContainer()) { - msg.addString(std::to_string(it.maxItems)); + msg.addString(std::to_string(it.maxItems), "ProtocolGame::sendMarketDetail - std::to_string(it.maxItems)"); } else { msg.add(0x00); } @@ -5172,9 +5172,9 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { if (it.extraDefense != 0) { std::ostringstream ss; ss << it.defense << ' ' << std::showpos << it.extraDefense << std::noshowpos; - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()"); } else { - msg.addString(std::to_string(it.defense)); + msg.addString(std::to_string(it.defense), "ProtocolGame::sendMarketDetail - std::to_string(it.defense)"); } } else { msg.add(0x00); @@ -5183,9 +5183,9 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { if (!it.description.empty()) { const std::string &descr = it.description; if (descr.back() == '.') { - msg.addString(std::string(descr, 0, descr.length() - 1)); + msg.addString(std::string(descr, 0, descr.length() - 1), "ProtocolGame::sendMarketDetail - std::string(descr, 0, descr.length() - 1)"); } else { - msg.addString(descr); + msg.addString(descr, "ProtocolGame::sendMarketDetail - descr"); } } else { msg.add(0x00); @@ -5194,7 +5194,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { if (it.decayTime != 0) { std::ostringstream ss; ss << it.decayTime << " seconds"; - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()"); } else { msg.add(0x00); } @@ -5217,25 +5217,25 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { ss << fmt::format("{} {:+}%", getCombatName(indexToCombatType(i)), it.abilities->absorbPercent[i]); } - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()"); } else { msg.add(0x00); } if (it.minReqLevel != 0) { - msg.addString(std::to_string(it.minReqLevel)); + msg.addString(std::to_string(it.minReqLevel), "ProtocolGame::sendMarketDetail - std::to_string(it.minReqLevel)"); } else { msg.add(0x00); } if (it.minReqMagicLevel != 0) { - msg.addString(std::to_string(it.minReqMagicLevel)); + msg.addString(std::to_string(it.minReqMagicLevel), "ProtocolGame::sendMarketDetail - std::to_string(it.minReqMagicLevel)"); } else { msg.add(0x00); } - msg.addString(it.vocationString); - msg.addString(it.runeSpellName); + msg.addString(it.vocationString, "ProtocolGame::sendMarketDetail - it.vocationString"); + msg.addString(it.runeSpellName, "ProtocolGame::sendMarketDetail - it.runeSpellName"); if (it.abilities) { std::ostringstream ss; @@ -5312,13 +5312,13 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { ss << fmt::format("speed {:+}", (it.abilities->speed >> 1)); } - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()"); } else { msg.add(0x00); } if (it.charges != 0) { - msg.addString(std::to_string(it.charges)); + msg.addString(std::to_string(it.charges), "ProtocolGame::sendMarketDetail - std::to_string(it.charges)"); } else { msg.add(0x00); } @@ -5333,7 +5333,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { } } - msg.addString(weaponName); + msg.addString(weaponName, "ProtocolGame::sendMarketDetail - weaponName"); if (it.weight != 0) { std::ostringstream ss; @@ -5347,7 +5347,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { ss << weightString; } ss << " oz"; - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()"); } else { msg.add(0x00); } @@ -5357,7 +5357,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { } if (it.imbuementSlot > 0) { - msg.addString(std::to_string(it.imbuementSlot)); + msg.addString(std::to_string(it.imbuementSlot), "ProtocolGame::sendMarketDetail - std::to_string(it.imbuementSlot)"); } else { msg.add(0x00); } @@ -5369,7 +5369,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { if (it.abilities->magicShieldCapacityFlat > 0) { string.clear(); string << std::showpos << it.abilities->magicShieldCapacityFlat << std::noshowpos << " and " << it.abilities->magicShieldCapacityPercent << "%"; - msg.addString(string.str()); + msg.addString(string.str(), "ProtocolGame::sendMarketDetail - string.str()"); } else { msg.add(0x00); } @@ -5377,7 +5377,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { if (it.abilities->cleavePercent > 0) { string.clear(); string << it.abilities->cleavePercent << "%"; - msg.addString(string.str()); + msg.addString(string.str(), "ProtocolGame::sendMarketDetail - string.str()"); } else { msg.add(0x00); } @@ -5385,7 +5385,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { if (it.abilities->reflectFlat[COMBAT_PHYSICALDAMAGE] > 0) { string.clear(); string << it.abilities->reflectFlat[COMBAT_PHYSICALDAMAGE]; - msg.addString(string.str()); + msg.addString(string.str(), "ProtocolGame::sendMarketDetail - string.str()"); } else { msg.add(0x00); } @@ -5393,7 +5393,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { if (it.abilities->perfectShotDamage > 0) { string.clear(); string << std::showpos << it.abilities->perfectShotDamage << std::noshowpos << " at " << it.abilities->perfectShotRange << "%"; - msg.addString(string.str()); + msg.addString(string.str(), "ProtocolGame::sendMarketDetail - string.str()"); } else { msg.add(0x00); } @@ -5411,7 +5411,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { // Upgrade and tier detail modifier if (it.upgradeClassification > 0 && tier > 0) { - msg.addString(std::to_string(it.upgradeClassification)); + msg.addString(std::to_string(it.upgradeClassification), "ProtocolGame::sendMarketDetail - std::to_string(it.upgradeClassification)"); std::ostringstream ss; double chance; @@ -5425,10 +5425,10 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { chance = (0.0307576 * tier * tier) + (0.440697 * tier) + 0.026; ss << fmt::format("{} ({:.2f}% Ruse)", static_cast(tier), chance); } - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()"); } else if (it.upgradeClassification > 0 && tier == 0) { - msg.addString(std::to_string(it.upgradeClassification)); - msg.addString(std::to_string(tier)); + msg.addString(std::to_string(it.upgradeClassification), "ProtocolGame::sendMarketDetail - std::to_string(it.upgradeClassification)"); + msg.addString(std::to_string(tier), "ProtocolGame::sendMarketDetail - std::to_string(tier)"); } else { msg.add(0x00); msg.add(0x00); @@ -5481,7 +5481,7 @@ void ProtocolGame::sendTradeItemRequest(const std::string &traderName, std::shar msg.addByte(0x7E); } - msg.addString(traderName); + msg.addString(traderName, "ProtocolGame::sendTradeItemRequest - traderName"); if (std::shared_ptr tradeContainer = item->getContainer()) { std::list> listContainer { tradeContainer }; @@ -5546,7 +5546,7 @@ void ProtocolGame::sendCreatureSay(std::shared_ptr creature, SpeakClas static uint32_t statementId = 0; msg.add(++statementId); - msg.addString(creature->getName()); + msg.addString(creature->getName(), "ProtocolGame::sendCreatureSay - creature->getName()"); if (!oldProtocol) { msg.addByte(0x00); // Show (Traded) @@ -5571,7 +5571,7 @@ void ProtocolGame::sendCreatureSay(std::shared_ptr creature, SpeakClas msg.addPosition(creature->getPosition()); } - msg.addString(text); + msg.addString(text, "ProtocolGame::sendCreatureSay - text"); writeToOutputBuffer(msg); } @@ -5593,7 +5593,7 @@ void ProtocolGame::sendToChannel(std::shared_ptr creature, SpeakClasse } type = TALKTYPE_CHANNEL_R1; } else { - msg.addString(creature->getName()); + msg.addString(creature->getName(), "ProtocolGame::sendToChannel - creature->getName()"); if (!oldProtocol && statementId != 0) { msg.addByte(0x00); // Show (Traded) } @@ -5613,7 +5613,7 @@ void ProtocolGame::sendToChannel(std::shared_ptr creature, SpeakClasse } msg.add(channelId); - msg.addString(text); + msg.addString(text, "ProtocolGame::sendToChannel - text"); writeToOutputBuffer(msg); } @@ -5623,7 +5623,7 @@ void ProtocolGame::sendPrivateMessage(std::shared_ptr speaker, SpeakClas static uint32_t statementId = 0; msg.add(++statementId); if (speaker) { - msg.addString(speaker->getName()); + msg.addString(speaker->getName(), "ProtocolGame::sendPrivateMessage - speaker->getName()"); if (!oldProtocol && statementId != 0) { msg.addByte(0x00); // Show (Traded) } @@ -5641,7 +5641,7 @@ void ProtocolGame::sendPrivateMessage(std::shared_ptr speaker, SpeakClas msg.addByte(type); } - msg.addString(text); + msg.addString(text, "ProtocolGame::sendPrivateMessage - text"); writeToOutputBuffer(msg); } @@ -5723,7 +5723,7 @@ void ProtocolGame::sendRestingStatus(uint8_t protection) { int32_t PlayerdailyStreak = player->getStorageValue(STORAGEVALUE_DAILYREWARD); msg.addByte(PlayerdailyStreak < 2 ? 0 : 1); if (PlayerdailyStreak < 2) { - msg.addString("Resting Area (no active bonus)"); + msg.addString("Resting Area (no active bonus)", "ProtocolGame::sendRestingStatus - Resting Area (no active bonus)"); } else { std::ostringstream ss; ss << "Active Resting Area Bonuses: "; @@ -5746,7 +5746,7 @@ void ProtocolGame::sendRestingStatus(uint8_t protection) { ss << ",\nSoul Points Regeneration"; } ss << "."; - msg.addString(ss.str()); + msg.addString(ss.str(), "ProtocolGame::sendRestingStatus - ss.str()"); } writeToOutputBuffer(msg); } @@ -5938,7 +5938,7 @@ void ProtocolGame::sendPlayerVocation(std::shared_ptr target) { void ProtocolGame::sendFYIBox(const std::string &message) { NetworkMessage msg; msg.addByte(0x15); - msg.addString(message); + msg.addString(message, "ProtocolGame::sendFYIBox - message"); writeToOutputBuffer(msg); } @@ -6101,7 +6101,7 @@ void ProtocolGame::sendAddCreature(std::shared_ptr creature, const Pos msg.addByte(0x00); // can change pvp framing option msg.addByte(0x00); // expert mode button enabled - msg.addString(g_configManager().getString(STORE_IMAGES_URL)); + msg.addString(g_configManager().getString(STORE_IMAGES_URL), "ProtocolGame::sendAddCreature - g_configManager().getString(STORE_IMAGES_URL)"); msg.add(static_cast(g_configManager().getNumber(STORE_COIN_PACKET))); if (!oldProtocol) { @@ -6344,16 +6344,16 @@ void ProtocolGame::sendTextWindow(uint32_t windowTextId, std::shared_ptr i if (canWrite) { msg.add(maxlen); - msg.addString(item->getAttribute(ItemAttribute_t::TEXT)); + msg.addString(item->getAttribute(ItemAttribute_t::TEXT), "ProtocolGame::sendTextWindow - item->getAttribute(ItemAttribute_t::TEXT)"); } else { const std::string &text = item->getAttribute(ItemAttribute_t::TEXT); msg.add(text.size()); - msg.addString(text); + msg.addString(text, "ProtocolGame::sendTextWindow - text"); } const std::string &writer = item->getAttribute(ItemAttribute_t::WRITER); if (!writer.empty()) { - msg.addString(writer); + msg.addString(writer, "ProtocolGame::sendTextWindow - writer"); } else { msg.add(0x00); } @@ -6364,7 +6364,7 @@ void ProtocolGame::sendTextWindow(uint32_t windowTextId, std::shared_ptr i auto writtenDate = item->getAttribute(ItemAttribute_t::DATE); if (writtenDate != 0) { - msg.addString(formatDateShort(writtenDate)); + msg.addString(formatDateShort(writtenDate), "ProtocolGame::sendTextWindow - formatDateShort(writtenDate)"); } else { msg.add(0x00); } @@ -6378,7 +6378,7 @@ void ProtocolGame::sendTextWindow(uint32_t windowTextId, uint32_t itemId, const msg.add(windowTextId); AddItem(msg, itemId, 1, 0); msg.add(text.size()); - msg.addString(text); + msg.addString(text, "ProtocolGame::sendTextWindow - text"); msg.add(0x00); if (!oldProtocol) { @@ -6394,7 +6394,7 @@ void ProtocolGame::sendHouseWindow(uint32_t windowTextId, const std::string &tex msg.addByte(0x97); msg.addByte(0x00); msg.add(windowTextId); - msg.addString(text); + msg.addString(text, "ProtocolGame::sendHouseWindow - text"); writeToOutputBuffer(msg); } @@ -6441,7 +6441,7 @@ void ProtocolGame::sendOutfitWindow() { msg.addByte(protocolOutfits.size()); for (const ProtocolOutfit &outfit : protocolOutfits) { msg.add(outfit.lookType); - msg.addString(outfit.name); + msg.addString(outfit.name, "ProtocolGame::sendOutfitWindow - outfit.name"); msg.addByte(outfit.addons); } @@ -6455,7 +6455,7 @@ void ProtocolGame::sendOutfitWindow() { msg.addByte(mounts.size()); for (const auto mount : mounts) { msg.add(mount->clientId); - msg.addString(mount->name); + msg.addString(mount->name, "ProtocolGame::sendOutfitWindow - mount->name"); } writeToOutputBuffer(msg); @@ -6486,19 +6486,19 @@ void ProtocolGame::sendOutfitWindow() { if (player->isAccessPlayer()) { msg.add(75); - msg.addString("Gamemaster"); + msg.addString("Gamemaster", "ProtocolGame::sendOutfitWindow - Gamemaster"); msg.addByte(0); msg.addByte(0x00); ++outfitSize; msg.add(266); - msg.addString("Customer Support"); + msg.addString("Customer Support", "ProtocolGame::sendOutfitWindow - Customer Support"); msg.addByte(0); msg.addByte(0x00); ++outfitSize; msg.add(302); - msg.addString("Community Manager"); + msg.addString("Community Manager", "ProtocolGame::sendOutfitWindow - Community Manager"); msg.addByte(0); msg.addByte(0x00); ++outfitSize; @@ -6510,25 +6510,25 @@ void ProtocolGame::sendOutfitWindow() { uint8_t addons; if (player->getOutfitAddons(outfit, addons)) { msg.add(outfit->lookType); - msg.addString(outfit->name); + msg.addString(outfit->name, "ProtocolGame::sendOutfitWindow - outfit->name"); msg.addByte(addons); msg.addByte(0x00); ++outfitSize; } else if (outfit->lookType == 1210 || outfit->lookType == 1211) { msg.add(outfit->lookType); - msg.addString(outfit->name); + msg.addString(outfit->name, "ProtocolGame::sendOutfitWindow - outfit->name"); msg.addByte(3); msg.addByte(0x02); ++outfitSize; } else if (outfit->lookType == 1456 || outfit->lookType == 1457) { msg.add(outfit->lookType); - msg.addString(outfit->name); + msg.addString(outfit->name, "ProtocolGame::sendOutfitWindow - outfit->name"); msg.addByte(3); msg.addByte(0x03); ++outfitSize; } else if (outfit->from == "store") { msg.add(outfit->lookType); - msg.addString(outfit->name); + msg.addString(outfit->name, "ProtocolGame::sendOutfitWindow - outfit->name"); msg.addByte(outfit->lookType >= 962 && outfit->lookType <= 975 ? 0 : 3); msg.addByte(0x01); msg.add(0x00); @@ -6554,12 +6554,12 @@ void ProtocolGame::sendOutfitWindow() { for (const auto mount : mounts) { if (player->hasMount(mount)) { msg.add(mount->clientId); - msg.addString(mount->name); + msg.addString(mount->name, "ProtocolGame::sendOutfitWindow - mount->name"); msg.addByte(0x00); ++mountSize; } else if (mount->type == "store") { msg.add(mount->clientId); - msg.addString(mount->name); + msg.addString(mount->name, "ProtocolGame::sendOutfitWindow - mount->name"); msg.addByte(0x01); msg.add(0x00); ++mountSize; @@ -6588,7 +6588,7 @@ void ProtocolGame::sendOutfitWindow() { } msg.add(familiar.lookType); - msg.addString(familiar.name); + msg.addString(familiar.name, "ProtocolGame::sendOutfitWindow - familiar.name"); msg.addByte(0x00); if (++familiarSize == limitFamiliars) { break; @@ -6652,7 +6652,7 @@ void ProtocolGame::sendPodiumWindow(std::shared_ptr podium, const Position } msg.add(outfit->lookType); - msg.addString(outfit->name); + msg.addString(outfit->name, "ProtocolGame::sendPodiumWindow - outfit->name"); msg.addByte(addons); msg.addByte(0x00); if (++outfitSize == limitOutfits) { @@ -6674,7 +6674,7 @@ void ProtocolGame::sendPodiumWindow(std::shared_ptr podium, const Position for (const auto mount : mounts) { if (player->hasMount(mount)) { msg.add(mount->clientId); - msg.addString(mount->name); + msg.addString(mount->name, "ProtocolGame::sendPodiumWindow - mount->name"); msg.addByte(0x00); if (++mountSize == limitMounts) { break; @@ -6724,8 +6724,8 @@ void ProtocolGame::sendVIP(uint32_t guid, const std::string &name, const std::st NetworkMessage msg; msg.addByte(0xD2); msg.add(guid); - msg.addString(name); - msg.addString(description); + msg.addString(name, "ProtocolGame::sendVIP - name"); + msg.addString(description, "ProtocolGame::sendVIP - description"); msg.add(std::min(10, icon)); msg.addByte(notify ? 0x01 : 0x00); msg.addByte(status); @@ -6822,7 +6822,7 @@ void ProtocolGame::sendPreyData(const std::unique_ptr &slot) { // Empty } else if (slot->state == PreyDataState_Active) { if (const auto mtype = g_monsters().getMonsterTypeByRaceId(slot->selectedRaceId)) { - msg.addString(mtype->name); + msg.addString(mtype->name, "ProtocolGame::sendPreyData - mtype->name"); const Outfit_t outfit = mtype->info.outfit; msg.add(outfit.lookType); if (outfit.lookType == 0) { @@ -6848,7 +6848,7 @@ void ProtocolGame::sendPreyData(const std::unique_ptr &slot) { continue; } - msg.addString(mtype->name); + msg.addString(mtype->name, "ProtocolGame::sendPreyData - mtype->name"); const Outfit_t outfit = mtype->info.outfit; msg.add(outfit.lookType); if (outfit.lookType == 0) { @@ -6873,7 +6873,7 @@ void ProtocolGame::sendPreyData(const std::unique_ptr &slot) { continue; } - msg.addString(mtype->name); + msg.addString(mtype->name, "ProtocolGame::sendPreyData - mtype->name"); const Outfit_t outfit = mtype->info.outfit; msg.add(outfit.lookType); if (outfit.lookType == 0) { @@ -6938,18 +6938,18 @@ void ProtocolGame::sendModalWindow(const ModalWindow &modalWindow) { msg.addByte(0xFA); msg.add(modalWindow.id); - msg.addString(modalWindow.title); - msg.addString(modalWindow.message); + msg.addString(modalWindow.title, "ProtocolGame::sendModalWindow - modalWindow.title"); + msg.addString(modalWindow.message, "ProtocolGame::sendModalWindow - modalWindow.message"); msg.addByte(modalWindow.buttons.size()); for (const auto &it : modalWindow.buttons) { - msg.addString(it.first); + msg.addString(it.first, "ProtocolGame::sendModalWindow - it.first"); msg.addByte(it.second); } msg.addByte(modalWindow.choices.size()); for (const auto &it : modalWindow.choices) { - msg.addString(it.first); + msg.addString(it.first, "ProtocolGame::sendModalWindow - it.first"); msg.addByte(it.second); } @@ -6987,9 +6987,9 @@ void ProtocolGame::AddCreature(NetworkMessage &msg, std::shared_ptr cr } if (!oldProtocol && creature->isHealthHidden()) { - msg.addString(""); + msg.addString("", "ProtocolGame::AddCreature - empty"); } else { - msg.addString(creature->getName()); + msg.addString(creature->getName(), "ProtocolGame::AddCreature - creature->getName()"); } } @@ -7208,9 +7208,9 @@ void ProtocolGame::addImbuementInfo(NetworkMessage &msg, uint16_t imbuementId) c const CategoryImbuement* categoryImbuement = g_imbuements().getCategoryByID(imbuement->getCategory()); msg.add(imbuementId); - msg.addString(baseImbuement->name + " " + imbuement->getName()); - msg.addString(imbuement->getDescription()); - msg.addString(categoryImbuement->name + imbuement->getSubGroup()); + msg.addString(baseImbuement->name + " " + imbuement->getName(), "ProtocolGame::addImbuementInfo - baseImbuement->name + " " + imbuement->getName()"); + msg.addString(imbuement->getDescription(), "ProtocolGame::addImbuementInfo - imbuement->getDescription()"); + msg.addString(categoryImbuement->name + imbuement->getSubGroup(), "ProtocolGame::addImbuementInfo - categoryImbuement->name + imbuement->getSubGroup()"); msg.add(imbuement->getIconID()); msg.add(baseImbuement->duration); @@ -7223,7 +7223,7 @@ void ProtocolGame::addImbuementInfo(NetworkMessage &msg, uint16_t imbuementId) c for (const auto &itm : items) { const ItemType &it = Item::items[itm.first]; msg.add(itm.first); - msg.addString(it.name); + msg.addString(it.name, "ProtocolGame::addImbuementInfo - it.name"); msg.add(itm.second); } @@ -7295,7 +7295,7 @@ void ProtocolGame::sendMessageDialog(const std::string &message) { NetworkMessage msg; msg.addByte(0xED); msg.addByte(0x14); // Unknown type - msg.addString(message); + msg.addString(message, "ProtocolGame::sendMessageDialog - message"); writeToOutputBuffer(msg); } @@ -7303,7 +7303,7 @@ void ProtocolGame::sendImbuementResult(const std::string message) { NetworkMessage msg; msg.addByte(0xED); msg.addByte(0x01); - msg.addString(message); + msg.addString(message, "ProtocolGame::sendImbuementResult - message"); writeToOutputBuffer(msg); } @@ -7364,7 +7364,7 @@ void ProtocolGame::updatePartyTrackerAnalyzer(const std::shared_ptr party msg.addByte(static_cast(party->membersData.size())); for (const std::shared_ptr analyzer : party->membersData) { msg.add(analyzer->id); - msg.addString(analyzer->name); + msg.addString(analyzer->name, "ProtocolGame::updatePartyTrackerAnalyzer - analyzer->name"); } } @@ -7400,7 +7400,7 @@ void ProtocolGame::sendKillTrackerUpdate(std::shared_ptr corpse, cons NetworkMessage msg; msg.addByte(0xD1); - msg.addString(name); + msg.addString(name, "ProtocolGame::sendKillTrackerUpdate - name"); msg.add(creatureOutfit.lookType ? creatureOutfit.lookType : 21); msg.addByte(creatureOutfit.lookType ? creatureOutfit.lookHead : 0x00); msg.addByte(creatureOutfit.lookType ? creatureOutfit.lookBody : 0x00); @@ -7468,7 +7468,7 @@ void ProtocolGame::sendUpdateInputAnalyzer(CombatType_t type, int32_t amount, st msg.addByte(ANALYZER_DAMAGE_RECEIVED); msg.add(amount); msg.addByte(clientElement); - msg.addString(target); + msg.addString(target, "ProtocolGame::sendUpdateInputAnalyzer - target"); writeToOutputBuffer(msg); } @@ -7632,7 +7632,7 @@ void ProtocolGame::AddHiddenShopItem(NetworkMessage &msg) { // Empty bytes from AddShopItem msg.add(0); msg.addByte(0); - msg.addString(std::string()); + msg.addString(std::string(), "ProtocolGame::AddHiddenShopItem - std::string()"; msg.add(0); msg.add(0); msg.add(0); @@ -7655,9 +7655,9 @@ void ProtocolGame::AddShopItem(NetworkMessage &msg, const ShopBlock &shopBlock) // If not send "itemName" variable from the npc shop, will registered the name that is in items.xml if (shopBlock.itemName.empty()) { - msg.addString(it.name); + msg.addString(it.name, "ProtocolGame::AddShopItem - it.name"); } else { - msg.addString(shopBlock.itemName); + msg.addString(shopBlock.itemName, "ProtocolGame::AddShopItem - shopBlock.itemName"); } msg.add(it.weight); msg.add(shopBlock.itemBuyPrice == 4294967295 ? 0 : shopBlock.itemBuyPrice); @@ -7739,7 +7739,7 @@ void ProtocolGame::sendInventoryImbuements(const std::mapgetBaseID()); msg.addByte(0x01); - msg.addString(baseImbuement->name + " " + imbuement->getName()); + msg.addString(baseImbuement->name + " " + imbuement->getName(), "ProtocolGame::sendInventoryImbuements - baseImbuement->name + " " + imbuement->getName()"); msg.add(imbuement->getIconID()); msg.add(imbuementInfo.duration); @@ -8332,9 +8332,9 @@ void ProtocolGame::sendPodiumDetails(NetworkMessage &msg, const std::vectorname); + msg.addString(mType->name, "ProtocolGame::sendPodiumDetails - mType->name"); } msg.add(monsterOutfit.lookType); if (isLookType) { diff --git a/src/server/network/protocol/protocollogin.cpp b/src/server/network/protocol/protocollogin.cpp index 1f0a3b57ad9..69b2741a8e4 100644 --- a/src/server/network/protocol/protocollogin.cpp +++ b/src/server/network/protocol/protocollogin.cpp @@ -22,7 +22,7 @@ void ProtocolLogin::disconnectClient(const std::string &message) { auto output = OutputMessagePool::getOutputMessage(); output->addByte(0x0B); - output->addString(message); + output->addString(message, "ProtocolLogin::disconnectClient - message"); send(output); disconnect(); @@ -56,12 +56,12 @@ void ProtocolLogin::getCharacterList(const std::string &accountDescriptor, const std::ostringstream ss; ss << g_game().getMotdNum() << "\n" << motd; - output->addString(ss.str()); + output->addString(ss.str(), "ProtocolLogin::getCharacterList - ss.str()"); } // Add session key output->addByte(0x28); - output->addString(accountDescriptor + "\n" + password); + output->addString(accountDescriptor + "\n" + password, "ProtocolLogin::getCharacterList - accountDescriptor + password"); // Add char list auto [players, result] = account.getAccountPlayers(); @@ -74,8 +74,8 @@ void ProtocolLogin::getCharacterList(const std::string &accountDescriptor, const output->addByte(1); // number of worlds output->addByte(0); // world id - output->addString(g_configManager().getString(SERVER_NAME)); - output->addString(g_configManager().getString(IP)); + output->addString(g_configManager().getString(SERVER_NAME), "ProtocolLogin::getCharacterList - _configManager().getString(SERVER_NAME)"); + output->addString(g_configManager().getString(IP), "ProtocolLogin::getCharacterList - g_configManager().getString(IP)"); output->add(g_configManager().getShortNumber(GAME_PORT)); @@ -85,7 +85,7 @@ void ProtocolLogin::getCharacterList(const std::string &accountDescriptor, const output->addByte(size); for (const auto &[name, deletion] : players) { output->addByte(0); - output->addString(name); + output->addString(name, "ProtocolLogin::getCharacterList - name"); } // Add premium days diff --git a/src/server/network/protocol/protocolstatus.cpp b/src/server/network/protocol/protocolstatus.cpp index f07e5e85d18..894aa49ab25 100644 --- a/src/server/network/protocol/protocolstatus.cpp +++ b/src/server/network/protocol/protocolstatus.cpp @@ -154,22 +154,22 @@ void ProtocolStatus::sendInfo(uint16_t requestedInfo, const std::string &charact if (requestedInfo & REQUEST_BASIC_SERVER_INFO) { output->addByte(0x10); - output->addString(g_configManager().getString(stringConfig_t::SERVER_NAME)); - output->addString(g_configManager().getString(IP)); - output->addString(std::to_string(g_configManager().getNumber(LOGIN_PORT))); + output->addString(g_configManager().getString(stringConfig_t::SERVER_NAME), "ProtocolStatus::sendInfo - g_configManager().getString(stringConfig_t::SERVER_NAME)"); + output->addString(g_configManager().getString(IP), "ProtocolStatus::sendInfo - g_configManager().getString(IP)"); + output->addString(std::to_string(g_configManager().getNumber(LOGIN_PORT)), "ProtocolStatus::sendInfo - std::to_string(g_configManager().getNumber(LOGIN_PORT))"); } if (requestedInfo & REQUEST_OWNER_SERVER_INFO) { output->addByte(0x11); - output->addString(g_configManager().getString(OWNER_NAME)); - output->addString(g_configManager().getString(OWNER_EMAIL)); + output->addString(g_configManager().getString(OWNER_NAME), "ProtocolStatus::sendInfo - g_configManager().getString(OWNER_NAME)"); + output->addString(g_configManager().getString(OWNER_EMAIL), "ProtocolStatus::sendInfo - g_configManager().getString(OWNER_EMAIL)"); } if (requestedInfo & REQUEST_MISC_SERVER_INFO) { output->addByte(0x12); - output->addString(g_configManager().getString(SERVER_MOTD)); - output->addString(g_configManager().getString(LOCATION)); - output->addString(g_configManager().getString(URL)); + output->addString(g_configManager().getString(SERVER_MOTD), "ProtocolStatus::sendInfo - g_configManager().getString(SERVER_MOTD)"); + output->addString(g_configManager().getString(LOCATION), "ProtocolStatus::sendInfo - g_configManager().getString(LOCATION)"); + output->addString(g_configManager().getString(URL), "ProtocolStatus::sendInfo - g_configManager().getString(URL)"); output->add((OTSYS_TIME() - ProtocolStatus::start) / 1000); } @@ -182,8 +182,8 @@ void ProtocolStatus::sendInfo(uint16_t requestedInfo, const std::string &charact if (requestedInfo & REQUEST_MAP_INFO) { output->addByte(0x30); - output->addString(g_configManager().getString(MAP_NAME)); - output->addString(g_configManager().getString(MAP_AUTHOR)); + output->addString(g_configManager().getString(MAP_NAME), "ProtocolStatus::sendInfo - g_configManager().getString(MAP_NAME)"); + output->addString(g_configManager().getString(MAP_AUTHOR), "ProtocolStatus::sendInfo - g_configManager().getString(MAP_AUTHOR)"); uint32_t mapWidth, mapHeight; g_game().getMapDimensions(mapWidth, mapHeight); output->add(mapWidth); @@ -196,7 +196,7 @@ void ProtocolStatus::sendInfo(uint16_t requestedInfo, const std::string &charact const auto players = g_game().getPlayers(); output->add(players.size()); for (const auto &it : players) { - output->addString(it.second->getName()); + output->addString(it.second->getName(), "ProtocolStatus::sendInfo - it.second->getName()"); output->add(it.second->getLevel()); } } @@ -212,9 +212,9 @@ void ProtocolStatus::sendInfo(uint16_t requestedInfo, const std::string &charact if (requestedInfo & REQUEST_SERVER_SOFTWARE_INFO) { output->addByte(0x23); // server software info - output->addString(ProtocolStatus::SERVER_NAME); - output->addString(ProtocolStatus::SERVER_VERSION); - output->addString(fmt::format("{}.{}", CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER)); + output->addString(ProtocolStatus::SERVER_NAME, "ProtocolStatus::sendInfo - ProtocolStatus::SERVER_NAME"); + output->addString(ProtocolStatus::SERVER_VERSION, "ProtocolStatus::sendInfo - ProtocolStatus::SERVER_VERSION)"; + output->addString(fmt::format("{}.{}", CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER), "ProtocolStatus::sendInfo - fmt::format(CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER)"); } send(output); disconnect(); From 61512031c2fec5a23c36d90b31b0b9c6b513392f Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 15 Nov 2023 04:47:22 +0000 Subject: [PATCH 2/3] Code format - (Clang-format) --- src/server/network/protocol/protocolgame.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index a49a434039c..b018ca3dbde 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -7208,7 +7208,8 @@ void ProtocolGame::addImbuementInfo(NetworkMessage &msg, uint16_t imbuementId) c const CategoryImbuement* categoryImbuement = g_imbuements().getCategoryByID(imbuement->getCategory()); msg.add(imbuementId); - msg.addString(baseImbuement->name + " " + imbuement->getName(), "ProtocolGame::addImbuementInfo - baseImbuement->name + " " + imbuement->getName()"); + msg.addString(baseImbuement->name + " " + imbuement->getName(), "ProtocolGame::addImbuementInfo - baseImbuement->name + " + " + imbuement->getName()"); msg.addString(imbuement->getDescription(), "ProtocolGame::addImbuementInfo - imbuement->getDescription()"); msg.addString(categoryImbuement->name + imbuement->getSubGroup(), "ProtocolGame::addImbuementInfo - categoryImbuement->name + imbuement->getSubGroup()"); @@ -7739,7 +7740,8 @@ void ProtocolGame::sendInventoryImbuements(const std::mapgetBaseID()); msg.addByte(0x01); - msg.addString(baseImbuement->name + " " + imbuement->getName(), "ProtocolGame::sendInventoryImbuements - baseImbuement->name + " " + imbuement->getName()"); + msg.addString(baseImbuement->name + " " + imbuement->getName(), "ProtocolGame::sendInventoryImbuements - baseImbuement->name + " + " + imbuement->getName()"); msg.add(imbuement->getIconID()); msg.add(imbuementInfo.duration); From 1688563c27e6a6e15797eb96c0cca826026ede70 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Wed, 15 Nov 2023 02:26:10 -0300 Subject: [PATCH 3/3] update --- src/server/network/protocol/protocolgame.cpp | 4 ++-- src/server/network/protocol/protocolstatus.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index a49a434039c..56d3a24defa 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -4670,7 +4670,7 @@ void ProtocolGame::sendMarketAcceptOffer(const MarketOfferEx &offer) { } else { msg.add(static_cast(offer.price)); } - msg.addString(offer.playerName "ProtocolGame::sendMarketAcceptOffer - offer.playerName"); + msg.addString(offer.playerName, "ProtocolGame::sendMarketAcceptOffer - offer.playerName"); } writeToOutputBuffer(msg); @@ -7632,7 +7632,7 @@ void ProtocolGame::AddHiddenShopItem(NetworkMessage &msg) { // Empty bytes from AddShopItem msg.add(0); msg.addByte(0); - msg.addString(std::string(), "ProtocolGame::AddHiddenShopItem - std::string()"; + msg.addString(std::string(), "ProtocolGame::AddHiddenShopItem - std::string()"); msg.add(0); msg.add(0); msg.add(0); diff --git a/src/server/network/protocol/protocolstatus.cpp b/src/server/network/protocol/protocolstatus.cpp index 894aa49ab25..5adaa7317c8 100644 --- a/src/server/network/protocol/protocolstatus.cpp +++ b/src/server/network/protocol/protocolstatus.cpp @@ -213,7 +213,7 @@ void ProtocolStatus::sendInfo(uint16_t requestedInfo, const std::string &charact if (requestedInfo & REQUEST_SERVER_SOFTWARE_INFO) { output->addByte(0x23); // server software info output->addString(ProtocolStatus::SERVER_NAME, "ProtocolStatus::sendInfo - ProtocolStatus::SERVER_NAME"); - output->addString(ProtocolStatus::SERVER_VERSION, "ProtocolStatus::sendInfo - ProtocolStatus::SERVER_VERSION)"; + output->addString(ProtocolStatus::SERVER_VERSION, "ProtocolStatus::sendInfo - ProtocolStatus::SERVER_VERSION)"); output->addString(fmt::format("{}.{}", CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER), "ProtocolStatus::sendInfo - fmt::format(CLIENT_VERSION_UPPER, CLIENT_VERSION_LOWER)"); } send(output);