コード例 #1
0
static void testTeamDefsModelScriptData (void)
{
	int i;
	linkedList_t *armourPaths = NULL;

	for (i = 0; i < csi.numTeamDefs; i++) {
		int j;
		const teamDef_t *teamDef = &csi.teamDef[i];
		if (!teamDef->armour)
			continue;

		for (j = 0; j < csi.numODs; j++) {
			const objDef_t *od = INVSH_GetItemByIDX(j);
			if (!INV_IsArmour(od))
				continue;

			/* not for this team */
			if (!CHRSH_IsArmourUseableForTeam(od, teamDef))
				continue;

			if (!LIST_ContainsString(armourPaths, od->armourPath))
				LIST_AddString(&armourPaths, od->armourPath);
		}

		UFO_CU_ASSERT_TRUE_MSG(!LIST_IsEmpty(armourPaths), va("no armour definitions found for team %s - but armour is set to true",
				teamDef->id));

		LIST_Foreach(armourPaths, char const, armourPath) {
			int l;

			for (l = NAME_NEUTRAL; l < NAME_LAST; l++) {
				/* no models for this gender */
				if (!teamDef->numModels[l])
					continue;

				CU_ASSERT_PTR_NOT_NULL_FATAL(teamDef->models[l]);

				for (linkedList_t const* list = teamDef->models[l]; list; list = list->next) {
					teamDef_t::model_t const& m = *static_cast<teamDef_t::model_t const*>(list->data);

					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckModel(va("%s/%s", m.path, m.body)), va("%s does not exist in models/%s (teamDef: %s)",
							m.body, m.path, teamDef->id));
					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckModel(va("%s%s/%s", m.path, armourPath, m.body)), va("%s does not exist in models/%s%s (teamDef: %s)",
							m.body, m.path, armourPath, teamDef->id));

					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckModel(va("%s/%s", m.path, m.head)), va("%s does not exist in models/%s (teamDef: %s)",
							m.head, m.path, teamDef->id));
					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckModel(va("%s%s/%s", m.path, armourPath, m.head)), va("%s does not exist in models/%s%s (teamDef: %s)",
							m.head, m.path, armourPath, teamDef->id));
				}
			}
		}

		LIST_Delete(&armourPaths);
	}
コード例 #2
0
ファイル: test_rma.cpp プロジェクト: MyWifeRules/ufoai-1
/**
 * @brief test the maps that have problems with certain seeds
 * this can also be used to produce new seedlists
 */
static void testNewSeedlists (void)
{
	int i;
	long time, timeSum = 0;
	mapInfo_t *randomMap;

	sv_threads->integer = 0;
	for (i = 0; i < 50; i++) {
		srand(i);
		time = Sys_Milliseconds();
		Com_Printf("Seed: %i\n", i);
		Cvar_Set("rm_drop", Com_GetRandomMapAssemblyNameForCraft("craft_drop_herakles"));
		Cvar_Set("rm_ufo", Com_GetRandomMapAssemblyNameForCraft("craft_ufo_fighter"));
		randomMap = SV_AssembleMap("mm_harbour", "mini", mapStr, posStr, i);
#if 0
		randomMap = SV_AssembleMap("forest", "large", mapStr, posStr, i);
#endif
		CU_ASSERT(randomMap != NULL);
		time = Sys_Milliseconds() - time;
		timeSum += time;
		UFO_CU_ASSERT_TRUE_MSG(time < MAX_ALLOWED_TIME_TO_ASSEMBLE,
				va("%s fails to assemble in a reasonable time with seed %i (time: %li ms)", randomMap->name, i, time));
		if (time > 10000)
			Com_Printf("Seed %i: tiles: %i ms: %li\n", i, randomMap->numPlaced, time);
		Mem_Free(randomMap);
	}
	Com_Printf("TotalTime: %li\n", timeSum);
}
コード例 #3
0
static void testVisFlags (void)
{
	const char *mapName = "test_game";
	if (FS_CheckFile("maps/%s.bsp", mapName) != -1) {
		edict_t *ent;
		int num;

		/* the other tests didn't call the server shutdown function to clean up */
		OBJZERO(*sv);
		SV_Map(true, mapName, NULL);

		num = 0;
		ent = NULL;
		while ((ent = G_EdictsGetNextLivingActorOfTeam(ent, TEAM_ALIEN))) {
			const teammask_t teamMask = G_TeamToVisMask(ent->team);
			const bool visible = ent->visflags & teamMask;
			char *visFlagsBuf = Mem_StrDup(Com_UnsignedIntToBinary(ent->visflags));
			char *teamMaskBuf = Mem_StrDup(Com_UnsignedIntToBinary(teamMask));
			CU_ASSERT_EQUAL(ent->team, TEAM_ALIEN);
			UFO_CU_ASSERT_TRUE_MSG(visible, va("visflags: %s, teamMask: %s", visFlagsBuf, teamMaskBuf));
			Mem_Free(visFlagsBuf);
			Mem_Free(teamMaskBuf);
			num++;
		}

		SV_ShutdownGameProgs();
		CU_ASSERT_TRUE(num > 0);
	} else {
		UFO_CU_FAIL_MSG(va("Map resource '%s.bsp' for test is missing.", mapName));
	}
}
コード例 #4
0
/**
 * @brief test the maps that have problems with certain seeds
 * this can also be used to produce new seedlists
 */
