/* ==================== W_CheckNumForName Returns -1 if name not found ==================== */ int W_CheckNumForName (char *name) { char cleanname[16]; int v1,v2, v3, v4; int i; lumpinfo_t *lump_p; CleanupName (name, cleanname); // make the name into four integers for easy compares v1 = *(int *)cleanname; v2 = *(int *)&cleanname[4]; v3 = *(int *)&cleanname[8]; v4 = *(int *)&cleanname[12]; // find it lump_p = lumpinfo; for (i=0 ; i<numlumps ; i++, lump_p++) { if ( *(int *)lump_p->name == v1 && *(int *)&lump_p->name[4] == v2 && *(int *)&lump_p->name[8] == v3 && *(int *)&lump_p->name[12] == v4) return i; } return -1; }
/* ================= TEX_InitFromWad ================= */ void TEX_InitFromWad (char *path) { int i, j = 0; char *word, buf[2048]; while ((word = (char *) strsep(&path, ";")) && j < NUM_WADS) { // sprintf(buf, "%s/%s", gamedir, word); strcpy(buf, word); printf("reading wadfile: '%s'\n", buf); texfile[j] = SafeOpenRead (buf); SafeRead (texfile[j], &wadinfo[j], sizeof(wadinfo_t)); if (strncmp (wadinfo[j].identification, "WAD2", 4)) Error ("TEX_InitFromWad: %s isn't a wadfile",buf); wadinfo[j].numlumps = LittleLong(wadinfo[j].numlumps); wadinfo[j].infotableofs = LittleLong(wadinfo[j].infotableofs); fseek (texfile[j], wadinfo[j].infotableofs, SEEK_SET); lumpinfo[j] = malloc(wadinfo[j].numlumps*sizeof(lumpinfo_t)); SafeRead (texfile[j], lumpinfo[j], wadinfo[j].numlumps*sizeof(lumpinfo_t)); for (i=0 ; i<wadinfo[j].numlumps ; i++) { CleanupName (lumpinfo[j][i].name, lumpinfo[j][i].name); lumpinfo[j][i].filepos = LittleLong(lumpinfo[j][i].filepos); lumpinfo[j][i].disksize = LittleLong(lumpinfo[j][i].disksize); } j++; } }
void AddAnimatingTextures (void) { int base; int i, j; char name[32]; base = nummiptex; for (i = 0;i < base;i++) { if (miptex[i][0] != '+') continue; CleanupName (miptex[i], name); for (j = 0;j < 20;j++) { if (j < 10) name[1] = j + '0'; else name[1] = j + 'A' - 10; // alternate animation if (!MipTexUsed(name) && FindMipTexFile(name)) FindMiptex (name); } } }
miptexfile_t *FindMipTexFile(char *texname) { int i; char name[16]; CleanupName(texname, name); for (i = 0;i < nummiptexfiles;i++) if (!strcmp(miptexfile[i].name, name)) return miptexfile + i; return NULL; }
int MipTexUsed(char *texname) { int i; char name[16]; CleanupName(texname, name); for (i = 0;i < nummiptex;i++) if (!strcmp(miptex[i], name)) return true; return false; }
int FindMiptex (char *name) { int i; for (i=0 ; i<nummiptex ; i++) { if (!Q_strncasecmp(name, miptex[i], sizeof(char16))) return i; } ExtendArray(miptex, i); CleanupName (name, miptex[i]); nummiptex++; return i; }
/* ================== LoadLump ================== */ int LoadLump (char *name, byte *dest) { int i, j; char cname[16]; CleanupName (name, cname); for (j = 0; j < NUM_WADS; j++) { for (i=0 ; i < wadinfo[j].numlumps ; i++) { if (!strcmp(cname, lumpinfo[j][i].name)) { fseek (texfile[j], lumpinfo[j][i].filepos, SEEK_SET); SafeRead (texfile[j], dest, lumpinfo[j][i].disksize); return lumpinfo[j][i].disksize; } } } printf ("WARNING: texture %s not found\n", name); return 0; }
/* ================= TEX_InitFromWad ================= */ void TEX_InitFromWad (char *path) { int i; texfile = SafeOpenRead (path); SafeRead (texfile, &wadinfo, sizeof(wadinfo)); if (strncmp (wadinfo.identification, "WAD2", 4)) Error ("TEX_InitFromWad: %s isn't a wadfile",path); wadinfo.numlumps = LittleLong(wadinfo.numlumps); wadinfo.infotableofs = LittleLong(wadinfo.infotableofs); fseek (texfile, wadinfo.infotableofs, SEEK_SET); lumpinfo = malloc(wadinfo.numlumps*sizeof(lumpinfo_t)); SafeRead (texfile, lumpinfo, wadinfo.numlumps*sizeof(lumpinfo_t)); for (i=0 ; i<wadinfo.numlumps ; i++) { CleanupName (lumpinfo[i].name, lumpinfo[i].name); lumpinfo[i].filepos = LittleLong(lumpinfo[i].filepos); lumpinfo[i].disksize = LittleLong(lumpinfo[i].disksize); } }
// *************************************************************************** // Function: CMD_Where // Description: Our '/where' command // Displays the direction and distance to the closest spawn // Usage: /where <spawn> // *************************************************************************** int CMD_Where(int argc, char* argv[]) { if (argc<2) { WriteChatf("Syntax: %s <spawn>",argv[0]); return 0; } if (!ppSpawnManager) return 0; if (!pSpawnList) return 0; PSPAWNINFO pChar = GetCharInfo()->pSpawn; PSPAWNINFO pSpawnClosest = NULL; SEARCHSPAWN SearchSpawn; ClearSearchSpawn(&SearchSpawn); CHAR szMsg[MAX_STRING] = {0}; CHAR szName[MAX_STRING] = {0}; CHAR szArg[MAX_STRING] = {0}; bRunNextCommand = TRUE; SearchSpawn.SpawnType= PC; ParseSearchSpawn(1,argc,argv,SearchSpawn); if (!(pSpawnClosest = SearchThroughSpawns(&SearchSpawn,pChar))) { sprintf(szMsg,"There were no matches for: %s",FormatSearchSpawn(szArg,&SearchSpawn)); } else { INT Angle = (INT)((atan2f(pChar->X - pSpawnClosest->X, pChar->Y - pSpawnClosest->Y) * 180.0f / PI + 360.0f) / 22.5f + 0.5f) % 16; sprintf(szMsg,"The closest '%s' is a level %d %s %s and %1.2f away to the %s, Z difference = %1.2f", CleanupName(strcpy(szName,pSpawnClosest->Name),FALSE), pSpawnClosest->Level, pEverQuest->GetRaceDesc(pSpawnClosest->Race), GetClassDesc(pSpawnClosest->Class), DistanceToSpawn(pChar,pSpawnClosest), szHeading[Angle], pSpawnClosest->Z-pChar->Z); DebugSpew("Where - %s",szMsg); } WriteChatColor(szMsg,USERCOLOR_WHO); return 0; }
void WriteMiptex (void) { int i, success; byte *miptex_data; dmiptexlump_t *miptex_lumps; char *path, *currentpath; miptexfile_t *m; path = ValueForKey (&entities[0], "_wad"); if (!path || !path[0]) { path = ValueForKey (&entities[0], "wad"); if (!path || !path[0]) { printf ("WriteMiptex: no wads specified in \"wad\" key in worldspawn\n"); texdatasize = 0; return; } } nummiptexfiles = 0; currentpath = path; while (*currentpath) { getwadname(wadname, ¤tpath); if (wadname[0]) { success = false; // try prepending each -wadpath on the commandline to the wad name for (i = 1;i < myargc;i++) { if (!Q_strcasecmp("-wadpath", myargv[i])) { i++; if (i < myargc) { sprintf(wadfilename, "%s%s", myargv[i], wadname); if ((success = loadwad(wadfilename) >= 0)) break; } } } if (!success) { // if the map name has a path, we can try loading the wad from there ExtractFilePath(bspfilename, wadfilename); if (wadfilename[0]) { strcat(wadfilename, wadname); if (!(success = loadwad(wadfilename) >= 0)) { // try the parent directory ExtractFilePath(bspfilename, wadfilename); strcat(wadfilename, "../"); strcat(wadfilename, wadname); success = loadwad(wadfilename) >= 0; } } } if (!success) { // try the wadname itself success = loadwad(wadname) >= 0; } if (!success) printf("Could not find wad \"%s\" using -wadpath options or in the same directory as the map or it's parent directory, so there!\n", wadname); } } for (i = 0;i < nummiptex;i++) CleanupName(miptex[i], miptex[i]); AddAnimatingTextures(); miptex_lumps = (dmiptexlump_t *)dtexdata; miptex_data = (byte *)&miptex_lumps->dataofs[nummiptex]; miptex_lumps->nummiptex = nummiptex; for (i=0 ; i < nummiptex ; i++) { printf("miptex used: %s", miptex[i]); m = FindMipTexFile(miptex[i]); if (m) { if (miptex_data + m->size - dtexdata >= MAX_MAP_MIPTEX) { miptex_lumps->dataofs[i] = -1; printf(" (MAX_MAP_MIPTEX exceeded)\n"); } else if (ReadMipTexFile(m, miptex_data)) { miptex_lumps->dataofs[i] = -1; printf(" (READ ERROR)\n"); } else { miptex_lumps->dataofs[i] = miptex_data - (byte *)miptex_lumps; printf("\n"); miptex_data += m->size; } } else { miptex_lumps->dataofs[i] = -1; printf(" (NOT FOUND)\n"); } } texdatasize = miptex_data - dtexdata; }
int loadwad(char *filename) { int i, oldnummiptexfiles = nummiptexfiles; wadinfo_t wadinfo; lumpinfo_t lumpinfo; FILE *file; file = fopen(filename, "rb"); if (!file) { printf("unable to open wad \"%s\"\n", filename); return -1; } if (fread(&wadinfo, sizeof(wadinfo_t), 1, file) < 1) { printf("error reading wad header in \"%s\"\n", filename); fclose(file); return -1; } // FIXME: support halflife WAD3? if (memcmp(wadinfo.identification, "WAD2", 4)) { printf("\"%s\" is not a quake WAD2 archive\n", filename); fclose(file); return -1; } wadinfo.numlumps = LittleLong(wadinfo.numlumps); wadinfo.infotableofs = LittleLong(wadinfo.infotableofs); if (fseek(file, wadinfo.infotableofs, SEEK_SET)) { printf("error seeking in wad \"%s\"\n", filename); fclose(file); return -1; } for (i = 0;i < wadinfo.numlumps;i++) { if (fread(&lumpinfo, sizeof(lumpinfo_t), 1, file) < 1) { printf("error reading lump header in wad \"%s\"\n", filename); fclose(file); return -1; } lumpinfo.filepos = LittleLong(lumpinfo.filepos); lumpinfo.disksize = LittleLong(lumpinfo.disksize); lumpinfo.size = LittleLong(lumpinfo.size); CleanupName(lumpinfo.name, lumpinfo.name); // LordHavoc: some wad editors write 0 size // disabled the size check because some wad editors write garbage for the lump size if (lumpinfo.compression)// || (lumpinfo.size && lumpinfo.size != lumpinfo.disksize)) { printf("lump \"%s\" in wad \"%s\" is compressed??\n", lumpinfo.name, filename); continue; } if (lumpinfo.type == TYP_MIPTEX) { miptexfile[nummiptexfiles].file = file; miptexfile[nummiptexfiles].filepos = lumpinfo.filepos; miptexfile[nummiptexfiles].size = lumpinfo.disksize; memcpy(miptexfile[nummiptexfiles].name, lumpinfo.name, 16); nummiptexfiles++; } } printf("loaded wad \"%s\" (%i miptex found)\n", filename, nummiptexfiles - oldnummiptexfiles); return nummiptexfiles - oldnummiptexfiles; }
void autowad_UpdateUsedWads() { // see which wadfiles are needed // code for this wad loop somewhat copied from below wadinfo_t thiswad; lumpinfo_t* thislump = NULL; wadpath_t* currentwad; char* pszWadFile; FILE* texfile; const char* pszWadroot = getenv("WADROOT"); int i, j; int nTexLumps = 0; #ifdef _DEBUG Log("[dbg] Starting wad dependency check\n"); #endif // open each wadpath and sort though its contents for (i = 0; i < g_iNumWadPaths; i++) { currentwad = g_pWadPaths[i]; pszWadFile = currentwad->path; currentwad->usedbymap = false; // guilty until proven innocent #ifdef _DEBUG Log(" Parsing wad: '%s'\n", pszWadFile); #endif texfile = fopen(pszWadFile, "rb"); #ifdef SYSTEM_WIN32 if (!texfile) { // cant find it, maybe this wad file has a hard code drive if (pszWadFile[1] == ':') { pszWadFile += 2; // skip past the drive texfile = fopen(pszWadFile, "rb"); } } #endif char szTmp[_MAX_PATH]; if (!texfile && pszWadroot) { char szFile[_MAX_PATH]; char szSubdir[_MAX_PATH]; ExtractFile(pszWadFile, szFile); ExtractFilePath(pszWadFile, szTmp); ExtractFile(szTmp, szSubdir); // szSubdir will have a trailing separator safe_snprintf(szTmp, _MAX_PATH, "%s" SYSTEM_SLASH_STR "%s%s", pszWadroot, szSubdir, szFile); texfile = fopen(szTmp, "rb"); #ifdef SYSTEM_POSIX if (!texfile) { // cant find it, Convert to lower case and try again strlwr(szTmp); texfile = fopen(szTmp, "rb"); } #endif } #ifdef HLCSG_SEARCHWADPATH_VL #ifdef SYSTEM_WIN32 if (!texfile && pszWadFile[0] == '\\') { char tmp[_MAX_PATH]; int l; for (l = 'C'; l <= 'Z'; ++l) { safe_snprintf (tmp, _MAX_PATH, "%c:%s", l, pszWadFile); texfile = fopen (tmp, "rb"); if (texfile) { break; } } } #endif #endif if (!texfile) // still cant find it, skip this one { #ifdef HLCSG_SEARCHWADPATH_VL pszWadFile = currentwad->path; // correct it back #endif if(pszWadroot) { Warning("Wad file '%s' not found, also tried '%s'",pszWadFile,szTmp); } else { Warning("Wad file '%s' not found",pszWadFile); } continue; } // look and see if we're supposed to include the textures from this WAD in the bsp. { WadInclude_i it; bool including = false; for (it = g_WadInclude.begin(); it != g_WadInclude.end(); it++) { if (stristr(pszWadFile, it->c_str())) { #ifdef _DEBUG Log(" - including wad\n"); #endif including = true; currentwad->usedbymap = true; break; } } if (including) { //fclose(texfile); //continue; } } // read in this wadfiles information SafeRead(texfile, &thiswad, sizeof(thiswad)); // make sure its a valid format if (strncmp(thiswad.identification, "WAD2", 4) && strncmp(thiswad.identification, "WAD3", 4)) { fclose(texfile); continue; } thiswad.numlumps = LittleLong(thiswad.numlumps); thiswad.infotableofs = LittleLong(thiswad.infotableofs); // read in lump if (fseek(texfile, thiswad.infotableofs, SEEK_SET)) { fclose(texfile); continue; // had trouble reading, skip this wad } // memalloc for this lump thislump = (lumpinfo_t*)realloc(thislump, (nTexLumps + thiswad.numlumps) * sizeof(lumpinfo_t)); // BUGBUG: is this destructed? // for each texlump for (j = 0; j < thiswad.numlumps; j++, nTexLumps++) { SafeRead(texfile, &thislump[nTexLumps], (sizeof(lumpinfo_t) - sizeof(int)) ); // iTexFile is NOT read from file CleanupName(thislump[nTexLumps].name, thislump[nTexLumps].name); if (autowad_IsUsedTexture(thislump[nTexLumps].name)) { currentwad->usedbymap = true; currentwad->usedtextures++; #ifdef _DEBUG Log(" - Used wadfile: [%s]\n", thislump[nTexLumps].name); #endif autowad_PurgeName(thislump[nTexLumps].name); } } fclose(texfile); } #ifdef _DEBUG Log("[dbg] End wad dependency check\n\n"); #endif return; }
int CMD_EQFace(int argc, char *argv[]) { //VOID Face(PSPAWNINFO pChar, PCHAR szLine) //{ if (!ppSpawnManager) return 0; if (!pSpawnList) return 0; PSPAWNINFO pSpawnClosest = NULL; PSPAWNINFO psTarget = NULL; SPAWNINFO LocSpawn = {0}; PSPAWNINFO pChar = (PSPAWNINFO)pLocalPlayer; SEARCHSPAWN SearchSpawn; ClearSearchSpawn(&SearchSpawn); CHAR szMsg[MAX_STRING] = {0}; CHAR szName[MAX_STRING] = {0}; CHAR szArg[MAX_STRING] = {0}; PCHAR pszArg = NULL; BOOL bArg = TRUE; BOOL bOtherArgs = FALSE; BOOL Away = FALSE; BOOL Predict = FALSE; BOOL Fast = FALSE; BOOL Look = TRUE; BOOL Parsing = TRUE; DOUBLE Distance; for(int qq=1; qq<argc; qq++) { if (!strcmp(argv[qq],"predict")) { Predict=TRUE; } else if (!strcmp(argv[qq],"fast")) { Fast = TRUE; } else if (!strcmp(argv[qq],"away")) { Away = TRUE; } else if (!strcmp(argv[qq],"nolook")) { Look = FALSE; } else if (!strnicmp(argv[qq], "loc", 3)) { pSpawnClosest = &LocSpawn; strcpy(LocSpawn.Name,"location"); if (((++qq)<argc) && strstr(argv[qq],",")) { pSpawnClosest->Y = (FLOAT)atof(argv[qq]); pszArg = strstr(argv[qq],",")+1; pSpawnClosest->X = (FLOAT)atof(pszArg); } } else if (!stricmp(argv[qq], "item")) { if (EnviroTarget.Name[0]==0) { printf("%s: item specified but no item targetted.", argv[0]); return 0; } pSpawnClosest = &EnviroTarget; } else if (!stricmp(argv[qq], "door")) { if (DoorEnviroTarget.Name[0] == 0) { printf("%s: door specified but no door targetted.", argv[0]); return 0; } pSpawnClosest = &DoorEnviroTarget; } else if (!strcmp(szArg,"help")) { printf("Usage: %s [spawn] [item] [door] [id #] [heading <ang>] [loc <y>,<x>] [away] [alert #]",argv[0]); return 0; } else { bOtherArgs = TRUE; qq+=ParseSearchSpawnArg(qq,argc,argv,SearchSpawn); // szFilter = ParseSearchSpawnArgs(szArg,szFilter,&SearchSpawn); } } if (!pSpawnClosest) { if (!bOtherArgs) { if (ppTarget && pTarget) { pSpawnClosest = (PSPAWNINFO)pTarget; } } else { pSpawnClosest = SearchThroughSpawns(&SearchSpawn,pChar); } } szMsg[0]=0; if (!pSpawnClosest) { printf("There were no matches for: %s",FormatSearchSpawn(szArg,&SearchSpawn)); } else { if (Predict) { Distance = DistanceToSpawn(pChar, pSpawnClosest); gFaceAngle = ( atan2((pSpawnClosest->X + (pSpawnClosest->SpeedX * Distance)) - pChar->X, (pSpawnClosest->Y + (pSpawnClosest->SpeedY * Distance)) - pChar->Y) * 256.0f / PI); } else { gFaceAngle = ( atan2(pSpawnClosest->X - pChar->X, pSpawnClosest->Y - pChar->Y) * 256.0f / PI); } if (Look) { Distance = DistanceToSpawn(pChar, pSpawnClosest); gLookAngle = ( atan2(pSpawnClosest->Z + pSpawnClosest->AvatarHeight*StateHeightMultiplier(pSpawnClosest->StandState) - pChar->Z - pChar->AvatarHeight*StateHeightMultiplier(pChar->StandState), (FLOAT)Distance) * 256.0f / PI); if (Away) gLookAngle = -gLookAngle; if (Fast) { pChar->CameraAngle = (FLOAT)gLookAngle; gLookAngle=10000.0f; } } if (Away) { gFaceAngle += 256.0f; } if (gFaceAngle>=512.0f) gFaceAngle -= 512.0f; if (gFaceAngle<0.0f) gFaceAngle += 512.0f; if (Fast) { ((PSPAWNINFO)pCharSpawn)->Heading = (FLOAT)gFaceAngle; gFaceAngle=10000.0f; } sprintf(szMsg,"Facing %s'%s'...",(Away)?"away from ":"", CleanupName(strcpy(szName,pSpawnClosest->Name),FALSE)); } if (ppTarget && pTarget) { psTarget = (PSPAWNINFO)pTarget; } if (szMsg[0] && ((pSpawnClosest != &LocSpawn) && ((Away) || (pSpawnClosest != psTarget)))) WriteChatColor(szMsg,USERCOLOR_WHO); DebugSpew("Face - %s",szMsg); return 0; }
// ===================================================================================== // TEX_InitFromWad // ===================================================================================== bool TEX_InitFromWad() { int i, j; wadinfo_t wadinfo; char szTmpWad[1024]; // arbitrary, but needs to be large. char* pszWadFile; const char* pszWadroot; wadpath_t* currentwad; Log("\n"); // looks cleaner szTmpWad[0] = 0; pszWadroot = getenv("WADROOT"); #ifdef HLCSG_AUTOWAD autowad_UpdateUsedWads(); #endif // for eachwadpath for (i = 0; i < g_iNumWadPaths; i++) { FILE* texfile; // temporary used in this loop bool bExcludeThisWad = false; currentwad = g_pWadPaths[i]; pszWadFile = currentwad->path; #ifdef HLCSG_AUTOWAD #ifdef _DEBUG Log("[dbg] Attempting to parse wad: '%s'\n", pszWadFile); #endif if (g_bWadAutoDetect && !currentwad->usedtextures) continue; #ifdef _DEBUG Log("[dbg] Parsing wad\n"); #endif #endif texfiles[nTexFiles] = fopen(pszWadFile, "rb"); #ifdef SYSTEM_WIN32 if (!texfiles[nTexFiles]) { // cant find it, maybe this wad file has a hard code drive if (pszWadFile[1] == ':') { pszWadFile += 2; // skip past the drive texfiles[nTexFiles] = fopen(pszWadFile, "rb"); } } #endif if (!texfiles[nTexFiles] && pszWadroot) { char szTmp[_MAX_PATH]; char szFile[_MAX_PATH]; char szSubdir[_MAX_PATH]; ExtractFile(pszWadFile, szFile); ExtractFilePath(pszWadFile, szTmp); ExtractFile(szTmp, szSubdir); // szSubdir will have a trailing separator safe_snprintf(szTmp, _MAX_PATH, "%s" SYSTEM_SLASH_STR "%s%s", pszWadroot, szSubdir, szFile); texfiles[nTexFiles] = fopen(szTmp, "rb"); #ifdef SYSTEM_POSIX if (!texfiles[nTexFiles]) { // if we cant find it, Convert to lower case and try again strlwr(szTmp); texfiles[nTexFiles] = fopen(szTmp, "rb"); } #endif } if (!texfiles[nTexFiles]) { // still cant find it, error out Fatal(assume_COULD_NOT_FIND_WAD, "Could not open wad file %s", pszWadFile); continue; } // look and see if we're supposed to include the textures from this WAD in the bsp. WadInclude_i it; for (it = g_WadInclude.begin(); it != g_WadInclude.end(); it++) { if (stristr(pszWadFile, it->c_str())) { Log("Including Wadfile: %s\n", pszWadFile); bExcludeThisWad = true; // wadincluding this one s_WadIncludeMap[nTexFiles] = true; break; } } if (!bExcludeThisWad) { Log("Using Wadfile: %s\n", pszWadFile); safe_snprintf(szTmpWad, 1024, "%s%s;", szTmpWad, pszWadFile); } // temp assignment to make things cleaner: texfile = texfiles[nTexFiles]; // read in this wadfiles information SafeRead(texfile, &wadinfo, sizeof(wadinfo)); // make sure its a valid format if (strncmp(wadinfo.identification, "WAD2", 4) && strncmp(wadinfo.identification, "WAD3", 4)) { Log(" - "); Error("%s isn't a Wadfile!", pszWadFile); } wadinfo.numlumps = LittleLong(wadinfo.numlumps); wadinfo.infotableofs = LittleLong(wadinfo.infotableofs); // read in lump if (fseek(texfile, wadinfo.infotableofs, SEEK_SET)) Warning("fseek to %d in wadfile %s failed\n", wadinfo.infotableofs, pszWadFile); // memalloc for this lump lumpinfo = (lumpinfo_t*)realloc(lumpinfo, (nTexLumps + wadinfo.numlumps) * sizeof(lumpinfo_t)); // for each texlump for (j = 0; j < wadinfo.numlumps; j++, nTexLumps++) { SafeRead(texfile, &lumpinfo[nTexLumps], (sizeof(lumpinfo_t) - sizeof(int)) ); // iTexFile is NOT read from file if (!TerminatedString(lumpinfo[nTexLumps].name, MAXWADNAME)) { lumpinfo[nTexLumps].name[MAXWADNAME - 1] = 0; Log(" - "); Warning("Unterminated texture name : wad[%s] texture[%d] name[%s]\n", pszWadFile, nTexLumps, lumpinfo[nTexLumps].name); } CleanupName(lumpinfo[nTexLumps].name, lumpinfo[nTexLumps].name); lumpinfo[nTexLumps].filepos = LittleLong(lumpinfo[nTexLumps].filepos); lumpinfo[nTexLumps].disksize = LittleLong(lumpinfo[nTexLumps].disksize); lumpinfo[nTexLumps].iTexFile = nTexFiles; if (lumpinfo[nTexLumps].disksize > MAX_TEXTURE_SIZE) { Log(" - "); Warning("Larger than expected texture (%d bytes): '%s'", lumpinfo[nTexLumps].disksize, lumpinfo[nTexLumps].name); } } // AJM: this feature is dependant on autowad. :( // CONSIDER: making it standard? #ifdef HLCSG_AUTOWAD { double percused = ((float)(currentwad->usedtextures) / (float)(g_numUsedTextures)) * 100; Log(" - Contains %i used texture%s, %2.2f percent of map (%d textures in wad)\n", currentwad->usedtextures, currentwad->usedtextures == 1 ? "" : "s", percused, wadinfo.numlumps); } #endif nTexFiles++; hlassume(nTexFiles < MAX_TEXFILES, assume_MAX_TEXFILES); } //Log("num of used textures: %i\n", g_numUsedTextures); // AJM: Tommy suggested i add this warning message in, and it certianly doesnt // hurt to be cautious. Especially one of the possible side effects he mentioned was svc_bad if (nTexFiles > 8) { Log("\n"); Warning("More than 8 wadfiles are in use. (%i)\n" "This may be harmless, and if no strange side effects are occurring, then\n" "it can safely be ignored. However, if your map starts exhibiting strange\n" "or obscure errors, consider this as suspect.\n" , nTexFiles); } // sort texlumps in memory by name qsort((void*)lumpinfo, (size_t) nTexLumps, sizeof(lumpinfo[0]), lump_sorter_by_name); SetKeyValue(&g_entities[0], "wad", szTmpWad); Log("\n"); CheckFatal(); return true; }