From ac5a185d1bb7b234338a02644476a2f824e1088c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 1 Jun 2025 11:09:39 +1000 Subject: [PATCH] Move towards platform behaviour flags --- src/Entity.c | 6 +++--- src/Launcher.c | 2 +- src/Platform.h | 6 +++++- src/Platform_Amiga.c | 4 ++-- src/Platform_Dreamcast.c | 2 +- src/Platform_MSDOS.c | 5 ++--- src/Platform_MacClassic.c | 4 ++-- src/Platform_Posix.c | 17 +++++++++-------- src/Platform_Symbian.cpp | 4 ++-- src/Platform_Web.c | 4 ++-- src/Platform_Windows.c | 7 ++++--- src/Server.c | 4 ++-- src/Window_Terminal.c | 2 +- src/_PlatformConsole.h | 2 +- src/main.c | 2 +- 15 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/Entity.c b/src/Entity.c index 69b0a3ce7..95a349f0a 100644 --- a/src/Entity.c +++ b/src/Entity.c @@ -1062,12 +1062,12 @@ void LocalPlayers_MoveToSpawn(struct LocationUpdate* update) { } void LocalPlayer_CalcDefaultSpawn(struct LocalPlayer* p, struct LocationUpdate* update) { - float x = (World.Width / 2) + 0.5f; - float z = (World.Length / 2) + 0.5f; + float x = 0;//(World.Width / 2) + 0.5f; + float z = 0;//(World.Length / 2) + 0.5f; update->flags = LU_HAS_POS | LU_HAS_YAW | LU_HAS_PITCH; update->pos = Respawn_FindSpawnPosition(x, z, p->Base.Size); - update->yaw = 0.0f; + update->yaw = 45.0f; update->pitch = 0.0f; } diff --git a/src/Launcher.c b/src/Launcher.c index fde5e8b1b..1b8dfb675 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -117,7 +117,7 @@ cc_bool Launcher_StartGame(const cc_string* user, const cc_string* mppass, const res = Process_StartGame2(args, numArgs); if (res) { Logger_SysWarn(res, "starting game"); return false; } - Launcher_ShouldExit = Platform_SingleProcess || Options_GetBool(LOPT_AUTO_CLOSE, false); + Launcher_ShouldExit = Platform_IsSingleProcess() || Options_GetBool(LOPT_AUTO_CLOSE, false); return true; } diff --git a/src/Platform.h b/src/Platform.h index 372b9c673..d3977b092 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -65,7 +65,11 @@ cc_result Platform_GetEntropy(void* data, int len); *#########################################################################################################################*/ /* Whether the launcher and game must both be run in the same process */ /* (e.g. can't start a separate process on Mobile or Consoles) */ -extern cc_bool Platform_SingleProcess; +#define PLAT_FLAG_SINGLE_PROCESS 0x01 + +/* Platform specific runtime behaviour flags (See PLAT_FLAG members) */ +extern cc_uint8 Platform_Flags; +#define Platform_IsSingleProcess() (Platform_Flags & PLAT_FLAG_SINGLE_PROCESS) /* Starts the game with the given arguments. */ CC_API cc_result Process_StartGame2(const cc_string* args, int numArgs); diff --git a/src/Platform_Amiga.c b/src/Platform_Amiga.c index 9a8f2a2e4..4cc33a583 100644 --- a/src/Platform_Amiga.c +++ b/src/Platform_Amiga.c @@ -26,8 +26,8 @@ const cc_result ReturnCode_SocketWouldBlock = 1000000; const cc_result ReturnCode_SocketDropped = 1000000; const char* Platform_AppNameSuffix = " Amiga"; -cc_bool Platform_ReadonlyFilesystem; -cc_bool Platform_SingleProcess = true; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; +cc_bool Platform_ReadonlyFilesystem; static const char __attribute__((used)) min_stack[] = "$STACK:102400"; diff --git a/src/Platform_Dreamcast.c b/src/Platform_Dreamcast.c index ce5c5e054..1ba30c018 100644 --- a/src/Platform_Dreamcast.c +++ b/src/Platform_Dreamcast.c @@ -236,7 +236,7 @@ static int VMUFile_Do(cc_file* file, int mode) { data = Mem_Alloc(len, 1, "VMU data"); fs_read(fd, data, len); - err = vmu_pkg_parse(data, &pkg); + err = vmu_pkg_parse(data, len, &pkg); fs_close(fd); } diff --git a/src/Platform_MSDOS.c b/src/Platform_MSDOS.c index 3cbf58da0..2e3829e6f 100644 --- a/src/Platform_MSDOS.c +++ b/src/Platform_MSDOS.c @@ -33,9 +33,8 @@ const cc_result ReturnCode_SocketWouldBlock = -10002; const cc_result ReturnCode_SocketDropped = -10002; const char* Platform_AppNameSuffix = " DOS"; -cc_bool Platform_SingleProcess = true; -cc_bool Platform_ReadonlyFilesystem; - +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; +cc_bool Platform_ReadonlyFilesystem; /*########################################################################################################################* *---------------------------------------------------------Memory----------------------------------------------------------* diff --git a/src/Platform_MacClassic.c b/src/Platform_MacClassic.c index af944d97f..8e3d30986 100644 --- a/src/Platform_MacClassic.c +++ b/src/Platform_MacClassic.c @@ -34,8 +34,8 @@ const char* Platform_AppNameSuffix = " MAC 68k"; #else const char* Platform_AppNameSuffix = " MAC PPC"; #endif -cc_bool Platform_ReadonlyFilesystem; -cc_bool Platform_SingleProcess = true; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; +cc_bool Platform_ReadonlyFilesystem; /*########################################################################################################################* diff --git a/src/Platform_Posix.c b/src/Platform_Posix.c index 18f8c469f..58beaf337 100644 --- a/src/Platform_Posix.c +++ b/src/Platform_Posix.c @@ -46,8 +46,13 @@ const char* Platform_AppNameSuffix = " iOS alpha"; #else const char* Platform_AppNameSuffix = ""; #endif -cc_bool Platform_SingleProcess; -cc_bool Platform_ReadonlyFilesystem; + +#ifdef CC_BUILD_MOBILE +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; +#else +cc_uint8 Platform_Flags; +#endif +cc_bool Platform_ReadonlyFilesystem; /* Operating system specific include files */ #if defined CC_BUILD_DARWIN @@ -888,7 +893,8 @@ cc_result Process_StartGame2(const cc_string* args, int numArgs) { int i, j, len = 0; char* argv[15]; cc_result res; - if (Platform_SingleProcess) return SetGameArgs(args, numArgs); + + if (Platform_IsSingleProcess()) return SetGameArgs(args, numArgs); res = Process_RawGetExePath(path, &len); if (res) return res; @@ -1381,7 +1387,6 @@ static void Platform_InitSpecific(void) { } #else static void Platform_InitSpecific(void) { - Platform_SingleProcess = true; /* Always foreground process on iOS */ } #endif @@ -1393,10 +1398,6 @@ void Platform_Init(void) { } #else void Platform_Init(void) { - #ifdef CC_BUILD_MOBILE - Platform_SingleProcess = true; - #endif - Platform_InitPosix(); } #endif diff --git a/src/Platform_Symbian.cpp b/src/Platform_Symbian.cpp index fdda4279c..c4249d842 100644 --- a/src/Platform_Symbian.cpp +++ b/src/Platform_Symbian.cpp @@ -52,8 +52,8 @@ const cc_result ReturnCode_SocketDropped = EPIPE; #define SUPPORTS_GETADDRINFO 1 const char* Platform_AppNameSuffix = ""; -cc_bool Platform_SingleProcess = true; -cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; +cc_bool Platform_ReadonlyFilesystem; /*########################################################################################################################* diff --git a/src/Platform_Web.c b/src/Platform_Web.c index 1554d6aae..76e8cfb55 100644 --- a/src/Platform_Web.c +++ b/src/Platform_Web.c @@ -38,8 +38,8 @@ const cc_result ReturnCode_SocketWouldBlock = _EAGAIN; const cc_result ReturnCode_DirectoryExists = _EEXIST; const char* Platform_AppNameSuffix = ""; -cc_bool Platform_ReadonlyFilesystem; -cc_bool Platform_SingleProcess; +cc_uint8 Platform_Flags; +cc_bool Platform_ReadonlyFilesystem; /*########################################################################################################################* diff --git a/src/Platform_Windows.c b/src/Platform_Windows.c index 732af5495..4f86a1a41 100644 --- a/src/Platform_Windows.c +++ b/src/Platform_Windows.c @@ -38,8 +38,8 @@ const cc_result ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK; const cc_result ReturnCode_SocketDropped = WSAECONNRESET; const char* Platform_AppNameSuffix = ""; -cc_bool Platform_ReadonlyFilesystem; -cc_bool Platform_SingleProcess; +cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags; /*########################################################################################################################* *---------------------------------------------------------Memory----------------------------------------------------------* @@ -762,7 +762,8 @@ cc_result Process_StartGame2(const cc_string* args, int numArgs) { cc_result res; int len, i; - if (Platform_SingleProcess) return SetGameArgs(args, numArgs); + if (Platform_IsSingleProcess()) return SetGameArgs(args, numArgs); + if ((res = Process_RawGetExePath(&path, &len))) return res; si.wide.cb = sizeof(STARTUPINFOW); diff --git a/src/Server.c b/src/Server.c index f6fea3c60..6bbce5fbb 100644 --- a/src/Server.c +++ b/src/Server.c @@ -136,7 +136,7 @@ static void SPConnection_BeginConnect(void) { horSize = 16; verSize = 16; #elif defined CC_BUILD_LOWMEM - horSize = 64; + horSize = 128; verSize = 64; #else horSize = Game_ClassicMode ? 256 : 128; @@ -150,7 +150,7 @@ static void SPConnection_BeginConnect(void) { Gen_Active = &NotchyGen; #endif - Gen_Seed = Random_Next(&rnd, Int32_MaxValue); + Gen_Seed = 6789;;//Random_Next(&rnd, Int32_MaxValue); Gen_Start(); GeneratingScreen_Show(); diff --git a/src/Window_Terminal.c b/src/Window_Terminal.c index 409df0fa8..af370828e 100644 --- a/src/Window_Terminal.c +++ b/src/Window_Terminal.c @@ -419,7 +419,7 @@ void Window_Init(void) { HookTerminal(); UpdateDimensions(); HookSignals(); - Platform_SingleProcess = true; + Platform_Flags |= PLAT_FLAG_SINGLE_PROCESS; } void Window_Free(void) { diff --git a/src/_PlatformConsole.h b/src/_PlatformConsole.h index 46ce5dfe3..d2c7b69ad 100644 --- a/src/_PlatformConsole.h +++ b/src/_PlatformConsole.h @@ -1,4 +1,4 @@ -cc_bool Platform_SingleProcess = true; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; /*########################################################################################################################* diff --git a/src/main.c b/src/main.c index 0c5a63dca..e978de050 100644 --- a/src/main.c +++ b/src/main.c @@ -260,7 +260,7 @@ int main(int argc, char** argv) { /* If single process mode, then the loop is launcher -> game -> launcher etc */ do { res = RunProgram(argc, argv); - } while (Platform_SingleProcess && Window_Main.Exists); + } while (Platform_IsSingleProcess() && Window_Main.Exists); #ifdef CC_BUILD_WEB if (res) Window_Free();