aboutsummaryrefslogtreecommitdiff
path: root/src/trinitycore
diff options
context:
space:
mode:
Diffstat (limited to 'src/trinitycore')
-rw-r--r--src/trinitycore/CliRunnable.cpp10
-rw-r--r--src/trinitycore/Master.cpp16
-rw-r--r--src/trinitycore/WorldRunnable.cpp2
3 files changed, 15 insertions, 13 deletions
diff --git a/src/trinitycore/CliRunnable.cpp b/src/trinitycore/CliRunnable.cpp
index 065a6662a50..0af892819b6 100644
--- a/src/trinitycore/CliRunnable.cpp
+++ b/src/trinitycore/CliRunnable.cpp
@@ -169,7 +169,7 @@ bool ChatHandler::HandleCharacterDeleteCommand(const char* args)
bool ChatHandler::HandleServerExitCommand(const char* args)
{
SendSysMessage(LANG_COMMAND_EXIT);
- World::m_stopEvent = true;
+ World::StopNow(SHUTDOWN_EXIT_CODE);
return true;
}
@@ -310,14 +310,14 @@ void CliRunnable::run()
printf("TC>");
///- As long as the World is running (no World::m_stopEvent), get the command line and handle it
- while (!World::m_stopEvent)
+ while (!World::IsStopped())
{
fflush(stdout);
#ifdef linux
- while (!kb_hit_return() && !World::m_stopEvent)
+ while (!kb_hit_return() && !World::IsStopped())
// With this, we limit CLI to 10commands/second
usleep(100);
- if (World::m_stopEvent)
+ if (World::IsStopped())
break;
#endif
char *command_str = fgets(commandbuf,sizeof(commandbuf),stdin);
@@ -348,7 +348,7 @@ void CliRunnable::run()
}
else if (feof(stdin))
{
- World::m_stopEvent = true;
+ World::StopNow(SHUTDOWN_EXIT_CODE);
}
}
diff --git a/src/trinitycore/Master.cpp b/src/trinitycore/Master.cpp
index 47a12484151..317a3a31a15 100644
--- a/src/trinitycore/Master.cpp
+++ b/src/trinitycore/Master.cpp
@@ -77,7 +77,7 @@ public:
w_loops = 0;
m_lastchange = 0;
w_lastchange = 0;
- while(!World::m_stopEvent)
+ while(!World::IsStopped())
{
ZThread::Thread::sleep(1000);
uint32 curtime = getMSTime();
@@ -172,13 +172,13 @@ public:
// if use ra spend time waiting for io, if not use ra ,just sleep
if (usera)
- while (!World::m_stopEvent)
+ while (!World::IsStopped())
{
h.Select (0, socketSelecttime);
checkping ();
}
else
- while (!World::m_stopEvent)
+ while (!World::IsStopped())
{
ZThread::Thread::sleep (static_cast<unsigned long> (socketSelecttime / 1000));
checkping ();
@@ -323,7 +323,7 @@ int Master::Run()
if (sWorldSocketMgr->StartNetwork (wsport, bind_ip.c_str ()) == -1)
{
sLog.outError ("Failed to start network");
- World::m_stopEvent = true;
+ World::StopNow(ERROR_EXIT_CODE);
// go down and shutdown the server
}
@@ -394,7 +394,8 @@ int Master::Run()
// fixes a memory leak related to detaching threads from the module
UnloadScriptingModule();
- return sWorld.GetShutdownMask() & SHUTDOWN_MASK_RESTART ? 2 : 0;
+ // Exit the process with specified return value
+ return World::GetExitCode();
}
/// Initialize connection to the databases
@@ -477,17 +478,18 @@ void Master::clearOnlineAccounts()
}
/// Handle termination signals
-/** Put the World::m_stopEvent to 'true' if a termination signal is caught **/
void Master::_OnSignal(int s)
{
switch (s)
{
case SIGINT:
+ World::StopNow(RESTART_EXIT_CODE);
+ break;
case SIGTERM:
#ifdef _WIN32
case SIGBREAK:
#endif
- World::m_stopEvent = true;
+ World::StopNow(SHUTDOWN_EXIT_CODE);
break;
}
diff --git a/src/trinitycore/WorldRunnable.cpp b/src/trinitycore/WorldRunnable.cpp
index 1a30740ddd9..5592b1d2064 100644
--- a/src/trinitycore/WorldRunnable.cpp
+++ b/src/trinitycore/WorldRunnable.cpp
@@ -51,7 +51,7 @@ void WorldRunnable::run()
uint32 prevSleepTime = 0; // used for balanced full tick time length near WORLD_SLEEP_CONST
///- While we have not World::m_stopEvent, update the world
- while (!World::m_stopEvent)
+ while (!World::IsStopped())
{
++World::m_worldLoopCounter;
realCurrTime = getMSTime();