custom players2 folder and fixes
This commit is contained in:
parent
ee0eeb4bb7
commit
cf210237bd
@ -16,6 +16,7 @@ namespace filesystem
|
||||
namespace
|
||||
{
|
||||
utils::hook::detour fs_startup_hook;
|
||||
utils::hook::detour fs_build_os_path_hook;
|
||||
|
||||
bool initialized = false;
|
||||
|
||||
@ -90,6 +91,18 @@ namespace filesystem
|
||||
static auto current_path = std::filesystem::current_path().string();
|
||||
return current_path.data();
|
||||
}
|
||||
|
||||
void fs_build_os_path_stub(const char* base, const char* game, const char* qpath, char* ospath)
|
||||
{
|
||||
if (!_stricmp(game, "players2"))
|
||||
{
|
||||
const auto path = "iw7-mod/"s + game;
|
||||
fs_build_os_path_hook.invoke<void>(base, path.data(), qpath, ospath);
|
||||
return;
|
||||
}
|
||||
|
||||
fs_build_os_path_hook.invoke<void>(base, game, qpath, ospath);
|
||||
}
|
||||
}
|
||||
|
||||
std::string read_file(const std::string& path)
|
||||
@ -229,6 +242,7 @@ namespace filesystem
|
||||
void post_unpack() override
|
||||
{
|
||||
fs_startup_hook.create(0xCDD800_b, fs_startup_stub);
|
||||
fs_build_os_path_hook.create(0xCDBBF0_b, fs_build_os_path_stub);
|
||||
|
||||
utils::hook::jump(0xCFE5E0_b, sys_default_install_path_stub);
|
||||
|
||||
|
@ -25,9 +25,9 @@ namespace profile_infos
|
||||
std::optional<profile_info> load_profile_info()
|
||||
{
|
||||
std::string data{};
|
||||
if (!utils::io::read_file("players2/user/profile_info", &data))
|
||||
if (!utils::io::read_file("iw7-mod/players2/user/profile_info", &data))
|
||||
{
|
||||
console::error("[load_profile_info] failed to load profile_info for self!\n");
|
||||
//console::error("[load_profile_info] failed to load profile_info for self!\n");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ namespace profile_infos
|
||||
std::string data{};
|
||||
data.reserve(info.m_memberplayer_card.size());
|
||||
data.append(info.m_memberplayer_card);
|
||||
utils::io::write_file("players2/user/profile_info", data);
|
||||
utils::io::write_file("iw7-mod/players2/user/profile_info", data);
|
||||
}
|
||||
|
||||
void send_all_profile_infos(const game::netadr_s& sender_addr)
|
||||
|
@ -11,6 +11,7 @@ namespace demonware
|
||||
this->register_task(43, &bdMarketplace::purchaseOnSteamInitialize);
|
||||
this->register_task(44, &bdMarketplace::purchaseOnSteamFinalize);
|
||||
this->register_task(49, &bdMarketplace::getExpiredInventoryItems);
|
||||
this->register_task(58, &bdMarketplace::validateInventoryItemsToken);
|
||||
this->register_task(60, &bdMarketplace::steamProcessDurable);
|
||||
this->register_task(85, &bdMarketplace::steamProcessDurableV2);
|
||||
this->register_task(122, &bdMarketplace::purchaseSkus);
|
||||
@ -49,6 +50,13 @@ namespace demonware
|
||||
reply.send();
|
||||
}
|
||||
|
||||
void bdMarketplace::validateInventoryItemsToken(service_server* server, byte_buffer* /*buffer*/) const
|
||||
{
|
||||
// TODO:
|
||||
auto reply = server->create_reply(this->task_id());
|
||||
reply.send();
|
||||
}
|
||||
|
||||
void bdMarketplace::steamProcessDurable(service_server* server, byte_buffer* /*buffer*/) const
|
||||
{
|
||||
// TODO:
|
||||
|
@ -12,6 +12,7 @@ namespace demonware
|
||||
void purchaseOnSteamInitialize(service_server* server, byte_buffer* buffer) const;
|
||||
void purchaseOnSteamFinalize(service_server* server, byte_buffer* buffer) const;
|
||||
void getExpiredInventoryItems(service_server* server, byte_buffer* buffer) const;
|
||||
void validateInventoryItemsToken(service_server* server, byte_buffer* buffer) const;
|
||||
void steamProcessDurable(service_server* server, byte_buffer* buffer) const;
|
||||
void steamProcessDurableV2(service_server* server, byte_buffer* buffer) const;
|
||||
void purchaseSkus(service_server* server, byte_buffer* buffer) const;
|
||||
|
@ -133,7 +133,7 @@ namespace demonware
|
||||
|
||||
std::string bdStorage::get_user_file_path(const std::string& name)
|
||||
{
|
||||
return "players2/user/" + name;
|
||||
return "iw7-mod/players2/user/" + name;
|
||||
}
|
||||
|
||||
void bdStorage::uploadAndValidateFiles(service_server* server, byte_buffer* buffer) const
|
||||
@ -231,53 +231,62 @@ namespace demonware
|
||||
|
||||
void bdStorage::getFiles(service_server* server, byte_buffer* buffer) const
|
||||
{
|
||||
std::string platform;
|
||||
uint32_t num_users;
|
||||
uint32_t num_files;
|
||||
uint64_t user_id = 0;
|
||||
std::string game;
|
||||
std::string context;
|
||||
buffer->read_string(&context);
|
||||
|
||||
buffer->read_string(&platform);
|
||||
buffer->read_uint32(&num_users);
|
||||
uint32_t count;
|
||||
buffer->read_uint32(&count);
|
||||
|
||||
for (uint32_t i = 0; i < num_users; i++)
|
||||
std::vector<std::pair<uint64_t, std::string>> user_ctxs;
|
||||
|
||||
for (auto i = 0u; i < count; i++)
|
||||
{
|
||||
uint64_t user_id;
|
||||
std::string acc_type;
|
||||
buffer->read_uint64(&user_id);
|
||||
buffer->read_string(&game);
|
||||
buffer->read_string(&acc_type);
|
||||
|
||||
user_ctxs.emplace_back(user_id, acc_type);
|
||||
}
|
||||
|
||||
buffer->read_uint32(&num_files);
|
||||
buffer->read_uint32(&count);
|
||||
|
||||
std::vector<std::string> filenames;
|
||||
|
||||
for (auto i = 0u; i < count; i++)
|
||||
{
|
||||
std::string filename;
|
||||
buffer->read_string(&filename);
|
||||
filenames.push_back(std::move(filename));
|
||||
}
|
||||
|
||||
auto reply = server->create_reply(this->task_id());
|
||||
|
||||
uint32_t count = 0;
|
||||
for (uint32_t i = 0; i < num_files; i++)
|
||||
for (size_t i = 0u; i < filenames.size(); i++)
|
||||
{
|
||||
std::string filename, data;
|
||||
buffer->read_string(&filename);
|
||||
auto entry = std::make_unique<bdFileQueryResult>();
|
||||
entry->user_id = user_ctxs.at(i).first;
|
||||
entry->platform = user_ctxs.at(i).second;
|
||||
entry->filename = filenames.at(i);
|
||||
entry->errorcode = 0;
|
||||
|
||||
const auto path = get_user_file_path(filename);
|
||||
if (!utils::io::read_file(path, &data))
|
||||
auto& name = filenames.at(i);
|
||||
std::string filedata;
|
||||
if (utils::io::read_file(get_user_file_path(name), &filedata))
|
||||
{
|
||||
entry->filedata = filedata;
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: get user file: missing file: %s, %s, %s\n", game.data(), filename.data(), platform.data());
|
||||
printf("[DW]: [bdStorage]: get user file: %s\n", name.data());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->errorcode = game::BD_NO_FILE;
|
||||
#ifdef DW_DEBUG
|
||||
printf("[DW]: [bdStorage]: missing user file: %s\n", name.data());
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
auto response = std::make_unique<bdFileQueryResult>();
|
||||
response->user_id = user_id;
|
||||
response->platform = platform;
|
||||
response->filename = filename;
|
||||
response->errorcode = 0;
|
||||
response->filedata = 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
|
||||
reply.add(entry);
|
||||
}
|
||||
|
||||
reply.send();
|
||||
|
Loading…
Reference in New Issue
Block a user