]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
strlwr does not exist on Linux
[xonotic/darkplaces.git] / host_cmd.c
index ac6d821fb6900c6b0f7c76fbebfe076d92d242fc..fae72a98624ba40d157eacf316ba7099dcd6ad49 100644 (file)
@@ -209,8 +209,7 @@ Host_Ping_f
 */
 void Host_Ping_f (void)
 {
-       int             i, j;
-       float   total;
+       int             i;
        client_t        *client;
 
        if (cmd_source == src_command)
@@ -224,11 +223,7 @@ void Host_Ping_f (void)
        {
                if (!client->active)
                        continue;
-               total = 0;
-               for (j=0 ; j<NUM_PING_TIMES ; j++)
-                       total+=client->ping_times[j];
-               total /= NUM_PING_TIMES;
-               SV_ClientPrintf("%4i %s\n", (int)(total*1000), client->name);
+               SV_ClientPrintf("%4i %s\n", (int)floor(client->ping*1000+0.5), client->name);
        }
 }
 
@@ -356,7 +351,7 @@ void Host_Restart_f (void)
        allowcheats = sv_cheats.integer != 0;
        strcpy(mapname, sv.name);
        SV_SpawnServer(mapname);
-       if (sv.active && cls.state == ca_disconnected) 
+       if (sv.active && cls.state == ca_disconnected)
        {
                SV_VM_Begin();
                CL_EstablishConnection("local:1");
@@ -374,6 +369,11 @@ 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)
        {
                Con_Print("reconnect : wait for signon messages again\n");
@@ -401,9 +401,13 @@ void Host_Connect_f (void)
                Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
                return;
        }
-       SV_VM_Begin();
-       CL_EstablishConnection("local:1");
-       SV_VM_End();
+       if( sv.active ) {
+               SV_VM_Begin();
+               CL_EstablishConnection(Cmd_Argv(1));
+               SV_VM_End();
+       } else {
+               CL_EstablishConnection(Cmd_Argv(1));
+       }
 }
 
 
@@ -947,7 +951,8 @@ void Host_Say(qboolean teamonly)
                        SV_ClientPrint(text);
        host_client = save;
 
-       //Con_Print(&text[1]);
+       if (cls.state == ca_dedicated)
+               Con_Print(&text[1]);
 }
 
 
@@ -1412,6 +1417,7 @@ void Host_Kick_f (void)
        if (cmd_source != src_command || !sv.active)
                return;
 
+       SV_VM_Begin();
        save = host_client;
 
        if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
@@ -1470,6 +1476,7 @@ void Host_Kick_f (void)
        }
 
        host_client = save;
+       SV_VM_End();
 }
 
 /*
@@ -1662,7 +1669,12 @@ void Host_Viewmodel_f (void)
        prvm_edict_t    *e;
        model_t *m;
 
+       if (!sv.active)
+               return;
+
+       SV_VM_Begin();
        e = FindViewthing ();
+       SV_VM_End();
        if (!e)
                return;
 
@@ -1688,7 +1700,12 @@ void Host_Viewframe_f (void)
        int             f;
        model_t *m;
 
+       if (!sv.active)
+               return;
+
+       SV_VM_Begin();
        e = FindViewthing ();
+       SV_VM_End();
        if (!e)
                return;
        m = cl.model_precache[(int)e->fields.server->modelindex];
@@ -1719,7 +1736,12 @@ void Host_Viewnext_f (void)
        prvm_edict_t    *e;
        model_t *m;
 
+       if (!sv.active)
+               return;
+
+       SV_VM_Begin();
        e = FindViewthing ();
+       SV_VM_End();
        if (!e)
                return;
        m = cl.model_precache[(int)e->fields.server->modelindex];
@@ -1741,7 +1763,12 @@ void Host_Viewprev_f (void)
        prvm_edict_t    *e;
        model_t *m;
 
+       if (!sv.active)
+               return;
+
+       SV_VM_Begin();
        e = FindViewthing ();
+       SV_VM_End();
        if (!e)
                return;
 
@@ -1772,7 +1799,7 @@ void Host_Startdemos_f (void)
 {
        int             i, c;
 
-       if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
+       if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
                return;
 
        c = Cmd_Argc() - 1;