Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add announcement for mismatched fdb #1424

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dGame/dGameMessages/GameMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AMFBaseValue&>(args);
uint32_t strMessageNameLength = message.size();
bitStream.Write(strMessageNameLength);

for (uint32_t k = 0; k < strMessageNameLength; k++) {
bitStream.Write<char>(message[k]);
}

SEND_PACKET;
}

void GameMessages::SendUIMessageServerToAllClients(const std::string& message, AMFBaseValue& args) {
CBITSTREAM;
CMSGHEADER;
Expand Down
3 changes: 3 additions & 0 deletions dGame/dGameMessages/GameMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 23 additions & 4 deletions dWorldServer/WorldServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#include "Server.h"
#include "PositionUpdate.h"
#include "PlayerManager.h"
#include "eLoginResponse.h"

namespace Game {
Logger* logger = nullptr;
Expand Down Expand Up @@ -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<Stamp> 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());
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions resources/worldconfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ help_4_description=Visit Discussions on the DarkflameServer GitHub page<br/>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.
Loading