예제 #1
0
static void ScanQuake3Models(const char *path)
{
	/*----- get a list of directories -----*/
	// NOTE: use of FS_PATH_NAMES here will not allow to add new skins by mod for model from base dir
	CFileList *dirNames = GFileSystem->List(va("%s/models/players/*", path), FS_DIR);

	/*--- go through the subdirectories ---*/
	for (TListIterator<CFileItem> diritem = *dirNames; diritem; ++diritem)
	{
		if (pmiList.Find(diritem->name)) continue;	// already have model with the same name

		// verify the existence of animation.cfg
		if (!GFileSystem->FileExists(va("%s/models/players/%s/animation.cfg", path, diritem->name)))
			continue;
		// verify the existence of at least one skin file
		CFileList *skinNames = GFileSystem->List(va("%s/models/players/%s/lower_*.skin", path, diritem->name), FS_FILE|FS_NOEXT);

		// count valid skins
		TList<CStringItem> skins;
		int numSkins = 0;
		for (TListIterator<CFileItem> skinItem = *skinNames; skinItem; ++skinItem)
		{
			const char *str = skinItem->name + 6;	// skip "lower_"
			// check at least one model
			if (!GFileSystem->FileExists(va("%s/models/players/%s/lower.md3", path, diritem->name))) continue;
			// may be, have "icon_file.jpg" and "icon_file.tga" ...
			if (skins.Find(str)) continue;
			skins.CreateAndInsert(str, pmiChain);
			numSkins++;
		}
		delete skinNames;
		if (!numSkins) continue;

		// create model info
		playerModelInfo_t *info = new (diritem->name, pmiChain) playerModelInfo_t;
		info->numSkins = numSkins;
		info->skins    = skins;
		info->isQ3mdl  = true;
		// add model info to pmi
		pmiList.Insert(info);
		numPlayerModels++;
	}
	delete dirNames;
}
예제 #2
0
static void ScanQuake2Models(const char *path)
{
	/*----- get a list of directories -----*/
	// NOTE: use of FS_PATH_NAMES here will not allow to add new skins by mod for model from base dir
	CFileList *dirNames = GFileSystem->List(va("%s/players/*", path), FS_DIR);

	/*--- go through the subdirectories ---*/
	for (TListIterator<CFileItem> diritem = *dirNames; diritem; ++diritem)
	{
		if (pmiList.Find(diritem->name)) continue;	// already have model with the same name

		// verify the existence of tris.md2
		if (!GFileSystem->FileExists(va("%s/players/%s/tris.md2", path, diritem->name)))
			continue;
		// verify the existence of at least one pcx skin
		CFileList *skinNames = GFileSystem->List(va("%s/players/%s/*.pcx,*.tga,*.jpg", path, diritem->name), FS_FILE|FS_NOEXT); // images only

		// count valid skins, which consist of a skin with a matching "_i" icon
		TList<CStringItem> skins;
		int numSkins = 0;
		for (TListIterator<CFileItem> skinItem = *skinNames; skinItem; ++skinItem)
			if (Md2SkinExists(skinItem->name, skinNames))
			{
				skins.CreateAndInsert(skinItem->name, pmiChain);
				numSkins++;
			}
		delete skinNames;
		if (!numSkins) continue;

		// create model info
		playerModelInfo_t *info = new (diritem->name, pmiChain) playerModelInfo_t;
		info->numSkins = numSkins;
		info->skins    = skins;
		// add model info to pmi
		pmiList.Insert(info);
		numPlayerModels++;
	}
	delete dirNames;
}
예제 #3
0
void CLobbyApp::BuildStaticCoreInfo()
{
	// build the master core list
	// then set coremask for each server
	// 1. get ride of the old list
	FreeStaticCoreInfo();
	// 2. loop thru unpaused servers and build a TList of StaticCoreInfo and the coremask
	ListConnections::Iterator iterCnxn(*GetFMServers().GetConnections());
	TList<StaticCoreInfo*,StaticCoreInfoEquals> CoreList;
	while (!iterCnxn.End())
	{
		CFLServer * pServerT = CFLServer::FromConnection(*iterCnxn.Value());
		if (pServerT) // skip lost/terminating server
		{
			pServerT->SetStaticCoreMask(0); // clear the core mask, not really needed here but it doesnt hurt
			int c = pServerT->GetcStaticCoreInfo();
			if (!pServerT->GetPaused()) // skip paused serveR
				for (int i=0; i<c; i++)
				{
					if (!CoreList.Find(&(pServerT->GetvStaticCoreInfo()[i])))
						CoreList.PushFront(&(pServerT->GetvStaticCoreInfo()[i]));
				}
		}
		iterCnxn.Next();
	}

	// 3. Allocate mem 
	m_cStaticCoreInfo = CoreList.GetCount();
	if (m_cStaticCoreInfo)
		m_vStaticCoreInfo =  new StaticCoreInfo[m_cStaticCoreInfo];
	else
		return; // no core, all done


    // 4. transform the TList into an array

	for (int i = 0; i < m_cStaticCoreInfo; i++)
		Strcpy(m_vStaticCoreInfo[i].cbIGCFile,CoreList[i]->cbIGCFile);
	CoreList.SetEmpty();

	// 5. loop thru unpaused servers and build the coremask
	ListConnections::Iterator iterCnxn2(*GetFMServers().GetConnections());
	while (!iterCnxn2.End())
	{
		CFLServer * pServerT = CFLServer::FromConnection(*iterCnxn2.Value());
		if (pServerT) // skip lost/terminating server
		{
			int c = pServerT->GetcStaticCoreInfo();
			pServerT->SetStaticCoreMask(0); // clear the core mask
			if (!pServerT->GetPaused()) // skip paused server
				for (int i=0; i<c; i++)
				{
					for (int j = 0; j < m_cStaticCoreInfo; j++)
						if (strcmp(pServerT->GetvStaticCoreInfo()[i].cbIGCFile,m_vStaticCoreInfo[j].cbIGCFile) == 0)
							pServerT->SetStaticCoreMask(pServerT->GetStaticCoreMask() | 1<<j);
						
				}
		}
		iterCnxn2.Next();
	}
}