Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit e152d60

Browse files
author
Dankrushen
authored
Merge pull request #246 from ServerMod/output-code-handling
Handle Exit Status OutputCodes
2 parents 8abe593 + 552e01e commit e152d60

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

MultiAdmin/Server.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,25 +473,39 @@ public void StartServer(bool restartOnCrash = true)
473473
} while (shouldRestart);
474474
}
475475

476-
public void StopServer(bool killGame = false)
476+
public void SetStopStatus(bool killGame = false)
477477
{
478478
if (!IsRunning) throw new Exceptions.ServerNotRunningException();
479479

480480
initStopTimeoutTime = DateTime.Now;
481481
Status = killGame ? ServerStatus.ForceStopping : ServerStatus.Stopping;
482482

483483
ForEachHandler<IEventServerStop>(stopEvent => stopEvent.OnServerStop());
484+
}
485+
486+
public void StopServer(bool killGame = false)
487+
{
488+
if (!IsRunning) throw new Exceptions.ServerNotRunningException();
489+
490+
SetStopStatus(killGame);
484491

485492
if ((killGame || !SendMessage("QUIT")) && IsGameProcessRunning)
486493
GameProcess.Kill();
487494
}
488495

489-
public void SoftRestartServer(bool killGame = false)
496+
public void SetRestartStatus()
490497
{
491498
if (!IsRunning) throw new Exceptions.ServerNotRunningException();
492499

493500
initRestartTimeoutTime = DateTime.Now;
494501
Status = ServerStatus.Restarting;
502+
}
503+
504+
public void SoftRestartServer(bool killGame = false)
505+
{
506+
if (!IsRunning) throw new Exceptions.ServerNotRunningException();
507+
508+
SetRestartStatus();
495509

496510
SendMessage("SOFTRESTART");
497511
if (killGame && IsGameProcessRunning)

MultiAdmin/ServerIO/OutputHandler.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,20 @@ public void HandleAction(object source, byte action)
189189
server.ForEachHandler<IEventIdleExit>(idleExit => idleExit.OnIdleExit());
190190
break;
191191

192-
// Unhandled for now
193192
case OutputCodes.ExitActionReset:
193+
server.SetRestartStatus();
194+
break;
195+
194196
case OutputCodes.ExitActionShutdown:
197+
server.SetStopStatus();
198+
break;
199+
195200
case OutputCodes.ExitActionSilentShutdown:
201+
server.SetStopStatus();
202+
break;
203+
196204
case OutputCodes.ExitActionRestart:
205+
server.SetRestartStatus();
197206
break;
198207

199208
default:

0 commit comments

Comments
 (0)