X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=host_cmd.c;h=b5a4047b2bbc17e69a295a97dfc0de4ea636f09a;hp=93d4cb097b3a4946a9d7963a346d8a921adaf103;hb=4923f258e0c7d504f77770c7571ebeadd5537660;hpb=5761d27796f5b77e37b4d5b6bb4afcbda729c01a diff --git a/host_cmd.c b/host_cmd.c index 93d4cb09..b5a4047b 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -35,6 +35,7 @@ cvar_t r_fixtrans_auto = {0, "r_fixtrans_auto", "0", "automatically fixtrans tex qboolean allowcheats = false; extern qboolean host_shuttingdown; +extern cvar_t developer_entityparsing; /* ================== @@ -58,9 +59,10 @@ Host_Status_f void Host_Status_f (void) { client_t *client; - int seconds, minutes, hours = 0, j, players; + int seconds = 0, minutes = 0, hours = 0, i, j, k, in, players, ping = 0, packetloss = 0; void (*print) (const char *fmt, ...); - + char ip[22]; + if (cmd_source == src_command) { // if running a client, try to send over network so the client's status report parser will see the report @@ -76,9 +78,18 @@ void Host_Status_f (void) if (!sv.active) return; + + in = 0; + if (Cmd_Argc() == 2) + { + if (strcmp(Cmd_Argv(1), "1") == 0) + in = 1; + else if (strcmp(Cmd_Argv(1), "2") == 0) + in = 2; + } - for (players = 0, j = 0;j < svs.maxclients;j++) - if (svs.clients[j].active) + for (players = 0, i = 0;i < svs.maxclients;i++) + if (svs.clients[i].active) players++; print ("host: %s\n", Cvar_VariableString ("hostname")); print ("version: %s build %s\n", gamename, buildstring); @@ -86,26 +97,73 @@ void Host_Status_f (void) print ("map: %s\n", sv.name); print ("timing: %s\n", Host_TimingReport()); print ("players: %i active (%i max)\n\n", players, svs.maxclients); - for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++) + + if (in == 1) + print ("^2IP %%pl ping time frags no name\n"); + else if (in == 2) + print ("^5IP no name\n"); + + for (i = 0, k = 0, client = svs.clients;i < svs.maxclients;i++, client++) { if (!client->active) continue; - seconds = (int)(realtime - client->connecttime); - minutes = seconds / 60; - if (minutes) + + ++k; + + if (in == 0 || in == 1) { - seconds -= (minutes * 60); - hours = minutes / 60; - if (hours) - minutes -= (hours * 60); + seconds = (int)(realtime - client->connecttime); + minutes = seconds / 60; + if (minutes) + { + seconds -= (minutes * 60); + hours = minutes / 60; + if (hours) + minutes -= (hours * 60); + } + else + hours = 0; + + packetloss = 0; + if (client->netconnection) + for (j = 0;j < NETGRAPH_PACKETS;j++) + if (client->netconnection->incoming_unreliablesize[j] == NETGRAPH_LOSTPACKET) + packetloss++; + packetloss = packetloss * 100 / NETGRAPH_PACKETS; + ping = bound(0, (int)floor(client->ping*1000+0.5), 9999); } - else - hours = 0; - print ("#%-3u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, client->frags, hours, minutes, seconds); + if(sv_status_privacy.integer && cmd_source != src_command) - print (" %s\n", client->netconnection ? "hidden" : "botclient"); + strlcpy(ip, client->netconnection ? "hidden" : "botclient" , 22); else - print (" %s\n", client->netconnection ? client->netconnection->address : "botclient"); + strlcpy(ip, (client->netconnection && client->netconnection->address) ? client->netconnection->address : "botclient", 22); + + if (in == 0) // default layout + { + print ("#%-3u ", i+1); + print ("%-16.16s ", client->name); + print ("%3i ", client->frags); + print ("%2i:%02i:%02i\n ", hours, minutes, seconds); + print ("%s\n", ip); + } + else if (in == 1) // extended layout + { + k%2 ? print("^3") : print("^7"); + print ("%-21s ", ip); + print ("%2i ", packetloss); + print ("%4i ", ping); + print ("%2i:%02i:%02i ", hours, minutes, seconds); + print ("%4i ", client->frags); + print ("#%-3u ", i+1); + print ("^7%s\n", client->name); + } + else if (in == 2) // reduced layout + { + k%2 ? print("^3") : print("^7"); + print ("%-21s ", ip); + print ("#%-3u ", i+1); + print ("^7%s\n", client->name); + } } } @@ -442,10 +500,16 @@ LOAD / SAVE GAME void Host_Savegame_to (const char *name) { qfile_t *f; - int i; + int i, lightstyles = 64; char comment[SAVEGAME_COMMENT_LENGTH+1]; qboolean isserver; + // first we have to figure out if this can be saved in 64 lightstyles + // (for Quake compatibility) + for (i=64 ; inum_edicts ; i++) { + FS_Printf(f,"// edict %d\n", i); //Con_Printf("edict %d...\n", i); PRVM_ED_Write (f, PRVM_EDICT_NUM(i)); } +#if 1 + FS_Printf(f,"/*\n"); + FS_Printf(f,"// DarkPlaces extended savegame\n"); + // darkplaces extension - extra lightstyles, support for color lightstyles + for (i=0 ; ifields.server, 0, prog->progs->entityfields * 4); ent->priv.server->free = false; + + if(developer_entityparsing.integer) + Con_Printf("Host_Loadgame_f: loading edict %d\n", entnum); + PRVM_ED_ParseEdict (start, ent); // link it into the bsp tree @@ -731,9 +847,9 @@ void Host_Loadgame_f (void) SV_LinkEdict (ent, false); } + end = t; entnum++; } - Mem_Free(text); prog->num_edicts = entnum; sv.time = time; @@ -741,6 +857,72 @@ void Host_Loadgame_f (void) for (i = 0;i < NUM_SPAWN_PARMS;i++) svs.clients[0].spawn_parms[i] = spawn_parms[i]; + if(developer_entityparsing.integer) + Con_Printf("Host_Loadgame_f: skipping until extended data\n"); + + // read extended data if present + // the extended data is stored inside a /* */ comment block, which the + // parser intentionally skips, so we have to check for it manually here + if(end) + { + while (*end == '\r' || *end == '\n') + end++; + if (end[0] == '/' && end[1] == '*' && (end[2] == '\r' || end[2] == '\n')) + { + if(developer_entityparsing.integer) + Con_Printf("Host_Loadgame_f: loading extended data\n"); + + Con_Printf("Loading extended DarkPlaces savegame\n"); + t = end + 2; + memset(sv.lightstyles[0], 0, sizeof(sv.lightstyles)); + memset(sv.model_precache[0], 0, sizeof(sv.model_precache)); + memset(sv.sound_precache[0], 0, sizeof(sv.sound_precache)); + while (COM_ParseToken_Simple(&t, false, false)) + { + if (!strcmp(com_token, "sv.lightstyles")) + { + COM_ParseToken_Simple(&t, false, false); + i = atoi(com_token); + COM_ParseToken_Simple(&t, false, false); + if (i >= 0 && i < MAX_LIGHTSTYLES) + strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i])); + else + Con_Printf("unsupported lightstyle %i \"%s\"\n", i, com_token); + } + else if (!strcmp(com_token, "sv.model_precache")) + { + COM_ParseToken_Simple(&t, false, false); + i = atoi(com_token); + COM_ParseToken_Simple(&t, false, false); + if (i >= 0 && i < MAX_MODELS) + { + strlcpy(sv.model_precache[i], com_token, sizeof(sv.model_precache[i])); + sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, false); + } + else + Con_Printf("unsupported model %i \"%s\"\n", i, com_token); + } + else if (!strcmp(com_token, "sv.sound_precache")) + { + COM_ParseToken_Simple(&t, false, false); + i = atoi(com_token); + COM_ParseToken_Simple(&t, false, false); + if (i >= 0 && i < MAX_SOUNDS) + strlcpy(sv.sound_precache[i], com_token, sizeof(sv.sound_precache[i])); + else + Con_Printf("unsupported sound %i \"%s\"\n", i, com_token); + } + // skip any trailing text or unrecognized commands + while (COM_ParseToken_Simple(&t, true, false) && strcmp(com_token, "\n")) + ; + } + } + } + Mem_Free(text); + + if(developer_entityparsing.integer) + Con_Printf("Host_Loadgame_f: finished\n"); + SV_VM_End(); // make sure we're connected to loopback @@ -2074,7 +2256,7 @@ void Host_SendCvar_f (void) if(svs.clients[i].active && svs.clients[i].netconnection) { host_client = &svs.clients[i]; - Host_ClientCommands(va("sendcvar %s\n", cvarname)); + Host_ClientCommands("sendcvar %s\n", cvarname); } host_client = old; }