]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
added error messages when opening sockets (reports both success and failure)
[xonotic/darkplaces.git] / common.c
index 4aa67becb9361c06e3424c1ad1e484257406c785..9ae390e0fbcdedb53c00157ba5f76c1e276313c1 100644 (file)
--- a/common.c
+++ b/common.c
@@ -362,7 +362,7 @@ float MSG_ReadDPCoord (void)
 // used by client
 float MSG_ReadCoord (void)
 {
-       if (dpprotocol == DPPROTOCOL_VERSION2 || dpprotocol == DPPROTOCOL_VERSION3)
+       if (dpprotocol == DPPROTOCOL_VERSION2 || dpprotocol == DPPROTOCOL_VERSION3 || dpprotocol == DPPROTOCOL_VERSION4)
                return (signed short) MSG_ReadLittleShort();
        else if (dpprotocol == DPPROTOCOL_VERSION1)
                return MSG_ReadLittleFloat();
@@ -506,7 +506,7 @@ COM_ParseToken
 Parse a token out of a string
 ==============
 */
-int COM_ParseToken (const char **datapointer)
+int COM_ParseToken(const char **datapointer, int returnnewline)
 {
        int c;
        int len;
@@ -523,7 +523,7 @@ int COM_ParseToken (const char **datapointer)
 
 // skip whitespace
 skipwhite:
-       while ((c = *data) <= ' ')
+       while ((c = *data) <= ' ' && (c != '\n' || !returnnewline))
        {
                if (c == 0)
                {
@@ -534,15 +534,25 @@ skipwhite:
                data++;
        }
 
-// skip // comments
-       if (c=='/' && data[1] == '/')
+       // check if it's a comment
+       if (c == '/')
        {
-               while (*data && *data != '\n')
-                       data++;
-               goto skipwhite;
+               // skip // comments
+               if (data[1] == '/')
+               {
+                       while (*data && *data != '\n')
+                               data++;
+                       goto skipwhite;
+               }
+               // skip /* comments
+               if (data[1] == '*')
+               {
+                       while (*data && *data != '*' && data[1] != '/')
+                               data++;
+                       goto skipwhite;
+               }
        }
 
-
 // handle quoted strings specially
        if (c == '\"')
        {
@@ -550,7 +560,7 @@ skipwhite:
                while (1)
                {
                        c = *data++;
-                       if (c=='\"' || !c)
+                       if (c == '\"' || !c)
                        {
                                com_token[len] = 0;
                                *datapointer = data;
@@ -562,7 +572,7 @@ skipwhite:
        }
 
 // parse single characters
-       if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
+       if (c == '{' || c == '}' || c == ')' || c == '(' || c == ']' || c == '[' || c == '\'' || c == ':' || c == ',' || c == ';' || c == '\n')
        {
                com_token[len] = c;
                len++;
@@ -578,7 +588,7 @@ skipwhite:
                data++;
                len++;
                c = *data;
-               if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
+               if (c == '{' || c == '}' || c == ')' || c == '(' || c == ']' || c == '[' || c == '\'' || c == ':' || c == ',' || c == ';')
                        break;
        } while (c>32);
 
@@ -678,10 +688,12 @@ void COM_InitGameType (void)
                gamemode = GAME_HIPNOTIC;
        else if (strstr(name, "rogue"))
                gamemode = GAME_ROGUE;
-       else if (strstr(name, "goodvsbad2"))
+       else if (strstr(name, "gvb2"))
                gamemode = GAME_GOODVSBAD2;
        else if (strstr(name, "teu"))
                gamemode = GAME_TEU;
+       else if (strstr(name, "battlemech"))
+               gamemode = GAME_BATTLEMECH;
        else
                gamemode = GAME_NORMAL;
 
@@ -701,6 +713,8 @@ void COM_InitGameType (void)
                gamemode = GAME_GOODVSBAD2;
        else if (COM_CheckParm ("-teu"))
                gamemode = GAME_TEU;
+       else if (COM_CheckParm ("-battlemech"))
+               gamemode = GAME_BATTLEMECH;
 
        switch(gamemode)
        {
@@ -736,6 +750,10 @@ void COM_InitGameType (void)
                gamename = "TheEvilUnleashed";
                gamedirname = "teu";
                break;
+       case GAME_BATTLEMECH:
+               gamename = "Battlemech";
+               gamedirname = "base";
+               break;
        default:
                Sys_Error("COM_InitGameType: unknown gamemode %i\n", gamemode);
                break;