From d0a7f9a57d734ce99da262fdf7dd206351fa8ac3 Mon Sep 17 00:00:00 2001 From: "lapayo94@gmail.com" Date: Sun, 25 Dec 2011 13:44:22 +0000 Subject: Code improvements Fixed authentication (Can be activated now) Added MersenneTwister.h Thanks to mtilden ( http://forum.mc-server.org/showthread.php?tid=183&pid=1428#pid1428 and http://forum.mc-server.org/showthread.php?tid=183&pid=1418#pid1418 ) git-svn-id: http://mc-server.googlecode.com/svn/trunk@106 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cServer.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source/cServer.cpp') diff --git a/source/cServer.cpp b/source/cServer.cpp index 5fbd6d8c7..ebd91db94 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -23,6 +23,8 @@ #include "cTracer.h" #include "cWebAdmin.h" +#include "MersenneTwister.h" + #include "../iniFile/iniFile.h" #include "Vector3f.h" @@ -196,6 +198,9 @@ bool cServer::InitServer( int a_Port ) if( IniFile.ReadFile() ) { g_bWaterPhysics = IniFile.GetValueB("Physics", "Water", false ); + + /* Replaced below with 1.0.0 compatible ServerID generation + std::string ServerID = IniFile.GetValue("Server", "ServerID"); if( ServerID.empty() ) { @@ -203,7 +208,19 @@ bool cServer::InitServer( int a_Port ) IniFile.SetValue("Server", "ServerID", ServerID, true ); IniFile.WriteFile(); } - m_pState->ServerID = ServerID; + */ + m_pState->ServerID = "-"; + if (IniFile.GetValueB("Authentication", "Authenticate")) + { + MTRand mtrand1; + unsigned int r1 = (mtrand1.randInt()%1147483647) + 1000000000; + unsigned int r2 = (mtrand1.randInt()%1147483647) + 1000000000; + std::ostringstream sid; + sid << std::hex << r1; + sid << std::hex << r2; + std::string ServerID = sid.str(); + m_pState->ServerID = ServerID; + } } return true; } -- cgit v1.2.3