diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2026-05-28 23:56:29 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2026-05-28 23:56:29 -0300 |
| commit | e2ba7cd29617ae05087ad3d25c55a2eb8ce607a3 (patch) | |
| tree | 2a93ee38c7cc9c83b3b89b3f0f7cbb6fcb8e8b3c /src/main.cc | |
| parent | d1c4dce3be82aa7e50ddb5b43f15ecc00a16f985 (diff) | |
| download | game-e2ba7cd29617ae05087ad3d25c55a2eb8ce607a3.tar.gz game-e2ba7cd29617ae05087ad3d25c55a2eb8ce607a3.zip | |
fix issues and warnings when compiling with glibc < 2.32 (#57, #58)
This also fixes some inconsistencies such as mixing both strerror
and strerrordesc_np, and possible formatting issues.
Diffstat (limited to 'src/main.cc')
| -rw-r--r-- | src/main.cc | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/main.cc b/src/main.cc index ddeda8b..937c222 100644 --- a/src/main.cc +++ b/src/main.cc @@ -53,7 +53,8 @@ static void SigBlock(int SigNr){ sigaddset(&Set, SigNr); if(sigprocmask(SIG_BLOCK, &Set, NULL) == -1){ error("SigBlock: Failed to block signal %d (%s): (%d) %s\n", - SigNr, sigdescr_np(SigNr), errno, strerrordesc_np(errno)); + SigNr, GetSignalDescription(SigNr), + errno, GetErrorDescription(errno)); } } @@ -63,18 +64,18 @@ static void SigWaitAny(void){ sigsuspend(&Set); } -static void SigHupHandler(int signr){ +static void SigHupHandler(int SigNr){ // no-op (?) } -static void SigAbortHandler(int signr){ +static void SigAbortHandler(int SigNr){ print(1, "SigAbortHandler: schalte Writer-Thread ab.\n"); AbortWriter(); } -static void DefaultHandler(int signr){ +static void DefaultHandler(int SigNr){ print(1, "DefaultHandler: Beende Game-Server (SigNr. %d: %s).\n", - signr, sigdescr_np(signr)); + SigNr, GetSignalDescription(SigNr)); SigHandler(SIGINT, SIG_IGN); SigHandler(SIGQUIT, SIG_IGN); @@ -83,8 +84,8 @@ static void DefaultHandler(int signr){ SigHandler(SIGXFSZ, SIG_IGN); SigHandler(SIGPWR, SIG_IGN); - SaveMapOn = (signr == SIGQUIT) || (signr == SIGTERM) || (signr == SIGPWR); - if(signr == SIGTERM){ + SaveMapOn = (SigNr == SIGQUIT) || (SigNr == SIGTERM) || (SigNr == SIGPWR); + if(SigNr == SIGTERM){ int Hour, Minute; GetRealTime(&Hour, &Minute); RebootTime = (Hour * 60 + Minute + 6) % 1440; @@ -98,8 +99,8 @@ static void DefaultHandler(int signr){ #if 0 // TODO(fusion): This function was exported in the binary but not referenced anywhere. -static void ErrorHandler(int signr){ - error("ErrorHandler: SigNr. %d: %s\n", signr, sigdescr_np(signr)); +static void ErrorHandler(int SigNr){ + error("ErrorHandler: SigNr. %d: %s\n", SigNr, GetSignalDescription(SigNr)); EndGame(); LogoutAllPlayers(); exit(EXIT_FAILURE); @@ -151,7 +152,7 @@ static void InitTime(void){ SigEvent.sigev_notify_thread_id = gettid(); if(timer_create(CLOCK_MONOTONIC, &SigEvent, &BeatTimer) == -1){ error("InitTime: Failed to create beat timer: (%d) %s\n", - errno, strerrordesc_np(errno)); + errno, GetErrorDescription(errno)); throw "cannot create beat timer"; } @@ -161,7 +162,7 @@ static void InitTime(void){ TimerSpec.it_value = TimerSpec.it_interval; if(timer_settime(BeatTimer, 0, &TimerSpec, NULL) == -1){ error("InitTime: Failed to start beat timer: (%d) %s\n", - errno, strerrordesc_np(errno)); + errno, GetErrorDescription(errno)); throw "cannot start beat timer"; } } @@ -169,7 +170,7 @@ static void InitTime(void){ static void ExitTime(void){ if(timer_delete(BeatTimer) == -1){ error("ExitTime: Failed to delete beat timer: (%d) %s\n", - errno, strerrordesc_np(errno)); + errno, GetErrorDescription(errno)); } SigHandler(SIGALRM, SIG_IGN); @@ -448,7 +449,7 @@ static void AdvanceGame(int Delay){ SendAll(); } -static void SigUsr1Handler(int signr){ +static void SigUsr1Handler(int SigNr){ SigUsr1Counter += 1; } @@ -508,7 +509,12 @@ static bool DaemonInit(bool NoFork){ } umask(0177); - chdir(SAVEPATH); + + // NOTE(fusion): The original binary would change directories to `SAVEPATH` + // here, but because this function is called very early at startup, no config + // values would have been loaded, leaving `SAVEPATH` empty and causing this + // next call to `chdir` to always fail with ENOENT. + //chdir(SAVEPATH); int OpenMax = sysconf(_SC_OPEN_MAX); if(OpenMax < 0){ |
