]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add support for networking a temporary low quality server banner via WritePicture...
authorterencehill <piuntn@gmail.com>
Mon, 9 Sep 2013 16:50:46 +0000 (18:50 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 9 Sep 2013 16:50:46 +0000 (18:50 +0200)
commands.cfg
qcsrc/client/Main.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/command/cmd.qc

index dca2334bc745a8a1a0f1cb869aec1b1ede7b5d4c..58f216aa82400ea4c027104cea5e754717c56b3f 100644 (file)
@@ -146,6 +146,7 @@ seta cl_autoswitch 1 "automatically switch to newly picked up weapons if they ar
 alias autoswitch           "qc_cmd_cmd    autoswitch           ${* ?}" // Whether or not to switch automatically when getting a better weapon
 alias checkfail            "qc_cmd_cmd    checkfail            ${* ?}" // Report if a client-side check failed
 alias clientversion        "qc_cmd_cmd    clientversion        ${* ?}" // Release version of the game
+//alias getserverpic       "qc_cmd_cmd    getserverpic         ${* ?}" // Retrieve server banner from the server
 //alias mv_getpicture      "qc_cmd_cmd    mv_getpicture        ${* ?}" // Retrieve mapshot picture from the server
 alias join                 "qc_cmd_cmd    join                 ${* ?}" // Become a player in the game
 alias ready                "qc_cmd_cmd    ready                ${* ?}" // Qualify as ready to end warmup stage (or restart server if allowed)
index 97afd14334b7669b94433a1751542c01b56f53d8..edc1a6fb098b61bb248ae7adbdb3ca4bc189ad6e 100644 (file)
@@ -1193,14 +1193,33 @@ void Net_ReadServerInfo()
        if(welcomedialog_args)
                strunzone(welcomedialog_args);
        welcomedialog_args = strcat("name \"", ReadString(), "\"");
-       welcomedialog_args = strcat(welcomedialog_args, "ip \"", ReadString(), "\"");
-       welcomedialog_args = strcat(welcomedialog_args, "motd \"", MakeConsoleSafe(strreplace("\n", "\\n", ReadString())), "\"");
+       welcomedialog_args = strcat(welcomedialog_args, " ip \"", ReadString(), "\"");
+       welcomedialog_args = strcat(welcomedialog_args, " motd \"", MakeConsoleSafe(strreplace("\n", "\\n", ReadString())), "\"");
        string pic = ReadString();
-       if(pic != "")
-               welcomedialog_args = strcat(welcomedialog_args, "pic \"", pic, "\"");
-       localcmd("\nmenu_cmd directmenu Welcome ", welcomedialog_args, "\n");
-       welcomedialog_args = string_null;
-       return;
+       if(pic == "" || PreviewExists(pic) )
+       {
+               if(pic != "")
+                       welcomedialog_args = strcat(welcomedialog_args, " pic \"", pic, "\"");
+               localcmd("\nmenu_cmd directmenu Welcome ", welcomedialog_args, "\n");
+               welcomedialog_args = string_null;
+               return;
+       } else {
+               welcomedialog_args = strzone(welcomedialog_args);
+               print(_("Requesting server banner...\n"));
+               localcmd("\ncmd getserverpic\n");
+       }
+}
+
+void Net_ReadServerInfo_Pic()
+{
+       if(welcomedialog_args)
+       {
+               localcmd("\nmenu_cmd directmenu Welcome ", strcat(welcomedialog_args, " pic \"", ReadPicture(), "\""), "\n");
+               strunzone(welcomedialog_args);
+               welcomedialog_args = string_null;
+       }
+       else // just get the image, we don't want to display the welcome dialog
+               ReadPicture();
 }
 
 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
@@ -1268,6 +1287,10 @@ float CSQC_Parse_TempEntity()
                        Net_ReadServerInfo();
                        bHandled = true;
                        break;
+               case TE_CSQC_SERVERINFO_PIC:
+                       Net_ReadServerInfo_Pic();
+                       bHandled = true;
+                       break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;
index 8e2f9544a9259be546fbd8cc3e7f35756c55689a..e769ad88a4a3853c4bd521ec94b77198dadced1f 100644 (file)
@@ -43,6 +43,7 @@ const float TE_CSQC_HAGAR_MAXROCKETS = 111;
 const float TE_CSQC_VEHICLESETUP = 112;
 const float TE_CSQC_SVNOTICE = 113;
 const float TE_CSQC_SERVERINFO = 114;
+const float TE_CSQC_SERVERINFO_PIC = 115;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
index 6ce80df789f37a0a3a46133c93ab5bd74723edc2..83ca126fe9f4098c0b030768cb332a39e5baa6f6 100644 (file)
@@ -726,7 +726,7 @@ void DecodeLevelParms (void)
        self.parm_idlesince = max(self.parm_idlesince, time - sv_maxidle + 60);
 }
 
-void MOTD_send()
+void serverinfo_welcomemessage_send()
 {
        msg_entity = self;
        WriteByte(MSG_ONE, SVC_TEMPENTITY);
@@ -734,6 +734,15 @@ void MOTD_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"));
+}
+
+void serverinfo_pic_send()
+{
+       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);
 }
 
 /*
@@ -1236,7 +1245,7 @@ void ClientConnect (void)
 
        if(IS_REAL_CLIENT(self))
        {
-               MOTD_send();
+               serverinfo_welcomemessage_send();
                sv_notice_join();
        }
 
index ec9c33b1987b093005f28c5df16c062d3d9e9c65..facdaa22c7676990ef3a43da6bd41b114053834b 100644 (file)
@@ -116,6 +116,26 @@ void ClientCommand_clientversion(float request, float argc) // internal command,
        }
 }
 
+void ClientCommand_getserverpic(float request) // internal command, used only by code
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       serverinfo_pic_send();
+                       return;
+               }
+
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       sprint(self, "\nUsage:^3 cmd getserverpic\n");
+                       sprint(self, "  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
 void ClientCommand_mv_getpicture(float request, float argc) // internal command, used only by code
 {
        switch(request)
@@ -563,6 +583,7 @@ void ClientCommand_(float request)
        CLIENT_COMMAND("checkfail", ClientCommand_checkfail(request, command), "Report if a client-side check failed") \
        CLIENT_COMMAND("clientversion", ClientCommand_clientversion(request, arguments), "Release version of the game") \
        CLIENT_COMMAND("mv_getpicture", ClientCommand_mv_getpicture(request, arguments), "Retrieve mapshot picture from the server") \
+       CLIENT_COMMAND("getserverpic", ClientCommand_getserverpic(request), "Retrieve server banner from the server") \
        CLIENT_COMMAND("join", ClientCommand_join(request), "Become a player in the game") \
        CLIENT_COMMAND("ready", ClientCommand_ready(request), "Qualify as ready to end warmup stage (or restart server if allowed)") \
        CLIENT_COMMAND("say", ClientCommand_say(request, arguments, command), "Print a message to chat to all players") \
@@ -649,6 +670,7 @@ void SV_ParseClientCommand(string command)
                // exempt commands which are not subject to floodcheck
                case "begin": break; // handled by engine in host_cmd.c
                case "download": break; // handled by engine in cl_parse.c
+               case "getserverpic": break; // handled by server in this file
                case "mv_getpicture": break; // handled by server in this file
                case "pause": break; // handled by engine in host_cmd.c
                case "prespawn": break; // handled by engine in host_cmd.c