Esempio n. 1
0
void appInit(/*?? const char *_cmdLine */)
{
	guard(appInit);

	// verify type sizes
	staticAssert(sizeof(short)==2, Sizeof_Short_2);
	staticAssert(sizeof(int)==4, Sizeof_Int_4);
	staticAssert(sizeof(int64)==8, Sizeof_Int64_8);
	staticAssert((char)127 > (char)128, Char_Should_Be_Signed);
	staticAssert(sizeof(address_t)==sizeof(void*), Wrong_Address_t_Size);

	appInitPlatform();
	appInitMemory();
	appInitError();
	appLoadDebugSymbols();

//!!	GVersion = PkgVersion;
//!!	RegisterCommand("version", Cmd_Version);
	RegisterCommand("quit", Cmd_Quit);		//?? add "exit" as synonym ("quit" came from Quake, but "exit" from bash etc)

	unguard;
}
Esempio n. 2
0
void appSetRootDirectory2(const char *filename)
{
	char buf[MAX_PACKAGE_PATH], buf2[MAX_PACKAGE_PATH];
	appStrncpyz(buf, filename, ARRAY_COUNT(buf));
	char *s;
	// replace slashes
	for (s = buf; *s; s++)
		if (*s == '\\') *s = '/';
	// cut filename
	s = strrchr(buf, '/');
	*s = 0;
	// make a copy for fallback
	strcpy(buf2, buf);

	FString root;
	int detected = 0;				// weigth; 0 = not detected
	root = buf;

	// analyze path
	const char *pCooked = NULL;
	for (int i = 0; i < 8; i++)
	{
		// find deepest directory name
		s = strrchr(buf, '/');
		if (!s) break;
		*s++ = 0;
		bool found = false;
		if (i == 0)
		{
			for (int j = 0; j < ARRAY_COUNT(KnownDirs2); j++)
				if (!stricmp(KnownDirs2[j], s))
				{
					found = true;
					break;
				}
		}
		if (found)
		{
			if (detected < 1)
			{
				detected = 1;
				root = buf;
			}
		}
		pCooked = appStristr(s, "Cooked");
		if (pCooked || appStristr(s, "Content"))
		{
			s[-1] = '/';			// put it back
			if (detected < 2)
			{
				detected = 2;
				root = buf;
				break;
			}
		}
	}
	appPrintf("Detected game root %s%s", *root, (detected == false) ? " (no recurse)" : "");
	// detect platform
	if (GForcePlatform == PLATFORM_UNKNOWN && pCooked)
	{
		pCooked += 6;	// skip "Cooked" string
		if (!strnicmp(pCooked, "PS3", 3))
			GForcePlatform = PLATFORM_PS3;
		else if (!strnicmp(pCooked, "Xenon", 5))
			GForcePlatform = PLATFORM_XBOX360;
		else if (!strnicmp(pCooked, "IPhone", 6))
			GForcePlatform = PLATFORM_IOS;
		if (GForcePlatform != PLATFORM_UNKNOWN)
		{
			static const char *PlatformNames[] =
			{
				"",
				"PC",
				"XBox360",
				"PS3",
				"iPhone",
				"Android",
			};
			staticAssert(ARRAY_COUNT(PlatformNames) == PLATFORM_COUNT, Verify_PlatformNames);
			appPrintf("; platform %s", PlatformNames[GForcePlatform]);
		}
	}
	// scan root directory
	appPrintf("\n");
	appSetRootDirectory(*root, detected);
}