mirror of
https://github.com/UberGames/rpgxEF.git
synced 2024-11-10 07:11:34 +00:00
added various checks concerning opening files
This commit is contained in:
parent
11e5e0caed
commit
e745657bdb
8 changed files with 24 additions and 15 deletions
|
@ -1486,7 +1486,7 @@ qboolean CG_LoadRanks(void) {
|
||||||
|
|
||||||
file_len = trap_FS_FOpenFile(fileName, &file, FS_READ);
|
file_len = trap_FS_FOpenFile(fileName, &file, FS_READ);
|
||||||
|
|
||||||
if (file_len <= 0) {
|
if (file == 0 || file_len <= 0) {
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1737,7 +1737,7 @@ qboolean CG_LoadCrosshairs(void) {
|
||||||
memset(&cgs.crosshairsData, 0, sizeof(&cgs.crosshairsData));
|
memset(&cgs.crosshairsData, 0, sizeof(&cgs.crosshairsData));
|
||||||
|
|
||||||
//check to see if we got anything
|
//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);
|
Com_Printf(S_COLOR_RED "Could not find file: %s\n", fileName);
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ qboolean LoadLuaFile(char *path, int32_t num_vm)
|
||||||
lvm_t *vm;
|
lvm_t *vm;
|
||||||
|
|
||||||
flen = trap_FS_FOpenFile(path, &f, FS_READ);
|
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);
|
LUA_LOG("Lua: can not open file %s\n", path);
|
||||||
CG_Printf(S_COLOR_YELLOW "Lua: can not open file %s\n", path);
|
CG_Printf(S_COLOR_YELLOW "Lua: can not open file %s\n", path);
|
||||||
|
|
|
@ -1596,7 +1596,7 @@ void CG_LoadObjectivesForMap(void)
|
||||||
|
|
||||||
len = trap_FS_FOpenFile( fullFileName, &f, FS_READ );
|
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_LocLogger(LL_ERROR, "CG_LoadObjectivesForMap : %s file bigger than %d!\n", fileName, MAX_OBJ_TEXT_LENGTH );
|
||||||
CG_LogFuncEnd();
|
CG_LogFuncEnd();
|
||||||
|
@ -1669,6 +1669,10 @@ qboolean CG_LoadClasses( void )
|
||||||
|
|
||||||
file_len = trap_FS_FOpenFile( filePath, &f, FS_READ );
|
file_len = trap_FS_FOpenFile( filePath, &f, FS_READ );
|
||||||
|
|
||||||
|
if (f == 0) {
|
||||||
|
return qfalse; // TODO logging
|
||||||
|
}
|
||||||
|
|
||||||
if ( !file_len )
|
if ( !file_len )
|
||||||
{
|
{
|
||||||
CG_LocLogger(LL_ERROR, "Couldn't find class file: %s\n", filePath );
|
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 );
|
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'
|
//It's assumed most maps won't have this feature, so just exit 'gracefully'
|
||||||
if ( file_len<=1 )
|
if ( file_len<=1 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -884,7 +884,7 @@ static void G_LoadTimedMessages(void) {
|
||||||
G_LogFuncBegin();
|
G_LogFuncBegin();
|
||||||
|
|
||||||
len = trap_FS_FOpenFile("timedmessages.cfg", &f, FS_READ);
|
len = trap_FS_FOpenFile("timedmessages.cfg", &f, FS_READ);
|
||||||
if (len == 0) {
|
if (f == 0) {
|
||||||
G_LogFuncEnd();
|
G_LogFuncEnd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -969,7 +969,7 @@ static void G_LoadHolodeckFile(void) {
|
||||||
|
|
||||||
free(info);
|
free(info);
|
||||||
|
|
||||||
if (file_len == 0) {
|
if (f == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1102,7 +1102,7 @@ static void G_LoadServerChangeFile(void) {
|
||||||
|
|
||||||
file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ);
|
file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ);
|
||||||
|
|
||||||
if (file_len == 0) {
|
if (f == 0) {
|
||||||
G_LogFuncEnd();
|
G_LogFuncEnd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1233,7 @@ static void G_LoadMapChangeFile(void) {
|
||||||
|
|
||||||
file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ);
|
file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ);
|
||||||
|
|
||||||
if (file_len == 0) {
|
if (f == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1352,7 +1352,7 @@ static void G_LoadLocationsFile(void) {
|
||||||
|
|
||||||
free(serverInfo);
|
free(serverInfo);
|
||||||
|
|
||||||
if (file_len <= 0) {
|
if (f <= 0) {
|
||||||
G_LogFuncEnd();
|
G_LogFuncEnd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ void G_Weapon_LoadConfig(void) {
|
||||||
G_LogFuncBegin();
|
G_LogFuncBegin();
|
||||||
|
|
||||||
len = trap_FS_FOpenFile("weapon.cfg", &f, FS_READ);
|
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_LocLogger(LL_ERROR, "weapon.cfg not found or empty! Using defaults.\n");
|
||||||
G_Weapon_DefaultConfig();
|
G_Weapon_DefaultConfig();
|
||||||
G_LogFuncEnd();
|
G_LogFuncEnd();
|
||||||
|
@ -2649,7 +2649,7 @@ static double G_Weapon_ShotSize(int32_t wp_num) {
|
||||||
case WP_4:
|
case WP_4:
|
||||||
case WP_5:
|
case WP_5:
|
||||||
case WP_6:
|
case WP_6:
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2677,7 +2677,7 @@ static double G_Weapon_AltShotSize(int32_t wp_num) {
|
||||||
case WP_2:
|
case WP_2:
|
||||||
case WP_3:
|
case WP_3:
|
||||||
case WP_4:
|
case WP_4:
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2135,7 +2135,7 @@ static void AdminAudio_InitFilesList(void)
|
||||||
/* First step: Parse in the config where we store all our file dirs */
|
/* First step: Parse in the config where we store all our file dirs */
|
||||||
strLen = trap_FS_FOpenFile("ext_data/audioFileRoutes.dat", &f, FS_READ);
|
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");
|
UI_Logger(LL_ERROR, "ext_data/audioFileRoutes.dat could not be found.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2910,7 +2910,7 @@ void UI_LanguageFilename(char *baseName, char *baseExtension, char *finalName)
|
||||||
/* Attempt to load the file */
|
/* Attempt to load the file */
|
||||||
trap_FS_FOpenFile(finalName, &file, FS_READ);
|
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 */
|
Com_sprintf(finalName, MAX_QPATH, "%s.%s", baseName, baseExtension); /* the caller will give the error if this isn't there */
|
||||||
}
|
}
|
||||||
|
|
|
@ -1231,7 +1231,7 @@ static void PlayerModel_BuildList(void)
|
||||||
|
|
||||||
//UI_Logger( LL_DEBUG, "File %s loaded.\n", dirptr );
|
//UI_Logger( LL_DEBUG, "File %s loaded.\n", dirptr );
|
||||||
|
|
||||||
if (!fileLength) {
|
if (fileLength <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//UI_Logger( LL_DEBUG, "We have length.\n" );
|
//UI_Logger( LL_DEBUG, "We have length.\n" );
|
||||||
|
|
Loading…
Reference in a new issue