From 6bf084ef8f3e4d26d0a6bc1f7bae77c2e214b780 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 18 Jan 2024 00:10:52 -0800 Subject: [PATCH] Add announcement for mismatched fdb (#1424) adds an announcement sent to the system address which had the mismatched FDB to let the developer know they have a mis-matched one. Tested that if a civilian tries to login without a gm level > developer, they are kicked. Tested that if a GM is found to have a mismatched FDB, they are let in but have an announcement sent to them. Use auth packets for msg added comment as to why ff remove default add comment Remove broadcast --- dGame/dGameMessages/GameMessages.cpp | 19 +++++++++++++++++++ dGame/dGameMessages/GameMessages.h | 3 +++ dWorldServer/WorldServer.cpp | 27 +++++++++++++++++++++++---- resources/worldconfig.ini | 4 ++++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 595444e9..8c935afe 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -625,6 +625,25 @@ void GameMessages::SendUIMessageServerToSingleClient(Entity* entity, const Syste SEND_PACKET; } +void GameMessages::SendUIMessageServerToSingleClient(const std::string& message, AMFBaseValue& args, const SystemAddress& sysAddr) { + CBITSTREAM; + CMSGHEADER; + + LWOOBJID empty = 0; + bitStream.Write(empty); + bitStream.Write(eGameMessageType::UI_MESSAGE_SERVER_TO_ALL_CLIENTS); // This is intentional to allow the server to send a ui message to a client via their system address. + + bitStream.Write(args); + uint32_t strMessageNameLength = message.size(); + bitStream.Write(strMessageNameLength); + + for (uint32_t k = 0; k < strMessageNameLength; k++) { + bitStream.Write(message[k]); + } + + SEND_PACKET; +} + void GameMessages::SendUIMessageServerToAllClients(const std::string& message, AMFBaseValue& args) { CBITSTREAM; CMSGHEADER; diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 9c8d183e..68a8471a 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -92,6 +92,9 @@ namespace GameMessages { void SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, eLootSourceType sourceType); void SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, AMFBaseValue& args); + + // Specify sysAddr if you need to send a flash message to a client who you dont know the objectID of. + void SendUIMessageServerToSingleClient(const std::string& message, AMFBaseValue& args, const SystemAddress& sysAddr); void SendUIMessageServerToAllClients(const std::string& message, AMFBaseValue& args); void SendPlayEmbeddedEffectOnAllClientsNearObject(Entity* entity, std::u16string effectName, const LWOOBJID& fromObjectID, float radius); diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index ccc300bc..c9647bd5 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -79,6 +79,7 @@ #include "Server.h" #include "PositionUpdate.h" #include "PlayerManager.h" +#include "eLoginResponse.h" namespace Game { Logger* logger = nullptr; @@ -867,10 +868,28 @@ void HandlePacket(Packet* packet) { } // Developers may skip this check - if (accountInfo->maxGmLevel < eGameMasterLevel::DEVELOPER && clientDatabaseChecksum.string != databaseChecksum) { - LOG("Client's database checksum does not match the server's, aborting connection."); - Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::WRONG_GAME_VERSION); - return; + if (clientDatabaseChecksum.string != databaseChecksum) { + + if (accountInfo->maxGmLevel < eGameMasterLevel::DEVELOPER) { + LOG("Client's database checksum does not match the server's, aborting connection."); + std::vector stamps; + + // Using the LoginResponse here since the UI is still in the login screen state + // and we have a way to send a message about the client mismatch. + AuthPackets::SendLoginResponse( + Game::server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, + Game::config->GetValue("cdclient_mismatch_message"), "", 0, "", stamps); + return; + } else { + AMFArrayValue args; + + args.Insert("title", Game::config->GetValue("cdclient_mismatch_title")); + args.Insert("message", Game::config->GetValue("cdclient_mismatch_message")); + + GameMessages::SendUIMessageServerToSingleClient("ToggleAnnounce", args, packet->systemAddress); + LOG("Account (%s) with GmLevel (%s) does not have a matching FDB, but is a developer and will skip this check." + , username.GetAsString().c_str(), StringifiedEnum::ToString(accountInfo->maxGmLevel).data()); + } } } diff --git a/resources/worldconfig.ini b/resources/worldconfig.ini index c68b42d2..91028ffe 100644 --- a/resources/worldconfig.ini +++ b/resources/worldconfig.ini @@ -73,3 +73,7 @@ help_4_description=Visit Discussions on the DarkflameServer GitHub page
to a # Toggleable quality of life feature to allow users to skip most cinematics. allow_players_to_skip_cinematics=0 + +# Customizable message for what to say when there is a cdclient fdb mismatch +cdclient_mismatch_title=Version out of date +cdclient_mismatch_message=We detected that your client is out of date. Please update your client to the latest version.