Example #1
0
void QGL_PrintExtensionsString(const char *label, const char *str, const char *mask)
{
	char	name[256];

	// display label
	appPrintf(S_RED"%s extensions: ", label);
	// display extension names
	int i = 0;
	while (true)
	{
		char c = *str++;
		if ((c == ' ' || c == 0) && i)
		{
			name[i] = 0;
			i = 0;
			// name[] now contains current extension name
			// check display mask
			if (mask && !appMatchWildcard(name, mask, true)) continue;
			// determine color for name display
			const char *color = NULL;
			int j;
			unsigned m;
			extInfo_t *ext;
			for (j = 0, m = 1, ext = extInfo; j < NUM_EXTENSIONS; j++, ext++, m <<= 1)
			{
				const char *s = ext->names;
				while (s[0])				// while aliases present
				{
					if (!strcmp(s, name)) break;
					s = strchr(s, 0) + 1;
				}
				if (!s[0]) continue;
				// here: current name is one of aliases of extInfo[j]
				if (gl_config.disabledExt & m)
					color = S_CYAN;			// disabled by cvar
				else if (gl_config.ignoredExt & m)
					color = S_BLUE;			// ignored in a favor of different extension
				else if (gl_config.extensionMask & m)
					color = S_GREEN;		// used
				else
					color = S_RED;			// switched off by another reason
				appPrintf("%s%s "S_WHITE, color, name);
				break;
			}
			if (!color) appPrintf("%s ", name);		// unsupported extension
		}
		else
		{
			if (i >= sizeof(name)-1)
			{
				appWPrintf("Bad extension string\n");
				return;
			}
			name[i++] = c;
		}
		if (!c) break;
	}
	// EOLN
	appPrintf("\n");
}
Example #2
0
static void Modellist_f(bool usage, int argc, char **argv)
{
	static const char *types[] = {"unk",	"inl",	"spr",		"md3"};		// see modelType_t
	static const char *colors[] = {S_RED,	"",		S_MAGENTA, S_GREEN};	// ...

	if (argc > 2 || usage)
	{
		appPrintf("Usage: modellist [mask]\n");
		return;
	}
	const char *mask = (argc == 2) ? argv[1] : NULL;

	int totalSize = 0;
	int totalCount = 0;
	appPrintf("-----type-size----name---------\n");
	for (int i = 0; i < modelCount; i++)
	{
		//?? skip inline model from list, or compact (print somethink like this: "0-96 inl *1..*97")
		model_t *m = modelsArray[i];
		if (mask && !appMatchWildcard(m->Name, mask, true)) continue;
		totalCount++;
		appPrintf("%-3d  %3s  %-7d %s%s\n", i, types[m->type], m->size, colors[m->type], *m->Name);
		totalSize += m->size;
	}
	appPrintf("Displayed %d/%d models, used %d bytes\n", totalCount, modelCount, totalSize);
}
Example #3
0
static bool FindPackageWildcardCallback(const CGameFileInfo *file, FindPackageWildcardData &data)
{
	bool useThisPackage = false;
	if (data.WildcardContainsPath)
	{
		useThisPackage = appMatchWildcard(file->RelativeName, *data.Wildcard, true);
	}
	else
	{
		useThisPackage = appMatchWildcard(file->ShortFilename, *data.Wildcard, true);
	}
	if (useThisPackage)
	{
		data.FoundFiles.Add(file);
	}
	return true;
}
Example #4
0
void CFileContainerArc::List(CFileList &list, const char *mask, unsigned flags)
{
	TString<256> Path; Path = mask;
	char *name = Path.rchr('/');
	FDirInfo *Dir;
	if (name)
	{
		*name++ = 0;
		Dir = FindDir(Path);
		if (!Dir) return;			// directory not found
	}
	else
	{
		name = Path;
		Dir  = &Root;
	}
	// list directories and files
#if FS_DIR != FS_FILE<<1
#error Check FS_DIR / FS_FILE relationship
#endif
	for (unsigned Flag = FS_FILE; Flag <= FS_DIR; Flag <<= 1)
	{
		if (!(flags & Flag)) continue;

		CListIterator it;
		if (Flag == FS_FILE)		// cannot write this as "it = (Flag == FS_FILE) ? ..."
			it = Dir->Files;
		else
			it = Dir->Dirs;

		for ( ; it; ++it)
		{
			if (!appMatchWildcard(it->name, name)) continue;

			TString<256> Name; Name = it->name;
			// process NOEXT
			if (flags & FS_NOEXT)
			{
				char *s = Name.rchr('.');
				if (s) *s = 0;
			}

			CFileItem *item, *place;
			if (!(item = list.Find(Name, &place)))
			{
				item = new (Name, &list) CFileItem;
				// here: item->flags=0
				list.InsertAfter(item, place);
			}
			item->flags |= containFlags|Flag;
		}
	}
}
Example #5
0
static void S_SoundList_f(bool usage, int argc, char **argv)
{
	if (argc > 2 || usage)
	{
		appPrintf("Usage: soundlist [<mask>]\n");
		return;
	}

	const char *mask = (argc == 2) ? argv[1] : NULL;

	appPrintf("---lp-bit-size----name----------\n");

	int n = 0, total = 0;
	int		i;
	sfx_t	*sfx;
	for (i = 0, sfx = known_sfx; i < num_sfx; i++, sfx++)
	{
		if (!sfx->Name[0])
			continue;

		if (mask && !appMatchWildcard(sfx->Name, mask, true)) continue;
		n++;

		sfxcache_t *sc = sfx->cache;
		if (sc)
		{
			int size = sc->length*sc->width*(sc->stereo+1);
			total += size;
			appPrintf("%-3d %c %2d  %-7d %s\n", i, sc->loopstart >= 0 ? 'L' : ' ', sc->width*8, size, *sfx->Name);
		}
		else
		{
			char *status;

			if (sfx->Name[0] == '*')
				status = "placeholder  ";
			else if (sfx->absent)
				status = S_RED"not found    "S_WHITE;
			else
				status = "not loaded   ";
			appPrintf("%-3d %s %s\n", i, status, *sfx->Name);
		}
	}
	appPrintf("Displayed %d/%d sounds; resident: %d bytes\n", n, num_sfx, total);
}