Make random name work in main menu
This commit is contained in:
parent
f5320b3690
commit
a6f3641c00
@ -19,6 +19,8 @@ extern std::string name_forced;
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
static TextFile randomnames_file;
|
||||
|
||||
DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason)
|
||||
{
|
||||
g_Settings.bInvalid = true;
|
||||
@ -51,13 +53,30 @@ DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason)
|
||||
votelogger::onShutdown(message);
|
||||
if (*random_name)
|
||||
{
|
||||
static TextFile file;
|
||||
if (file.TryLoad("names.txt"))
|
||||
if (randomnames_file.TryLoad("names.txt"))
|
||||
{
|
||||
name_forced = file.lines.at(rand() % file.lines.size());
|
||||
name_forced = randomnames_file.lines.at(rand() % randomnames_file.lines.size());
|
||||
}
|
||||
}
|
||||
else
|
||||
name_forced = "";
|
||||
}
|
||||
|
||||
static InitRoutine init(
|
||||
[]()
|
||||
{
|
||||
random_name.installChangeCallback(
|
||||
[](settings::VariableBase<bool> &, bool after)
|
||||
{
|
||||
if (after)
|
||||
{
|
||||
if (randomnames_file.TryLoad("names.txt"))
|
||||
{
|
||||
name_forced = randomnames_file.lines.at(rand() % randomnames_file.lines.size());
|
||||
}
|
||||
}
|
||||
else
|
||||
name_forced = "";
|
||||
});
|
||||
});
|
||||
} // namespace hooked_methods
|
||||
|
Reference in New Issue
Block a user