static void testNewSeedlists (void)
{
    int i;
    long time, timeSum = 0;
    MapInfo *randomMap;
    char entityString[MAX_TOKEN_CHARS];

    sv_threads->integer = 0;
    for (i = 0; i < RMA_HIGHEST_SUPPORTED_SEED; i++) {
        srand(i);
        time = Sys_Milliseconds();
        Com_Printf("Seed: %i\n", i);
        Cvar_Set("rm_drop", Com_GetRandomMapAssemblyNameForCraft("craft_drop_herakles"));
        Cvar_Set("rm_ufo", Com_GetRandomMapAssemblyNameForCraft("craft_ufo_fighter"));
        randomMap = SV_AssembleMap("village", "medium", mapStr, posStr, entityString, i);
#if 0
        randomMap = SV_AssembleMap("village", "medium_noufo", mapStr, posStr, entityString, i);
        randomMap = SV_AssembleMap("village", "small", mapStr, posStr, entityString, i);
        randomMap = SV_AssembleMap("frozen", "nature_medium", mapStr, posStr, entityString, i);
        randomMap = SV_AssembleMap("forest", "large", mapStr, posStr, entityString, i);
#endif
        CU_ASSERT(randomMap != NULL);
        time = Sys_Milliseconds() - time;
        timeSum += time;
        UFO_CU_ASSERT_TRUE_MSG(time < MAX_ALLOWED_TIME_TO_ASSEMBLE,
                               va("%s fails to assemble in a reasonable time with seed %i (time: %li ms)", randomMap->name, i, time));
        if (time > 10000)
            Com_Printf("Seed %i: tiles: %i ms: %li\n", i, randomMap->numPlaced, time);
        Mem_Free(randomMap);
    }
    Com_Printf("TotalTime: %li\n", timeSum);
}
コード例 #5
0
static void testTeamDefs (void)
{
	int i;

	for (i = 0; i < csi.numTeamDefs; i++) {
		const teamDef_t *teamDef = &csi.teamDef[i];
		int k;

		UFO_CU_ASSERT_TRUE_MSG(teamDef->numTemplates > 0, va("%s has no character templates assigned", teamDef->id));

		for (k = 0; k < SND_MAX; k++) {
			int l;
			for (l = 0; l < NAME_LAST; l++) {
				LIST_Foreach(teamDef->sounds[k][l], char, soundFile) {
					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckSound(soundFile), va("sound %s does not exist (team %s)", soundFile, teamDef->id));
				}
			}
		}
	}
}
コード例 #6
0
ファイル: test_rma.cpp プロジェクト: MyWifeRules/ufoai-1
/* sequential version */
static void testMassAssemblySequential (void)
{
	int i;
	long time;
	mapInfo_t *randomMap;

	sv_threads->integer = 0;
	for (i = 0; i < 10; i++) {
		srand(i);
		time = Sys_Milliseconds();
		randomMap = SV_AssembleMap("forest", "large", mapStr, posStr, i);
		CU_ASSERT_PTR_NOT_NULL(randomMap);
		time = Sys_Milliseconds() - time;
		UFO_CU_ASSERT_TRUE_MSG(time < MAX_ALLOWED_TIME_TO_ASSEMBLE,
				va("%s fails to assemble in a reasonable time with seed %i (time: %li ms)", randomMap->name, i, time));
		Com_Printf("%i: %i %li\n", i, randomMap->numPlaced, time);
		Mem_Free(randomMap);
	}
}
コード例 #7
0
ファイル: test_rma.cpp プロジェクト: MyWifeRules/ufoai-1
static void testMassAssemblyParallel (void)
{
	int i;
	long time;
	mapInfo_t *randomMap;

	sv_threads->integer = 2;
	for (i = 0; i < 10; i++) {
		/** @todo the assemble thread sets a different seed */
		srand(i);
		time = Sys_Milliseconds();
		randomMap = SV_AssembleMap("forest", "large", mapStr, posStr, i);
		CU_ASSERT(randomMap != NULL);
		time = Sys_Milliseconds() - time;
		UFO_CU_ASSERT_TRUE_MSG(time < MAX_ALLOWED_TIME_TO_ASSEMBLE,
				va("%s fails to assemble in a reasonable time with seed %i (time: %li ms)", randomMap->name, i, time));
		Com_Printf("%i: %i %li\n", i, randomMap->numPlaced, time); fflush(stdout);
		Mem_Free(randomMap);
	}
}
コード例 #8
0
/* test the maps that have seedlists */
static void testSeedlists (void)
{
    int i, n;
    long time, timeSum = 0;
    MapInfo *randomMap;
    size_t length;
    const char* assNames[][2] = {
        {"farm", "medium"},
        {"farm", "large"},
        {"forest", "large"},
        {"forest", "large_crash"},
        {"oriental", "large"},
        {"village", "commercial"},
        {"village", "small"}
    };
    length = sizeof(assNames) / (2 * sizeof(char *));
    char entityString[MAX_TOKEN_CHARS];

    sv_threads->integer = 0;
    for (n = 0; n < length; n++) {
        for (i = 1; i < 20; i++) {
            srand(i);
            time = Sys_Milliseconds();
            Com_Printf("Seed: %i\n", i);
            randomMap = SV_AssembleMap(assNames[n][0], assNames[n][1], mapStr, posStr, entityString, i);
            CU_ASSERT(randomMap != NULL);
            time = Sys_Milliseconds() - time;
            timeSum += time;
            UFO_CU_ASSERT_TRUE_MSG(time < MAX_ALLOWED_TIME_TO_ASSEMBLE,
                                   va("%s fails to assemble in a reasonable time with seed %i (time: %li ms)", randomMap->name, i, time));
            if (time > 10000)
                Com_Printf("Seed %i: tiles: %i ms: %li\n", i, randomMap->numPlaced, time);
            Mem_Free(randomMap);
        }
    }
    Com_Printf("TotalTime: %li\n", timeSum);
}
コード例 #9
0
static void testTeamDefsModelScriptData (void)
{
	int i;
	linkedList_t *armourPaths = NULL;

	for (i = 0; i < csi.numTeamDefs; i++) {
		int j;
		const teamDef_t *teamDef = &csi.teamDef[i];
		if (!teamDef->armour)
			continue;

		for (j = 0; j < csi.numODs; j++) {
			const objDef_t *od = INVSH_GetItemByIDX(j);
			if (!INV_IsArmour(od))
				continue;

			/* not for this team */
			if (!CHRSH_IsArmourUseableForTeam(od, teamDef))
				continue;

			if (!LIST_ContainsString(armourPaths, od->armourPath))
				LIST_AddString(&armourPaths, od->armourPath);
		}

		UFO_CU_ASSERT_TRUE_MSG(!LIST_IsEmpty(armourPaths), va("no armour definitions found for team %s - but armour is set to true",
				teamDef->id));

		LIST_Foreach(armourPaths, char const, armourPath) {
			nametypes_t l;

			for (l = NAME_NEUTRAL; l < NAME_LAST; l++) {
				linkedList_t *list = teamDef->models[l];
				int k;

				/* no models for this gender */
				if (!teamDef->numModels[l])
					continue;

				CU_ASSERT_PTR_NOT_NULL(list);
				for (k = 0; k < teamDef->numModels[l]; k++) {
					const char *path;

					CU_ASSERT_PTR_NOT_NULL_FATAL(list);
					path = (const char*)list->data;
					/* body */
					list = list->next;
					CU_ASSERT_PTR_NOT_NULL_FATAL(list);
					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckModel(va("%s/%s", path, list->data)), va("%s does not exist in models/%s (teamDef: %s)",
							list->data, path, teamDef->id));
					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckModel(va("%s%s/%s", path, armourPath, list->data)), va("%s does not exist in models/%s%s (teamDef: %s)",
							list->data, path, armourPath, teamDef->id));

					list = list->next;
					CU_ASSERT_PTR_NOT_NULL_FATAL(list);
					/* head */
					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckModel(va("%s/%s", path, list->data)), va("%s does not exist in models/%s (teamDef: %s)",
							list->data, path, teamDef->id));
					UFO_CU_ASSERT_TRUE_MSG(TEST_CheckModel(va("%s%s/%s", path, armourPath, list->data)), va("%s does not exist in models/%s%s (teamDef: %s)",
							list->data, path, armourPath, teamDef->id));

					/* skip skin */
					/** @todo check that the skin is valid for the given model */
					list = list->next;
					CU_ASSERT_PTR_NOT_NULL_FATAL(list);

					/* new path */
					list = list->next;
				}
			}
		}

		LIST_Delete(&armourPaths);
	}