3
*************************************************************************
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
8
**************************************************************************
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
***************************************************************************
28
#include "tConfiguration.h"
29
#include "tDirectories.h"
31
#include "nServerInfo.h"
34
#include "tCommandLine.h"
38
REAL save_interval = 300.0f;
39
static tSettingItem< REAL > si( "MASTER_SAVE_INTERVAL", save_interval );
41
REAL query_interval = 10.0f;
42
static tSettingItem< REAL > qi( "MASTER_QUERY_INTERVAL", query_interval );
44
int master_port = 4533;
45
static tSettingItem< int > mp( "MASTER_PORT", master_port );
48
static tSettingItem< REAL > mi( "MASTER_IDLE", master_idle );
50
// console with filter for better machine readable log format
51
class nConsoleDateFilter:public tConsoleFilter{
53
virtual void DoFilterLine( tString &line )
59
pTime = localtime(&now);
60
strftime(szTemp,sizeof(szTemp),"[%Y/%m/%d %H:%M:%S] ",pTime);
64
line << szTemp << orig;
67
virtual int DoGetPriority() const{ return 1; }
70
static nConsoleDateFilter sn_consoleFilter;
72
int main(int argc, char** argv)
74
tCommandLineData commandLine;
75
commandLine.programVersion_ = &sn_programVersion;
76
commandLine.Analyse(argc, argv);
77
tLocale::Load("languages.txt");
78
atexit(tLocale::Clear);
82
nServerInfo::GetMasters();
86
// std::istringstream s("SERVER_IP ANY");
87
// tConfItemBase::LoadAll( s );
90
nServerInfo::Load( tDirectories::Var(), "master_list.srv" );
92
nServerInfo::StartQueryAll();
95
sn_serverPort = master_port;
96
sn_SetNetState(nSERVER);
98
nTimeAbsolute savetimeout = tSysTimeFloat();
99
nTimeAbsolute querytimeout = tSysTimeFloat();
100
nTimeAbsolute quitTimeout = tSysTimeFloat() + master_idle * 3600;
105
nServerInfo::RunMaster();
107
sn_BasicNetworkSystem.Select( .1f );
109
nTimeAbsolute time = tSysTimeFloat();
112
sn_ReceiveFromControlSocket();
115
static bool queryGoesOn = true;
116
if (queryGoesOn && time > querytimeout)
118
queryGoesOn = nServerInfo::DoQueryAll(1);
119
querytimeout = time + query_interval;
122
if (time > savetimeout)
124
nServerInfo::Save( tDirectories::Var(), "master_list.srv" );
127
nServerInfo::StartQueryAll();
130
savetimeout = time + save_interval;
132
goon = time < quitTimeout;
136
nServerInfo::DeleteAll();