-/*!
-Manually create an eclass_t, for when no modules exist.
-this replaces and centralizes the eclass_t allocation
-*/
-eclass_t * EClass_Create( const char *name, float col1, float col2, float col3, const vec3_t *mins, const vec3_t *maxs, const char *comments )
-{
- eclass_t *e;
- char color[128];
-
- e = (eclass_t*)malloc(sizeof(*e));
- memset (e, 0, sizeof(*e));
-
- e->name = strdup(name);
-
- // grab the color, reformat as texture name
- e->color[0] = col1;
- e->color[1] = col2;
- e->color[2] = col3;
- sprintf (color, "(%f %f %f)", e->color[0], e->color[1], e->color[2]);
- e->texdef.SetName(color);
-
- // supplied size ?
- if (mins && maxs)
- {
- // Hydra:
- // If we set worldspawn to be a fixed-size all the textures are
- // displayed as flat-shaded. This is a KLUDGE now that we have
- // multiple game support as the worldspawn entity is game specific.
- // Note that this is only ever fixed for the user if a definition
- // for the worldspawn entity was not loaded, this can happen for
- // several reasons:
- // a) no entity definition plugin exists
- // b) no entity definition files were found
- // c) no entity definition file contained an entry for worldspawn.
-
- if (stricmp(name,"worldspawn") != 0) e->fixedsize = true;
-
- // copy the sizes..
- memcpy(e->mins,mins,sizeof(vec3_t));
- memcpy(e->maxs,maxs,sizeof(vec3_t));
- }
-
- if (comments)
- e->comments = strdup(comments);
- else
- {
- e->comments = (char*)malloc(1);
- e->comments[0] = '\0';
- }
-
- return e;
-}
-
-void Eclass_Init ()
-{
- GSList *pFiles;
-
- // start by creating the default unknown eclass
- eclass_bad = EClass_Create("UNKNOWN_CLASS" , 0, 0.5, 0,NULL,NULL,NULL);
-
- // now scan the definitions
- _EClassTable *pTable = &g_EClassDefTable;
- while (pTable)
- {
- // read in all scripts/*.<extension>
- pFiles = vfsGetFileList("scripts", pTable->m_pfnGetExtension());
- if (pFiles)
- {
- GSList *pFile = pFiles;
- while (pFile)
- {
- /*!
- \todo the MP/SP filtering rules need to be CLEANED UP and SANITIZED
- */
- // HACK
- // JKII SP/MP mapping mode
- if (g_pGameDescription->mGameFile == "jk2.game" || g_pGameDescription->mGameFile == "ja.game")
- {
- if (!strcmp(ValueForKey(g_qeglobals.d_project_entity, "gamemode"), "sp"))
- {
- // SP mapping, ignore mp_*.def
- char *name = (char *)pFile->data;
- if (name[0]=='m' && name[1]=='p' && name[2]=='_')
- {
- Sys_Printf("Single Player mapping mode. Ignoring '%s'\n", name);
- pFile = pFile->next;
- continue;
- }
- }
- else
- {
- // MP mapping, ignore sp_*.def
- char *name = (char *)pFile->data;
- if (name[0]=='s' && name[1]=='p' && name[2]=='_')
- {
- Sys_Printf("Multiplayer mapping mode. Ignoring '%s'\n", name);
- pFile = pFile->next;
- continue;
- }
- }
- }
- // RIANT
- // STVEF SP/MP mapping mode
- else if (g_pGameDescription->mGameFile == "stvef.game")
- {
- if (!strcmp(ValueForKey(g_qeglobals.d_project_entity, "gamemode"), "sp"))
- {
- // SP mapping, ignore mp_*.def
- char *name = (char *)pFile->data;
- if (name[0]=='m' && name[1]=='p' && name[2]=='_')
- {
- Sys_Printf("Single Player mapping mode. Ignoring '%s'\n", name);
- pFile = pFile->next;
- continue;
- }
- }
- else
- {
- // HM mapping, ignore sp_*.def
- char *name = (char *)pFile->data;
- if (name[0]=='h' && name[1]=='m' && name[2]=='_')
- {
- Sys_Printf("HoloMatch mapping mode. Ignoring '%s'\n", name);
- pFile = pFile->next;
- continue;
- }
- }
- }
- // 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);
- char *fullpath = vfsGetFullPath(relPath, 0, 0);
- if (!fullpath)
- {
- Sys_FPrintf(SYS_ERR, "Failed to find the full path for \"%s\" in the VFS\n", relPath);
- }
- else
- pTable->m_pfnScanFile(fullpath);
- if (g_pGameDescription->mEClassSingleLoad)
- break;
- pFile = pFile->next;
- }
- vfsClearFileDirList(&pFiles);
- pFiles = NULL;
- }
- else
- Sys_FPrintf(SYS_ERR, "Didn't find any scripts/*.%s files to load EClass information\n", pTable->m_pfnGetExtension());
-
- // we deal with two formats max, if the other table exists, loop again
- if (g_bHaveEClassExt && pTable == &g_EClassDefTable)
- pTable = &g_EClassExtTable;
- else
- pTable = NULL; // done, exit
- }
- Eclass_CreateSpriteModelPaths();
-}
-
-eclass_t *Eclass_ForName (const char *name, qboolean has_brushes)
-{
- eclass_t *e;