From fcb13333c801783eef28e963c5699082beab6b24 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 8 Mar 2015 18:20:00 +0100 Subject: [PATCH] Make sure banner image exists --- gfx/menu/luma/skinvalues.txt | 3 ++- qcsrc/common/util.qc | 10 ++++++++++ qcsrc/common/util.qh | 1 + qcsrc/menu/command/menu_cmd.qc | 2 +- qcsrc/menu/xonotic/dialog_welcome.qc | 2 +- qcsrc/menu/xonotic/textlistbox.qc | 2 +- qcsrc/server/cl_client.qc | 16 ++++++++++++++-- 7 files changed, 30 insertions(+), 6 deletions(-) diff --git a/gfx/menu/luma/skinvalues.txt b/gfx/menu/luma/skinvalues.txt index 1e87e8869..2487582cb 100644 --- a/gfx/menu/luma/skinvalues.txt +++ b/gfx/menu/luma/skinvalues.txt @@ -90,9 +90,10 @@ COLOR_DIALOG_VIEW '1 1 1' COLOR_DIALOG_MODEL '1 1 1' COLOR_DIALOG_CROSSHAIR '1 1 1' COLOR_DIALOG_HUD '1 1 1' -COLOR_DIALOG_SCREENSHOTVIEWER '1 1 1' COLOR_DIALOG_SERVERINFO '1 1 1' +COLOR_DIALOG_SCREENSHOTVIEWER '1 1 1' COLOR_DIALOG_FIRSTRUN '1 1 1' +COLOR_DIALOG_WELCOME '1 1 1' COLOR_DIALOG_CVARS '1 0.2 0.15' COLOR_DIALOG_HUDCONFIRM '1 0.2 0.15' diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 99fecda0b..861543ee3 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -280,6 +280,16 @@ bool fexists(string f) return true; } +bool ImageExists(string img) +{ + if(fexists(strcat(img, ".tga"))) return true; + if(fexists(strcat(img, ".png"))) return true; + if(fexists(strcat(img, ".jpg"))) return true; + if(fexists(strcat(img, ".pcx"))) return true; + + return false; +} + // Databases (hash tables) const float DB_BUCKETS = 8192; void db_save(float db, string pFilename) diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 4de610f26..e28a38626 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -75,6 +75,7 @@ float median(float a, float b, float c); string ftos_decimals(float number, float decimals); bool fexists(string f); +bool ImageExists(string img); vector colormapPaletteColor(float c, float isPants); diff --git a/qcsrc/menu/command/menu_cmd.qc b/qcsrc/menu/command/menu_cmd.qc index dac57f34a..5eecda0e2 100644 --- a/qcsrc/menu/command/menu_cmd.qc +++ b/qcsrc/menu/command/menu_cmd.qc @@ -63,7 +63,7 @@ void GameCommand(string theCommand) if(argv(0) == "directmenu" || argv(0) == "directpanelhudmenu") { - float i; + int i; entity e; string s; string filter = string_null; diff --git a/qcsrc/menu/xonotic/dialog_welcome.qc b/qcsrc/menu/xonotic/dialog_welcome.qc index 49c9ab4e8..b99f81be4 100644 --- a/qcsrc/menu/xonotic/dialog_welcome.qc +++ b/qcsrc/menu/xonotic/dialog_welcome.qc @@ -47,7 +47,7 @@ void XonoticWelcomeDialog_configureDialog(entity me) } void XonoticWelcomeDialog_readInputArgs(entity me, float argsbuf) { - float i = 0; + int i = 0; string s; welcomeDialog_resetStrings(me); while((s = bufstr_get(argsbuf, i)) != "") diff --git a/qcsrc/menu/xonotic/textlistbox.qc b/qcsrc/menu/xonotic/textlistbox.qc index c42754d3b..48451ee1f 100644 --- a/qcsrc/menu/xonotic/textlistbox.qc +++ b/qcsrc/menu/xonotic/textlistbox.qc @@ -51,7 +51,7 @@ void XonoticTextListBox_resizeNotify(entity me, vector relOrigin, vector relSize } void XonoticTextListBox_setText(entity me, string theText) { - float i, k; + int i, k; string ts; if(me.textbuf >= 0) buf_del(me.textbuf); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 6111527a1..133d2a669 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -774,15 +774,27 @@ void serverinfo_welcomemessage_send() WriteString(MSG_ONE, "128.03.192.999"); // FIXME: send the real server ip WriteString(MSG_ONE, autocvar_hostname); WriteString(MSG_ONE, getwelcomemessage()); - WriteString(MSG_ONE, strcat("128.03.192.999", "/banner")); + string pic = strcat("128.03.192.999", "/banner"); + if(ImageExists(pic)) + { + print("Warning: image %s doesn't exist!\n", pic); + pic = ""; + } + WriteString(MSG_ONE, pic); } void serverinfo_pic_send() { + string pic = strcat("128.03.192.999", "/banner"); + if(ImageExists(pic)) + { + print("Cannot send %s, file doesn't exist!\n", pic); + return; + } msg_entity = self; WriteByte(MSG_ONE, SVC_TEMPENTITY); WriteByte(MSG_ONE, TE_CSQC_SERVERINFO_PIC); - WritePicture(MSG_ONE, strcat("128.03.192.999", "/banner"), 3072); + WritePicture(MSG_ONE, pic, 3072); } /* -- 2.39.2