void CheckForErrorLog() { if (g_log) { char logfilename[_MAX_PATH]; safe_snprintf(logfilename, _MAX_PATH, "%s.err", g_Mapname); if (q_exists(logfilename)) { Log(">> There was a problem compiling the map.\n" ">> Check the file %s.log for the cause.\n", g_Mapname); exit(1); } } }
void LoadWadincludeFile(const char* const filename) { char* fname; int i, x; char* pData = NULL; char* pszData; unsigned len = strlen(filename) + 5; fname = (char*)Alloc(len); safe_snprintf(fname, len, "%s.wic", filename); if (q_exists(fname)) { i = LoadFile(fname, &pData); if (i == 0) { goto LoadWadincludeFileReturn; } } else { Warning("WadInclude file %s does not exist", fname); goto LoadWadincludeFileReturn; } for (pszData = pData, x = 0; x < i; x++) { if (pData[x] == ';') { pData[x] = 0; g_WadInclude.push_back(pszData); pszData = pData + x + 1; } } LoadWadincludeFileReturn:; Free(fname); if (pData) { Free(pData); } }
// ===================================================================================== // LoadWadConfigFile // ===================================================================================== void LoadWadConfigFile() { FILE* wadcfg; wadconfig_t* current; wadconfig_t* previous; char temp[_MAX_PATH]; //JK: If exists lets use user-defined file if (g_wadcfgfile && q_exists(g_wadcfgfile)) { wadcfg = fopen(g_wadcfgfile, "r"); } else // find the wad.cfg file { char appdir[_MAX_PATH]; char tmp[_MAX_PATH]; memset(tmp, 0, sizeof(tmp)); memset(appdir, 0, sizeof(appdir)); // Get application directory (only an approximation on posix systems) // try looking in the directory we were run from #ifdef SYSTEM_WIN32 GetModuleFileName(NULL, tmp, _MAX_PATH); #else safe_strncpy(tmp, g_apppath, _MAX_PATH); #endif ExtractFilePath(tmp, appdir); safe_snprintf(tmp, _MAX_PATH, "%s%s", appdir, WAD_CONFIG_FILE); #ifdef _DEBUG Log("[dbg] Trying '%s'\n", tmp); #endif if (!q_exists(tmp)) { // try the Half-Life directory /*#ifdef SYSTEM_WIN32 { HKEY HLMachineKey; DWORD disposition; DWORD dwType, dwSize; // REG: create machinekey RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Valve\\Half-Life"), 0, NULL, 0, 0, NULL, &HLMachineKey, &disposition); // REG: get hl dir dwType = REG_SZ; dwSize = _MAX_PATH; RegQueryValueEx(HLMachineKey, TEXT("InstallPath"), NULL, &dwType, (PBYTE)&appdir, &dwSize); } safe_strncpy(tmp, appdir, _MAX_PATH); safe_strncat(tmp, SYSTEM_SLASH_STR, _MAX_PATH); // system slash pointless as this will only work on win32, but anyway... safe_strncat(tmp, WAD_CONFIG_FILE, _MAX_PATH); #ifdef _DEBUG Log("[dbg] Trying '%s'\n", tmp); #endif if (!q_exists(tmp)) #endif // SYSTEM_WIN32*/ // not a good idea. --vluzacn { // still cant find it, error out Log("Warning: could not find wad configurations file\n" /*"Make sure that wad.cfg is in the Half-Life directory or the current working directory\n"*/ ); return; } } wadcfg = fopen(tmp, "r"); } if (!wadcfg) { // cant open it, die Log("Warning: could not open the wad configurations file\n" "Make sure that wad.cfg is in the Half-Life directory or the current working directory\n" ); return; } while(!feof(wadcfg)) { Safe_GetToken(wadcfg, temp, MAX_WAD_CFG_NAME); if (!strcmp(temp, "HalfLifePath=")) // backwards compadibitly { Safe_GetToken(wadcfg, temp, MAX_WAD_CFG_NAME); Warning("Redundant line in " WAD_CONFIG_FILE ": \"HalfLifePath= %s\" - Ignoring...\n", temp); continue; } if (feof(wadcfg)) break; // assume its the name of a configuration current = (wadconfig_t*)malloc(sizeof(wadconfig_t)); safe_strncpy(current->name, temp, _MAX_PATH); current->entries = 0; current->next = NULL; current->firstentry = NULL; // make sure the next char starts a wad configuration Safe_GetToken(wadcfg, temp, _MAX_PATH); if (strcmp(temp, "{")) { WadCfgParseError("Expected start of wadfile configuration, '{'", g_wadcfglinecount, temp); //Log("[dbg] temp[0] is %i\n", temp[0]); fclose(wadcfg); return; } // otherwise were ok, get the definition if (!GetWadConfig(wadcfg, current)) { fclose(wadcfg); return; } // add this config to the list if (!g_WadCfg) { g_WadCfg = current; } else { previous->next = current; } previous = current; previous->next = NULL; } g_bWadConfigsLoaded = true; }