]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
renamed varray_ arrays to rsurface_array_, and they are no longer used outside the...
[xonotic/darkplaces.git] / host_cmd.c
index 865ecb026b2f02b65337af548e902f93ba1a4e1b..9bd58db01dec59540b4940a99657b89ab775d5a4 100644 (file)
@@ -371,22 +371,39 @@ This is sent just before a server changes levels
 */
 void Host_Reconnect_f (void)
 {
-       if (cmd_source == src_command)
-       {
-               Con_Print("reconnect is not valid from the console\n");
-               return;
-       }
-       if (Cmd_Argc() != 1)
+       if (cls.protocol == PROTOCOL_QUAKEWORLD)
        {
-               Con_Print("reconnect : wait for signon messages again\n");
-               return;
+               if (cls.qw_downloadmemory)  // don't change when downloading
+                       return;
+
+               S_StopAllSounds();
+
+               if (cls.netcon)
+               {
+                       if (cls.state == ca_connected && cls.signon < SIGNONS)
+                       {
+                               Con_Printf("reconnecting...\n");
+                               MSG_WriteChar(&cls.netcon->message, qw_clc_stringcmd);
+                               MSG_WriteString(&cls.netcon->message, "new");
+                       }
+                       else
+                               Con_Printf("Please use connect instead (reconnect not implemented)\n");
+               }
        }
-       if (!cls.signon)
+       else
        {
-               //Con_Print("reconnect: no signon, ignoring reconnect\n");
-               return;
+               if (Cmd_Argc() != 1)
+               {
+                       Con_Print("reconnect : wait for signon messages again\n");
+                       return;
+               }
+               if (!cls.signon)
+               {
+                       Con_Print("reconnect: no signon, ignoring reconnect\n");
+                       return;
+               }
+               cls.signon = 0;         // need new connection messages
        }
-       cls.signon = 0;         // need new connection messages
 }
 
 /*
@@ -712,6 +729,7 @@ void Host_Loadgame_f (void)
 
                entnum++;
        }
+       Mem_Free(text);
 
        prog->num_edicts = entnum;
        sv.time = time;
@@ -1404,10 +1422,21 @@ void Host_Spawn_f (void)
        // in a state where it is expecting the client to correct the angle
        // and it won't happen if the game was just loaded, so you wind up
        // with a permanent head tilt
-       MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
-       MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
-       MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
-       MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
+       if (sv.loadgame)
+       {
+               MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
+               MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[0], sv.protocol);
+               MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[1], sv.protocol);
+               MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
+               sv.loadgame = false; // we're basically done with loading now
+       }
+       else
+       {
+               MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
+               MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
+               MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
+               MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
+       }
 
        SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->netconnection->message, stats);
 
@@ -1957,20 +1986,6 @@ static void MaxPlayers_f(void)
 
 // QuakeWorld commands
 
-char emodel_name[] =
-       { 'e' ^ 0xff, 'm' ^ 0xff, 'o' ^ 0xff, 'd' ^ 0xff, 'e' ^ 0xff, 'l' ^ 0xff, 0 };
-char pmodel_name[] =
-       { 'p' ^ 0xff, 'm' ^ 0xff, 'o' ^ 0xff, 'd' ^ 0xff, 'e' ^ 0xff, 'l' ^ 0xff, 0 };
-char prespawn_name[] =
-       { 'p'^0xff, 'r'^0xff, 'e'^0xff, 's'^0xff, 'p'^0xff, 'a'^0xff, 'w'^0xff, 'n'^0xff,
-               ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '0'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
-char modellist_name[] =
-       { 'm'^0xff, 'o'^0xff, 'd'^0xff, 'e'^0xff, 'l'^0xff, 'l'^0xff, 'i'^0xff, 's'^0xff, 't'^0xff,
-               ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
-char soundlist_name[] =
-       { 's'^0xff, 'o'^0xff, 'u'^0xff, 'n'^0xff, 'd'^0xff, 'l'^0xff, 'i'^0xff, 's'^0xff, 't'^0xff,
-               ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
-
 /*
 =====================
 Host_Rcon_f
@@ -2045,9 +2060,9 @@ void Host_User_f (void) // credit: taken from QuakeWorld
        {
                if (!cl.scores[i].name[0])
                        continue;
-               if (cl.scores[i].userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
+               if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
                {
-                       InfoString_Print(cl.scores[i].userinfo);
+                       InfoString_Print(cl.scores[i].qw_userinfo);
                        return;
                }
        }
@@ -2073,7 +2088,7 @@ void Host_Users_f (void) // credit: taken from QuakeWorld
        {
                if (cl.scores[i].name[0])
                {
-                       Con_Printf ("%6i %4i %s\n", cl.scores[i].userid, cl.scores[i].frags, cl.scores[i].name);
+                       Con_Printf ("%6i %4i %s\n", cl.scores[i].qw_userid, cl.scores[i].frags, cl.scores[i].name);
                        c++;
                }
        }
@@ -2091,13 +2106,16 @@ Sent by server when serverinfo changes
 // TODO: shouldn't this be a cvar instead?
 void Host_FullServerinfo_f (void) // credit: taken from QuakeWorld
 {
+       char temp[512];
        if (Cmd_Argc() != 2)
        {
                Con_Printf ("usage: fullserverinfo <complete info string>\n");
                return;
        }
 
-       strlcpy (cl.serverinfo, Cmd_Argv(1), sizeof(cl.serverinfo));
+       strlcpy (cl.qw_serverinfo, Cmd_Argv(1), sizeof(cl.qw_serverinfo));
+       InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
+       cl.qw_teamplay = atoi(temp);
 }
 
 /*
@@ -2146,7 +2164,7 @@ void Host_FullInfo_f (void) // credit: taken from QuakeWorld
                if (*s)
                        s++;
 
-               if (!strcasecmp(key, pmodel_name) || !strcasecmp(key, emodel_name))
+               if (!strcasecmp(key, "pmodel") || !strcasecmp(key, "emodel"))
                        continue;
 
                if (key[0] == '*')
@@ -2178,7 +2196,7 @@ void Host_SetInfo_f (void) // credit: taken from QuakeWorld
                Con_Printf ("usage: setinfo [ <key> <value> ]\n");
                return;
        }
-       if (!strcasecmp(Cmd_Argv(1), pmodel_name) || !strcasecmp(Cmd_Argv(1), emodel_name))
+       if (!strcasecmp(Cmd_Argv(1), "pmodel") || !strcasecmp(Cmd_Argv(1), "emodel"))
                return;
        if (Cmd_Argv(1)[0] == '*')
        {
@@ -2224,7 +2242,7 @@ void Host_Packet_f (void) // credit: taken from QuakeWorld
        out = send+4;
        send[0] = send[1] = send[2] = send[3] = 0xff;
 
-       l = strlen (in);
+       l = (int)strlen (in);
        for (i=0 ; i<l ; i++)
        {
                if (out >= send + sizeof(send) - 1)
@@ -2234,14 +2252,33 @@ void Host_Packet_f (void) // credit: taken from QuakeWorld
                        *out++ = '\n';
                        i++;
                }
+               else if (in[i] == '\\' && in[i+1] == '0')
+               {
+                       *out++ = '\0';
+                       i++;
+               }
+               else if (in[i] == '\\' && in[i+1] == 't')
+               {
+                       *out++ = '\t';
+                       i++;
+               }
+               else if (in[i] == '\\' && in[i+1] == 'r')
+               {
+                       *out++ = '\r';
+                       i++;
+               }
+               else if (in[i] == '\\' && in[i+1] == '"')
+               {
+                       *out++ = '\"';
+                       i++;
+               }
                else
                        *out++ = in[i];
        }
-       *out = 0;
 
        mysocket = NetConn_ChooseClientSocketForAddress(&address);
        if (mysocket)
-               NetConn_WriteString(mysocket, send, &address);
+               NetConn_Write(mysocket, send, out - send, &address);
 }
 
 //=============================================================================