Move towards platform behaviour flags

This commit is contained in:
UnknownShadow200 2025-06-01 11:09:39 +10:00
parent cecb4bc1b5
commit ac5a185d1b
15 changed files with 38 additions and 33 deletions

View File

@ -1062,12 +1062,12 @@ void LocalPlayers_MoveToSpawn(struct LocationUpdate* update) {
} }
void LocalPlayer_CalcDefaultSpawn(struct LocalPlayer* p, struct LocationUpdate* update) { void LocalPlayer_CalcDefaultSpawn(struct LocalPlayer* p, struct LocationUpdate* update) {
float x = (World.Width / 2) + 0.5f; float x = 0;//(World.Width / 2) + 0.5f;
float z = (World.Length / 2) + 0.5f; float z = 0;//(World.Length / 2) + 0.5f;
update->flags = LU_HAS_POS | LU_HAS_YAW | LU_HAS_PITCH; update->flags = LU_HAS_POS | LU_HAS_YAW | LU_HAS_PITCH;
update->pos = Respawn_FindSpawnPosition(x, z, p->Base.Size); update->pos = Respawn_FindSpawnPosition(x, z, p->Base.Size);
update->yaw = 0.0f; update->yaw = 45.0f;
update->pitch = 0.0f; update->pitch = 0.0f;
} }

View File

@ -117,7 +117,7 @@ cc_bool Launcher_StartGame(const cc_string* user, const cc_string* mppass, const
res = Process_StartGame2(args, numArgs); res = Process_StartGame2(args, numArgs);
if (res) { Logger_SysWarn(res, "starting game"); return false; } 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; return true;
} }

View File

@ -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 */ /* 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) */ /* (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. */ /* Starts the game with the given arguments. */
CC_API cc_result Process_StartGame2(const cc_string* args, int numArgs); CC_API cc_result Process_StartGame2(const cc_string* args, int numArgs);

View File

@ -26,8 +26,8 @@ const cc_result ReturnCode_SocketWouldBlock = 1000000;
const cc_result ReturnCode_SocketDropped = 1000000; const cc_result ReturnCode_SocketDropped = 1000000;
const char* Platform_AppNameSuffix = " Amiga"; const char* Platform_AppNameSuffix = " Amiga";
cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS;
cc_bool Platform_ReadonlyFilesystem; cc_bool Platform_ReadonlyFilesystem;
cc_bool Platform_SingleProcess = true;
static const char __attribute__((used)) min_stack[] = "$STACK:102400"; static const char __attribute__((used)) min_stack[] = "$STACK:102400";

View File

@ -236,7 +236,7 @@ static int VMUFile_Do(cc_file* file, int mode) {
data = Mem_Alloc(len, 1, "VMU data"); data = Mem_Alloc(len, 1, "VMU data");
fs_read(fd, data, len); fs_read(fd, data, len);
err = vmu_pkg_parse(data, &pkg); err = vmu_pkg_parse(data, len, &pkg);
fs_close(fd); fs_close(fd);
} }

View File

@ -33,10 +33,9 @@ const cc_result ReturnCode_SocketWouldBlock = -10002;
const cc_result ReturnCode_SocketDropped = -10002; const cc_result ReturnCode_SocketDropped = -10002;
const char* Platform_AppNameSuffix = " DOS"; const char* Platform_AppNameSuffix = " DOS";
cc_bool Platform_SingleProcess = true; cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS;
cc_bool Platform_ReadonlyFilesystem; cc_bool Platform_ReadonlyFilesystem;
/*########################################################################################################################* /*########################################################################################################################*
*---------------------------------------------------------Memory----------------------------------------------------------* *---------------------------------------------------------Memory----------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/

View File

@ -34,8 +34,8 @@ const char* Platform_AppNameSuffix = " MAC 68k";
#else #else
const char* Platform_AppNameSuffix = " MAC PPC"; const char* Platform_AppNameSuffix = " MAC PPC";
#endif #endif
cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS;
cc_bool Platform_ReadonlyFilesystem; cc_bool Platform_ReadonlyFilesystem;
cc_bool Platform_SingleProcess = true;
/*########################################################################################################################* /*########################################################################################################################*

View File

@ -46,7 +46,12 @@ const char* Platform_AppNameSuffix = " iOS alpha";
#else #else
const char* Platform_AppNameSuffix = ""; const char* Platform_AppNameSuffix = "";
#endif #endif
cc_bool Platform_SingleProcess;
#ifdef CC_BUILD_MOBILE
cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS;
#else
cc_uint8 Platform_Flags;
#endif
cc_bool Platform_ReadonlyFilesystem; cc_bool Platform_ReadonlyFilesystem;
/* Operating system specific include files */ /* Operating system specific include files */
@ -888,7 +893,8 @@ cc_result Process_StartGame2(const cc_string* args, int numArgs) {
int i, j, len = 0; int i, j, len = 0;
char* argv[15]; char* argv[15];
cc_result res; cc_result res;
if (Platform_SingleProcess) return SetGameArgs(args, numArgs);
if (Platform_IsSingleProcess()) return SetGameArgs(args, numArgs);
res = Process_RawGetExePath(path, &len); res = Process_RawGetExePath(path, &len);
if (res) return res; if (res) return res;
@ -1381,7 +1387,6 @@ static void Platform_InitSpecific(void) {
} }
#else #else
static void Platform_InitSpecific(void) { static void Platform_InitSpecific(void) {
Platform_SingleProcess = true;
/* Always foreground process on iOS */ /* Always foreground process on iOS */
} }
#endif #endif
@ -1393,10 +1398,6 @@ void Platform_Init(void) {
} }
#else #else
void Platform_Init(void) { void Platform_Init(void) {
#ifdef CC_BUILD_MOBILE
Platform_SingleProcess = true;
#endif
Platform_InitPosix(); Platform_InitPosix();
} }
#endif #endif

