custom players2 folder and fixes
This commit is contained in:
parent
ee0eeb4bb7
commit
cf210237bd
@ -16,6 +16,7 @@ namespace filesystem
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
utils::hook::detour fs_startup_hook;
|
utils::hook::detour fs_startup_hook;
|
||||||
|
utils::hook::detour fs_build_os_path_hook;
|
||||||
|
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
@ -90,6 +91,18 @@ namespace filesystem
|
|||||||
static auto current_path = std::filesystem::current_path().string();
|
static auto current_path = std::filesystem::current_path().string();
|
||||||
return current_path.data();
|
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)
|
std::string read_file(const std::string& path)
|
||||||
@ -229,6 +242,7 @@ namespace filesystem
|
|||||||
void post_unpack() override
|
void post_unpack() override
|
||||||
{
|
{
|
||||||
fs_startup_hook.create(0xCDD800_b, fs_startup_stub);
|
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);
|
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::optional<profile_info> load_profile_info()
|
||||||
{
|
{
|
||||||
std::string data{};
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ namespace profile_infos
|
|||||||
std::string data{};
|
std::string data{};
|
||||||
data.reserve(info.m_memberplayer_card.size());
|
data.reserve(info.m_memberplayer_card.size());
|
||||||
data.append(info.m_memberplayer_card);
|
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)
|
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(43, &bdMarketplace::purchaseOnSteamInitialize);
|
||||||
this->register_task(44, &bdMarketplace::purchaseOnSteamFinalize);
|
this->register_task(44, &bdMarketplace::purchaseOnSteamFinalize);
|
||||||
this->register_task(49, &bdMarketplace::getExpiredInventoryItems);
|
this->register_task(49, &bdMarketplace::getExpiredInventoryItems);
|
||||||
|
this->register_task(58, &bdMarketplace::validateInventoryItemsToken);
|
||||||
this->register_task(60, &bdMarketplace::steamProcessDurable);
|
this->register_task(60, &bdMarketplace::steamProcessDurable);
|
||||||
this->register_task(85, &bdMarketplace::steamProcessDurableV2);
|
this->register_task(85, &bdMarketplace::steamProcessDurableV2);
|
||||||
this->register_task(122, &bdMarketplace::purchaseSkus);
|
this->register_task(122, &bdMarketplace::purchaseSkus);
|
||||||
@ -49,6 +50,13 @@ namespace demonware
|
|||||||
reply.send();
|
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
|
void bdMarketplace::steamProcessDurable(service_server* server, byte_buffer* /*buffer*/) const
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
|
@ -12,6 +12,7 @@ namespace demonware
|
|||||||
void purchaseOnSteamInitialize(service_server* server, byte_buffer* buffer) const;
|
void purchaseOnSteamInitialize(service_server* server, byte_buffer* buffer) const;
|
||||||
void purchaseOnSteamFinalize(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 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 steamProcessDurable(service_server* server, byte_buffer* buffer) const;
|
||||||
void steamProcessDurableV2(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;
|
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)
|
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
|
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
|
void bdStorage::getFiles(service_server* server, byte_buffer* buffer) const
|
||||||
{
|
{
|
||||||
std::string platform;
|
std::string context;
|
||||||
uint32_t num_users;
|
buffer->read_string(&context);
|
||||||
uint32_t num_files;
|
|
||||||
uint64_t user_id = 0;
|
|
||||||
std::string game;
|
|
||||||
|
|
||||||
buffer->read_string(&platform);
|
uint32_t count;
|
||||||
buffer->read_uint32(&num_users);
|
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_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());
|
auto reply = server->create_reply(this->task_id());
|
||||||
|
for (size_t i = 0u; i < filenames.size(); i++)
|
||||||
uint32_t count = 0;
|
|
||||||
for (uint32_t i = 0; i < num_files; i++)
|
|
||||||
{
|
{
|
||||||
std::string filename, data;
|
auto entry = std::make_unique<bdFileQueryResult>();
|
||||||
buffer->read_string(&filename);
|
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);
|
auto& name = filenames.at(i);
|
||||||
if (!utils::io::read_file(path, &data))
|
std::string filedata;
|
||||||
|
if (utils::io::read_file(get_user_file_path(name), &filedata))
|
||||||
{
|
{
|
||||||
|
entry->filedata = filedata;
|
||||||
#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]: 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
|
#endif
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto response = std::make_unique<bdFileQueryResult>();
|
reply.add(entry);
|
||||||
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.send();
|
reply.send();
|
||||||
|
Loading…
Reference in New Issue
Block a user