X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=host_cmd.c;h=2fbc012f7abec4be55156636d6e0938b5c19fe60;hb=cf1572fc715474459d170a47fd84407621ab2601;hp=1dec6eca1da66f36d5590bc3d6243f18aaac0009;hpb=ea7c24e1fb41f3b1df984ac0eed6881c9fde16f5;p=xonotic%2Fdarkplaces.git diff --git a/host_cmd.c b/host_cmd.c index 1dec6eca..2fbc012f 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -48,12 +48,9 @@ Host_Status_f */ void Host_Status_f (void) { - client_t *client; - int seconds; - int minutes; - int hours = 0; - int j; - void (*print) (char *fmt, ...); + client_t *client; + int seconds, minutes, hours = 0, j; + void (*print) (const char *fmt, ...); if (cmd_source == src_command) { @@ -241,15 +238,15 @@ SERVER TRANSITIONS ====================== Host_Map_f -handle a +handle a map command from the console. Active clients are kicked off. ====================== */ void Host_Map_f (void) { - int i; - char name[MAX_QPATH]; + int i; + char name[MAX_QPATH]; if (cmd_source != src_command) return; @@ -259,7 +256,7 @@ void Host_Map_f (void) SCR_BeginLoadingPlaque (); CL_Disconnect (); - Host_ShutdownServer(false); + Host_ShutdownServer(false); key_dest = key_game; // remove console or menu @@ -276,9 +273,10 @@ void Host_Map_f (void) SV_SpawnServer (name); if (!sv.active) return; - + if (cls.state != ca_dedicated) { + /* strcpy (cls.spawnparms, ""); for (i=2 ; iv, 0, progs->entityfields * 4); ent->free = false; ED_ParseEdict (start, ent); - - // link it into the bsp tree + + // link it into the bsp tree if (!ent->free) SV_LinkEdict (ent, false); } entnum++; } - + sv.num_edicts = entnum; sv.time = time; @@ -700,7 +703,7 @@ void Host_Name_f (void) MSG_WriteString (&sv.reliable_datagram, host_client->name); } - + void Host_Version_f (void) { Con_Printf ("Version: %s build %s\n", gamename, buildstring); @@ -710,11 +713,11 @@ void Host_Say(qboolean teamonly) { client_t *client; client_t *save; - int j; - char *p; + int j; + const char *p1, *p2; // LordHavoc: 256 char say messages - unsigned char text[256]; - qboolean fromServer = false; + unsigned char text[256]; + qboolean fromServer = false; if (cmd_source == src_command) { @@ -733,28 +736,34 @@ void Host_Say(qboolean teamonly) if (Cmd_Argc () < 2) return; - save = host_client; - - p = Cmd_Args(); -// remove quotes if present - if (*p == '"') - { - p++; - p[strlen(p)-1] = 0; - } - // turn on color set 1 if (!fromServer) - sprintf (text, "%c%s: ", 1, save->name); + sprintf (text, "%c%s: ", 1, host_client->name); else sprintf (text, "%c<%s> ", 1, hostname.string); - j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator - if (strlen(p) > j) - p[j] = 0; + save = host_client; - strcat (text, p); - strcat (text, "\n"); + p1 = Cmd_Args(); + p2 = p1 + strlen(p1); + // remove trailing newlines + while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r')) + p2--; + // remove quotes if present + if (*p1 == '"') + { + p1++; + if (p2[-1] == '"') + p2--; + else + Con_Printf("Host_Say: missing end quote\n"); + } + while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r')) + p2--; + for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;) + text[j++] = *p1++; + text[j++] = '\n'; + text[j++] = 0; for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) { @@ -787,38 +796,55 @@ void Host_Tell_f(void) { client_t *client; client_t *save; - int j; - char *p; - char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64) + int j; + const char *p1, *p2; + char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64) + qboolean fromServer = false; if (cmd_source == src_command) { - Cmd_ForwardToServer (); - return; + if (cls.state == ca_dedicated) + fromServer = true; + else + { + Cmd_ForwardToServer (); + return; + } } if (Cmd_Argc () < 3) return; - strcpy(text, host_client->name); - strcat(text, ": "); - - p = Cmd_Args(); - -// remove quotes if present - if (*p == '"') - { - p++; - p[strlen(p)-1] = 0; + if (!fromServer) + sprintf (text, "%s: ", host_client->name); + else + sprintf (text, "<%s> ", hostname.string); + + p1 = Cmd_Args(); + p2 = p1 + strlen(p1); + // remove the target name + while (p1 < p2 && *p1 != ' ') + p1++; + while (p1 < p2 && *p1 == ' ') + p1++; + // remove trailing newlines + while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r')) + p2--; + // remove quotes if present + if (*p1 == '"') + { + p1++; + if (p2[-1] == '"') + p2--; + else + Con_Printf("Host_Say: missing end quote\n"); } - -// check length & truncate if necessary - j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator - if (strlen(p) > j) - p[j] = 0; - - strcat (text, p); - strcat (text, "\n"); + while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r')) + p2--; + for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;) + text[j++] = *p1++; + text[j++] = '\n'; + text[j++] = 0; save = host_client; for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) @@ -846,11 +872,11 @@ void Host_Color_f(void) int playercolor; dfunction_t *f; func_t SV_ChangeTeam; - + if (Cmd_Argc() == 1) { Con_Printf ("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15); - Con_Printf ("color <0-13> [0-13]\n"); + Con_Printf ("color <0-15> [0-15]\n"); return; } @@ -861,7 +887,7 @@ void Host_Color_f(void) top = atoi(Cmd_Argv(1)); bottom = atoi(Cmd_Argv(2)); } - + top &= 15; // LordHavoc: allow skin colormaps 14 and 15 (was 13) if (top > 15) @@ -870,7 +896,7 @@ void Host_Color_f(void) // LordHavoc: allow skin colormaps 14 and 15 (was 13) if (bottom > 15) bottom = 15; - + playercolor = top*16 + bottom; if (cmd_source == src_command) @@ -885,7 +911,7 @@ void Host_Color_f(void) { Con_DPrintf("Calling SV_ChangeTeam\n"); pr_global_struct->time = sv.time; - pr_globals[0] = playercolor; + pr_globals[OFS_PARM0] = playercolor; pr_global_struct->self = EDICT_TO_PROG(host_client->edict); PR_ExecuteProgram (SV_ChangeTeam, ""); } @@ -919,7 +945,7 @@ void Host_Kill_f (void) SV_ClientPrintf ("Can't suicide -- already dead!\n"); return; } - + pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(sv_player); PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing"); @@ -1019,7 +1045,8 @@ void Host_Spawn_f (void) // run the entrance script if (sv.loadgame) - { // loaded games are fully inited already + { + // loaded games are fully initialized already // if this is the last client to be connected, unpause sv.paused = false; @@ -1079,7 +1106,7 @@ void Host_Spawn_f (void) MSG_WriteByte (&host_client->message, i); MSG_WriteByte (&host_client->message, client->colors); } - + // send all current light styles for (i=0 ; iname; @@ -1209,7 +1238,8 @@ void Host_Kick_f (void) if (Cmd_Argc() > 2) { - message = COM_Parse(Cmd_Args()); + message = Cmd_Args(); + COM_ParseToken(&message); if (byNumber) { message++; // skip the # @@ -1245,9 +1275,9 @@ Host_Give_f */ void Host_Give_f (void) { - char *t; - int v; - eval_t *val; + const char *t; + int v; + eval_t *val; if (cmd_source == src_command) {