Merge in xonotic/xonotic-data.pk3dir.git: terencehill/fexists
git-manager created issue #376 (closed) on 2011-04-03T14:34:07Z:
Reason of request:
This is a code cleanup, for the description please read the unique commit description
Repository: xonotic/xonotic-data.pk3dir.git Commit: 80811920 Branch: terencehill/fexists
Merge commands:
cd data/xonotic-data.pk3dir
git checkout master
git reset --hard origin/master
git pull && git diff '80811920732c5756699249adb24ed8d241699d73'..'origin/terencehill/fexists'
git merge --no-ff 'origin/terencehill/fexists'
git push && git push --delete origin 'terencehill/fexists'
Diffstat:
qcsrc/client/miscfunctions.qc | 33 +++++----------------------------
qcsrc/common/gamecommand.qc | 19 ++++++-------------
qcsrc/common/mapinfo.qc | 6 +-----
qcsrc/common/util.qc | 10 ++++++++++
qcsrc/common/util.qh | 2 ++
qcsrc/menu/xonotic/util.qc | 10 +++-------
qcsrc/server/g_world.qc | 17 +----------------
qcsrc/server/miscfunctions.qc | 10 ----------
8 files changed, 28 insertions(+), 79 deletions(-)
Revision log:
commit 80811920732c5756699249adb24ed8d241699d73
Author: terencehill
Commit: terencehill
Move fexists from server/miscfunctions.qc to common/util.qc so that it's available in csqc and menu too; use it when possible
Remove from server/g_world.qc the never called function TryFile, which is a copy of fexists
User agreed to the GPLv2*.
Diff:
<pre>diff —git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc
index d38b7c9..1b1eaad 100644
— a/qcsrc/client/miscfunctions.qc
**+ b/qcsrc/client/miscfunctions.qc
@ -325,34 +325,11
@ float PreviewExists
if
return false;
- file = strcat;
- f = fopen;
- if
- {
- fclose;
- return true;
- }
- file = strcat;
- f = fopen;
- if
- {
- fclose;
- return true;
- }
- file = strcat;
- f = fopen;
- if
- {
- fclose;
- return true;
- }
- file = strcat;
- f = fopen;
- if
- {
- fclose;
- 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; }
diff —git a/qcsrc/common/gamecommand.qc b/qcsrc/common/gamecommand.qc
index 3b93c4c..518cf74 100644
— a/qcsrc/common/gamecommand.qc
**+ b/qcsrc/common/gamecommand.qc
@ -210,10 +210,8
@ float GameCommand_Generic
{
if "add" && argc 3)
{
- f = fopen, “.bsp”), FILE_READ);
- if
- fclose;
- else {
- if , “.bsp”)))
- {
print(“maplist: ERROR:”, argv(2), " does not exist!“);
return TRUE;
}
@ -771,10 +769,8
@ float GameCommand_Generic(string command) 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!“);
rpn_error = TRUE;
}
@ -783,14 +779,11
@ float GameCommand_Generic(string command) 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()));
} else if(rpncmd ”gmtime“) {
diff —git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc
index 58f0cc8..a6b0788 100644
— a/qcsrc/common/mapinfo.qc
**+ b/qcsrc/common/mapinfo.qc
@ -875,12 +875,8
@ float MapInfo_Get_ByName fputs, _MapInfo_GetDefaultEx)); - fh2 = fopen, FILE_READ);
- if
- {
- fclose;
- if)) fputs;
- }
fputs;
fputs cvarname value\n");
diff —git a/qcsrc/common/util.qc b/qcsrc/common/util.qc
index fc86c3a..05152d4 100644
— a/qcsrc/common/util.qc
**+ b/qcsrc/common/util.qc
@ -236,6 +236,16
@ string fstrunzone 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)
diff —git a/qcsrc/common/util.qh b/qcsrc/common/util.qh
index a158557..c3ae491 100644
— a/qcsrc/common/util.qh
**+ b/qcsrc/common/util.qh
@ -34,6 +34,8
@ float median;
// works for up to 10 decimals!
string ftos_decimals;
*float fexists;
*
vector colormapPaletteColor(float c, float isPants);
// unzone the string, and return it as tempstring. Safe to be called on string_null
diff —git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc
index 1d21ba4..c24693e 100644
— a/qcsrc/menu/xonotic/util.qc
**+ b/qcsrc/menu/xonotic/util.qc
@ -474,15 +474,11
@ string HUD_Panel_GetSettingName
float updateCompression
{
- float fh; float have_dds, have_jpg, have_tga; float can_dds;
- if) >= 0)))
- fclose;
- if) >= 0)))
- fclose;
- if) >= 0)))
- fclose;
- have_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))
{
diff —git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc
index 4c41852..5cfe2fb 100644
— a/qcsrc/server/g_world.qc
**+ b/qcsrc/server/g_world.qc
@ -940,19 +940,6
@ void spawnfunc_light remove; } ~~float TryFile ~~{
- local float lHandle;
- dprint“);
- lHandle = fopen( pFilename, FILE_READ );
- if( lHandle != ~~1 ) { ~~ fclose( lHandle );
- return TRUE;
- } else {
- return FALSE;
- }
~~};
~~
string GetGametype()
{
return GametypeNameFromType(game);
@ -996,14 +983,12
@ float MapHasRightSize(string map) 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;
}
// open map size restriction file
diff —git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc
index 4cf479f..c424bc7 100644
— a/qcsrc/server/miscfunctions.qc
**+ b/qcsrc/server/miscfunctions.qc
@ -625,16 +625,6
@ void GetCvars(float f) } }
~~float fexists ~~{
- float fh;
- fh = fopen(f, FILE_READ);
- if (fh < 0)
- return FALSE;
- fclose(fh);
- return TRUE; ~~} ~~ void backtrace(string msg) { float dev, war;