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) {
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;
}

View File

@ -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;
}

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 */
/* (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);

View File

@ -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";

View File

@ -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);
}

View File

@ -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----------------------------------------------------------*

View File

@ -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;
/*########################################################################################################################*

View File

@ -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

View File

@ -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;
/*########################################################################################################################*

View File

@ -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;
/*########################################################################################################################*

View File

@ -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);

View File

@ -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();

View File

@ -419,7 +419,7 @@ void Window_Init(void) {
HookTerminal();
UpdateDimensions();
HookSignals();
Platform_SingleProcess = true;
Platform_Flags |= PLAT_FLAG_SINGLE_PROCESS;
}
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 */
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();