Esempio n. 1
0
/**
 * @brief test the maps that have problems with certain seeds
 * this can also be used to produce new seedlists
 */
TEST_F(RandomMapAssemblyTest, NewSeedlists)
{
	long time, timeSum = 0;
	char entityString[MAX_TOKEN_CHARS];

	sv_rmadisplaythemap->integer = 1;	/* print out the RMA analysis */
	sv_threads->integer = 0;
	for (int 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"));
		const char* mapTheme = "industrial";
		const char* asmName = "medium";
#if 0
		mapTheme = "tropic"; asmName = "river";
		mapTheme = "village"; asmName = "large";
		mapTheme = "desert"; asmName = "large";
#endif
		int numPlaced = SV_AssembleMap(mapTheme, asmName, mapStr, posStr, entityString, i, false);
		ASSERT_TRUE(numPlaced != 0);
		time = Sys_Milliseconds() - time;
		timeSum += time;
		ASSERT_TRUE(time < MAX_ALLOWED_TIME_TO_ASSEMBLE) << mapTheme << " fails to assemble in a reasonable time with seed " << i << "(time: " << time << " ms)";
		if (time > 10000)
			Com_Printf("Seed %i: tiles: %i ms: %li\n", i, numPlaced, time);
	}
	Com_Printf("TotalTime: %li\n", timeSum);
}
Esempio n. 2
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_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);
}
Esempio n. 3
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);
}
Esempio n. 4
0
static void GAME_InitMenuOptions (void)
{
	int i;
	uiNode_t* ufoOptions = NULL;
	uiNode_t* aircraftOptions = NULL;

	for (i = 0; i < UFO_MAX; i++) {
		const char *shortName = Com_UFOTypeToShortName(i);
		UI_AddOption(&ufoOptions, shortName, shortName, Com_GetRandomMapAssemblyNameForCraft(shortName));
	}
	for (i = 0; i < UFO_MAX; i++) {
		const char *shortName = Com_UFOCrashedTypeToShortName(i);
		UI_AddOption(&ufoOptions, shortName, shortName, Com_GetRandomMapAssemblyNameForCraft(shortName));
	}
	UI_RegisterOption(OPTION_UFOS, ufoOptions);

	for (i = 0; i < DROPSHIP_MAX; i++) {
		const char *shortName = Com_DropShipTypeToShortName(i);
		UI_AddOption(&aircraftOptions, shortName, shortName, Com_GetRandomMapAssemblyNameForCraft(shortName));
	}
	UI_RegisterOption(OPTION_DROPSHIPS, aircraftOptions);
}
Esempio n. 5
0
/**
 * @brief Hide the ufo selection or show it with the ufos given in the parameter
 * @param ufos if @c NULL, the ufo selection panel will be hidden, otherwise it
 * will be shown with the given list entries as content.
 */
static inline void GAME_SK_HideUFOs (const linkedList_t *ufos)
{
	const qboolean hide = (ufos == NULL);
	if (hide) {
		UI_ExecuteConfunc("skirmish_hide_ufos true");
		Cvar_Set("rm_ufo", "");
	} else {
		const char *rma = Com_GetRandomMapAssemblyNameForCraft((const char *)ufos->data);
		Cvar_Set("rm_ufo", rma);
		UI_UpdateInvisOptions(UI_GetOption(OPTION_UFOS), ufos);

		UI_ExecuteConfunc("skirmish_hide_ufos false");
	}
}
Esempio n. 6
0
/**
 * @brief Hide the dropship selection or show it with the dropship given in the parameter
 * @param dropships if @c NULL, the dropship selection panel will be hidden, otherwise it
 * will be shown with the given list entries as content.
 */
