Revert "Almost fix classes not saving"

This reverts commit ed87298a6e.
This commit is contained in:
Federico Cecchetto 2022-03-02 00:13:18 +01:00
parent 5ed19f20ec
commit 8e5e5598f1
2 changed files with 41 additions and 125 deletions

View File

@ -254,7 +254,7 @@ namespace console
{ {
std::string cmd; std::string cmd;
while (!this->terminate_runner_) while (true)
{ {
std::getline(std::cin, cmd); std::getline(std::cin, cmd);
command::execute(cmd); command::execute(cmd);

View File

@ -66,24 +66,17 @@ namespace demonware
void bdStorage::list_publisher_files(service_server* server, byte_buffer* buffer) void bdStorage::list_publisher_files(service_server* server, byte_buffer* buffer)
{ {
#ifdef DEBUG
utils::io::write_file("demonware/bdStorage/list_publisher_files", buffer->get_buffer());
#endif
uint32_t date; uint32_t date;
uint16_t num_results, offset; uint16_t num_results, offset;
std::string unk, filename, data; std::string filename, data;
buffer->read_string(&unk); int out{};
buffer->read(2, &out);
buffer->read_uint32(&date); buffer->read_uint32(&date);
buffer->read_uint16(&num_results); buffer->read_uint16(&num_results);
buffer->read_uint16(&offset); buffer->read_uint16(&offset);
buffer->read_string(&filename); buffer->read_string(&filename);
#ifdef DEBUG
printf("[DW]: [bdStorage]: list publisher files: %s\n", filename.data());
#endif
auto reply = server->create_reply(this->task_id()); auto reply = server->create_reply(this->task_id());
if (this->load_publisher_resource(filename, data)) if (this->load_publisher_resource(filename, data))
@ -106,12 +99,9 @@ namespace demonware
void bdStorage::get_publisher_file(service_server* server, byte_buffer* buffer) void bdStorage::get_publisher_file(service_server* server, byte_buffer* buffer)
{ {
#ifdef DEBUG std::string filename;
utils::io::write_file("demonware/bdStorage/get_publisher_file", buffer->get_buffer()); int out{};
#endif buffer->read(2, &out);
std::string unk, filename;
buffer->read_string(&unk);
buffer->read_string(&filename); buffer->read_string(&filename);
#ifdef DEBUG #ifdef DEBUG
@ -142,37 +132,20 @@ namespace demonware
} }
void bdStorage::set_user_file(service_server* server, byte_buffer* buffer) const void bdStorage::set_user_file(service_server* server, byte_buffer* buffer) const
{
#ifdef DEBUG
utils::io::write_file("demonware/bdStorage/set_user_file", buffer->get_buffer());
#endif
auto reply = server->create_reply(this->task_id());
uint64_t owner;
{ {
bool priv; bool priv;
uint32_t unk32_0; uint64_t owner;
uint32_t unk32_1; std::string game, filename, data;
std::string game, platform, filename, data;
buffer->read_string(&game); buffer->read_string(&game);
buffer->read_string(&filename);
buffer->read_bool(&priv);
buffer->read_blob(&data);
buffer->read_uint64(&owner); 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); const auto path = get_user_file_path(filename);
utils::io::write_file(path, data); utils::io::write_file(path, data);
#ifdef DEBUG
printf("[DW]: [bdStorage]: set user file: %s\n", filename.data());
#endif
auto* info = new bdFileInfo; auto* info = new bdFileInfo;
info->file_id = *reinterpret_cast<const uint64_t*>(utils::cryptography::sha1::compute(filename).data()); info->file_id = *reinterpret_cast<const uint64_t*>(utils::cryptography::sha1::compute(filename).data());
@ -180,89 +153,36 @@ namespace demonware
info->create_time = uint32_t(time(nullptr)); info->create_time = uint32_t(time(nullptr));
info->modified_time = info->create_time; info->modified_time = info->create_time;
info->file_size = uint32_t(data.size()); info->file_size = uint32_t(data.size());
info->owner_id = uint64_t(owner); info->owner_id = owner;
info->priv = priv; info->priv = priv;
printf("set user file %llx\n", owner); auto reply = server->create_reply(this->task_id());
reply->add(info); reply->add(info);
}
{
bool priv;
uint32_t unk32_0;
std::string filename, data;
buffer->read_string(&filename);
buffer->read_blob(&data);
buffer->read_uint32(&unk32_0);
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);
}
reply->send(); reply->send();
} }
void bdStorage::get_user_file(service_server* server, byte_buffer* buffer) const void bdStorage::get_user_file(service_server* server, byte_buffer* buffer) const
{ {
#ifdef DEBUG uint64_t owner{};
utils::io::write_file("demonware/bdStorage/get_user_file", buffer->get_buffer()); std::string game, filename, platform, data;
#endif
uint32_t unk32_0;
uint32_t unk32_1;
uint64_t owner;
std::string game, filename, filename2,
platform, data, data2;
int out{};
buffer->read(2, &out);
buffer->read_string(&game); buffer->read_string(&game);
buffer->read_uint32(&unk32_0);
buffer->read_uint64(&owner);
buffer->read_string(&platform);
buffer->read_uint64(&owner);
buffer->read_string(&platform);
buffer->read_uint32(&unk32_1);
buffer->read_string(&filename); buffer->read_string(&filename);
buffer->read_string(&filename2); buffer->read_uint64(&owner);
buffer->read_string(&platform);
#ifdef DEBUG #ifdef DEBUG
printf("[DW]: [bdStorage]: get user file: %s, %s, %s\n", game.data(), filename.data(), platform.data()); printf("[DW]: [bdStorage]: user file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
#endif
#ifdef DEBUG
printf("[DW]: [bdStorage]: get user file: %s, %s, %s\n", game.data(), filename2.data(), platform.data());
#endif #endif
const auto path = get_user_file_path(filename); const auto path = get_user_file_path(filename);
const auto path2 = get_user_file_path(filename2); if (utils::io::read_file(path, &data))
if (utils::io::read_file(path, &data) && utils::io::read_file(path2, &data2))
{ {
// TODO: find out what the response should be for 2 files auto reply = server->create_reply(this->task_id());
// auto reply = server->create_reply(this->task_id()); reply->add(new bdFileData(data));
// reply->add(new bdFileData(data)); reply->send();
// reply->add(new bdFileData(data2));
// reply->send();
server->create_reply(this->task_id(), game::BD_NO_FILE)->send();
} }
else else
{ {
@ -272,10 +192,6 @@ namespace demonware
void bdStorage::unk12(service_server* server, byte_buffer* buffer) const void bdStorage::unk12(service_server* server, byte_buffer* buffer) const
{ {
#ifdef DEBUG
utils::io::write_file("demonware/bdStorage/unk12", buffer->get_buffer());
#endif
// TODO: // TODO:
auto reply = server->create_reply(this->task_id()); auto reply = server->create_reply(this->task_id());
reply->send(); reply->send();