From 069749f915d1aaa8e6747c735eb45d12c265373b Mon Sep 17 00:00:00 2001 From: project-bo4 <127137346+project-bo4@users.noreply.github.com> Date: Mon, 13 Mar 2023 06:37:51 -0700 Subject: [PATCH] bdProfiles service fixes profile customization lockout(calling card and emblem only?) Not tested on public games but clearly others players still wont see real info since your dw server is emulated locally and does not provide connectivity between players. in case you want to adopt it with your system basically one way might be somehow merging it with any of ddl's shared with dedicated servers; not so familiar with how it works. --- src/client/game/demonware/data_types.hpp | 22 ++++++++++++ .../game/demonware/services/bdProfiles.cpp | 34 +++++++++++++++---- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/client/game/demonware/data_types.hpp b/src/client/game/demonware/data_types.hpp index 067d6650..2c626104 100644 --- a/src/client/game/demonware/data_types.hpp +++ b/src/client/game/demonware/data_types.hpp @@ -505,4 +505,26 @@ namespace demonware buffer->read_uint32(&this->m_maxPlayers); } }; + + class bdPublicProfileInfo final : public bdTaskResult + { + public: + uint64_t m_entityID; + int32_t m_VERSION; + std::string m_ddl; + + void serialize(byte_buffer* buffer) override + { + buffer->write_uint64(this->m_entityID); + buffer->write_int32(this->m_VERSION); + buffer->write_blob(this->m_ddl); + } + + void deserialize(byte_buffer* buffer) override + { + buffer->read_uint64(&this->m_entityID); + buffer->read_int32(&this->m_VERSION); + buffer->read_blob(&this->m_ddl); + } + }; } diff --git a/src/client/game/demonware/services/bdProfiles.cpp b/src/client/game/demonware/services/bdProfiles.cpp index ac7a466a..d53e5c0a 100644 --- a/src/client/game/demonware/services/bdProfiles.cpp +++ b/src/client/game/demonware/services/bdProfiles.cpp @@ -1,5 +1,7 @@ #include #include "../services.hpp" +#include "steam/steam.hpp" +#include namespace demonware { @@ -15,16 +17,36 @@ namespace demonware this->register_task(8, &bdProfiles::setPublicInfoByUserID); } - void bdProfiles::getPublicInfos(service_server* server, byte_buffer* /*buffer*/) const + void bdProfiles::getPublicInfos(service_server* server, byte_buffer* buffer) const { - // TODO: - auto reply = server->create_reply(this->task_id()); - reply->send(); + uint64_t entity_id; + buffer->read_uint64(&entity_id); + + auto* result = new bdPublicProfileInfo; + result->m_entityID = entity_id; + result->m_VERSION = 4; + + if (utils::io::read_file(std::format("players/user/profileInfo_{}", entity_id), &result->m_ddl)) + { + auto reply = server->create_reply(this->task_id()); + reply->add(result); + reply->send(); + } + else + { + auto reply = server->create_reply(this->task_id(), game::BD_NO_PROFILE_INFO_EXISTS); + reply->send(); + } } - void bdProfiles::setPublicInfo(service_server* server, byte_buffer* /*buffer*/) const + void bdProfiles::setPublicInfo(service_server* server, byte_buffer* buffer) const { - // TODO: + int32_t version; std::string ddl; + buffer->read_int32(&version); + buffer->read_blob(&ddl); + + utils::io::write_file(std::format("players/user/profileInfo_{}", steam::SteamUser()->GetSteamID().bits), ddl); + auto reply = server->create_reply(this->task_id()); reply->send(); }