Display on server browser

This commit is contained in:
TehRealSalt 2019-04-26 14:07:48 -04:00
parent cdd7e9b1c6
commit ed093e0856
4 changed files with 27 additions and 15 deletions

View file

@ -1435,6 +1435,11 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
p = PutFileNeeded(); p = PutFileNeeded();
if (cv_kartusepwrlv.value)
netbuffer->u.serverinfo.avgpwrlv = K_CalculatePowerLevelAvg();
else
netbuffer->u.serverinfo.avgpwrlv = -1;
HSendPacket(node, false, 0, p - ((UINT8 *)&netbuffer->u)); HSendPacket(node, false, 0, p - ((UINT8 *)&netbuffer->u));
} }

View file

@ -399,6 +399,7 @@ typedef struct
UINT8 actnum; UINT8 actnum;
UINT8 iszone; UINT8 iszone;
UINT8 fileneeded[MAXFILENEEDED]; // is filled with writexxx (byteptr.h) UINT8 fileneeded[MAXFILENEEDED]; // is filled with writexxx (byteptr.h)
INT16 avgpwrlv; // Kart avg power level
} ATTRPACK serverinfo_pak; } ATTRPACK serverinfo_pak;
typedef struct typedef struct

View file

@ -6132,7 +6132,7 @@ INT16 K_CalculatePowerLevelAvg(void)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (!playeringame[i] || players[i].spectator if (!playeringame[i] || players[i].spectator
|| clientpowerlevels[i][t] == 0) || clientpowerlevels[i][t] == 0) // splitscreen player
continue; continue;
avg += clientpowerlevels[i][t]; avg += clientpowerlevels[i][t];

View file

@ -7288,6 +7288,7 @@ static void M_DrawConnectMenu(void)
UINT16 i, j; UINT16 i, j;
const char *gt = "Unknown"; const char *gt = "Unknown";
const char *spd = ""; const char *spd = "";
const char *pwr = "----";
INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE; INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE;
for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++) for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++)
@ -7322,36 +7323,41 @@ static void M_DrawConnectMenu(void)
V_DrawString(currentMenu->x, S_LINEY(i), globalflags, serverlist[slindex].info.servername); V_DrawString(currentMenu->x, S_LINEY(i), globalflags, serverlist[slindex].info.servername);
// Don't use color flags intentionally, the global yellow color will auto override the text color code if (serverlist[slindex].info.kartvars & SV_PASSWORD)
if (serverlist[slindex].info.modifiedgame) V_DrawFixedPatch((currentMenu->x - 9) << FRACBITS, (S_LINEY(i)) << FRACBITS, FRACUNIT, globalflags & (~V_ALLOWLOWERCASE), W_CachePatchName("SERVLOCK", PU_CACHE), NULL);
V_DrawSmallString(currentMenu->x+202, S_LINEY(i)+8, globalflags, "\x85" "Mod");
if (serverlist[slindex].info.cheatsenabled)
V_DrawSmallString(currentMenu->x+222, S_LINEY(i)+8, globalflags, "\x83" "Cheats");
V_DrawSmallString(currentMenu->x, S_LINEY(i)+8, globalflags, V_DrawSmallString(currentMenu->x, S_LINEY(i)+8, globalflags,
va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time))); va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time)));
V_DrawSmallString(currentMenu->x+44,S_LINEY(i)+8, globalflags,
va("Players: %02d/%02d", serverlist[slindex].info.numberofplayer, serverlist[slindex].info.maxplayer));
gt = "Unknown"; gt = "Unknown";
for (j = 0; gametype_cons_t[j].strvalue; j++) for (j = 0; gametype_cons_t[j].strvalue; j++)
{ {
if (gametype_cons_t[j].value == serverlist[slindex].info.gametype) if (gametype_cons_t[j].value == serverlist[slindex].info.gametype)
gt = gametype_cons_t[j].strvalue; gt = gametype_cons_t[j].strvalue;
} }
V_DrawSmallString(currentMenu->x+108, S_LINEY(i)+8, globalflags, gt);
V_DrawSmallString(currentMenu->x+46,S_LINEY(i)+8, globalflags,
va("Players: %02d/%02d", serverlist[slindex].info.numberofplayer, serverlist[slindex].info.maxplayer));
V_DrawSmallString(currentMenu->x+112, S_LINEY(i)+8, globalflags, gt);
if (serverlist[slindex].info.gametype == GT_RACE) if (serverlist[slindex].info.gametype == GT_RACE)
{ {
spd = kartspeed_cons_t[serverlist[slindex].info.kartvars & SV_SPEEDMASK].strvalue; spd = kartspeed_cons_t[serverlist[slindex].info.kartvars & SV_SPEEDMASK].strvalue;
V_DrawSmallString(currentMenu->x+128, S_LINEY(i)+8, globalflags, va("(%s)", spd));
V_DrawSmallString(currentMenu->x+132, S_LINEY(i)+8, globalflags, va("(%s Speed)", spd));
} }
if (serverlist[slindex].info.kartvars & SV_PASSWORD) pwr = "----";
V_DrawFixedPatch((currentMenu->x - 9) << FRACBITS, (S_LINEY(i)) << FRACBITS, FRACUNIT, globalflags & (~V_ALLOWLOWERCASE), W_CachePatchName("SERVLOCK", PU_CACHE), NULL); if (serverlist[slindex].info.avgpwrlv == -1)
pwr = "Off";
else if (serverlist[slindex].info.avgpwrlv > 0)
pwr = va("%04d", serverlist[slindex].info.avgpwrlv);
V_DrawSmallString(currentMenu->x+171, S_LINEY(i)+8, globalflags, va("Power Level: %s", pwr));
// Don't use color flags intentionally, the global yellow color will auto override the text color code
if (serverlist[slindex].info.modifiedgame)
V_DrawSmallString(currentMenu->x+245, S_LINEY(i)+8, globalflags, "\x85" "Mod");
if (serverlist[slindex].info.cheatsenabled)
V_DrawSmallString(currentMenu->x+265, S_LINEY(i)+8, globalflags, "\x83" "Cheats");
MP_ConnectMenu[i+FIRSTSERVERLINE].status = IT_STRING | IT_CALL; MP_ConnectMenu[i+FIRSTSERVERLINE].status = IT_STRING | IT_CALL;
} }