]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
Fix setinfo.
[xonotic/darkplaces.git] / common.c
index 66b7895a2118c2550dabc8f3bef9e77cfb8b1a99..badf4c9ccaca487160a3af26f8d2f3d14fd870df 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1475,6 +1475,7 @@ static const gamemode_info_t gamemode_info [GAME_COUNT] =
 { GAME_STEELSTORM,                             GAME_STEELSTORM,                        "steelstorm",                   "-steelstorm",                          "Steel-Storm",                          "Steel-Storm",                          "gamedata",     NULL,                   "ss",                           "steelstorm"                    }, // COMMANDLINEOPTION: Game: -steelstorm runs the game Steel Storm
 { GAME_STEELSTORM2,                            GAME_STEELSTORM2,                       "steelstorm2",                  "-steelstorm2",                         "Steel Storm 2",                        "Steel_Storm_2",                        "gamedata",     NULL,                   "ss2",                          "steelstorm2"                   }, // COMMANDLINEOPTION: Game: -steelstorm2 runs the game Steel Storm 2
 { GAME_SSAMMO,                                 GAME_SSAMMO,                            "steelstorm-ammo",              "-steelstormammo",                      "Steel Storm A.M.M.O.",         "Steel_Storm_A.M.M.O.",         "gamedata", NULL,                       "ssammo",                       "steelstorm-ammo"               }, // COMMANDLINEOPTION: Game: -steelstormammo runs the game Steel Storm A.M.M.O.
+{ GAME_STEELSTORMREVENANTS,            GAME_STEELSTORMREVENANTS,       "steelstorm-revenants", "-steelstormrev",                       "Steel Storm: Revenants",       "Steel_Storm_Revenants",        "base", NULL,                           "ssrev",                        "steelstorm-revenants"  }, // COMMANDLINEOPTION: Game: -steelstormrev runs the game Steel Storm: Revenants
 { GAME_TOMESOFMEPHISTOPHELES,  GAME_TOMESOFMEPHISTOPHELES,     "tomesofmephistopheles","-tomesofmephistopheles",       "Tomes of Mephistopheles",      "Tomes_of_Mephistopheles",      "gamedata",     NULL,                   "tom",                          "tomesofmephistopheles" }, // COMMANDLINEOPTION: Game: -tomesofmephistopheles runs the game Tomes of Mephistopheles
 { GAME_STRAPBOMB,                              GAME_STRAPBOMB,                         "strapbomb",                    "-strapbomb",                           "Strap-on-bomb Car",            "Strap-on-bomb_Car",            "id1",          NULL,                   "strap",                        "strapbomb"                             }, // COMMANDLINEOPTION: Game: -strapbomb runs the game Strap-on-bomb Car
 { GAME_MOONHELM,                               GAME_MOONHELM,                          "moonhelm",                             "-moonhelm",                            "MoonHelm",                                     "MoonHelm",                                     "data",         NULL,                   "mh",                           "moonhelm"                              }, // COMMANDLINEOPTION: Game: -moonhelm runs the game MoonHelm
@@ -2034,16 +2035,20 @@ char *InfoString_GetValue(const char *buffer, const char *key, char *value, size
        }
        while (buffer[pos] == '\\')
        {
-               if (!memcmp(buffer + pos+1, key, keylength))
+               if (!memcmp(buffer + pos+1, key, keylength) &&
+                               (buffer[pos+1 + keylength] == 0 ||
+                                buffer[pos+1 + keylength] == '\\'))
                {
-                       for (pos++;buffer[pos] && buffer[pos] != '\\';pos++);
-                       pos++;
+                       pos += 1 + keylength;           // Skip \key
+                       if (buffer[pos] == '\\') pos++; // Skip \ before value.
                        for (j = 0;buffer[pos+j] && buffer[pos+j] != '\\' && j < (int)valuelength - 1;j++)
                                value[j] = buffer[pos+j];
                        value[j] = 0;
                        return value;
                }
+               if (buffer[pos] == '\\') pos++; // Skip \ before value.
                for (pos++;buffer[pos] && buffer[pos] != '\\';pos++);
+               if (buffer[pos] == '\\') pos++; // Skip \ before value.
                for (pos++;buffer[pos] && buffer[pos] != '\\';pos++);
        }
        // if we reach this point the key was not found
@@ -2076,17 +2081,22 @@ void InfoString_SetValue(char *buffer, size_t bufferlength, const char *key, con
        }
        while (buffer[pos] == '\\')
        {
-               if (!memcmp(buffer + pos+1, key, keylength))
+               if (!memcmp(buffer + pos+1, key, keylength) &&
+                               (buffer[pos+1 + keylength] == 0 ||
+                                buffer[pos+1 + keylength] == '\\'))
                        break;
-               for (pos++;buffer[pos] && buffer[pos] != '\\';pos++);
-               for (pos++;buffer[pos] && buffer[pos] != '\\';pos++);
+               if (buffer[pos] == '\\') pos++; // Skip \ before value.
+               for (;buffer[pos] && buffer[pos] != '\\';pos++);
+               if (buffer[pos] == '\\') pos++; // Skip \ before value.
+               for (;buffer[pos] && buffer[pos] != '\\';pos++);
        }
        // if we found the key, find the end of it because we will be replacing it
        pos2 = pos;
        if (buffer[pos] == '\\')
        {
-               for (pos2++;buffer[pos2] && buffer[pos2] != '\\';pos2++);
-               for (pos2++;buffer[pos2] && buffer[pos2] != '\\';pos2++);
+               pos2 += 1 + keylength;  // Skip \key
+               if (buffer[pos2] == '\\') pos2++; // Skip \ before value.
+               for (;buffer[pos2] && buffer[pos2] != '\\';pos2++);
        }
        if (bufferlength <= pos + 1 + strlen(key) + 1 + strlen(value) + strlen(buffer + pos2))
        {