mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
converting more format strings
This commit is contained in:
parent
494c2b5784
commit
ceb1d5d82a
@ -41,7 +41,7 @@ template <typename T>
|
|||||||
class location_wrapper {
|
class location_wrapper {
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
template <std::convertible_to<T> U = T>
|
template <typename U = T>
|
||||||
consteval location_wrapper(const U val, const std::source_location loc = std::source_location::current())
|
consteval location_wrapper(const U val, const std::source_location loc = std::source_location::current())
|
||||||
: m_Obj(val)
|
: m_Obj(val)
|
||||||
, m_Loc(loc) {
|
, m_Loc(loc) {
|
||||||
@ -67,12 +67,15 @@ protected:
|
|||||||
*/
|
*/
|
||||||
namespace Log {
|
namespace Log {
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
constexpr tm Time() { // TODO: Move?
|
[[nodiscard]] inline tm Time() { // TODO: Move?
|
||||||
return fmt::localtime(std::time(nullptr));
|
return fmt::localtime(std::time(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
constexpr void Info(const location_wrapper<fmt::format_string<Ts...>> fmt_str, Ts&&... args) {
|
using FormatString = location_wrapper<fmt::format_string<Ts...>>;
|
||||||
|
|
||||||
|
template <typename... Ts>
|
||||||
|
inline void Info(const FormatString<Ts...> fmt_str, Ts&&... args) {
|
||||||
const auto filename = GetFileNameFromAbsolutePath(fmt_str.loc().file_name());
|
const auto filename = GetFileNameFromAbsolutePath(fmt_str.loc().file_name());
|
||||||
|
|
||||||
fmt::print("[{:%d-%m-%y %H:%M:%S} {:s}:{:d}] ", Time(), filename, fmt_str.loc().line());
|
fmt::print("[{:%d-%m-%y %H:%M:%S} {:s}:{:d}] ", Time(), filename, fmt_str.loc().line());
|
||||||
@ -80,7 +83,7 @@ namespace Log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
constexpr void Warn(const location_wrapper<fmt::format_string<Ts...>> fmt_str, Ts&&... args) {
|
inline void Warn(const FormatString<Ts...> fmt_str, Ts&&... args) {
|
||||||
const auto filename = GetFileNameFromAbsolutePath(fmt_str.loc().file_name());
|
const auto filename = GetFileNameFromAbsolutePath(fmt_str.loc().file_name());
|
||||||
|
|
||||||
fmt::print("[{:%d-%m-%y %H:%M:%S} {:s}:{:d}] Warning: ", Time(), filename, fmt_str.loc().line());
|
fmt::print("[{:%d-%m-%y %H:%M:%S} {:s}:{:d}] Warning: ", Time(), filename, fmt_str.loc().line());
|
||||||
@ -88,7 +91,7 @@ namespace Log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
constexpr void Debug(const location_wrapper<fmt::format_string<Ts...>> fmt_str, Ts&&... args) {
|
inline void Debug(const FormatString<Ts...> fmt_str, Ts&&... args) {
|
||||||
// if (!m_logDebugStatements) return;
|
// if (!m_logDebugStatements) return;
|
||||||
Log::Info(fmt_str, std::forward<Ts>(args)...);
|
Log::Info(fmt_str, std::forward<Ts>(args)...);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
|||||||
|
|
||||||
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
|
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
|
||||||
if (!character) {
|
if (!character) {
|
||||||
LOG("Failed to find char tag while loading XML!");
|
Log::Warn("Failed to find char tag while loading XML!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (character->QueryAttribute("rpt", &m_Reputation) == tinyxml2::XML_NO_ATTRIBUTE) {
|
if (character->QueryAttribute("rpt", &m_Reputation) == tinyxml2::XML_NO_ATTRIBUTE) {
|
||||||
@ -302,7 +302,7 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
|||||||
void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
||||||
tinyxml2::XMLElement* minifig = doc->FirstChildElement("obj")->FirstChildElement("mf");
|
tinyxml2::XMLElement* minifig = doc->FirstChildElement("obj")->FirstChildElement("mf");
|
||||||
if (!minifig) {
|
if (!minifig) {
|
||||||
LOG("Failed to find mf tag while updating XML!");
|
Log::Warn("Failed to find mf tag while updating XML!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
|||||||
|
|
||||||
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
|
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
|
||||||
if (!character) {
|
if (!character) {
|
||||||
LOG("Failed to find char tag while updating XML!");
|
Log::Warn("Failed to find char tag while updating XML!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
auto newUpdateTimestamp = std::time(nullptr);
|
auto newUpdateTimestamp = std::time(nullptr);
|
||||||
LOG("Time since last save: %d", newUpdateTimestamp - m_LastUpdateTimestamp);
|
Log::Warn("Time since last save: {:d}", newUpdateTimestamp - m_LastUpdateTimestamp);
|
||||||
|
|
||||||
m_TotalTimePlayed += newUpdateTimestamp - m_LastUpdateTimestamp;
|
m_TotalTimePlayed += newUpdateTimestamp - m_LastUpdateTimestamp;
|
||||||
character->SetAttribute("time", m_TotalTimePlayed);
|
character->SetAttribute("time", m_TotalTimePlayed);
|
||||||
@ -405,7 +405,7 @@ Item* CharacterComponent::GetRocket(Entity* player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!rocket) {
|
if (!rocket) {
|
||||||
LOG("Unable to find rocket to equip!");
|
Log::Warn("Unable to find rocket to equip!");
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
return rocket;
|
return rocket;
|
||||||
@ -772,7 +772,7 @@ void CharacterComponent::AwardClaimCodes() {
|
|||||||
|
|
||||||
auto* cdrewardCodes = CDClientManager::GetTable<CDRewardCodesTable>();
|
auto* cdrewardCodes = CDClientManager::GetTable<CDRewardCodesTable>();
|
||||||
for (auto const rewardCode : rewardCodes) {
|
for (auto const rewardCode : rewardCodes) {
|
||||||
LOG_DEBUG("Processing RewardCode %i", rewardCode);
|
Log::Debug("Processing RewardCode {:d}", rewardCode);
|
||||||
const uint32_t rewardCodeIndex = rewardCode >> 6;
|
const uint32_t rewardCodeIndex = rewardCode >> 6;
|
||||||
const uint32_t bitIndex = rewardCode % 64;
|
const uint32_t bitIndex = rewardCode % 64;
|
||||||
if (GeneralUtils::CheckBit(m_ClaimCodes[rewardCodeIndex], bitIndex)) continue;
|
if (GeneralUtils::CheckBit(m_ClaimCodes[rewardCodeIndex], bitIndex)) continue;
|
||||||
|
@ -47,7 +47,7 @@ Mission::Mission(MissionComponent* missionComponent, const uint32_t missionId) {
|
|||||||
info = *mis;
|
info = *mis;
|
||||||
|
|
||||||
if (mis == &CDMissionsTable::Default) {
|
if (mis == &CDMissionsTable::Default) {
|
||||||
LOG("Failed to find mission (%i)!", missionId);
|
Log::Info("Failed to find mission ({:d})!", missionId);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -53,18 +53,18 @@ void AuthPackets::HandleHandshake(dServer* server, Packet* packet) {
|
|||||||
|
|
||||||
ServiceId serviceId;
|
ServiceId serviceId;
|
||||||
inStream.Read(serviceId);
|
inStream.Read(serviceId);
|
||||||
if (serviceId != ServiceId::Client) LOG("WARNING: Service ID is not a Client!");
|
if (serviceId != ServiceId::Client) Log::Warn("Service ID is not a Client!");
|
||||||
|
|
||||||
uint32_t processID;
|
uint32_t processID;
|
||||||
inStream.Read(processID);
|
inStream.Read(processID);
|
||||||
|
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
inStream.Read(port);
|
inStream.Read(port);
|
||||||
if (port != packet->systemAddress.port) LOG("WARNING: Port written in packet does not match the port the client is connecting over!");
|
if (port != packet->systemAddress.port) Log::Warn("Port written in packet does not match the port the client is connecting over!");
|
||||||
|
|
||||||
inStream.IgnoreBytes(33);
|
inStream.IgnoreBytes(33);
|
||||||
|
|
||||||
LOG_DEBUG("Client Data [Version: %i, Service: %s, Process: %u, Port: %u, Sysaddr Port: %u]", clientVersion, StringifiedEnum::ToString(serviceId).data(), processID, port, packet->systemAddress.port);
|
Log::Debug("Client Data [Version: {:d}, Service: {:s}, Process: {:d}, Port: {:d}, Sysaddr Port: {:d}]", clientVersion, StringifiedEnum::ToString(serviceId), processID, port, packet->systemAddress.port);
|
||||||
|
|
||||||
SendHandshake(server, packet->systemAddress, server->GetIP(), server->GetPort(), server->GetServerType());
|
SendHandshake(server, packet->systemAddress, server->GetIP(), server->GetPort(), server->GetServerType());
|
||||||
}
|
}
|
||||||
@ -102,20 +102,20 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
|
|||||||
|
|
||||||
LanguageCodeID locale_id;
|
LanguageCodeID locale_id;
|
||||||
inStream.Read(locale_id);
|
inStream.Read(locale_id);
|
||||||
LOG_DEBUG("Locale ID: %s", StringifiedEnum::ToString(locale_id).data());
|
Log::Debug("Locale ID: {:s}", StringifiedEnum::ToString(locale_id));
|
||||||
|
|
||||||
ClientOS clientOS;
|
ClientOS clientOS;
|
||||||
inStream.Read(clientOS);
|
inStream.Read(clientOS);
|
||||||
LOG_DEBUG("Operating System: %s", StringifiedEnum::ToString(clientOS).data());
|
Log::Debug("Operating System: {:s}", StringifiedEnum::ToString(clientOS));
|
||||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_CLIENT_OS, 0);
|
stamps.emplace_back(eStamps::PASSPORT_AUTH_CLIENT_OS, 0);
|
||||||
|
|
||||||
LUWString memoryStats(256);
|
LUWString memoryStats(256);
|
||||||
inStream.Read(memoryStats);
|
inStream.Read(memoryStats);
|
||||||
LOG_DEBUG("Memory Stats [%s]", memoryStats.GetAsString().c_str());
|
Log::Debug("Memory Stats {:s}", memoryStats.GetAsString());
|
||||||
|
|
||||||
LUWString videoCard(128);
|
LUWString videoCard(128);
|
||||||
inStream.Read(videoCard);
|
inStream.Read(videoCard);
|
||||||
LOG_DEBUG("VideoCard Info: [%s]", videoCard.GetAsString().c_str());
|
Log::Debug("VideoCard Info: {:s}", videoCard.GetAsString());
|
||||||
|
|
||||||
// Processor/CPU info
|
// Processor/CPU info
|
||||||
uint32_t numOfProcessors;
|
uint32_t numOfProcessors;
|
||||||
@ -126,7 +126,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
|
|||||||
inStream.Read(processorLevel);
|
inStream.Read(processorLevel);
|
||||||
uint16_t processorRevision;
|
uint16_t processorRevision;
|
||||||
inStream.Read(processorRevision);
|
inStream.Read(processorRevision);
|
||||||
LOG_DEBUG("CPU Info: [#Processors: %i, Processor Type: %i, Processor Level: %i, Processor Revision: %i]", numOfProcessors, processorType, processorLevel, processorRevision);
|
Log::Debug("CPU Info: [#Processors: {:d}, Processor Type: {:d}, Processor Level: {:d}, Processor Revision: {:d}]", numOfProcessors, processorType, processorLevel, processorRevision);
|
||||||
|
|
||||||
// OS Info
|
// OS Info
|
||||||
uint32_t osVersionInfoSize;
|
uint32_t osVersionInfoSize;
|
||||||
@ -139,13 +139,13 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
|
|||||||
inStream.Read(buildNumber);
|
inStream.Read(buildNumber);
|
||||||
uint32_t platformID;
|
uint32_t platformID;
|
||||||
inStream.Read(platformID);
|
inStream.Read(platformID);
|
||||||
LOG_DEBUG("OS Info: [Size: %i, Major: %i, Minor %i, Buid#: %i, platformID: %i]", osVersionInfoSize, majorVersion, minorVersion, buildNumber, platformID);
|
Log::Debug("OS Info: [Size: {:d}, Major: {:d}, Minor {:d}, Buid#: {:d}, platformID: {:d}]", osVersionInfoSize, majorVersion, minorVersion, buildNumber, platformID);
|
||||||
|
|
||||||
// Fetch account details
|
// Fetch account details
|
||||||
auto accountInfo = Database::Get()->GetAccountInfo(username);
|
auto accountInfo = Database::Get()->GetAccountInfo(username);
|
||||||
|
|
||||||
if (!accountInfo) {
|
if (!accountInfo) {
|
||||||
LOG("No user by name %s found!", username.c_str());
|
Log::Info("No user by name {:s} found!", username);
|
||||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username, stamps);
|
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username, stamps);
|
||||||
return;
|
return;
|
||||||
@ -164,7 +164,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
|
|||||||
if (accountInfo->playKeyId == 0) {
|
if (accountInfo->playKeyId == 0) {
|
||||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username, stamps);
|
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username, stamps);
|
||||||
LOG("User %s tried to log in, but they don't have a play key.", username.c_str());
|
Log::Info("User {:s} tried to log in, but they don't have a play key.", username);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
|
|||||||
if (!playKeyStatus.value()) {
|
if (!playKeyStatus.value()) {
|
||||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username, stamps);
|
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username, stamps);
|
||||||
LOG("User %s tried to log in, but their play key was disabled", username.c_str());
|
Log::Info("User {:s} tried to log in, but their play key was disabled", username);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (Game::config->GetValue("dont_use_keys") == "1" || accountInfo->maxGmLevel > eGameMasterLevel::CIVILIAN){
|
} else if (Game::config->GetValue("dont_use_keys") == "1" || accountInfo->maxGmLevel > eGameMasterLevel::CIVILIAN){
|
||||||
@ -204,7 +204,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
|
|||||||
if (!loginSuccess) {
|
if (!loginSuccess) {
|
||||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username, stamps);
|
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username, stamps);
|
||||||
LOG("Wrong password used");
|
Log::Info("Wrong password used");
|
||||||
} else {
|
} else {
|
||||||
SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main
|
SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main
|
||||||
|
|
||||||
@ -302,6 +302,6 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
|||||||
bitStream.Write(LUString(username));
|
bitStream.Write(LUString(username));
|
||||||
server->SendToMaster(bitStream);
|
server->SendToMaster(bitStream);
|
||||||
|
|
||||||
LOG("Set sessionKey: %i for user %s", sessionKey, username.c_str());
|
Log::Info("Set sessionKey: {:d} for user {:s}", sessionKey, username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, int64_t rep
|
|||||||
|
|
||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
delete[] compressedData;
|
delete[] compressedData;
|
||||||
LOG("Sent CreateCharacter for ID: %llu", player);
|
Log::Info("Sent CreateCharacter for ID: {:d}", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector<std::pair<uint8_t, uint8_t>> unacceptedItems) {
|
void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector<std::pair<uint8_t, uint8_t>> unacceptedItems) {
|
||||||
|
@ -65,10 +65,13 @@ dServer::dServer(const std::string& ip, int port, int instanceID, int maxConnect
|
|||||||
|
|
||||||
if (mIsOkay) {
|
if (mIsOkay) {
|
||||||
if (zoneID == 0)
|
if (zoneID == 0)
|
||||||
LOG("%s Server is listening on %s:%i with encryption: %i", StringifiedEnum::ToString(serverType).data(), ip.c_str(), port, int(useEncryption));
|
Log::Info("{:s} Server is listening on {:s}:{:d} with encryption: '{}'", StringifiedEnum::ToString(serverType), ip, port, useEncryption);
|
||||||
else
|
else
|
||||||
LOG("%s Server is listening on %s:%i with encryption: %i, running zone %i / %i", StringifiedEnum::ToString(serverType).data(), ip.c_str(), port, int(useEncryption), zoneID, instanceID);
|
Log::Info("{:s} Server is listening on {:s}:{:d} with encryption: '{}' running zone {:d} / {:d}", StringifiedEnum::ToString(serverType), ip, port, useEncryption, zoneID, instanceID);
|
||||||
} else { LOG("FAILED TO START SERVER ON IP/PORT: %s:%i", ip.c_str(), port); return; }
|
} else {
|
||||||
|
Log::Warn("FAILED TO START SERVER ON IP/PORT: {:s}:{:d}", ip, port);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mLogger->SetLogToConsole(prevLogSetting);
|
mLogger->SetLogToConsole(prevLogSetting);
|
||||||
|
|
||||||
@ -76,7 +79,7 @@ dServer::dServer(const std::string& ip, int port, int instanceID, int maxConnect
|
|||||||
if (serverType != ServerType::Master) {
|
if (serverType != ServerType::Master) {
|
||||||
SetupForMasterConnection();
|
SetupForMasterConnection();
|
||||||
if (!ConnectToMaster()) {
|
if (!ConnectToMaster()) {
|
||||||
LOG("Failed ConnectToMaster!");
|
Log::Warn("Failed ConnectToMaster!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,13 +113,13 @@ Packet* dServer::ReceiveFromMaster() {
|
|||||||
if (packet->length < 1) { mMasterPeer->DeallocatePacket(packet); return nullptr; }
|
if (packet->length < 1) { mMasterPeer->DeallocatePacket(packet); return nullptr; }
|
||||||
|
|
||||||
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
|
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
|
||||||
LOG("Lost our connection to master, shutting DOWN!");
|
Log::Info("Lost our connection to master, shutting DOWN!");
|
||||||
mMasterConnectionActive = false;
|
mMasterConnectionActive = false;
|
||||||
//ConnectToMaster(); //We'll just shut down now
|
//ConnectToMaster(); //We'll just shut down now
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) {
|
if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) {
|
||||||
LOG("Established connection to master, zone (%i), instance (%i)", this->GetZoneID(), this->GetInstanceID());
|
Log::Info("Established connection to master, zone ({:d}), instance ({:d})", this->GetZoneID(), this->GetInstanceID());
|
||||||
mMasterConnectionActive = true;
|
mMasterConnectionActive = true;
|
||||||
mMasterSystemAddress = packet->systemAddress;
|
mMasterSystemAddress = packet->systemAddress;
|
||||||
MasterPackets::SendServerInfo(this, packet);
|
MasterPackets::SendServerInfo(this, packet);
|
||||||
@ -238,11 +241,11 @@ void dServer::SetupForMasterConnection() {
|
|||||||
mMasterSocketDescriptor = SocketDescriptor(uint16_t(mPort + 1), 0);
|
mMasterSocketDescriptor = SocketDescriptor(uint16_t(mPort + 1), 0);
|
||||||
mMasterPeer = RakNetworkFactory::GetRakPeerInterface();
|
mMasterPeer = RakNetworkFactory::GetRakPeerInterface();
|
||||||
bool ret = mMasterPeer->Startup(1, 30, &mMasterSocketDescriptor, 1);
|
bool ret = mMasterPeer->Startup(1, 30, &mMasterSocketDescriptor, 1);
|
||||||
if (!ret) LOG("Failed MasterPeer Startup!");
|
if (!ret) Log::Warn("Failed MasterPeer Startup!");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dServer::ConnectToMaster() {
|
bool dServer::ConnectToMaster() {
|
||||||
//LOG("Connection to Master %s:%d", mMasterIP.c_str(), mMasterPort);
|
//Log::Info("Connection to Master {:s}:{:d}", mMasterIP, mMasterPort);
|
||||||
return mMasterPeer->Connect(mMasterIP.c_str(), mMasterPort, "3.25 DARKFLAME1", 15);
|
return mMasterPeer->Connect(mMasterIP.c_str(), mMasterPort, "3.25 DARKFLAME1", 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,7 +958,7 @@ CppScripts::Script* const CppScripts::GetScript(Entity* parent, const std::strin
|
|||||||
(scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") ||
|
(scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") ||
|
||||||
(scriptName == "scripts\\ai\\WILD\\L_WILD_GF_FROG.lua") ||
|
(scriptName == "scripts\\ai\\WILD\\L_WILD_GF_FROG.lua") ||
|
||||||
(scriptName == "scripts\\empty.lua")
|
(scriptName == "scripts\\empty.lua")
|
||||||
)) LOG_DEBUG("LOT %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str());
|
)) Log::Debug("LOT {:d} attempted to load CppScript for '{:s}', but returned InvalidScript.", parent->GetLOT(), scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Scripts[scriptName] = script;
|
m_Scripts[scriptName] = script;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
void Server::SetupLogger(const std::string_view serviceName) {
|
void Server::SetupLogger(const std::string_view serviceName) {
|
||||||
if (Game::logger) {
|
if (Game::logger) {
|
||||||
LOG("A logger has already been setup, skipping.");
|
Log::Info("A logger has already been setup, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ int main(int argc, char** argv) {
|
|||||||
} catch (CppSQLite3Exception& e) {
|
} catch (CppSQLite3Exception& e) {
|
||||||
Log::Warn("Unable to connect to CDServer SQLite Database");
|
Log::Warn("Unable to connect to CDServer SQLite Database");
|
||||||
Log::Warn("Error: {:s}", e.errorMessage());
|
Log::Warn("Error: {:s}", e.errorMessage());
|
||||||
Log::Warn("Error Code: %i", e.errorCode());
|
Log::Warn("Error Code: {:d}", e.errorCode());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,20 +630,20 @@ void HandlePacketChat(Packet* packet) {
|
|||||||
if (deleteTeam) {
|
if (deleteTeam) {
|
||||||
TeamManager::Instance()->DeleteTeam(teamID);
|
TeamManager::Instance()->DeleteTeam(teamID);
|
||||||
|
|
||||||
Log::Info("Deleting team (%llu)", teamID);
|
Log::Info("Deleting team ({:d})", teamID);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
inStream.Read(lootOption);
|
inStream.Read(lootOption);
|
||||||
inStream.Read(memberCount);
|
inStream.Read(memberCount);
|
||||||
Log::Info("Updating team (%llu), ({:d}), ({:d})", teamID, lootOption, memberCount);
|
Log::Info("Updating team ({:d}), ({:d}), ({:d})", teamID, lootOption, memberCount);
|
||||||
for (char i = 0; i < memberCount; i++) {
|
for (char i = 0; i < memberCount; i++) {
|
||||||
LWOOBJID member = LWOOBJID_EMPTY;
|
LWOOBJID member = LWOOBJID_EMPTY;
|
||||||
inStream.Read(member);
|
inStream.Read(member);
|
||||||
members.push_back(member);
|
members.push_back(member);
|
||||||
|
|
||||||
Log::Info("Updating team member (%llu)", member);
|
Log::Info("Updating team member ({:d})", member);
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamManager::Instance()->UpdateTeam(teamID, lootOption, members);
|
TeamManager::Instance()->UpdateTeam(teamID, lootOption, members);
|
||||||
@ -740,7 +740,7 @@ void HandleMasterPacket(Packet* packet) {
|
|||||||
CINSTREAM_SKIP_HEADER;
|
CINSTREAM_SKIP_HEADER;
|
||||||
uint64_t requestID;
|
uint64_t requestID;
|
||||||
inStream.Read(requestID);
|
inStream.Read(requestID);
|
||||||
Log::Info("Got affirmation request of transfer %llu", requestID);
|
Log::Info("Got affirmation request of transfer {:d}", requestID);
|
||||||
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
|
|
||||||
@ -753,7 +753,7 @@ void HandleMasterPacket(Packet* packet) {
|
|||||||
|
|
||||||
case eMasterMessageType::SHUTDOWN: {
|
case eMasterMessageType::SHUTDOWN: {
|
||||||
Game::lastSignal = -1;
|
Game::lastSignal = -1;
|
||||||
Log::Info("Got shutdown request from master, zone (%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID());
|
Log::Info("Got shutdown request from master, zone ({:d}), instance ({:d})", Game::server->GetZoneID(), Game::server->GetInstanceID());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ void HandleMasterPacket(Packet* packet) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Log::Info("Unknown packet ID from master %i", int(packet->data[3]));
|
Log::Info("Unknown packet ID from master {:d}", static_cast<int>(packet->data[3]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,7 +810,7 @@ void HandlePacket(Packet* packet) {
|
|||||||
|
|
||||||
entity->GetCharacter()->SaveXMLToDatabase();
|
entity->GetCharacter()->SaveXMLToDatabase();
|
||||||
|
|
||||||
Log::Info("Deleting player %llu", entity->GetObjectID());
|
Log::Info("Deleting player {:d}", entity->GetObjectID());
|
||||||
|
|
||||||
Game::entityManager->DestroyEntity(entity);
|
Game::entityManager->DestroyEntity(entity);
|
||||||
}
|
}
|
||||||
@ -1084,11 +1084,11 @@ void HandlePacket(Packet* packet) {
|
|||||||
LWOOBJID propertyId = LWOOBJID_EMPTY;
|
LWOOBJID propertyId = LWOOBJID_EMPTY;
|
||||||
if (propertyInfo) propertyId = propertyInfo->id;
|
if (propertyInfo) propertyId = propertyInfo->id;
|
||||||
else {
|
else {
|
||||||
Log::Info("Couldn't find property ID for zone %i, clone %i", zoneId, cloneId);
|
Log::Warn("Couldn't find property ID for zone {:d}, clone {:d}", zoneId, cloneId);
|
||||||
goto noBBB;
|
goto noBBB;
|
||||||
}
|
}
|
||||||
for (auto& bbbModel : Database::Get()->GetUgcModels(propertyId)) {
|
for (auto& bbbModel : Database::Get()->GetUgcModels(propertyId)) {
|
||||||
Log::Info("Getting lxfml ugcID: %llu", bbbModel.id);
|
Log::Info("Getting lxfml ugcID: {:d}", bbbModel.id);
|
||||||
|
|
||||||
bbbModel.lxfmlData.seekg(0, std::ios::end);
|
bbbModel.lxfmlData.seekg(0, std::ios::end);
|
||||||
size_t lxfmlSize = bbbModel.lxfmlData.tellg();
|
size_t lxfmlSize = bbbModel.lxfmlData.tellg();
|
||||||
@ -1149,7 +1149,7 @@ void HandlePacket(Packet* packet) {
|
|||||||
Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false);
|
Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log::Warn("Couldn't find character to log in with for user {:s} (%i)!", user->GetUsername(), user->GetAccountID());
|
Log::Warn("Couldn't find character to log in with for user {:s} ({:d})!", user->GetUsername(), user->GetAccountID());
|
||||||
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1307,7 +1307,7 @@ void HandlePacket(Packet* packet) {
|
|||||||
std::string playerName = user->GetLastUsedChar()->GetName();
|
std::string playerName = user->GetLastUsedChar()->GetName();
|
||||||
bool isMythran = user->GetLastUsedChar()->GetGMLevel() > eGameMasterLevel::CIVILIAN;
|
bool isMythran = user->GetLastUsedChar()->GetGMLevel() > eGameMasterLevel::CIVILIAN;
|
||||||
bool isOk = Game::chatFilter->IsSentenceOkay(GeneralUtils::UTF16ToWTF8(chatMessage.message), user->GetLastUsedChar()->GetGMLevel()).empty();
|
bool isOk = Game::chatFilter->IsSentenceOkay(GeneralUtils::UTF16ToWTF8(chatMessage.message), user->GetLastUsedChar()->GetGMLevel()).empty();
|
||||||
Log::Debug("Msg: {:s} was approved previously? %i", GeneralUtils::UTF16ToWTF8(chatMessage.message), user->GetLastChatMessageApproved());
|
Log::Debug("Msg: {:s} was approved previously? {}", GeneralUtils::UTF16ToWTF8(chatMessage.message), user->GetLastChatMessageApproved());
|
||||||
if (!isOk) return;
|
if (!isOk) return;
|
||||||
if (!isOk && !isMythran) return;
|
if (!isOk && !isMythran) return;
|
||||||
|
|
||||||
@ -1381,7 +1381,7 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorldShutdownProcess(uint32_t zoneId) {
|
void WorldShutdownProcess(uint32_t zoneId) {
|
||||||
Log::Info("Saving map %i instance %i", zoneId, instanceID);
|
Log::Info("Saving map {:d} instance {:d}", zoneId, instanceID);
|
||||||
for (auto i = 0; i < Game::server->GetReplicaManager()->GetParticipantCount(); ++i) {
|
for (auto i = 0; i < Game::server->GetReplicaManager()->GetParticipantCount(); ++i) {
|
||||||
const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(i);
|
const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(i);
|
||||||
|
|
||||||
@ -1400,13 +1400,13 @@ void WorldShutdownProcess(uint32_t zoneId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PropertyManagementComponent::Instance() != nullptr) {
|
if (PropertyManagementComponent::Instance() != nullptr) {
|
||||||
Log::Info("Saving ALL property data for zone %i clone %i!", zoneId, PropertyManagementComponent::Instance()->GetCloneId());
|
Log::Info("Saving ALL property data for zone {:d} clone {:d}!", zoneId, PropertyManagementComponent::Instance()->GetCloneId());
|
||||||
PropertyManagementComponent::Instance()->Save();
|
PropertyManagementComponent::Instance()->Save();
|
||||||
Database::Get()->RemoveUnreferencedUgcModels();
|
Database::Get()->RemoveUnreferencedUgcModels();
|
||||||
Log::Info("ALL property data saved for zone %i clone %i!", zoneId, PropertyManagementComponent::Instance()->GetCloneId());
|
Log::Info("ALL property data saved for zone {:d} clone {:d}!", zoneId, PropertyManagementComponent::Instance()->GetCloneId());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::Info("ALL DATA HAS BEEN SAVED FOR ZONE %i INSTANCE %i!", zoneId, instanceID);
|
Log::Info("ALL DATA HAS BEEN SAVED FOR ZONE {:d} INSTANCE {:d}!", zoneId, instanceID);
|
||||||
|
|
||||||
while (Game::server->GetReplicaManager()->GetParticipantCount() > 0) {
|
while (Game::server->GetReplicaManager()->GetParticipantCount() > 0) {
|
||||||
const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(0);
|
const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(0);
|
||||||
@ -1428,13 +1428,13 @@ void WorldShutdownSequence() {
|
|||||||
|
|
||||||
if (!Game::logger) return;
|
if (!Game::logger) return;
|
||||||
|
|
||||||
Log::Info("Zone (%i) instance (%i) shutting down outside of main loop!", Game::server->GetZoneID(), instanceID);
|
Log::Info("Zone ({:d}) instance ({:d}) shutting down outside of main loop!", Game::server->GetZoneID(), instanceID);
|
||||||
WorldShutdownProcess(Game::server->GetZoneID());
|
WorldShutdownProcess(Game::server->GetZoneID());
|
||||||
FinalizeShutdown();
|
FinalizeShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinalizeShutdown() {
|
void FinalizeShutdown() {
|
||||||
Log::Info("Shutdown complete, zone (%i), instance (%i)", Game::server->GetZoneID(), instanceID);
|
Log::Info("Shutdown complete, zone ({:d}), instance ({:d})", Game::server->GetZoneID(), instanceID);
|
||||||
|
|
||||||
//Delete our objects here:
|
//Delete our objects here:
|
||||||
Metrics::Clear();
|
Metrics::Clear();
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "ObjectIDManager.h"
|
#include "ObjectIDManager.h"
|
||||||
|
|
||||||
void dZoneManager::Initialize(const LWOZONEID& zoneID) {
|
void dZoneManager::Initialize(const LWOZONEID& zoneID) {
|
||||||
LOG("Preparing zone: %i/%i/%i", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID());
|
Log::Info("Preparing zone: {:d}/{:d}/{:d}", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID());
|
||||||
|
|
||||||
int64_t startTime = 0;
|
int64_t startTime = 0;
|
||||||
int64_t endTime = 0;
|
int64_t endTime = 0;
|
||||||
@ -46,11 +46,11 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("Creating zone control object %i", zoneControlTemplate);
|
Log::Info("Creating zone control object {:d}", zoneControlTemplate);
|
||||||
|
|
||||||
// Create ZoneControl object
|
// Create ZoneControl object
|
||||||
if (!Game::entityManager) {
|
if (!Game::entityManager) {
|
||||||
LOG("ERROR: No entity manager loaded. Cannot proceed.");
|
Log::Warn("ERROR: No entity manager loaded. Cannot proceed.");
|
||||||
throw std::invalid_argument("No entity manager loaded. Cannot proceed.");
|
throw std::invalid_argument("No entity manager loaded. Cannot proceed.");
|
||||||
}
|
}
|
||||||
Game::entityManager->Initialize();
|
Game::entityManager->Initialize();
|
||||||
@ -66,7 +66,7 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
|
|||||||
|
|
||||||
LoadWorldConfig();
|
LoadWorldConfig();
|
||||||
|
|
||||||
LOG("Zone prepared in: %llu ms", (endTime - startTime));
|
Log::Info("Zone prepared in: {:d} ms", (endTime - startTime));
|
||||||
|
|
||||||
VanityUtilities::SpawnVanity();
|
VanityUtilities::SpawnVanity();
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id) {
|
|||||||
auto* spawner = GetSpawner(id);
|
auto* spawner = GetSpawner(id);
|
||||||
|
|
||||||
if (spawner == nullptr) {
|
if (spawner == nullptr) {
|
||||||
LOG("Failed to find spawner (%llu)", id);
|
Log::Info("Failed to find spawner ({:d})", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,14 +158,14 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id) {
|
|||||||
entity->Kill();
|
entity->Kill();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
LOG("Failed to find spawner entity (%llu)", id);
|
Log::Info("Failed to find spawner entity ({:d})", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
spawner->DestroyAllEntities();
|
spawner->DestroyAllEntities();
|
||||||
|
|
||||||
spawner->Deactivate();
|
spawner->Deactivate();
|
||||||
|
|
||||||
LOG("Destroying spawner (%llu)", id);
|
Log::Info("Destroying spawner ({:d})", id);
|
||||||
|
|
||||||
m_Spawners.erase(id);
|
m_Spawners.erase(id);
|
||||||
|
|
||||||
@ -218,14 +218,14 @@ bool dZoneManager::CheckIfAccessibleZone(LWOMAPID zoneID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dZoneManager::LoadWorldConfig() {
|
void dZoneManager::LoadWorldConfig() {
|
||||||
LOG("Loading WorldConfig into memory");
|
Log::Info("Loading WorldConfig into memory");
|
||||||
|
|
||||||
auto worldConfig = CDClientDatabase::ExecuteQuery("SELECT * FROM WorldConfig;");
|
auto worldConfig = CDClientDatabase::ExecuteQuery("SELECT * FROM WorldConfig;");
|
||||||
|
|
||||||
if (!m_WorldConfig) m_WorldConfig = new WorldConfig();
|
if (!m_WorldConfig) m_WorldConfig = new WorldConfig();
|
||||||
|
|
||||||
if (worldConfig.eof()) {
|
if (worldConfig.eof()) {
|
||||||
LOG("WorldConfig table is empty. Is this intended?");
|
Log::Info("WorldConfig table is empty. Is this intended?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,5 +288,5 @@ void dZoneManager::LoadWorldConfig() {
|
|||||||
m_WorldConfig->characterVersion = worldConfig.getIntField("CharacterVersion");
|
m_WorldConfig->characterVersion = worldConfig.getIntField("CharacterVersion");
|
||||||
m_WorldConfig->levelCapCurrencyConversion = worldConfig.getIntField("LevelCapCurrencyConversion");
|
m_WorldConfig->levelCapCurrencyConversion = worldConfig.getIntField("LevelCapCurrencyConversion");
|
||||||
worldConfig.finalize();
|
worldConfig.finalize();
|
||||||
LOG("Loaded WorldConfig into memory");
|
Log::Info("Loaded WorldConfig into memory");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user