Merge pull request #54 from ineedbots/develop

Remove updater, update changelog and links
This commit is contained in:
Dss0 2020-12-12 22:15:34 +01:00 committed by GitHub
commit f3f2c69e85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 457 additions and 619 deletions

View File

@ -4,15 +4,50 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog v0.3.0](http://keepachangelog.com/en/0.3.0/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [unreleased] - xxxx-xx-xx
## [0.6.1 Community] - 2020-12-05
### Added
- Add host information to /info endpoint (request)
- Add fileWrite GSC Function (#36)
- Add fileRead GSC Function (#36)
- Add fileExists GSC Function (#36)
- Add fileRemove GSC Function (#36)
- Add botMovement GSC Function (#46)
- Add botAction GSC Function (#46)
- Add botWeapon GSC Function (#46)
- Add botStop GSC Function (#46)
- Add isBot GSC Function (#46)
- Add setPing GSC Function (#46)
- Add GetSystemTime and GetSystemTimeMilliseconds GSC Functions (#46)
- Add PrintConsole GSC Function (#46)
- Add Exec GSC Function (#46)
- Add getIP GSC Method (#36)
- Add getPing GSC Method (#36)
- Add scr_intermissionTime GSC Function (#25)
- Add g_playerCollision Dvar (#36)
- Add g_playerEjection Dvar (#36)
- Add r_specularCustomMaps Dvar (#36)
- Unlock safeArea_horizontal and safeArea_vertical Dvars (#42)
- Unlock cg_fovscale Dvar (#47)
### Changed
- Stats are now separate for each mod (#6). Player stats are copied to `fs_game` folder if no stats exist for this mod yet. Keep in mind this also means that level, XP and classes will not be synchronized with the main stats file after this point.
- Reduced duration of toasts (#48)
- Removed old updater functionality
- Use old bot names if bots.txt is not found (#46)
- Removed Steam integration because Steam updates kept breaking it (#51)
### Fixed
- Fixed a node system related crash (#45)
- Fixed an issue that made dedicated servers crash when info was requested during map rotation (#43)
- Fixed an issue where the game was trying to decrypt gsc files which caused it to crash when loading mods (#35)
#######################End of official IW4x Development - Project goes Open Source#######################
## [0.6.0] - 2018-12-30

View File

@ -12,7 +12,7 @@ namespace Components
std::lock_guard<std::mutex> _(Changelog::Mutex);
Changelog::Lines.clear();
std::string data = Utils::Cache::GetFile("/iw4/changelog.txt");
std::string data = Utils::Cache::GetFile("/develop/CHANGELOG.md");
if (data.empty())
{

View File

@ -766,8 +766,7 @@ namespace Components
{
if (pack.index == dlc)
{
News::LaunchUpdater(Utils::String::VA("-dlc %i -c", pack.index));
//ShellExecuteA(nullptr, "open", pack.url.data(), nullptr, nullptr, SW_SHOWNORMAL);
ShellExecute(0, 0, L"https://xlabs.dev/support_iw4x_client.html", 0, 0, SW_SHOW);
return;
}
}

View File

@ -6,9 +6,6 @@ namespace Components
{
bool News::Terminate;
std::thread News::Thread;
std::string News::UpdaterArgs;
std::string News::UpdaterHash;
std::mutex News::UpdaterMutex;
bool News::unitTest()
{
@ -33,165 +30,18 @@ namespace Components
return result;
}
void News::ExitProcessStub(unsigned int exitCode)
{
std::this_thread::sleep_for(10ms);
STARTUPINFOA sInfo;
PROCESS_INFORMATION pInfo;
ZeroMemory(&sInfo, sizeof(sInfo));
ZeroMemory(&pInfo, sizeof(pInfo));
sInfo.cb = sizeof(sInfo);
CreateProcessA("updater.exe", const_cast<char*>(Utils::String::VA("updater.exe %s", News::UpdaterArgs.data())), nullptr, nullptr, false, NULL, nullptr, nullptr, &sInfo, &pInfo);
if (pInfo.hThread && pInfo.hThread != INVALID_HANDLE_VALUE) CloseHandle(pInfo.hThread);
if (pInfo.hProcess && pInfo.hProcess != INVALID_HANDLE_VALUE) CloseHandle(pInfo.hProcess);
TerminateProcess(GetCurrentProcess(), exitCode);
}
bool News::GetLatestUpdater()
{
std::lock_guard<std::mutex> _(News::UpdaterMutex);
if (Utils::IO::FileExists("updater.exe"))
{
// Generate hash of local updater.exe
std::string localUpdater = Utils::IO::ReadFile("updater.exe");
localUpdater = Utils::Cryptography::SHA1::Compute(localUpdater, true);
static Utils::Time::Interval updateInterval;
if (News::UpdaterHash.empty() || updateInterval.elapsed(15min)) // Check for updater Update every 15 mins max
{
updateInterval.update();
std::string data = Utils::Cache::GetFile("/json/updater"); // {"updater.exe":{"SHA1":"*HASH*"}}
std::string error;
json11::Json listData = json11::Json::parse(data, error);
if (error.empty() || listData.is_object())
{
News::UpdaterHash = listData["updater.exe"]["SHA1"].string_value();
}
}
if (!News::UpdaterHash.empty() && localUpdater != News::UpdaterHash)
{
remove("updater.exe");
}
}
if (!Utils::IO::FileExists("updater.exe"))
{
return News::DownloadUpdater();
}
return true;
}
bool News::DownloadUpdater()
{
std::string data = Utils::Cache::GetFile("/iw4/updater.exe");
if (!data.empty())
{
Utils::IO::WriteFile("updater.exe", data);
return true;
}
return false;
}
const char* News::GetNewsText()
{
return Localization::Get("MPUI_MOTD_TEXT");
}
void News::CheckForUpdate()
{
std::string _client = Utils::Cache::GetFile("/json/client");
if (!_client.empty())
{
std::string error;
json11::Json client = json11::Json::parse(_client.data(), error);
int revisionNumber;
if (client["revision"].is_number())
{
revisionNumber = client["revision"].int_value();
}
else if (client["revision"].is_string())
{
revisionNumber = atoi(client["revision"].string_value().data());
}
else return;
Dvar::Var("cl_updateversion").get<Game::dvar_t*>()->current.integer = revisionNumber;
Dvar::Var("cl_updateavailable").get<Game::dvar_t*>()->current.enabled = (revisionNumber > REVISION);
// if there is an update then show the toast, but only once
static bool showToast = true;
if (revisionNumber > REVISION && showToast)
{
showToast = false;
Scheduler::OnReady([]()
{
Toast::Show("cardicon_gears", "^4Update Available", "There is an update available for your client!", 5000);
});
}
}
}
void News::LaunchUpdater(const std::string& params)
{
if (News::Updating()) return;
News::UpdaterArgs = params;
Localization::SetTemp("MENU_RECONNECTING_TO_PARTY", "Downloading updater");
Command::Execute("openmenu popup_reconnectingtoparty", true);
// Run the updater on shutdown
Utils::Hook::Set(0x6D72A0, News::ExitProcessStub);
std::thread([]()
{
if (News::GetLatestUpdater())
{
Console::SetSkipShutdown();
Command::Execute("wait 300; quit;", false);
}
else
{
Localization::ClearTemp();
News::UpdaterArgs.clear();
Command::Execute("closemenu popup_reconnectingtoparty", false);
Game::ShowMessageBox("Failed to download the updater!", "Error");
}
}).detach();
}
bool News::Updating()
{
return !News::UpdaterArgs.empty();
}
News::News()
{
News::UpdaterArgs.clear();
News::UpdaterHash.clear();
if (ZoneBuilder::IsEnabled() || Dedicated::IsEnabled()) return; // Maybe also dedi?
Dvar::Register<bool>("g_firstLaunch", true, Game::DVAR_FLAG_SAVED, "");
Dvar::Register<int>("cl_updateoldversion", REVISION, REVISION, REVISION, Game::DVAR_FLAG_WRITEPROTECTED, "Current version number.");
Dvar::Register<int>("cl_updateversion", 0, 0, -1, Game::DVAR_FLAG_WRITEPROTECTED, "New version number.");
Dvar::Register<bool>("cl_updateavailable", false, Game::DVAR_FLAG_WRITEPROTECTED, "New update is available.");
UIScript::Add("checkFirstLaunch", [](UIScript::Token)
{
@ -221,8 +71,6 @@ namespace Components
Localization::Set("MPUI_CHANGELOG_TEXT", "Loading...");
Localization::Set("MPUI_MOTD_TEXT", NEWS_MOTD_DEFAULT);
//News::GetLatestUpdater();
// make newsfeed (ticker) menu items not cut off based on safe area
Utils::Hook::Nop(0x63892D, 5);
@ -230,17 +78,6 @@ namespace Components
Utils::Hook::Nop(0x6388BB, 2); // skip the "if (item->text[0] == '@')" localize check
Utils::Hook(0x6388C1, News::GetNewsText, HOOK_CALL).install()->quick();
Command::Add("checkforupdate", [](Command::Params*)
{
News::CheckForUpdate();
});
Command::Add("getautoupdate", [](Command::Params*)
{
if (!Dvar::Var("cl_updateavailable").get<Game::dvar_t*>()->current.enabled) return;
News::LaunchUpdater("-update -c");
});
if (!Utils::IsWineEnvironment() && !Loader::IsPerformingUnitTests())
{
News::Terminate = false;
@ -257,12 +94,8 @@ namespace Components
if (!Loader::IsPerformingUnitTests() && !News::Terminate)
{
News::GetLatestUpdater();
while (!News::Terminate)
{
News::CheckForUpdate();
// Sleep for 3 minutes
for (int i = 0; i < 180 && !News::Terminate; ++i)
{
@ -274,12 +107,6 @@ namespace Components
}
}
News::~News()
{
News::UpdaterArgs.clear();
News::UpdaterHash.clear();
}
void News::preDestroy()
{
News::Terminate = true;

View File

@ -6,27 +6,16 @@ namespace Components
{
public:
News();
~News();
void preDestroy() override;
bool unitTest() override;
static void LaunchUpdater(const std::string& params);
static bool Updating();
private:
static std::string UpdaterArgs;
static std::string UpdaterHash;
static std::thread Thread;
static std::mutex UpdaterMutex;
static bool Terminate;
static bool GetLatestUpdater();
static bool DownloadUpdater();
static void CheckForUpdate();
static void ExitProcessStub(unsigned int exitCode);
static const char* GetNewsText();
};
}

View File

@ -4,27 +4,15 @@ namespace Utils
{
const char* Cache::Urls[] =
{
"https://iw4x.org",
"https://xlabs.dev",
"https://raw.githubusercontent.com/XLabsProject/iw4x-client"
"https://iw4xcachep26muba.onion.to",
"https://iw4xcachep26muba.tor2web.xyz",
"https://iw4xcachep26muba.onion.ws",
"https://iw4xcachep26muba.onion.sh",
"https://iw4xcachep26muba.onion.pet",
//Links to old onion site - deprecated
//"https://iw4xcachep26muba.tor2web.xyz",
//"https://iw4xcachep26muba.onion.ws",
//"https://iw4xcachep26muba.onion.sh",
//"https://iw4xcachep26muba.onion.pet",
// Links below are dead
// Still, let's keep them in case they come back
"https://iw4xcachep26muba.onion.rip",
"https://iw4xcachep26muba.onion.nu",
"https://iw4xcachep26muba.onion.guide",
"https://iw4xcachep26muba.onion.casa",
"https://iw4xcachep26muba.hiddenservice.net",
"https://iw4xcachep26muba.onion.cab",
"https://iw4xcachep26muba.onion.link",
// Not registered yet
//"https://iw4xcachejnetuln.onion.to",
//"https://iw4xcachedjodc4y.onion.to",
};
std::string Cache::ValidUrl;
std::mutex Cache::CacheMutex;