40
40
#include " TCSoap.h"
41
41
#include " Timer.h"
42
42
#include " Util.h"
43
+ #include " AuthSocket.h"
43
44
44
45
#include " BigNumber.h"
45
46
@@ -122,44 +123,47 @@ int Master::Run()
122
123
BigNumber seed1;
123
124
seed1.SetRand (16 * 8 );
124
125
125
- sLog ->outString ( " %s (core-daemon)" , _FULLVERSION );
126
- sLog ->outString ( " <Ctrl-C> to stop.\n " );
126
+ sLog ->outString (" %s (core-daemon)" , _FULLVERSION);
127
+ sLog ->outString (" <Ctrl-C> to stop.\n " );
127
128
128
- sLog ->outString ( " ______ __" );
129
- sLog ->outString ( " /\\ __ _\\ __ __/\\ \\ __" );
130
- sLog ->outString ( " \\ /_/\\ \\ / _ __ /\\ _\\ ___ /\\ _\\ \\ ,_\\ __ __" );
131
- sLog ->outString ( " \\ \\ \\ /\\ `'__\\ /\\ \\ /' _ `\\ /\\ \\ \\ \\ / /\\ \\ /\\ \\ " );
132
- sLog ->outString ( " \\ \\ \\ \\ \\ / \\ \\ \\ /\\ \\ /\\ \\ \\ \\ \\ \\ _\\ \\ \\ _\\ \\ " );
133
- sLog ->outString ( " \\ \\ _\\ \\ _\\ \\ \\ _\\ \\ _\\ \\ _\\ \\ _\\ \\ __\\\\ /`____ \\ " );
134
- sLog ->outString ( " \\ /_/\\ /_/ \\ /_/\\ /_/\\ /_/\\ /_/\\ /__/ `/___/> \\ " );
135
- sLog ->outString ( " C O R E /\\ ___/" );
136
- sLog ->outString ( " http://TrinityCore.org \\ /__/\n " );
129
+ sLog ->outString (" ______ __" );
130
+ sLog ->outString (" /\\ __ _\\ __ __/\\ \\ __" );
131
+ sLog ->outString (" \\ /_/\\ \\ / _ __ /\\ _\\ ___ /\\ _\\ \\ ,_\\ __ __" );
132
+ sLog ->outString (" \\ \\ \\ /\\ `'__\\ /\\ \\ /' _ `\\ /\\ \\ \\ \\ / /\\ \\ /\\ \\ " );
133
+ sLog ->outString (" \\ \\ \\ \\ \\ / \\ \\ \\ /\\ \\ /\\ \\ \\ \\ \\ \\ _\\ \\ \\ _\\ \\ " );
134
+ sLog ->outString (" \\ \\ _\\ \\ _\\ \\ \\ _\\ \\ _\\ \\ _\\ \\ _\\ \\ __\\\\ /`____ \\ " );
135
+ sLog ->outString (" \\ /_/\\ /_/ \\ /_/\\ /_/\\ /_/\\ /_/\\ /__/ `/___/> \\ " );
136
+ sLog ->outString (" C O R E /\\ ___/" );
137
+ sLog ->outString (" http://TrinityCore.org \\ /__/\n " );
137
138
138
139
#ifdef USE_SFMT_FOR_RNG
139
- sLog ->outString ( " \n " );
140
- sLog ->outString ( " SFMT has been enabled as the random number generator, if worldserver" );
141
- sLog ->outString ( " freezes or crashes randomly, first, try disabling SFMT in CMAKE configuration" );
142
- sLog ->outString ( " \n " );
140
+ sLog ->outString (" \n " );
141
+ sLog ->outString (" SFMT has been enabled as the random number generator, if worldserver" );
142
+ sLog ->outString (" freezes or crashes randomly, first, try disabling SFMT in CMAKE configuration" );
143
+ sLog ->outString (" \n " );
143
144
#endif // USE_SFMT_FOR_RNG
144
145
145
146
// / worldd PID file creation
146
147
std::string pidfile = sConfig ->GetStringDefault (" PidFile" , " " );
147
- if (!pidfile.empty ())
148
+ if (!pidfile.empty ())
148
149
{
149
150
uint32 pid = CreatePIDFile (pidfile);
150
- if ( !pid )
151
+ if ( !pid)
151
152
{
152
- sLog ->outError ( " Cannot create PID file %s.\n " , pidfile.c_str () );
153
+ sLog ->outError (" Cannot create PID file %s.\n " , pidfile.c_str ());
153
154
return 1 ;
154
155
}
155
156
156
- sLog ->outString ( " Daemon PID: %u\n " , pid );
157
+ sLog ->outString (" Daemon PID: %u\n " , pid);
157
158
}
158
159
159
160
// /- Start the databases
160
161
if (!_StartDB ())
161
162
return 1 ;
162
163
164
+ // set server offline (not connectable)
165
+ LoginDatabase.DirectPExecute (" UPDATE realmlist SET color = (color & ~%u) | %u WHERE id = '%d'" , REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID);
166
+
163
167
// /- Initialize the World
164
168
sWorld ->SetInitialWorldSettings ();
165
169
@@ -183,9 +187,6 @@ int Master::Run()
183
187
ACE_Based::Thread world_thread (new WorldRunnable);
184
188
world_thread.setPriority (ACE_Based::Highest);
185
189
186
- // set server online
187
- LoginDatabase.PExecute (" UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'" ,realmID);
188
-
189
190
ACE_Based::Thread* cliThread = NULL ;
190
191
191
192
#ifdef _WIN32
@@ -206,34 +207,34 @@ int Master::Run()
206
207
HANDLE hProcess = GetCurrentProcess ();
207
208
208
209
uint32 Aff = sConfig ->GetIntDefault (" UseProcessors" , 0 );
209
- if (Aff > 0 )
210
+ if (Aff > 0 )
210
211
{
211
212
ULONG_PTR appAff;
212
213
ULONG_PTR sysAff;
213
214
214
- if (GetProcessAffinityMask (hProcess,&appAff,&sysAff))
215
+ if (GetProcessAffinityMask (hProcess,&appAff,&sysAff))
215
216
{
216
217
ULONG_PTR curAff = Aff & appAff; // remove non accessible processors
217
218
218
- if (!curAff )
219
+ if (!curAff)
219
220
{
220
221
sLog ->outError (" Processors marked in UseProcessors bitmask (hex) %x not accessible for Trinityd. Accessible processors bitmask (hex): %x" ,Aff,appAff);
221
222
}
222
223
else
223
224
{
224
- if (SetProcessAffinityMask (hProcess,curAff))
225
+ if (SetProcessAffinityMask (hProcess,curAff))
225
226
sLog ->outString (" Using processors (bitmask, hex): %x" , curAff);
226
227
else
227
- sLog ->outError (" Can't set used processors (hex): %x" ,curAff);
228
+ sLog ->outError (" Can't set used processors (hex): %x" , curAff);
228
229
}
229
230
}
230
231
sLog ->outString (" " );
231
232
}
232
233
233
234
bool Prio = sConfig ->GetBoolDefault (" ProcessPriority" , false );
234
235
235
- // if (Prio && (m_ServiceStatus == -1)/* need set to default process priority class in service mode*/)
236
- if (Prio)
236
+ // if (Prio && (m_ServiceStatus == -1) /* need set to default process priority class in service mode*/)
237
+ if (Prio)
237
238
{
238
239
if (SetPriorityClass (hProcess,HIGH_PRIORITY_CLASS))
239
240
sLog ->outString (" TrinityCore process priority class set to HIGH" );
@@ -246,7 +247,7 @@ int Master::Run()
246
247
// Start soap serving thread
247
248
ACE_Based::Thread* soap_thread = NULL ;
248
249
249
- if (sConfig ->GetBoolDefault (" SOAP.Enabled" , false ))
250
+ if (sConfig ->GetBoolDefault (" SOAP.Enabled" , false ))
250
251
{
251
252
TCSoapRunnable *runnable = new TCSoapRunnable ();
252
253
runnable->setListenArguments (sConfig ->GetStringDefault (" SOAP.IP" , " 127.0.0.1" ), sConfig ->GetIntDefault (" SOAP.Port" , 7878 ));
@@ -257,7 +258,7 @@ int Master::Run()
257
258
realCurrTime = realPrevTime = getMSTime ();
258
259
259
260
// /- Start up freeze catcher thread
260
- if (uint32 freeze_delay = sConfig ->GetIntDefault (" MaxCoreStuckTime" , 0 ))
261
+ if (uint32 freeze_delay = sConfig ->GetIntDefault (" MaxCoreStuckTime" , 0 ))
261
262
{
262
263
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable ();
263
264
fdr->SetDelayTime (freeze_delay*1000 );
@@ -267,31 +268,34 @@ int Master::Run()
267
268
268
269
// /- Launch the world listener socket
269
270
uint16 wsport = sWorld ->getIntConfig (CONFIG_PORT_WORLD);
270
- std::string bind_ip = sConfig ->GetStringDefault (" BindIP" , " 0.0.0.0" );
271
+ std::string bind_ip = sConfig ->GetStringDefault (" BindIP" , " 0.0.0.0" );
271
272
272
- if (sWorldSocketMgr ->StartNetwork (wsport, bind_ip.c_str ()) == -1 )
273
+ if (sWorldSocketMgr ->StartNetwork (wsport, bind_ip.c_str ()) == -1 )
273
274
{
274
275
sLog ->outError (" Failed to start network" );
275
276
World::StopNow (ERROR_EXIT_CODE);
276
277
// go down and shutdown the server
277
278
}
278
279
279
- sWorldSocketMgr ->Wait ();
280
+ // set server online (allow connecting now)
281
+ LoginDatabase.DirectPExecute (" UPDATE realmlist SET color = color & ~%u, population = 0 WHERE id = '%u'" , REALM_FLAG_INVALID, realmID);
282
+
283
+ sWorldSocketMgr ->Wait ();
280
284
281
- if (soap_thread)
285
+ if (soap_thread)
282
286
{
283
- soap_thread->wait ();
284
- soap_thread->destroy ();
285
- delete soap_thread;
287
+ soap_thread->wait ();
288
+ soap_thread->destroy ();
289
+ delete soap_thread;
286
290
}
287
291
288
292
// set server offline
289
- LoginDatabase.PExecute (" UPDATE realmlist SET color = 2 WHERE id = '%d'" ,realmID);
293
+ LoginDatabase.PExecute (" UPDATE realmlist SET color = color | %u WHERE id = '%d'" , REALM_FLAG_OFFLINE, realmID);
290
294
291
295
// when the main thread closes the singletons get unloaded
292
296
// since worldrunnable uses them, it will crash if unloaded after master
293
297
world_thread.wait ();
294
- rar_thread.wait ();
298
+ rar_thread.wait ();
295
299
296
300
// /- Clean database before leaving
297
301
clearOnlineAccounts ();
@@ -301,7 +305,7 @@ int Master::Run()
301
305
WorldDatabase.Close ();
302
306
LoginDatabase.Close ();
303
307
304
- sLog ->outString ( " Halting process..." );
308
+ sLog ->outString (" Halting process..." );
305
309
306
310
if (cliThread)
307
311
{
0 commit comments