Fix player list map icon colors to match map markers
The tab player list and teleport menu now show the correct map marker color for each player. The icon is computed using the same hash as the map renderer (getRandomPlayerMapIcon) and stored by player name, bypassing the unreliable small-ID lookup that produced wrong colors on dedicated servers.
This commit is contained in:
@@ -187,6 +187,7 @@ CMinecraftApp::CMinecraftApp()
|
||||
#endif
|
||||
|
||||
ZeroMemory(m_playerColours,MINECRAFT_NET_MAX_PLAYERS);
|
||||
ZeroMemory(m_playerMapIcons,MINECRAFT_NET_MAX_PLAYERS);
|
||||
|
||||
m_iDLCOfferC=0;
|
||||
m_bAllDLCContentRetrieved=true;
|
||||
@@ -8533,6 +8534,39 @@ short CMinecraftApp::GetPlayerColour(BYTE networkSmallId)
|
||||
return index;
|
||||
}
|
||||
|
||||
void CMinecraftApp::SetPlayerMapIcon(const wchar_t* name, char icon)
|
||||
{
|
||||
if (name == nullptr) return;
|
||||
// Update existing entry or use first empty slot
|
||||
int emptySlot = -1;
|
||||
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
|
||||
{
|
||||
if (m_playerMapIcons[i].name[0] != 0 && _wcsicmp(m_playerMapIcons[i].name, name) == 0)
|
||||
{
|
||||
m_playerMapIcons[i].icon = icon;
|
||||
return;
|
||||
}
|
||||
if (emptySlot < 0 && m_playerMapIcons[i].name[0] == 0)
|
||||
emptySlot = i;
|
||||
}
|
||||
if (emptySlot >= 0)
|
||||
{
|
||||
wcsncpy_s(m_playerMapIcons[emptySlot].name, 32, name, _TRUNCATE);
|
||||
m_playerMapIcons[emptySlot].icon = icon;
|
||||
}
|
||||
}
|
||||
|
||||
char CMinecraftApp::GetPlayerMapIconByName(const wchar_t* name)
|
||||
{
|
||||
if (name == nullptr) return 0;
|
||||
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
|
||||
{
|
||||
if (m_playerMapIcons[i].name[0] != 0 && _wcsicmp(m_playerMapIcons[i].name, name) == 0)
|
||||
return m_playerMapIcons[i].icon;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned int CMinecraftApp::GetPlayerPrivileges(BYTE networkSmallId)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user