Persist the lobby Terms Of Use and Terms Of Service checkbox if the logged in user and the accepted versions of the pages didn't change since last login, refs #5218.

This way the user is only forced to read the Terms again that changed or
if the user logged in from a different machine.
Use md5sum since it is sufficiently resistant against collisions and
doesn't freeze the window for 2 seconds like EncryptPassword / SHA256
does, refs #4399.
Use 0 instead of empty string in default.cfg, refs #3990.

Differential Revision: https://code.wildfiregames.com/D1575
Partial review by: Vladislav
This was SVN commit r21850.
This commit is contained in:
elexis
2018-06-21 16:38:08 +00:00
parent fe41404ba8
commit 468d963e78
7 changed files with 62 additions and 1 deletions
+17
View File
@@ -23,6 +23,7 @@
#include "graphics/MapReader.h"
#include "lib/sysdep/sysdep.h"
#include "lib/utf8.h"
#include "maths/MD5.h"
#include "ps/CStrIntern.h"
#include "ps/GUID.h"
#include "ps/GameSetup/Atlas.h"
@@ -109,6 +110,21 @@ int JSI_Main::GetTextWidth(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const
return width;
}
std::string JSI_Main::CalculateMD5(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& input)
{
u8 digest[MD5::DIGESTSIZE];
MD5 m;
m.Update(static_cast<const u8*>(input.c_str()), input.length());
m.Final(digest);
char digeststr[MD5::DIGESTSIZE*2+1];
for (size_t i = 0; i < MD5::DIGESTSIZE; ++i)
sprintf_s(digeststr+2*i, 3, "%02x", (unsigned int)digest[i]);
return digeststr;
}
void JSI_Main::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
{
scriptInterface.RegisterFunction<void, &QuitEngine>("Exit");
@@ -122,4 +138,5 @@ void JSI_Main::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
scriptInterface.RegisterFunction<bool, std::string, &HotkeyIsPressed_>("HotkeyIsPressed");
scriptInterface.RegisterFunction<int, &GetFps>("GetFPS");
scriptInterface.RegisterFunction<int, std::string, std::wstring, &GetTextWidth>("GetTextWidth");
scriptInterface.RegisterFunction<std::string, std::string, &CalculateMD5>("CalculateMD5");
}