]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - libcurl.c
change a few WIN64 checks to _WIN64 (which actually works), and remove
[xonotic/darkplaces.git] / libcurl.c
index 141086ae0bef4da54297b179f01f92034610a7f3..9824a46a32e490a450a5126e3afd6c4d588a6d6a 100644 (file)
--- a/libcurl.c
+++ b/libcurl.c
@@ -318,9 +318,7 @@ static qboolean CURL_OpenLibrary (void)
 {
        const char* dllnames [] =
        {
-#if defined(WIN64)
-               "libcurl64.dll",
-#elif defined(WIN32)
+#if defined(WIN32)
                "libcurl-4.dll",
                "libcurl-3.dll",
 #elif defined(MACOSX)
@@ -695,10 +693,31 @@ static qboolean Curl_Begin(const char *URL, const char *name, qboolean ispak, qb
        else
        {
                char fn[MAX_OSPATH];
+               char urlbuf[1024];
                const char *p, *q;
                size_t length;
                downloadinfo *di;
 
+               // if URL is protocol:///* or protocol://:port/*, insert the IP of the current server
+               p = strchr(URL, ':');
+               if(p)
+               {
+                       if(!strncmp(p, ":///", 4) || !strncmp(p, "://:", 4))
+                       {
+                               char addressstring[128];
+                               *addressstring = 0;
+                               InfoString_GetValue(cls.userinfo, "*ip", addressstring, sizeof(addressstring));
+                               q = strchr(addressstring, ':');
+                               if(!q)
+                                       q = addressstring + strlen(addressstring);
+                               if(*addressstring)
+                               {
+                                       dpsnprintf(urlbuf, sizeof(urlbuf), "%.*s://%.*s%s", (int) (p - URL), URL, (int) (q - addressstring), addressstring, URL + (p - URL) + 3);
+                                       URL = urlbuf;
+                               }
+                       }
+               }
+
                // Note: This extraction of the file name portion is NOT entirely correct.
                //
                // It does the following: