]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
because gethostbyname("0.0.0.0") fails in windows, the fallback was being called...
[xonotic/darkplaces.git] / common.c
index 6363ad1e2fa39998754c67ad5d00a557d7c4fcb9..4aa67becb9361c06e3424c1ad1e484257406c785 100644 (file)
--- a/common.c
+++ b/common.c
@@ -339,7 +339,7 @@ char *MSG_ReadString (void)
 {
        static char string[2048];
        int l,c;
-       for (l = 0;l < sizeof(string) - 1 && (c = MSG_ReadChar()) != -1 && c != 0;l++)
+       for (l = 0;l < (int) sizeof(string) - 1 && (c = MSG_ReadChar()) != -1 && c != 0;l++)
                string[l] = c;
        string[l] = 0;
        return string;
@@ -670,21 +670,25 @@ void COM_InitGameType (void)
 
        if (strstr(name, "transfusion"))
                gamemode = GAME_TRANSFUSION;
-       else if (strstr(name, "nexiuz"))
-               gamemode = GAME_NEXIUZ;
+       else if (strstr(name, "nexuiz"))
+               gamemode = GAME_NEXUIZ;
        else if (strstr(name, "nehahra"))
                gamemode = GAME_NEHAHRA;
        else if (strstr(name, "hipnotic"))
                gamemode = GAME_HIPNOTIC;
        else if (strstr(name, "rogue"))
                gamemode = GAME_ROGUE;
+       else if (strstr(name, "goodvsbad2"))
+               gamemode = GAME_GOODVSBAD2;
+       else if (strstr(name, "teu"))
+               gamemode = GAME_TEU;
        else
                gamemode = GAME_NORMAL;
 
        if (COM_CheckParm ("-transfusion"))
                gamemode = GAME_TRANSFUSION;
-       else if (COM_CheckParm ("-nexiuz"))
-               gamemode = GAME_NEXIUZ;
+       else if (COM_CheckParm ("-nexuiz"))
+               gamemode = GAME_NEXUIZ;
        else if (COM_CheckParm ("-nehahra"))
                gamemode = GAME_NEHAHRA;
        else if (COM_CheckParm ("-hipnotic"))
@@ -693,6 +697,10 @@ void COM_InitGameType (void)
                gamemode = GAME_ROGUE;
        else if (COM_CheckParm ("-quake"))
                gamemode = GAME_NORMAL;
+       else if (COM_CheckParm ("-goodvsbad2"))
+               gamemode = GAME_GOODVSBAD2;
+       else if (COM_CheckParm ("-teu"))
+               gamemode = GAME_TEU;
 
        switch(gamemode)
        {
@@ -712,14 +720,22 @@ void COM_InitGameType (void)
                gamename = "DarkPlaces-Nehahra";
                gamedirname = "nehahra";
                break;
-       case GAME_NEXIUZ:
-               gamename = "Nexiuz";
+       case GAME_NEXUIZ:
+               gamename = "Nexuiz";
                gamedirname = "data";
                break;
        case GAME_TRANSFUSION:
                gamename = "Transfusion";
                gamedirname = "transfusion";
                break;
+       case GAME_GOODVSBAD2:
+               gamename = "GoodVs.Bad2";
+               gamedirname = "rts";
+               break;
+       case GAME_TEU:
+               gamename = "TheEvilUnleashed";
+               gamedirname = "teu";
+               break;
        default:
                Sys_Error("COM_InitGameType: unknown gamemode %i\n", gamemode);
                break;
@@ -767,6 +783,7 @@ void COM_Init (void)
        Mathlib_Init();
 
        FS_Init ();
+       Con_InitLogging();
        COM_CheckRegistered ();
 
        COM_InitGameType();
@@ -831,3 +848,66 @@ int COM_StringBeginsWith(const char *s, const char *match)
                        return false;
        return true;
 }
+
+// written by Elric, thanks Elric!
+char *SearchInfostring(const char *infostring, const char *key)
+{
+       static char value [256];
+       char crt_key [256];
+       size_t value_ind, key_ind;
+       char c;
+
+       if (*infostring++ != '\\')
+               return NULL;
+
+       value_ind = 0;
+       for (;;)
+       {
+               key_ind = 0;
+
+               // Get the key name
+               for (;;)
+               {
+                       c = *infostring++;
+
+                       if (c == '\0')
+                               return NULL;
+                       if (c == '\\')
+                       {
+                               crt_key[key_ind] = '\0';
+                               break;
+                       }
+
+                       crt_key[key_ind++] = c;
+               }
+
+               // If it's the key we are looking for, save it in "value"
+               if (!strcmp(crt_key, key))
+               {
+                       for (;;)
+                       {
+                               c = *infostring++;
+
+                               if (c == '\0' || c == '\\')
+                               {
+                                       value[value_ind] = '\0';
+                                       return value;
+                               }
+
+                               value[value_ind++] = c;
+                       }
+               }
+
+               // Else, skip the value
+               for (;;)
+               {
+                       c = *infostring++;
+
+                       if (c == '\0')
+                               return NULL;
+                       if (c == '\\')
+                               break;
+               }
+       }
+}
+