View File

@ -52,7 +52,7 @@ const cc_result ReturnCode_SocketDropped = EPIPE;
#define SUPPORTS_GETADDRINFO 1 #define SUPPORTS_GETADDRINFO 1
const char* Platform_AppNameSuffix = ""; const char* Platform_AppNameSuffix = "";
cc_bool Platform_SingleProcess = true; cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS;
cc_bool Platform_ReadonlyFilesystem; cc_bool Platform_ReadonlyFilesystem;

View File

@ -38,8 +38,8 @@ const cc_result ReturnCode_SocketWouldBlock = _EAGAIN;
const cc_result ReturnCode_DirectoryExists = _EEXIST; const cc_result ReturnCode_DirectoryExists = _EEXIST;
const char* Platform_AppNameSuffix = ""; const char* Platform_AppNameSuffix = "";
cc_uint8 Platform_Flags;
cc_bool Platform_ReadonlyFilesystem; cc_bool Platform_ReadonlyFilesystem;
cc_bool Platform_SingleProcess;
/*########################################################################################################################* /*########################################################################################################################*

View File

@ -39,7 +39,7 @@ const cc_result ReturnCode_SocketDropped = WSAECONNRESET;
const char* Platform_AppNameSuffix = ""; const char* Platform_AppNameSuffix = "";
cc_bool Platform_ReadonlyFilesystem; cc_bool Platform_ReadonlyFilesystem;
cc_bool Platform_SingleProcess; cc_uint8 Platform_Flags;
/*########################################################################################################################* /*########################################################################################################################*
*---------------------------------------------------------Memory----------------------------------------------------------* *---------------------------------------------------------Memory----------------------------------------------------------*
@ -762,7 +762,8 @@ cc_result Process_StartGame2(const cc_string* args, int numArgs) {
cc_result res; cc_result res;
int len, i; 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; if ((res = Process_RawGetExePath(&path, &len))) return res;
si.wide.cb = sizeof(STARTUPINFOW); si.wide.cb = sizeof(STARTUPINFOW);

View File

@ -136,7 +136,7 @@ static void SPConnection_BeginConnect(void) {
horSize = 16; horSize = 16;
verSize = 16; verSize = 16;
#elif defined CC_BUILD_LOWMEM #elif defined CC_BUILD_LOWMEM
horSize = 64; horSize = 128;
verSize = 64; verSize = 64;
#else #else
horSize = Game_ClassicMode ? 256 : 128; horSize = Game_ClassicMode ? 256 : 128;
@ -150,7 +150,7 @@ static void SPConnection_BeginConnect(void) {
Gen_Active = &NotchyGen; Gen_Active = &NotchyGen;
#endif #endif
Gen_Seed = Random_Next(&rnd, Int32_MaxValue); Gen_Seed = 6789;;//Random_Next(&rnd, Int32_MaxValue);
Gen_Start(); Gen_Start();
GeneratingScreen_Show(); GeneratingScreen_Show();

View File

@ -419,7 +419,7 @@ void Window_Init(void) {
HookTerminal(); HookTerminal();
UpdateDimensions(); UpdateDimensions();
HookSignals(); HookSignals();
Platform_SingleProcess = true; Platform_Flags |= PLAT_FLAG_SINGLE_PROCESS;
} }
void Window_Free(void) { void Window_Free(void) {

View File

@ -1,4 +1,4 @@
cc_bool Platform_SingleProcess = true; cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS;
/*########################################################################################################################* /*########################################################################################################################*

View File

@ -260,7 +260,7 @@ int main(int argc, char** argv) {
/* If single process mode, then the loop is launcher -> game -> launcher etc */ /* If single process mode, then the loop is launcher -> game -> launcher etc */
do { do {
res = RunProgram(argc, argv); res = RunProgram(argc, argv);
} while (Platform_SingleProcess && Window_Main.Exists); } while (Platform_IsSingleProcess() && Window_Main.Exists);
#ifdef CC_BUILD_WEB #ifdef CC_BUILD_WEB
if (res) Window_Free(); if (res) Window_Free();