diff --git a/src/client/game/demonware/data_types.hpp b/src/client/game/demonware/data_types.hpp index 83c188c3..7cc82f21 100644 --- a/src/client/game/demonware/data_types.hpp +++ b/src/client/game/demonware/data_types.hpp @@ -234,4 +234,35 @@ namespace demonware buffer->read_blob(&this->data); } }; + + class bdContextUserStorageFileInfo final : public bdTaskResult + { + public: + uint32_t create_time; + uint32_t modifed_time; + bool priv; + uint64_t owner_id; + std::string account_type; + std::string filename; + + void serialize(byte_buffer* buffer) override + { + buffer->write_uint32(this->create_time); + buffer->write_uint32(this->modifed_time); + buffer->write_bool(this->priv); + buffer->write_uint64(this->owner_id); + buffer->write_string(this->account_type); + buffer->write_string(this->filename); + } + + void deserialize(byte_buffer* buffer) override + { + buffer->read_uint32(&this->create_time); + buffer->read_uint32(&this->modifed_time); + buffer->read_bool(&this->priv); + buffer->read_uint64(&this->owner_id); + buffer->read_string(&this->account_type); + buffer->read_string(&this->filename); + } + }; } diff --git a/src/client/game/demonware/services/bdStorage.cpp b/src/client/game/demonware/services/bdStorage.cpp index f93a5ec8..0ec3ade7 100644 --- a/src/client/game/demonware/services/bdStorage.cpp +++ b/src/client/game/demonware/services/bdStorage.cpp @@ -16,6 +16,7 @@ namespace demonware this->register_task(20, &bdStorage::list_publisher_files); this->register_task(21, &bdStorage::get_publisher_file); this->register_task(24, &bdStorage::upload_files); + this->register_task(18, &bdStorage::upload_files_new); this->register_task(16, &bdStorage::get_files); this->register_task(12, &bdStorage::unk12); this->register_task(10, &bdStorage::set_user_file); @@ -212,6 +213,52 @@ namespace demonware info->filename = filename; info->data = data; +#ifndef NDEBUG + printf("[DW]: [bdStorage]: set user file: %s\n", filename.data()); +#endif + + reply->add(info); + } + + reply->send(); + } + + void bdStorage::upload_files_new(service_server* server, byte_buffer* buffer) const + { + uint64_t owner; + uint32_t numfiles; + std::string game, platform; + + buffer->read_string(&game); + buffer->read_uint64(&owner); + buffer->read_string(&platform); + buffer->read_uint32(&numfiles); + + auto reply = server->create_reply(this->task_id()); + + for (uint32_t i = 0; i < numfiles; i++) + { + std::string filename, data; + uint32_t version; + bool priv; + + buffer->read_string(&filename); + buffer->read_blob(&data); + buffer->read_uint32(&version); + buffer->read_bool(&priv); + + const auto path = get_user_file_path(filename); + utils::io::write_file(path, data); + + auto* info = new bdContextUserStorageFileInfo; + + info->modifed_time = static_cast(time(nullptr)); + info->create_time = info->modifed_time; + info->priv = priv; + info->owner_id = owner; + info->account_type = platform; + info->filename = filename; + #ifndef NDEBUG printf("[DW]: [bdStorage]: set user file: %s\n", filename.data()); #endif diff --git a/src/client/game/demonware/services/bdStorage.hpp b/src/client/game/demonware/services/bdStorage.hpp index 4451e517..2e9875e4 100644 --- a/src/client/game/demonware/services/bdStorage.hpp +++ b/src/client/game/demonware/services/bdStorage.hpp @@ -20,6 +20,7 @@ namespace demonware void get_publisher_file(service_server* server, byte_buffer* buffer); void set_user_file(service_server* server, byte_buffer* buffer) const; void upload_files(service_server* server, byte_buffer* buffer) const; + void upload_files_new(service_server* server, byte_buffer* buffer) const; void get_files(service_server* server, byte_buffer* buffer) const; void unk12(service_server* server, byte_buffer* buffer) const;