Remove from server/g_world.qc the never called function TryFile, which is a copy of fexists
if(autocvar_cl_readpicture_force)
return false;
- file = strcat(name, ".tga");
- f = fopen(file, FILE_READ);
- if(f >= 0)
- {
- fclose(f);
- return true;
- }
- file = strcat(name, ".png");
- f = fopen(file, FILE_READ);
- if(f >= 0)
- {
- fclose(f);
- return true;
- }
- file = strcat(name, ".jpg");
- f = fopen(file, FILE_READ);
- if(f >= 0)
- {
- fclose(f);
- return true;
- }
- file = strcat(name, ".pcx");
- f = fopen(file, FILE_READ);
- if(f >= 0)
- {
- fclose(f);
- return true;
- }
+ if (fexists(strcat(name, ".tga"))) return true;
+ if (fexists(strcat(name, ".png"))) return true;
+ if (fexists(strcat(name, ".jpg"))) return true;
+ if (fexists(strcat(name, ".pcx"))) return true;
+
return false;
}
{
if(argv(1) == "add" && argc == 3)
{
- f = fopen(strcat("maps/", argv(2), ".bsp"), FILE_READ);
- if(f != -1)
- fclose(f);
- else {
+ if (!fexists(strcat("maps/", argv(2), ".bsp")))
+ {
print("maplist: ERROR: ", argv(2), " does not exist!\n");
return TRUE;
}
s = rpn_pop();
if(!rpn_error)
{
- f = fopen(s, FILE_READ);
- if(f != -1)
- fclose(f);
- else {
+ if (!fexists(s))
+ {
print("rpn: ERROR: ", s, " does not exist!\n");
rpn_error = TRUE;
}
s = rpn_get();
if(!rpn_error)
{
- f = fopen(s, FILE_READ);
- if(f != -1) {
- fclose(f);
+ if (fexists(s))
rpn_setf(1);
- } else {
+ else
rpn_setf(0);
- }
}
} else if(rpncmd == "localtime") {
rpn_set(strftime(TRUE, rpn_get()));
if(MapInfo_Map_supportedGametypes & i)
fputs(fh, sprintf("gametype %s // defaults: %s\n", MapInfo_Type_ToString(i), _MapInfo_GetDefaultEx(i)));
- fh2 = fopen(strcat("scripts/", pFilename, ".arena"), FILE_READ);
- if(fh2 >= 0)
- {
- fclose(fh2);
+ if(fexists(strcat("scripts/", pFilename, ".arena")))
fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n");
- }
fputs(fh, "// optional: fog density red green blue alpha mindist maxdist\n");
fputs(fh, "// optional: settemp_for_type (all|gametypename) cvarname value\n");
return sc;
}
+float fexists(string f)
+{
+ float fh;
+ fh = fopen(f, FILE_READ);
+ if (fh < 0)
+ return FALSE;
+ fclose(fh);
+ return TRUE;
+}
+
// Databases (hash tables)
#define DB_BUCKETS 8192
void db_save(float db, string pFilename)
// works for up to 10 decimals!
string ftos_decimals(float number, float decimals);
+float fexists(string f);
+
vector colormapPaletteColor(float c, float isPants);
// unzone the string, and return it as tempstring. Safe to be called on string_null
float updateCompression()
{
- float fh;
float have_dds, have_jpg, have_tga;
float can_dds;
- if((have_dds = ((fh = fopen("dds/particles/particlefont.dds", FILE_READ)) >= 0)))
- fclose(fh);
- if((have_jpg = ((fh = fopen("particles/particlefont.jpg", FILE_READ)) >= 0)))
- fclose(fh);
- if((have_tga = ((fh = fopen("particles/particlefont.tga", FILE_READ)) >= 0)))
- fclose(fh);
+ have_dds = (fexists("dds/particles/particlefont.dds"));
+ have_dds = (fexists("particles/particlefont.jpg"));
+ have_dds = (fexists("particles/particlefont.tga"));
can_dds = GL_Have_TextureCompression();
if(have_dds && (have_jpg || have_tga))
{
remove(self);
}
-float TryFile( string pFilename )
-{
- local float lHandle;
- dprint("TryFile(\"", pFilename, "\")\n");
- lHandle = fopen( pFilename, FILE_READ );
- if( lHandle != -1 ) {
- fclose( lHandle );
- return TRUE;
- } else {
- return FALSE;
- }
-};
-
string GetGametype()
{
return GametypeNameFromType(game);
if(autocvar_g_maplist_check_waypoints)
{
dprint("checkwp "); dprint(map);
- fh = fopen(strcat("maps/", map, ".waypoints"), FILE_READ);
- if(fh < 0)
+ if(!fexists(strcat("maps/", map, ".waypoints")))
{
dprint(": no waypoints\n");
return FALSE;
}
dprint(": has waypoints\n");
- fclose(fh);
}
// open map size restriction file
}
}
-float fexists(string f)
-{
- float fh;
- fh = fopen(f, FILE_READ);
- if (fh < 0)
- return FALSE;
- fclose(fh);
- return TRUE;
-}
-
void backtrace(string msg)
{
float dev, war;