コード例 #1
0
ファイル: s_music.cpp プロジェクト: chagara/ufoai
static int M_CompleteMusic (const char* partial, const char** match)
{
	int n = 0;
	while (char const* const filename = FS_NextFileFromFileList("music/*.ogg")) {
		if (Cmd_GenericCompleteFunction(filename, partial, match)) {
			Com_Printf("%s\n", filename);
			++n;
		}
	}
	FS_NextFileFromFileList(nullptr);
	return n;
}
コード例 #2
0
ファイル: common.cpp プロジェクト: ArkyRomania/ufoai
/**
 * @brief Checks for duplicate files
 * @param[in] file The file path to check whether there is an identical file
 * @param[in] wildcard The wildcard to specify which files should be checked
 * @return @c false if no duplicate was found, @c true otherwise
 */
bool Com_CheckDuplicateFile (const char* file, const char* wildcard)
{
	const char* md5 = Com_MD5File(file);
	const char* filename;
	bool match = false;
	while ((filename = FS_NextFileFromFileList(wildcard)) != nullptr) {
		const char* md5Other = Com_MD5File(filename);
		if (Q_streq(md5, md5Other)) {
			match = true;
			break;
		}
	}
	FS_NextFileFromFileList(nullptr);
	return match;
}
コード例 #3
0
ファイル: cmd.c プロジェクト: chrisglass/ufoai
/**
 * @brief Autocomplete function for exec command
 * @note This function only lists all cfg files - but doesn't perform any
 * autocomplete step when hitting tab after "exec "
 * @sa Cmd_AddParamCompleteFunction
 */
static int Cmd_CompleteExecCommand (const char *partial, const char **match)
{
	const char *filename;
	size_t len;

	FS_BuildFileList("*.cfg");

	len = strlen(partial);
	if (!len) {
		while ((filename = FS_NextFileFromFileList("*.cfg")) != NULL) {
			Com_Printf("%s\n", filename);
		}
	}

	FS_NextFileFromFileList(NULL);
	return 0;
}
コード例 #4
0
ファイル: test_renderer.cpp プロジェクト: AresAndy/ufoai
TEST_F(RendererTest, LoadAllAnimationFiles)
{
	const char* pattern = "models/**.anm";
	const char* filename;
	mAliasModel_t mod;

	OBJZERO(mod);
	/* set a very high value to work around the error check in the loading function */
	mod.num_frames = 100000;

	while ((filename = FS_NextFileFromFileList(pattern)) != nullptr) {
		vid_modelPool = Mem_CreatePool("Vid Model Pool");
		Com_Printf("load anim file: %s\n", filename);
		R_ModLoadAnims(&mod, filename);
		Mem_DeletePool(vid_modelPool);
	}

	FS_NextFileFromFileList(nullptr);
}
コード例 #5
0
ファイル: s_main.cpp プロジェクト: jklemmack/ufoai
static int S_CompleteSounds (const char *partial, const char **match)
{
    char const* const soundExtensions[] = SAMPLE_TYPES;

    int n = 0;
    for (char const* const* extension = soundExtensions; *extension; ++extension) {
        char pattern[MAX_OSPATH];
        Com_sprintf(pattern, sizeof(pattern), "sound/**.%s", *extension);
        FS_BuildFileList(pattern);
        while (char const* filename = FS_NextFileFromFileList(pattern)) {
            char const* const fileWithPath = filename + 6;
            if (Cmd_GenericCompleteFunction(fileWithPath, partial, match)) {
                Com_Printf("%s\n", fileWithPath);
                ++n;
            }
        }
        FS_NextFileFromFileList(0);
    }
    return n;
}
コード例 #6
0
ファイル: cl_game_team.cpp プロジェクト: AresAndy/ufoai
/**
 * @brief Reads the comments from team files
 */