static inline void GAME_SK_HideDropships (const linkedList_t *dropships)
{
	const qboolean hide = (dropships == NULL);
	if (hide) {
		UI_ExecuteConfunc("skirmish_hide_dropships true");
		Cvar_Set("rm_drop", "");
	} else {
		const char *rma = Com_GetRandomMapAssemblyNameForCraft((const char *)dropships->data);
		Cvar_Set("rm_drop", rma);
		UI_UpdateInvisOptions(UI_GetOption(OPTION_DROPSHIPS), dropships);

		UI_ExecuteConfunc("skirmish_hide_dropships false");
	}
}
Esempio n. 7
0
void GameTest::testCountSpawnpointsForMapWithAssemblyAndAircraft(bool verbose, const mapDef_t *md, const char *asmName, const char *aircraft)
{
	if (verbose && aircraft) {
		std::cout << "[          ] adding test parameter: aircraft " << aircraft << std::endl;
		Com_Printf("CountSpawnpoints - adding test parameter: aircraft %s\n", aircraft);
	}

	/* Check if we are manually testing a certain UFO type. */
	if (TEST_ExistsProperty("ufo")) {
		const char *ufo = TEST_GetStringProperty("ufo");
		int tested = 0;
		LIST_Foreach(md->ufos, const char, s) {
			if (Q_streq(ufo, s)) {
				Cvar_Set("rm_ufo", "%s", Com_GetRandomMapAssemblyNameForCraft(ufo));
				testCountSpawnpointsForMapWithAssemblyAndAircraftAndUfo(verbose, md, asmName, aircraft, ufo);
				tested += 1;
			}
		}
		if (tested < 1) {
			Com_Printf("CountSpawnpoints - error: Not a valid UFO id: %s\n", ufo);
			ADD_FAILURE() << "Error: Not a valid ufo id: " << ufo;
		}
	} else if (LIST_IsEmpty(md->ufos)) {
Esempio n. 8
0
/**
 * @brief This test cycles through the list of map definitions found in the maps.ufo script
 * and builds each map with each ufo and every assembly for all valid seeds.
 * In other words: this a FULL test to check if some seed causes problems in any of the
 * possible combinations, so it should not be run on the buildserver on a daily basis.
 */
TEST_F(MapDefMassRMATest, DISABLED_MapDefsMassRMA)
{
	/** You can test a certain assembly by passing "-Dmapdef-id=assembly" to testall. */
	const char* filterId = TEST_GetStringProperty("mapdef-id");
	const mapDef_t* md;
	int mapCount = 0;

	ASSERT_TRUE(csi.numMDs > 0);

	MapDef_Foreach(md) {
		if (md->mapTheme[0] == '.')
			continue;
		if (filterId && !Q_streq(filterId, md->id))
			continue;
		if (++mapCount <= 0)		/* change 0 to n to skip the first n assemblies */
			continue;

		{
			char* p = md->mapTheme;

			if (*p == '+')
				p++;
			else
				continue;

			const char* asmName = (const char*)LIST_GetByIdx(md->params, 0);
			Com_Printf("\nMap: %s Assembly: %s AssNr: %i\n", p, asmName, mapCount);

			sv_threads->integer = 0;

			/* This is tricky. Some maps don't have any ufo on them and thus in the mapdef.
			 * That would cause a LIST_Foreach macro to never run it's body. That's why these
			 * for-loops seem to have two termination conditions. In fact, we have to manually
			 * exit the for-loops if we ran it just once (without ufos nor dropships).
			 */
			bool didItOnce = false;
			linkedList_t* iterDrop;
			for (iterDrop = md->aircraft; iterDrop || !didItOnce; iterDrop = iterDrop->next) {
				const char* craft = nullptr;
				if (iterDrop)
					craft = (const char*) (iterDrop->data);

				if (craft)
					Cvar_Set("rm_drop", "%s", Com_GetRandomMapAssemblyNameForCraft(craft));
				else
					Cvar_Set("rm_drop", "+craft_drop_firebird");

				linkedList_t* iterUfo;
				for (iterUfo = md->ufos; iterUfo || !didItOnce; iterUfo = iterUfo->next) {
					const char* ufo = nullptr;
					if (iterUfo)
						ufo = (const char*) (iterUfo->data);
					if (ufo)
						Cvar_Set("rm_ufo", "%s", Com_GetRandomMapAssemblyNameForCraft(ufo));
					else
						Cvar_Set("rm_ufo", "+craft_ufo_scout");

					Com_Printf("\nDrop: %s Ufo: %s", craft, ufo);
					Com_Printf("\nSeed:");
					for (int i = 0; i < RMA_HIGHEST_SUPPORTED_SEED; i++) {
						asmName = nullptr;
						srand(i);
						long time = Sys_Milliseconds();
						Com_Printf(" %i", i);
#if 0

						typedef struct skip_info {
							int         seed;
							char const* map;
							char const* params;
							char const* craft;
							char const* ufo;
						} skip_info;
						/* if we have known problems with some combinations, we can skip them */
						skip_info const skip_list[] = {
							/* examples: */
						//	{ 20, "forest",		"large",		"craft_drop_raptor",   0                     },
						//	{ 12, "forest",		"large"			"craft_drop_herakles", "craft_ufo_harvester" },
							{ -1, "frozen",		"nature_medium",0,                     0                     },
							{ 11, "village",	"medium",		0,                     0					 },
							{ 19, "village",	"medium",		0,                     0					 },
							{ -1, "village",	"medium_noufo",	0,                     0					 },
							{ -1, "village",	"small",		0,                     0					 },
						};

						bool skip = false;
						for (skip_info const* e = skip_list; e != endof(skip_list); ++e) {
							if (e->seed >= 0 && i != e->seed)
								continue;
							if (e->map && !Q_streq(p, e->map))
								continue;
							if (e->params && !Q_streq(md->params, e->params))
								continue;
							if (e->craft && !Q_streq(craft, e->craft))
								continue;
							if (e->ufo && !Q_streq(ufo, e->ufo))
								continue;
							skip = true;
							break;
						}
						if (skip)
							continue;
#endif
						/* for ufocrash map, the ufoname is the assemblyame */
						if (Q_streq(p, "ufocrash"))
							asmName = Com_GetRandomMapAssemblyNameForCraft(ufo) + 1;	/* +1 = get rid of the '+' */
						else
							asmName = (const char*)LIST_GetByIdx(md->params, 0);

						char* entityString = SV_GetConfigString(CS_ENTITYSTRING);
						const int numPlaced = SV_AssembleMap(p, asmName, mapStr, posStr, entityString, i, false);
						ASSERT_TRUE(numPlaced != 0);
						time = (Sys_Milliseconds() - time);
						ASSERT_TRUE(time < 30000);
						if (time > 10000)
							Com_Printf("\nMap: %s Assembly: %s Seed: %i tiles: %i ms: %li\n", p, asmName, i, numPlaced, time);
					}
					didItOnce = true;
					if (!iterUfo)
						break;
				}
				if (!iterDrop)
					break;
			}
		}
	}
}