]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
web download patch from div0, this adds the "curl" console command, and the ability...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 9 Jun 2006 02:03:34 +0000 (02:03 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 9 Jun 2006 02:03:34 +0000 (02:03 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6443 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
cl_screen.c
host.c
host_cmd.c
makefile.inc
model_shared.c
model_shared.h
sv_main.c

index e77ea64aef7e77f3b105a9274ec6bc0776996bf1..215cea560ee31831d5acec27c85e4c219850e8f3 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "image.h"
 #include "csprogs.h"
 #include "r_shadow.h"
+#include "libcurl.h"
 
 // we need to declare some mouse variables here, because the menu system
 // references them even when on a unix system.
@@ -395,6 +396,9 @@ void CL_EstablishConnection(const char *host)
        // stop demo loop in case this fails
        CL_Disconnect();
 
+       // if downloads are running, cancel their finishing action
+       Curl_Clear_forthismap();
+
        // make sure the client ports are open before attempting to connect
        NetConn_UpdateSockets();
 
index a4069c250d85defb42bc13ea62fa3655113df9fb..c35d11393a89bd9c3a0cba4b296e82a1fc92c08f 100644 (file)
@@ -4,6 +4,7 @@
 #include "image.h"
 #include "jpeg.h"
 #include "cl_collision.h"
+#include "libcurl.h"
 #include "csprogs.h"
 
 cvar_t scr_viewsize = {CVAR_SAVE, "viewsize","100", "how large the view should be, 110 disables inventory bar, 120 disables status bar"};
@@ -303,27 +304,88 @@ void SCR_DrawBrand (void)
 
 /*
 ==============
-SCR_DrawDownload
+SCR_DrawQWDownload
 ==============
 */
-static void SCR_DrawDownload(void)
+static int SCR_DrawQWDownload(int offset)
 {
        int len;
        float x, y;
        float size = 8;
        char temp[256];
        if (!cls.qw_downloadname[0])
-               return;
+               return 0;
        dpsnprintf(temp, sizeof(temp), "Downloading %s ...  %3i%%\n", cls.qw_downloadname, cls.qw_downloadpercent);
        len = (int)strlen(temp);
        x = (vid_conwidth.integer - len*size) / 2;
-       y = vid_conheight.integer - size;
+       y = vid_conheight.integer - size - offset;
        DrawQ_Pic(0, y, NULL, vid_conwidth.integer, size, 0, 0, 0, 0.5, 0);
        DrawQ_String(x, y, temp, len, size, size, 1, 1, 1, 1, 0);
+       return 8;
 }
 
-//=============================================================================
+/*
+==============
+SCR_DrawCurlDownload
+==============
+*/
+static int SCR_DrawCurlDownload(int offset)
+{
+       int len;
+       int nDownloads;
+       int i;
+       float x, y;
+       float size = 8;
+       Curl_downloadinfo_t *downinfo;
+       char temp[256];
+       const char *addinfo;
+
+       downinfo = Curl_GetDownloadInfo(&nDownloads, &addinfo);
+       if(!downinfo)
+               return 0;
+
+       y = vid_conheight.integer - size * nDownloads - offset;
+
+       if(addinfo)
+       {
+               len = (int)strlen(addinfo);
+               x = (vid_conwidth.integer - len*size) / 2;
+               DrawQ_Pic(0, y - size, NULL, vid_conwidth.integer, size, 1, 1, 1, 0.8, 0);
+               DrawQ_String(x, y - size, addinfo, len, size, size, 0, 0, 0, 1, 0);
+       }
+
+       for(i = 0; i != nDownloads; ++i)
+       {
+               if(downinfo[i].queued)
+                       dpsnprintf(temp, sizeof(temp), "Still in queue: %s\n", downinfo[i].filename);
+               else if(downinfo[i].progress <= 0)
+                       dpsnprintf(temp, sizeof(temp), "Downloading %s ...  ???.?%% @ %.1f KiB/s\n", downinfo[i].filename, downinfo[i].speed / 1024.0);
+               else
+                       dpsnprintf(temp, sizeof(temp), "Downloading %s ...  %5.1f%% @ %.1f KiB/s\n", downinfo[i].filename, 100.0 * downinfo[i].progress, downinfo[i].speed / 1024.0);
+               len = (int)strlen(temp);
+               x = (vid_conwidth.integer - len*size) / 2;
+               DrawQ_Pic(0, y + i * size, NULL, vid_conwidth.integer, size, 0, 0, 0, 0.8, 0);
+               DrawQ_String(x, y + i * size, temp, len, size, size, 1, 1, 1, 1, 0);
+       }
 
+       Z_Free(downinfo);
+
+       return 8 * (nDownloads + (addinfo ? 1 : 0));
+}
+
+/*
+==============
+SCR_DrawDownload
+==============
+*/
+static void SCR_DrawDownload()
+{
+       int offset = 0;
+       offset += SCR_DrawQWDownload(offset);
+       offset += SCR_DrawCurlDownload(offset);
+}
+
+//=============================================================================
 
 /*
 ==================
diff --git a/host.c b/host.c
index 84ff2d427295257f50e282a5de9d5054673d0e04..23f1a5ec447d03f6f5fff7b18a5d3f47a17f778e 100644 (file)
--- a/host.c
+++ b/host.c
@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <time.h>
 #include "quakedef.h"
+#include "libcurl.h"
 #include "cdaudio.h"
 #include "cl_video.h"
 #include "progsvm.h"
@@ -619,6 +620,8 @@ void Host_Main(void)
 
                NetConn_UpdateSockets();
 
+               Curl_Run();
+
        //-------------------
        //
        // server operations
@@ -922,6 +925,7 @@ static void Host_Init (void)
        // initialize various cvars that could not be initialized earlier
        Memory_Init_Commands();
        Con_Init_Commands();
+       Curl_Init_Commands();
        Cmd_Init_Commands();
        Sys_Init_Commands();
        COM_Init_Commands();
@@ -932,6 +936,7 @@ static void Host_Init (void)
        Mathlib_Init();
 
        NetConn_Init();
+       Curl_Init();
        //PR_Init();
        //PR_Cmd_Init();
        PRVM_Init();
@@ -1086,6 +1091,7 @@ void Host_Shutdown(void)
 
        CDAudio_Shutdown ();
        S_Terminate ();
+       Curl_Shutdown ();
        NetConn_Shutdown ();
        //PR_Shutdown ();
 
index bf993d67d799bf3f237f5f72c8bd9a86d1eaa523..56864d056c90f4ccd47321d929651f4ce77f67d0 100644 (file)
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
 #include "quakedef.h"
+#include "libcurl.h"
 
 int current_skill;
 cvar_t sv_cheats = {0, "sv_cheats", "0", "enables cheat commands in any game, and cheat impulses in dpmod"};
@@ -1513,6 +1514,8 @@ void Host_Begin_f (void)
                return;
        }
 
+       Curl_SendRequirements();
+
        host_client->spawned = true;
 }
 
index bcb9764dd05ff0d5b0247281403086ea2738b4ad..8a455a2e62854ca1067053b81d4b9d0c6195a3f1 100644 (file)
@@ -54,6 +54,7 @@ OBJ_NOCD=cd_null.o
 
 # Common objects
 OBJ_COMMON= \
+       libcurl.o \
        cd_shared.o \
        cl_collision.o \
        cl_demo.o \
index 8b2333f48e01d19c3153cb4e765cbbd719e8b80c..4e4116483dda6ac337efe2e72a765269d17d8015 100644 (file)
@@ -344,6 +344,24 @@ model_t *Mod_ForName(const char *name, qboolean crash, qboolean checkdisk, qbool
        return model;
 }
 
+/*
+==================
+Mod_Reload
+
+Reloads all models if they have changed
+==================
+*/
+void Mod_Reload()
+{
+       int i;
+       model_t *mod;
+
+       for (i = 0, mod = mod_known;i < mod_numknown;i++, mod++)
+               if (mod->name[0])
+                       if (mod->used)
+                               Mod_LoadModel(mod, true, true, mod->isworldmodel);
+}
+
 unsigned char *mod_base;
 
 
index e12da96be416dc36d2301e1ce185f00ab039312e..4b539e2341590b0c415dc4776e64d00b8e3531c7 100644 (file)
@@ -603,6 +603,7 @@ extern unsigned char *mod_base;
 extern cvar_t r_fullbrights;
 
 void Mod_Init (void);
+void Mod_Reload (void);
 model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
 model_t *Mod_FindName (const char *name);
 model_t *Mod_ForName (const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
index 2efbb8895127c36094a638d4225719bec70375cb..2e45d00f0931382a9e373c1509587c43aaf3a375 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // sv_main.c -- server main program
 
 #include "quakedef.h"
+#include "libcurl.h"
 
 void SV_VM_Init();
 void SV_VM_Setup();
@@ -1677,6 +1678,10 @@ void SV_SpawnServer (const char *server)
 
        svs.changelevel_issued = false;         // now safe to issue another
 
+       // make the map a required file for clients
+       Curl_ClearRequirements();
+       Curl_RequireFile(modelname);
+
 //
 // tell all connected clients that we are going to a new level
 //