Finish fixing classes not saving
This commit is contained in:
parent
2f69033ec1
commit
0b3f8bf8fa
@ -141,4 +141,33 @@ namespace demonware
|
||||
buffer->read_string(&this->timezone);
|
||||
}
|
||||
};
|
||||
|
||||
// made up name
|
||||
class bdFile final : public bdTaskResult
|
||||
{
|
||||
public:
|
||||
uint64_t owner_id;
|
||||
std::string platform;
|
||||
std::string filename;
|
||||
uint32_t unk;
|
||||
std::string data;
|
||||
|
||||
void serialize(byte_buffer* buffer) override
|
||||
{
|
||||
buffer->write_uint64(this->owner_id);
|
||||
buffer->write_string(this->platform);
|
||||
buffer->write_string(this->filename);
|
||||
buffer->write_uint32(this->unk);
|
||||
buffer->write_blob(this->data);
|
||||
}
|
||||
|
||||
void deserialize(byte_buffer* buffer) override
|
||||
{
|
||||
buffer->read_uint64(&this->owner_id);
|
||||
buffer->read_string(&this->platform);
|
||||
buffer->read_string(&this->filename);
|
||||
buffer->read_uint32(&this->unk);
|
||||
buffer->read_blob(&this->data);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -147,62 +147,31 @@ namespace demonware
|
||||
utils::io::write_file("demonware/bdStorage/set_user_file", buffer->get_buffer());
|
||||
#endif
|
||||
|
||||
auto reply = server->create_reply(this->task_id());
|
||||
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++)
|
||||
{
|
||||
bool priv;
|
||||
uint32_t unk32_0;
|
||||
uint32_t unk32_1;
|
||||
std::string game, platform, filename, data;
|
||||
|
||||
buffer->read_string(&game);
|
||||
buffer->read_uint64(&owner);
|
||||
buffer->read_string(&platform);
|
||||
buffer->read_uint32(&unk32_0);
|
||||
|
||||
buffer->read_string(&filename);
|
||||
buffer->read_blob(&data);
|
||||
buffer->read_uint32(&unk32_1);
|
||||
buffer->read_bool(&priv);
|
||||
|
||||
const auto path = get_user_file_path(filename);
|
||||
utils::io::write_file(path, data);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("[DW]: [bdStorage]: set user file: %s\n", filename.data());
|
||||
#endif
|
||||
|
||||
auto* info = new bdFileInfo;
|
||||
|
||||
info->file_id = *reinterpret_cast<const uint64_t*>(utils::cryptography::sha1::compute(filename).data());
|
||||
info->filename = filename;
|
||||
info->create_time = uint32_t(time(nullptr));
|
||||
info->modified_time = info->create_time;
|
||||
info->file_size = uint32_t(data.size());
|
||||
info->owner_id = uint64_t(owner);
|
||||
info->priv = priv;
|
||||
|
||||
reply->add(info);
|
||||
}
|
||||
|
||||
{
|
||||
bool priv;
|
||||
uint32_t unk32_0;
|
||||
std::string filename, data;
|
||||
uint32_t unk;
|
||||
bool priv;
|
||||
|
||||
buffer->read_string(&filename);
|
||||
buffer->read_blob(&data);
|
||||
buffer->read_uint32(&unk32_0);
|
||||
buffer->read_uint32(&unk);
|
||||
buffer->read_bool(&priv);
|
||||
|
||||
const auto path = get_user_file_path(filename);
|
||||
utils::io::write_file(path, data);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("[DW]: [bdStorage]: set user file: %s\n", filename.data());
|
||||
#endif
|
||||
|
||||
auto* info = new bdFileInfo;
|
||||
|
||||
info->file_id = *reinterpret_cast<const uint64_t*>(utils::cryptography::sha1::compute(filename).data());
|
||||
@ -213,6 +182,10 @@ namespace demonware
|
||||
info->owner_id = uint64_t(owner);
|
||||
info->priv = priv;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("[DW]: [bdStorage]: set user file: %s\n", filename.data());
|
||||
#endif
|
||||
|
||||
reply->add(info);
|
||||
}
|
||||
|
||||
@ -226,10 +199,9 @@ namespace demonware
|
||||
#endif
|
||||
|
||||
uint32_t unk32_0;
|
||||
uint32_t unk32_1;
|
||||
uint32_t numfiles, count = 0;
|
||||
uint64_t owner;
|
||||
std::string game, filename, filename2,
|
||||
platform, data, data2;
|
||||
std::string game, platform;
|
||||
|
||||
buffer->read_string(&game);
|
||||
buffer->read_uint32(&unk32_0);
|
||||
@ -237,30 +209,39 @@ namespace demonware
|
||||
buffer->read_string(&platform);
|
||||
buffer->read_uint64(&owner);
|
||||
buffer->read_string(&platform);
|
||||
buffer->read_uint32(&unk32_1);
|
||||
buffer->read_string(&filename);
|
||||
buffer->read_string(&filename2);
|
||||
buffer->read_uint32(&numfiles);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("[DW]: [bdStorage]: get user file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
|
||||
#endif
|
||||
auto reply = server->create_reply(this->task_id());
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("[DW]: [bdStorage]: get user file: %s, %s, %s\n", game.data(), filename2.data(), platform.data());
|
||||
#endif
|
||||
|
||||
const auto path = get_user_file_path(filename);
|
||||
const auto path2 = get_user_file_path(filename2);
|
||||
|
||||
if (utils::io::read_file(path, &data) && utils::io::read_file(path2, &data2))
|
||||
for (uint32_t i = 0; i < numfiles; i++)
|
||||
{
|
||||
// TODO: find out what the response should be for 2 files
|
||||
// auto reply = server->create_reply(this->task_id());
|
||||
// reply->add(new bdFileData(data));
|
||||
// reply->add(new bdFileData(data2));
|
||||
// reply->send();
|
||||
std::string filename, data;
|
||||
buffer->read_string(&filename);
|
||||
|
||||
server->create_reply(this->task_id(), game::BD_NO_FILE)->send();
|
||||
const auto path = get_user_file_path(filename);
|
||||
if (!utils::io::read_file(path, &data))
|
||||
{
|
||||
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 DEBUG
|
||||
printf("[DW]: [bdStorage]: get user file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
|
||||
#endif
|
||||
}
|
||||
|
||||
if (count == numfiles)
|
||||
{
|
||||
reply->send();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user