void GAME_TeamSlotComments_f (void)
{
	UI_ExecuteConfunc("teamsaveslotsclear");

	char relSavePath[MAX_OSPATH];
	GAME_GetRelativeSavePath(relSavePath, sizeof(relSavePath));
	char pattern[MAX_OSPATH];
	Q_strncpyz(pattern, relSavePath, sizeof(pattern));
	Q_strcat(pattern, sizeof(pattern), "*.mpt");

	FS_BuildFileList(pattern);
	int i = 0;
	const char* filename;
	while ((filename = FS_NextFileFromFileList(pattern)) != nullptr) {
		ScopedFile f;
		const char* savePath = va("%s/%s", relSavePath, filename);
		FS_OpenFile(savePath, &f, FILE_READ);
		if (!f) {
			Com_Printf("Warning: Could not open '%s'\n", filename);
			continue;
		}
		teamSaveFileHeader_t header;
		const int clen = sizeof(header);
		if (FS_Read(&header, clen, &f) != clen) {
			Com_Printf("Warning: Could not read %i bytes from savefile\n", clen);
			continue;
		}
		if (LittleLong(header.version) != TEAM_SAVE_FILE_VERSION) {
			Com_Printf("Warning: Version mismatch in '%s'\n", filename);
			continue;
		}

		char absSavePath[MAX_OSPATH];
		GAME_GetAbsoluteSavePath(absSavePath, sizeof(absSavePath));
		const bool uploadable = FS_FileExists("%s/%s", absSavePath, filename);
		UI_ExecuteConfunc("teamsaveslotadd %i \"%s\" \"%s\" %i %i", i++, filename, header.name, LittleLong(header.soldiercount), uploadable ? 1 : 0);
	}
	FS_NextFileFromFileList(nullptr);
}
コード例 #7
0
ファイル: s_music.cpp プロジェクト: chagara/ufoai
/**
 * @brief Sets the music cvar to a random track
 */
