Use localized string for motd (async).

This commit is contained in:
momo5502 2016-01-27 00:50:20 +01:00
parent b1e16f70e7
commit b819f7e68e
3 changed files with 24 additions and 25 deletions

View File

@ -20,14 +20,6 @@ namespace Components
data.push_back({ "weapons_mp", 1, 0 }); data.push_back({ "weapons_mp", 1, 0 });
Game::DB_LoadXAssets(data.data(), data.size(), sync); Game::DB_LoadXAssets(data.data(), data.size(), sync);
#ifdef DEBUG
if (!ZoneBuilder::IsEnabled())
{
info = { "penis", 1, 0 };
Game::DB_LoadXAssets(&info, 1, 1);
}
#endif
} }
const char* FastFiles::GetZoneLocation(const char* file) const char* FastFiles::GetZoneLocation(const char* file)

View File

@ -2,27 +2,34 @@
namespace Components namespace Components
{ {
std::string News::Motd; std::thread* News::Thread = 0;
const char* News::GetMotd()
{
return News::Motd.data();
}
News::News() News::News()
{ {
Localization::Set("MPUI_CHANGELOG_TEXT", ""); Localization::Set("MPUI_CHANGELOG_TEXT", "");
Localization::Set("MPUI_MOTD_TEXT", "Welcome to ReactIW4x Multiplayer!");
News::Motd = Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/motd.txt").SetTimeout(1000)->Get(); News::Thread = new std::thread([] ()
if (!News::Motd.size())
{ {
News::Motd = "Welcome to ReactIW4x Multiplayer!"; Localization::Set("MPUI_CHANGELOG_TEXT", Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/changelog.txt").Get().data());
std::string data = Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/motd.txt").Get();
if (data.size())
{
Localization::Set("MPUI_MOTD_TEXT", data.data());
} }
Localization::Set("MPUI_CHANGELOG_TEXT", Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/changelog.txt").SetTimeout(1000)->Get().data()); // TODO: Implement update checks here!
});
}
// Patch motd setting News::~News()
Utils::Hook(0x60BF19, News::GetMotd, HOOK_CALL).Install()->Quick(); {
if (News::Thread)
{
News::Thread->join();
delete News::Thread;
}
} }
} }

View File

@ -4,10 +4,10 @@ namespace Components
{ {
public: public:
News(); News();
~News();
const char* GetName() { return "News"; }; const char* GetName() { return "News"; };
private: private:
static std::string Motd; static std::thread* Thread;
static const char* GetMotd();
}; };
} }