X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=host_cmd.c;h=b3fd8db6be8ca8a2eec22bb8b106e8701b603b3a;hp=e31254bc808846b0460fa5afbef63eefd800001f;hb=fab6eb344365652bd53d03faa1ea43e14fbe1d7f;hpb=ddbf1199123be08b34ee2bb2693cdfc7ceaae999 diff --git a/host_cmd.c b/host_cmd.c index e31254bc..b3fd8db6 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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 ; jping_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); } } @@ -299,7 +294,12 @@ void Host_Changelevel_f (void) Con_Print("changelevel : continue game on a new level\n"); return; } - if (!sv.active || cls.demoplayback) + // HACKHACKHACK + if (!sv.active) { + Host_Map_f(); + return; + } + if (cls.demoplayback) { Con_Print("Only the server may changelevel\n"); return; @@ -374,6 +374,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"); @@ -435,12 +440,14 @@ void Host_SavegameComment (char *text) for (i=0 ; i= MAX_EDICTS) { Mem_Free(text); - Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)\n", MAX_EDICTS); + Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS); } while (entnum >= prog->max_edicts) //SV_IncreaseEdicts(); @@ -816,8 +823,6 @@ void Host_Playermodel_f (void) PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(host_client->playermodel); if (strcmp(host_client->old_model, host_client->playermodel)) { - if (host_client->spawned) - SV_BroadcastPrintf("%s changed model to %s\n", host_client->name, host_client->playermodel); strcpy(host_client->old_model, host_client->playermodel); /*// send notification to all clients MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel); @@ -899,7 +904,7 @@ void Host_Say(qboolean teamonly) const char *p1; char *p2; // LordHavoc: 256 char say messages - unsigned char text[256]; + char text[256]; qboolean fromServer = false; if (cmd_source == src_command) @@ -931,9 +936,9 @@ void Host_Say(qboolean teamonly) p1++; } if (!fromServer) - dpsnprintf (text, sizeof(text), "%c%s: %s", 1, host_client->name, p1); + dpsnprintf (text, sizeof(text), "%c%s" STRING_COLOR_DEFAULT_STR ": %s", 1, host_client->name, p1); else - dpsnprintf (text, sizeof(text), "%c<%s> %s", 1, hostname.string, p1); + dpsnprintf (text, sizeof(text), "%c<%s" STRING_COLOR_DEFAULT_STR "> %s", 1, hostname.string, p1); p2 = text + strlen(text); while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted))) { @@ -1018,7 +1023,7 @@ void Host_Tell_f(void) } while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r')) p2--; - for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;) + for (j = (int)strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;) text[j++] = *p1++; text[j++] = '\n'; text[j++] = 0; @@ -1186,6 +1191,7 @@ void Host_Pause_f (void) ====================== Host_PModel_f LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen. +LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility. ====================== */ cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0"}; @@ -1341,9 +1347,12 @@ void Host_Spawn_f (void) // send all current light styles for (i=0 ; imessage, svc_lightstyle); - MSG_WriteByte (&host_client->message, (char)i); - MSG_WriteString (&host_client->message, sv.lightstyles[i]); + if (sv.lightstyles[i][0]) + { + MSG_WriteByte (&host_client->message, svc_lightstyle); + MSG_WriteByte (&host_client->message, (char)i); + MSG_WriteString (&host_client->message, sv.lightstyles[i]); + } } // send some stats @@ -1417,6 +1426,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) @@ -1475,6 +1485,7 @@ void Host_Kick_f (void) } host_client = save; + SV_VM_End(); } /* @@ -1667,14 +1678,19 @@ 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; m = Mod_ForName (Cmd_Argv(1), false, true, false); - if (!m) + if (!m || !m->loaded || !m->Draw) { - Con_Printf("Can't load %s\n", Cmd_Argv(1)); + Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1)); return; } @@ -1693,7 +1709,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]; @@ -1724,7 +1745,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]; @@ -1746,7 +1772,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; @@ -1777,7 +1808,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; @@ -1860,7 +1891,7 @@ static void MaxPlayers_f(void) if (svs.clients) Mem_Free(svs.clients); svs.maxclients = n; - svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients); + svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients); if (n == 1) Cvar_Set ("deathmatch", "0"); else