S3E_MAIN_DECL void IwMain() { srand(time(NULL)); GameManager *mgr; mgr = new GameManager(); mgr->SetRequestedFPS(100); mgr->GetResourceManager()->RegisterResourceGroup("images.group"); BUG_HANDLE = mgr->GetResourceManager()->RegisterImage("bug"); SPLAT_HANDLE = mgr->GetResourceManager()->RegisterImage("splat"); LEAVES_HANDLE = mgr->GetResourceManager()->RegisterImage("leaves"); ARROW_HANDLE = mgr->GetResourceManager()->RegisterImage("right_arrow"); FIRE_HANDLE = mgr->GetResourceManager()->RegisterImage("FireBlast"); TREB_FONT_HANDLE = mgr->GetResourceManager()->RegisterFont("trebuchet16pt"); COOPER_FONT_HANDLE = mgr->GetResourceManager()->RegisterFont("cooper_24pt"); GameManager::SetDebugFont(mgr->GetResourceManager()->GetFont(TREB_FONT_HANDLE)); Iw2DSetFont(mgr->GetResourceManager()->GetFont(TREB_FONT_HANDLE)); Sprite *background = new Sprite(mgr); background->SetImage(mgr->GetResourceManager()->GetImage(LEAVES_HANDLE)); background->SetBaseLocation(CIwVec2(0, 0)); background->SetZIndex(-999); mgr->RegisterGameObject(background); int width = mgr->GetSurfaceWidth(); int height = mgr->GetSurfaceHeight(); #define SIMPLE_TEST 0 #define MANY_SHIP_TEST 1 #define ORBITER_TEST 2 #define ANIMATION_TEST 3 #define LABELED_SPRITE 4 #define PATH_TEST 5 int test_selection = SIMPLE_TEST; switch(test_selection) { case SIMPLE_TEST: DoSimpleTest(mgr, ARROW_HANDLE, width, height); break; case MANY_SHIP_TEST: DoManyShipTest(mgr, 10, 10, width, height, ARROW_HANDLE); break; case ORBITER_TEST: MakeOrbiters(mgr, width / 2, height / 2, ARROW_HANDLE); break; case ANIMATION_TEST: AnimationTest(mgr, 0, width, height); break; case LABELED_SPRITE: LabeledSprite(mgr, 0, width, height); break; case PATH_TEST: PathTest(mgr, ARROW_HANDLE, width, height); break; } mgr->MainLoop(); delete mgr; }
int ExecTest ( CDirectory* pDir, Test * pTest, TestVariant * pTestVariant ) { char *p = NULL; char full[MAX_PATH]; DWORD millisecTimeout = DEFAULT_TEST_TIMEOUT; const char *strTimeout = pTestVariant->testInfo.data[TIK_TIMEOUT]; if (strTimeout) { char *end; _set_errno(0); uint32 secTimeout = strtoul(strTimeout, &end, 10); millisecTimeout = 1000 * secTimeout; // Validation has already occurred so this string should // parse fine and the value shouldn't overflow the DWORD. ASSERT(errno == 0 && *end == 0); ASSERT(millisecTimeout > secTimeout); } // Check to see if all of the files exist. for (StringList * pFile = pTest->files; pFile != NULL; pFile = pFile->next) { // Get a pointer to the filename sans path, if present. p = GetFilenamePtr(pFile->string); // If we have no pathname, use the current directory. if (p == pFile->string) { sprintf_s(full, "%s\\", pDir->GetFullPathFromSourceOrDirectory()); } else { // Look for %REGRESS% specifier. if (!_strnicmp(pFile->string, "%REGRESS%", strlen("%REGRESS%"))) { // Temporarily truncate the filename. ASSERT(p[-1] == '\\'); p[-1] = '\0'; sprintf_s(full, "%s%s\\", REGRESS, pFile->string + strlen("%REGRESS%")); p[-1] = '\\'; } else { *p = '\0'; } } strcat_s(full, p); if (GetFileAttributes(full) == INVALID_FILE_ATTRIBUTES) { LogError("ERROR: '%s' does not exist", full); return -1; } } const char* ext = GetFilenameExt(p); // Special case dotest.cmd if (!_stricmp(p, "dotest.cmd")) { // We don't handle these yet. ASSERTNR(pTestVariant->testInfo.data[TIK_LINK_FLAGS] == NULL); if (IsPogoTest(pTest)) return DoPogoExternalTest(pDir, pTestVariant, full, TK_CMDSCRIPT, TRUE, millisecTimeout); else return DoExternalTest(pDir, pTestVariant, full, TK_CMDSCRIPT, TRUE, millisecTimeout); } // Special case for standardized RL makefiles. else if (!_stricmp(p, "rl.mak")) { // We don't handle these yet. ASSERTNR(pTestVariant->testInfo.data[TIK_LINK_FLAGS] == NULL); if (IsPogoTest(pTest)) return DoPogoExternalTest(pDir, pTestVariant, full, TK_MAKEFILE, FALSE, millisecTimeout); else return DoExternalTest(pDir, pTestVariant, full, TK_MAKEFILE, SuppressNoGPF(pTest), millisecTimeout); } // Special case for files ending with ".js", ".html", ".htm" (<command> dealt with separately) else if (pTestVariant->testInfo.data[TIK_COMMAND] == NULL && !_stricmp(ext, ".js")) { return DoExternalTest(pDir, pTestVariant, full, TK_JSCRIPT, FALSE, millisecTimeout); } else if (pTestVariant->testInfo.data[TIK_COMMAND] == NULL && (!_stricmp(ext, ".html") || !_stricmp(ext, ".htm"))) { return DoExternalTest(pDir, pTestVariant, full, TK_HTML, FALSE, millisecTimeout); } // Special case for tests with a <command> argument else if (pTestVariant->testInfo.data[TIK_COMMAND] != NULL) { return DoExternalTest(pDir, pTestVariant, full, TK_COMMAND, FALSE, millisecTimeout); } // Non-scripted test. else { if (IsPogoTest(pTest)) { // We don't handle these yet. ASSERTNR(pTestVariant->testInfo.data[TIK_LINK_FLAGS] == NULL); return DoPogoSimpleTest(pDir, pTest, pTestVariant, FALSE, millisecTimeout); } else { return DoSimpleTest(pDir, pTest, pTestVariant, SuppressNoGPF(pTest), millisecTimeout); } } }