diff --git a/code/cgame/cg_drawtools.c b/code/cgame/cg_drawtools.c index 86806d6..7b391e5 100644 --- a/code/cgame/cg_drawtools.c +++ b/code/cgame/cg_drawtools.c @@ -1486,7 +1486,7 @@ qboolean CG_LoadRanks(void) { file_len = trap_FS_FOpenFile(fileName, &file, FS_READ); - if (file_len <= 0) { + if (file == 0 || file_len <= 0) { return qfalse; } @@ -1737,7 +1737,7 @@ qboolean CG_LoadCrosshairs(void) { memset(&cgs.crosshairsData, 0, sizeof(&cgs.crosshairsData)); //check to see if we got anything - if (file_len <= 0) { + if (f == 0 || file_len <= 0) { Com_Printf(S_COLOR_RED "Could not find file: %s\n", fileName); return qfalse; } diff --git a/code/cgame/cg_lua.c b/code/cgame/cg_lua.c index 2777ead..57e3e4b 100644 --- a/code/cgame/cg_lua.c +++ b/code/cgame/cg_lua.c @@ -52,7 +52,7 @@ qboolean LoadLuaFile(char *path, int32_t num_vm) lvm_t *vm; flen = trap_FS_FOpenFile(path, &f, FS_READ); - if(flen < 0) + if(f == 0 || flen <= 0) { LUA_LOG("Lua: can not open file %s\n", path); CG_Printf(S_COLOR_YELLOW "Lua: can not open file %s\n", path); diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c index a2da38f..92d6e07 100644 --- a/code/cgame/cg_main.c +++ b/code/cgame/cg_main.c @@ -1596,7 +1596,7 @@ void CG_LoadObjectivesForMap(void) len = trap_FS_FOpenFile( fullFileName, &f, FS_READ ); - if ( len > MAX_OBJ_TEXT_LENGTH ) + if (f == 0 || len > MAX_OBJ_TEXT_LENGTH ) // TODO split these checks { CG_LocLogger(LL_ERROR, "CG_LoadObjectivesForMap : %s file bigger than %d!\n", fileName, MAX_OBJ_TEXT_LENGTH ); CG_LogFuncEnd(); @@ -1669,6 +1669,10 @@ qboolean CG_LoadClasses( void ) file_len = trap_FS_FOpenFile( filePath, &f, FS_READ ); + if (f == 0) { + return qfalse; // TODO logging + } + if ( !file_len ) { CG_LocLogger(LL_ERROR, "Couldn't find class file: %s\n", filePath ); @@ -1894,6 +1898,11 @@ qboolean CG_LoadUsablesStrings( void ) file_len = trap_FS_FOpenFile( fileRoute, &f, FS_READ ); + if (f == 0) { + // TODO logging + return qfalse; + } + //It's assumed most maps won't have this feature, so just exit 'gracefully' if ( file_len<=1 ) { diff --git a/code/game/g_main.c b/code/game/g_main.c index eaf89e4..0801584 100644 --- a/code/game/g_main.c +++ b/code/game/g_main.c @@ -884,7 +884,7 @@ static void G_LoadTimedMessages(void) { G_LogFuncBegin(); len = trap_FS_FOpenFile("timedmessages.cfg", &f, FS_READ); - if (len == 0) { + if (f == 0) { G_LogFuncEnd(); return; } @@ -969,7 +969,7 @@ static void G_LoadHolodeckFile(void) { free(info); - if (file_len == 0) { + if (f == 0) { return; } @@ -1102,7 +1102,7 @@ static void G_LoadServerChangeFile(void) { file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); - if (file_len == 0) { + if (f == 0) { G_LogFuncEnd(); return; } @@ -1233,7 +1233,7 @@ static void G_LoadMapChangeFile(void) { file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ); - if (file_len == 0) { + if (f == 0) { return; } @@ -1352,7 +1352,7 @@ static void G_LoadLocationsFile(void) { free(serverInfo); - if (file_len <= 0) { + if (f <= 0) { G_LogFuncEnd(); return; } diff --git a/code/game/g_weapon.c b/code/game/g_weapon.c index dd90bdc..e64b0b3 100644 --- a/code/game/g_weapon.c +++ b/code/game/g_weapon.c @@ -1093,7 +1093,7 @@ void G_Weapon_LoadConfig(void) { G_LogFuncBegin(); len = trap_FS_FOpenFile("weapon.cfg", &f, FS_READ); - if (len == 0) { + if (f == 0) { G_LocLogger(LL_ERROR, "weapon.cfg not found or empty! Using defaults.\n"); G_Weapon_DefaultConfig(); G_LogFuncEnd(); @@ -2649,7 +2649,7 @@ static double G_Weapon_ShotSize(int32_t wp_num) { case WP_4: case WP_5: case WP_6: - default: + default: return 0; } } @@ -2677,7 +2677,7 @@ static double G_Weapon_AltShotSize(int32_t wp_num) { case WP_2: case WP_3: case WP_4: - default: + default: return 0; } } diff --git a/code/ui/ui_admin.c b/code/ui/ui_admin.c index 688cc8e..c3bc732 100644 --- a/code/ui/ui_admin.c +++ b/code/ui/ui_admin.c @@ -2135,7 +2135,7 @@ static void AdminAudio_InitFilesList(void) /* First step: Parse in the config where we store all our file dirs */ strLen = trap_FS_FOpenFile("ext_data/audioFileRoutes.dat", &f, FS_READ); - if (!strLen) { + if (strLen <= 0) { UI_Logger(LL_ERROR, "ext_data/audioFileRoutes.dat could not be found.\n"); return; } diff --git a/code/ui/ui_atoms.c b/code/ui/ui_atoms.c index 39e579d..1da2ba1 100644 --- a/code/ui/ui_atoms.c +++ b/code/ui/ui_atoms.c @@ -2910,7 +2910,7 @@ void UI_LanguageFilename(char *baseName, char *baseExtension, char *finalName) /* Attempt to load the file */ trap_FS_FOpenFile(finalName, &file, FS_READ); - if (file == 0) /* This extension doesn't exist, go English. */ + if (file <= 0) /* This extension doesn't exist, go English. */ { Com_sprintf(finalName, MAX_QPATH, "%s.%s", baseName, baseExtension); /* the caller will give the error if this isn't there */ } diff --git a/code/ui/ui_playermodel.c b/code/ui/ui_playermodel.c index 68402de..f23bafc 100644 --- a/code/ui/ui_playermodel.c +++ b/code/ui/ui_playermodel.c @@ -1231,7 +1231,7 @@ static void PlayerModel_BuildList(void) //UI_Logger( LL_DEBUG, "File %s loaded.\n", dirptr ); - if (!fileLength) { + if (fileLength <= 0) { continue; } //UI_Logger( LL_DEBUG, "We have length.\n" );