X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=host_cmd.c;h=9a0cc2a0c99c620ba0b053161ffc1e5563e03274;hb=d2fed87da5e82d94c8c422b7be8bb2bca5d5383d;hp=0552aff84d85d3d324f612f41c3e28ad4216ef24;hpb=ff46d6ff516fda192c5adc55a5c9b82007545bd2;p=xonotic%2Fdarkplaces.git diff --git a/host_cmd.c b/host_cmd.c index 0552aff8..9a0cc2a0 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -50,6 +50,7 @@ Host_Status_f */ void Host_Status_f (void) { + const char *protocolname; client_t *client; int seconds, minutes, hours = 0, j, players; void (*print) (const char *fmt, ...); @@ -71,6 +72,17 @@ void Host_Status_f (void) players++; print ("host: %s\n", Cvar_VariableString ("hostname")); print ("version: %s build %s\n", gamename, buildstring); + switch(sv.protocol) + { + case PROTOCOL_QUAKE: protocolname = sv.netquakecompatible ? "QUAKE" : "QUAKEDP";break; + case PROTOCOL_DARKPLACES1: protocolname = "PROTOCOL_DARKPLACES1";break; + case PROTOCOL_DARKPLACES2: protocolname = "PROTOCOL_DARKPLACES2";break; + case PROTOCOL_DARKPLACES3: protocolname = "PROTOCOL_DARKPLACES3";break; + case PROTOCOL_DARKPLACES4: protocolname = "PROTOCOL_DARKPLACES4";break; + case PROTOCOL_DARKPLACES5: protocolname = "PROTOCOL_DARKPLACES5";break; + default: protocolname = "PROTOCOL_UNKNOWN";break; + } + print ("protocol: %i (%s)\n", sv.protocol, protocolname); print ("map: %s\n", sv.name); print ("players: %i active (%i max)\n\n", players, svs.maxclients); for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++) @@ -271,16 +283,24 @@ void Host_Map_f (void) { char level[MAX_QPATH]; + if (Cmd_Argc() != 2) + { + Con_Print("map : start a new game (kicks off all players)\n"); + return; + } + if (cmd_source != src_command) return; + SCR_BeginLoadingPlaque (); cls.demonum = -1; // stop demo loop in case this fails CL_Disconnect (); Host_ShutdownServer(false); - key_dest = key_game; // remove console or menu - SCR_BeginLoadingPlaque (); + // remove console or menu + key_dest = key_game; + key_consoleactive = 0; svs.serverflags = 0; // haven't completed an episode yet allowcheats = sv_cheats.integer != 0; @@ -311,7 +331,15 @@ void Host_Changelevel_f (void) Con_Print("Only the server may changelevel\n"); return; } + if (cmd_source != src_command) + return; + + // remove console or menu + key_dest = key_game; + key_consoleactive = 0; + SV_SaveSpawnparms (); + SCR_BeginLoadingPlaque(); allowcheats = sv_cheats.integer != 0; strcpy(level, Cmd_Argv(1)); SV_SpawnServer(level); @@ -330,11 +358,24 @@ void Host_Restart_f (void) { char mapname[MAX_QPATH]; - if (cls.demoplayback || !sv.active) + if (Cmd_Argc() != 1) + { + Con_Print("restart : restart current level\n"); return; - + } + if (!sv.active || cls.demoplayback) + { + Con_Print("Only the server may restart\n"); + return; + } if (cmd_source != src_command) return; + + // remove console or menu + key_dest = key_game; + key_consoleactive = 0; + + SCR_BeginLoadingPlaque(); allowcheats = sv_cheats.integer != 0; strcpy(mapname, sv.name); SV_SpawnServer(mapname); @@ -352,6 +393,16 @@ This is sent just before a server changes levels */ void Host_Reconnect_f (void) { + 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; + } SCR_BeginLoadingPlaque(); cls.signon = 0; // need new connection messages } @@ -365,6 +416,11 @@ User command to connect to server */ void Host_Connect_f (void) { + if (Cmd_Argc() != 2) + { + Con_Print("connect : connect to a multiplayer game\n"); + return; + } CL_EstablishConnection(Cmd_Argv(1)); } @@ -671,6 +727,7 @@ Host_Name_f cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player"}; void Host_Name_f (void) { + int i, j; char newName[sizeof(host_client->name)]; if (Cmd_Argc () == 1) @@ -684,16 +741,27 @@ void Host_Name_f (void) else strlcpy (newName, Cmd_Args(), sizeof (newName)); + for (i = 0, j = 0;newName[i];i++) + if (newName[i] != '\r' && newName[i] != '\n') + newName[j++] = newName[i]; + newName[j] = 0; + if (cmd_source == src_command) { - if (strcmp(cl_name.string, newName) == 0) - return; Cvar_Set ("_cl_name", newName); if (cls.state == ca_connected) Cmd_ForwardToServer (); return; } + if (sv.time < host_client->nametime) + { + SV_ClientPrintf("You can't change name more than once every 5 seconds!\n"); + return; + } + + host_client->nametime = sv.time + 5; + if (strcmp(host_client->name, newName) && host_client->name[0] && strcmp(host_client->name, "unconnected")) SV_BroadcastPrintf("%s changed name to %s\n", host_client->name, newName); strcpy(host_client->name, newName); @@ -719,7 +787,7 @@ void Host_Say(qboolean teamonly) { client_t *save; int j; - const char *p1, *p2; + const char *p1; // LordHavoc: 256 char say messages unsigned char text[256]; qboolean fromServer = false; @@ -741,39 +809,20 @@ void Host_Say(qboolean teamonly) if (Cmd_Argc () < 2) return; - save = host_client; + if (!teamplay.integer) + teamonly = false; // turn on color set 1 + p1 = Cmd_Args(); if (!fromServer) - sprintf (text, "%c%s: ", 1, host_client->name); + snprintf (text, sizeof(text), "%c%s: %s\n", 1, host_client->name, p1); else - sprintf (text, "%c<%s> ", 1, hostname.string); - - 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 if (fromServer) - Con_Print("Host_Say: missing end quote\n"); - else - SV_ClientPrint("Host_Say: missing end quote\n"); - } - while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r')) - p2--; - for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;) - text[j++] = *p1++; - text[j++] = '\n'; - text[j++] = 0; + snprintf (text, sizeof(text), "%c<%s> %s\n", 1, hostname.string, p1); + // note: save is not a valid edict if fromServer is true + save = host_client; for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++) - if (host_client->spawned && (!teamplay.integer || host_client->edict->v->team == save->edict->v->team)) + if (host_client->spawned && (!teamonly || host_client->edict->v->team == save->edict->v->team)) SV_ClientPrint(text); host_client = save; @@ -909,7 +958,7 @@ void Host_Color_f(void) pr_global_struct->time = sv.time; pr_globals[OFS_PARM0] = playercolor; pr_global_struct->self = EDICT_TO_PROG(sv_player); - PR_ExecuteProgram (SV_ChangeTeam, ""); + PR_ExecuteProgram (SV_ChangeTeam, "QC function SV_ChangeTeam is missing"); } else { @@ -931,10 +980,9 @@ void Host_Color_f(void) } cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000"}; -cvar_t sv_maxrate = {CVAR_SAVE | CVAR_NOTIFY, "sv_maxrate", "10000"}; void Host_Rate_f(void) { - int rate, maxrate; + int rate; if (Cmd_Argc() != 2) { @@ -953,12 +1001,7 @@ void Host_Rate_f(void) return; } - maxrate = bound(NET_MINRATE, sv_maxrate.integer, NET_MAXRATE); - if (sv_maxrate.integer != maxrate) - Cvar_SetValueQuick(&sv_maxrate, maxrate); - - if (LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) != LHNETADDRESSTYPE_LOOP) - host_client->netconnection->rate = bound(NET_MINRATE, rate, maxrate); + host_client->netconnection->rate = rate; } /* @@ -1103,6 +1146,8 @@ void Host_Spawn_f (void) return; } + host_client->nametime = 0; + // LordHavoc: moved this above the QC calls at FrikaC's request // send all current names, colors, and frag counts SZ_Clear (&host_client->message); @@ -1120,7 +1165,7 @@ void Host_Spawn_f (void) Con_DPrint("Calling RestoreGame\n"); pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(sv_player); - PR_ExecuteProgram (RestoreGame, ""); + PR_ExecuteProgram (RestoreGame, "QC function RestoreGame is missing"); } } else @@ -1196,9 +1241,9 @@ void Host_Spawn_f (void) // and it won't happen if the game was just loaded, so you wind up // with a permanent head tilt MSG_WriteByte (&host_client->message, svc_setangle); - for (i=0 ; i < 2 ; i++) - MSG_WriteAngle (&host_client->message, sv_player->v->angles[i] ); - MSG_WriteAngle (&host_client->message, 0 ); + MSG_WriteAngle (&host_client->message, sv_player->v->angles[0], sv.protocol); + MSG_WriteAngle (&host_client->message, sv_player->v->angles[1], sv.protocol); + MSG_WriteAngle (&host_client->message, 0, sv.protocol); SV_WriteClientdataToMessage (sv_player, &host_client->message); @@ -1673,6 +1718,7 @@ void Host_Stopdemo_f (void) if (!cls.demoplayback) return; CL_Disconnect (); + Host_ShutdownServer (false); } static void MaxPlayers_f(void) @@ -1763,7 +1809,6 @@ void Host_InitCommands (void) Cmd_AddCommand ("color", Host_Color_f); Cvar_RegisterVariable (&cl_rate); Cmd_AddCommand ("rate", Host_Rate_f); - Cvar_RegisterVariable (&sv_maxrate); if (gamemode == GAME_NEHAHRA) { Cvar_RegisterVariable (&cl_pmodel);