]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
use dynamic eye position-centered bouncegrid when rendering in dynamic
[xonotic/darkplaces.git] / common.c
index 9bcaeb8c407b92b148d6bccfbcb059eb13825b68..11a350bfc2dba30daa9d4614657f0e9d873e7fb4 100644 (file)
--- a/common.c
+++ b/common.c
@@ -606,7 +606,7 @@ void SZ_Write (sizebuf_t *buf, const unsigned char *data, int length)
 // attention, it has been eradicated from here, its only (former) use in
 // all of darkplaces.
 
-static char *hexchar = "0123456789ABCDEF";
+static const char *hexchar = "0123456789ABCDEF";
 void Com_HexDumpToConsole(const unsigned char *data, int size)
 {
        int i, j, n;
@@ -1448,6 +1448,9 @@ static const gamemode_info_t gamemode_info [GAME_COUNT] =
 // GAME_NEXUIZ
 // COMMANDLINEOPTION: Game: -nexuiz runs the multiplayer game Nexuiz
 { "nexuiz",                    "-nexuiz",              "Nexuiz",                               "data",         NULL,                   "nexuiz",               "nexuiz" },
+// GAME_XONOTIC
+// COMMANDLINEOPTION: Game: -xonotic runs the multiplayer game Xonotic
+{ "xonotic",                   "-xonotic",             "Xonotic",                              "data",         NULL,                   "xonotic",              "xonotic" },
 // GAME_TRANSFUSION
 // COMMANDLINEOPTION: Game: -transfusion runs Transfusion (the recreation of Blood in Quake)
 { "transfusion",       "-transfusion", "Transfusion",                  "basetf",       NULL,                   "transfusion",  "transfusion" },
@@ -1511,6 +1514,9 @@ static const gamemode_info_t gamemode_info [GAME_COUNT] =
 // GAME_STRAPBOMB
 // COMMANDLINEOPTION: Game: -strapbomb runs the game Strap-on-bomb Car
 { "strapbomb",                         "-strapbomb",           "Strap-on-bomb Car",            "id1",          NULL,                   "strap",                        "strapbomb" },
+// GAME_MOONHELM
+// COMMANDLINEOPTION: Game: -moonhelm runs the game MoonHelm
+{ "moonhelm",                          "-moonhelm",            "MoonHelm",             "data",         NULL,                   "mh",                   "moonhelm" },
 };
 
 void COM_InitGameType (void)
@@ -1996,8 +2002,6 @@ void InfoString_GetValue(const char *buffer, const char *key, char *value, size_
        size_t keylength;
        if (!key)
                key = "";
-       if (!value)
-               value = "";
        keylength = strlen(key);
        if (valuelength < 1 || !value)
        {
@@ -2256,3 +2260,34 @@ char **XPM_DecodeString(const char *in)
 
        return tokens;
 }
+
+static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static void base64_3to4(const unsigned char *in, unsigned char *out, int bytes)
+{
+       unsigned char i0 = (bytes > 0) ? in[0] : 0;
+       unsigned char i1 = (bytes > 1) ? in[1] : 0;
+       unsigned char i2 = (bytes > 2) ? in[2] : 0;
+       unsigned char o0 = base64[i0 >> 2];
+       unsigned char o1 = base64[((i0 << 4) | (i1 >> 4)) & 077];
+       unsigned char o2 = base64[((i1 << 2) | (i2 >> 6)) & 077];
+       unsigned char o3 = base64[i2 & 077];
+       out[0] = (bytes > 0) ? o0 : '?';
+       out[1] = (bytes > 0) ? o1 : '?';
+       out[2] = (bytes > 1) ? o2 : '=';
+       out[3] = (bytes > 2) ? o3 : '=';
+}
+
+size_t base64_encode(unsigned char *buf, size_t buflen, size_t outbuflen)
+{
+       size_t blocks, i;
+       // expand the out-buffer
+       blocks = (buflen + 2) / 3;
+       if(blocks*4 > outbuflen)
+               return 0;
+       for(i = blocks; i > 0; )
+       {
+               --i;
+               base64_3to4(buf + 3*i, buf + 4*i, buflen - 3*i);
+       }
+       return blocks * 4;
+}