From 5942182486c37f71fc2002543a3c6a813d4d3f81 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:31:55 -0700 Subject: [PATCH] feat: Abstract Logger and simplify code (#1207) * Logger: Rename logger to Logger from dLogger * Logger: Add compile time filename Fix include issues Add writers Add macros Add macro to force compilation * Logger: Replace calls with macros Allows for filename and line number to be logged * Logger: Add comments and remove extra define Logger: Replace with unique_ptr also flush console at exit. regular file writer should be flushed on file close. Logger: Remove constexpr on variable * Logger: Simplify code * Update Logger.cpp --- dAuthServer/AuthServer.cpp | 18 +-- dChatFilter/dChatFilter.cpp | 2 +- dChatServer/ChatPacketHandler.cpp | 20 +-- dChatServer/ChatServer.cpp | 34 ++--- dChatServer/PlayerContainer.cpp | 10 +- dCommon/Amf3.h | 2 +- dCommon/AmfSerialize.cpp | 4 +- dCommon/BrickByBrickFix.cpp | 18 +-- dCommon/CMakeLists.txt | 2 +- dCommon/Diagnostics.cpp | 12 +- dCommon/FdbToSqlite.cpp | 4 +- dCommon/Game.h | 4 +- dCommon/GeneralUtils.h | 2 +- dCommon/LDFFormat.cpp | 22 +-- dCommon/Logger.cpp | 96 ++++++++++++ dCommon/Logger.h | 89 ++++++++++++ dCommon/dClient/AssetManager.cpp | 2 +- dCommon/dClient/Pack.h | 1 + dCommon/dClient/PackIndex.cpp | 4 +- dCommon/dLogger.cpp | 110 -------------- dCommon/dLogger.h | 38 ----- dDatabase/Database.cpp | 10 +- dDatabase/MigrationRunner.cpp | 20 +-- dGame/Character.cpp | 18 +-- dGame/Entity.cpp | 2 +- dGame/EntityManager.cpp | 8 +- dGame/LeaderboardManager.cpp | 10 +- dGame/Player.cpp | 4 +- dGame/TradingManager.cpp | 22 +-- dGame/User.cpp | 6 +- dGame/UserManager.cpp | 50 +++---- dGame/dBehaviors/AirMovementBehavior.cpp | 8 +- dGame/dBehaviors/AndBehavior.cpp | 2 +- dGame/dBehaviors/AreaOfEffectBehavior.cpp | 10 +- dGame/dBehaviors/AttackDelayBehavior.cpp | 4 +- dGame/dBehaviors/BasicAttackBehavior.cpp | 32 ++-- dGame/dBehaviors/Behavior.cpp | 10 +- dGame/dBehaviors/BehaviorContext.cpp | 12 +- dGame/dBehaviors/BlockBehavior.cpp | 6 +- dGame/dBehaviors/BuffBehavior.cpp | 10 +- dGame/dBehaviors/CarBoostBehavior.cpp | 6 +- dGame/dBehaviors/ChainBehavior.cpp | 6 +- dGame/dBehaviors/ChargeUpBehavior.cpp | 4 +- dGame/dBehaviors/DamageAbsorptionBehavior.cpp | 6 +- dGame/dBehaviors/DamageReductionBehavior.cpp | 6 +- dGame/dBehaviors/DarkInspirationBehavior.cpp | 4 +- dGame/dBehaviors/ForceMovementBehavior.cpp | 8 +- dGame/dBehaviors/HealBehavior.cpp | 6 +- dGame/dBehaviors/ImaginationBehavior.cpp | 2 +- dGame/dBehaviors/ImmunityBehavior.cpp | 6 +- dGame/dBehaviors/InterruptBehavior.cpp | 8 +- dGame/dBehaviors/KnockbackBehavior.cpp | 4 +- dGame/dBehaviors/MovementSwitchBehavior.cpp | 4 +- dGame/dBehaviors/OverTimeBehavior.cpp | 2 +- dGame/dBehaviors/ProjectileAttackBehavior.cpp | 18 +-- dGame/dBehaviors/PropertyTeleportBehavior.cpp | 2 +- dGame/dBehaviors/RepairBehavior.cpp | 6 +- dGame/dBehaviors/SpawnBehavior.cpp | 8 +- dGame/dBehaviors/SpeedBehavior.cpp | 2 +- dGame/dBehaviors/StunBehavior.cpp | 10 +- dGame/dBehaviors/SwitchBehavior.cpp | 6 +- dGame/dBehaviors/SwitchMultipleBehavior.cpp | 4 +- dGame/dBehaviors/TacArcBehavior.cpp | 18 +-- dGame/dBehaviors/TauntBehavior.cpp | 6 +- dGame/dBehaviors/VerifyBehavior.cpp | 4 +- dGame/dComponents/BaseCombatAIComponent.cpp | 4 +- dGame/dComponents/BouncerComponent.cpp | 6 +- dGame/dComponents/BuffComponent.cpp | 4 +- dGame/dComponents/BuildBorderComponent.cpp | 6 +- dGame/dComponents/CharacterComponent.cpp | 13 +- .../ControllablePhysicsComponent.cpp | 14 +- dGame/dComponents/DestroyableComponent.cpp | 16 +- dGame/dComponents/InventoryComponent.cpp | 32 ++-- .../dComponents/LevelProgressionComponent.cpp | 4 +- dGame/dComponents/MissionComponent.cpp | 4 +- dGame/dComponents/MissionOfferComponent.cpp | 6 +- dGame/dComponents/MovementAIComponent.h | 2 +- dGame/dComponents/MovingPlatformComponent.cpp | 4 +- dGame/dComponents/PetComponent.cpp | 6 +- dGame/dComponents/PhantomPhysicsComponent.cpp | 4 +- .../dComponents/PropertyEntranceComponent.cpp | 4 +- .../PropertyManagementComponent.cpp | 32 ++-- dGame/dComponents/PropertyVendorComponent.cpp | 8 +- dGame/dComponents/RacingControlComponent.cpp | 28 ++-- dGame/dComponents/RailActivatorComponent.cpp | 2 +- dGame/dComponents/RebuildComponent.cpp | 6 +- dGame/dComponents/RenderComponent.cpp | 6 +- .../RocketLaunchpadControlComponent.cpp | 4 +- .../dComponents/ScriptedActivityComponent.cpp | 6 +- dGame/dComponents/SimplePhysicsComponent.cpp | 2 +- dGame/dComponents/SkillComponent.cpp | 12 +- dGame/dComponents/SkillComponent.h | 2 +- dGame/dComponents/SoundTriggerComponent.cpp | 2 +- dGame/dComponents/TriggerComponent.cpp | 24 +-- dGame/dComponents/VendorComponent.cpp | 4 +- dGame/dGameMessages/GameMessageHandler.cpp | 8 +- dGame/dGameMessages/GameMessageHandler.h | 2 +- dGame/dGameMessages/GameMessages.cpp | 94 ++++++------ dGame/dGameMessages/PropertyDataMessage.cpp | 2 +- dGame/dInventory/Inventory.cpp | 8 +- dGame/dInventory/Item.cpp | 16 +- dGame/dInventory/Item.h | 2 +- dGame/dMission/Mission.cpp | 4 +- dGame/dMission/MissionPrerequisites.cpp | 2 +- dGame/dMission/MissionTask.cpp | 10 +- .../AddActionMessage.cpp | 2 +- .../ControlBehaviorMessages/AddMessage.cpp | 2 +- .../AddStripMessage.cpp | 4 +- .../BehaviorMessageBase.h | 2 +- .../MergeStripsMessage.cpp | 2 +- .../MigrateActionsMessage.cpp | 2 +- .../MoveToInventoryMessage.cpp | 2 +- .../RearrangeStripMessage.cpp | 2 +- .../RemoveActionsMessage.cpp | 2 +- .../RemoveStripMessage.cpp | 2 +- .../ControlBehaviorMessages/RenameMessage.cpp | 2 +- .../SplitStripMessage.cpp | 2 +- .../UpdateActionMessage.cpp | 2 +- .../UpdateStripUiMessage.cpp | 2 +- dGame/dPropertyBehaviors/ControlBehaviors.cpp | 38 ++--- dGame/dUtilities/CheatDetection.cpp | 16 +- dGame/dUtilities/Mail.cpp | 8 +- dGame/dUtilities/Preconditions.cpp | 4 +- dGame/dUtilities/SlashCommandHandler.cpp | 22 +-- dGame/dUtilities/VanityUtilities.cpp | 34 +++-- dMasterServer/InstanceManager.cpp | 26 ++-- dMasterServer/InstanceManager.h | 6 +- dMasterServer/MasterServer.cpp | 137 +++++++++--------- dMasterServer/ObjectIDManager.cpp | 10 +- dMasterServer/ObjectIDManager.h | 6 +- dNavigation/dNavMesh.cpp | 6 +- dNet/AuthPackets.cpp | 16 +- dNet/ClientPackets.cpp | 14 +- dNet/PacketUtils.cpp | 4 +- dNet/WorldPackets.cpp | 6 +- dNet/dServer.cpp | 16 +- dNet/dServer.h | 8 +- dPhysics/dpWorld.cpp | 8 +- .../Enemy/AG/BossSpiderQueenEnemyServer.cpp | 6 +- .../02_server/Enemy/FV/FvMaelstromDragon.cpp | 2 +- .../02_server/Map/njhub/FlameJetServer.cpp | 2 +- .../boss_instance/NjMonastryBossInstance.cpp | 2 +- dScripts/ActivityManager.cpp | 8 +- dScripts/BaseRandomServer.cpp | 6 +- dScripts/CppScripts.cpp | 4 +- dScripts/ai/FV/TriggerGas.cpp | 2 +- dScripts/ai/GF/GfParrotCrash.cpp | 2 +- .../ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp | 62 ++++---- dWorldServer/ObjectIDManager.cpp | 2 +- dWorldServer/WorldServer.cpp | 104 ++++++------- dZoneManager/Level.cpp | 4 +- dZoneManager/Spawner.cpp | 2 +- dZoneManager/Zone.cpp | 18 +-- dZoneManager/dZoneManager.cpp | 28 ++-- tests/dCommonTests/AMFDeserializeTests.cpp | 2 +- tests/dCommonTests/TestLDFFormat.cpp | 4 +- tests/dCommonTests/dCommonDependencies.cpp | 4 +- tests/dCommonTests/dCommonDependencies.h | 4 +- tests/dGameTests/GameDependencies.cpp | 2 +- tests/dGameTests/GameDependencies.h | 4 +- 160 files changed, 1013 insertions(+), 985 deletions(-) create mode 100644 dCommon/Logger.cpp create mode 100644 dCommon/Logger.h delete mode 100644 dCommon/dLogger.cpp delete mode 100644 dCommon/dLogger.h diff --git a/dAuthServer/AuthServer.cpp b/dAuthServer/AuthServer.cpp index 38910823..a18657ca 100644 --- a/dAuthServer/AuthServer.cpp +++ b/dAuthServer/AuthServer.cpp @@ -7,7 +7,7 @@ //DLU Includes: #include "dCommonVars.h" #include "dServer.h" -#include "dLogger.h" +#include "Logger.h" #include "Database.h" #include "dConfig.h" #include "Diagnostics.h" @@ -25,14 +25,14 @@ #include "Game.h" namespace Game { - dLogger* logger = nullptr; + Logger* logger = nullptr; dServer* server = nullptr; dConfig* config = nullptr; bool shouldShutdown = false; std::mt19937 randomEngine; } -dLogger* SetupLogger(); +Logger* SetupLogger(); void HandlePacket(Packet* packet); int main(int argc, char** argv) { @@ -51,9 +51,9 @@ int main(int argc, char** argv) { Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0"); Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); - Game::logger->Log("AuthServer", "Starting Auth server..."); - Game::logger->Log("AuthServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); - Game::logger->Log("AuthServer", "Compiled on: %s", __TIMESTAMP__); + LOG("Starting Auth server..."); + LOG("Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); + LOG("Compiled on: %s", __TIMESTAMP__); //Connect to the MySQL Database std::string mysql_host = Game::config->GetValue("mysql_host"); @@ -64,7 +64,7 @@ int main(int argc, char** argv) { try { Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password); } catch (sql::SQLException& ex) { - Game::logger->Log("AuthServer", "Got an error while connecting to the database: %s", ex.what()); + LOG("Got an error while connecting to the database: %s", ex.what()); Database::Destroy("AuthServer"); delete Game::server; delete Game::logger; @@ -161,7 +161,7 @@ int main(int argc, char** argv) { return EXIT_SUCCESS; } -dLogger* SetupLogger() { +Logger* SetupLogger() { std::string logPath = (BinaryPathFinder::GetBinaryDir() / ("logs/AuthServer_" + std::to_string(time(nullptr)) + ".log")).string(); bool logToConsole = false; bool logDebugStatements = false; @@ -170,7 +170,7 @@ dLogger* SetupLogger() { logDebugStatements = true; #endif - return new dLogger(logPath, logToConsole, logDebugStatements); + return new Logger(logPath, logToConsole, logDebugStatements); } void HandlePacket(Packet* packet) { diff --git a/dChatFilter/dChatFilter.cpp b/dChatFilter/dChatFilter.cpp index 92da9556..6e3cd069 100644 --- a/dChatFilter/dChatFilter.cpp +++ b/dChatFilter/dChatFilter.cpp @@ -8,7 +8,7 @@ #include #include "dCommonVars.h" -#include "dLogger.h" +#include "Logger.h" #include "dConfig.h" #include "Database.h" #include "Game.h" diff --git a/dChatServer/ChatPacketHandler.cpp b/dChatServer/ChatPacketHandler.cpp index 3d6fca31..c6cc24b1 100644 --- a/dChatServer/ChatPacketHandler.cpp +++ b/dChatServer/ChatPacketHandler.cpp @@ -7,7 +7,7 @@ #include "Game.h" #include "dServer.h" #include "GeneralUtils.h" -#include "dLogger.h" +#include "Logger.h" #include "eAddFriendResponseCode.h" #include "eAddFriendResponseType.h" #include "RakString.h" @@ -397,7 +397,7 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet) { std::string message = PacketUtils::ReadString(0x66, packet, true, 512); - Game::logger->Log("ChatPacketHandler", "Got a message from (%s) [%d]: %s", senderName.c_str(), channel, message.c_str()); + LOG("Got a message from (%s) [%d]: %s", senderName.c_str(), channel, message.c_str()); if (channel != 8) return; @@ -527,13 +527,13 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet) { if (team->memberIDs.size() > 3) { // no more teams greater than 4 - Game::logger->Log("ChatPacketHandler", "Someone tried to invite a 5th player to a team"); + LOG("Someone tried to invite a 5th player to a team"); return; } SendTeamInvite(other, player); - Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.c_str()); + LOG("Got team invite: %llu -> %s", playerID, invitedPlayer.c_str()); } void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) { @@ -547,7 +547,7 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) { LWOOBJID leaderID = LWOOBJID_EMPTY; inStream.Read(leaderID); - Game::logger->Log("ChatPacketHandler", "Accepted invite: %llu -> %llu (%d)", playerID, leaderID, declined); + LOG("Accepted invite: %llu -> %llu (%d)", playerID, leaderID, declined); if (declined) { return; @@ -556,13 +556,13 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) { auto* team = playerContainer.GetTeam(leaderID); if (team == nullptr) { - Game::logger->Log("ChatPacketHandler", "Failed to find team for leader (%llu)", leaderID); + LOG("Failed to find team for leader (%llu)", leaderID); team = playerContainer.GetTeam(playerID); } if (team == nullptr) { - Game::logger->Log("ChatPacketHandler", "Failed to find team for player (%llu)", playerID); + LOG("Failed to find team for player (%llu)", playerID); return; } @@ -578,7 +578,7 @@ void ChatPacketHandler::HandleTeamLeave(Packet* packet) { auto* team = playerContainer.GetTeam(playerID); - Game::logger->Log("ChatPacketHandler", "(%llu) leaving team", playerID); + LOG("(%llu) leaving team", playerID); if (team != nullptr) { playerContainer.RemoveMember(team, playerID, false, false, true); @@ -592,7 +592,7 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet) { std::string kickedPlayer = PacketUtils::ReadString(0x14, packet, true); - Game::logger->Log("ChatPacketHandler", "(%llu) kicking (%s) from team", playerID, kickedPlayer.c_str()); + LOG("(%llu) kicking (%s) from team", playerID, kickedPlayer.c_str()); auto* kicked = playerContainer.GetPlayerData(kickedPlayer); @@ -622,7 +622,7 @@ void ChatPacketHandler::HandleTeamPromote(Packet* packet) { std::string promotedPlayer = PacketUtils::ReadString(0x14, packet, true); - Game::logger->Log("ChatPacketHandler", "(%llu) promoting (%s) to team leader", playerID, promotedPlayer.c_str()); + LOG("(%llu) promoting (%s) to team leader", playerID, promotedPlayer.c_str()); auto* promoted = playerContainer.GetPlayerData(promotedPlayer); diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index 185bccbf..6fb54594 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -6,7 +6,7 @@ //DLU Includes: #include "dCommonVars.h" #include "dServer.h" -#include "dLogger.h" +#include "Logger.h" #include "Database.h" #include "dConfig.h" #include "dChatFilter.h" @@ -27,7 +27,7 @@ #include namespace Game { - dLogger* logger = nullptr; + Logger* logger = nullptr; dServer* server = nullptr; dConfig* config = nullptr; dChatFilter* chatFilter = nullptr; @@ -37,7 +37,7 @@ namespace Game { } -dLogger* SetupLogger(); +Logger* SetupLogger(); void HandlePacket(Packet* packet); PlayerContainer playerContainer; @@ -58,9 +58,9 @@ int main(int argc, char** argv) { Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0"); Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); - Game::logger->Log("ChatServer", "Starting Chat server..."); - Game::logger->Log("ChatServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); - Game::logger->Log("ChatServer", "Compiled on: %s", __TIMESTAMP__); + LOG("Starting Chat server..."); + LOG("Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); + LOG("Compiled on: %s", __TIMESTAMP__); try { std::string clientPathStr = Game::config->GetValue("client_location"); @@ -72,7 +72,7 @@ int main(int argc, char** argv) { Game::assetManager = new AssetManager(clientPath); } catch (std::runtime_error& ex) { - Game::logger->Log("ChatServer", "Got an error while setting up assets: %s", ex.what()); + LOG("Got an error while setting up assets: %s", ex.what()); return EXIT_FAILURE; } @@ -86,7 +86,7 @@ int main(int argc, char** argv) { try { Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password); } catch (sql::SQLException& ex) { - Game::logger->Log("ChatServer", "Got an error while connecting to the database: %s", ex.what()); + LOG("Got an error while connecting to the database: %s", ex.what()); Database::Destroy("ChatServer"); delete Game::server; delete Game::logger; @@ -185,7 +185,7 @@ int main(int argc, char** argv) { return EXIT_SUCCESS; } -dLogger* SetupLogger() { +Logger* SetupLogger() { std::string logPath = (BinaryPathFinder::GetBinaryDir() / ("logs/ChatServer_" + std::to_string(time(nullptr)) + ".log")).string(); bool logToConsole = false; bool logDebugStatements = false; @@ -194,16 +194,16 @@ dLogger* SetupLogger() { logDebugStatements = true; #endif - return new dLogger(logPath, logToConsole, logDebugStatements); + return new Logger(logPath, logToConsole, logDebugStatements); } void HandlePacket(Packet* packet) { if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) { - Game::logger->Log("ChatServer", "A server has disconnected, erasing their connected players from the list."); + LOG("A server has disconnected, erasing their connected players from the list."); } if (packet->data[0] == ID_NEW_INCOMING_CONNECTION) { - Game::logger->Log("ChatServer", "A server is connecting, awaiting user list."); + LOG("A server is connecting, awaiting user list."); } if (packet->length < 4) return; // Nothing left to process. Need 4 bytes to continue. @@ -234,7 +234,7 @@ void HandlePacket(Packet* packet) { } default: - Game::logger->Log("ChatServer", "Unknown CHAT_INTERNAL id: %i", int(packet->data[3])); + LOG("Unknown CHAT_INTERNAL id: %i", int(packet->data[3])); } } @@ -245,7 +245,7 @@ void HandlePacket(Packet* packet) { break; case eChatMessageType::GET_IGNORE_LIST: - Game::logger->Log("ChatServer", "Asked for ignore list, but is unimplemented right now."); + LOG("Asked for ignore list, but is unimplemented right now."); break; case eChatMessageType::TEAM_GET_STATUS: @@ -303,19 +303,19 @@ void HandlePacket(Packet* packet) { break; default: - Game::logger->Log("ChatServer", "Unknown CHAT id: %i", int(packet->data[3])); + LOG("Unknown CHAT id: %i", int(packet->data[3])); } } if (static_cast(packet->data[1]) == eConnectionType::WORLD) { switch (static_cast(packet->data[3])) { case eWorldMessageType::ROUTE_PACKET: { - Game::logger->Log("ChatServer", "Routing packet from world"); + LOG("Routing packet from world"); break; } default: - Game::logger->Log("ChatServer", "Unknown World id: %i", int(packet->data[3])); + LOG("Unknown World id: %i", int(packet->data[3])); } } } diff --git a/dChatServer/PlayerContainer.cpp b/dChatServer/PlayerContainer.cpp index 503495f6..f467cfbe 100644 --- a/dChatServer/PlayerContainer.cpp +++ b/dChatServer/PlayerContainer.cpp @@ -3,7 +3,7 @@ #include #include #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "ChatPacketHandler.h" #include "GeneralUtils.h" #include "BitStreamUtils.h" @@ -44,7 +44,7 @@ void PlayerContainer::InsertPlayer(Packet* packet) { mNames[data->playerID] = GeneralUtils::UTF8ToUTF16(data->playerName); mPlayers.insert(std::make_pair(data->playerID, data)); - Game::logger->Log("PlayerContainer", "Added user: %s (%llu), zone: %i", data->playerName.c_str(), data->playerID, data->zoneID.GetMapID()); + LOG("Added user: %s (%llu), zone: %i", data->playerName.c_str(), data->playerID, data->zoneID.GetMapID()); auto* insertLog = Database::CreatePreppedStmt("INSERT INTO activity_log (character_id, activity, time, map_id) VALUES (?, ?, ?, ?);"); @@ -87,7 +87,7 @@ void PlayerContainer::RemovePlayer(Packet* packet) { } } - Game::logger->Log("PlayerContainer", "Removed user: %llu", playerID); + LOG("Removed user: %llu", playerID); mPlayers.erase(playerID); auto* insertLog = Database::CreatePreppedStmt("INSERT INTO activity_log (character_id, activity, time, map_id) VALUES (?, ?, ?, ?);"); @@ -110,7 +110,7 @@ void PlayerContainer::MuteUpdate(Packet* packet) { auto* player = this->GetPlayerData(playerID); if (player == nullptr) { - Game::logger->Log("PlayerContainer", "Failed to find user: %llu", playerID); + LOG("Failed to find user: %llu", playerID); return; } @@ -214,7 +214,7 @@ TeamData* PlayerContainer::GetTeam(LWOOBJID playerID) { void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) { if (team->memberIDs.size() >= 4){ - Game::logger->Log("PlayerContainer", "Tried to add player to team that already had 4 players"); + LOG("Tried to add player to team that already had 4 players"); auto* player = GetPlayerData(playerID); if (!player) return; ChatPackets::SendSystemMessage(player->sysAddr, u"The teams is full! You have not been added to a team!"); diff --git a/dCommon/Amf3.h b/dCommon/Amf3.h index 4c649524..967313c7 100644 --- a/dCommon/Amf3.h +++ b/dCommon/Amf3.h @@ -2,7 +2,7 @@ #define __AMF3__H__ #include "dCommonVars.h" -#include "dLogger.h" +#include "Logger.h" #include "Game.h" #include diff --git a/dCommon/AmfSerialize.cpp b/dCommon/AmfSerialize.cpp index 79ba5e2d..08f1eaad 100644 --- a/dCommon/AmfSerialize.cpp +++ b/dCommon/AmfSerialize.cpp @@ -1,7 +1,7 @@ #include "AmfSerialize.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" // Writes an AMFValue pointer to a RakNet::BitStream template<> @@ -29,7 +29,7 @@ void RakNet::BitStream::Write(AMFBaseValue& value) { break; } default: { - Game::logger->Log("AmfSerialize", "Encountered unwritable AMFType %i!", type); + LOG("Encountered unwritable AMFType %i!", type); } case eAmf::Undefined: case eAmf::Null: diff --git a/dCommon/BrickByBrickFix.cpp b/dCommon/BrickByBrickFix.cpp index 15194bf9..d9b589c1 100644 --- a/dCommon/BrickByBrickFix.cpp +++ b/dCommon/BrickByBrickFix.cpp @@ -9,7 +9,7 @@ #include "Database.h" #include "Game.h" #include "ZCompression.h" -#include "dLogger.h" +#include "Logger.h" //! Forward declarations @@ -59,14 +59,14 @@ uint32_t BrickByBrickFix::TruncateBrokenBrickByBrickXml() { completeUncompressedModel.append((char*)uncompressedChunk.get()); completeUncompressedModel.resize(previousSize + actualUncompressedSize); } else { - Game::logger->Log("BrickByBrickFix", "Failed to inflate chunk %i for model %llu. Error: %i", chunkCount, modelId, err); + LOG("Failed to inflate chunk %i for model %llu. Error: %i", chunkCount, modelId, err); break; } chunkCount++; } std::unique_ptr document = std::make_unique(); if (!document) { - Game::logger->Log("BrickByBrickFix", "Failed to initialize tinyxml document. Aborting."); + LOG("Failed to initialize tinyxml document. Aborting."); return 0; } @@ -75,8 +75,7 @@ uint32_t BrickByBrickFix::TruncateBrokenBrickByBrickXml() { "", completeUncompressedModel.length() >= 15 ? completeUncompressedModel.length() - 15 : 0) == std::string::npos ) { - Game::logger->Log("BrickByBrickFix", - "Brick-by-brick model %llu will be deleted!", modelId); + LOG("Brick-by-brick model %llu will be deleted!", modelId); ugcModelToDelete->setInt64(1, modelsToTruncate->getInt64(1)); pcModelToDelete->setInt64(1, modelsToTruncate->getInt64(1)); ugcModelToDelete->execute(); @@ -85,8 +84,7 @@ uint32_t BrickByBrickFix::TruncateBrokenBrickByBrickXml() { } } } else { - Game::logger->Log("BrickByBrickFix", - "Brick-by-brick model %llu will be deleted!", modelId); + LOG("Brick-by-brick model %llu will be deleted!", modelId); ugcModelToDelete->setInt64(1, modelsToTruncate->getInt64(1)); pcModelToDelete->setInt64(1, modelsToTruncate->getInt64(1)); ugcModelToDelete->execute(); @@ -140,12 +138,10 @@ uint32_t BrickByBrickFix::UpdateBrickByBrickModelsToSd0() { insertionStatement->setInt64(2, modelId); try { insertionStatement->executeUpdate(); - Game::logger->Log("BrickByBrickFix", "Updated model %i to sd0", modelId); + LOG("Updated model %i to sd0", modelId); updatedModels++; } catch (sql::SQLException exception) { - Game::logger->Log( - "BrickByBrickFix", - "Failed to update model %i. This model should be inspected manually to see why." + LOG("Failed to update model %i. This model should be inspected manually to see why." "The database error is %s", modelId, exception.what()); } } diff --git a/dCommon/CMakeLists.txt b/dCommon/CMakeLists.txt index 8092ec76..1354c051 100644 --- a/dCommon/CMakeLists.txt +++ b/dCommon/CMakeLists.txt @@ -4,7 +4,7 @@ set(DCOMMON_SOURCES "BinaryIO.cpp" "dConfig.cpp" "Diagnostics.cpp" - "dLogger.cpp" + "Logger.cpp" "GeneralUtils.cpp" "LDFFormat.cpp" "MD5.cpp" diff --git a/dCommon/Diagnostics.cpp b/dCommon/Diagnostics.cpp index f6c4b4b9..179ff6f6 100644 --- a/dCommon/Diagnostics.cpp +++ b/dCommon/Diagnostics.cpp @@ -1,6 +1,6 @@ #include "Diagnostics.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" // If we're on Win32, we'll include our minidump writer #ifdef _WIN32 @@ -9,7 +9,7 @@ #include #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void make_minidump(EXCEPTION_POINTERS* e) { auto hDbgHelp = LoadLibraryA("dbghelp"); @@ -28,7 +28,7 @@ void make_minidump(EXCEPTION_POINTERS* e) { "_%4d%02d%02d_%02d%02d%02d.dmp", t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); } - Game::logger->Log("Diagnostics", "Creating crash dump %s", name); + LOG("Creating crash dump %s", name); auto hFile = CreateFileA(name, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (hFile == INVALID_HANDLE_VALUE) return; @@ -83,7 +83,7 @@ struct bt_ctx { static inline void Bt(struct backtrace_state* state) { std::string fileName = Diagnostics::GetOutDirectory() + "crash_" + Diagnostics::GetProcessName() + "_" + std::to_string(getpid()) + ".log"; - Game::logger->Log("Diagnostics", "backtrace is enabled, crash dump located at %s", fileName.c_str()); + LOG("backtrace is enabled, crash dump located at %s", fileName.c_str()); FILE* file = fopen(fileName.c_str(), "w+"); if (file != nullptr) { backtrace_print(state, 2, file); @@ -118,7 +118,7 @@ void CatchUnhandled(int sig) { #ifndef __include_backtrace__ std::string fileName = Diagnostics::GetOutDirectory() + "crash_" + Diagnostics::GetProcessName() + "_" + std::to_string(getpid()) + ".log"; - Game::logger->Log("Diagnostics", "Encountered signal %i, creating crash dump %s", sig, fileName.c_str()); + LOG("Encountered signal %i, creating crash dump %s", sig, fileName.c_str()); if (Diagnostics::GetProduceMemoryDump()) { GenerateDump(); } @@ -154,7 +154,7 @@ void CatchUnhandled(int sig) { } } - Game::logger->Log("Diagnostics", "[%02zu] %s", i, functionName.c_str()); + LOG("[%02zu] %s", i, functionName.c_str()); } # else // defined(__GNUG__) backtrace_symbols_fd(array, size, STDOUT_FILENO); diff --git a/dCommon/FdbToSqlite.cpp b/dCommon/FdbToSqlite.cpp index e05286a9..0b2c546c 100644 --- a/dCommon/FdbToSqlite.cpp +++ b/dCommon/FdbToSqlite.cpp @@ -9,7 +9,7 @@ #include "CDClientDatabase.h" #include "GeneralUtils.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "AssetManager.h" #include "eSqliteDataType.h" @@ -44,7 +44,7 @@ bool FdbToSqlite::Convert::ConvertDatabase(AssetMemoryBuffer& buffer) { CDClientDatabase::ExecuteQuery("COMMIT;"); } catch (CppSQLite3Exception& e) { - Game::logger->Log("FdbToSqlite", "Encountered error %s converting FDB to SQLite", e.errorMessage()); + LOG("Encountered error %s converting FDB to SQLite", e.errorMessage()); return false; } diff --git a/dCommon/Game.h b/dCommon/Game.h index 09ac6f6e..79a271ec 100644 --- a/dCommon/Game.h +++ b/dCommon/Game.h @@ -3,7 +3,7 @@ #include class dServer; -class dLogger; +class Logger; class InstanceManager; class dChatFilter; class dConfig; @@ -14,7 +14,7 @@ class EntityManager; class dZoneManager; namespace Game { - extern dLogger* logger; + extern Logger* logger; extern dServer* server; extern InstanceManager* im; extern dChatFilter* chatFilter; diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index ec41c19b..7acb15b8 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -13,7 +13,7 @@ #include "NiPoint3.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" enum eInventoryType : uint32_t; enum class eObjectBits : size_t; diff --git a/dCommon/LDFFormat.cpp b/dCommon/LDFFormat.cpp index 5278747c..67f6a630 100644 --- a/dCommon/LDFFormat.cpp +++ b/dCommon/LDFFormat.cpp @@ -4,7 +4,7 @@ #include "GeneralUtils.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" // C++ #include @@ -48,7 +48,7 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { try { type = static_cast(strtol(ldfTypeAndValue.first.data(), &storage, 10)); } catch (std::exception) { - Game::logger->Log("LDFFormat", "Attempted to process invalid ldf type (%s) from string (%s)", ldfTypeAndValue.first.data(), format.data()); + LOG("Attempted to process invalid ldf type (%s) from string (%s)", ldfTypeAndValue.first.data(), format.data()); return nullptr; } @@ -63,7 +63,7 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { case LDF_TYPE_S32: { int32_t data; if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid int32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + LOG("Warning: Attempted to process invalid int32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); return nullptr; } returnValue = new LDFData(key, data); @@ -74,7 +74,7 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { case LDF_TYPE_FLOAT: { float data; if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid float value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + LOG("Warning: Attempted to process invalid float value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); return nullptr; } returnValue = new LDFData(key, data); @@ -84,7 +84,7 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { case LDF_TYPE_DOUBLE: { double data; if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid double value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + LOG("Warning: Attempted to process invalid double value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); return nullptr; } returnValue = new LDFData(key, data); @@ -101,7 +101,7 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { data = 0; } else { if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid uint32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + LOG("Warning: Attempted to process invalid uint32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); return nullptr; } } @@ -119,7 +119,7 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { data = false; } else { if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid bool value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + LOG("Warning: Attempted to process invalid bool value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); return nullptr; } } @@ -131,7 +131,7 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { case LDF_TYPE_U64: { uint64_t data; if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid uint64 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + LOG("Warning: Attempted to process invalid uint64 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); return nullptr; } returnValue = new LDFData(key, data); @@ -141,7 +141,7 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { case LDF_TYPE_OBJID: { LWOOBJID data; if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid LWOOBJID value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + LOG("Warning: Attempted to process invalid LWOOBJID value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); return nullptr; } returnValue = new LDFData(key, data); @@ -155,12 +155,12 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { } case LDF_TYPE_UNKNOWN: { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid unknown value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + LOG("Warning: Attempted to process invalid unknown value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); break; } default: { - Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid LDF type (%d) from string (%s)", type, format.data()); + LOG("Warning: Attempted to process invalid LDF type (%d) from string (%s)", type, format.data()); break; } } diff --git a/dCommon/Logger.cpp b/dCommon/Logger.cpp new file mode 100644 index 00000000..83a97aa6 --- /dev/null +++ b/dCommon/Logger.cpp @@ -0,0 +1,96 @@ +#include "Logger.h" + +#include +#include +#include +#include + +Writer::~Writer() { + // Dont try to close stdcout... + if (!m_Outfile || m_IsConsoleWriter) return; + + fclose(m_Outfile); + m_Outfile = NULL; +} + +void Writer::Log(const char* time, const char* message) { + if (!m_Outfile) return; + + fputs(time, m_Outfile); + fputs(message, m_Outfile); +} + +void Writer::Flush() { + if (!m_Outfile) return; + fflush(m_Outfile); +} + +FileWriter::FileWriter(const char* outpath) { + m_Outfile = fopen(outpath, "wt"); + if (!m_Outfile) printf("Couldn't open %s for writing!\n", outpath); + m_Outpath = outpath; + m_IsConsoleWriter = false; +} + +ConsoleWriter::ConsoleWriter(bool enabled) { + m_Enabled = enabled; + m_Outfile = stdout; + m_IsConsoleWriter = true; +} + +Logger::Logger(const std::string& outpath, bool logToConsole, bool logDebugStatements) { + m_logDebugStatements = logDebugStatements; + std::filesystem::path outpathPath(outpath); + if (!std::filesystem::exists(outpathPath.parent_path())) std::filesystem::create_directories(outpathPath.parent_path()); + m_Writers.push_back(std::make_unique(outpath)); + m_Writers.push_back(std::make_unique(logToConsole)); +} + +void Logger::vLog(const char* format, va_list args) { + time_t t = time(NULL); + struct tm* time = localtime(&t); + char timeStr[70]; + strftime(timeStr, sizeof(timeStr), "[%d-%m-%y %H:%M:%S ", time); + char message[2048]; + vsnprintf(message, 2048, format, args); + for (const auto& writer : m_Writers) { + writer->Log(timeStr, message); + } +} + +void Logger::Log(const char* className, const char* format, ...) { + va_list args; + std::string log = std::string(className) + "] " + std::string(format) + "\n"; + va_start(args, format); + vLog(log.c_str(), args); + va_end(args); +} + +void Logger::LogDebug(const char* className, const char* format, ...) { + if (!m_logDebugStatements) return; + va_list args; + std::string log = std::string(className) + "] " + std::string(format) + "\n"; + va_start(args, format); + vLog(log.c_str(), args); + va_end(args); +} + +void Logger::Flush() { + for (const auto& writer : m_Writers) { + writer->Flush(); + } +} + +void Logger::SetLogToConsole(bool logToConsole) { + for (const auto& writer : m_Writers) { + if (writer->IsConsoleWriter()) writer->SetEnabled(logToConsole); + } +} + +bool Logger::GetLogToConsole() const { + bool toReturn = false; + for (const auto& writer : m_Writers) { + if (writer->IsConsoleWriter()) toReturn |= writer->GetEnabled(); + } + return toReturn; +} diff --git a/dCommon/Logger.h b/dCommon/Logger.h new file mode 100644 index 00000000..5754d9ac --- /dev/null +++ b/dCommon/Logger.h @@ -0,0 +1,89 @@ +#pragma once + +#include +#include +#include + +#define STRINGIFY_IMPL(x) #x + +#define STRINGIFY(x) STRINGIFY_IMPL(x) + +#define GET_FILE_NAME(x, y) GetFileNameFromAbsolutePath(__FILE__ x y) + +#define FILENAME_AND_LINE GET_FILE_NAME(":", STRINGIFY(__LINE__)) + +// Calculate the filename at compile time from the path. +// We just do this by scanning the path for the last '/' or '\' character and returning the string after it. +constexpr const char* GetFileNameFromAbsolutePath(const char* path) { + const char* file = path; + while (*path) { + char nextChar = *path++; + if (nextChar == '/' || nextChar == '\\') { + file = path; + } + } + return file; +} + +// These have to have a constexpr variable to store the filename_and_line result in a local variable otherwise +// they will not be valid constexpr and will be evaluated at runtime instead of compile time! +// The full string is still stored in the binary, however the offset of the filename in the absolute paths +// is used in the instruction instead of the start of the absolute path. +#define LOG(message, ...) do { auto str = FILENAME_AND_LINE; Game::logger->Log(str, message, ##__VA_ARGS__); } while(0) +#define LOG_DEBUG(message, ...) do { auto str = FILENAME_AND_LINE; Game::logger->LogDebug(str, message, ##__VA_ARGS__); } while(0) + +// Writer class for writing data to files. +class Writer { +public: + Writer(bool enabled = true) : m_Enabled(enabled) {}; + virtual ~Writer(); + + virtual void Log(const char* time, const char* message); + virtual void Flush(); + + void SetEnabled(bool disabled) { m_Enabled = disabled; } + bool GetEnabled() const { return m_Enabled; } + + bool IsConsoleWriter() { return m_IsConsoleWriter; } +public: + bool m_Enabled = true; + bool m_IsConsoleWriter = false; + FILE* m_Outfile; +}; + +// FileWriter class for writing data to a file on a disk. +class FileWriter : public Writer { +public: + FileWriter(const char* outpath); + FileWriter(const std::string& outpath) : FileWriter(outpath.c_str()) {}; +private: + std::string m_Outpath; +}; + +// ConsoleWriter class for writing data to the console. +class ConsoleWriter : public Writer { +public: + ConsoleWriter(bool enabled); +}; + +class Logger { +public: + Logger() = delete; + Logger(const std::string& outpath, bool logToConsole, bool logDebugStatements); + + void Log(const char* filenameAndLine, const char* format, ...); + void LogDebug(const char* filenameAndLine, const char* format, ...); + + void Flush(); + + bool GetLogToConsole() const; + void SetLogToConsole(bool logToConsole); + + void SetLogDebugStatements(bool logDebugStatements) { m_logDebugStatements = logDebugStatements; } + +private: + void vLog(const char* format, va_list args); + + bool m_logDebugStatements; + std::vector> m_Writers; +}; diff --git a/dCommon/dClient/AssetManager.cpp b/dCommon/dClient/AssetManager.cpp index 00cedba9..c672b335 100644 --- a/dCommon/dClient/AssetManager.cpp +++ b/dCommon/dClient/AssetManager.cpp @@ -2,7 +2,7 @@ #include "AssetManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include diff --git a/dCommon/dClient/Pack.h b/dCommon/dClient/Pack.h index 3e95b00a..8113ed55 100644 --- a/dCommon/dClient/Pack.h +++ b/dCommon/dClient/Pack.h @@ -3,6 +3,7 @@ #include #include #include +#include #pragma pack(push, 1) struct PackRecord { diff --git a/dCommon/dClient/PackIndex.cpp b/dCommon/dClient/PackIndex.cpp index 5d96abeb..55c26b48 100644 --- a/dCommon/dClient/PackIndex.cpp +++ b/dCommon/dClient/PackIndex.cpp @@ -1,7 +1,7 @@ #include "PackIndex.h" #include "BinaryIO.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" PackIndex::PackIndex(const std::filesystem::path& filePath) { m_FileStream = std::ifstream(filePath / "versions" / "primary.pki", std::ios::in | std::ios::binary); @@ -34,7 +34,7 @@ PackIndex::PackIndex(const std::filesystem::path& filePath) { m_PackFileIndices.push_back(packFileIndex); } - Game::logger->Log("PackIndex", "Loaded pack catalog with %i pack files and %i files", m_PackPaths.size(), m_PackFileIndices.size()); + LOG("Loaded pack catalog with %i pack files and %i files", m_PackPaths.size(), m_PackFileIndices.size()); for (auto& item : m_PackPaths) { std::replace(item.begin(), item.end(), '\\', '/'); diff --git a/dCommon/dLogger.cpp b/dCommon/dLogger.cpp deleted file mode 100644 index 7785a070..00000000 --- a/dCommon/dLogger.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "dLogger.h" - -dLogger::dLogger(const std::string& outpath, bool logToConsole, bool logDebugStatements) { - m_logToConsole = logToConsole; - m_logDebugStatements = logDebugStatements; - m_outpath = outpath; - -#ifdef _WIN32 - mFile = std::ofstream(m_outpath); - if (!mFile) { printf("Couldn't open %s for writing!\n", outpath.c_str()); } -#else - fp = fopen(outpath.c_str(), "wt"); - if (fp == NULL) { printf("Couldn't open %s for writing!\n", outpath.c_str()); } -#endif -} - -dLogger::~dLogger() { -#ifdef _WIN32 - mFile.close(); -#else - if (fp != nullptr) { - fclose(fp); - fp = nullptr; - } -#endif -} - -void dLogger::vLog(const char* format, va_list args) { -#ifdef _WIN32 - time_t t = time(NULL); - struct tm time; - localtime_s(&time, &t); - char timeStr[70]; - strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time); - char message[2048]; - vsnprintf(message, 2048, format, args); - - if (m_logToConsole) std::cout << "[" << timeStr << "] " << message; - mFile << "[" << timeStr << "] " << message; -#else - time_t t = time(NULL); - struct tm* time = localtime(&t); - char timeStr[70]; - strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time); - char message[2048]; - vsnprintf(message, 2048, format, args); - - if (m_logToConsole) { - fputs("[", stdout); - fputs(timeStr, stdout); - fputs("] ", stdout); - fputs(message, stdout); - } - - if (fp != nullptr) { - fputs("[", fp); - fputs(timeStr, fp); - fputs("] ", fp); - fputs(message, fp); - } else { - printf("Logger not initialized!\n"); - } -#endif -} - -void dLogger::LogBasic(const char* format, ...) { - va_list args; - va_start(args, format); - vLog(format, args); - va_end(args); -} - -void dLogger::LogBasic(const std::string& message) { - LogBasic(message.c_str()); -} - -void dLogger::Log(const char* className, const char* format, ...) { - va_list args; - std::string log = "[" + std::string(className) + "] " + std::string(format) + "\n"; - va_start(args, format); - vLog(log.c_str(), args); - va_end(args); -} - -void dLogger::Log(const std::string& className, const std::string& message) { - Log(className.c_str(), message.c_str()); -} - -void dLogger::LogDebug(const char* className, const char* format, ...) { - if (!m_logDebugStatements) return; - va_list args; - std::string log = "[" + std::string(className) + "] " + std::string(format) + "\n"; - va_start(args, format); - vLog(log.c_str(), args); - va_end(args); -} - -void dLogger::LogDebug(const std::string& className, const std::string& message) { - LogDebug(className.c_str(), message.c_str()); -} - -void dLogger::Flush() { -#ifdef _WIN32 - mFile.flush(); -#else - if (fp != nullptr) { - std::fflush(fp); - } -#endif -} diff --git a/dCommon/dLogger.h b/dCommon/dLogger.h deleted file mode 100644 index 6726c6f1..00000000 --- a/dCommon/dLogger.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include - -class dLogger { -public: - dLogger(const std::string& outpath, bool logToConsole, bool logDebugStatements); - ~dLogger(); - - void SetLogToConsole(bool logToConsole) { m_logToConsole = logToConsole; } - void SetLogDebugStatements(bool logDebugStatements) { m_logDebugStatements = logDebugStatements; } - void vLog(const char* format, va_list args); - - void LogBasic(const std::string& message); - void LogBasic(const char* format, ...); - void Log(const char* className, const char* format, ...); - void Log(const std::string& className, const std::string& message); - void LogDebug(const std::string& className, const std::string& message); - void LogDebug(const char* className, const char* format, ...); - - void Flush(); - - const bool GetIsLoggingToConsole() const { return m_logToConsole; } - -private: - bool m_logDebugStatements; - bool m_logToConsole; - std::string m_outpath; - std::ofstream mFile; - -#ifndef _WIN32 - //Glorious linux can run with SPEED: - FILE* fp = nullptr; -#endif -}; diff --git a/dDatabase/Database.cpp b/dDatabase/Database.cpp index 1ce6966f..5fc76786 100644 --- a/dDatabase/Database.cpp +++ b/dDatabase/Database.cpp @@ -1,7 +1,7 @@ #include "Database.h" #include "Game.h" #include "dConfig.h" -#include "dLogger.h" +#include "Logger.h" using namespace std; #pragma warning (disable:4251) //Disables SQL warnings @@ -64,8 +64,8 @@ void Database::Destroy(std::string source, bool log) { if (!con) return; if (log) { - if (source != "") Game::logger->Log("Database", "Destroying MySQL connection from %s!", source.c_str()); - else Game::logger->Log("Database", "Destroying MySQL connection!"); + if (source != "") LOG("Destroying MySQL connection from %s!", source.c_str()); + else LOG("Destroying MySQL connection!"); } con->close(); @@ -84,7 +84,7 @@ sql::PreparedStatement* Database::CreatePreppedStmt(const std::string& query) { if (!con) { Connect(); - Game::logger->Log("Database", "Trying to reconnect to MySQL"); + LOG("Trying to reconnect to MySQL"); } if (!con->isValid() || con->isClosed()) { @@ -93,7 +93,7 @@ sql::PreparedStatement* Database::CreatePreppedStmt(const std::string& query) { con = nullptr; Connect(); - Game::logger->Log("Database", "Trying to reconnect to MySQL from invalid or closed connection"); + LOG("Trying to reconnect to MySQL from invalid or closed connection"); } auto* stmt = con->prepareStatement(str); diff --git a/dDatabase/MigrationRunner.cpp b/dDatabase/MigrationRunner.cpp index 5e70c401..2dbe9101 100644 --- a/dDatabase/MigrationRunner.cpp +++ b/dDatabase/MigrationRunner.cpp @@ -5,10 +5,10 @@ #include "Database.h" #include "Game.h" #include "GeneralUtils.h" -#include "dLogger.h" +#include "Logger.h" #include "BinaryPathFinder.h" -#include +#include Migration LoadMigration(std::string path) { Migration migration{}; @@ -53,7 +53,7 @@ void MigrationRunner::RunMigrations() { delete stmt; if (doExit) continue; - Game::logger->Log("MigrationRunner", "Running migration: %s", migration.name.c_str()); + LOG("Running migration: %s", migration.name.c_str()); if (migration.name == "dlu/5_brick_model_sd0.sql") { runSd0Migrations = true; } else { @@ -67,7 +67,7 @@ void MigrationRunner::RunMigrations() { } if (finalSQL.empty() && !runSd0Migrations) { - Game::logger->Log("MigrationRunner", "Server database is up to date."); + LOG("Server database is up to date."); return; } @@ -79,7 +79,7 @@ void MigrationRunner::RunMigrations() { if (query.empty()) continue; simpleStatement->execute(query.c_str()); } catch (sql::SQLException& e) { - Game::logger->Log("MigrationRunner", "Encountered error running migration: %s", e.what()); + LOG("Encountered error running migration: %s", e.what()); } } } @@ -87,9 +87,9 @@ void MigrationRunner::RunMigrations() { // Do this last on the off chance none of the other migrations have been run yet. if (runSd0Migrations) { uint32_t numberOfUpdatedModels = BrickByBrickFix::UpdateBrickByBrickModelsToSd0(); - Game::logger->Log("MasterServer", "%i models were updated from zlib to sd0.", numberOfUpdatedModels); + LOG("%i models were updated from zlib to sd0.", numberOfUpdatedModels); uint32_t numberOfTruncatedModels = BrickByBrickFix::TruncateBrokenBrickByBrickXml(); - Game::logger->Log("MasterServer", "%i models were truncated from the database.", numberOfTruncatedModels); + LOG("%i models were truncated from the database.", numberOfTruncatedModels); } } @@ -135,14 +135,14 @@ void MigrationRunner::RunSQLiteMigrations() { // Doing these 1 migration at a time since one takes a long time and some may think it is crashing. // This will at the least guarentee that the full migration needs to be run in order to be counted as "migrated". - Game::logger->Log("MigrationRunner", "Executing migration: %s. This may take a while. Do not shut down server.", migration.name.c_str()); + LOG("Executing migration: %s. This may take a while. Do not shut down server.", migration.name.c_str()); CDClientDatabase::ExecuteQuery("BEGIN TRANSACTION;"); for (const auto& dml : GeneralUtils::SplitString(migration.data, ';')) { if (dml.empty()) continue; try { CDClientDatabase::ExecuteDML(dml.c_str()); } catch (CppSQLite3Exception& e) { - Game::logger->Log("MigrationRunner", "Encountered error running DML command: (%i) : %s", e.errorCode(), e.errorMessage()); + LOG("Encountered error running DML command: (%i) : %s", e.errorCode(), e.errorMessage()); } } @@ -154,5 +154,5 @@ void MigrationRunner::RunSQLiteMigrations() { CDClientDatabase::ExecuteQuery("COMMIT;"); } - Game::logger->Log("MigrationRunner", "CDServer database is up to date."); + LOG("CDServer database is up to date."); } diff --git a/dGame/Character.cpp b/dGame/Character.cpp index c5602bf2..a153fe10 100644 --- a/dGame/Character.cpp +++ b/dGame/Character.cpp @@ -2,7 +2,7 @@ #include "User.h" #include "Database.h" #include "GeneralUtils.h" -#include "dLogger.h" +#include "Logger.h" #include "BitStream.h" #include "Game.h" #include @@ -145,16 +145,16 @@ void Character::DoQuickXMLDataParse() { if (!m_Doc) return; if (m_Doc->Parse(m_XMLData.c_str(), m_XMLData.size()) == 0) { - Game::logger->Log("Character", "Loaded xmlData for character %s (%i)!", m_Name.c_str(), m_ID); + LOG("Loaded xmlData for character %s (%i)!", m_Name.c_str(), m_ID); } else { - Game::logger->Log("Character", "Failed to load xmlData!"); + LOG("Failed to load xmlData!"); //Server::rakServer->CloseConnection(m_ParentUser->GetSystemAddress(), true); return; } tinyxml2::XMLElement* mf = m_Doc->FirstChildElement("obj")->FirstChildElement("mf"); if (!mf) { - Game::logger->Log("Character", "Failed to find mf tag!"); + LOG("Failed to find mf tag!"); return; } @@ -173,14 +173,14 @@ void Character::DoQuickXMLDataParse() { tinyxml2::XMLElement* inv = m_Doc->FirstChildElement("obj")->FirstChildElement("inv"); if (!inv) { - Game::logger->Log("Character", "Char has no inv!"); + LOG("Char has no inv!"); return; } tinyxml2::XMLElement* bag = inv->FirstChildElement("items")->FirstChildElement("in"); if (!bag) { - Game::logger->Log("Character", "Couldn't find bag0!"); + LOG("Couldn't find bag0!"); return; } @@ -373,7 +373,7 @@ void Character::SaveXMLToDatabase() { //Call upon the entity to update our xmlDoc: if (!m_OurEntity) { - Game::logger->Log("Character", "%i:%s didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!", this->GetID(), this->GetName().c_str()); + LOG("%i:%s didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!", this->GetID(), this->GetName().c_str()); return; } @@ -384,7 +384,7 @@ void Character::SaveXMLToDatabase() { //For metrics, log the time it took to save: auto end = std::chrono::system_clock::now(); std::chrono::duration elapsed = end - start; - Game::logger->Log("Character", "%i:%s Saved character to Database in: %fs", this->GetID(), this->GetName().c_str(), elapsed.count()); + LOG("%i:%s Saved character to Database in: %fs", this->GetID(), this->GetName().c_str(), elapsed.count()); } void Character::SetIsNewLogin() { @@ -396,7 +396,7 @@ void Character::SetIsNewLogin() { while (currentChild) { if (currentChild->Attribute("si")) { flags->DeleteChild(currentChild); - Game::logger->Log("Character", "Removed isLoggedIn flag from character %i:%s, saving character to database", GetID(), GetName().c_str()); + LOG("Removed isLoggedIn flag from character %i:%s, saving character to database", GetID(), GetName().c_str()); WriteToDatabase(); } currentChild = currentChild->NextSiblingElement(); diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 3f87dec5..14eadd4a 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -2,7 +2,7 @@ #include "Entity.h" #include "CDClientManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include #include #include "CDDestructibleComponentTable.h" diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index 4018aba8..15634e14 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -16,7 +16,7 @@ #include "dZoneManager.h" #include "MissionComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "MessageIdentifiers.h" #include "dConfig.h" #include "eTriggerEventType.h" @@ -208,7 +208,7 @@ void EntityManager::KillEntities() { auto* entity = GetEntity(*entry); if (!entity) { - Game::logger->Log("EntityManager", "Attempting to kill null entity %llu", *entry); + LOG("Attempting to kill null entity %llu", *entry); continue; } @@ -237,7 +237,7 @@ void EntityManager::DeleteEntities() { if (ghostingToDelete != m_EntitiesToGhost.end()) m_EntitiesToGhost.erase(ghostingToDelete); } else { - Game::logger->Log("EntityManager", "Attempted to delete non-existent entity %llu", *entry); + LOG("Attempted to delete non-existent entity %llu", *entry); } m_Entities.erase(*entry); } @@ -330,7 +330,7 @@ const std::unordered_map& EntityManager::GetSpawnPointEnt void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr, const bool skipChecks) { if (!entity) { - Game::logger->Log("EntityManager", "Attempted to construct null entity"); + LOG("Attempted to construct null entity"); return; } diff --git a/dGame/LeaderboardManager.cpp b/dGame/LeaderboardManager.cpp index 0e64b6b3..b7083ea8 100644 --- a/dGame/LeaderboardManager.cpp +++ b/dGame/LeaderboardManager.cpp @@ -8,7 +8,7 @@ #include "Character.h" #include "Game.h" #include "GameMessages.h" -#include "dLogger.h" +#include "Logger.h" #include "dConfig.h" #include "CDClientManager.h" #include "GeneralUtils.h" @@ -236,7 +236,7 @@ void Leaderboard::SetupLeaderboard(bool weekly, uint32_t resultStart, uint32_t r baseLookup += std::to_string(static_cast(this->relatedPlayer)); } baseLookup += " LIMIT 1"; - Game::logger->LogDebug("LeaderboardManager", "query is %s", baseLookup.c_str()); + LOG_DEBUG("query is %s", baseLookup.c_str()); std::unique_ptr baseQuery(Database::CreatePreppedStmt(baseLookup)); baseQuery->setInt(1, this->gameID); std::unique_ptr baseResult(baseQuery->executeQuery()); @@ -251,7 +251,7 @@ void Leaderboard::SetupLeaderboard(bool weekly, uint32_t resultStart, uint32_t r int32_t res = snprintf(lookupBuffer.get(), STRING_LENGTH, queryBase.c_str(), orderBase.data(), filter.c_str(), resultStart, resultEnd); DluAssert(res != -1); std::unique_ptr query(Database::CreatePreppedStmt(lookupBuffer.get())); - Game::logger->LogDebug("LeaderboardManager", "Query is %s vars are %i %i %i", lookupBuffer.get(), this->gameID, this->relatedPlayer, relatedPlayerLeaderboardId); + LOG_DEBUG("Query is %s vars are %i %i %i", lookupBuffer.get(), this->gameID, this->relatedPlayer, relatedPlayerLeaderboardId); query->setInt(1, this->gameID); if (this->infoType == InfoType::Friends) { query->setInt(2, this->relatedPlayer); @@ -358,7 +358,7 @@ void LeaderboardManager::SaveScore(const LWOOBJID& playerID, const GameID activi } case Leaderboard::Type::None: default: - Game::logger->Log("LeaderboardManager", "Unknown leaderboard type %i for game %i. Cannot save score!", leaderboardType, activityId); + LOG("Unknown leaderboard type %i for game %i. Cannot save score!", leaderboardType, activityId); return; } bool newHighScore = lowerScoreBetter ? newScore < oldScore : newScore > oldScore; @@ -377,7 +377,7 @@ void LeaderboardManager::SaveScore(const LWOOBJID& playerID, const GameID activi } else { saveQuery = FormatInsert(leaderboardType, newScore, false); } - Game::logger->Log("LeaderboardManager", "save query %s %i %i", saveQuery.c_str(), playerID, activityId); + LOG("save query %s %i %i", saveQuery.c_str(), playerID, activityId); std::unique_ptr saveStatement(Database::CreatePreppedStmt(saveQuery)); saveStatement->setInt(1, playerID); saveStatement->setInt(2, activityId); diff --git a/dGame/Player.cpp b/dGame/Player.cpp index 48b983aa..65c7aae5 100644 --- a/dGame/Player.cpp +++ b/dGame/Player.cpp @@ -7,7 +7,7 @@ #include "MissionComponent.h" #include "UserManager.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" #include "ZoneInstanceManager.h" #include "WorldPackets.h" #include "dZoneManager.h" @@ -260,7 +260,7 @@ void Player::SetDroppedCoins(uint64_t value) { } Player::~Player() { - Game::logger->Log("Player", "Deleted player"); + LOG("Deleted player"); for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) { const auto id = m_ObservedEntities[i]; diff --git a/dGame/TradingManager.cpp b/dGame/TradingManager.cpp index 09d452b3..7c3c9bb6 100644 --- a/dGame/TradingManager.cpp +++ b/dGame/TradingManager.cpp @@ -4,7 +4,7 @@ #include "InventoryComponent.h" #include "../dWorldServer/ObjectIDManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "Item.h" #include "Character.h" #include "CharacterComponent.h" @@ -67,7 +67,7 @@ void Trade::SetAccepted(LWOOBJID participant, bool value) { if (participant == m_ParticipantA) { m_AcceptedA = !value; - Game::logger->Log("Trade", "Accepted from A (%d), B: (%d)", value, m_AcceptedB); + LOG("Accepted from A (%d), B: (%d)", value, m_AcceptedB); auto* entityB = GetParticipantBEntity(); @@ -77,7 +77,7 @@ void Trade::SetAccepted(LWOOBJID participant, bool value) { } else if (participant == m_ParticipantB) { m_AcceptedB = !value; - Game::logger->Log("Trade", "Accepted from B (%d), A: (%d)", value, m_AcceptedA); + LOG("Accepted from B (%d), A: (%d)", value, m_AcceptedA); auto* entityA = GetParticipantAEntity(); @@ -125,7 +125,7 @@ void Trade::Complete() { // First verify both players have the coins and items requested for the trade. if (characterA->GetCoins() < m_CoinsA || characterB->GetCoins() < m_CoinsB) { - Game::logger->Log("TradingManager", "Possible coin trade cheating attempt! Aborting trade."); + LOG("Possible coin trade cheating attempt! Aborting trade."); return; } @@ -133,11 +133,11 @@ void Trade::Complete() { auto* itemToRemove = inventoryA->FindItemById(tradeItem.itemId); if (itemToRemove) { if (itemToRemove->GetCount() < tradeItem.itemCount) { - Game::logger->Log("TradingManager", "Possible cheating attempt from %s in trading!!! Aborting trade", characterA->GetName().c_str()); + LOG("Possible cheating attempt from %s in trading!!! Aborting trade", characterA->GetName().c_str()); return; } } else { - Game::logger->Log("TradingManager", "Possible cheating attempt from %s in trading due to item not being available!!!", characterA->GetName().c_str()); + LOG("Possible cheating attempt from %s in trading due to item not being available!!!", characterA->GetName().c_str()); return; } } @@ -146,11 +146,11 @@ void Trade::Complete() { auto* itemToRemove = inventoryB->FindItemById(tradeItem.itemId); if (itemToRemove) { if (itemToRemove->GetCount() < tradeItem.itemCount) { - Game::logger->Log("TradingManager", "Possible cheating attempt from %s in trading!!! Aborting trade", characterB->GetName().c_str()); + LOG("Possible cheating attempt from %s in trading!!! Aborting trade", characterB->GetName().c_str()); return; } } else { - Game::logger->Log("TradingManager", "Possible cheating attempt from %s in trading due to item not being available!!! Aborting trade", characterB->GetName().c_str()); + LOG("Possible cheating attempt from %s in trading due to item not being available!!! Aborting trade", characterB->GetName().c_str()); return; } } @@ -194,7 +194,7 @@ void Trade::SendUpdateToOther(LWOOBJID participant) { uint64_t coins; std::vector itemIds; - Game::logger->Log("Trade", "Attempting to send trade update"); + LOG("Attempting to send trade update"); if (participant == m_ParticipantA) { other = GetParticipantBEntity(); @@ -228,7 +228,7 @@ void Trade::SendUpdateToOther(LWOOBJID participant) { items.push_back(tradeItem); } - Game::logger->Log("Trade", "Sending trade update"); + LOG("Sending trade update"); GameMessages::SendServerTradeUpdate(other->GetObjectID(), coins, items, other->GetSystemAddress()); } @@ -279,7 +279,7 @@ Trade* TradingManager::NewTrade(LWOOBJID participantA, LWOOBJID participantB) { trades[tradeId] = trade; - Game::logger->Log("TradingManager", "Created new trade between (%llu) <-> (%llu)", participantA, participantB); + LOG("Created new trade between (%llu) <-> (%llu)", participantA, participantB); return trade; } diff --git a/dGame/User.cpp b/dGame/User.cpp index 55bbcc09..afde75f6 100644 --- a/dGame/User.cpp +++ b/dGame/User.cpp @@ -2,7 +2,7 @@ #include "Database.h" #include "Character.h" #include "dServer.h" -#include "dLogger.h" +#include "Logger.h" #include "Game.h" #include "dZoneManager.h" #include "eServerDisconnectIdentifiers.h" @@ -52,7 +52,7 @@ User::User(const SystemAddress& sysAddr, const std::string& username, const std: LWOOBJID objID = res->getUInt64(1); Character* character = new Character(uint32_t(objID), this); m_Characters.push_back(character); - Game::logger->Log("User", "Loaded %llu as it is the last used char", objID); + LOG("Loaded %llu as it is the last used char", objID); } } @@ -127,7 +127,7 @@ void User::UserOutOfSync() { m_AmountOfTimesOutOfSync++; if (m_AmountOfTimesOutOfSync > m_MaxDesyncAllowed) { //YEET - Game::logger->Log("User", "User %s was out of sync %i times out of %i, disconnecting for suspected speedhacking.", m_Username.c_str(), m_AmountOfTimesOutOfSync, m_MaxDesyncAllowed); + LOG("User %s was out of sync %i times out of %i, disconnecting for suspected speedhacking.", m_Username.c_str(), m_AmountOfTimesOutOfSync, m_MaxDesyncAllowed); Game::server->Disconnect(this->m_SystemAddress, eServerDisconnectIdentifiers::PLAY_SCHEDULE_TIME_DONE); } } diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index 90e44187..aaa4893f 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -6,14 +6,14 @@ #include "Database.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "User.h" #include #include "Character.h" #include #include "PacketUtils.h" #include "../dWorldServer/ObjectIDManager.h" -#include "dLogger.h" +#include "Logger.h" #include "GeneralUtils.h" #include "ZoneInstanceManager.h" #include "dServer.h" @@ -46,7 +46,7 @@ void UserManager::Initialize() { AssetMemoryBuffer fnBuff = Game::assetManager->GetFileAsBuffer("names/minifigname_first.txt"); if (!fnBuff.m_Success) { - Game::logger->Log("UserManager", "Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_first.txt").string().c_str()); + LOG("Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_first.txt").string().c_str()); throw std::runtime_error("Aborting initialization due to missing minifigure name file."); } std::istream fnStream = std::istream(&fnBuff); @@ -59,7 +59,7 @@ void UserManager::Initialize() { AssetMemoryBuffer mnBuff = Game::assetManager->GetFileAsBuffer("names/minifigname_middle.txt"); if (!mnBuff.m_Success) { - Game::logger->Log("UserManager", "Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_middle.txt").string().c_str()); + LOG("Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_middle.txt").string().c_str()); throw std::runtime_error("Aborting initialization due to missing minifigure name file."); } std::istream mnStream = std::istream(&mnBuff); @@ -72,7 +72,7 @@ void UserManager::Initialize() { AssetMemoryBuffer lnBuff = Game::assetManager->GetFileAsBuffer("names/minifigname_last.txt"); if (!lnBuff.m_Success) { - Game::logger->Log("UserManager", "Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_last.txt").string().c_str()); + LOG("Failed to load %s", (Game::assetManager->GetResPath() / "names/minifigname_last.txt").string().c_str()); throw std::runtime_error("Aborting initialization due to missing minifigure name file."); } std::istream lnStream = std::istream(&lnBuff); @@ -86,7 +86,7 @@ void UserManager::Initialize() { //Load our pre-approved names: AssetMemoryBuffer chatListBuff = Game::assetManager->GetFileAsBuffer("chatplus_en_us.txt"); if (!chatListBuff.m_Success) { - Game::logger->Log("UserManager", "Failed to load %s", (Game::assetManager->GetResPath() / "chatplus_en_us.txt").string().c_str()); + LOG("Failed to load %s", (Game::assetManager->GetResPath() / "chatplus_en_us.txt").string().c_str()); throw std::runtime_error("Aborting initialization due to missing chat whitelist file."); } std::istream chatListStream = std::istream(&chatListBuff); @@ -150,7 +150,7 @@ bool UserManager::DeleteUser(const SystemAddress& sysAddr) { void UserManager::DeletePendingRemovals() { for (auto* user : m_UsersToDelete) { - Game::logger->Log("UserManager", "Deleted user %i", user->GetAccountID()); + LOG("Deleted user %i", user->GetAccountID()); delete user; } @@ -271,21 +271,21 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) LOT pantsLOT = FindCharPantsID(pantsColor); if (name != "" && !UserManager::IsNameAvailable(name)) { - Game::logger->Log("UserManager", "AccountID: %i chose unavailable name: %s", u->GetAccountID(), name.c_str()); + LOG("AccountID: %i chose unavailable name: %s", u->GetAccountID(), name.c_str()); WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::CUSTOM_NAME_IN_USE); return; } if (!IsNameAvailable(predefinedName)) { - Game::logger->Log("UserManager", "AccountID: %i chose unavailable predefined name: %s", u->GetAccountID(), predefinedName.c_str()); + LOG("AccountID: %i chose unavailable predefined name: %s", u->GetAccountID(), predefinedName.c_str()); WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::PREDEFINED_NAME_IN_USE); return; } if (name == "") { - Game::logger->Log("UserManager", "AccountID: %i is creating a character with predefined name: %s", u->GetAccountID(), predefinedName.c_str()); + LOG("AccountID: %i is creating a character with predefined name: %s", u->GetAccountID(), predefinedName.c_str()); } else { - Game::logger->Log("UserManager", "AccountID: %i is creating a character with name: %s (temporary: %s)", u->GetAccountID(), name.c_str(), predefinedName.c_str()); + LOG("AccountID: %i is creating a character with name: %s (temporary: %s)", u->GetAccountID(), name.c_str(), predefinedName.c_str()); } //Now that the name is ok, we can get an objectID from Master: @@ -296,7 +296,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) auto* overlapResult = overlapStmt->executeQuery(); if (overlapResult->next()) { - Game::logger->Log("UserManager", "Character object id unavailable, check objectidtracker!"); + LOG("Character object id unavailable, check objectidtracker!"); WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::OBJECT_ID_UNAVAILABLE); return; } @@ -383,14 +383,14 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet) { User* u = GetUser(sysAddr); if (!u) { - Game::logger->Log("UserManager", "Couldn't get user to delete character"); + LOG("Couldn't get user to delete character"); return; } LWOOBJID objectID = PacketUtils::ReadS64(8, packet); uint32_t charID = static_cast(objectID); - Game::logger->Log("UserManager", "Received char delete req for ID: %llu (%u)", objectID, charID); + LOG("Received char delete req for ID: %llu (%u)", objectID, charID); bool hasCharacter = CheatDetection::VerifyLwoobjidIsSender( objectID, @@ -402,7 +402,7 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet) if (!hasCharacter) { WorldPackets::SendCharacterDeleteResponse(sysAddr, false); } else { - Game::logger->Log("UserManager", "Deleting character %i", charID); + LOG("Deleting character %i", charID); { sql::PreparedStatement* stmt = Database::CreatePreppedStmt("DELETE FROM charxml WHERE id=? LIMIT 1;"); stmt->setUInt64(1, charID); @@ -478,7 +478,7 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet) void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) { User* u = GetUser(sysAddr); if (!u) { - Game::logger->Log("UserManager", "Couldn't get user to delete character"); + LOG("Couldn't get user to delete character"); return; } @@ -487,7 +487,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) GeneralUtils::ClearBit(objectID, eObjectBits::PERSISTENT); uint32_t charID = static_cast(objectID); - Game::logger->Log("UserManager", "Received char rename request for ID: %llu (%u)", objectID, charID); + LOG("Received char rename request for ID: %llu (%u)", objectID, charID); std::string newName = PacketUtils::ReadString(16, packet, true); @@ -526,7 +526,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) stmt->execute(); delete stmt; - Game::logger->Log("UserManager", "Character %s now known as %s", character->GetName().c_str(), newName.c_str()); + LOG("Character %s now known as %s", character->GetName().c_str(), newName.c_str()); WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::SUCCESS); UserManager::RequestCharacterList(sysAddr); } else { @@ -537,7 +537,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) stmt->execute(); delete stmt; - Game::logger->Log("UserManager", "Character %s has been renamed to %s and is pending approval by a moderator.", character->GetName().c_str(), newName.c_str()); + LOG("Character %s has been renamed to %s and is pending approval by a moderator.", character->GetName().c_str(), newName.c_str()); WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::SUCCESS); UserManager::RequestCharacterList(sysAddr); } @@ -545,7 +545,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::NAME_IN_USE); } } else { - Game::logger->Log("UserManager", "Unknown error occurred when renaming character, either hasCharacter or character variable != true."); + LOG("Unknown error occurred when renaming character, either hasCharacter or character variable != true."); WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::UNKNOWN_ERROR); } } @@ -553,7 +553,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID) { User* u = GetUser(sysAddr); if (!u) { - Game::logger->Log("UserManager", "Couldn't get user to log in character"); + LOG("Couldn't get user to log in character"); return; } @@ -576,7 +576,7 @@ void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID if (zoneID == LWOZONEID_INVALID) zoneID = 1000; //Send char to VE ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneID, character->GetZoneClone(), false, [=](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) { - Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); + LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); if (character) { character->SetZoneID(zoneID); character->SetZoneInstance(zoneInstance); @@ -586,7 +586,7 @@ void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID return; }); } else { - Game::logger->Log("UserManager", "Unknown error occurred when logging in a character, either hasCharacter or character variable != true."); + LOG("Unknown error occurred when logging in a character, either hasCharacter or character variable != true."); } } @@ -601,7 +601,7 @@ uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) { tableData.finalize(); return shirtLOT; } catch (const std::exception&) { - Game::logger->Log("Character Create", "Failed to execute query! Using backup..."); + LOG("Failed to execute query! Using backup..."); // in case of no shirt found in CDServer, return problematic red vest. return 4069; } @@ -616,7 +616,7 @@ uint32_t FindCharPantsID(uint32_t pantsColor) { tableData.finalize(); return pantsLOT; } catch (const std::exception&) { - Game::logger->Log("Character Create", "Failed to execute query! Using backup..."); + LOG("Failed to execute query! Using backup..."); // in case of no pants color found in CDServer, return red pants. return 2508; } diff --git a/dGame/dBehaviors/AirMovementBehavior.cpp b/dGame/dBehaviors/AirMovementBehavior.cpp index a6d749d3..8a3f894c 100644 --- a/dGame/dBehaviors/AirMovementBehavior.cpp +++ b/dGame/dBehaviors/AirMovementBehavior.cpp @@ -3,13 +3,13 @@ #include "BehaviorContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { uint32_t handle{}; if (!bitStream->Read(handle)) { - Game::logger->Log("AirMovementBehavior", "Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; } @@ -26,14 +26,14 @@ void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitS uint32_t behaviorId{}; if (!bitStream->Read(behaviorId)) { - Game::logger->Log("AirMovementBehavior", "Unable to read behaviorId from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read behaviorId from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); return; } LWOOBJID target{}; if (!bitStream->Read(target)) { - Game::logger->Log("AirMovementBehavior", "Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); return; } diff --git a/dGame/dBehaviors/AndBehavior.cpp b/dGame/dBehaviors/AndBehavior.cpp index 67c88679..57493248 100644 --- a/dGame/dBehaviors/AndBehavior.cpp +++ b/dGame/dBehaviors/AndBehavior.cpp @@ -1,7 +1,7 @@ #include "AndBehavior.h" #include "BehaviorBranchContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { for (auto* behavior : this->m_behaviors) { diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.cpp b/dGame/dBehaviors/AreaOfEffectBehavior.cpp index aef73223..463cad8e 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.cpp +++ b/dGame/dBehaviors/AreaOfEffectBehavior.cpp @@ -4,19 +4,19 @@ #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "BehaviorBranchContext.h" #include "BehaviorContext.h" #include "RebuildComponent.h" #include "DestroyableComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { uint32_t targetCount{}; if (!bitStream->Read(targetCount)) { - Game::logger->Log("AreaOfEffectBehavior", "Unable to read targetCount from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read targetCount from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; } @@ -28,7 +28,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b } if (targetCount > this->m_maxTargets) { - Game::logger->Log("AreaOfEffectBehavior", "Serialized size is greater than max targets! Size: %i, Max: %i", targetCount, this->m_maxTargets); + LOG("Serialized size is greater than max targets! Size: %i, Max: %i", targetCount, this->m_maxTargets); return; } @@ -41,7 +41,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b for (auto i = 0u; i < targetCount; ++i) { LWOOBJID target{}; if (!bitStream->Read(target)) { - Game::logger->Log("AreaOfEffectBehavior", "failed to read in target %i from bitStream, aborting target Handle!", i); + LOG("failed to read in target %i from bitStream, aborting target Handle!", i); }; targets.push_back(target); } diff --git a/dGame/dBehaviors/AttackDelayBehavior.cpp b/dGame/dBehaviors/AttackDelayBehavior.cpp index 3f12f662..1bf1048a 100644 --- a/dGame/dBehaviors/AttackDelayBehavior.cpp +++ b/dGame/dBehaviors/AttackDelayBehavior.cpp @@ -2,13 +2,13 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { uint32_t handle{}; if (!bitStream->Read(handle)) { - Game::logger->Log("AttackDelayBehavior", "Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; diff --git a/dGame/dBehaviors/BasicAttackBehavior.cpp b/dGame/dBehaviors/BasicAttackBehavior.cpp index 0a21383b..2bd6ce41 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.cpp +++ b/dGame/dBehaviors/BasicAttackBehavior.cpp @@ -1,7 +1,7 @@ #include "BasicAttackBehavior.h" #include "BehaviorBranchContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "EntityManager.h" #include "DestroyableComponent.h" #include "BehaviorContext.h" @@ -26,10 +26,10 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi uint16_t allocatedBits{}; if (!bitStream->Read(allocatedBits) || allocatedBits == 0) { - Game::logger->LogDebug("BasicAttackBehavior", "No allocated bits"); + LOG_DEBUG("No allocated bits"); return; } - Game::logger->LogDebug("BasicAttackBehavior", "Number of allocated bits %i", allocatedBits); + LOG_DEBUG("Number of allocated bits %i", allocatedBits); const auto baseAddress = bitStream->GetReadOffset(); DoHandleBehavior(context, bitStream, branch); @@ -40,13 +40,13 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { auto* targetEntity = Game::entityManager->GetEntity(branch.target); if (!targetEntity) { - Game::logger->Log("BasicAttackBehavior", "Target targetEntity %llu not found.", branch.target); + LOG("Target targetEntity %llu not found.", branch.target); return; } auto* destroyableComponent = targetEntity->GetComponent(); if (!destroyableComponent) { - Game::logger->Log("BasicAttackBehavior", "No destroyable found on the obj/lot %llu/%i", branch.target, targetEntity->GetLOT()); + LOG("No destroyable found on the obj/lot %llu/%i", branch.target, targetEntity->GetLOT()); return; } @@ -55,7 +55,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit bool isSuccess{}; if (!bitStream->Read(isBlocked)) { - Game::logger->Log("BasicAttackBehavior", "Unable to read isBlocked"); + LOG("Unable to read isBlocked"); return; } @@ -67,7 +67,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit } if (!bitStream->Read(isImmune)) { - Game::logger->Log("BasicAttackBehavior", "Unable to read isImmune"); + LOG("Unable to read isImmune"); return; } @@ -77,20 +77,20 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit } if (!bitStream->Read(isSuccess)) { - Game::logger->Log("BasicAttackBehavior", "failed to read success from bitstream"); + LOG("failed to read success from bitstream"); return; } if (isSuccess) { uint32_t armorDamageDealt{}; if (!bitStream->Read(armorDamageDealt)) { - Game::logger->Log("BasicAttackBehavior", "Unable to read armorDamageDealt"); + LOG("Unable to read armorDamageDealt"); return; } uint32_t healthDamageDealt{}; if (!bitStream->Read(healthDamageDealt)) { - Game::logger->Log("BasicAttackBehavior", "Unable to read healthDamageDealt"); + LOG("Unable to read healthDamageDealt"); return; } @@ -103,7 +103,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit bool died{}; if (!bitStream->Read(died)) { - Game::logger->Log("BasicAttackBehavior", "Unable to read died"); + LOG("Unable to read died"); return; } auto previousArmor = destroyableComponent->GetArmor(); @@ -114,7 +114,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit uint8_t successState{}; if (!bitStream->Read(successState)) { - Game::logger->Log("BasicAttackBehavior", "Unable to read success state"); + LOG("Unable to read success state"); return; } @@ -127,7 +127,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit break; default: if (static_cast(successState) != eBasicAttackSuccessTypes::FAILIMMUNE) { - Game::logger->Log("BasicAttackBehavior", "Unknown success state (%i)!", successState); + LOG("Unknown success state (%i)!", successState); return; } this->m_OnFailImmune->Handle(context, bitStream, branch); @@ -157,13 +157,13 @@ void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { auto* targetEntity = Game::entityManager->GetEntity(branch.target); if (!targetEntity) { - Game::logger->Log("BasicAttackBehavior", "Target entity %llu is null!", branch.target); + LOG("Target entity %llu is null!", branch.target); return; } auto* destroyableComponent = targetEntity->GetComponent(); if (!destroyableComponent || !destroyableComponent->GetParent()) { - Game::logger->Log("BasicAttackBehavior", "No destroyable component on %llu", branch.target); + LOG("No destroyable component on %llu", branch.target); return; } @@ -227,7 +227,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet break; default: if (static_cast(successState) != eBasicAttackSuccessTypes::FAILIMMUNE) { - Game::logger->Log("BasicAttackBehavior", "Unknown success state (%i)!", successState); + LOG("Unknown success state (%i)!", successState); break; } this->m_OnFailImmune->Calculate(context, bitStream, branch); diff --git a/dGame/dBehaviors/Behavior.cpp b/dGame/dBehaviors/Behavior.cpp index a51ad545..26c284bf 100644 --- a/dGame/dBehaviors/Behavior.cpp +++ b/dGame/dBehaviors/Behavior.cpp @@ -4,7 +4,7 @@ #include "Behavior.h" #include "CDActivitiesTable.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "BehaviorTemplates.h" #include "BehaviorBranchContext.h" #include @@ -278,12 +278,12 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) { case BehaviorTemplates::BEHAVIOR_MOUNT: break; case BehaviorTemplates::BEHAVIOR_SKILL_SET: break; default: - //Game::logger->Log("Behavior", "Failed to load behavior with invalid template id (%i)!", templateId); + //LOG("Failed to load behavior with invalid template id (%i)!", templateId); break; } if (behavior == nullptr) { - //Game::logger->Log("Behavior", "Failed to load unimplemented template id (%i)!", templateId); + //LOG("Failed to load unimplemented template id (%i)!", templateId); behavior = new EmptyBehavior(behaviorId); } @@ -306,7 +306,7 @@ BehaviorTemplates Behavior::GetBehaviorTemplate(const uint32_t behaviorId) { } if (templateID == BehaviorTemplates::BEHAVIOR_EMPTY && behaviorId != 0) { - Game::logger->Log("Behavior", "Failed to load behavior template with id (%i)!", behaviorId); + LOG("Failed to load behavior template with id (%i)!", behaviorId); } return templateID; @@ -426,7 +426,7 @@ Behavior::Behavior(const uint32_t behaviorId) { // Make sure we do not proceed if we are trying to load an invalid behavior if (templateInDatabase.behaviorID == 0) { - Game::logger->Log("Behavior", "Failed to load behavior with id (%i)!", behaviorId); + LOG("Failed to load behavior with id (%i)!", behaviorId); this->m_effectId = 0; this->m_effectHandle = nullptr; diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index 4357548a..d23ee596 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -4,7 +4,7 @@ #include "EntityManager.h" #include "SkillComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "dServer.h" #include "BitStreamUtils.h" @@ -31,7 +31,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const { auto* entity = Game::entityManager->GetEntity(this->originator); if (entity == nullptr) { - Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator); + LOG("Invalid entity for (%llu)!", this->originator); return 0; } @@ -39,7 +39,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const { auto* component = entity->GetComponent(); if (component == nullptr) { - Game::logger->Log("BehaviorContext", "No skill component attached to (%llu)!", this->originator);; + LOG("No skill component attached to (%llu)!", this->originator);; return 0; } @@ -126,7 +126,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit } if (!found) { - Game::logger->Log("BehaviorContext", "Failed to find behavior sync entry with sync id (%i)!", syncId); + LOG("Failed to find behavior sync entry with sync id (%i)!", syncId); return; } @@ -135,7 +135,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit const auto branch = entry.branchContext; if (behavior == nullptr) { - Game::logger->Log("BehaviorContext", "Invalid behavior for sync id (%i)!", syncId); + LOG("Invalid behavior for sync id (%i)!", syncId); return; } @@ -319,7 +319,7 @@ void BehaviorContext::FilterTargets(std::vector& targets, std::forward_ // if the caster is not there, return empty targets list auto* caster = Game::entityManager->GetEntity(this->caster); if (!caster) { - Game::logger->LogDebug("BehaviorContext", "Invalid caster for (%llu)!", this->originator); + LOG_DEBUG("Invalid caster for (%llu)!", this->originator); targets.clear(); return; } diff --git a/dGame/dBehaviors/BlockBehavior.cpp b/dGame/dBehaviors/BlockBehavior.cpp index 19db0267..88c6bb0b 100644 --- a/dGame/dBehaviors/BlockBehavior.cpp +++ b/dGame/dBehaviors/BlockBehavior.cpp @@ -4,7 +4,7 @@ #include "BehaviorBranchContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "DestroyableComponent.h" void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { @@ -13,7 +13,7 @@ void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea auto* entity = Game::entityManager->GetEntity(target); if (entity == nullptr) { - Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } @@ -43,7 +43,7 @@ void BlockBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branc auto* entity = Game::entityManager->GetEntity(target); if (entity == nullptr) { - Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } diff --git a/dGame/dBehaviors/BuffBehavior.cpp b/dGame/dBehaviors/BuffBehavior.cpp index 2c06dbd4..7ac8b352 100644 --- a/dGame/dBehaviors/BuffBehavior.cpp +++ b/dGame/dBehaviors/BuffBehavior.cpp @@ -4,7 +4,7 @@ #include "BehaviorBranchContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "DestroyableComponent.h" void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { @@ -13,7 +13,7 @@ void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream auto* entity = Game::entityManager->GetEntity(target); if (entity == nullptr) { - Game::logger->Log("BuffBehavior", "Invalid target (%llu)!", target); + LOG("Invalid target (%llu)!", target); return; } @@ -21,7 +21,7 @@ void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream auto* component = entity->GetComponent(); if (component == nullptr) { - Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target); + LOG("Invalid target, no destroyable component (%llu)!", target); return; } @@ -47,7 +47,7 @@ void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch auto* entity = Game::entityManager->GetEntity(target); if (entity == nullptr) { - Game::logger->Log("BuffBehavior", "Invalid target (%llu)!", target); + LOG("Invalid target (%llu)!", target); return; } @@ -55,7 +55,7 @@ void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch auto* component = entity->GetComponent(); if (component == nullptr) { - Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target); + LOG("Invalid target, no destroyable component (%llu)!", target); return; } diff --git a/dGame/dBehaviors/CarBoostBehavior.cpp b/dGame/dBehaviors/CarBoostBehavior.cpp index e2929863..eb22cb09 100644 --- a/dGame/dBehaviors/CarBoostBehavior.cpp +++ b/dGame/dBehaviors/CarBoostBehavior.cpp @@ -5,7 +5,7 @@ #include "BehaviorContext.h" #include "CharacterComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "PossessableComponent.h" void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { @@ -17,7 +17,7 @@ void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt return; } - Game::logger->Log("Car boost", "Activating car boost!"); + LOG("Activating car boost!"); auto* possessableComponent = entity->GetComponent(); if (possessableComponent != nullptr) { @@ -27,7 +27,7 @@ void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt auto* characterComponent = possessor->GetComponent(); if (characterComponent != nullptr) { - Game::logger->Log("Car boost", "Tracking car boost!"); + LOG("Tracking car boost!"); characterComponent->UpdatePlayerStatistic(RacingCarBoostsActivated); } } diff --git a/dGame/dBehaviors/ChainBehavior.cpp b/dGame/dBehaviors/ChainBehavior.cpp index ec0f8969..4a20c151 100644 --- a/dGame/dBehaviors/ChainBehavior.cpp +++ b/dGame/dBehaviors/ChainBehavior.cpp @@ -1,13 +1,13 @@ #include "ChainBehavior.h" #include "BehaviorBranchContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { uint32_t chainIndex{}; if (!bitStream->Read(chainIndex)) { - Game::logger->Log("ChainBehavior", "Unable to read chainIndex from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read chainIndex from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; } @@ -16,7 +16,7 @@ void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea if (chainIndex < this->m_behaviors.size()) { this->m_behaviors.at(chainIndex)->Handle(context, bitStream, branch); } else { - Game::logger->Log("ChainBehavior", "chainIndex out of bounds, aborting handle of chain %i bits unread %i", chainIndex, bitStream->GetNumberOfUnreadBits()); + LOG("chainIndex out of bounds, aborting handle of chain %i bits unread %i", chainIndex, bitStream->GetNumberOfUnreadBits()); } } diff --git a/dGame/dBehaviors/ChargeUpBehavior.cpp b/dGame/dBehaviors/ChargeUpBehavior.cpp index 4c7c3dac..cf737e19 100644 --- a/dGame/dBehaviors/ChargeUpBehavior.cpp +++ b/dGame/dBehaviors/ChargeUpBehavior.cpp @@ -2,13 +2,13 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { uint32_t handle{}; if (!bitStream->Read(handle)) { - Game::logger->Log("ChargeUpBehavior", "Unable to read handle from bitStream, aborting Handle! variable_type"); + LOG("Unable to read handle from bitStream, aborting Handle! variable_type"); return; }; diff --git a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp index f9936767..880550e3 100644 --- a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp +++ b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp @@ -4,14 +4,14 @@ #include "BehaviorContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "DestroyableComponent.h" void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { - Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } @@ -37,7 +37,7 @@ void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchCon auto* target = Game::entityManager->GetEntity(second); if (target == nullptr) { - Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", second); + LOG("Failed to find target (%llu)!", second); return; } diff --git a/dGame/dBehaviors/DamageReductionBehavior.cpp b/dGame/dBehaviors/DamageReductionBehavior.cpp index 7645ec7b..bf32360e 100644 --- a/dGame/dBehaviors/DamageReductionBehavior.cpp +++ b/dGame/dBehaviors/DamageReductionBehavior.cpp @@ -4,14 +4,14 @@ #include "BehaviorContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "DestroyableComponent.h" void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { - Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } @@ -35,7 +35,7 @@ void DamageReductionBehavior::Timer(BehaviorContext* context, BehaviorBranchCont auto* target = Game::entityManager->GetEntity(second); if (target == nullptr) { - Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!", second); + LOG("Failed to find target (%llu)!", second); return; } diff --git a/dGame/dBehaviors/DarkInspirationBehavior.cpp b/dGame/dBehaviors/DarkInspirationBehavior.cpp index 4e9890e3..27a7c634 100644 --- a/dGame/dBehaviors/DarkInspirationBehavior.cpp +++ b/dGame/dBehaviors/DarkInspirationBehavior.cpp @@ -10,7 +10,7 @@ void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { - Game::logger->LogDebug("DarkInspirationBehavior", "Failed to find target (%llu)!", branch.target); + LOG_DEBUG("Failed to find target (%llu)!", branch.target); return; } @@ -29,7 +29,7 @@ void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStr auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { - Game::logger->LogDebug("DarkInspirationBehavior", "Failed to find target (%llu)!", branch.target); + LOG_DEBUG("Failed to find target (%llu)!", branch.target); return; } diff --git a/dGame/dBehaviors/ForceMovementBehavior.cpp b/dGame/dBehaviors/ForceMovementBehavior.cpp index 97208236..2ba3f2e1 100644 --- a/dGame/dBehaviors/ForceMovementBehavior.cpp +++ b/dGame/dBehaviors/ForceMovementBehavior.cpp @@ -4,7 +4,7 @@ #include "ControllablePhysicsComponent.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) { @@ -13,7 +13,7 @@ void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* uint32_t handle{}; if (!bitStream->Read(handle)) { - Game::logger->Log("ForceMovementBehavior", "Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; } context->RegisterSyncBehavior(handle, this, branch, this->m_Duration); @@ -22,13 +22,13 @@ void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { uint32_t next{}; if (!bitStream->Read(next)) { - Game::logger->Log("ForceMovementBehavior", "Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); return; } LWOOBJID target{}; if (!bitStream->Read(target)) { - Game::logger->Log("ForceMovementBehavior", "Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); return; } diff --git a/dGame/dBehaviors/HealBehavior.cpp b/dGame/dBehaviors/HealBehavior.cpp index dae009d4..3eb4928c 100644 --- a/dGame/dBehaviors/HealBehavior.cpp +++ b/dGame/dBehaviors/HealBehavior.cpp @@ -1,7 +1,7 @@ #include "HealBehavior.h" #include "BehaviorBranchContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "EntityManager.h" #include "DestroyableComponent.h" #include "eReplicaComponentType.h" @@ -11,7 +11,7 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea auto* entity = Game::entityManager->GetEntity(branch.target); if (entity == nullptr) { - Game::logger->Log("HealBehavior", "Failed to find entity for (%llu)!", branch.target); + LOG("Failed to find entity for (%llu)!", branch.target); return; } @@ -19,7 +19,7 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea auto* destroyable = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); if (destroyable == nullptr) { - Game::logger->Log("HealBehavior", "Failed to find destroyable component for %(llu)!", branch.target); + LOG("Failed to find destroyable component for %(llu)!", branch.target); return; } diff --git a/dGame/dBehaviors/ImaginationBehavior.cpp b/dGame/dBehaviors/ImaginationBehavior.cpp index 50f7e046..c57fd0c7 100644 --- a/dGame/dBehaviors/ImaginationBehavior.cpp +++ b/dGame/dBehaviors/ImaginationBehavior.cpp @@ -3,7 +3,7 @@ #include "DestroyableComponent.h" #include "dpWorld.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { diff --git a/dGame/dBehaviors/ImmunityBehavior.cpp b/dGame/dBehaviors/ImmunityBehavior.cpp index ba4a8b77..9824c479 100644 --- a/dGame/dBehaviors/ImmunityBehavior.cpp +++ b/dGame/dBehaviors/ImmunityBehavior.cpp @@ -4,7 +4,7 @@ #include "BehaviorContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "DestroyableComponent.h" #include "ControllablePhysicsComponent.h" #include "eStateChangeType.h" @@ -13,7 +13,7 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt auto* target = Game::entityManager->GetEntity(branch.target); if (!target) { - Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } @@ -59,7 +59,7 @@ void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext bra auto* target = Game::entityManager->GetEntity(second); if (!target) { - Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", second); + LOG("Failed to find target (%llu)!", second); return; } diff --git a/dGame/dBehaviors/InterruptBehavior.cpp b/dGame/dBehaviors/InterruptBehavior.cpp index ffe3bb8b..bd3f0c4a 100644 --- a/dGame/dBehaviors/InterruptBehavior.cpp +++ b/dGame/dBehaviors/InterruptBehavior.cpp @@ -2,7 +2,7 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "EntityManager.h" #include "SkillComponent.h" @@ -12,7 +12,7 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS bool unknown = false; if (!bitStream->Read(unknown)) { - Game::logger->Log("InterruptBehavior", "Unable to read unknown1 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read unknown1 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; @@ -23,7 +23,7 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS bool unknown = false; if (!bitStream->Read(unknown)) { - Game::logger->Log("InterruptBehavior", "Unable to read unknown2 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read unknown2 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; @@ -35,7 +35,7 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS bool unknown = false; if (!bitStream->Read(unknown)) { - Game::logger->Log("InterruptBehavior", "Unable to read unknown3 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read unknown3 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; } diff --git a/dGame/dBehaviors/KnockbackBehavior.cpp b/dGame/dBehaviors/KnockbackBehavior.cpp index d67ebbc8..d0f86597 100644 --- a/dGame/dBehaviors/KnockbackBehavior.cpp +++ b/dGame/dBehaviors/KnockbackBehavior.cpp @@ -7,13 +7,13 @@ #include "GameMessages.h" #include "DestroyableComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void KnockbackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { bool unknown{}; if (!bitStream->Read(unknown)) { - Game::logger->Log("KnockbackBehavior", "Unable to read unknown from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read unknown from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; } diff --git a/dGame/dBehaviors/MovementSwitchBehavior.cpp b/dGame/dBehaviors/MovementSwitchBehavior.cpp index 0c11380f..cddeeea9 100644 --- a/dGame/dBehaviors/MovementSwitchBehavior.cpp +++ b/dGame/dBehaviors/MovementSwitchBehavior.cpp @@ -1,7 +1,7 @@ #include "MovementSwitchBehavior.h" #include "BehaviorBranchContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { uint32_t movementType{}; @@ -15,7 +15,7 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* this->m_movingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) { return; } - Game::logger->Log("MovementSwitchBehavior", "Unable to read movementType from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read movementType from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; diff --git a/dGame/dBehaviors/OverTimeBehavior.cpp b/dGame/dBehaviors/OverTimeBehavior.cpp index 49077f0f..bdef2eb6 100644 --- a/dGame/dBehaviors/OverTimeBehavior.cpp +++ b/dGame/dBehaviors/OverTimeBehavior.cpp @@ -2,7 +2,7 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "EntityManager.h" #include "SkillComponent.h" #include "DestroyableComponent.h" diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.cpp b/dGame/dBehaviors/ProjectileAttackBehavior.cpp index eb435d7c..c63a3d6f 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.cpp +++ b/dGame/dBehaviors/ProjectileAttackBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "SkillComponent.h" #include "../dWorldServer/ObjectIDManager.h" #include "eObjectBits.h" @@ -12,14 +12,14 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea LWOOBJID target{}; if (!bitStream->Read(target)) { - Game::logger->Log("ProjectileAttackBehavior", "Unable to read target from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read target from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; auto* entity = Game::entityManager->GetEntity(context->originator); if (entity == nullptr) { - Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!", context->originator); + LOG("Failed to find originator (%llu)!", context->originator); return; } @@ -27,7 +27,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea auto* skillComponent = entity->GetComponent(); if (skillComponent == nullptr) { - Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", -context->originator); + LOG("Failed to find skill component for (%llu)!", -context->originator); return; } @@ -35,7 +35,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea if (m_useMouseposit && !branch.isSync) { NiPoint3 targetPosition = NiPoint3::ZERO; if (!bitStream->Read(targetPosition)) { - Game::logger->Log("ProjectileAttackBehavior", "Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; } @@ -46,7 +46,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea LWOOBJID projectileId{}; if (!bitStream->Read(projectileId)) { - Game::logger->Log("ProjectileAttackBehavior", "Unable to read projectileId from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read projectileId from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; @@ -64,7 +64,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt auto* entity = Game::entityManager->GetEntity(context->originator); if (entity == nullptr) { - Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!", context->originator); + LOG("Failed to find originator (%llu)!", context->originator); return; } @@ -72,7 +72,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt auto* skillComponent = entity->GetComponent(); if (skillComponent == nullptr) { - Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", context->originator); + LOG("Failed to find skill component for (%llu)!", context->originator); return; @@ -81,7 +81,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt auto* other = Game::entityManager->GetEntity(branch.target); if (other == nullptr) { - Game::logger->Log("ProjectileAttackBehavior", "Invalid projectile target (%llu)!", branch.target); + LOG("Invalid projectile target (%llu)!", branch.target); return; } diff --git a/dGame/dBehaviors/PropertyTeleportBehavior.cpp b/dGame/dBehaviors/PropertyTeleportBehavior.cpp index 309fc929..939568f6 100644 --- a/dGame/dBehaviors/PropertyTeleportBehavior.cpp +++ b/dGame/dBehaviors/PropertyTeleportBehavior.cpp @@ -40,7 +40,7 @@ void PropertyTeleportBehavior::Handle(BehaviorContext* context, RakNet::BitStrea if (zoneClone != 0) ChatPackets::SendSystemMessage(sysAddr, u"Transfering to your property!"); else ChatPackets::SendSystemMessage(sysAddr, u"Transfering back to previous world!"); - Game::logger->Log("PropertyTeleportBehavior", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); + LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); if (entity->GetCharacter()) { entity->GetCharacter()->SetZoneID(zoneID); entity->GetCharacter()->SetZoneInstance(zoneInstance); diff --git a/dGame/dBehaviors/RepairBehavior.cpp b/dGame/dBehaviors/RepairBehavior.cpp index d2967921..d0ce3fe8 100644 --- a/dGame/dBehaviors/RepairBehavior.cpp +++ b/dGame/dBehaviors/RepairBehavior.cpp @@ -3,7 +3,7 @@ #include "DestroyableComponent.h" #include "dpWorld.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" #include "Game.h" #include "eReplicaComponentType.h" @@ -11,7 +11,7 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str auto* entity = Game::entityManager->GetEntity(branch.target); if (entity == nullptr) { - Game::logger->Log("RepairBehavior", "Failed to find entity for (%llu)!", branch.target); + LOG("Failed to find entity for (%llu)!", branch.target); return; } @@ -19,7 +19,7 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str auto* destroyable = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); if (destroyable == nullptr) { - Game::logger->Log("RepairBehavior", "Failed to find destroyable component for %(llu)!", branch.target); + LOG("Failed to find destroyable component for %(llu)!", branch.target); return; } diff --git a/dGame/dBehaviors/SpawnBehavior.cpp b/dGame/dBehaviors/SpawnBehavior.cpp index 2803251a..96430766 100644 --- a/dGame/dBehaviors/SpawnBehavior.cpp +++ b/dGame/dBehaviors/SpawnBehavior.cpp @@ -4,7 +4,7 @@ #include "BehaviorBranchContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "DestroyableComponent.h" #include "RebuildComponent.h" #include "Entity.h" @@ -15,7 +15,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea auto* origin = Game::entityManager->GetEntity(context->originator); if (origin == nullptr) { - Game::logger->Log("SpawnBehavior", "Failed to find self entity (%llu)!", context->originator); + LOG("Failed to find self entity (%llu)!", context->originator); return; } @@ -45,7 +45,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea ); if (entity == nullptr) { - Game::logger->Log("SpawnBehavior", "Failed to spawn entity (%i)!", this->m_lot); + LOG("Failed to spawn entity (%i)!", this->m_lot); return; } @@ -82,7 +82,7 @@ void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext auto* entity = Game::entityManager->GetEntity(second); if (entity == nullptr) { - Game::logger->Log("SpawnBehavior", "Failed to find spawned entity (%llu)!", second); + LOG("Failed to find spawned entity (%llu)!", second); return; } diff --git a/dGame/dBehaviors/SpeedBehavior.cpp b/dGame/dBehaviors/SpeedBehavior.cpp index 5dbad8ec..f21fda7e 100644 --- a/dGame/dBehaviors/SpeedBehavior.cpp +++ b/dGame/dBehaviors/SpeedBehavior.cpp @@ -3,7 +3,7 @@ #include "ControllablePhysicsComponent.h" #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -#include "dLogger.h" +#include "Logger.h" void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { diff --git a/dGame/dBehaviors/StunBehavior.cpp b/dGame/dBehaviors/StunBehavior.cpp index 8e160338..02144f69 100644 --- a/dGame/dBehaviors/StunBehavior.cpp +++ b/dGame/dBehaviors/StunBehavior.cpp @@ -5,7 +5,7 @@ #include "BehaviorContext.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "DestroyableComponent.h" #include "eReplicaComponentType.h" @@ -17,14 +17,14 @@ void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream bool blocked{}; if (!bitStream->Read(blocked)) { - Game::logger->Log("StunBehavior", "Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { - Game::logger->Log("StunBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } @@ -47,7 +47,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr auto* self = Game::entityManager->GetEntity(context->originator); if (self == nullptr) { - Game::logger->Log("StunBehavior", "Invalid self entity (%llu)!", context->originator); + LOG("Invalid self entity (%llu)!", context->originator); return; } @@ -82,7 +82,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr bitStream->Write(blocked); if (target == nullptr) { - Game::logger->Log("StunBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } diff --git a/dGame/dBehaviors/SwitchBehavior.cpp b/dGame/dBehaviors/SwitchBehavior.cpp index d65191d2..db04650d 100644 --- a/dGame/dBehaviors/SwitchBehavior.cpp +++ b/dGame/dBehaviors/SwitchBehavior.cpp @@ -1,7 +1,7 @@ #include "SwitchBehavior.h" #include "BehaviorBranchContext.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" #include "DestroyableComponent.h" #include "BehaviorContext.h" #include "BuffComponent.h" @@ -11,7 +11,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre if (this->m_imagination > 0 || !this->m_isEnemyFaction) { if (!bitStream->Read(state)) { - Game::logger->Log("SwitchBehavior", "Unable to read state from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read state from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; } @@ -28,7 +28,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre return; } - Game::logger->LogDebug("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination()); + LOG_DEBUG("[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination()); if (state) { this->m_actionTrue->Handle(context, bitStream, branch); diff --git a/dGame/dBehaviors/SwitchMultipleBehavior.cpp b/dGame/dBehaviors/SwitchMultipleBehavior.cpp index 23411429..947c331f 100644 --- a/dGame/dBehaviors/SwitchMultipleBehavior.cpp +++ b/dGame/dBehaviors/SwitchMultipleBehavior.cpp @@ -5,7 +5,7 @@ #include "BehaviorBranchContext.h" #include "CDActivitiesTable.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "EntityManager.h" @@ -13,7 +13,7 @@ void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream* float value{}; if (!bitStream->Read(value)) { - Game::logger->Log("SwitchMultipleBehavior", "Unable to read value from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read value from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; diff --git a/dGame/dBehaviors/TacArcBehavior.cpp b/dGame/dBehaviors/TacArcBehavior.cpp index 7629c377..29cee327 100644 --- a/dGame/dBehaviors/TacArcBehavior.cpp +++ b/dGame/dBehaviors/TacArcBehavior.cpp @@ -1,7 +1,7 @@ #include "TacArcBehavior.h" #include "BehaviorBranchContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "Entity.h" #include "BehaviorContext.h" #include "BaseCombatAIComponent.h" @@ -16,7 +16,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre if (this->m_usePickedTarget && branch.target != LWOOBJID_EMPTY) { auto target = Game::entityManager->GetEntity(branch.target); - if (!target) Game::logger->Log("TacArcBehavior", "target %llu is null", branch.target); + if (!target) LOG("target %llu is null", branch.target); else { targets.push_back(target); context->FilterTargets(targets, this->m_ignoreFactionList, this->m_includeFactionList, this->m_targetSelf, this->m_targetEnemy, this->m_targetFriend, this->m_targetTeam); @@ -29,7 +29,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre bool hasTargets = false; if (!bitStream->Read(hasTargets)) { - Game::logger->Log("TacArcBehavior", "Unable to read hasTargets from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read hasTargets from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; @@ -37,7 +37,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre bool blocked = false; if (!bitStream->Read(blocked)) { - Game::logger->Log("TacArcBehavior", "Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; @@ -50,12 +50,12 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre if (hasTargets) { uint32_t count = 0; if (!bitStream->Read(count)) { - Game::logger->Log("TacArcBehavior", "Unable to read count from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read count from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; if (count > m_maxTargets) { - Game::logger->Log("TacArcBehavior", "Bitstream has too many targets Max:%i Recv:%i", this->m_maxTargets, count); + LOG("Bitstream has too many targets Max:%i Recv:%i", this->m_maxTargets, count); return; } @@ -63,7 +63,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre LWOOBJID id{}; if (!bitStream->Read(id)) { - Game::logger->Log("TacArcBehavior", "Unable to read id from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read id from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; }; @@ -71,7 +71,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre auto* canidate = Game::entityManager->GetEntity(id); if (canidate) targets.push_back(canidate); } else { - Game::logger->Log("TacArcBehavior", "Bitstream has LWOOBJID_EMPTY as a target!"); + LOG("Bitstream has LWOOBJID_EMPTY as a target!"); } } @@ -85,7 +85,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { auto* self = Game::entityManager->GetEntity(context->originator); if (self == nullptr) { - Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!", context->originator); + LOG("Invalid self for (%llu)!", context->originator); return; } diff --git a/dGame/dBehaviors/TauntBehavior.cpp b/dGame/dBehaviors/TauntBehavior.cpp index b86cd7b5..2e9f2168 100644 --- a/dGame/dBehaviors/TauntBehavior.cpp +++ b/dGame/dBehaviors/TauntBehavior.cpp @@ -3,14 +3,14 @@ #include "BehaviorContext.h" #include "BaseCombatAIComponent.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { - Game::logger->Log("TauntBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } @@ -26,7 +26,7 @@ void TauntBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitSt auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { - Game::logger->Log("TauntBehavior", "Failed to find target (%llu)!", branch.target); + LOG("Failed to find target (%llu)!", branch.target); return; } diff --git a/dGame/dBehaviors/VerifyBehavior.cpp b/dGame/dBehaviors/VerifyBehavior.cpp index 6824a25f..2056f146 100644 --- a/dGame/dBehaviors/VerifyBehavior.cpp +++ b/dGame/dBehaviors/VerifyBehavior.cpp @@ -4,7 +4,7 @@ #include "NiPoint3.h" #include "BehaviorContext.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { @@ -18,7 +18,7 @@ void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS auto* self = Game::entityManager->GetEntity(context->originator); if (self == nullptr) { - Game::logger->Log("VerifyBehavior", "Invalid self for (%llu)", context->originator); + LOG("Invalid self for (%llu)", context->originator); return; } diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index 3afd3cc9..1961e6d6 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -540,7 +540,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const { auto* entity = Game::entityManager->GetEntity(target); if (entity == nullptr) { - Game::logger->Log("BaseCombatAIComponent", "Invalid entity for checking validity (%llu)!", target); + LOG("Invalid entity for checking validity (%llu)!", target); return false; } @@ -554,7 +554,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const { auto* referenceDestroyable = m_Parent->GetComponent(); if (referenceDestroyable == nullptr) { - Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_Parent->GetObjectID()); + LOG("Invalid reference destroyable component on (%llu)!", m_Parent->GetObjectID()); return false; } diff --git a/dGame/dComponents/BouncerComponent.cpp b/dGame/dComponents/BouncerComponent.cpp index a9a278e8..56002ac4 100644 --- a/dGame/dComponents/BouncerComponent.cpp +++ b/dGame/dComponents/BouncerComponent.cpp @@ -4,7 +4,7 @@ #include "dZoneManager.h" #include "SwitchComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "GameMessages.h" #include #include "eTriggerEventType.h" @@ -81,13 +81,13 @@ void BouncerComponent::LookupPetSwitch() { Game::entityManager->SerializeEntity(m_Parent); - Game::logger->Log("BouncerComponent", "Loaded pet bouncer"); + LOG("Loaded pet bouncer"); } } } if (!m_PetSwitchLoaded) { - Game::logger->Log("BouncerComponent", "Failed to load pet bouncer"); + LOG("Failed to load pet bouncer"); m_Parent->AddCallbackTimer(0.5f, [this]() { LookupPetSwitch(); diff --git a/dGame/dComponents/BuffComponent.cpp b/dGame/dComponents/BuffComponent.cpp index 56480438..24124f6e 100644 --- a/dGame/dComponents/BuffComponent.cpp +++ b/dGame/dComponents/BuffComponent.cpp @@ -4,7 +4,7 @@ #include #include "DestroyableComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "GameMessages.h" #include "SkillComponent.h" #include "ControllablePhysicsComponent.h" @@ -334,7 +334,7 @@ const std::vector& BuffComponent::GetBuffParameters(int32_t buffI param.values.push_back(value); } catch (std::invalid_argument& exception) { - Game::logger->Log("BuffComponent", "Failed to parse value (%s): (%s)!", token.c_str(), exception.what()); + LOG("Failed to parse value (%s): (%s)!", token.c_str(), exception.what()); } } } diff --git a/dGame/dComponents/BuildBorderComponent.cpp b/dGame/dComponents/BuildBorderComponent.cpp index af31f939..9e392e69 100644 --- a/dGame/dComponents/BuildBorderComponent.cpp +++ b/dGame/dComponents/BuildBorderComponent.cpp @@ -4,7 +4,7 @@ #include "GameMessages.h" #include "Entity.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "InventoryComponent.h" #include "Item.h" #include "PropertyManagementComponent.h" @@ -24,7 +24,7 @@ void BuildBorderComponent::OnUse(Entity* originator) { if (!entities.empty()) { buildArea = entities[0]->GetObjectID(); - Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque"); + LOG("Using PropertyPlaque"); } auto* inventoryComponent = originator->GetComponent(); @@ -41,7 +41,7 @@ void BuildBorderComponent::OnUse(Entity* originator) { inventoryComponent->PushEquippedItems(); - Game::logger->Log("BuildBorderComponent", "Starting with %llu", buildArea); + LOG("Starting with %llu", buildArea); if (PropertyManagementComponent::Instance() != nullptr) { GameMessages::SendStartArrangingWithItem( diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index d5632989..7a30d821 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -2,7 +2,7 @@ #include #include "tinyxml2.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "GeneralUtils.h" #include "dServer.h" #include "dZoneManager.h" @@ -16,6 +16,7 @@ #include "Amf3.h" #include "eGameMasterLevel.h" #include "eGameActivity.h" +#include CharacterComponent::CharacterComponent(Entity* parent, Character* character) : Component(parent) { m_Character = character; @@ -178,7 +179,7 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); if (!character) { - Game::logger->Log("CharacterComponent", "Failed to find char tag while loading XML!"); + LOG("Failed to find char tag while loading XML!"); return; } if (character->QueryAttribute("rpt", &m_Reputation) == tinyxml2::XML_NO_ATTRIBUTE) { @@ -283,7 +284,7 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* minifig = doc->FirstChildElement("obj")->FirstChildElement("mf"); if (!minifig) { - Game::logger->Log("CharacterComponent", "Failed to find mf tag while updating XML!"); + LOG("Failed to find mf tag while updating XML!"); return; } @@ -303,7 +304,7 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); if (!character) { - Game::logger->Log("CharacterComponent", "Failed to find char tag while updating XML!"); + LOG("Failed to find char tag while updating XML!"); return; } @@ -351,7 +352,7 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) { // auto newUpdateTimestamp = std::time(nullptr); - Game::logger->Log("TotalTimePlayed", "Time since last save: %d", newUpdateTimestamp - m_LastUpdateTimestamp); + LOG("Time since last save: %d", newUpdateTimestamp - m_LastUpdateTimestamp); m_TotalTimePlayed += newUpdateTimestamp - m_LastUpdateTimestamp; character->SetAttribute("time", m_TotalTimePlayed); @@ -381,7 +382,7 @@ Item* CharacterComponent::GetRocket(Entity* player) { } if (!rocket) { - Game::logger->Log("CharacterComponent", "Unable to find rocket to equip!"); + LOG("Unable to find rocket to equip!"); return rocket; } return rocket; diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index fe3c1248..08281ed5 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -1,7 +1,7 @@ #include "ControllablePhysicsComponent.h" #include "Entity.h" #include "BitStream.h" -#include "dLogger.h" +#include "Logger.h" #include "Game.h" #include "dpWorld.h" @@ -52,7 +52,7 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Phy return; if (entity->GetLOT() == 1) { - Game::logger->Log("ControllablePhysicsComponent", "Using patch to load minifig physics"); + LOG("Using patch to load minifig physics"); float radius = 1.5f; m_dpEntity = new dpEntity(m_Parent->GetObjectID(), radius, false); @@ -161,7 +161,7 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); if (!character) { - Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag!"); + LOG("Failed to find char tag!"); return; } @@ -181,7 +181,7 @@ void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); if (!character) { - Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag while updating XML!"); + LOG("Failed to find char tag while updating XML!"); return; } @@ -268,7 +268,7 @@ void ControllablePhysicsComponent::RemovePickupRadiusScale(float value) { if (pos != m_ActivePickupRadiusScales.end()) { m_ActivePickupRadiusScales.erase(pos); } else { - Game::logger->LogDebug("ControllablePhysicsComponent", "Warning: Could not find pickup radius %f in list of active radii. List has %i active radii.", value, m_ActivePickupRadiusScales.size()); + LOG_DEBUG("Warning: Could not find pickup radius %f in list of active radii. List has %i active radii.", value, m_ActivePickupRadiusScales.size()); return; } @@ -293,7 +293,7 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) { if (pos != m_ActiveSpeedBoosts.end()) { m_ActiveSpeedBoosts.erase(pos); } else { - Game::logger->LogDebug("ControllablePhysicsComponent", "Warning: Could not find speedboost %f in list of active speedboosts. List has %i active speedboosts.", value, m_ActiveSpeedBoosts.size()); + LOG_DEBUG("Warning: Could not find speedboost %f in list of active speedboosts. List has %i active speedboosts.", value, m_ActiveSpeedBoosts.size()); return; } @@ -311,7 +311,7 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) { void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims){ if (m_IsInBubble) { - Game::logger->Log("ControllablePhysicsComponent", "Already in bubble"); + LOG("Already in bubble"); return; } m_BubbleType = bubbleType; diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 163d2dc6..1cf1da40 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -1,6 +1,6 @@ #include "DestroyableComponent.h" #include -#include "dLogger.h" +#include "Logger.h" #include "Game.h" #include "dConfig.h" @@ -182,7 +182,7 @@ void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* dest = doc->FirstChildElement("obj")->FirstChildElement("dest"); if (!dest) { - Game::logger->Log("DestroyableComponent", "Failed to find dest tag!"); + LOG("Failed to find dest tag!"); return; } @@ -204,7 +204,7 @@ void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* dest = doc->FirstChildElement("obj")->FirstChildElement("dest"); if (!dest) { - Game::logger->Log("DestroyableComponent", "Failed to find dest tag!"); + LOG("Failed to find dest tag!"); return; } @@ -643,19 +643,19 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32 void DestroyableComponent::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd) { m_SubscribedScripts.insert(std::make_pair(scriptObjId, scriptToAdd)); - Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_Parent->GetObjectID()); - Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); + LOG_DEBUG("Added script %llu to entity %llu", scriptObjId, m_Parent->GetObjectID()); + LOG_DEBUG("Number of subscribed scripts %i", m_SubscribedScripts.size()); } void DestroyableComponent::Unsubscribe(LWOOBJID scriptObjId) { auto foundScript = m_SubscribedScripts.find(scriptObjId); if (foundScript != m_SubscribedScripts.end()) { m_SubscribedScripts.erase(foundScript); - Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_Parent->GetObjectID()); + LOG_DEBUG("Removed script %llu from entity %llu", scriptObjId, m_Parent->GetObjectID()); } else { - Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_Parent->GetObjectID(), scriptObjId); + LOG_DEBUG("Tried to remove a script for Entity %llu but script %llu didnt exist", m_Parent->GetObjectID(), scriptObjId); } - Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); + LOG_DEBUG("Number of subscribed scripts %i", m_SubscribedScripts.size()); } void DestroyableComponent::NotifySubscribers(Entity* attacker, uint32_t damage) { diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 512e3c90..7a7ca20a 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -5,7 +5,7 @@ #include "Entity.h" #include "Item.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "CDClientManager.h" #include "../dWorldServer/ObjectIDManager.h" #include "MissionComponent.h" @@ -175,14 +175,14 @@ void InventoryComponent::AddItem( const bool bound, int32_t preferredSlot) { if (count == 0) { - Game::logger->Log("InventoryComponent", "Attempted to add 0 of item (%i) to the inventory!", lot); + LOG("Attempted to add 0 of item (%i) to the inventory!", lot); return; } if (!Inventory::IsValidItem(lot)) { if (lot > 0) { - Game::logger->Log("InventoryComponent", "Attempted to add invalid item (%i) to the inventory!", lot); + LOG("Attempted to add invalid item (%i) to the inventory!", lot); } return; @@ -200,7 +200,7 @@ void InventoryComponent::AddItem( const auto slot = preferredSlot != -1 && inventory->IsSlotEmpty(preferredSlot) ? preferredSlot : inventory->FindEmptySlot(); if (slot == -1) { - Game::logger->Log("InventoryComponent", "Failed to find empty slot for inventory (%i)!", inventoryType); + LOG("Failed to find empty slot for inventory (%i)!", inventoryType); return; } @@ -302,7 +302,7 @@ void InventoryComponent::AddItem( void InventoryComponent::RemoveItem(const LOT lot, const uint32_t count, eInventoryType inventoryType, const bool ignoreBound) { if (count == 0) { - Game::logger->Log("InventoryComponent", "Attempted to remove 0 of item (%i) from the inventory!", lot); + LOG("Attempted to remove 0 of item (%i) from the inventory!", lot); return; } @@ -496,7 +496,7 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document) { auto* inventoryElement = document->FirstChildElement("obj")->FirstChildElement("inv"); if (inventoryElement == nullptr) { - Game::logger->Log("InventoryComponent", "Failed to find 'inv' xml element!"); + LOG("Failed to find 'inv' xml element!"); return; } @@ -504,7 +504,7 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document) { auto* bags = inventoryElement->FirstChildElement("bag"); if (bags == nullptr) { - Game::logger->Log("InventoryComponent", "Failed to find 'bags' xml element!"); + LOG("Failed to find 'bags' xml element!"); return; } @@ -530,7 +530,7 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document) { auto* items = inventoryElement->FirstChildElement("items"); if (items == nullptr) { - Game::logger->Log("InventoryComponent", "Failed to find 'items' xml element!"); + LOG("Failed to find 'items' xml element!"); return; } @@ -545,7 +545,7 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document) { auto* inventory = GetInventory(static_cast(type)); if (inventory == nullptr) { - Game::logger->Log("InventoryComponent", "Failed to find inventory (%i)!", type); + LOG("Failed to find inventory (%i)!", type); return; } @@ -618,7 +618,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) { auto* inventoryElement = document->FirstChildElement("obj")->FirstChildElement("inv"); if (inventoryElement == nullptr) { - Game::logger->Log("InventoryComponent", "Failed to find 'inv' xml element!"); + LOG("Failed to find 'inv' xml element!"); return; } @@ -641,7 +641,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) { auto* bags = inventoryElement->FirstChildElement("bag"); if (bags == nullptr) { - Game::logger->Log("InventoryComponent", "Failed to find 'bags' xml element!"); + LOG("Failed to find 'bags' xml element!"); return; } @@ -660,7 +660,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) { auto* items = inventoryElement->FirstChildElement("items"); if (items == nullptr) { - Game::logger->Log("InventoryComponent", "Failed to find 'items' xml element!"); + LOG("Failed to find 'items' xml element!"); return; } @@ -935,7 +935,7 @@ void InventoryComponent::EquipScripts(Item* equippedItem) { CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID); auto* itemScript = CppScripts::GetScript(m_Parent, scriptCompData.script_name); if (!itemScript) { - Game::logger->Log("InventoryComponent", "null script?"); + LOG("null script?"); } itemScript->OnFactionTriggerItemEquipped(m_Parent, equippedItem->GetId()); } @@ -950,7 +950,7 @@ void InventoryComponent::UnequipScripts(Item* unequippedItem) { CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID); auto* itemScript = CppScripts::GetScript(m_Parent, scriptCompData.script_name); if (!itemScript) { - Game::logger->Log("InventoryComponent", "null script?"); + LOG("null script?"); } itemScript->OnFactionTriggerItemUnequipped(m_Parent, unequippedItem->GetId()); } @@ -1330,7 +1330,7 @@ std::vector InventoryComponent::FindBuffs(Item* item, bool castOnEquip const auto entry = behaviors->GetSkillByID(result.skillID); if (entry.skillID == 0) { - Game::logger->Log("InventoryComponent", "Failed to find buff behavior for skill (%i)!", result.skillID); + LOG("Failed to find buff behavior for skill (%i)!", result.skillID); continue; } @@ -1397,7 +1397,7 @@ std::vector InventoryComponent::GenerateProxies(Item* parent) { try { lots.push_back(std::stoi(segment)); } catch (std::invalid_argument& exception) { - Game::logger->Log("InventoryComponent", "Failed to parse proxy (%s): (%s)!", segment.c_str(), exception.what()); + LOG("Failed to parse proxy (%s): (%s)!", segment.c_str(), exception.what()); } } diff --git a/dGame/dComponents/LevelProgressionComponent.cpp b/dGame/dComponents/LevelProgressionComponent.cpp index 9930bdef..3a18b19c 100644 --- a/dGame/dComponents/LevelProgressionComponent.cpp +++ b/dGame/dComponents/LevelProgressionComponent.cpp @@ -16,7 +16,7 @@ LevelProgressionComponent::LevelProgressionComponent(Entity* parent) : Component void LevelProgressionComponent::UpdateXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* level = doc->FirstChildElement("obj")->FirstChildElement("lvl"); if (!level) { - Game::logger->Log("LevelProgressionComponent", "Failed to find lvl tag while updating XML!"); + LOG("Failed to find lvl tag while updating XML!"); return; } level->SetAttribute("l", m_Level); @@ -27,7 +27,7 @@ void LevelProgressionComponent::UpdateXml(tinyxml2::XMLDocument* doc) { void LevelProgressionComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { tinyxml2::XMLElement* level = doc->FirstChildElement("obj")->FirstChildElement("lvl"); if (!level) { - Game::logger->Log("LevelProgressionComponent", "Failed to find lvl tag while loading XML!"); + LOG("Failed to find lvl tag while loading XML!"); return; } level->QueryAttribute("l", &m_Level); diff --git a/dGame/dComponents/MissionComponent.cpp b/dGame/dComponents/MissionComponent.cpp index 40411902..d7da29d9 100644 --- a/dGame/dComponents/MissionComponent.cpp +++ b/dGame/dComponents/MissionComponent.cpp @@ -7,7 +7,7 @@ #include #include "MissionComponent.h" -#include "dLogger.h" +#include "Logger.h" #include "CDClientManager.h" #include "CDMissionTasksTable.h" #include "InventoryComponent.h" @@ -363,7 +363,7 @@ bool MissionComponent::LookForAchievements(eMissionTaskType type, int32_t value, break; } } catch (std::invalid_argument& exception) { - Game::logger->Log("MissionComponent", "Failed to parse target (%s): (%s)!", token.c_str(), exception.what()); + LOG("Failed to parse target (%s): (%s)!", token.c_str(), exception.what()); } } diff --git a/dGame/dComponents/MissionOfferComponent.cpp b/dGame/dComponents/MissionOfferComponent.cpp index e4c94ebd..9299ebd7 100644 --- a/dGame/dComponents/MissionOfferComponent.cpp +++ b/dGame/dComponents/MissionOfferComponent.cpp @@ -11,7 +11,7 @@ #include "GameMessages.h" #include "Entity.h" #include "MissionComponent.h" -#include "dLogger.h" +#include "Logger.h" #include "Game.h" #include "MissionPrerequisites.h" #include "eMissionState.h" @@ -82,7 +82,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi auto* missionComponent = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); if (!missionComponent) { - Game::logger->Log("MissionOfferComponent", "Unable to get mission component for Entity %llu", entity->GetObjectID()); + LOG("Unable to get mission component for Entity %llu", entity->GetObjectID()); return; } @@ -154,7 +154,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi randomMissionPool.push_back(value); } catch (std::invalid_argument& exception) { - Game::logger->Log("MissionOfferComponent", "Failed to parse value (%s): (%s)!", token.c_str(), exception.what()); + LOG("Failed to parse value (%s): (%s)!", token.c_str(), exception.what()); } } diff --git a/dGame/dComponents/MovementAIComponent.h b/dGame/dComponents/MovementAIComponent.h index 4a4e4c0a..9c345bd1 100644 --- a/dGame/dComponents/MovementAIComponent.h +++ b/dGame/dComponents/MovementAIComponent.h @@ -11,7 +11,7 @@ #include "GameMessages.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "Component.h" #include "eReplicaComponentType.h" #include diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index 60d320f4..a95735fd 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -8,7 +8,7 @@ #include "GeneralUtils.h" #include "dZoneManager.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" #include "GameMessages.h" #include "CppScripts.h" #include "SimplePhysicsComponent.h" @@ -63,7 +63,7 @@ MovingPlatformComponent::MovingPlatformComponent(Entity* parent, const std::stri m_NoAutoStart = false; if (m_Path == nullptr) { - Game::logger->Log("MovingPlatformComponent", "Path not found: %s", pathName.c_str()); + LOG("Path not found: %s", pathName.c_str()); } } diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 5132af08..b82427c1 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -240,7 +240,7 @@ void PetComponent::OnUse(Entity* originator) { if (bricks.empty()) { ChatPackets::SendSystemMessage(originator->GetSystemAddress(), u"Failed to load the puzzle minigame for this pet."); - Game::logger->Log("PetComponent", "Couldn't find %s for minigame!", buildFile.c_str()); + LOG("Couldn't find %s for minigame!", buildFile.c_str()); return; } @@ -647,7 +647,7 @@ void PetComponent::RequestSetPetName(std::u16string name) { return; } - Game::logger->Log("PetComponent", "Got set pet name (%s)", GeneralUtils::UTF16ToWTF8(name).c_str()); + LOG("Got set pet name (%s)", GeneralUtils::UTF16ToWTF8(name).c_str()); auto* inventoryComponent = tamer->GetComponent(); @@ -923,7 +923,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) { // Set this to a variable so when this is called back from the player the timer doesn't fire off. m_Parent->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item]() { if (!playerDestroyableComponent) { - Game::logger->Log("PetComponent", "No petComponent and/or no playerDestroyableComponent"); + LOG("No petComponent and/or no playerDestroyableComponent"); return; } diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index 66030de2..e0a76f67 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -9,7 +9,7 @@ #include "PhantomPhysicsComponent.h" #include "Game.h" #include "LDFFormat.h" -#include "dLogger.h" +#include "Logger.h" #include "Entity.h" #include "EntityManager.h" #include "ControllablePhysicsComponent.h" @@ -223,7 +223,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : PhysicsCompon m_dpEntity->SetPosition(m_Position); dpWorld::Instance().AddEntity(m_dpEntity); } else { - //Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str()); + //LOG("This one is supposed to have %s", info->physicsAsset.c_str()); //add fallback cube: m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 2.0f, 2.0f, 2.0f); diff --git a/dGame/dComponents/PropertyEntranceComponent.cpp b/dGame/dComponents/PropertyEntranceComponent.cpp index bff917d8..cb7baf63 100644 --- a/dGame/dComponents/PropertyEntranceComponent.cpp +++ b/dGame/dComponents/PropertyEntranceComponent.cpp @@ -10,7 +10,7 @@ #include "RocketLaunchpadControlComponent.h" #include "CharacterComponent.h" #include "UserManager.h" -#include "dLogger.h" +#include "Logger.h" #include "Amf3.h" #include "eObjectBits.h" #include "eGameMasterLevel.h" @@ -219,7 +219,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl delete nameLookup; nameLookup = nullptr; - Game::logger->Log("PropertyEntranceComponent", "Failed to find property owner name for %llu!", cloneId); + LOG("Failed to find property owner name for %llu!", cloneId); continue; } else { diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index c8937c35..63c321f6 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -123,7 +123,7 @@ std::vector PropertyManagementComponent::GetPaths() const { points.push_back(value); } catch (std::invalid_argument& exception) { - Game::logger->Log("PropertyManagementComponent", "Failed to parse value (%s): (%s)!", token.c_str(), exception.what()); + LOG("Failed to parse value (%s): (%s)!", token.c_str(), exception.what()); } } @@ -234,7 +234,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) { try { insertion->execute(); } catch (sql::SQLException& exception) { - Game::logger->Log("PropertyManagementComponent", "Failed to execute query: (%s)!", exception.what()); + LOG("Failed to execute query: (%s)!", exception.what()); throw exception; return false; @@ -294,7 +294,7 @@ void PropertyManagementComponent::OnFinishBuilding() { } void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation) { - Game::logger->Log("PropertyManagementComponent", "Placing model <%f, %f, %f>", position.x, position.y, position.z); + LOG("Placing model <%f, %f, %f>", position.x, position.y, position.z); auto* entity = GetOwner(); @@ -311,7 +311,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N auto* item = inventoryComponent->FindItemById(id); if (item == nullptr) { - Game::logger->Log("PropertyManagementComponent", "Failed to find item with id %d", id); + LOG("Failed to find item with id %d", id); return; } @@ -409,7 +409,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N } void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int deleteReason) { - Game::logger->Log("PropertyManagementComponent", "Delete model: (%llu) (%i)", id, deleteReason); + LOG("Delete model: (%llu) (%i)", id, deleteReason); auto* entity = GetOwner(); @@ -426,7 +426,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet const auto index = models.find(id); if (index == models.end()) { - Game::logger->Log("PropertyManagementComponent", "Failed to find model"); + LOG("Failed to find model"); return; } @@ -438,20 +438,20 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet models.erase(id); if (spawner == nullptr) { - Game::logger->Log("PropertyManagementComponent", "Failed to find spawner"); + LOG("Failed to find spawner"); } auto* model = Game::entityManager->GetEntity(id); if (model == nullptr) { - Game::logger->Log("PropertyManagementComponent", "Failed to find model entity"); + LOG("Failed to find model entity"); return; } Game::entityManager->DestructEntity(model); - Game::logger->Log("PropertyManagementComponent", "Deleting model LOT %i", model->GetLOT()); + LOG("Deleting model LOT %i", model->GetLOT()); if (model->GetLOT() == 14) { //add it to the inv @@ -534,13 +534,13 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet { item->SetCount(item->GetCount() - 1); - Game::logger->Log("BODGE TIME", "YES IT GOES HERE"); + LOG("YES IT GOES HERE"); break; } default: { - Game::logger->Log("PropertyManagementComponent", "Invalid delete reason"); + LOG("Invalid delete reason"); } } @@ -679,7 +679,7 @@ void PropertyManagementComponent::Save() { try { lookupResult = lookup->executeQuery(); } catch (sql::SQLException& ex) { - Game::logger->Log("PropertyManagementComponent", "lookup error %s", ex.what()); + LOG("lookup error %s", ex.what()); } std::vector present; @@ -729,7 +729,7 @@ void PropertyManagementComponent::Save() { try { insertion->execute(); } catch (sql::SQLException& ex) { - Game::logger->Log("PropertyManagementComponent", "Error inserting into properties_contents. Error %s", ex.what()); + LOG("Error inserting into properties_contents. Error %s", ex.what()); } } else { update->setDouble(1, position.x); @@ -744,7 +744,7 @@ void PropertyManagementComponent::Save() { try { update->executeUpdate(); } catch (sql::SQLException& ex) { - Game::logger->Log("PropertyManagementComponent", "Error updating properties_contents. Error: %s", ex.what()); + LOG("Error updating properties_contents. Error: %s", ex.what()); } } } @@ -758,7 +758,7 @@ void PropertyManagementComponent::Save() { try { remove->execute(); } catch (sql::SQLException& ex) { - Game::logger->Log("PropertyManagementComponent", "Error removing from properties_contents. Error %s", ex.what()); + LOG("Error removing from properties_contents. Error %s", ex.what()); } } @@ -789,7 +789,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const const auto& worldId = Game::zoneManager->GetZone()->GetZoneID(); const auto zoneId = worldId.GetMapID(); - Game::logger->Log("Properties", "Getting property info for %d", zoneId); + LOG("Getting property info for %d", zoneId); GameMessages::PropertyDataMessage message = GameMessages::PropertyDataMessage(zoneId); const auto isClaimed = GetOwnerId() != LWOOBJID_EMPTY; diff --git a/dGame/dComponents/PropertyVendorComponent.cpp b/dGame/dComponents/PropertyVendorComponent.cpp index cff4995c..502888d5 100644 --- a/dGame/dComponents/PropertyVendorComponent.cpp +++ b/dGame/dComponents/PropertyVendorComponent.cpp @@ -6,7 +6,7 @@ #include "EntityManager.h" #include "dZoneManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "PropertyManagementComponent.h" #include "UserManager.h" @@ -19,7 +19,7 @@ void PropertyVendorComponent::OnUse(Entity* originator) { OnQueryPropertyData(originator, originator->GetSystemAddress()); if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) { - Game::logger->Log("PropertyVendorComponent", "Property vendor opening!"); + LOG("Property vendor opening!"); GameMessages::SendOpenPropertyVendor(m_Parent->GetObjectID(), originator->GetSystemAddress()); @@ -37,7 +37,7 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con if (PropertyManagementComponent::Instance() == nullptr) return; if (PropertyManagementComponent::Instance()->Claim(originator->GetObjectID()) == false) { - Game::logger->Log("PropertyVendorComponent", "FAILED TO CLAIM PROPERTY. PLAYER ID IS %llu", originator->GetObjectID()); + LOG("FAILED TO CLAIM PROPERTY. PLAYER ID IS %llu", originator->GetObjectID()); return; } @@ -51,6 +51,6 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, originator->GetSystemAddress()); - Game::logger->Log("PropertyVendorComponent", "Fired event; (%d) (%i) (%i)", confirmed, lot, count); + LOG("Fired event; (%d) (%i) (%i)", confirmed, lot, count); } diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index cda1abd0..e5f2dbe1 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -26,6 +26,7 @@ #include "LeaderboardManager.h" #include "dZoneManager.h" #include "CDActivitiesTable.h" +#include #ifndef M_PI #define M_PI 3.14159265358979323846264338327950288 @@ -79,7 +80,7 @@ void RacingControlComponent::OnPlayerLoaded(Entity* player) { m_LoadedPlayers++; - Game::logger->Log("RacingControlComponent", "Loading player %i", + LOG("Loading player %i", m_LoadedPlayers); m_LobbyPlayers.push_back(player->GetObjectID()); } @@ -103,7 +104,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, auto* item = inventoryComponent->FindItemByLot(8092); if (item == nullptr) { - Game::logger->Log("RacingControlComponent", "Failed to find item"); + LOG("Failed to find item"); auto* playerInstance = dynamic_cast(player); if(playerInstance){ m_LoadedPlayers--; @@ -552,12 +553,10 @@ void RacingControlComponent::Update(float deltaTime) { // From the first 2 players loading in the rest have a max of 15 seconds // to load in, can raise this if it's too low if (m_LoadTimer >= 15) { - Game::logger->Log("RacingControlComponent", - "Loading all players..."); + LOG("Loading all players..."); for (size_t positionNumber = 0; positionNumber < m_LobbyPlayers.size(); positionNumber++) { - Game::logger->Log("RacingControlComponent", - "Loading player now!"); + LOG("Loading player now!"); auto* player = Game::entityManager->GetEntity(m_LobbyPlayers[positionNumber]); @@ -566,8 +565,7 @@ void RacingControlComponent::Update(float deltaTime) { return; } - Game::logger->Log("RacingControlComponent", - "Loading player now NOW!"); + LOG("Loading player now NOW!"); LoadPlayerVehicle(player, positionNumber + 1, true); @@ -717,7 +715,7 @@ void RacingControlComponent::Update(float deltaTime) { m_Started = true; - Game::logger->Log("RacingControlComponent", "Starting race"); + LOG("Starting race"); Game::entityManager->SerializeEntity(m_Parent); @@ -820,8 +818,7 @@ void RacingControlComponent::Update(float deltaTime) { if (player.bestLapTime == 0 || player.bestLapTime > lapTime) { player.bestLapTime = lapTime; - Game::logger->Log("RacingControlComponent", - "Best lap time (%llu)", lapTime); + LOG("Best lap time (%llu)", lapTime); } auto* missionComponent = @@ -841,8 +838,7 @@ void RacingControlComponent::Update(float deltaTime) { player.raceTime = raceTime; - Game::logger->Log("RacingControlComponent", - "Completed time %llu, %llu", + LOG("Completed time %llu, %llu", raceTime, raceTime * 1000); LeaderboardManager::SaveScore(playerEntity->GetObjectID(), m_ActivityID, static_cast(player.raceTime), static_cast(player.bestLapTime), static_cast(player.finished == 1)); @@ -858,13 +854,11 @@ void RacingControlComponent::Update(float deltaTime) { } } - Game::logger->Log("RacingControlComponent", - "Lapped (%i) in (%llu)", player.lap, + LOG("Lapped (%i) in (%llu)", player.lap, lapTime); } - Game::logger->Log("RacingControlComponent", - "Reached point (%i)/(%i)", player.respawnIndex, + LOG("Reached point (%i)/(%i)", player.respawnIndex, path->pathWaypoints.size()); break; diff --git a/dGame/dComponents/RailActivatorComponent.cpp b/dGame/dComponents/RailActivatorComponent.cpp index c7d58999..5662303b 100644 --- a/dGame/dComponents/RailActivatorComponent.cpp +++ b/dGame/dComponents/RailActivatorComponent.cpp @@ -6,7 +6,7 @@ #include "GameMessages.h" #include "RebuildComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "RenderComponent.h" #include "EntityManager.h" #include "eStateChangeType.h" diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index da8a9a4b..5359dee0 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -4,7 +4,7 @@ #include "GameMessages.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "CharacterComponent.h" #include "MissionComponent.h" #include "eMissionTaskType.h" @@ -39,7 +39,7 @@ RebuildComponent::RebuildComponent(Entity* entity) : Component(entity) { GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) && GeneralUtils::TryParse(positionAsVector[2], m_ActivatorPosition.z)) { } else { - Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.", m_Parent->GetLOT()); + LOG("Failed to find activator position for lot %i. Defaulting to parents position.", m_Parent->GetLOT()); m_ActivatorPosition = m_Parent->GetPosition(); } @@ -439,7 +439,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { characterComponent->SetCurrentActivity(eGameActivity::NONE); characterComponent->TrackRebuildComplete(); } else { - Game::logger->Log("RebuildComponent", "Some user tried to finish the rebuild but they didn't have a character somehow."); + LOG("Some user tried to finish the rebuild but they didn't have a character somehow."); return; } diff --git a/dGame/dComponents/RenderComponent.cpp b/dGame/dComponents/RenderComponent.cpp index 6f32dd79..f1b8ea0c 100644 --- a/dGame/dComponents/RenderComponent.cpp +++ b/dGame/dComponents/RenderComponent.cpp @@ -10,7 +10,7 @@ #include "CDClientManager.h" #include "GameMessages.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "CDAnimationsTable.h" std::unordered_map RenderComponent::m_DurationCache{}; @@ -32,7 +32,7 @@ RenderComponent::RenderComponent(Entity* parent, int32_t componentId): Component for (auto& groupId : groupIdsSplit) { int32_t groupIdInt; if (!GeneralUtils::TryParse(groupId, groupIdInt)) { - Game::logger->Log("RenderComponent", "bad animation group Id %s", groupId.c_str()); + LOG("bad animation group Id %s", groupId.c_str()); continue; } m_animationGroupIds.push_back(groupIdInt); @@ -229,6 +229,6 @@ float RenderComponent::DoAnimation(Entity* self, const std::string& animation, b } } if (sendAnimation) GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(animation), priority, scale); - if (returnlength == 0.0f) Game::logger->Log("RenderComponent", "WARNING: Unable to find animation %s for lot %i in any group.", animation.c_str(), self->GetLOT()); + if (returnlength == 0.0f) LOG("WARNING: Unable to find animation %s for lot %i in any group.", animation.c_str(), self->GetLOT()); return returnlength; } diff --git a/dGame/dComponents/RocketLaunchpadControlComponent.cpp b/dGame/dComponents/RocketLaunchpadControlComponent.cpp index 34c34dd1..5a385546 100644 --- a/dGame/dComponents/RocketLaunchpadControlComponent.cpp +++ b/dGame/dComponents/RocketLaunchpadControlComponent.cpp @@ -8,7 +8,7 @@ #include "EntityManager.h" #include "Item.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "CDClientDatabase.h" #include "ChatPackets.h" #include "MissionComponent.h" @@ -57,7 +57,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId, auto* rocket = characterComponent->GetRocket(originator); if (!rocket) { - Game::logger->Log("RocketLaunchpadControlComponent", "Unable to find rocket!"); + LOG("Unable to find rocket!"); return; } diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ScriptedActivityComponent.cpp index fa70139b..838fe5ed 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ScriptedActivityComponent.cpp @@ -6,7 +6,7 @@ #include "dZoneManager.h" #include "ZoneInstanceManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include #include "EntityManager.h" #include "ChatPackets.h" @@ -273,7 +273,7 @@ void ScriptedActivityComponent::Update(float deltaTime) { // The timer has elapsed, start the instance if (lobby->timer <= 0.0f) { - Game::logger->Log("ScriptedActivityComponent", "Setting up instance."); + LOG("Setting up instance."); ActivityInstance* instance = NewInstance(); LoadPlayersIntoInstance(instance, lobby->players); instance->StartZone(); @@ -539,7 +539,7 @@ void ActivityInstance::StartZone() { if (player == nullptr) return; - Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", player->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); + LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", player->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); if (player->GetCharacter()) { player->GetCharacter()->SetZoneID(zoneID); player->GetCharacter()->SetZoneInstance(zoneInstance); diff --git a/dGame/dComponents/SimplePhysicsComponent.cpp b/dGame/dComponents/SimplePhysicsComponent.cpp index 9a955304..b92aa1a3 100644 --- a/dGame/dComponents/SimplePhysicsComponent.cpp +++ b/dGame/dComponents/SimplePhysicsComponent.cpp @@ -6,7 +6,7 @@ #include "SimplePhysicsComponent.h" #include "BitStream.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "dpWorld.h" #include "CDClientManager.h" #include "CDPhysicsComponentTable.h" diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index 13cf98f6..7762345e 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -55,7 +55,7 @@ void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syn const auto index = this->m_managedBehaviors.find(skillUid); if (index == this->m_managedBehaviors.end()) { - Game::logger->Log("SkillComponent", "Failed to find skill with uid (%i)!", skillUid, syncId); + LOG("Failed to find skill with uid (%i)!", skillUid, syncId); return; } @@ -80,7 +80,7 @@ void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::B } if (index == -1) { - Game::logger->Log("SkillComponent", "Failed to find projectile id (%llu)!", projectileId); + LOG("Failed to find projectile id (%llu)!", projectileId); return; } @@ -94,7 +94,7 @@ void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::B auto result = query.execQuery(); if (result.eof()) { - Game::logger->Log("SkillComponent", "Failed to find skill id for (%i)!", sync_entry.lot); + LOG("Failed to find skill id for (%i)!", sync_entry.lot); return; } @@ -243,7 +243,7 @@ bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LW // check to see if we got back a valid behavior if (behaviorId == -1) { - Game::logger->LogDebug("SkillComponent", "Tried to cast skill %i but found no behavior", skillId); + LOG_DEBUG("Tried to cast skill %i but found no behavior", skillId); return false; } @@ -401,7 +401,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) if (other == nullptr) { if (entry.branchContext.target != LWOOBJID_EMPTY) { - Game::logger->Log("SkillComponent", "Invalid projectile target (%llu)!", entry.branchContext.target); + LOG("Invalid projectile target (%llu)!", entry.branchContext.target); } return; @@ -413,7 +413,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) auto result = query.execQuery(); if (result.eof()) { - Game::logger->Log("SkillComponent", "Failed to find skill id for (%i)!", entry.lot); + LOG("Failed to find skill id for (%i)!", entry.lot); return; } diff --git a/dGame/dComponents/SkillComponent.h b/dGame/dComponents/SkillComponent.h index b157ad3d..4b950e71 100644 --- a/dGame/dComponents/SkillComponent.h +++ b/dGame/dComponents/SkillComponent.h @@ -12,7 +12,7 @@ #include "BitStream.h" #include "Component.h" #include "Entity.h" -#include "dLogger.h" +#include "Logger.h" #include "eReplicaComponentType.h" struct ProjectileSyncEntry { diff --git a/dGame/dComponents/SoundTriggerComponent.cpp b/dGame/dComponents/SoundTriggerComponent.cpp index dc7355db..34d2441c 100644 --- a/dGame/dComponents/SoundTriggerComponent.cpp +++ b/dGame/dComponents/SoundTriggerComponent.cpp @@ -1,6 +1,6 @@ #include "SoundTriggerComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" void MusicCue::Serialize(RakNet::BitStream* outBitStream){ outBitStream->Write(name.size()); diff --git a/dGame/dComponents/TriggerComponent.cpp b/dGame/dComponents/TriggerComponent.cpp index ab52c4e5..f7ef7c54 100644 --- a/dGame/dComponents/TriggerComponent.cpp +++ b/dGame/dComponents/TriggerComponent.cpp @@ -155,7 +155,7 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity case eTriggerCommandType::DEACTIVATE_MIXER_PROGRAM: break; // DEPRECATED BLOCK END default: - Game::logger->LogDebug("TriggerComponent", "Event %i was not handled!", command->id); + LOG_DEBUG("Event %i was not handled!", command->id); break; } } @@ -198,7 +198,7 @@ void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string arg void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){ auto* triggerComponent = targetEntity->GetComponent(); if (!triggerComponent) { - Game::logger->LogDebug("TriggerComponent::HandleToggleTrigger", "Trigger component not found!"); + LOG_DEBUG("Trigger component not found!"); return; } triggerComponent->SetTriggerEnabled(args == "1"); @@ -207,7 +207,7 @@ void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string arg void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args){ auto* rebuildComponent = targetEntity->GetComponent(); if (!rebuildComponent) { - Game::logger->LogDebug("TriggerComponent::HandleResetRebuild", "Rebuild component not found!"); + LOG_DEBUG("Rebuild component not found!"); return; } rebuildComponent->ResetRebuild(args == "1"); @@ -239,7 +239,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vectorGetComponent(); if (!phantomPhysicsComponent) { - Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!"); + LOG_DEBUG("Phantom Physics component not found!"); return; } phantomPhysicsComponent->SetPhysicsEffectActive(true); @@ -256,7 +256,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vectorGetComponent(); if (!phantomPhysicsComponent) { - Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!"); + LOG_DEBUG("Phantom Physics component not found!"); return; } float forceMultiplier; @@ -279,7 +279,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args) void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector argArray){ if (argArray.size() != 2) { - Game::logger->LogDebug("TriggerComponent::HandleSetTimer", "Not ehought variables!"); + LOG_DEBUG("Not ehought variables!"); return; } float time = 0.0; @@ -320,7 +320,7 @@ void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vectorGetCharacter(); if (!character) { - Game::logger->LogDebug("TriggerComponent::HandleToggleBBB", "Character was not found!"); + LOG_DEBUG("Character was not found!"); return; } bool buildMode = !(character->GetBuildMode()); @@ -336,7 +336,7 @@ void TriggerComponent::HandleUpdateMission(Entity* targetEntity, std::vectorGetComponent(); if (!missionComponent){ - Game::logger->LogDebug("TriggerComponent::HandleUpdateMission", "Mission component not found!"); + LOG_DEBUG("Mission component not found!"); return; } missionComponent->Progress(eMissionTaskType::EXPLORE, 0, 0, argArray.at(4)); @@ -355,7 +355,7 @@ void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vectorGetComponent(); if (!skillComponent) { - Game::logger->LogDebug("TriggerComponent::HandleCastSkill", "Skill component not found!"); + LOG_DEBUG("Skill component not found!"); return; } uint32_t skillId; @@ -366,7 +366,7 @@ void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::vector argArray) { auto* phantomPhysicsComponent = targetEntity->GetComponent(); if (!phantomPhysicsComponent) { - Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); + LOG_DEBUG("Phantom Physics component not found!"); return; } phantomPhysicsComponent->SetPhysicsEffectActive(true); @@ -401,7 +401,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::string args) { auto* phantomPhysicsComponent = targetEntity->GetComponent(); if (!phantomPhysicsComponent) { - Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); + LOG_DEBUG("Phantom Physics component not found!"); return; } phantomPhysicsComponent->SetPhysicsEffectActive(args == "On"); @@ -438,6 +438,6 @@ void TriggerComponent::HandleActivatePhysics(Entity* targetEntity, std::string a } else if (args == "false"){ // TODO remove Phsyics entity if there is one } else { - Game::logger->LogDebug("TriggerComponent", "Invalid argument for ActivatePhysics Trigger: %s", args.c_str()); + LOG_DEBUG("Invalid argument for ActivatePhysics Trigger: %s", args.c_str()); } } diff --git a/dGame/dComponents/VendorComponent.cpp b/dGame/dComponents/VendorComponent.cpp index e6f99245..dfea33df 100644 --- a/dGame/dComponents/VendorComponent.cpp +++ b/dGame/dComponents/VendorComponent.cpp @@ -57,7 +57,7 @@ void VendorComponent::RefreshInventory(bool isCreation) { if (!m_HasStandardCostItems || !m_HasMultiCostItems) { auto itemComponentID = compRegistryTable->GetByIDAndType(item.itemid, eReplicaComponentType::ITEM, -1); if (itemComponentID == -1) { - Game::logger->Log("VendorComponent", "Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT()); + LOG("Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT()); continue; } auto itemComponent = itemComponentTable->GetItemComponentByID(itemComponentID); @@ -77,7 +77,7 @@ void VendorComponent::RefreshInventory(bool isCreation) { if (!m_HasStandardCostItems || !m_HasMultiCostItems) { auto itemComponentID = compRegistryTable->GetByIDAndType(randomItem.itemid, eReplicaComponentType::ITEM, -1); if (itemComponentID == -1) { - Game::logger->Log("VendorComponent", "Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT()); + LOG("Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT()); continue; } auto itemComponent = itemComponentTable->GetItemComponentByID(itemComponentID); diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index b2af8ca7..9a50a746 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -47,11 +47,11 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System User* usr = UserManager::Instance()->GetUser(sysAddr); if (!entity) { - Game::logger->Log("GameMessageHandler", "Failed to find associated entity (%llu), aborting GM (%X)!", objectID, messageID); + LOG("Failed to find associated entity (%llu), aborting GM (%X)!", objectID, messageID); return; } - if (messageID != eGameMessageType::READY_FOR_UPDATES) Game::logger->LogDebug("GameMessageHandler", "received game message ID: %i", messageID); + if (messageID != eGameMessageType::READY_FOR_UPDATES) LOG_DEBUG("received game message ID: %i", messageID); switch (messageID) { @@ -167,7 +167,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System character->OnZoneLoad(); } - Game::logger->Log("GameMessageHandler", "Player %s (%llu) loaded.", entity->GetCharacter()->GetName().c_str(), entity->GetObjectID()); + LOG("Player %s (%llu) loaded.", entity->GetCharacter()->GetName().c_str(), entity->GetObjectID()); // After we've done our thing, tell the client they're ready GameMessages::SendPlayerReady(entity, sysAddr); @@ -694,7 +694,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System GameMessages::HandleCancelDonationOnPlayer(inStream, entity); break; default: - Game::logger->LogDebug("GameMessageHandler", "Unknown game message ID: %i", messageID); + LOG_DEBUG("Unknown game message ID: %i", messageID); break; } } diff --git a/dGame/dGameMessages/GameMessageHandler.h b/dGame/dGameMessages/GameMessageHandler.h index 8b6685cb..821d80be 100644 --- a/dGame/dGameMessages/GameMessageHandler.h +++ b/dGame/dGameMessages/GameMessageHandler.h @@ -16,7 +16,7 @@ #include "Entity.h" #include "EntityManager.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "GameMessages.h" #include "../dDatabase/CDClientDatabase.h" diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 1e0fe2d8..a0e3a7b4 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -8,7 +8,7 @@ #include "SlashCommandHandler.h" #include "NiPoint3.h" #include "NiQuaternion.h" -#include "dLogger.h" +#include "Logger.h" #include "GeneralUtils.h" #include "Character.h" #include "EntityManager.h" @@ -156,7 +156,7 @@ void GameMessages::SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, c void GameMessages::SendPlayAnimation(Entity* entity, const std::u16string& animationName, float fPriority, float fScale) { if (!entity) { - Game::logger->Log("SendPlayAnimation", "Trying to play animation, but entity var is nullptr!"); + LOG("Trying to play animation, but entity var is nullptr!"); return; } @@ -1631,7 +1631,7 @@ void GameMessages::HandleUpdateShootingGalleryRotation(RakNet::BitStream* inStre void GameMessages::HandleActivitySummaryLeaderboardData(RakNet::BitStream* instream, Entity* entity, const SystemAddress& sysAddr) { - Game::logger->Log("AGS", "We got mail!"); + LOG("We got mail!"); } void GameMessages::SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, const Leaderboard* leaderboard, const SystemAddress& sysAddr) { @@ -1688,7 +1688,7 @@ void GameMessages::HandleActivityStateChangeRequest(RakNet::BitStream* inStream, auto* assosiate = Game::entityManager->GetEntity(objectID); - Game::logger->Log("Activity State Change", "%s [%i, %i] from %i to %i", GeneralUtils::UTF16ToWTF8(stringValue).c_str(), value1, value2, entity->GetLOT(), assosiate != nullptr ? assosiate->GetLOT() : 0); + LOG("%s [%i, %i] from %i to %i", GeneralUtils::UTF16ToWTF8(stringValue).c_str(), value1, value2, entity->GetLOT(), assosiate != nullptr ? assosiate->GetLOT() : 0); std::vector scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SHOOTING_GALLERY); for (Entity* scriptEntity : scriptedActs) { @@ -1982,7 +1982,7 @@ void GameMessages::SendDownloadPropertyData(const LWOOBJID objectId, const Prope data.Serialize(bitStream); - Game::logger->Log("SendDownloadPropertyData", "(%llu) sending property data (%d)", objectId, sysAddr == UNASSIGNED_SYSTEM_ADDRESS); + LOG("(%llu) sending property data (%d)", objectId, sysAddr == UNASSIGNED_SYSTEM_ADDRESS); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -2053,7 +2053,7 @@ void GameMessages::SendGetModelsOnProperty(LWOOBJID objectId, std::mapLog("SendGetModelsOnProperty", "Sending property models to (%llu) (%d)", objectId, sysAddr == UNASSIGNED_SYSTEM_ADDRESS); + LOG("Sending property models to (%llu) (%d)", objectId, sysAddr == UNASSIGNED_SYSTEM_ADDRESS); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -2150,7 +2150,7 @@ void GameMessages::HandleSetPropertyAccess(RakNet::BitStream* inStream, Entity* inStream->Read(renewIsDefault); if (renewIsDefault != 0) inStream->Read(renew); - Game::logger->Log("GameMessages", "Set privacy option to: %i", accessType); + LOG("Set privacy option to: %i", accessType); if (PropertyManagementComponent::Instance() == nullptr) return; @@ -2169,7 +2169,7 @@ void GameMessages::HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity, if (item) { inventoryComponent->MoveItemToInventory(item, eInventoryType::MODELS, 1); } else { - Game::logger->Log("GameMessages", "item id %llu not found in MODELS_IN_BBB inventory, likely because it does not exist", objIdToAddToInventory); + LOG("item id %llu not found in MODELS_IN_BBB inventory, likely because it does not exist", objIdToAddToInventory); } } @@ -2216,7 +2216,7 @@ void GameMessages::HandleUpdatePropertyOrModelForFilterCheck(RakNet::BitStream* } void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { - Game::logger->Log("HandleQueryPropertyData", "Entity (%i) requesting data", entity->GetLOT()); + LOG("Entity (%i) requesting data", entity->GetLOT()); /* auto entites = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_VENDOR); @@ -2274,7 +2274,7 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit player->GetCharacter()->SetBuildMode(start); - Game::logger->Log("GameMessages", "Sending build mode confirm (%i): (%d) (%i) (%d) (%i) (%llu)", entity->GetLOT(), start, distanceType, modePaused, modeValue, playerId); + LOG("Sending build mode confirm (%i): (%d) (%i) (%d) (%i) (%llu)", entity->GetLOT(), start, distanceType, modePaused, modeValue, playerId); SendSetBuildModeConfirmed(entity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS, start, false, modePaused, modeValue, playerId, startPosition); } @@ -2310,7 +2310,7 @@ void GameMessages::HandleStartBuildingWithItem(RakNet::BitStream* inStream, Enti sourceType = 4; } - Game::logger->Log("GameMessages", "Handling start building with item (%i): (%d) (%d) (%i) (%llu) (%i) (%i) (%llu) (%i) (%i)", entity->GetLOT(), firstTime, success, sourceBag, sourceId, sourceLot, sourceType, targetId, targetLot, targetType); + LOG("Handling start building with item (%i): (%d) (%d) (%i) (%llu) (%i) (%i) (%llu) (%i) (%i)", entity->GetLOT(), firstTime, success, sourceBag, sourceId, sourceLot, sourceType, targetId, targetLot, targetType); auto* user = UserManager::Instance()->GetUser(sysAddr); @@ -2400,7 +2400,7 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity* LWOOBJID previousItemID = LWOOBJID_EMPTY; inStream->Read(previousItemID); - Game::logger->Log("BBB", "Load item request for: %lld", previousItemID); + LOG("Load item request for: %lld", previousItemID); LWOOBJID newId = previousItemID; auto* inventoryComponent = entity->GetComponent(); if (inventoryComponent) { @@ -2417,7 +2417,7 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity* if (movedItem) newId = movedItem->GetId(); } } else { - Game::logger->Log("GameMessages", "item id %llu not found in MODELS inventory, likely because it does not exist", previousItemID); + LOG("item id %llu not found in MODELS inventory, likely because it does not exist", previousItemID); } } @@ -2555,7 +2555,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent //int32_t size = ZCompression::Decompress(inData, lxfmlSize, outData, 327680, error); //if (size == -1) { - // Game::logger->Log("GameMessages", "Failed to decompress LXFML: (%i)", error); + // LOG("Failed to decompress LXFML: (%i)", error); // return; //} // @@ -3304,7 +3304,7 @@ void GameMessages::HandleClientTradeRequest(RakNet::BitStream* inStream, Entity* return; } - Game::logger->Log("GameMessages", "Trade request to (%llu)", i64Invitee); + LOG("Trade request to (%llu)", i64Invitee); auto* trade = TradingManager::Instance()->GetPlayerTrade(entity->GetObjectID()); @@ -3333,7 +3333,7 @@ void GameMessages::HandleClientTradeCancel(RakNet::BitStream* inStream, Entity* if (trade == nullptr) return; - Game::logger->Log("GameMessages", "Trade canceled from (%llu)", entity->GetObjectID()); + LOG("Trade canceled from (%llu)", entity->GetObjectID()); TradingManager::Instance()->CancelTrade(trade->GetTradeId()); } @@ -3341,7 +3341,7 @@ void GameMessages::HandleClientTradeCancel(RakNet::BitStream* inStream, Entity* void GameMessages::HandleClientTradeAccept(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { bool bFirst = inStream->ReadBit(); - Game::logger->Log("GameMessages", "Trade accepted from (%llu) -> (%d)", entity->GetObjectID(), bFirst); + LOG("Trade accepted from (%llu) -> (%d)", entity->GetObjectID(), bFirst); auto* trade = TradingManager::Instance()->GetPlayerTrade(entity->GetObjectID()); @@ -3357,7 +3357,7 @@ void GameMessages::HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* inStream->Read(currency); inStream->Read(itemCount); - Game::logger->Log("GameMessages", "Trade update from (%llu) -> (%llu), (%i)", entity->GetObjectID(), currency, itemCount); + LOG("Trade update from (%llu) -> (%llu), (%i)", entity->GetObjectID(), currency, itemCount); std::vector items{}; @@ -3405,7 +3405,7 @@ void GameMessages::HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* items.push_back({ itemId, lot, unknown2 }); - Game::logger->Log("GameMessages", "Trade item from (%llu) -> (%llu)/(%llu), (%i), (%llu), (%i), (%i)", entity->GetObjectID(), itemId, itemId2, lot, unknown1, unknown2, unknown3); + LOG("Trade item from (%llu) -> (%llu)/(%llu), (%i), (%llu), (%i), (%i)", entity->GetObjectID(), itemId, itemId2, lot, unknown1, unknown2, unknown3); } auto* trade = TradingManager::Instance()->GetPlayerTrade(entity->GetObjectID()); @@ -3848,7 +3848,7 @@ void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity* userData.push_back(character); } - Game::logger->Log("HandleMessageBoxResponse", "Button: %d; LOT: %u identifier: %s; userData: %s", iButton, entity->GetLOT(), GeneralUtils::UTF16ToWTF8(identifier).c_str(), GeneralUtils::UTF16ToWTF8(userData).c_str()); + LOG("Button: %d; LOT: %u identifier: %s; userData: %s", iButton, entity->GetLOT(), GeneralUtils::UTF16ToWTF8(identifier).c_str(), GeneralUtils::UTF16ToWTF8(userData).c_str()); auto* user = UserManager::Instance()->GetUser(sysAddr); @@ -3904,7 +3904,7 @@ void GameMessages::HandleChoiceBoxRespond(RakNet::BitStream* inStream, Entity* e identifier.push_back(character); } - Game::logger->Log("HandleChoiceBoxRespond", "Button: %d; LOT: %u buttonIdentifier: %s; userData: %s", iButton, entity->GetLOT(), GeneralUtils::UTF16ToWTF8(buttonIdentifier).c_str(), GeneralUtils::UTF16ToWTF8(identifier).c_str()); + LOG("Button: %d; LOT: %u buttonIdentifier: %s; userData: %s", iButton, entity->GetLOT(), GeneralUtils::UTF16ToWTF8(buttonIdentifier).c_str(), GeneralUtils::UTF16ToWTF8(identifier).c_str()); auto* user = UserManager::Instance()->GetUser(sysAddr); @@ -4084,10 +4084,10 @@ void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Enti void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { auto* moduleAssemblyComponent = entity->GetComponent(); - Game::logger->Log("HandleModuleAssemblyQueryData", "Got Query from %i", entity->GetLOT()); + LOG("Got Query from %i", entity->GetLOT()); if (moduleAssemblyComponent != nullptr) { - Game::logger->Log("HandleModuleAssemblyQueryData", "Returning assembly %s", GeneralUtils::UTF16ToWTF8(moduleAssemblyComponent->GetAssemblyPartsLOTs()).c_str()); + LOG("Returning assembly %s", GeneralUtils::UTF16ToWTF8(moduleAssemblyComponent->GetAssemblyPartsLOTs()).c_str()); SendModuleAssemblyDBDataForClient(entity->GetObjectID(), moduleAssemblyComponent->GetSubKey(), moduleAssemblyComponent->GetAssemblyPartsLOTs(), UNASSIGNED_SYSTEM_ADDRESS); } @@ -4170,7 +4170,7 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, auto* racingControlComponent = zoneController->GetComponent(); - Game::logger->Log("HandleRequestDie", "Got die request: %i", entity->GetLOT()); + LOG("Got die request: %i", entity->GetLOT()); if (racingControlComponent != nullptr) { auto* possessableComponent = entity->GetComponent(); @@ -4213,7 +4213,7 @@ void GameMessages::HandleRacingPlayerInfoResetFinished(RakNet::BitStream* inStre auto* racingControlComponent = zoneController->GetComponent(); - Game::logger->Log("HandleRacingPlayerInfoResetFinished", "Got finished: %i", entity->GetLOT()); + LOG("Got finished: %i", entity->GetLOT()); if (racingControlComponent != nullptr) { racingControlComponent->OnRacingPlayerInfoResetFinished(player); @@ -4720,7 +4720,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti if (!inv) return; if (!isCommendationVendor && !vend->SellsItem(item)) { - Game::logger->Log("GameMessages", "User %llu %s tried to buy an item %i from a vendor when they do not sell said item", player->GetObjectID(), user->GetUsername().c_str(), item); + LOG("User %llu %s tried to buy an item %i from a vendor when they do not sell said item", player->GetObjectID(), user->GetUsername().c_str(), item); return; } @@ -4974,7 +4974,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity mapId = Game::zoneManager->GetZoneID().GetMapID(); // Fallback to sending the player back to the same zone. } - Game::logger->Log("FireEventServerSide", "Player %llu has requested zone transfer to (%i, %i).", sender->GetObjectID(), (int)mapId, (int)cloneId); + LOG("Player %llu has requested zone transfer to (%i, %i).", sender->GetObjectID(), (int)mapId, (int)cloneId); auto* character = player->GetCharacter(); @@ -4983,7 +4983,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity } ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, mapId, cloneId, false, [=](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) { - Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); + LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); if (character) { character->SetZoneID(zoneID); @@ -5033,7 +5033,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, Entity* interactedObject = Game::entityManager->GetEntity(objectID); if (interactedObject == nullptr) { - Game::logger->Log("GameMessages", "Object %llu tried to interact, but doesn't exist!", objectID); + LOG("Object %llu tried to interact, but doesn't exist!", objectID); return; } @@ -5072,7 +5072,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity) inStream->Read(emoteID); inStream->Read(targetID); - Game::logger->LogDebug("GameMessages", "Emote (%i) (%llu)", emoteID, targetID); + LOG_DEBUG("Emote (%i) (%llu)", emoteID, targetID); //TODO: If targetID != 0, and we have one of the "perform emote" missions, complete them. @@ -5085,14 +5085,14 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity) if (targetID != LWOOBJID_EMPTY) { auto* targetEntity = Game::entityManager->GetEntity(targetID); - Game::logger->LogDebug("GameMessages", "Emote target found (%d)", targetEntity != nullptr); + LOG_DEBUG("Emote target found (%d)", targetEntity != nullptr); if (targetEntity != nullptr) { targetEntity->OnEmoteReceived(emoteID, entity); missionComponent->Progress(eMissionTaskType::EMOTE, emoteID, targetID); } } else { - Game::logger->LogDebug("GameMessages", "Target ID is empty, using backup"); + LOG_DEBUG("Target ID is empty, using backup"); const auto scriptedEntities = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT); const auto& referencePoint = entity->GetPosition(); @@ -5168,7 +5168,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e MissionComponent* missionComponent = static_cast(entity->GetComponent(eReplicaComponentType::MISSION)); if (!missionComponent) { - Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle RespondToMission", playerID); + LOG("Unable to get mission component for entity %llu to handle RespondToMission", playerID); return; } @@ -5176,13 +5176,13 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e if (mission) { mission->SetReward(reward); } else { - Game::logger->Log("GameMessages", "Unable to get mission %i for entity %llu to update reward in RespondToMission", missionID, playerID); + LOG("Unable to get mission %i for entity %llu to update reward in RespondToMission", missionID, playerID); } Entity* offerer = Game::entityManager->GetEntity(receiverID); if (offerer == nullptr) { - Game::logger->Log("GameMessages", "Unable to get receiver entity %llu for RespondToMission", receiverID); + LOG("Unable to get receiver entity %llu for RespondToMission", receiverID); return; } @@ -5211,7 +5211,7 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* en // Get the player's mission component MissionComponent* missionComponent = static_cast(player->GetComponent(eReplicaComponentType::MISSION)); if (!missionComponent) { - Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle MissionDialogueOK", player->GetObjectID()); + LOG("Unable to get mission component for entity %llu to handle MissionDialogueOK", player->GetObjectID()); return; } @@ -5564,7 +5564,7 @@ void GameMessages::HandleBuildModeSet(RakNet::BitStream* inStream, Entity* entit inStream->Read(bStart); // there's more here but we don't need it (for now?) - Game::logger->Log("GameMessages", "Set build mode to (%d) for (%llu)", bStart, entity->GetObjectID()); + LOG("Set build mode to (%d) for (%llu)", bStart, entity->GetObjectID()); if (entity->GetCharacter()) { entity->GetCharacter()->SetBuildMode(bStart); @@ -5579,7 +5579,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* InventoryComponent* inv = static_cast(character->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; - Game::logger->Log("GameMessages", "Build finished"); + LOG("Build finished"); GameMessages::SendFinishArrangingWithItem(character, entity->GetObjectID()); // kick them from modular build GameMessages::SendModularBuildEnd(character); // i dont know if this does anything but DLUv2 did it @@ -5708,7 +5708,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti inStream->Read(oldItemTYPE); /* - Game::logger->Log("GameMessages", + LOG("GameMessages", "\nnewSourceBAG: %d\nnewSourceID: %llu\nnewSourceLOT: %d\nnewSourceTYPE: %d\nnewTargetID: %llu\nnewTargetLOT: %d\nnewTargetTYPE: %d\nnewTargetPOS: %f, %f, %f\noldItemBAG: %d\noldItemID: %llu\noldItemLOT: %d\noldItemTYPE: %d", newSourceBAG, newSourceID, newSourceLOT, newSourceTYPE, newTargetID, newTargetLOT, newTargetTYPE, newTargetPOS.x, newTargetPOS.y, newTargetPOS.z, oldItemBAG, oldItemID, oldItemLOT, oldItemTYPE ); @@ -5726,14 +5726,14 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti } else if (!entities.empty()) { buildArea = entities[0]; - Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque"); + LOG("Using PropertyPlaque"); } else { - Game::logger->Log("BuildBorderComponent", "No build area found"); + LOG("No build area found"); return; } - Game::logger->Log("GameMessages", "Build area found: %llu", buildArea->GetObjectID()); + LOG("Build area found: %llu", buildArea->GetObjectID()); GameMessages::SendStartArrangingWithItem( character, @@ -5752,7 +5752,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti ); } - Game::logger->Log("GameMessages", "Done Arranging"); + LOG("Done Arranging"); //GenericInventory* models = inv->GetGenericInventory(MODELS); //GenericInventory* tempModels = inv->GetGenericInventory(TEMP_MODELS); @@ -5776,7 +5776,7 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E Entity* character = Game::entityManager->GetEntity(user->GetLoggedInChar()); if (!character) return; - Game::logger->Log("GameMessages", "Build and move"); + LOG("Build and move"); LOT templateID; @@ -6036,7 +6036,7 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity) insertBug->execute(); delete insertBug; } catch (sql::SQLException& e) { - Game::logger->Log("HandleReportBug", "Couldn't save bug report! (%s)", e.what()); + LOG("Couldn't save bug report! (%s)", e.what()); } } @@ -6228,7 +6228,7 @@ void GameMessages::HandleAddDonationItem(RakNet::BitStream* inStream, Entity* en auto* donationVendorComponent = entity->GetComponent(); if (!donationVendorComponent) return; if (donationVendorComponent->GetActivityID() == 0) { - Game::logger->Log("GameMessages", "WARNING: Trying to dontate to a vendor with no activity"); + LOG("WARNING: Trying to dontate to a vendor with no activity"); return; } User* user = UserManager::Instance()->GetUser(sysAddr); @@ -6283,7 +6283,7 @@ void GameMessages::HandleConfirmDonationOnPlayer(RakNet::BitStream* inStream, En auto* donationVendorComponent = donationEntity->GetComponent(); if (!donationVendorComponent) return; if (donationVendorComponent->GetActivityID() == 0) { - Game::logger->Log("GameMessages", "WARNING: Trying to dontate to a vendor with no activity"); + LOG("WARNING: Trying to dontate to a vendor with no activity"); return; } auto* inventory = inventoryComponent->GetInventory(eInventoryType::DONATION); diff --git a/dGame/dGameMessages/PropertyDataMessage.cpp b/dGame/dGameMessages/PropertyDataMessage.cpp index c3443f31..e39cfeca 100644 --- a/dGame/dGameMessages/PropertyDataMessage.cpp +++ b/dGame/dGameMessages/PropertyDataMessage.cpp @@ -3,7 +3,7 @@ #include "GeneralUtils.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "CDClientManager.h" #include "CDPropertyTemplateTable.h" diff --git a/dGame/dInventory/Inventory.cpp b/dGame/dInventory/Inventory.cpp index 3d2c82ae..4475f77b 100644 --- a/dGame/dInventory/Inventory.cpp +++ b/dGame/dInventory/Inventory.cpp @@ -194,7 +194,7 @@ void Inventory::AddManagedItem(Item* item) { const auto id = item->GetId(); if (items.find(id) != items.end()) { - Game::logger->Log("Inventory", "Attempting to add an item with an already present id (%llu)!", id); + LOG("Attempting to add an item with an already present id (%llu)!", id); return; } @@ -204,7 +204,7 @@ void Inventory::AddManagedItem(Item* item) { const auto slot = item->GetSlot(); if (slots.find(slot) != slots.end()) { - Game::logger->Log("Inventory", "Attempting to add an item with an already present slot (%i)!", slot); + LOG("Attempting to add an item with an already present slot (%i)!", slot); return; } @@ -218,7 +218,7 @@ void Inventory::RemoveManagedItem(Item* item) { const auto id = item->GetId(); if (items.find(id) == items.end()) { - Game::logger->Log("Inventory", "Attempting to remove an item with an invalid id (%llu), lot (%i)!", id, item->GetLot()); + LOG("Attempting to remove an item with an invalid id (%llu), lot (%i)!", id, item->GetLot()); return; } @@ -282,7 +282,7 @@ const CDItemComponent& Inventory::FindItemComponent(const LOT lot) { const auto componentId = registry->GetByIDAndType(lot, eReplicaComponentType::ITEM); if (componentId == 0) { - Game::logger->Log("Inventory", "Failed to find item component for (%i)!", lot); + LOG("Failed to find item component for (%i)!", lot); return CDItemComponentTable::Default; } diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index e55df9d2..3b12f8b3 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -7,7 +7,7 @@ #include "GameMessages.h" #include "Entity.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "EntityManager.h" #include "RenderComponent.h" #include "PossessableComponent.h" @@ -98,7 +98,7 @@ Item::Item( if (isModMoveAndEquip) { Equip(); - Game::logger->Log("Item", "Move and equipped (%i) from (%i)", this->lot, this->inventory->GetType()); + LOG("Move and equipped (%i) from (%i)", this->lot, this->inventory->GetType()); Game::entityManager->SerializeEntity(inventory->GetComponent()->GetParent()); } @@ -260,7 +260,7 @@ bool Item::Consume() { } } - Game::logger->LogDebug("Item", "Consumed LOT (%i) itemID (%llu). Success=(%d)", lot, id, success); + LOG_DEBUG("Consumed LOT (%i) itemID (%llu). Success=(%d)", lot, id, success); GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success); @@ -274,19 +274,19 @@ bool Item::Consume() { void Item::UseNonEquip(Item* item) { LOT thisLot = this->GetLot(); if (!GetInventory()) { - Game::logger->LogDebug("Item", "item %i has no inventory??", this->GetLot()); + LOG_DEBUG("item %i has no inventory??", this->GetLot()); return; } auto* playerInventoryComponent = GetInventory()->GetComponent(); if (!playerInventoryComponent) { - Game::logger->LogDebug("Item", "no inventory component attached to item id %llu lot %i", this->GetId(), this->GetLot()); + LOG_DEBUG("no inventory component attached to item id %llu lot %i", this->GetId(), this->GetLot()); return; } auto* playerEntity = playerInventoryComponent->GetParent(); if (!playerEntity) { - Game::logger->LogDebug("Item", "no player entity attached to inventory? item id is %llu", this->GetId()); + LOG_DEBUG("no player entity attached to inventory? item id is %llu", this->GetId()); return; } @@ -346,7 +346,7 @@ void Item::UseNonEquip(Item* item) { } } } - Game::logger->LogDebug("Item", "Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot); + LOG_DEBUG("Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot); GameMessages::SendUseItemResult(playerInventoryComponent->GetParent(), thisLot, success); } } @@ -411,7 +411,7 @@ void Item::DisassembleModel() { auto buffer = Game::assetManager->GetFileAsBuffer(lxfmlPath.c_str()); if (!buffer.m_Success) { - Game::logger->Log("Item", "Failed to load %s to disassemble model into bricks, check that this file exists", lxfmlPath.c_str()); + LOG("Failed to load %s to disassemble model into bricks, check that this file exists", lxfmlPath.c_str()); return; } diff --git a/dGame/dInventory/Item.h b/dGame/dInventory/Item.h index be2359ef..16f85feb 100644 --- a/dGame/dInventory/Item.h +++ b/dGame/dInventory/Item.h @@ -4,7 +4,7 @@ #include "Inventory.h" #include "LDFFormat.h" #include "CDClientManager.h" -#include "dLogger.h" +#include "Logger.h" #include "Preconditions.h" #include "eInventoryType.h" #include "eLootSourceType.h" diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 085fc38b..c190ec50 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -13,7 +13,7 @@ #include "Mail.h" #include "MissionComponent.h" #include "eRacingTaskParam.h" -#include "dLogger.h" +#include "Logger.h" #include "dServer.h" #include "dZoneManager.h" #include "InventoryComponent.h" @@ -46,7 +46,7 @@ Mission::Mission(MissionComponent* missionComponent, const uint32_t missionId) { info = *mis; if (mis == &CDMissionsTable::Default) { - Game::logger->Log("Missions", "Failed to find mission (%i)!", missionId); + LOG("Failed to find mission (%i)!", missionId); return; } diff --git a/dGame/dMission/MissionPrerequisites.cpp b/dGame/dMission/MissionPrerequisites.cpp index 8dab9a2d..89d547fd 100644 --- a/dGame/dMission/MissionPrerequisites.cpp +++ b/dGame/dMission/MissionPrerequisites.cpp @@ -4,7 +4,7 @@ #include #include "CDClientManager.h" -#include "dLogger.h" +#include "Logger.h" PrerequisiteExpression::PrerequisiteExpression(const std::string& str) { diff --git a/dGame/dMission/MissionTask.cpp b/dGame/dMission/MissionTask.cpp index 997fd34e..604276ec 100644 --- a/dGame/dMission/MissionTask.cpp +++ b/dGame/dMission/MissionTask.cpp @@ -3,7 +3,7 @@ #include "MissionTask.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "Mission.h" #include "Character.h" #include "dServer.h" @@ -233,7 +233,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& entity = Game::entityManager->GetEntity(associate); if (entity == nullptr) { if (associate != LWOOBJID_EMPTY) { - Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!", associate); + LOG("Failed to find associated entity (%llu)!", associate); } break; } @@ -275,7 +275,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& entity = Game::entityManager->GetEntity(associate); if (entity == nullptr) { - Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!", associate); + LOG("Failed to find associated entity (%llu)!", associate); break; } @@ -349,7 +349,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& entity = Game::entityManager->GetEntity(associate); if (entity == nullptr) { - Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!", associate); + LOG("Failed to find associated entity (%llu)!", associate); break; } @@ -453,7 +453,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& AddProgress(count); break; default: - Game::logger->Log("MissionTask", "Invalid mission task type (%i)!", static_cast(type)); + LOG("Invalid mission task type (%i)!", static_cast(type)); return; } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp index 98672909..36d9a3dc 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp @@ -9,5 +9,5 @@ AddActionMessage::AddActionMessage(AMFArrayValue* arguments) : BehaviorMessageBa action = Action(actionValue); - Game::logger->LogDebug("AddActionMessage", "actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i", actionIndex, actionContext.GetStripId(), actionContext.GetStateId(), action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId); + LOG_DEBUG("actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i", actionIndex, actionContext.GetStripId(), actionContext.GetStateId(), action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp index badee2c2..cf96ab13 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp @@ -7,5 +7,5 @@ AddMessage::AddMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments if (!behaviorIndexValue) return; behaviorIndex = static_cast(behaviorIndexValue->GetValue()); - Game::logger->LogDebug("AddMessage", "behaviorId %i index %i", behaviorId, behaviorIndex); + LOG_DEBUG("behaviorId %i index %i", behaviorId, behaviorIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp index 261b3462..5e75f6c4 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp @@ -18,7 +18,7 @@ AddStripMessage::AddStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase actionsToAdd.push_back(Action(actionValue)); - Game::logger->LogDebug("AddStripMessage", "xPosition %f yPosition %f stripId %i stateId %i behaviorId %i t %s valueParameterName %s valueParameterString %s valueParameterDouble %f", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId, actionsToAdd.back().GetType().c_str(), actionsToAdd.back().GetValueParameterName().c_str(), actionsToAdd.back().GetValueParameterString().c_str(), actionsToAdd.back().GetValueParameterDouble()); + LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %i t %s valueParameterName %s valueParameterString %s valueParameterDouble %f", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId, actionsToAdd.back().GetType().c_str(), actionsToAdd.back().GetValueParameterName().c_str(), actionsToAdd.back().GetValueParameterString().c_str(), actionsToAdd.back().GetValueParameterDouble()); } - Game::logger->Log("AddStripMessage", "number of actions %i", actionsToAdd.size()); + LOG_DEBUG("number of actions %i", actionsToAdd.size()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h index 8771286c..39246c9d 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h @@ -8,7 +8,7 @@ #include "dCommonVars.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" enum class BehaviorState : uint32_t; diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp index df50641a..18327ecf 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp @@ -6,6 +6,6 @@ MergeStripsMessage::MergeStripsMessage(AMFArrayValue* arguments) : BehaviorMessa destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID"); dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex"); - Game::logger->LogDebug("MergeStripsMessage", "srcstripId %i dststripId %i srcstateId %i dststateId %i dstactionIndex %i behaviorId %i", sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), dstActionIndex, behaviorId); + LOG_DEBUG("srcstripId %i dststripId %i srcstateId %i dststateId %i dstactionIndex %i behaviorId %i", sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), dstActionIndex, behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp index 08f830a4..4d45429b 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp @@ -7,5 +7,5 @@ MigrateActionsMessage::MigrateActionsMessage(AMFArrayValue* arguments) : Behavio destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID"); dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex"); - Game::logger->LogDebug("MigrateActionsMessage", "srcactionIndex %i dstactionIndex %i srcstripId %i dststripId %i srcstateId %i dststateId %i behaviorId %i", srcActionIndex, dstActionIndex, sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), behaviorId); + LOG_DEBUG("srcactionIndex %i dstactionIndex %i srcstripId %i dststripId %i srcstateId %i dststateId %i behaviorId %i", srcActionIndex, dstActionIndex, sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp index 5b61ee32..5195e676 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp @@ -5,5 +5,5 @@ MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) : Behav if (!behaviorIndexValue) return; behaviorIndex = static_cast(behaviorIndexValue->GetValue()); - Game::logger->LogDebug("MoveToInventoryMessage", "behaviorId %i behaviorIndex %i", behaviorId, behaviorIndex); + LOG_DEBUG("behaviorId %i behaviorIndex %i", behaviorId, behaviorIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp index 4018a423..d612ae2a 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp @@ -6,5 +6,5 @@ RearrangeStripMessage::RearrangeStripMessage(AMFArrayValue* arguments) : Behavio dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex"); - Game::logger->LogDebug("RearrangeStripMessage", "srcactionIndex %i dstactionIndex %i stripId %i behaviorId %i stateId %i", srcActionIndex, dstActionIndex, actionContext.GetStripId(), behaviorId, actionContext.GetStateId()); + LOG_DEBUG("srcactionIndex %i dstactionIndex %i stripId %i behaviorId %i stateId %i", srcActionIndex, dstActionIndex, actionContext.GetStripId(), behaviorId, actionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp index 8f00d2b0..c6164c6f 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp @@ -4,5 +4,5 @@ RemoveActionsMessage::RemoveActionsMessage(AMFArrayValue* arguments) : BehaviorM actionContext = ActionContext(arguments); actionIndex = GetActionIndexFromArgument(arguments); - Game::logger->LogDebug("RemoveActionsMessage", "behaviorId %i actionIndex %i stripId %i stateId %i", behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId()); + LOG_DEBUG("behaviorId %i actionIndex %i stripId %i stateId %i", behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp index 40288b07..b70beece 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp @@ -3,5 +3,5 @@ RemoveStripMessage::RemoveStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { actionContext = ActionContext(arguments); - Game::logger->LogDebug("RemoveStripMessage", "stripId %i stateId %i behaviorId %i", actionContext.GetStripId(), actionContext.GetStateId(), behaviorId); + LOG_DEBUG("stripId %i stateId %i behaviorId %i", actionContext.GetStripId(), actionContext.GetStateId(), behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp index a1c2abbc..17365be2 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp @@ -5,5 +5,5 @@ RenameMessage::RenameMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arg if (!nameAmf) return; name = nameAmf->GetValue(); - Game::logger->LogDebug("RenameMessage", "behaviorId %i n %s", behaviorId, name.c_str()); + LOG_DEBUG("behaviorId %i n %s", behaviorId, name.c_str()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp index b4601a17..45dad737 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp @@ -7,5 +7,5 @@ SplitStripMessage::SplitStripMessage(AMFArrayValue* arguments) : BehaviorMessage destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID"); destinationPosition = StripUiPosition(arguments, "dstStripUI"); - Game::logger->LogDebug("SplitStripMessage", "behaviorId %i xPosition %f yPosition %f sourceStrip %i destinationStrip %i sourceState %i destinationState %i srcActindex %i", behaviorId, destinationPosition.GetX(), destinationPosition.GetY(), sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), srcActionIndex); + LOG_DEBUG("behaviorId %i xPosition %f yPosition %f sourceStrip %i destinationStrip %i sourceState %i destinationState %i srcActindex %i", behaviorId, destinationPosition.GetX(), destinationPosition.GetY(), sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), srcActionIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp index 23a0050d..924a9e62 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp @@ -11,5 +11,5 @@ UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) : BehaviorMes action = Action(actionValue); actionIndex = GetActionIndexFromArgument(arguments); - Game::logger->LogDebug("UpdateActionMessage", "type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i actionIndex %i stripId %i stateId %i", action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId()); + LOG_DEBUG("type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i actionIndex %i stripId %i stateId %i", action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp index 073db9b4..05dc7cf7 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp @@ -4,5 +4,5 @@ UpdateStripUiMessage::UpdateStripUiMessage(AMFArrayValue* arguments) : BehaviorM position = StripUiPosition(arguments); actionContext = ActionContext(arguments); - Game::logger->LogDebug("UpdateStripUIMessage", "xPosition %f yPosition %f stripId %i stateId %i behaviorId %i", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId); + LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %i", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index d8a062ca..3dbd777a 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -6,7 +6,7 @@ #include "GameMessages.h" #include "ModelComponent.h" #include "../../dWorldServer/ObjectIDManager.h" -#include "dLogger.h" +#include "Logger.h" #include "BehaviorStates.h" #include "AssetManager.h" #include "BlockDefinition.h" @@ -170,7 +170,7 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent // AMFArrayValue* stateSerialize = new AMFArrayValue(); // for (auto it = states.begin(); it != states.end(); it++) { - // Game::logger->Log("PropertyBehaviors", "Begin serialization of state %i!\n", it->first); + // LOG("Begin serialization of state %i!\n", it->first); // AMFArrayValue* state = new AMFArrayValue(); // AMFDoubleValue* stateAsDouble = new AMFDoubleValue(); @@ -180,7 +180,7 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent // AMFArrayValue* strips = new AMFArrayValue(); // auto stripsInState = it->second->GetStrips(); // for (auto strip = stripsInState.begin(); strip != stripsInState.end(); strip++) { - // Game::logger->Log("PropertyBehaviors", "Begin serialization of strip %i!\n", strip->first); + // LOG("Begin serialization of strip %i!\n", strip->first); // AMFArrayValue* thisStrip = new AMFArrayValue(); // AMFDoubleValue* stripID = new AMFDoubleValue(); @@ -202,7 +202,7 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent // AMFArrayValue* stripSerialize = new AMFArrayValue(); // for (auto behaviorAction : strip->second->GetActions()) { - // Game::logger->Log("PropertyBehaviors", "Begin serialization of action %s!\n", behaviorAction->actionName.c_str()); + // LOG("Begin serialization of action %s!\n", behaviorAction->actionName.c_str()); // AMFArrayValue* thisAction = new AMFArrayValue(); // AMFStringValue* actionName = new AMFStringValue(); @@ -247,20 +247,20 @@ void ControlBehaviors::UpdateAction(AMFArrayValue* arguments) { auto* blockDefinition = GetBlockInfo(updateActionMessage.GetAction().GetType()); if (!blockDefinition) { - Game::logger->Log("ControlBehaviors", "Received undefined block type %s. Ignoring.", updateActionMessage.GetAction().GetType().c_str()); + LOG("Received undefined block type %s. Ignoring.", updateActionMessage.GetAction().GetType().c_str()); return; } if (updateActionMessage.GetAction().GetValueParameterString().size() > 0) { if (updateActionMessage.GetAction().GetValueParameterString().size() < blockDefinition->GetMinimumValue() || updateActionMessage.GetAction().GetValueParameterString().size() > blockDefinition->GetMaximumValue()) { - Game::logger->Log("ControlBehaviors", "Updated block %s is out of range. Ignoring update", updateActionMessage.GetAction().GetType().c_str()); + LOG("Updated block %s is out of range. Ignoring update", updateActionMessage.GetAction().GetType().c_str()); return; } } else { if (updateActionMessage.GetAction().GetValueParameterDouble() < blockDefinition->GetMinimumValue() || updateActionMessage.GetAction().GetValueParameterDouble() > blockDefinition->GetMaximumValue()) { - Game::logger->Log("ControlBehaviors", "Updated block %s is out of range. Ignoring update", updateActionMessage.GetAction().GetType().c_str()); + LOG("Updated block %s is out of range. Ignoring update", updateActionMessage.GetAction().GetType().c_str()); return; } } @@ -320,18 +320,18 @@ void ControlBehaviors::ProcessCommand(Entity* modelEntity, const SystemAddress& else if (command == "updateAction") UpdateAction(arguments); else - Game::logger->Log("ControlBehaviors", "Unknown behavior command (%s)\n", command.c_str()); + LOG("Unknown behavior command (%s)\n", command.c_str()); } ControlBehaviors::ControlBehaviors() { auto blocksDefStreamBuffer = Game::assetManager->GetFileAsBuffer("ui\\ingame\\blocksdef.xml"); if (!blocksDefStreamBuffer.m_Success) { - Game::logger->Log("ControlBehaviors", "failed to open blocksdef"); + LOG("failed to open blocksdef"); return; } std::istream blocksBuffer(&blocksDefStreamBuffer); if (!blocksBuffer.good()) { - Game::logger->Log("ControlBehaviors", "Blocks buffer is not good!"); + LOG("Blocks buffer is not good!"); return; } @@ -356,14 +356,14 @@ ControlBehaviors::ControlBehaviors() { auto ret = m_Doc.Parse(buffer.c_str()); if (ret == tinyxml2::XML_SUCCESS) { - Game::logger->LogDebug("ControlBehaviors", "Successfully parsed the blocksdef file!"); + LOG_DEBUG("Successfully parsed the blocksdef file!"); } else { - Game::logger->Log("Character", "Failed to parse BlocksDef xmlData due to error %i!", ret); + LOG("Failed to parse BlocksDef xmlData due to error %i!", ret); return; } auto* blockLibrary = m_Doc.FirstChildElement(); if (!blockLibrary) { - Game::logger->Log("ControlBehaviors", "No Block Library child element found."); + LOG("No Block Library child element found."); return; } @@ -413,13 +413,13 @@ ControlBehaviors::ControlBehaviors() { } else { values = argument->FirstChildElement("EnumerationSource"); if (!values) { - Game::logger->Log("ControlBehaviors", "Failed to parse EnumerationSource from block (%s)", blockName.c_str()); + LOG("Failed to parse EnumerationSource from block (%s)", blockName.c_str()); continue; } auto* serviceNameNode = values->FirstChildElement("ServiceName"); if (!serviceNameNode) { - Game::logger->Log("ControlBehaviors", "Failed to parse ServiceName from block (%s)", blockName.c_str()); + LOG("Failed to parse ServiceName from block (%s)", blockName.c_str()); continue; } @@ -429,12 +429,12 @@ ControlBehaviors::ControlBehaviors() { blockDefinition->SetMaximumValue(res.getIntField("countSounds")); blockDefinition->SetDefaultValue("0"); } else { - Game::logger->Log("ControlBehaviors", "Unsupported Enumeration ServiceType (%s)", serviceName.c_str()); + LOG("Unsupported Enumeration ServiceType (%s)", serviceName.c_str()); continue; } } } else { - Game::logger->Log("ControlBehaviors", "Unsupported block value type (%s)!", typeName.c_str()); + LOG("Unsupported block value type (%s)!", typeName.c_str()); continue; } } @@ -444,9 +444,9 @@ ControlBehaviors::ControlBehaviors() { blockSections = blockSections->NextSiblingElement(); } isInitialized = true; - Game::logger->LogDebug("ControlBehaviors", "Created all base block classes"); + LOG_DEBUG("Created all base block classes"); for (auto b : blockTypes) { - Game::logger->LogDebug("ControlBehaviors", "block name is %s default %s min %f max %f", b.first.c_str(), b.second->GetDefaultValue().c_str(), b.second->GetMinimumValue(), b.second->GetMaximumValue()); + LOG_DEBUG("block name is %s default %s min %f max %f", b.first.c_str(), b.second->GetDefaultValue().c_str(), b.second->GetMinimumValue(), b.second->GetMaximumValue()); } } diff --git a/dGame/dUtilities/CheatDetection.cpp b/dGame/dUtilities/CheatDetection.cpp index 11a68263..9e1f597c 100644 --- a/dGame/dUtilities/CheatDetection.cpp +++ b/dGame/dUtilities/CheatDetection.cpp @@ -24,7 +24,7 @@ Entity* GetPossessedEntity(const LWOOBJID& objId) { void ReportCheat(User* user, const SystemAddress& sysAddr, const char* messageIfNotSender, va_list args) { if (!user) { - Game::logger->Log("CheatDetection", "WARNING: User is null, using defaults."); + LOG("WARNING: User is null, using defaults."); } std::unique_ptr stmt(Database::CreatePreppedStmt( "INSERT INTO player_cheat_detections (account_id, name, violation_msg, violation_system_address) VALUES (?, ?, ?, ?)") @@ -39,7 +39,7 @@ void ReportCheat(User* user, const SystemAddress& sysAddr, const char* messageIf stmt->setString(3, buffer); stmt->setString(4, Game::config->GetValue("log_ip_addresses_for_anti_cheat") == "1" ? sysAddr.ToString() : "IP logging disabled."); stmt->execute(); - Game::logger->Log("CheatDetection", "Anti-cheat message: %s", buffer); + LOG("Anti-cheat message: %s", buffer); } void LogAndSaveFailedAntiCheatCheck(const LWOOBJID& id, const SystemAddress& sysAddr, const CheckType checkType, const char* messageIfNotSender, va_list args) { @@ -51,20 +51,20 @@ void LogAndSaveFailedAntiCheatCheck(const LWOOBJID& id, const SystemAddress& sys // If player exists and entity exists in world, use both for logging info. if (entity && player) { - Game::logger->Log("CheatDetection", "Player (%s) (%llu) at system address (%s) with sending player (%s) (%llu) does not match their own.", + LOG("Player (%s) (%llu) at system address (%s) with sending player (%s) (%llu) does not match their own.", player->GetCharacter()->GetName().c_str(), player->GetObjectID(), sysAddr.ToString(), entity->GetCharacter()->GetName().c_str(), entity->GetObjectID()); toReport = player->GetParentUser(); // In the case that the target entity id did not exist, just log the player info. } else if (player) { - Game::logger->Log("CheatDetection", "Player (%s) (%llu) at system address (%s) with sending player (%llu) does not match their own.", + LOG("Player (%s) (%llu) at system address (%s) with sending player (%llu) does not match their own.", player->GetCharacter()->GetName().c_str(), player->GetObjectID(), sysAddr.ToString(), id); toReport = player->GetParentUser(); // In the rare case that the player does not exist, just log the system address and who the target id was. } else { - Game::logger->Log("CheatDetection", "Player at system address (%s) with sending player (%llu) does not match their own.", + LOG("Player at system address (%s) with sending player (%llu) does not match their own.", sysAddr.ToString(), id); } break; @@ -73,11 +73,11 @@ void LogAndSaveFailedAntiCheatCheck(const LWOOBJID& id, const SystemAddress& sys auto* user = UserManager::Instance()->GetUser(sysAddr); if (user) { - Game::logger->Log("CheatDetection", "User at system address (%s) (%s) (%llu) sent a packet as (%i) which is not an id they own.", + LOG("User at system address (%s) (%s) (%llu) sent a packet as (%i) which is not an id they own.", sysAddr.ToString(), user->GetLastUsedChar()->GetName().c_str(), user->GetLastUsedChar()->GetObjectID(), static_cast(id)); // Can't know sending player. Just log system address for IP banning. } else { - Game::logger->Log("CheatDetection", "No user found for system address (%s).", sysAddr.ToString()); + LOG("No user found for system address (%s).", sysAddr.ToString()); } toReport = user; break; @@ -110,7 +110,7 @@ bool CheatDetection::VerifyLwoobjidIsSender(const LWOOBJID& id, const SystemAddr // Check here if the system address has a character with id matching the lwoobjid after unsetting the flag bits. auto* sendingUser = UserManager::Instance()->GetUser(sysAddr); if (!sendingUser) { - Game::logger->Log("CheatDetection", "No user found for system address (%s).", sysAddr.ToString()); + LOG("No user found for system address (%s).", sysAddr.ToString()); return false; } invalidPacket = true; diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index a828efa0..961dc5f6 100644 --- a/dGame/dUtilities/Mail.cpp +++ b/dGame/dUtilities/Mail.cpp @@ -14,7 +14,7 @@ #include "Character.h" #include "PacketUtils.h" #include "BitStreamUtils.h" -#include "dLogger.h" +#include "Logger.h" #include "EntityManager.h" #include "InventoryComponent.h" #include "GameMessages.h" @@ -153,7 +153,7 @@ void Mail::HandleMailStuff(RakNet::BitStream* packet, const SystemAddress& sysAd Mail::HandleSendMail(packet, sysAddr, entity); break; default: - Game::logger->Log("Mail", "Unhandled and possibly undefined MailStuffID: %i", int(stuffID)); + LOG("Unhandled and possibly undefined MailStuffID: %i", int(stuffID)); } }); } @@ -262,10 +262,10 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd Mail::SendSendResponse(sysAddr, Mail::MailSendResponse::Success); entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, eLootSourceType::MAIL); - Game::logger->Log("Mail", "Seeing if we need to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT); + LOG("Seeing if we need to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT); if (inv && itemLOT != 0 && attachmentCount > 0 && item) { - Game::logger->Log("Mail", "Trying to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT); + LOG("Trying to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT); inv->RemoveItem(itemLOT, attachmentCount, INVALID, true); auto* missionCompoent = entity->GetComponent(); diff --git a/dGame/dUtilities/Preconditions.cpp b/dGame/dUtilities/Preconditions.cpp index 8602586c..46ee7c18 100644 --- a/dGame/dUtilities/Preconditions.cpp +++ b/dGame/dUtilities/Preconditions.cpp @@ -1,7 +1,7 @@ #include "Preconditions.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include @@ -28,7 +28,7 @@ Precondition::Precondition(const uint32_t condition) { this->count = 1; this->values = { 0 }; - Game::logger->Log("Precondition", "Failed to find precondition of id (%i)!", condition); + LOG("Failed to find precondition of id (%i)!", condition); return; } diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 17fd980c..af44d543 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -29,7 +29,7 @@ #include "GeneralUtils.h" #include "Entity.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" #include "WorldPackets.h" #include "GameMessages.h" #include "CDClientDatabase.h" @@ -142,7 +142,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit WorldPackets::SendGMLevelChange(sysAddr, success, user->GetMaxGMLevel(), entity->GetGMLevel(), level); GameMessages::SendChatModeUpdate(entity->GetObjectID(), level); entity->SetGMLevel(level); - Game::logger->Log("SlashCommandHandler", "User %s (%i) has changed their GM level to %i for charID %llu", user->GetUsername().c_str(), user->GetAccountID(), level, entity->GetObjectID()); + LOG("User %s (%i) has changed their GM level to %i for charID %llu", user->GetUsername().c_str(), user->GetAccountID(), level, entity->GetObjectID()); } } @@ -179,7 +179,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit auto* character = entity->GetComponent(); if (character == nullptr) { - Game::logger->Log("SlashCommandHandler", "Failed to find character component!"); + LOG("Failed to find character component!"); return; } @@ -263,7 +263,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit args.Insert("visible", true); args.Insert("text", customText); - Game::logger->Log("SlashCommandHandler", "Sending %s", customText.c_str()); + LOG("Sending %s", customText.c_str()); GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", args); }); @@ -297,7 +297,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit const auto sysAddr = entity->GetSystemAddress(); - Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", entity->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); + LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", entity->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); if (entity->GetCharacter()) { entity->GetCharacter()->SetZoneID(zoneID); @@ -316,7 +316,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit const auto& password = args[0]; ZoneInstanceManager::Instance()->RequestPrivateZone(Game::server, false, password, [=](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) { - Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); + LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); if (entity->GetCharacter()) { entity->GetCharacter()->SetZoneID(zoneID); @@ -908,7 +908,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit pos.SetY(y); pos.SetZ(z); - Game::logger->Log("SlashCommandHandler", "Teleporting objectID: %llu to %f, %f, %f", entity->GetObjectID(), pos.x, pos.y, pos.z); + LOG("Teleporting objectID: %llu to %f, %f, %f", entity->GetObjectID(), pos.x, pos.y, pos.z); GameMessages::SendTeleport(entity->GetObjectID(), pos, NiQuaternion(), sysAddr); } else if (args.size() == 2) { @@ -928,7 +928,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit pos.SetY(0.0f); pos.SetZ(z); - Game::logger->Log("SlashCommandHandler", "Teleporting objectID: %llu to X: %f, Z: %f", entity->GetObjectID(), pos.x, pos.z); + LOG("Teleporting objectID: %llu to X: %f, Z: %f", entity->GetObjectID(), pos.x, pos.z); GameMessages::SendTeleport(entity->GetObjectID(), pos, NiQuaternion(), sysAddr); } else { ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /teleport () - if no Y given, will teleport to the height of the terrain (or any physics object)."); @@ -1552,7 +1552,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit ChatPackets::SendSystemMessage(sysAddr, u"Transfering map..."); - Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); + LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort); if (entity->GetCharacter()) { entity->GetCharacter()->SetZoneID(zoneID); entity->GetCharacter()->SetZoneInstance(zoneInstance); @@ -1819,7 +1819,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (!GeneralUtils::TryParse(args[0], inventoryType)) { // In this case, we treat the input as a string and try to find it in the reflection list std::transform(args[0].begin(), args[0].end(), args[0].begin(), ::toupper); - Game::logger->Log("SlashCommandHandler", "looking for inventory %s", args[0].c_str()); + LOG("looking for inventory %s", args[0].c_str()); for (uint32_t index = 0; index < NUMBER_OF_INVENTORIES; index++) { if (std::string_view(args[0]) == std::string_view(InventoryType::InventoryTypeToString(static_cast(index)))) inventoryType = static_cast(index); } @@ -1837,7 +1837,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (!inventoryToDelete) return; inventoryToDelete->DeleteAllItems(); - Game::logger->Log("SlashCommandHandler", "Deleted inventory %s for user %llu", args[0].c_str(), entity->GetObjectID()); + LOG("Deleted inventory %s for user %llu", args[0].c_str(), entity->GetObjectID()); ChatPackets::SendSystemMessage(sysAddr, u"Deleted inventory " + GeneralUtils::UTF8ToUTF16(args[0])); } diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index eb182e04..95436cd3 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -12,7 +12,7 @@ #include "dServer.h" #include "tinyxml2.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "BinaryPathFinder.h" #include "EntityInfo.h" @@ -49,7 +49,7 @@ void VanityUtilities::SpawnVanity() { std::vector npcList = m_NPCs; std::vector taken = {}; - Game::logger->Log("VanityUtilities", "Spawning party with %i locations", party.m_Locations.size()); + LOG("Spawning party with %i locations", party.m_Locations.size()); // Loop through all locations for (const auto& location : party.m_Locations) { @@ -70,7 +70,7 @@ void VanityUtilities::SpawnVanity() { taken.push_back(npcIndex); // Spawn the NPC - Game::logger->Log("VanityUtilities", "ldf size is %i", npc.ldf.size()); + LOG("ldf size is %i", npc.ldf.size()); if (npc.ldf.empty()) { npc.ldf = { new LDFData>(u"syncLDF", { u"custom_script_client" }), @@ -194,7 +194,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* npcs = doc.FirstChildElement("npcs"); if (npcs == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse NPCs"); + LOG("Failed to parse NPCs"); return; } @@ -218,7 +218,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* locations = party->FirstChildElement("locations"); if (locations == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse party locations"); + LOG("Failed to parse party locations"); continue; } @@ -235,7 +235,7 @@ void VanityUtilities::ParseXML(const std::string& file) { if (x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr || rz == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse party location data"); + LOG("Failed to parse party location data"); continue; } @@ -253,7 +253,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* partyPhrases = npcs->FirstChildElement("partyphrases"); if (partyPhrases == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse party phrases"); + LOG("Failed to parse party phrases"); return; } @@ -263,7 +263,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* text = phrase->GetText(); if (text == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse party phrase"); + LOG("Failed to parse party phrase"); continue; } @@ -280,7 +280,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* lot = npc->Attribute("lot"); if (lot == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse NPC lot"); + LOG("Failed to parse NPC lot"); continue; } @@ -314,7 +314,7 @@ void VanityUtilities::ParseXML(const std::string& file) { // Get the phrase auto* text = phrase->GetText(); if (text == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse NPC phrase"); + LOG("Failed to parse NPC phrase"); continue; } phraseList.push_back(text); @@ -367,7 +367,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* name = flag->Attribute("name"); if (name == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse NPC flag name"); + LOG("Failed to parse NPC flag name"); continue; } @@ -375,7 +375,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* value = flag->Attribute("value"); if (value == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse NPC flag value"); + LOG("Failed to parse NPC flag value"); continue; } @@ -389,7 +389,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* zoneID = zone->Attribute("id"); if (zoneID == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse NPC zone ID"); + LOG("Failed to parse NPC zone ID"); continue; } @@ -397,7 +397,7 @@ void VanityUtilities::ParseXML(const std::string& file) { auto* locations = zone->FirstChildElement("locations"); if (locations == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse NPC locations"); + LOG("Failed to parse NPC locations"); continue; } @@ -414,7 +414,7 @@ void VanityUtilities::ParseXML(const std::string& file) { if (x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr || rz == nullptr) { - Game::logger->Log("VanityUtilities", "Failed to parse NPC location data"); + LOG("Failed to parse NPC location data"); continue; } @@ -478,8 +478,10 @@ std::string VanityUtilities::ParseMarkdown(const std::string& file) { while (std::getline(ss, line)) { #define TOSTRING(x) #x -#define STRINGIFY(x) TOSTRING(x) +#ifndef STRINGIFY +#define STRINGIFY(x) TOSTRING(x) +#endif // Replace "__TIMESTAMP__" with the __TIMESTAMP__ GeneralUtils::ReplaceInString(line, "__TIMESTAMP__", __TIMESTAMP__); // Replace "__VERSION__" wit'h the PROJECT_VERSION diff --git a/dMasterServer/InstanceManager.cpp b/dMasterServer/InstanceManager.cpp index 9ef3077a..28ee37b5 100644 --- a/dMasterServer/InstanceManager.cpp +++ b/dMasterServer/InstanceManager.cpp @@ -2,7 +2,7 @@ #include #include "Game.h" #include "dServer.h" -#include "dLogger.h" +#include "Logger.h" #include "dConfig.h" #include "CDClientDatabase.h" #include "CDClientManager.h" @@ -13,7 +13,7 @@ #include "eConnectionType.h" #include "eMasterMessageType.h" -InstanceManager::InstanceManager(dLogger* logger, const std::string& externalIP) { +InstanceManager::InstanceManager(Logger* logger, const std::string& externalIP) { mLogger = logger; mExternalIP = externalIP; m_LastPort = std::atoi(Game::config->GetValue("world_port_start").c_str()); @@ -28,14 +28,13 @@ InstanceManager::~InstanceManager() { } Instance* InstanceManager::GetInstance(LWOMAPID mapID, bool isFriendTransfer, LWOCLONEID cloneID) { - mLogger->Log("InstanceManager", "Searching for an instance for mapID %i/%i", mapID, cloneID); + LOG("Searching for an instance for mapID %i/%i", mapID, cloneID); Instance* instance = FindInstance(mapID, isFriendTransfer, cloneID); if (instance) return instance; // If we are shutting down, return a nullptr so a new instance is not created. if (m_IsShuttingDown) { - Game::logger->Log("InstanceManager", - "Tried to create a new instance map/instance/clone %i/%i/%i, but Master is shutting down.", + LOG("Tried to create a new instance map/instance/clone %i/%i/%i, but Master is shutting down.", mapID, m_LastInstanceID + 1, cloneID); @@ -89,9 +88,9 @@ Instance* InstanceManager::GetInstance(LWOMAPID mapID, bool isFriendTransfer, LW m_Instances.push_back(instance); if (instance) { - mLogger->Log("InstanceManager", "Created new instance: %i/%i/%i with min/max %i/%i", mapID, m_LastInstanceID, cloneID, softCap, maxPlayers); + LOG("Created new instance: %i/%i/%i with min/max %i/%i", mapID, m_LastInstanceID, cloneID, softCap, maxPlayers); return instance; - } else mLogger->Log("InstanceManager", "Failed to create a new instance!"); + } else LOG("Failed to create a new instance!"); return nullptr; } @@ -179,7 +178,7 @@ void InstanceManager::ReadyInstance(Instance* instance) { for (const auto& request : pending) { const auto& zoneId = instance->GetZoneID(); - Game::logger->Log("InstanceManager", "Responding to pending request %llu -> %i (%i)", request, zoneId.GetMapID(), zoneId.GetCloneID()); + LOG("Responding to pending request %llu -> %i (%i)", request, zoneId.GetMapID(), zoneId.GetCloneID()); MasterPackets::SendZoneTransferResponse( Game::server, @@ -208,7 +207,7 @@ void InstanceManager::RequestAffirmation(Instance* instance, const PendingInstan Game::server->Send(&bitStream, instance->GetSysAddr(), false); - Game::logger->Log("MasterServer", "Sent affirmation request %llu to %i/%i", request.id, + LOG("Sent affirmation request %llu to %i/%i", request.id, static_cast(instance->GetZoneID().GetMapID()), static_cast(instance->GetZoneID().GetCloneID()) ); @@ -306,8 +305,7 @@ Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID clon } if (m_IsShuttingDown) { - Game::logger->Log("InstanceManager", - "Tried to create a new private instance map/instance/clone %i/%i/%i, but Master is shutting down.", + LOG("Tried to create a new private instance map/instance/clone %i/%i/%i, but Master is shutting down.", mapID, m_LastInstanceID + 1, cloneID); @@ -346,7 +344,7 @@ Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID clon m_Instances.push_back(instance); if (instance) return instance; - else mLogger->Log("InstanceManager", "Failed to create a new instance!"); + else LOG("Failed to create a new instance!"); return instance; } @@ -359,7 +357,7 @@ Instance* InstanceManager::FindPrivateInstance(const std::string& password) { continue; } - mLogger->Log("InstanceManager", "Password: %s == %s => %d", password.c_str(), instance->GetPassword().c_str(), password == instance->GetPassword()); + LOG("Password: %s == %s => %d", password.c_str(), instance->GetPassword().c_str(), password == instance->GetPassword()); if (instance->GetPassword() == password) { return instance; @@ -410,5 +408,5 @@ void Instance::Shutdown() { Game::server->Send(&bitStream, this->m_SysAddr, false); - Game::logger->Log("Instance", "Triggered world shutdown for zone/clone/instance %i/%i/%i", GetMapID(), GetCloneID(), GetInstanceID()); + LOG("Triggered world shutdown for zone/clone/instance %i/%i/%i", GetMapID(), GetCloneID(), GetInstanceID()); } diff --git a/dMasterServer/InstanceManager.h b/dMasterServer/InstanceManager.h index 5f48f93b..a665a7d3 100644 --- a/dMasterServer/InstanceManager.h +++ b/dMasterServer/InstanceManager.h @@ -3,7 +3,7 @@ #include "dCommonVars.h" #include "RakNetTypes.h" #include "dZMCommon.h" -#include "dLogger.h" +#include "Logger.h" struct Player { LWOOBJID id; @@ -101,7 +101,7 @@ private: class InstanceManager { public: - InstanceManager(dLogger* logger, const std::string& externalIP); + InstanceManager(Logger* logger, const std::string& externalIP); ~InstanceManager(); Instance* GetInstance(LWOMAPID mapID, bool isFriendTransfer, LWOCLONEID cloneID); //Creates an instance if none found @@ -131,7 +131,7 @@ public: void SetIsShuttingDown(bool value) { this->m_IsShuttingDown = value; }; private: - dLogger* mLogger; + Logger* mLogger; std::string mExternalIP; std::vector m_Instances; unsigned short m_LastPort; diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index bf2c1537..0380a89a 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -23,7 +23,7 @@ #include "Diagnostics.h" #include "dCommonVars.h" #include "dConfig.h" -#include "dLogger.h" +#include "Logger.h" #include "dServer.h" #include "AssetManager.h" #include "BinaryPathFinder.h" @@ -45,7 +45,7 @@ #include "BitStreamUtils.h" namespace Game { - dLogger* logger = nullptr; + Logger* logger = nullptr; dServer* server = nullptr; InstanceManager* im = nullptr; dConfig* config = nullptr; @@ -57,7 +57,7 @@ namespace Game { bool shutdownSequenceStarted = false; void ShutdownSequence(int32_t signal = -1); int32_t FinalizeShutdown(int32_t signal = -1); -dLogger* SetupLogger(); +Logger* SetupLogger(); void StartAuthServer(); void StartChatServer(); void HandlePacket(Packet* packet); @@ -86,27 +86,27 @@ int main(int argc, char** argv) { if (!Game::logger) return EXIT_FAILURE; if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "authconfig.ini")) { - Game::logger->Log("MasterServer", "Couldnt find authconfig.ini"); + LOG("Couldnt find authconfig.ini"); return EXIT_FAILURE; } if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "chatconfig.ini")) { - Game::logger->Log("MasterServer", "Couldnt find chatconfig.ini"); + LOG("Couldnt find chatconfig.ini"); return EXIT_FAILURE; } if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "masterconfig.ini")) { - Game::logger->Log("MasterServer", "Couldnt find masterconfig.ini"); + LOG("Couldnt find masterconfig.ini"); return EXIT_FAILURE; } if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "sharedconfig.ini")) { - Game::logger->Log("MasterServer", "Couldnt find sharedconfig.ini"); + LOG("Couldnt find sharedconfig.ini"); return EXIT_FAILURE; } if (!std::filesystem::exists(BinaryPathFinder::GetBinaryDir() / "worldconfig.ini")) { - Game::logger->Log("MasterServer", "Couldnt find worldconfig.ini"); + LOG("Couldnt find worldconfig.ini"); return EXIT_FAILURE; } @@ -116,18 +116,18 @@ int main(int argc, char** argv) { uint32_t clientNetVersion = 0; if (!GeneralUtils::TryParse(Game::config->GetValue("client_net_version"), clientNetVersion)) { - Game::logger->Log("MasterServer", "Failed to parse (%s) as net version. Cannot start server as no clients could connect.", Game::config->GetValue("client_net_version").c_str()); - Game::logger->Log("MasterServer", "As of version 1.1.1, client_net_version is required to be defined in sharedconfig.ini as opposed to in CMakeVariables.txt as NET_VERSION."); - Game::logger->Log("MasterServer", "Rerun cmake to ensure all config values exist. If client_net_version already exists in sharedconfig.ini, please ensure it is a valid number."); - Game::logger->Log("MasterServer", "like 171022"); + LOG("Failed to parse (%s) as net version. Cannot start server as no clients could connect.",Game::config->GetValue("client_net_version").c_str()); + LOG("As of version 1.1.1, client_net_version is required to be defined in sharedconfig.ini as opposed to in CMakeVariables.txt as NET_VERSION."); + LOG("Rerun cmake to ensure all config values exist. If client_net_version already exists in sharedconfig.ini, please ensure it is a valid number."); + LOG("like 171022"); return EXIT_FAILURE; } - Game::logger->Log("MasterServer", "Using net version %s", Game::config->GetValue("client_net_version").c_str()); + LOG("Using net version %s", Game::config->GetValue("client_net_version").c_str()); - Game::logger->Log("MasterServer", "Starting Master server..."); - Game::logger->Log("MasterServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); - Game::logger->Log("MasterServer", "Compiled on: %s", __TIMESTAMP__); + LOG("Starting Master server..."); + LOG("Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); + LOG("Compiled on: %s", __TIMESTAMP__); //Connect to the MySQL Database std::string mysql_host = Game::config->GetValue("mysql_host"); @@ -138,8 +138,8 @@ int main(int argc, char** argv) { try { Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password); } catch (sql::SQLException& ex) { - Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s", ex.what()); - Game::logger->Log("MigrationRunner", "Migrations not run"); + LOG("Got an error while connecting to the database: %s", ex.what()); + LOG("Migrations not run"); return EXIT_FAILURE; } @@ -153,7 +153,7 @@ int main(int argc, char** argv) { Game::assetManager = new AssetManager(clientPath); } catch (std::runtime_error& ex) { - Game::logger->Log("MasterServer", "Got an error while setting up assets: %s", ex.what()); + LOG("Got an error while setting up assets: %s", ex.what()); return EXIT_FAILURE; } @@ -167,25 +167,24 @@ int main(int argc, char** argv) { if (!cdServerExists) { if (oldCDServerExists) { // If the file doesn't exist in the new CDServer location, copy it there. We copy because we may not have write permissions from the previous directory. - Game::logger->Log("MasterServer", "CDServer.sqlite is not located at resServer, but is located at res path. Copying file..."); + LOG("CDServer.sqlite is not located at resServer, but is located at res path. Copying file..."); std::filesystem::copy_file(Game::assetManager->GetResPath() / "CDServer.sqlite", BinaryPathFinder::GetBinaryDir() / "resServer" / "CDServer.sqlite"); } else { - Game::logger->Log("MasterServer", - "%s could not be found in resServer or res. Looking for %s to convert to sqlite.", + LOG("%s could not be found in resServer or res. Looking for %s to convert to sqlite.", (BinaryPathFinder::GetBinaryDir() / "resServer" / "CDServer.sqlite").c_str(), (Game::assetManager->GetResPath() / "cdclient.fdb").c_str()); AssetMemoryBuffer cdClientBuffer = Game::assetManager->GetFileAsBuffer("cdclient.fdb"); if (!cdClientBuffer.m_Success) { - Game::logger->Log("MasterServer", "Failed to load %s", (Game::assetManager->GetResPath() / "cdclient.fdb").c_str()); + LOG("Failed to load %s", (Game::assetManager->GetResPath() / "cdclient.fdb").c_str()); throw std::runtime_error("Aborting initialization due to missing cdclient.fdb."); } - Game::logger->Log("MasterServer", "Found %s. Converting to SQLite", (Game::assetManager->GetResPath() / "cdclient.fdb").c_str()); + LOG("Found %s. Converting to SQLite", (Game::assetManager->GetResPath() / "cdclient.fdb").c_str()); Game::logger->Flush(); if (FdbToSqlite::Convert((BinaryPathFinder::GetBinaryDir() / "resServer").string()).ConvertDatabase(cdClientBuffer) == false) { - Game::logger->Log("MasterServer", "Failed to convert fdb to sqlite."); + LOG("Failed to convert fdb to sqlite."); return EXIT_FAILURE; } cdClientBuffer.close(); @@ -196,9 +195,9 @@ int main(int argc, char** argv) { try { CDClientDatabase::Connect((BinaryPathFinder::GetBinaryDir() / "resServer" / "CDServer.sqlite").string()); } catch (CppSQLite3Exception& e) { - Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database"); - Game::logger->Log("WorldServer", "Error: %s", e.errorMessage()); - Game::logger->Log("WorldServer", "Error Code: %i", e.errorCode()); + LOG("Unable to connect to CDServer SQLite Database"); + LOG("Error: %s", e.errorMessage()); + LOG("Error Code: %i", e.errorCode()); return EXIT_FAILURE; } @@ -209,10 +208,10 @@ int main(int argc, char** argv) { try { CDClientManager::Instance(); } catch (CppSQLite3Exception& e) { - Game::logger->Log("WorldServer", "Failed to initialize CDServer SQLite Database"); - Game::logger->Log("WorldServer", "May be caused by corrupted file: %s", (Game::assetManager->GetResPath() / "CDServer.sqlite").string().c_str()); - Game::logger->Log("WorldServer", "Error: %s", e.errorMessage()); - Game::logger->Log("WorldServer", "Error Code: %i", e.errorCode()); + LOG("Failed to initialize CDServer SQLite Database"); + LOG("May be caused by corrupted file: %s", (Game::assetManager->GetResPath() / "CDServer.sqlite").string().c_str()); + LOG("Error: %s", e.errorMessage()); + LOG("Error Code: %i", e.errorCode()); return EXIT_FAILURE; } @@ -230,7 +229,7 @@ int main(int argc, char** argv) { userLookupStatement->setString(1, username.c_str()); std::unique_ptr res(userLookupStatement->executeQuery()); if (res->rowsCount() > 0) { - Game::logger->Log("MasterServer", "Account with name \"%s\" already exists", username.c_str()); + LOG("Account with name \"%s\" already exists", username.c_str()); std::cout << "Do you want to change the password of that account? [y/n]?"; std::string prompt = ""; std::cin >> prompt; @@ -263,9 +262,9 @@ int main(int argc, char** argv) { userUpdateStatement->setUInt(2, accountId); userUpdateStatement->execute(); - Game::logger->Log("MasterServer", "Account \"%s\" password updated successfully!", username.c_str()); + LOG("Account \"%s\" password updated successfully!", username.c_str()); } else { - Game::logger->Log("MasterServer", "Account \"%s\" was not updated.", username.c_str()); + LOG("Account \"%s\" was not updated.", username.c_str()); } return EXIT_SUCCESS; } @@ -295,12 +294,12 @@ int main(int argc, char** argv) { statement->setString(2, std::string(hash, BCRYPT_HASHSIZE).c_str()); statement->setInt(3, 9); statement->execute(); - } catch (sql::SQLException& e) { - Game::logger->Log("MasterServer", "A SQL error occurred!:\n %s", e.what()); + } catch(sql::SQLException& e) { + LOG("A SQL error occurred!:\n %s", e.what()); return EXIT_FAILURE; } - Game::logger->Log("MasterServer", "Account created successfully!"); + LOG("Account created successfully!"); return EXIT_SUCCESS; } @@ -450,7 +449,7 @@ int main(int argc, char** argv) { return FinalizeShutdown(EXIT_SUCCESS); } -dLogger* SetupLogger() { +Logger* SetupLogger() { std::string logPath = (BinaryPathFinder::GetBinaryDir() / ("logs/MasterServer_" + std::to_string(time(nullptr)) + ".log")).string(); bool logToConsole = false; @@ -460,19 +459,19 @@ dLogger* SetupLogger() { logDebugStatements = true; #endif - return new dLogger(logPath, logToConsole, logDebugStatements); + return new Logger(logPath, logToConsole, logDebugStatements); } void HandlePacket(Packet* packet) { if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION) { - Game::logger->Log("MasterServer", "A server has disconnected"); + LOG("A server has disconnected"); //Since this disconnection is intentional, we'll just delete it as //we'll start a new one anyway if needed: Instance* instance = Game::im->GetInstanceBySysAddr(packet->systemAddress); if (instance) { - Game::logger->Log("MasterServer", "Actually disconnected from zone %i clone %i instance %i port %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort()); + LOG("Actually disconnected from zone %i clone %i instance %i port %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort()); Game::im->RemoveInstance(instance); //Delete the old } @@ -488,7 +487,7 @@ void HandlePacket(Packet* packet) { } if (packet->data[0] == ID_CONNECTION_LOST) { - Game::logger->Log("MasterServer", "A server has lost the connection"); + LOG("A server has lost the connection"); Instance* instance = Game::im->GetInstanceBySysAddr(packet->systemAddress); @@ -513,7 +512,7 @@ void HandlePacket(Packet* packet) { if (static_cast(packet->data[1]) == eConnectionType::MASTER) { switch (static_cast(packet->data[3])) { case eMasterMessageType::REQUEST_PERSISTENT_ID: { - Game::logger->Log("MasterServer", "A persistent ID req"); + LOG("A persistent ID req"); RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); uint64_t requestID = 0; @@ -525,7 +524,7 @@ void HandlePacket(Packet* packet) { } case eMasterMessageType::REQUEST_ZONE_TRANSFER: { - Game::logger->Log("MasterServer", "Received zone transfer req"); + LOG("Received zone transfer req"); RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); uint64_t requestID = 0; @@ -538,24 +537,24 @@ void HandlePacket(Packet* packet) { inStream.Read(zoneID); inStream.Read(zoneClone); if (shutdownSequenceStarted) { - Game::logger->Log("MasterServer", "Shutdown sequence has been started. Not creating a new zone."); + LOG("Shutdown sequence has been started. Not creating a new zone."); break; } Instance* in = Game::im->GetInstance(zoneID, false, zoneClone); for (auto* instance : Game::im->GetInstances()) { - Game::logger->Log("MasterServer", "Instance: %i/%i/%i -> %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance == in); + LOG("Instance: %i/%i/%i -> %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance == in); } if (in && !in->GetIsReady()) //Instance not ready, make a pending request { in->GetPendingRequests().push_back({ requestID, static_cast(mythranShift), packet->systemAddress }); - Game::logger->Log("MasterServer", "Server not ready, adding pending request %llu %i %i", requestID, zoneID, zoneClone); + LOG("Server not ready, adding pending request %llu %i %i", requestID, zoneID, zoneClone); break; } //Instance is ready, transfer - Game::logger->Log("MasterServer", "Responding to transfer request %llu for zone %i %i", requestID, zoneID, zoneClone); + LOG("Responding to transfer request %llu for zone %i %i", requestID, zoneID, zoneClone); Game::im->RequestAffirmation(in, { requestID, static_cast(mythranShift), packet->systemAddress }); break; } @@ -616,7 +615,7 @@ void HandlePacket(Packet* packet) { authServerMasterPeerSysAddr = copy; } - Game::logger->Log("MasterServer", "Received server info, instance: %i port: %i", theirInstanceID, theirPort); + LOG("Received server info, instance: %i port: %i", theirInstanceID, theirPort); break; } @@ -648,7 +647,7 @@ void HandlePacket(Packet* packet) { } activeSessions.insert(std::make_pair(sessionKey, username)); - Game::logger->Log("MasterServer", "Got sessionKey %i for user %s", sessionKey, username.c_str()); + LOG("Got sessionKey %i for user %s", sessionKey, username.c_str()); break; } @@ -754,7 +753,7 @@ void HandlePacket(Packet* packet) { auto* instance = Game::im->FindPrivateInstance(password.c_str()); - Game::logger->Log("MasterServer", "Join private zone: %llu %d %s %p", requestID, mythranShift, password.c_str(), instance); + LOG("Join private zone: %llu %d %s %p", requestID, mythranShift, password.c_str(), instance); if (instance == nullptr) { return; @@ -777,16 +776,16 @@ void HandlePacket(Packet* packet) { inStream.Read(zoneID); inStream.Read(instanceID); - Game::logger->Log("MasterServer", "Got world ready %i %i", zoneID, instanceID); + LOG("Got world ready %i %i", zoneID, instanceID); auto* instance = Game::im->FindInstance(zoneID, instanceID); if (instance == nullptr) { - Game::logger->Log("MasterServer", "Failed to find zone to ready"); + LOG("Failed to find zone to ready"); return; } - Game::logger->Log("MasterServer", "Ready zone %i", zoneID); + LOG("Ready zone %i", zoneID); Game::im->ReadyInstance(instance); break; } @@ -798,10 +797,10 @@ void HandlePacket(Packet* packet) { int32_t zoneID; inStream.Read(zoneID); if (shutdownSequenceStarted) { - Game::logger->Log("MasterServer", "Shutdown sequence has been started. Not prepping a new zone."); + LOG("Shutdown sequence has been started. Not prepping a new zone."); break; } else { - Game::logger->Log("MasterServer", "Prepping zone %i", zoneID); + LOG("Prepping zone %i", zoneID); Game::im->GetInstance(zoneID, false, 0); } break; @@ -815,7 +814,7 @@ void HandlePacket(Packet* packet) { inStream.Read(requestID); - Game::logger->Log("MasterServer", "Got affirmation of transfer %llu", requestID); + LOG("Got affirmation of transfer %llu", requestID); auto* instance = Game::im->GetInstanceBySysAddr(packet->systemAddress); @@ -823,7 +822,7 @@ void HandlePacket(Packet* packet) { return; Game::im->AffirmTransfer(instance, requestID); - Game::logger->Log("MasterServer", "Affirmation complete %llu", requestID); + LOG("Affirmation complete %llu", requestID); break; } @@ -837,26 +836,26 @@ void HandlePacket(Packet* packet) { return; } - Game::logger->Log("MasterServer", "Got shutdown response from zone %i clone %i instance %i port %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort()); + LOG("Got shutdown response from zone %i clone %i instance %i port %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort()); instance->SetIsShuttingDown(true); break; } case eMasterMessageType::SHUTDOWN_UNIVERSE: { - Game::logger->Log("MasterServer", "Received shutdown universe command, shutting down in 10 minutes."); + LOG("Received shutdown universe command, shutting down in 10 minutes."); Game::shouldShutdown = true; break; } default: - Game::logger->Log("MasterServer", "Unknown master packet ID from server: %i", packet->data[3]); + LOG("Unknown master packet ID from server: %i", packet->data[3]); } } } void StartChatServer() { if (Game::shouldShutdown) { - Game::logger->Log("MasterServer", "Currently shutting down. Chat will not be restarted."); + LOG("Currently shutting down. Chat will not be restarted."); return; } #ifdef __APPLE__ @@ -875,7 +874,7 @@ void StartChatServer() { void StartAuthServer() { if (Game::shouldShutdown) { - Game::logger->Log("MasterServer", "Currently shutting down. Auth will not be restarted."); + LOG("Currently shutting down. Auth will not be restarted."); return; } #ifdef __APPLE__ @@ -908,13 +907,13 @@ void ShutdownSequence(int32_t signal) { CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN); Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); - Game::logger->Log("MasterServer", "Triggered master shutdown"); + LOG("Triggered master shutdown"); } auto* objIdManager = ObjectIDManager::TryInstance(); if (objIdManager) { objIdManager->SaveToDatabase(); - Game::logger->Log("MasterServer", "Saved ObjectIDTracker to DB"); + LOG("Saved ObjectIDTracker to DB"); } // A server might not be finished spinning up yet, remove all of those here. @@ -928,7 +927,7 @@ void ShutdownSequence(int32_t signal) { instance->SetIsShuttingDown(true); } - Game::logger->Log("MasterServer", "Attempting to shutdown instances, max 60 seconds..."); + LOG("Attempting to shutdown instances, max 60 seconds..."); auto t = std::chrono::high_resolution_clock::now(); uint32_t framesSinceShutdownStart = 0; @@ -956,7 +955,7 @@ void ShutdownSequence(int32_t signal) { } if (allInstancesShutdown && authServerMasterPeerSysAddr == UNASSIGNED_SYSTEM_ADDRESS && chatServerMasterPeerSysAddr == UNASSIGNED_SYSTEM_ADDRESS) { - Game::logger->Log("MasterServer", "Finished shutting down MasterServer!"); + LOG("Finished shutting down MasterServer!"); break; } @@ -966,7 +965,7 @@ void ShutdownSequence(int32_t signal) { framesSinceShutdownStart++; if (framesSinceShutdownStart == maxShutdownTime) { - Game::logger->Log("MasterServer", "Finished shutting down by timeout!"); + LOG("Finished shutting down by timeout!"); break; } } diff --git a/dMasterServer/ObjectIDManager.cpp b/dMasterServer/ObjectIDManager.cpp index 83dde8dd..df0613cc 100644 --- a/dMasterServer/ObjectIDManager.cpp +++ b/dMasterServer/ObjectIDManager.cpp @@ -2,13 +2,14 @@ // Custom Classes #include "Database.h" -#include "dLogger.h" +#include "Logger.h" +#include "Game.h" // Static Variables ObjectIDManager* ObjectIDManager::m_Address = nullptr; //! Initializes the manager -void ObjectIDManager::Initialize(dLogger* logger) { +void ObjectIDManager::Initialize(Logger* logger) { this->mLogger = logger; this->currentPersistentID = 1; @@ -39,9 +40,8 @@ void ObjectIDManager::Initialize(dLogger* logger) { delete result; delete stmt; } catch (sql::SQLException& e) { - mLogger->Log("ObjectIDManager", "Unable to fetch max persistent object " - "ID in use. Defaulting to 1."); - mLogger->Log("ObjectIDManager", "SQL error: %s", e.what()); + LOG("Unable to fetch max persistent object ID in use. Defaulting to 1."); + LOG("SQL error: %s", e.what()); this->currentPersistentID = 1; } } diff --git a/dMasterServer/ObjectIDManager.h b/dMasterServer/ObjectIDManager.h index b18619bc..1454d08f 100644 --- a/dMasterServer/ObjectIDManager.h +++ b/dMasterServer/ObjectIDManager.h @@ -3,7 +3,7 @@ // C++ #include -class dLogger; +class Logger; /*! \file ObjectIDManager.hpp @@ -13,7 +13,7 @@ class dLogger; //! The Object ID Manager class ObjectIDManager { private: - dLogger* mLogger; + Logger* mLogger; static ObjectIDManager* m_Address; //!< The singleton instance uint32_t currentPersistentID; //!< The highest current persistent ID in use @@ -35,7 +35,7 @@ public: } //! Initializes the manager - void Initialize(dLogger* logger); + void Initialize(Logger* logger); //! Generates a new persistent ID /*! diff --git a/dNavigation/dNavMesh.cpp b/dNavigation/dNavMesh.cpp index 14b59055..aa43689b 100644 --- a/dNavigation/dNavMesh.cpp +++ b/dNavigation/dNavMesh.cpp @@ -3,7 +3,7 @@ #include "RawFile.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "dPlatforms.h" #include "NiPoint3.h" #include "BinaryIO.h" @@ -21,9 +21,9 @@ dNavMesh::dNavMesh(uint32_t zoneId) { m_NavQuery = dtAllocNavMeshQuery(); m_NavQuery->init(m_NavMesh, 2048); - Game::logger->Log("dNavMesh", "Navmesh loaded successfully!"); + LOG("Navmesh loaded successfully!"); } else { - Game::logger->Log("dNavMesh", "Navmesh loading failed (This may be intended)."); + LOG("Navmesh loading failed (This may be intended)."); } } diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 3fe9b35b..1445be37 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -4,7 +4,7 @@ #include "dNetCommon.h" #include "dServer.h" -#include "dLogger.h" +#include "Logger.h" #include "Database.h" #include "ZoneInstanceManager.h" #include "MD5.h" @@ -34,7 +34,7 @@ void AuthPackets::HandleHandshake(dServer* server, Packet* packet) { uint32_t clientVersion = 0; inStream.Read(clientVersion); - server->GetLogger()->Log("AuthPackets", "Received client version: %i", clientVersion); + LOG("Received client version: %i", clientVersion); SendHandshake(server, packet->systemAddress, server->GetIP(), server->GetPort(), server->GetServerType()); } @@ -43,7 +43,7 @@ void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, c BitStreamUtils::WriteHeader(bitStream, eConnectionType::SERVER, eServerMessageType::VERSION_CONFIRM); uint32_t netVersion; if (!GeneralUtils::TryParse(Game::config->GetValue("client_net_version"), netVersion)) { - Game::logger->Log("AuthPackets", "Failed to parse client_net_version. Cannot authenticate to %s:%i", nextServerIP.c_str(), nextServerPort); + LOG("Failed to parse client_net_version. Cannot authenticate to %s:%i", nextServerIP.c_str(), nextServerPort); return; } bitStream.Write(netVersion); @@ -70,7 +70,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { sql::ResultSet* res = stmt->executeQuery(); if (res->rowsCount() == 0) { - server->GetLogger()->Log("AuthPackets", "No user found!"); + LOG("No user found!"); AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username); return; } @@ -103,7 +103,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { //Check to see if we have a play key: if (sqlPlayKey == 0 && sqlGmLevel == 0) { AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username); - server->GetLogger()->Log("AuthPackets", "User %s tried to log in, but they don't have a play key.", username.c_str()); + LOG("User %s tried to log in, but they don't have a play key.", username.c_str()); return; } @@ -124,7 +124,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { if (!isKeyActive && sqlGmLevel == 0) { AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username); - server->GetLogger()->Log("AuthPackets", "User %s tried to log in, but their play key was disabled", username.c_str()); + LOG("User %s tried to log in, but their play key was disabled", username.c_str()); return; } } @@ -181,7 +181,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { if (!loginSuccess) { AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username); - server->GetLogger()->Log("AuthPackets", "Wrong password used"); + LOG("Wrong password used"); } else { SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main @@ -268,6 +268,6 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd bitStream.Write(LUString(username, 66)); server->SendToMaster(&bitStream); - server->GetLogger()->Log("AuthPackets", "Set sessionKey: %i for user %s", sessionKey, username.c_str()); + LOG("Set sessionKey: %i for user %s", sessionKey, username.c_str()); } } diff --git a/dNet/ClientPackets.cpp b/dNet/ClientPackets.cpp index e797ea21..8059b7af 100644 --- a/dNet/ClientPackets.cpp +++ b/dNet/ClientPackets.cpp @@ -11,7 +11,7 @@ #include "Entity.h" #include "ControllablePhysicsComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "WorldPackets.h" #include "NiPoint3.h" #include "NiQuaternion.h" @@ -38,7 +38,7 @@ void ClientPackets::HandleChatMessage(const SystemAddress& sysAddr, Packet* packet) { User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) { - Game::logger->Log("ClientPackets", "Unable to get user to parse chat message"); + LOG("Unable to get user to parse chat message"); return; } @@ -67,7 +67,7 @@ void ClientPackets::HandleChatMessage(const SystemAddress& sysAddr, Packet* pack std::string playerName = user->GetLastUsedChar()->GetName(); bool isMythran = user->GetLastUsedChar()->GetGMLevel() > eGameMasterLevel::CIVILIAN; bool isOk = Game::chatFilter->IsSentenceOkay(GeneralUtils::UTF16ToWTF8(message), user->GetLastUsedChar()->GetGMLevel()).empty(); - Game::logger->LogDebug("ClientPackets", "Msg: %s was approved previously? %i", GeneralUtils::UTF16ToWTF8(message).c_str(), user->GetLastChatMessageApproved()); + LOG_DEBUG("Msg: %s was approved previously? %i", GeneralUtils::UTF16ToWTF8(message).c_str(), user->GetLastChatMessageApproved()); if (!isOk) { // Add a limit to the string converted by general utils because it is a user received string and may be a bad actor. CheatDetection::ReportCheat( @@ -80,14 +80,14 @@ void ClientPackets::HandleChatMessage(const SystemAddress& sysAddr, Packet* pack if (!isOk && !isMythran) return; std::string sMessage = GeneralUtils::UTF16ToWTF8(message); - Game::logger->Log("Chat", "%s: %s", playerName.c_str(), sMessage.c_str()); + LOG("%s: %s", playerName.c_str(), sMessage.c_str()); ChatPackets::SendChatMessage(sysAddr, chatChannel, playerName, user->GetLoggedInChar(), isMythran, message); } void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Packet* packet) { User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) { - Game::logger->Log("ClientPackets", "Unable to get user to parse position update"); + LOG("Unable to get user to parse position update"); return; } @@ -286,14 +286,14 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac void ClientPackets::HandleChatModerationRequest(const SystemAddress& sysAddr, Packet* packet) { User* user = UserManager::Instance()->GetUser(sysAddr); if (!user) { - Game::logger->Log("ClientPackets", "Unable to get user to parse chat moderation request"); + LOG("Unable to get user to parse chat moderation request"); return; } auto* entity = Player::GetPlayer(sysAddr); if (entity == nullptr) { - Game::logger->Log("ClientPackets", "Unable to get player to parse chat moderation request"); + LOG("Unable to get player to parse chat moderation request"); return; } diff --git a/dNet/PacketUtils.cpp b/dNet/PacketUtils.cpp index c1929826..6b39c2f2 100644 --- a/dNet/PacketUtils.cpp +++ b/dNet/PacketUtils.cpp @@ -1,7 +1,7 @@ #include "PacketUtils.h" #include #include -#include "dLogger.h" +#include "Logger.h" #include "Game.h" uint16_t PacketUtils::ReadU16(uint32_t startLoc, Packet* packet) { @@ -62,7 +62,7 @@ std::string PacketUtils::ReadString(uint32_t startLoc, Packet* packet, bool wide //! Saves a packet to the filesystem void PacketUtils::SavePacket(const std::string& filename, const char* data, size_t length) { //If we don't log to the console, don't save the bin files either. This takes up a lot of time. - if (!Game::logger->GetIsLoggingToConsole()) return; + if (!Game::logger->GetLogToConsole()) return; std::string path = "packets/" + filename; diff --git a/dNet/WorldPackets.cpp b/dNet/WorldPackets.cpp index 18c2c8a5..d6de9186 100644 --- a/dNet/WorldPackets.cpp +++ b/dNet/WorldPackets.cpp @@ -5,7 +5,7 @@ #include "GeneralUtils.h" #include "User.h" #include "Character.h" -#include "dLogger.h" +#include "Logger.h" #include #include "Game.h" #include "LDFFormat.h" @@ -137,7 +137,7 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* ent auto character = entity->GetComponent(); if (!character) { - Game::logger->Log("WorldPackets", "Entity is not a character?? what??"); + LOG("Entity is not a character?? what??"); return; } @@ -194,7 +194,7 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* ent // PacketUtils::SavePacket("chardata.bin", (const char*)bitStream.GetData(), static_cast(bitStream.GetNumberOfBytesUsed())); SEND_PACKET; delete[] compressedData; - Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu", entity->GetObjectID()); + LOG("Sent CreateCharacter for ID: %llu", entity->GetObjectID()); } void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector> unacceptedItems) { diff --git a/dNet/dServer.cpp b/dNet/dServer.cpp index 75cd4091..9a3955b6 100644 --- a/dNet/dServer.cpp +++ b/dNet/dServer.cpp @@ -1,7 +1,7 @@ #define _VARIADIC_MAX 10 #include "dServer.h" #include "dNetCommon.h" -#include "dLogger.h" +#include "Logger.h" #include "dConfig.h" #include "RakNetworkFactory.h" @@ -39,7 +39,7 @@ public: } } ReceiveDownloadCompleteCB; -dServer::dServer(const std::string& ip, int port, int instanceID, int maxConnections, bool isInternal, bool useEncryption, dLogger* logger, const std::string masterIP, int masterPort, ServerType serverType, dConfig* config, bool* shouldShutdown, unsigned int zoneID) { +dServer::dServer(const std::string& ip, int port, int instanceID, int maxConnections, bool isInternal, bool useEncryption, Logger* logger, const std::string masterIP, int masterPort, ServerType serverType, dConfig* config, bool* shouldShutdown, unsigned int zoneID) { mIP = ip; mPort = port; mZoneID = zoneID; @@ -60,15 +60,15 @@ dServer::dServer(const std::string& ip, int port, int instanceID, int maxConnect mIsOkay = Startup(); //Forcibly log to both the console and our file what ip, port and possibly zoneID / instanceID we're running on: - bool prevLogSetting = mLogger->GetIsLoggingToConsole(); + bool prevLogSetting = mLogger->GetLogToConsole(); mLogger->SetLogToConsole(true); if (mIsOkay) { if (zoneID == 0) - mLogger->Log("dServer", "Server is listening on %s:%i with encryption: %i", ip.c_str(), port, int(useEncryption)); + LOG("Server is listening on %s:%i with encryption: %i", ip.c_str(), port, int(useEncryption)); else - mLogger->Log("dServer", "Server is listening on %s:%i with encryption: %i, running zone %i / %i", ip.c_str(), port, int(useEncryption), zoneID, instanceID); - } else { mLogger->Log("dServer", "FAILED TO START SERVER ON IP/PORT: %s:%i", ip.c_str(), port); return; } + LOG("Server is listening on %s:%i with encryption: %i, running zone %i / %i", ip.c_str(), port, int(useEncryption), zoneID, instanceID); + } else { LOG("FAILED TO START SERVER ON IP/PORT: %s:%i", ip.c_str(), port); return; } mLogger->SetLogToConsole(prevLogSetting); @@ -108,13 +108,13 @@ Packet* dServer::ReceiveFromMaster() { if (packet->length < 1) { mMasterPeer->DeallocatePacket(packet); return nullptr; } if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) { - mLogger->Log("dServer", "Lost our connection to master, shutting DOWN!"); + LOG("Lost our connection to master, shutting DOWN!"); mMasterConnectionActive = false; //ConnectToMaster(); //We'll just shut down now } if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) { - mLogger->Log("dServer", "Established connection to master, zone (%i), instance (%i)", this->GetZoneID(), this->GetInstanceID()); + LOG("Established connection to master, zone (%i), instance (%i)", this->GetZoneID(), this->GetInstanceID()); mMasterConnectionActive = true; mMasterSystemAddress = packet->systemAddress; MasterPackets::SendServerInfo(this, packet); diff --git a/dNet/dServer.h b/dNet/dServer.h index 797647b6..5df5bddc 100644 --- a/dNet/dServer.h +++ b/dNet/dServer.h @@ -4,7 +4,7 @@ #include "ReplicaManager.h" #include "NetworkIDManager.h" -class dLogger; +class Logger; class dConfig; enum class eServerDisconnectIdentifiers : uint32_t; @@ -26,7 +26,7 @@ public: int maxConnections, bool isInternal, bool useEncryption, - dLogger* logger, + Logger* logger, const std::string masterIP, int masterPort, ServerType serverType, @@ -51,7 +51,7 @@ public: const bool GetIsEncrypted() const { return mUseEncryption; } const bool GetIsInternal() const { return mIsInternal; } const bool GetIsOkay() const { return mIsOkay; } - dLogger* GetLogger() const { return mLogger; } + Logger* GetLogger() const { return mLogger; } const bool GetIsConnectedToMaster() const { return mMasterConnectionActive; } const unsigned int GetZoneID() const { return mZoneID; } const int GetInstanceID() const { return mInstanceID; } @@ -74,7 +74,7 @@ private: bool ConnectToMaster(); private: - dLogger* mLogger = nullptr; + Logger* mLogger = nullptr; dConfig* mConfig = nullptr; RakPeerInterface* mPeer = nullptr; ReplicaManager* mReplicaManager = nullptr; diff --git a/dPhysics/dpWorld.cpp b/dPhysics/dpWorld.cpp index 70fbfa3a..1abcb04a 100644 --- a/dPhysics/dpWorld.cpp +++ b/dPhysics/dpWorld.cpp @@ -6,7 +6,7 @@ #include #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "dConfig.h" void dpWorld::Initialize(unsigned int zoneID, bool generateNewNavMesh) { @@ -23,7 +23,7 @@ void dpWorld::Initialize(unsigned int zoneID, bool generateNewNavMesh) { if (generateNewNavMesh) m_NavMesh = new dNavMesh(zoneID); - Game::logger->Log("dpWorld", "Physics world initialized!"); + LOG("Physics world initialized!"); m_ZoneID = zoneID; } @@ -42,9 +42,9 @@ void dpWorld::Reload() { } } } - Game::logger->Log("dpWorld", "Successfully reloaded physics world!"); + LOG("Successfully reloaded physics world!"); } else { - Game::logger->Log("dpWorld", "No physics world to reload!"); + LOG("No physics world to reload!"); } } diff --git a/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp b/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp index 8d092078..49359ed1 100644 --- a/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp +++ b/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp @@ -309,7 +309,7 @@ void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self) { impactList.erase(impactList.begin()); if (entity == nullptr) { - Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact!"); + LOG("Failed to find impact!"); return; } @@ -317,7 +317,7 @@ void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self) { auto* skillComponent = entity->GetComponent(); if (skillComponent == nullptr) { - Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact skill component!"); + LOG("Failed to find impact skill component!"); return; } @@ -366,7 +366,7 @@ void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self) { } if (targets.empty()) { - Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find RFS targets"); + LOG("Failed to find RFS targets"); self->AddTimer("RFS", GeneralUtils::GenerateRandomNumber(5, 10)); diff --git a/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp b/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp index ff7e7a51..d2b3c737 100644 --- a/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp +++ b/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp @@ -67,7 +67,7 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_ auto weakpoint = self->GetVar(u"weakpoint"); if (weakpoint == 0) { - Game::logger->Log("FvMaelstromDragon", "Activating weakpoint"); + LOG("Activating weakpoint"); self->AddTimer("ReviveTimer", 12); diff --git a/dScripts/02_server/Map/njhub/FlameJetServer.cpp b/dScripts/02_server/Map/njhub/FlameJetServer.cpp index 771dd841..9cb687d8 100644 --- a/dScripts/02_server/Map/njhub/FlameJetServer.cpp +++ b/dScripts/02_server/Map/njhub/FlameJetServer.cpp @@ -37,7 +37,7 @@ void FlameJetServer::OnCollisionPhantom(Entity* self, Entity* target) { } void FlameJetServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { - Game::logger->Log("FlameJetServer::OnFireEventServerSide", "Event: %s", args.c_str()); + LOG("Event: %s", args.c_str()); if (args == "OnActivated") { self->SetNetworkVar(u"FlameOn", false); diff --git a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp index d31f7b17..137a9ed3 100644 --- a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp +++ b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp @@ -101,7 +101,7 @@ void NjMonastryBossInstance::OnPlayerExit(Entity* self, Entity* player) { if (playerToRemove != totalPlayersLoaded.end()) { totalPlayersLoaded.erase(playerToRemove); } else { - Game::logger->Log("NjMonastryBossInstance", "Failed to remove player at exit."); + LOG("Failed to remove player at exit."); } // Set the players loaded var back diff --git a/dScripts/ActivityManager.cpp b/dScripts/ActivityManager.cpp index a5bc0d5b..0f251dbf 100644 --- a/dScripts/ActivityManager.cpp +++ b/dScripts/ActivityManager.cpp @@ -4,7 +4,7 @@ #include "LeaderboardManager.h" #include "GameMessages.h" #include -#include "dLogger.h" +#include "Logger.h" #include "Loot.h" bool ActivityManager::IsPlayerInActivity(Entity* self, LWOOBJID playerID) { @@ -129,7 +129,7 @@ void ActivityManager::ActivityTimerStart(Entity* self, const std::string& timerN auto* timer = new ActivityTimer{ timerName, updateInterval, stopTime }; activeTimers.push_back(timer); - Game::logger->LogDebug("ActivityManager", "Starting timer '%s', %f, %f", timerName.c_str(), updateInterval, stopTime); + LOG_DEBUG("Starting timer '%s', %f, %f", timerName.c_str(), updateInterval, stopTime); self->AddTimer(GetPrefixedName(timer->name), timer->updateInterval); } @@ -210,10 +210,10 @@ void ActivityManager::OnTimerDone(Entity* self, std::string timerName) { activeTimers.erase(std::remove(activeTimers.begin(), activeTimers.end(), timer), activeTimers.end()); delete timer; - Game::logger->LogDebug("ActivityManager", "Executing timer '%s'", activityTimerName.c_str()); + LOG_DEBUG("Executing timer '%s'", activityTimerName.c_str()); OnActivityTimerDone(self, activityTimerName); } else { - Game::logger->LogDebug("ActivityManager", "Updating timer '%s'", activityTimerName.c_str()); + LOG_DEBUG("Updating timer '%s'", activityTimerName.c_str()); OnActivityTimerUpdate(self, timer->name, timer->stopTime - timer->runTime, timer->runTime); self->AddTimer(GetPrefixedName(timer->name), timer->updateInterval); } diff --git a/dScripts/BaseRandomServer.cpp b/dScripts/BaseRandomServer.cpp index 293fb79a..17817d7a 100644 --- a/dScripts/BaseRandomServer.cpp +++ b/dScripts/BaseRandomServer.cpp @@ -1,7 +1,7 @@ #include "BaseRandomServer.h" #include "dZoneManager.h" #include "Spawner.h" -#include "dLogger.h" +#include "Logger.h" #include "Entity.h" void BaseRandomServer::BaseStartup(Entity* self) { @@ -34,7 +34,7 @@ void BaseRandomServer::SpawnSection(Entity* self, const std::string& sectionName Zone* spawnLoad = GetRandomLoad(self, sectionName); if (spawnLoad == nullptr) { - Game::logger->Log("BaseRandomServer", "Failed to find section: %s", sectionName.c_str()); + LOG("Failed to find section: %s", sectionName.c_str()); return; } @@ -59,7 +59,7 @@ void BaseRandomServer::SetSpawnerNetwork(Entity* self, const std::string& spawne } if (spawners.empty()) { - Game::logger->Log("BaseRandomServer", "Failed to find spawner: %s", spawnerName.c_str()); + LOG("Failed to find spawner: %s", spawnerName.c_str()); return; } diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 065248c5..24fe7b5b 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -7,7 +7,7 @@ #include "Entity.h" #include "ScriptComponent.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "InvalidScript.h" //VE / AG scripts: @@ -930,7 +930,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr (scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") || (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_FROG.lua") || (scriptName == "scripts\\empty.lua") - )) Game::logger->LogDebug("CppScripts", "LOT %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str()); + )) LOG_DEBUG("LOT %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str()); } m_Scripts[scriptName] = script; diff --git a/dScripts/ai/FV/TriggerGas.cpp b/dScripts/ai/FV/TriggerGas.cpp index 7e9762e3..328063e5 100644 --- a/dScripts/ai/FV/TriggerGas.cpp +++ b/dScripts/ai/FV/TriggerGas.cpp @@ -2,7 +2,7 @@ #include "InventoryComponent.h" #include "SkillComponent.h" #include "Entity.h" -#include "dLogger.h" +#include "Logger.h" void TriggerGas::OnStartup(Entity* self) { diff --git a/dScripts/ai/GF/GfParrotCrash.cpp b/dScripts/ai/GF/GfParrotCrash.cpp index 6b76a51d..fa869335 100644 --- a/dScripts/ai/GF/GfParrotCrash.cpp +++ b/dScripts/ai/GF/GfParrotCrash.cpp @@ -1,7 +1,7 @@ #include "GfParrotCrash.h" #include "SkillComponent.h" #include "Entity.h" -#include "dLogger.h" +#include "Logger.h" void GfParrotCrash::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { auto* skillComponent = self->GetComponent(); diff --git a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp index 2208d5d7..eceee601 100644 --- a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp +++ b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp @@ -19,7 +19,7 @@ #include "eGameActivity.h" void SGCannon::OnStartup(Entity* self) { - Game::logger->Log("SGCannon", "OnStartup"); + LOG("OnStartup"); m_Waves = GetWaves(); constants = GetConstants(); @@ -65,7 +65,7 @@ void SGCannon::OnStartup(Entity* self) { } void SGCannon::OnPlayerLoaded(Entity* self, Entity* player) { - Game::logger->Log("SGCannon", "Player loaded"); + LOG("Player loaded"); self->SetVar(PlayerIDVariable, player->GetObjectID()); } @@ -76,15 +76,15 @@ void SGCannon::OnFireEventServerSide(Entity* self, Entity* sender, std::string a void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int32_t value1, int32_t value2, const std::u16string& stringValue) { - Game::logger->Log("SGCannon", "Got activity state change request: %s", GeneralUtils::UTF16ToWTF8(stringValue).c_str()); + LOG("Got activity state change request: %s", GeneralUtils::UTF16ToWTF8(stringValue).c_str()); if (stringValue == u"clientready") { auto* player = Game::entityManager->GetEntity(self->GetVar(PlayerIDVariable)); if (player != nullptr) { - Game::logger->Log("SGCannon", "Player is ready"); + LOG("Player is ready"); /*GameMessages::SendSetStunned(player->GetObjectID(), eStateChangeType::PUSH, player->GetSystemAddress(), LWOOBJID_EMPTY, true, true, true, true, true, true, true);*/ - Game::logger->Log("SGCannon", "Sending ActivityEnter"); + LOG("Sending ActivityEnter"); GameMessages::SendActivityEnter(self->GetObjectID(), player->GetSystemAddress()); @@ -93,11 +93,11 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int if (shootingGalleryComponent != nullptr) { shootingGalleryComponent->SetCurrentPlayerID(player->GetObjectID()); - Game::logger->Log("SGCannon", "Setting player ID"); + LOG("Setting player ID"); Game::entityManager->SerializeEntity(self); } else { - Game::logger->Log("SGCannon", "Shooting gallery component is null"); + LOG("Shooting gallery component is null"); } auto* characterComponent = player->GetComponent(); @@ -129,7 +129,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int //GameMessages::SendRequestActivityEnter(self->GetObjectID(), player->GetSystemAddress(), false, player->GetObjectID()); } else { - Game::logger->Log("SGCannon", "Player not found"); + LOG("Player not found"); } } else if (value1 == 1200) { StartGame(self); @@ -184,7 +184,7 @@ void SGCannon::SpawnWaveTimerFunc(Entity* self) { SpawnObject(self, enemyToSpawn, true); } - Game::logger->Log("SGCannon", "Current wave spawn: %i/%i", wave, m_Waves.size()); + LOG("Current wave spawn: %i/%i", wave, m_Waves.size()); // All waves completed const auto timeLimit = (float_t)self->GetVar(TimeLimitVariable); @@ -199,7 +199,7 @@ void SGCannon::SpawnWaveTimerFunc(Entity* self) { GameMessages::SendPlayFXEffect(player->GetObjectID(), -1, u"SG-start", ""); GameMessages::SendStartActivityTime(self->GetObjectID(), timeLimit, player->GetSystemAddress()); - Game::logger->Log("SGCannon", "Sending ActivityPause false"); + LOG("Sending ActivityPause false"); GameMessages::SendActivityPause(self->GetObjectID(), false, player->GetSystemAddress()); } @@ -222,7 +222,7 @@ void SGCannon::EndWaveTimerFunc(Entity* self) { self->SetNetworkVar(WaveNumVariable, self->GetVar(ThisWaveVariable) + 1); self->SetNetworkVar(WaveStrVariable, self->GetVar(TimeLimitVariable)); - Game::logger->Log("SGCannon", "Current wave: %i/%i", self->GetVar(ThisWaveVariable), m_Waves.size()); + LOG("Current wave: %i/%i", self->GetVar(ThisWaveVariable), m_Waves.size()); if (self->GetVar(ThisWaveVariable) >= m_Waves.size()) { ActivityTimerStart(self, GameOverTimer, 0.1, 0.1); @@ -230,7 +230,7 @@ void SGCannon::EndWaveTimerFunc(Entity* self) { ActivityTimerStart(self, SpawnWaveTimer, constants.inBetweenWavePause, constants.inBetweenWavePause); } - Game::logger->Log("SGCannon", "Sending ActivityPause true"); + LOG("Sending ActivityPause true"); GameMessages::SendActivityPause(self->GetObjectID(), true); if (self->GetVar(SuperChargeActiveVariable) && !self->GetVar(SuperChargePausedVariable)) { @@ -241,7 +241,7 @@ void SGCannon::EndWaveTimerFunc(Entity* self) { void SGCannon::GameOverTimerFunc(Entity* self) { auto* player = Game::entityManager->GetEntity(self->GetVar(PlayerIDVariable)); if (player != nullptr) { - Game::logger->Log("SGCannon", "Sending ActivityPause true"); + LOG_DEBUG("Sending ActivityPause true"); GameMessages::SendActivityPause(self->GetObjectID(), true, player->GetSystemAddress()); @@ -261,27 +261,27 @@ void SGCannon::GameOverTimerFunc(Entity* self) { void SGCannon::DoSpawnTimerFunc(Entity* self, const std::string& name) { if (self->GetVar(GameStartedVariable)) { - Game::logger->LogDebug("SGCannon", "time name %s %s", name.c_str(), name.substr(7).c_str()); + LOG_DEBUG("time name %s %s", name.c_str(), name.substr(7).c_str()); const auto spawnNumber = (uint32_t)std::stoi(name.substr(7)); const auto& activeSpawns = self->GetVar>(ActiveSpawnsVariable); - Game::logger->LogDebug("SGCannon", "size %i, %i", activeSpawns.size(), spawnNumber); + LOG_DEBUG("size %i, %i", activeSpawns.size(), spawnNumber); if (activeSpawns.size() <= spawnNumber) { - Game::logger->Log("SGCannon", "Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size()); + LOG_DEBUG("Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size()); return; } const auto& toSpawn = activeSpawns.at(spawnNumber); - Game::logger->LogDebug("SGCannon", "toSpawn %i", toSpawn.spawnPaths.size()); + LOG_DEBUG("toSpawn %i", toSpawn.spawnPaths.size()); const auto pathIndex = GeneralUtils::GenerateRandomNumber(0, toSpawn.spawnPaths.size() - 1); - Game::logger->LogDebug("SGCannon", "index %f", pathIndex); - Game::logger->LogDebug("SGCannon", "%s", toSpawn.spawnPaths.at(pathIndex).c_str()); + LOG_DEBUG("index %f", pathIndex); + LOG_DEBUG("%s", toSpawn.spawnPaths.at(pathIndex).c_str()); const auto* path = Game::zoneManager->GetZone()->GetPath(toSpawn.spawnPaths.at(pathIndex)); if (!path) { - Game::logger->Log("SGCannon", "Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex); + LOG_DEBUG("Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex); return; } - Game::logger->LogDebug("SGCannon", "%s", path->pathName.c_str()); + LOG_DEBUG("%s", path->pathName.c_str()); auto info = EntityInfo{}; info.lot = toSpawn.lot; @@ -297,7 +297,7 @@ void SGCannon::DoSpawnTimerFunc(Entity* self, const std::string& name) { new LDFData(u"groupID", u"SGEnemy") }; - Game::logger->Log("SGCannon", "Spawning enemy %i on path %s", toSpawn.lot, path->pathName.c_str()); + LOG_DEBUG("Spawning enemy %i on path %s", toSpawn.lot, path->pathName.c_str()); auto* enemy = Game::entityManager->CreateEntity(info, nullptr, self); Game::entityManager->ConstructEntity(enemy); @@ -374,7 +374,7 @@ void SGCannon::StartGame(Entity* self) { auto* player = Game::entityManager->GetEntity(self->GetVar(PlayerIDVariable)); if (player != nullptr) { GetLeaderboardData(self, player->GetObjectID(), GetActivityID(self), 1); - Game::logger->Log("SGCannon", "Sending ActivityStart"); + LOG("Sending ActivityStart"); GameMessages::SendActivityStart(self->GetObjectID(), player->GetSystemAddress()); GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"start", ""); @@ -656,7 +656,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time auto scScore = self->GetVar(TotalScoreVariable) - lastSuperTotal; - Game::logger->Log("SGCannon", "LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i", + LOG("LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i", lastSuperTotal, scScore, constants.chargedPoints ); @@ -740,7 +740,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) { auto* player = Game::entityManager->GetEntity(self->GetVar(PlayerIDVariable)); if (player == nullptr) { - Game::logger->Log("SGCannon", "Player not found in toggle super charge"); + LOG("Player not found in toggle super charge"); return; } @@ -748,7 +748,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) { auto equippedItems = inventoryComponent->GetEquippedItems(); - Game::logger->Log("SGCannon", "Player has %d equipped items", equippedItems.size()); + LOG("Player has %d equipped items", equippedItems.size()); auto skillID = constants.cannonSkill; auto cooldown = constants.cannonRefireRate; @@ -756,12 +756,12 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) { auto* selfInventoryComponent = self->GetComponent(); if (inventoryComponent == nullptr) { - Game::logger->Log("SGCannon", "Inventory component not found"); + LOG("Inventory component not found"); return; } if (enable) { - Game::logger->Log("SGCannon", "Player is activating super charge"); + LOG("Player is activating super charge"); selfInventoryComponent->UpdateSlot("greeble_r", { ObjectIDManager::GenerateRandomObjectID(), 6505, 1, 0 }); selfInventoryComponent->UpdateSlot("greeble_l", { ObjectIDManager::GenerateRandomObjectID(), 6506, 1, 0 }); @@ -774,19 +774,19 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) { self->SetNetworkVar(u"SuperChargeBar", 0); - Game::logger->Log("SGCannon", "Player disables super charge"); + LOG("Player disables super charge"); // TODO: Unequip items for (const auto& equipped : equippedItems) { if (equipped.first == "special_r" || equipped.first == "special_l") { - Game::logger->Log("SGCannon", "Trying to unequip a weapon, %i", equipped.second.lot); + LOG("Trying to unequip a weapon, %i", equipped.second.lot); auto* item = inventoryComponent->FindItemById(equipped.second.id); if (item != nullptr) { inventoryComponent->UnEquipItem(item); } else { - Game::logger->Log("SGCannon", "Item not found, %i", equipped.second.lot); + LOG("Item not found, %i", equipped.second.lot); } } } diff --git a/dWorldServer/ObjectIDManager.cpp b/dWorldServer/ObjectIDManager.cpp index 9490c0a7..44a45437 100644 --- a/dWorldServer/ObjectIDManager.cpp +++ b/dWorldServer/ObjectIDManager.cpp @@ -3,7 +3,7 @@ // Custom Classes #include "MasterPackets.h" #include "Database.h" -#include "dLogger.h" +#include "Logger.h" #include "Game.h" // Static Variables diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index 0803bbf7..58539cb0 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -9,7 +9,7 @@ //DLU Includes: #include "dCommonVars.h" #include "dServer.h" -#include "dLogger.h" +#include "Logger.h" #include "Database.h" #include "dConfig.h" #include "dpWorld.h" @@ -76,7 +76,7 @@ #include "CheatDetection.h" namespace Game { - dLogger* logger = nullptr; + Logger* logger = nullptr; dServer* server = nullptr; dpWorld* physicsWorld = nullptr; dChatFilter* chatFilter = nullptr; @@ -98,7 +98,7 @@ void WorldShutdownProcess(uint32_t zoneId); void FinalizeShutdown(); void SendShutdownMessageToMaster(); -dLogger* SetupLogger(uint32_t zoneID, uint32_t instanceID); +Logger* SetupLogger(uint32_t zoneID, uint32_t instanceID); void HandlePacketChat(Packet* packet); void HandlePacket(Packet* packet); @@ -148,9 +148,9 @@ int main(int argc, char** argv) { Game::logger->SetLogToConsole(Game::config->GetValue("log_to_console") != "0"); Game::logger->SetLogDebugStatements(Game::config->GetValue("log_debug_statements") == "1"); - Game::logger->Log("WorldServer", "Starting World server..."); - Game::logger->Log("WorldServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); - Game::logger->Log("WorldServer", "Compiled on: %s", __TIMESTAMP__); + LOG("Starting World server..."); + LOG("Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR); + LOG("Compiled on: %s", __TIMESTAMP__); if (Game::config->GetValue("disable_chat") == "1") chatDisabled = true; @@ -163,7 +163,7 @@ int main(int argc, char** argv) { } Game::assetManager = new AssetManager(clientPath); } catch (std::runtime_error& ex) { - Game::logger->Log("WorldServer", "Got an error while setting up assets: %s", ex.what()); + LOG("Got an error while setting up assets: %s", ex.what()); return EXIT_FAILURE; } @@ -172,9 +172,9 @@ int main(int argc, char** argv) { try { CDClientDatabase::Connect((BinaryPathFinder::GetBinaryDir() / "resServer" / "CDServer.sqlite").string()); } catch (CppSQLite3Exception& e) { - Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database"); - Game::logger->Log("WorldServer", "Error: %s", e.errorMessage()); - Game::logger->Log("WorldServer", "Error Code: %i", e.errorCode()); + LOG("Unable to connect to CDServer SQLite Database"); + LOG("Error: %s", e.errorMessage()); + LOG("Error Code: %i", e.errorCode()); return EXIT_FAILURE; } @@ -195,7 +195,7 @@ int main(int argc, char** argv) { try { Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password); } catch (sql::SQLException& ex) { - Game::logger->Log("WorldServer", "Got an error while connecting to the database: %s", ex.what()); + LOG("Got an error while connecting to the database: %s", ex.what()); return EXIT_FAILURE; } @@ -305,7 +305,7 @@ int main(int argc, char** argv) { delete md5; - Game::logger->Log("WorldServer", "FDB Checksum calculated as: %s", databaseChecksum.c_str()); + LOG("FDB Checksum calculated as: %s", databaseChecksum.c_str()); } uint32_t currentFrameDelta = highFrameDelta; @@ -341,7 +341,7 @@ int main(int argc, char** argv) { float_t ratioBeforeToAfter = (float)currentFrameDelta / (float)newFrameDelta; currentFrameDelta = newFrameDelta; currentFramerate = MS_TO_FRAMES(newFrameDelta); - Game::logger->LogDebug("WorldServer", "Framerate for zone/instance/clone %i/%i/%i is now %i", zoneID, instanceID, cloneID, currentFramerate); + LOG_DEBUG("Framerate for zone/instance/clone %i/%i/%i is now %i", zoneID, instanceID, cloneID, currentFramerate); logFlushTime = 15 * currentFramerate; // 15 seconds in frames framesSinceLastFlush *= ratioBeforeToAfter; shutdownTimeout = 10 * 60 * currentFramerate; // 10 minutes in frames @@ -360,7 +360,7 @@ int main(int argc, char** argv) { //Warning if we ran slow if (deltaTime > currentFrameDelta) { - Game::logger->Log("WorldServer", "We're running behind, dT: %f > %f (framerate %i)", deltaTime, currentFrameDelta, currentFramerate); + LOG("We're running behind, dT: %f > %f (framerate %i)", deltaTime, currentFrameDelta, currentFramerate); } //Check if we're still connected to master: @@ -368,7 +368,7 @@ int main(int argc, char** argv) { framesSinceMasterDisconnect++; if (framesSinceMasterDisconnect >= noMasterConnectionTimeout && !Game::shouldShutdown) { - Game::logger->Log("WorldServer", "Game loop running but no connection to master for %d frames, shutting down", noMasterConnectionTimeout); + LOG("Game loop running but no connection to master for %d frames, shutting down", noMasterConnectionTimeout); Game::shouldShutdown = true; } } else framesSinceMasterDisconnect = 0; @@ -513,7 +513,7 @@ int main(int argc, char** argv) { framesSinceMasterStatus++; if (framesSinceMasterStatus >= 200) { - Game::logger->Log("WorldServer", "Finished loading world with zone (%i), ready up!", Game::server->GetZoneID()); + LOG("Finished loading world with zone (%i), ready up!", Game::server->GetZoneID()); MasterPackets::SendWorldReady(Game::server, Game::server->GetZoneID(), Game::server->GetInstanceID()); @@ -533,7 +533,7 @@ int main(int argc, char** argv) { return EXIT_SUCCESS; } -dLogger* SetupLogger(uint32_t zoneID, uint32_t instanceID) { +Logger* SetupLogger(uint32_t zoneID, uint32_t instanceID) { std::string logPath = (BinaryPathFinder::GetBinaryDir() / ("logs/WorldServer_" + std::to_string(zoneID) + "_" + std::to_string(instanceID) + "_" + std::to_string(time(nullptr)) + ".log")).string(); bool logToConsole = false; bool logDebugStatements = false; @@ -542,18 +542,18 @@ dLogger* SetupLogger(uint32_t zoneID, uint32_t instanceID) { logDebugStatements = true; #endif - return new dLogger(logPath, logToConsole, logDebugStatements); + return new Logger(logPath, logToConsole, logDebugStatements); } void HandlePacketChat(Packet* packet) { if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) { - Game::logger->Log("WorldServer", "Lost our connection to chat, zone(%i), instance(%i)", Game::server->GetZoneID(), Game::server->GetInstanceID()); + LOG("Lost our connection to chat, zone(%i), instance(%i)", Game::server->GetZoneID(), Game::server->GetInstanceID()); chatConnected = false; } if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) { - Game::logger->Log("WorldServer", "Established connection to chat, zone(%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID()); + LOG("Established connection to chat, zone(%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID()); Game::chatSysAddr = packet->systemAddress; chatConnected = true; @@ -648,20 +648,20 @@ void HandlePacketChat(Packet* packet) { if (deleteTeam) { TeamManager::Instance()->DeleteTeam(teamID); - Game::logger->Log("WorldServer", "Deleting team (%llu)", teamID); + LOG("Deleting team (%llu)", teamID); break; } inStream.Read(lootOption); inStream.Read(memberCount); - Game::logger->Log("WorldServer", "Updating team (%llu), (%i), (%i)", teamID, lootOption, memberCount); + LOG("Updating team (%llu), (%i), (%i)", teamID, lootOption, memberCount); for (char i = 0; i < memberCount; i++) { LWOOBJID member = LWOOBJID_EMPTY; inStream.Read(member); members.push_back(member); - Game::logger->Log("WorldServer", "Updating team member (%llu)", member); + LOG("Updating team member (%llu)", member); } TeamManager::Instance()->UpdateTeam(teamID, lootOption, members); @@ -670,7 +670,7 @@ void HandlePacketChat(Packet* packet) { } default: - Game::logger->Log("WorldServer", "Received an unknown chat internal: %i", int(packet->data[3])); + LOG("Received an unknown chat internal: %i", int(packet->data[3])); } } } @@ -702,7 +702,7 @@ void HandlePacket(Packet* packet) { entity->GetCharacter()->SaveXMLToDatabase(); - Game::logger->Log("WorldServer", "Deleting player %llu", entity->GetObjectID()); + LOG("Deleting player %llu", entity->GetObjectID()); Game::entityManager->DestroyEntity(entity); } @@ -769,11 +769,11 @@ void HandlePacket(Packet* packet) { //Verify it: if (userHash != it->second.hash) { - Game::logger->Log("WorldServer", "SOMEONE IS TRYING TO HACK? SESSION KEY MISMATCH: ours: %s != master: %s", userHash.c_str(), it->second.hash.c_str()); + LOG("SOMEONE IS TRYING TO HACK? SESSION KEY MISMATCH: ours: %s != master: %s", userHash.c_str(), it->second.hash.c_str()); Game::server->Disconnect(it->second.sysAddr, eServerDisconnectIdentifiers::INVALID_SESSION_KEY); return; } else { - Game::logger->Log("WorldServer", "User %s authenticated with correct key.", username.c_str()); + LOG("User %s authenticated with correct key.", username.c_str()); UserManager::Instance()->DeleteUser(packet->systemAddress); @@ -818,7 +818,7 @@ void HandlePacket(Packet* packet) { case eMasterMessageType::AFFIRM_TRANSFER_REQUEST: { const uint64_t requestID = PacketUtils::ReadU64(8, packet); - Game::logger->Log("MasterServer", "Got affirmation request of transfer %llu", requestID); + LOG("Got affirmation request of transfer %llu", requestID); CBITSTREAM; @@ -831,7 +831,7 @@ void HandlePacket(Packet* packet) { case eMasterMessageType::SHUTDOWN: { Game::shouldShutdown = true; - Game::logger->Log("WorldServer", "Got shutdown request from master, zone (%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID()); + LOG("Got shutdown request from master, zone (%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID()); break; } @@ -853,13 +853,13 @@ void HandlePacket(Packet* packet) { //Find them: User* user = UserManager::Instance()->GetUser(username.c_str()); if (!user) { - Game::logger->Log("WorldServer", "Got new session alert for user %s, but they're not logged in.", username.c_str()); + LOG("Got new session alert for user %s, but they're not logged in.", username.c_str()); return; } //Check the key: if (sessionKey != std::atoi(user->GetSessionKey().c_str())) { - Game::logger->Log("WorldServer", "Got new session alert for user %s, but the session key is invalid.", username.c_str()); + LOG("Got new session alert for user %s, but the session key is invalid.", username.c_str()); Game::server->Disconnect(user->GetSystemAddress(), eServerDisconnectIdentifiers::INVALID_SESSION_KEY); return; } @@ -867,7 +867,7 @@ void HandlePacket(Packet* packet) { } default: - Game::logger->Log("WorldServer", "Unknown packet ID from master %i", int(packet->data[3])); + LOG("Unknown packet ID from master %i", int(packet->data[3])); } return; @@ -900,7 +900,7 @@ void HandlePacket(Packet* packet) { // Developers may skip this check if (gmLevel < 8 && clientDatabaseChecksum != databaseChecksum) { - Game::logger->Log("WorldServer", "Client's database checksum does not match the server's, aborting connection."); + LOG("Client's database checksum does not match the server's, aborting connection."); Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::WRONG_GAME_VERSION); return; } @@ -1023,7 +1023,7 @@ void HandlePacket(Packet* packet) { } case eWorldMessageType::LEVEL_LOAD_COMPLETE: { - Game::logger->Log("WorldServer", "Received level load complete from user."); + LOG("Received level load complete from user."); User* user = UserManager::Instance()->GetUser(packet->systemAddress); if (user) { Character* c = user->GetLastUsedChar(); @@ -1062,15 +1062,15 @@ void HandlePacket(Packet* packet) { case eCharacterVersion::RELEASE: // TODO: Implement, super low priority case eCharacterVersion::LIVE: - Game::logger->Log("WorldServer", "Updating Character Flags"); + LOG("Updating Character Flags"); c->SetRetroactiveFlags(); levelComponent->SetCharacterVersion(eCharacterVersion::PLAYER_FACTION_FLAGS); case eCharacterVersion::PLAYER_FACTION_FLAGS: - Game::logger->Log("WorldServer", "Updating Vault Size"); + LOG("Updating Vault Size"); player->RetroactiveVaultSize(); levelComponent->SetCharacterVersion(eCharacterVersion::VAULT_SIZE); case eCharacterVersion::VAULT_SIZE: - Game::logger->Log("WorldServer", "Updaing Speedbase"); + LOG("Updaing Speedbase"); levelComponent->SetRetroactiveBaseSpeed(); levelComponent->SetCharacterVersion(eCharacterVersion::UP_TO_DATE); case eCharacterVersion::UP_TO_DATE: @@ -1100,7 +1100,7 @@ void HandlePacket(Packet* packet) { auto result = query.execQuery(); if (result.eof() || result.fieldIsNull(0)) { - Game::logger->Log("WorldServer", "No property templates found for zone %d, not sending BBB", zoneId); + LOG("No property templates found for zone %d, not sending BBB", zoneId); goto noBBB; } @@ -1128,7 +1128,7 @@ void HandlePacket(Packet* packet) { stmt->setUInt64(1, propertyId); auto res = stmt->executeQuery(); while (res->next()) { - Game::logger->Log("UGC", "Getting lxfml ugcID: %u", res->getUInt(1)); + LOG("Getting lxfml ugcID: %u", res->getUInt(1)); //Get lxfml: auto stmtL = Database::CreatePreppedStmt("SELECT lxfml from ugc where id=?"); @@ -1207,11 +1207,11 @@ void HandlePacket(Packet* packet) { Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false); } } else { - Game::logger->Log("WorldServer", "Couldn't find character to log in with for user %s (%i)!", user->GetUsername().c_str(), user->GetAccountID()); + LOG("Couldn't find character to log in with for user %s (%i)!", user->GetUsername().c_str(), user->GetAccountID()); Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND); } } else { - Game::logger->Log("WorldServer", "Couldn't get user for level load complete!"); + LOG("Couldn't get user for level load complete!"); } break; } @@ -1237,7 +1237,7 @@ void HandlePacket(Packet* packet) { inStream.Read(size); if (size > 20000) { - Game::logger->Log("WorldServer", "Tried to route a packet with a read size > 20000, so likely a false packet."); + LOG("Tried to route a packet with a read size > 20000, so likely a false packet."); return; } @@ -1298,36 +1298,36 @@ void HandlePacket(Packet* packet) { } default: - Game::server->GetLogger()->Log("HandlePacket", "Unknown world packet received: %i", int(packet->data[3])); + LOG("Unknown world packet received: %i", int(packet->data[3])); } } void WorldShutdownProcess(uint32_t zoneId) { - Game::logger->Log("WorldServer", "Saving map %i instance %i", zoneId, instanceID); + LOG("Saving map %i instance %i", zoneId, instanceID); for (auto i = 0; i < Game::server->GetReplicaManager()->GetParticipantCount(); ++i) { const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(i); auto* entity = Player::GetPlayer(player); - Game::logger->Log("WorldServer", "Saving data!"); + LOG("Saving data!"); if (entity != nullptr && entity->GetCharacter() != nullptr) { auto* skillComponent = entity->GetComponent(); if (skillComponent != nullptr) { skillComponent->Reset(); } - Game::logger->Log("WorldServer", "Saving character %s...", entity->GetCharacter()->GetName().c_str()); + LOG("Saving character %s...", entity->GetCharacter()->GetName().c_str()); entity->GetCharacter()->SaveXMLToDatabase(); - Game::logger->Log("WorldServer", "Character data for %s was saved!", entity->GetCharacter()->GetName().c_str()); + LOG("Character data for %s was saved!", entity->GetCharacter()->GetName().c_str()); } } if (PropertyManagementComponent::Instance() != nullptr) { - Game::logger->Log("WorldServer", "Saving ALL property data for zone %i clone %i!", zoneId, PropertyManagementComponent::Instance()->GetCloneId()); + LOG("Saving ALL property data for zone %i clone %i!", zoneId, PropertyManagementComponent::Instance()->GetCloneId()); PropertyManagementComponent::Instance()->Save(); - Game::logger->Log("WorldServer", "ALL property data saved for zone %i clone %i!", zoneId, PropertyManagementComponent::Instance()->GetCloneId()); + LOG("ALL property data saved for zone %i clone %i!", zoneId, PropertyManagementComponent::Instance()->GetCloneId()); } - Game::logger->Log("WorldServer", "ALL DATA HAS BEEN SAVED FOR ZONE %i INSTANCE %i!", zoneId, instanceID); + LOG("ALL DATA HAS BEEN SAVED FOR ZONE %i INSTANCE %i!", zoneId, instanceID); while (Game::server->GetReplicaManager()->GetParticipantCount() > 0) { const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(0); @@ -1344,13 +1344,13 @@ void WorldShutdownSequence() { Game::shouldShutdown = true; - Game::logger->Log("WorldServer", "Zone (%i) instance (%i) shutting down outside of main loop!", Game::server->GetZoneID(), instanceID); + LOG("Zone (%i) instance (%i) shutting down outside of main loop!", Game::server->GetZoneID(), instanceID); WorldShutdownProcess(Game::server->GetZoneID()); FinalizeShutdown(); } void FinalizeShutdown() { - Game::logger->Log("WorldServer", "Shutdown complete, zone (%i), instance (%i)", Game::server->GetZoneID(), instanceID); + LOG("Shutdown complete, zone (%i), instance (%i)", Game::server->GetZoneID(), instanceID); //Delete our objects here: Metrics::Clear(); diff --git a/dZoneManager/Level.cpp b/dZoneManager/Level.cpp index 7d248588..953b11e2 100644 --- a/dZoneManager/Level.cpp +++ b/dZoneManager/Level.cpp @@ -5,7 +5,7 @@ #include #include #include "BinaryIO.h" -#include "dLogger.h" +#include "Logger.h" #include "Spawner.h" #include "dZoneManager.h" #include "GeneralUtils.h" @@ -21,7 +21,7 @@ Level::Level(Zone* parentZone, const std::string& filepath) { auto buffer = Game::assetManager->GetFileAsBuffer(filepath.c_str()); if (!buffer.m_Success) { - Game::logger->Log("Level", "Failed to load %s", filepath.c_str()); + LOG("Failed to load %s", filepath.c_str()); return; } diff --git a/dZoneManager/Spawner.cpp b/dZoneManager/Spawner.cpp index bd1970c6..8cf7b809 100644 --- a/dZoneManager/Spawner.cpp +++ b/dZoneManager/Spawner.cpp @@ -1,6 +1,6 @@ #include "Spawner.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" #include "Game.h" #include #include diff --git a/dZoneManager/Zone.cpp b/dZoneManager/Zone.cpp index 07b3d72c..18de939c 100644 --- a/dZoneManager/Zone.cpp +++ b/dZoneManager/Zone.cpp @@ -3,7 +3,7 @@ #include #include #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "GeneralUtils.h" #include "BinaryIO.h" #include "LUTriggers.h" @@ -29,7 +29,7 @@ Zone::Zone(const LWOMAPID& mapID, const LWOINSTANCEID& instanceID, const LWOCLON } Zone::~Zone() { - Game::logger->Log("Zone", "Destroying zone %i", m_ZoneID.GetMapID()); + LOG("Destroying zone %i", m_ZoneID.GetMapID()); for (std::map::iterator it = m_Scenes.begin(); it != m_Scenes.end(); ++it) { if (it->second.level != nullptr) delete it->second.level; } @@ -49,7 +49,7 @@ void Zone::LoadZoneIntoMemory() { AssetMemoryBuffer buffer = Game::assetManager->GetFileAsBuffer(m_ZoneFilePath.c_str()); if (!buffer.m_Success) { - Game::logger->Log("Zone", "Failed to load %s", m_ZoneFilePath.c_str()); + LOG("Failed to load %s", m_ZoneFilePath.c_str()); throw std::runtime_error("Aborting Zone loading due to no Zone File."); } @@ -61,7 +61,7 @@ void Zone::LoadZoneIntoMemory() { if (m_FileFormatVersion >= Zone::FileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision); BinaryIO::BinaryRead(file, m_WorldID); - if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) Game::logger->Log("Zone", "WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID()); + if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) LOG("WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID()); AddRevision(LWOSCENEID_INVALID, mapRevision); @@ -156,7 +156,7 @@ void Zone::LoadZoneIntoMemory() { } } } else { - Game::logger->Log("Zone", "Failed to open: %s", m_ZoneFilePath.c_str()); + LOG("Failed to open: %s", m_ZoneFilePath.c_str()); } m_ZonePath = m_ZoneFilePath.substr(0, m_ZoneFilePath.rfind('/') + 1); @@ -223,7 +223,7 @@ void Zone::AddRevision(LWOSCENEID sceneID, uint32_t revision) { const void Zone::PrintAllGameObjects() { for (std::pair scene : m_Scenes) { - Game::logger->Log("Zone", "In sceneID: %i", scene.first.GetSceneID()); + LOG("In sceneID: %i", scene.first.GetSceneID()); scene.second.level->PrintAllObjects(); } } @@ -279,7 +279,7 @@ std::vector Zone::LoadLUTriggers(std::string triggerFile, auto buffer = Game::assetManager->GetFileAsBuffer((m_ZonePath + triggerFile).c_str()); if (!buffer.m_Success) { - Game::logger->Log("Zone", "Failed to load %s from disk. Skipping loading triggers", (m_ZonePath + triggerFile).c_str()); + LOG("Failed to load %s from disk. Skipping loading triggers", (m_ZonePath + triggerFile).c_str()); return lvlTriggers; } @@ -295,9 +295,9 @@ std::vector Zone::LoadLUTriggers(std::string triggerFile, if (!doc) return lvlTriggers; if (doc->Parse(data.str().c_str(), data.str().size()) == 0) { - //Game::logger->Log("Zone", "Loaded LUTriggers from file %s!", triggerFile.c_str()); + //LOG("Loaded LUTriggers from file %s!", triggerFile.c_str()); } else { - Game::logger->Log("Zone", "Failed to load LUTriggers from file %s", triggerFile.c_str()); + LOG("Failed to load LUTriggers from file %s", triggerFile.c_str()); return lvlTriggers; } diff --git a/dZoneManager/dZoneManager.cpp b/dZoneManager/dZoneManager.cpp index 7b352a57..c87619cd 100644 --- a/dZoneManager/dZoneManager.cpp +++ b/dZoneManager/dZoneManager.cpp @@ -2,7 +2,7 @@ #include "dCommonVars.h" #include "dZoneManager.h" #include "EntityManager.h" -#include "dLogger.h" +#include "Logger.h" #include "dConfig.h" #include "InventoryComponent.h" #include "DestroyableComponent.h" @@ -18,7 +18,7 @@ #include "../dWorldServer/ObjectIDManager.h" void dZoneManager::Initialize(const LWOZONEID& zoneID) { - Game::logger->Log("dZoneManager", "Preparing zone: %i/%i/%i", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID()); + LOG("Preparing zone: %i/%i/%i", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID()); int64_t startTime = 0; int64_t endTime = 0; @@ -43,11 +43,11 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) { } } - Game::logger->Log("dZoneManager", "Creating zone control object %i", zoneControlTemplate); + LOG("Creating zone control object %i", zoneControlTemplate); // Create ZoneControl object if (!Game::entityManager) { - Game::logger->Log("dZoneManager", "ERROR: No entity manager loaded. Cannot proceed."); + LOG("ERROR: No entity manager loaded. Cannot proceed."); throw std::invalid_argument("No entity manager loaded. Cannot proceed."); } Game::entityManager->Initialize(); @@ -63,7 +63,7 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) { LoadWorldConfig(); - Game::logger->Log("dZoneManager", "Zone prepared in: %llu ms", (endTime - startTime)); + LOG("Zone prepared in: %llu ms", (endTime - startTime)); VanityUtilities::SpawnVanity(); } @@ -100,7 +100,7 @@ void dZoneManager::NotifyZone(const dZoneNotifier& notifier, const LWOOBJID& obj case dZoneNotifier::SpawnedChildObjectDestroyed: break; case dZoneNotifier::ReloadZone: - Game::logger->Log("dZoneManager", "Forcing reload of zone %i", m_ZoneID.GetMapID()); + LOG("Forcing reload of zone %i", m_ZoneID.GetMapID()); LoadZone(m_ZoneID); m_pZone->Initalize(); @@ -113,10 +113,10 @@ void dZoneManager::NotifyZone(const dZoneNotifier& notifier, const LWOOBJID& obj m_pZone->PrintAllGameObjects(); break; case dZoneNotifier::InvalidNotifier: - Game::logger->Log("dZoneManager", "Got an invalid zone notifier."); + LOG("Got an invalid zone notifier."); break; default: - Game::logger->Log("dZoneManager", "Unknown zone notifier: %i", int(notifier)); + LOG("Unknown zone notifier: %i", int(notifier)); } } @@ -174,7 +174,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id) { auto* spawner = GetSpawner(id); if (spawner == nullptr) { - Game::logger->Log("dZoneManager", "Failed to find spawner (%llu)", id); + LOG("Failed to find spawner (%llu)", id); return; } @@ -184,14 +184,14 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id) { entity->Kill(); } else { - Game::logger->Log("dZoneManager", "Failed to find spawner entity (%llu)", id); + LOG("Failed to find spawner entity (%llu)", id); } spawner->DestroyAllEntities(); spawner->Deactivate(); - Game::logger->Log("dZoneManager", "Destroying spawner (%llu)", id); + LOG("Destroying spawner (%llu)", id); m_Spawners.erase(id); @@ -244,14 +244,14 @@ bool dZoneManager::CheckIfAccessibleZone(LWOMAPID zoneID) { } void dZoneManager::LoadWorldConfig() { - Game::logger->Log("dZoneManager", "Loading WorldConfig into memory"); + LOG("Loading WorldConfig into memory"); auto worldConfig = CDClientDatabase::ExecuteQuery("SELECT * FROM WorldConfig;"); if (!m_WorldConfig) m_WorldConfig = new WorldConfig(); if (worldConfig.eof()) { - Game::logger->Log("dZoneManager", "WorldConfig table is empty. Is this intended?"); + LOG("WorldConfig table is empty. Is this intended?"); return; } @@ -314,5 +314,5 @@ void dZoneManager::LoadWorldConfig() { m_WorldConfig->characterVersion = worldConfig.getIntField("CharacterVersion"); m_WorldConfig->levelCapCurrencyConversion = worldConfig.getIntField("LevelCapCurrencyConversion"); worldConfig.finalize(); - Game::logger->Log("dZoneManager", "Loaded WorldConfig into memory"); + LOG("Loaded WorldConfig into memory"); } diff --git a/tests/dCommonTests/AMFDeserializeTests.cpp b/tests/dCommonTests/AMFDeserializeTests.cpp index 5a9d91e6..58c46584 100644 --- a/tests/dCommonTests/AMFDeserializeTests.cpp +++ b/tests/dCommonTests/AMFDeserializeTests.cpp @@ -6,7 +6,7 @@ #include "Amf3.h" #include "Game.h" -#include "dLogger.h" +#include "Logger.h" /** * Helper method that all tests use to get their respective AMF. diff --git a/tests/dCommonTests/TestLDFFormat.cpp b/tests/dCommonTests/TestLDFFormat.cpp index 9ca84775..7baa5a0b 100644 --- a/tests/dCommonTests/TestLDFFormat.cpp +++ b/tests/dCommonTests/TestLDFFormat.cpp @@ -4,7 +4,7 @@ #include "Game.h" #include "dCommonDependencies.h" -#include "dLogger.h" +#include "Logger.h" class LDFTests : public dCommonDependenciesTest { protected: @@ -237,7 +237,7 @@ TEST_F(LDFTests, LDFParseEdgeCaseTest) { "key=Garbage:value", // invalid LDF type }; for (auto testString : tests) { - Game::logger->Log("LDFTests", "Testing LDF Parsing of invalid string (%s)", testString.c_str()); + LOG("Testing LDF Parsing of invalid string (%s)", testString.c_str()); EXPECT_NO_THROW(LDFBaseData::DataFromString(testString)); } } diff --git a/tests/dCommonTests/dCommonDependencies.cpp b/tests/dCommonTests/dCommonDependencies.cpp index 5b25fd47..89e9fd87 100644 --- a/tests/dCommonTests/dCommonDependencies.cpp +++ b/tests/dCommonTests/dCommonDependencies.cpp @@ -1,7 +1,7 @@ #include "Game.h" -class dLogger; +class Logger; namespace Game { - dLogger* logger; + Logger* logger; } // namespace Game diff --git a/tests/dCommonTests/dCommonDependencies.h b/tests/dCommonTests/dCommonDependencies.h index 12aeb938..228c3c52 100644 --- a/tests/dCommonTests/dCommonDependencies.h +++ b/tests/dCommonTests/dCommonDependencies.h @@ -2,7 +2,7 @@ #define __DCOMMONDEPENDENCIES__H__ #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "dServer.h" #include "EntityInfo.h" #include "EntityManager.h" @@ -12,7 +12,7 @@ class dCommonDependenciesTest : public ::testing::Test { protected: void SetUpDependencies() { - Game::logger = new dLogger("./testing.log", true, true); + Game::logger = new Logger("./testing.log", true, true); } void TearDownDependencies() { diff --git a/tests/dGameTests/GameDependencies.cpp b/tests/dGameTests/GameDependencies.cpp index 1765bd9b..32563209 100644 --- a/tests/dGameTests/GameDependencies.cpp +++ b/tests/dGameTests/GameDependencies.cpp @@ -1,7 +1,7 @@ #include "GameDependencies.h" namespace Game { - dLogger* logger = nullptr; + Logger* logger = nullptr; dServer* server = nullptr; dZoneManager* zoneManager = nullptr; dChatFilter* chatFilter = nullptr; diff --git a/tests/dGameTests/GameDependencies.h b/tests/dGameTests/GameDependencies.h index 95ef2f9f..096dcb13 100644 --- a/tests/dGameTests/GameDependencies.h +++ b/tests/dGameTests/GameDependencies.h @@ -2,7 +2,7 @@ #define __GAMEDEPENDENCIES__H__ #include "Game.h" -#include "dLogger.h" +#include "Logger.h" #include "dServer.h" #include "EntityInfo.h" #include "EntityManager.h" @@ -29,7 +29,7 @@ protected: info.scale = 1.0f; info.spawner = nullptr; info.lot = 999; - Game::logger = new dLogger("./testing.log", true, true); + Game::logger = new Logger("./testing.log", true, true); Game::server = new dServerMock(); Game::config = new dConfig("worldconfig.ini"); Game::entityManager = new EntityManager();