diff --git a/src/base/color.h b/src/base/color.h index f1a7577de..f3ea22ed5 100644 --- a/src/base/color.h +++ b/src/base/color.h @@ -102,22 +102,40 @@ public: class ColorHSLA : public color4_base { public: + bool m_Lit = false; + using color4_base::color4_base; ColorHSLA() {}; ColorHSLA(color4_base b): color4_base(b) {}; ColorHSLA Lighten() { + if(m_Lit) + return *this; + ColorHSLA col = *this; col.l = 0.5f + l * 0.5f; + col.m_Lit = true; return col; }; - int PackLegacy() + ColorHSLA Darken() { - ColorHSLA t = *this; - t.l = (t.l - 0.5f) * 2; - return t.Pack(); + if(!m_Lit) + return *this; + + ColorHSLA col = *this; + col.l = (l - 0.5f) * 2; + col.m_Lit = false; + return col; + } + + int Pack() + { + if(m_Lit) + return Darken().color4_base::Pack(); + else + return color4_base::Pack(); } }; diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index b31d1bb37..442e9cd1b 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -46,7 +46,6 @@ ColorHSLA CConsole::CResult::GetColor(unsigned Index, bool Light) const char *pStr = m_apArgs[Index]; if(str_isallnum(pStr) || ((pStr[0] == '-' || pStr[0] == '+') && str_isallnum(pStr+1))) // Teeworlds Color (Packed HSL) { - dbg_msg("DEBUG", "HERE %s %d", pStr, str_toint(pStr)); hsl = ColorHSLA(str_toint(pStr), true); } else if(*pStr == '$') // Hex RGB diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index b36354ffd..82b211b7e 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1685,8 +1685,8 @@ void CGameClient::SendInfo(bool Start) Msg.m_Country = g_Config.m_PlayerCountry; Msg.m_pSkin = g_Config.m_ClPlayerSkin; Msg.m_UseCustomColor = g_Config.m_ClPlayerUseCustomColor; - Msg.m_ColorBody = ColorHSLA(g_Config.m_ClPlayerColorBody).PackLegacy(); - Msg.m_ColorFeet = ColorHSLA(g_Config.m_ClPlayerColorFeet).PackLegacy(); + Msg.m_ColorBody = g_Config.m_ClPlayerColorBody; + Msg.m_ColorFeet = g_Config.m_ClPlayerColorFeet; CMsgPacker Packer(Msg.MsgID()); Msg.Pack(&Packer); Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0); @@ -1700,8 +1700,8 @@ void CGameClient::SendInfo(bool Start) Msg.m_Country = g_Config.m_PlayerCountry; Msg.m_pSkin = g_Config.m_ClPlayerSkin; Msg.m_UseCustomColor = g_Config.m_ClPlayerUseCustomColor; - Msg.m_ColorBody = ColorHSLA(g_Config.m_ClPlayerColorBody).PackLegacy(); - Msg.m_ColorFeet = ColorHSLA(g_Config.m_ClPlayerColorFeet).PackLegacy(); + Msg.m_ColorBody = g_Config.m_ClPlayerColorBody; + Msg.m_ColorFeet = g_Config.m_ClPlayerColorFeet; CMsgPacker Packer(Msg.MsgID()); Msg.Pack(&Packer); Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0); @@ -1719,8 +1719,8 @@ void CGameClient::SendDummyInfo(bool Start) Msg.m_Country = g_Config.m_ClDummyCountry; Msg.m_pSkin = g_Config.m_ClDummySkin; Msg.m_UseCustomColor = g_Config.m_ClDummyUseCustomColor; - Msg.m_ColorBody = ColorHSLA(g_Config.m_ClDummyColorBody).PackLegacy(); - Msg.m_ColorFeet = ColorHSLA(g_Config.m_ClDummyColorFeet).PackLegacy(); + Msg.m_ColorBody = g_Config.m_ClDummyColorBody; + Msg.m_ColorFeet = g_Config.m_ClDummyColorFeet; CMsgPacker Packer(Msg.MsgID()); Msg.Pack(&Packer); Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 1); @@ -1734,8 +1734,8 @@ void CGameClient::SendDummyInfo(bool Start) Msg.m_Country = g_Config.m_ClDummyCountry; Msg.m_pSkin = g_Config.m_ClDummySkin; Msg.m_UseCustomColor = g_Config.m_ClDummyUseCustomColor; - Msg.m_ColorBody = ColorHSLA(g_Config.m_ClDummyColorBody).PackLegacy(); - Msg.m_ColorFeet = ColorHSLA(g_Config.m_ClDummyColorFeet).PackLegacy(); + Msg.m_ColorBody = g_Config.m_ClDummyColorBody; + Msg.m_ColorFeet = g_Config.m_ClDummyColorFeet; CMsgPacker Packer(Msg.MsgID()); Msg.Pack(&Packer); Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 1);