[Stats] Add support for mod-specific stat files
This commit is contained in:
parent
138d6ad1dd
commit
b97610facb
@ -63,6 +63,17 @@ namespace Components
|
|||||||
Stats::SendStats();
|
Stats::SendStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Stats::SaveStats(char* dest, const char* folder, const char* buffer, size_t length)
|
||||||
|
{
|
||||||
|
const auto fs_game = Game::Dvar_FindVar("fs_game");
|
||||||
|
if (fs_game && fs_game->current.string && strlen(fs_game->current.string) && !strncmp(fs_game->current.string, "mods/", 5))
|
||||||
|
{
|
||||||
|
folder = fs_game->current.string;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Utils::Hook::Call<int(char*, const char*, const char*, size_t)>(0x426450)(dest, folder, buffer, length);
|
||||||
|
}
|
||||||
|
|
||||||
Stats::Stats()
|
Stats::Stats()
|
||||||
{
|
{
|
||||||
// This UIScript should be added in the onClose code of the cac_popup menu,
|
// This UIScript should be added in the onClose code of the cac_popup menu,
|
||||||
@ -91,6 +102,9 @@ namespace Components
|
|||||||
|
|
||||||
// Don't create stat backup
|
// Don't create stat backup
|
||||||
Utils::Hook::Nop(0x402CE6, 2);
|
Utils::Hook::Nop(0x402CE6, 2);
|
||||||
|
|
||||||
|
// Write stats to mod folder if a mod is loaded
|
||||||
|
Utils::Hook(0x682F7B, Stats::SaveStats, HOOK_CALL).install()->quick();
|
||||||
}
|
}
|
||||||
|
|
||||||
Stats::~Stats()
|
Stats::~Stats()
|
||||||
|
@ -13,6 +13,7 @@ namespace Components
|
|||||||
private:
|
private:
|
||||||
static void UpdateClasses(UIScript::Token token);
|
static void UpdateClasses(UIScript::Token token);
|
||||||
static void SendStats();
|
static void SendStats();
|
||||||
|
static int SaveStats(char* dest, const char* folder, const char* buffer, size_t length);
|
||||||
|
|
||||||
static int64_t* GetStatsID();
|
static int64_t* GetStatsID();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user