diff --git a/src/multiint.cpp b/src/multiint.cpp index 6ceff9e1d52..f8a6ba9235d 100644 --- a/src/multiint.cpp +++ b/src/multiint.cpp @@ -7684,12 +7684,23 @@ void displayPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) } else if (ingame.localOptionsReceived && NetPlay.players[j].allocated) // only draw if real player! { + const PLAYERSTATS& stat = getMultiStats(j); + auto ar = stat.autorating; + std::string name = NetPlay.players[j].name; + if (ar.name != "") + { + name = ar.name; + } std::map serverPlayers; // TODO Fill this with players known to the server (needs implementing on the server, too). Currently useless. PIELIGHT colour; - if (ingame.PingTimes[j] >= PING_LIMIT) + if (ar.nameTextColorOverride[0] != 255 || ar.nameTextColorOverride[1] != 255 || ar.nameTextColorOverride[2] != 255) + { + colour = pal_Colour(ar.nameTextColorOverride[0], ar.nameTextColorOverride[1], ar.nameTextColorOverride[2]); + } + else if (ingame.PingTimes[j] >= PING_LIMIT) { colour = WZCOL_FORM_PLAYER_NOPING; } @@ -7743,8 +7754,6 @@ void displayPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) subText += buf; } - const PLAYERSTATS& stat = getMultiStats(j); - auto ar = stat.autorating; if (!ar.valid) { ar.dummy = stat.played < 5; @@ -7810,8 +7819,13 @@ void displayPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) if (!ar.elo.empty()) { + PIELIGHT eloColour = WZCOL_TEXT_BRIGHT; + if (ar.eloTextColorOverride[0] != 255 || ar.eloTextColorOverride[1] != 255 || ar.eloTextColorOverride[2] != 255) + { + eloColour = pal_Colour(ar.eloTextColorOverride[0], ar.eloTextColorOverride[1], ar.eloTextColorOverride[2]); + } cache.wzEloText.setText(WzString::fromUtf8(ar.elo), font_small); - cache.wzEloText.render(x + nameX, y + 28 + H*!subText.isEmpty(), WZCOL_TEXT_BRIGHT); + cache.wzEloText.render(x + nameX, y + 28 + H*!subText.isEmpty(), eloColour); } } else // AI diff --git a/src/multistat.cpp b/src/multistat.cpp index 640a518b3fb..6a06eafbd00 100644 --- a/src/multistat.cpp +++ b/src/multistat.cpp @@ -71,6 +71,9 @@ static void NETauto(PLAYERSTATS::Autorating &ar) NETauto(ar.elo); NETauto(ar.autohoster); NETauto(ar.details); + NETauto(ar.name); + NETauto(ar.nameTextColorOverride); + NETauto(ar.eloTextColorOverride); } } @@ -86,6 +89,22 @@ PLAYERSTATS::Autorating::Autorating(nlohmann::json const &json) elo = json["elo"].get(); autohoster = json["autohoster"].get(); details = json["details"].get(); + if (json.contains("name")) + { + name = json["name"].get(); + } + if (json.contains("nameTextColorOverride")) + { + nameTextColorOverride[0] = json["nameTextColorOverride"][0].get(); + nameTextColorOverride[1] = json["nameTextColorOverride"][1].get(); + nameTextColorOverride[2] = json["nameTextColorOverride"][2].get(); + } + if (json.contains("eloTextColorOverride")) + { + eloTextColorOverride[0] = json["eloTextColorOverride"][0].get(); + eloTextColorOverride[1] = json["eloTextColorOverride"][1].get(); + eloTextColorOverride[2] = json["eloTextColorOverride"][2].get(); + } valid = true; } catch (const std::exception &e) { debug(LOG_WARNING, "Error parsing rating JSON: %s", e.what()); @@ -165,7 +184,7 @@ void lookupRatingAsync(uint32_t playerIndex) debug(LOG_WARNING, "Failure fetching \"%s\".", urlCopy.c_str()); }); }; - req.maxDownloadSizeLimit = 4096; + req.maxDownloadSizeLimit = 4096*4; urlRequestData(req); } diff --git a/src/multistat.h b/src/multistat.h index 6e9aadbc1d8..eed40a239fb 100644 --- a/src/multistat.h +++ b/src/multistat.h @@ -75,8 +75,11 @@ struct PLAYERSTATS uint8_t star[3] = {0, 0, 0}; uint8_t medal = 0; uint8_t level = 0; + uint8_t nameTextColorOverride[3] = {255, 255, 255}; // rgb + uint8_t eloTextColorOverride[3] = {255, 255, 255}; // rgb std::string elo; std::string details; + std::string name; }; Autorating autorating; RATING_SOURCE autoratingFrom = RATING_SOURCE_HOST;