-/*!
-This looks at each eclass_t, if it has a "modelpath" set then it leaves it alone
-if it's not set it checks to see if a file called "sprites/<eclassname>.*" exists, and
-if it does exist then it sets the "modelpath" to "sprites/<eclassname>.spr"
-*/
-void Eclass_CreateSpriteModelPaths()
-{
- int Counts[4] = { 0, 0, 0, 0 };
- char filename[512]; // should be big enough, ExtractFileBase doesn't take a buffer size...
- eclass_t *e;
-
- // get a list of all sprite/*>* files in all sprite/ directories
- Sys_Printf("Searching VFS for files in sprites/*.* that match entity names...\n");
- GSList *pFiles = vfsGetFileList("sprites", NULL);
- GSList *pFile;
-
- if (pFiles)
- {
-
- // find an eclass without a modelpath.
- for (e=eclass ; e ; e=e->next)
- {
- Counts[0]++;
- if (e->modelpath)
- {
-#ifdef _DEBUG
- Sys_Printf("Ignoring sprite for entity %s (modelpath: \"%s\")\n",e->name,e->modelpath);
-#endif
- Counts[1]++;
- continue; // ignore this eclass, it's already got a model
- }
-
- // TODO: remove this check when we can have sprites for non-fixed size entities.
- if (!e->fixedsize)
- {
-#ifdef _DEBUG
- Sys_Printf("Ignoring sprite for non-fixed-size entity %s\n",e->name);
-#endif
- Counts[2]++;
- continue; // can't have sprites for non-fixed size entities (yet!)
- }
-
-
- Sys_Printf("Searching for sprite for fixed-size entity %s...",e->name);
-
- pFile = pFiles; // point to start of list
-
- // look for a file that has the same name, with any extension.
- bool Found = FALSE;
- while (pFile)
- {
-
- // strip the path/ and the .extension.
- ExtractFileBase((char *)pFile->data,filename);
-
- // does the eclass name match the filename?
- if (stricmp(e->name,filename) == 0)
- {
- // yes, so generate a sprite filename using the all-encompasing .spr extension
- // so that the model wrapper knows the sprite model plugin will be the model
- // plugin used to render it.
- CString strSpriteName;
- strSpriteName.Format("sprites/%s.spr",e->name);
- e->modelpath = strdup(strSpriteName.GetBuffer());
- Sys_Printf("Found! (\"%s\")\n",(char *)pFile->data);
- Counts[3]++;
- Found = TRUE;
- }
- pFile = pFile->next;
- }
-
- if (!Found)
- Sys_Printf("not found\n");
-
- }
-
- vfsClearFileDirList(&pFiles);
- }
- Sys_Printf("%d entities were scanned\n"
- "%d entities that already had models/sprites were ignored\n"
- "%d non-fixed-size entities were ignored\n"
- "%d entities did not have matching sprite files\n"
- "%d entities had sprite files and have been attached\n",
- Counts[0],Counts[1],Counts[2],Counts[0]-Counts[3],Counts[3]);
-
-}
-
-void EClass_InitForFileList(GSList *pFiles, _EClassTable *pTable)
-{
- GSList *pFile = pFiles;
- while (pFile)
- {
- // for a given name, we grab the first .def in the vfs
- // this allows to override baseq3/scripts/entities.def for instance
- char relPath[PATH_MAX];
- strcpy(relPath, "scripts/");
- strcat(relPath, (char*)pFile->data);
- // FIXME TTimo http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=130
- if (!vfsGetFullPath(relPath, 0, 0))
- {
- Sys_FPrintf(SYS_ERR, "Failed to find the full path for '%s' in the VFS\n", relPath);
- Sys_FPrintf(SYS_ERR, "did you hit bug http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=130 ?\n");
- }
- else
- pTable->m_pfnScanFile(vfsGetFullPath(relPath, 0, 0));
- pFile = pFile->next;
- }