name some demonware stuff
This commit is contained in:
parent
9fc7f08b09
commit
36739acae4
@ -142,14 +142,13 @@ namespace demonware
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// made up name
|
class bdFileQueryResult final : public bdTaskResult
|
||||||
class bdFile final : public bdTaskResult
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
uint64_t owner_id;
|
std::uint64_t owner_id;
|
||||||
std::string platform;
|
std::string platform;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
uint32_t unk;
|
std::uint32_t errorcode;
|
||||||
std::string data;
|
std::string data;
|
||||||
|
|
||||||
void serialize(byte_buffer* buffer) override
|
void serialize(byte_buffer* buffer) override
|
||||||
@ -157,7 +156,7 @@ namespace demonware
|
|||||||
buffer->write_uint64(this->owner_id);
|
buffer->write_uint64(this->owner_id);
|
||||||
buffer->write_string(this->platform);
|
buffer->write_string(this->platform);
|
||||||
buffer->write_string(this->filename);
|
buffer->write_string(this->filename);
|
||||||
buffer->write_uint32(this->unk);
|
buffer->write_uint32(this->errorcode);
|
||||||
buffer->write_blob(this->data);
|
buffer->write_blob(this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +165,7 @@ namespace demonware
|
|||||||
buffer->read_uint64(&this->owner_id);
|
buffer->read_uint64(&this->owner_id);
|
||||||
buffer->read_string(&this->platform);
|
buffer->read_string(&this->platform);
|
||||||
buffer->read_string(&this->filename);
|
buffer->read_string(&this->filename);
|
||||||
buffer->read_uint32(&this->unk);
|
buffer->read_uint32(&this->errorcode);
|
||||||
buffer->read_blob(&this->data);
|
buffer->read_blob(&this->data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -13,9 +13,9 @@ namespace demonware
|
|||||||
{
|
{
|
||||||
this->register_task(20, &bdStorage::list_publisher_files);
|
this->register_task(20, &bdStorage::list_publisher_files);
|
||||||
this->register_task(21, &bdStorage::get_publisher_file);
|
this->register_task(21, &bdStorage::get_publisher_file);
|
||||||
this->register_task(24, &bdStorage::set_user_file);
|
this->register_task(24, &bdStorage::upload_and_validate_files);
|
||||||
this->register_task(16, &bdStorage::get_user_file);
|
this->register_task(16, &bdStorage::get_user_files);
|
||||||
this->register_task(12, &bdStorage::unk12);
|
this->register_task(12, &bdStorage::get_user_file);
|
||||||
|
|
||||||
this->map_publisher_resource("motd-.*\\.txt", DW_MOTD);
|
this->map_publisher_resource("motd-.*\\.txt", DW_MOTD);
|
||||||
// this->map_publisher_resource("ffotd-.*\\.ff", DW_FASTFILE);
|
// this->map_publisher_resource("ffotd-.*\\.ff", DW_FASTFILE);
|
||||||
@ -133,7 +133,7 @@ namespace demonware
|
|||||||
return "players2/user/" + name;
|
return "players2/user/" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bdStorage::set_user_file(service_server* server, byte_buffer* buffer) const
|
void bdStorage::upload_and_validate_files(service_server* server, byte_buffer* buffer) const
|
||||||
{
|
{
|
||||||
uint64_t owner;
|
uint64_t owner;
|
||||||
uint32_t numfiles;
|
uint32_t numfiles;
|
||||||
@ -146,6 +146,10 @@ namespace demonware
|
|||||||
|
|
||||||
auto reply = server->create_reply(this->task_id());
|
auto reply = server->create_reply(this->task_id());
|
||||||
|
|
||||||
|
#ifdef DW_DEBUG
|
||||||
|
printf("[DW]: [bdStorage]: upload_and_validate_files has %d files\n", numfiles);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (uint32_t i = 0; i < numfiles; i++)
|
for (uint32_t i = 0; i < numfiles; i++)
|
||||||
{
|
{
|
||||||
std::string filename, data;
|
std::string filename, data;
|
||||||
@ -172,62 +176,88 @@ namespace demonware
|
|||||||
info->data = data;
|
info->data = data;
|
||||||
|
|
||||||
#ifdef DW_DEBUG
|
#ifdef DW_DEBUG
|
||||||
printf("[DW]: [bdStorage]: set user file: %s\n", filename.data());
|
printf("[DW]: [bdStorage]: adding \"%s\" to reply\n", filename.data());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
reply->add(info);
|
reply->add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DW_DEBUG
|
||||||
|
printf("[DW]: [bdStorage]: sending reply for upload_and_validate_files\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
reply->send();
|
reply->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bdStorage::get_user_file(service_server* server, byte_buffer* buffer) const
|
void bdStorage::get_user_files(service_server* server, byte_buffer* buffer) const
|
||||||
{
|
{
|
||||||
uint32_t unk32_0;
|
std::string context;
|
||||||
uint32_t numfiles, count = 0;
|
buffer->read_string(&context);
|
||||||
uint64_t owner;
|
|
||||||
std::string game, platform;
|
|
||||||
|
|
||||||
buffer->read_string(&game);
|
#ifdef DW_DEBUG
|
||||||
buffer->read_uint32(&unk32_0);
|
printf("[DW]: [bdStorage]: context is '%s'\n", context.data());
|
||||||
buffer->read_uint64(&owner);
|
#endif
|
||||||
buffer->read_string(&platform);
|
|
||||||
buffer->read_uint64(&owner);
|
|
||||||
buffer->read_string(&platform);
|
|
||||||
buffer->read_uint32(&numfiles);
|
|
||||||
|
|
||||||
auto reply = server->create_reply(this->task_id());
|
uint32_t count;
|
||||||
|
buffer->read_uint32(&count);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < numfiles; i++)
|
std::vector<std::pair<uint64_t, std::string>> user_ctxs;
|
||||||
|
|
||||||
|
for (auto i = 0u; i < count; i++)
|
||||||
{
|
{
|
||||||
std::string filename, data;
|
uint64_t user_id;
|
||||||
|
std::string acc_type;
|
||||||
|
buffer->read_uint64(&user_id);
|
||||||
|
buffer->read_string(&acc_type);
|
||||||
|
user_ctxs.emplace_back(user_id, acc_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer->read_uint32(&count);
|
||||||
|
|
||||||
|
std::vector<std::string> filenames;
|
||||||
|
|
||||||
|
for (auto i = 0u; i < count; i++)
|
||||||
|
{
|
||||||
|
std::string filename;
|
||||||
buffer->read_string(&filename);
|
buffer->read_string(&filename);
|
||||||
|
|
||||||
const auto path = get_user_file_path(filename);
|
filenames.push_back(std::move(filename));
|
||||||
if (!utils::io::read_file(path, &data))
|
}
|
||||||
|
|
||||||
|
auto reply = server->create_reply(this->task_id());
|
||||||
|
uint32_t available = 0;
|
||||||
|
|
||||||
|
for (size_t i = 0u; i < filenames.size(); i++)
|
||||||
|
{
|
||||||
|
auto& name = filenames.at(i);
|
||||||
|
std::string data;
|
||||||
|
|
||||||
|
if (utils::io::read_file(get_user_file_path(name), &data))
|
||||||
|
{
|
||||||
|
auto entry = new bdFileQueryResult;
|
||||||
|
entry->owner_id = user_ctxs.at(i).first;
|
||||||
|
entry->platform = user_ctxs.at(i).second;
|
||||||
|
entry->filename = filenames.at(i);
|
||||||
|
entry->errorcode = 0;
|
||||||
|
entry->data = data;
|
||||||
|
|
||||||
|
reply->add(entry);
|
||||||
|
|
||||||
|
++available;
|
||||||
|
|
||||||
|
#ifdef DW_DEBUG
|
||||||
|
printf("[DW]: [bdStorage]: user file \"%s\" dispatched\n", name.data());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
#ifdef DW_DEBUG
|
#ifdef DW_DEBUG
|
||||||
printf("[DW]: [bdStorage]: get user file: missing file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
|
printf("[DW]: [bdStorage]: user file \"%s\" not found\n", name.data());
|
||||||
#endif
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto response = new bdFile;
|
|
||||||
response->owner_id = owner;
|
|
||||||
response->unk = 0;
|
|
||||||
response->platform = platform;
|
|
||||||
response->filename = filename;
|
|
||||||
response->data = data;
|
|
||||||
|
|
||||||
reply->add(response);
|
|
||||||
++count;
|
|
||||||
|
|
||||||
#ifdef DW_DEBUG
|
|
||||||
printf("[DW]: [bdStorage]: get user file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (count == numfiles)
|
if (available == count)
|
||||||
{
|
{
|
||||||
reply->send();
|
reply->send();
|
||||||
}
|
}
|
||||||
@ -237,7 +267,7 @@ namespace demonware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bdStorage::unk12(service_server* server, byte_buffer* buffer) const
|
void bdStorage::get_user_file(service_server* server, byte_buffer* buffer) const
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
auto reply = server->create_reply(this->task_id());
|
auto reply = server->create_reply(this->task_id());
|
||||||
|
@ -18,9 +18,9 @@ namespace demonware
|
|||||||
|
|
||||||
void list_publisher_files(service_server* server, byte_buffer* buffer);
|
void list_publisher_files(service_server* server, byte_buffer* buffer);
|
||||||
void get_publisher_file(service_server* server, byte_buffer* buffer);
|
void get_publisher_file(service_server* server, byte_buffer* buffer);
|
||||||
void set_user_file(service_server* server, byte_buffer* buffer) const;
|
void upload_and_validate_files(service_server* server, byte_buffer* buffer) const;
|
||||||
|
void get_user_files(service_server* server, byte_buffer* buffer) const;
|
||||||
void get_user_file(service_server* server, byte_buffer* buffer) const;
|
void get_user_file(service_server* server, byte_buffer* buffer) const;
|
||||||
void unk12(service_server* server, byte_buffer* buffer) const;
|
|
||||||
|
|
||||||
static std::string get_user_file_path(const std::string& name);
|
static std::string get_user_file_path(const std::string& name);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user