static void M_RandomTrack_f (void)
{
	if (!s_env.initialized || !music.playing)
		return;

	const int musicTrackCount = FS_BuildFileList("music/*.ogg");
	if (musicTrackCount) {
		int randomID = rand() % musicTrackCount;
		Com_DPrintf(DEBUG_SOUND, "M_RandomTrack_f: random track id: %i/%i\n", randomID, musicTrackCount);

		const char* filename;
		while ((filename = FS_NextFileFromFileList("music/*.ogg")) != nullptr) {
			if (!randomID) {
				const char* musicTrack = Com_SkipPath(filename);
				Com_Printf("..playing next music track: '%s'\n", musicTrack);
				Cvar_Set("snd_music", "%s", musicTrack);
			}
			randomID--;
		}
		FS_NextFileFromFileList(nullptr);
	} else {
		Com_DPrintf(DEBUG_SOUND, "M_RandomTrack_f: No music found!\n");
	}
}
コード例 #8
0
ファイル: s_main.c プロジェクト: chrisglass/ufoai
static int S_CompleteSounds (const char *partial, const char **match)
{
	const char *filename;
	int matches = 0;
	char *localMatch[MAX_COMPLETE];
	size_t len = strlen(partial);
	const char *soundExtensions[] = SAMPLE_TYPES;
	const char **extension = soundExtensions;
	int returnValue;

	/* check for partial matches */
	while (*extension) {
		char pattern[MAX_OSPATH];
		Com_sprintf(pattern, sizeof(pattern), "sound/**.%s", *extension);
		FS_BuildFileList(pattern);
		while ((filename = FS_NextFileFromFileList(pattern)) != NULL) {
			char fileWithPath[MAX_OSPATH];
			Com_sprintf(fileWithPath, sizeof(fileWithPath), "%s", filename + 6);
			if (!len) {
				Com_Printf("%s\n", fileWithPath);
			} else if (!strncmp(partial, fileWithPath, len)) {
				Com_Printf("%s\n", fileWithPath);
				localMatch[matches++] = strdup(fileWithPath);
				if (matches >= MAX_COMPLETE)
					break;
			}
		}
		FS_NextFileFromFileList(NULL);
		extension++;
	}

	returnValue = Cmd_GenericCompleteFunction(len, match, matches, (const char **)localMatch);
	while (--matches >= 0)
		free(localMatch[matches]);
	return returnValue;
}
コード例 #9
0
ファイル: test_renderer.cpp プロジェクト: AresAndy/ufoai
TEST_F(RendererTest, CharacterAnimationFiles)
{
	const char* pattern = "models/**.anm";
	const char* filename;
	mAliasModel_t mod;
	const char* bloodspider[] = { "death1", "death2", "death3", "dead1",
			"dead2", "dead3", "stand0", "stand1", "stand2", "stand3", "walk0",
			"walk1", "walk2", "walk3", "cstand0", "cstand1", "cstand2",
			"cstand3", "cwalk0", "cwalk1", "cwalk2", "cwalk3", "stand_menu",
			"panic0", nullptr };
	const char* hovernet[] = { "death1", "dead1", "death2","dead2", "death3",
			"dead3", "stand0", "walk0", "cstand0", "cwalk0", "stand1", "walk1",
			"cstand1", "cwalk1", "stand2", "walk2", "cstand2", "cwalk2",
			"stand3", "walk3", "cstand3", "cwalk3", "move_rifle", "shoot_rifle",
			"cmove_rifle", "cshoot_rifle", "stand_menu", "panic0", nullptr };
	const char* soldiers[] = { "death1", "death2", "death3", "dead1", "dead2",
			"dead3", "stand0", "stand1", "stand2", "stand3", "walk0", "walk1",
			"walk2", "walk3", "cstand0", "cstand1", "cstand2", "cstand3",
			"cwalk0", "cwalk1", "cwalk2", "cwalk3", "stand_menu", "panic0",
			"move_rifle", "shoot_rifle", "cmove_rifle", "cshoot_rifle",
			"move_biggun", "shoot_biggun", "cmove_biggun", "cshoot_biggun",
			"move_melee", "shoot_melee", "cmove_melee", "cshoot_melee",
			"stand_still", "move_pistol", "shoot_pistol", "cmove_pistol",
			"cshoot_pistol", "move_pistol_d", "shoot_pistol_d",
			"cmove_pistol_d", "cshoot_pistol_d", "move_grenade",
			"shoot_grenade", "cmove_grenade", "cshoot_grenade", "move_item",
			"shoot_item", "cmove_item", "cshoot_item", "move_rpg", "shoot_rpg",
			"cmove_rpg", "cshoot_rpg", nullptr };
	const char* civilians[] = { "death1", "dead1", "death2", "dead2", "death3",
			"dead3", "stand0", "walk0", "panic0", "stand1", "stand2",
			"stand_menu", "stand_still", nullptr };

	FS_BuildFileList(pattern);

	vid_modelPool = Mem_CreatePool("Vid Model Pool");

	while ((filename = FS_NextFileFromFileList(pattern)) != nullptr) {
		const char** animList;
		if (Q_strstart(filename, "models/soldiers/"))
			animList = soldiers;
		else if (Q_strstart(filename, "models/civilians/"))
			animList = civilians;
		else if (Q_strstart(filename, "models/aliens/bloodspider"))
			animList = bloodspider;
		else if (Q_strstart(filename, "models/aliens/hovernet"))
			animList = hovernet;
		else if (Q_strstart(filename, "models/aliens/"))
			animList = soldiers;
		else
			animList = nullptr;

		/** @todo remove this hack - but ugvs are just not ready yet */
		if (Q_strstart(filename, "models/soldiers/ugv_"))
			continue;
		/** @todo remove this hack - alientank is just not ready yet */
		if (Q_strstart(filename, "models/aliens/alientank/"))
			continue;

		if (animList != nullptr) {
			OBJZERO(mod);
			/* set a very high value to work around the error check in the loading function */
			mod.num_frames = 100000;

			Com_Printf("load character anim file: %s\n", filename);
			R_ModLoadAnims(&mod, filename);

			while (*animList != nullptr) {
				int i;
				for (i = 0; i < mod.num_anims; i++) {
					const mAliasAnim_t* a = &mod.animdata[i];
					if (Q_streq(a->name, *animList))
						break;
				}
				ASSERT_FALSE(i == mod.num_anims) << "anm file " << filename << " does not contain the needed animation definition " << *animList;

				animList++;
			}
		}
	}

	Mem_DeletePool(vid_modelPool);

	FS_NextFileFromFileList(nullptr);
}