Skip to content

Commit a5508d8

Browse files
authored
Fix #1223: Regression: double chat messages if player is in team (#1241)
1 parent 19eb2e6 commit a5508d8

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9970,29 +9970,15 @@ bool CStaticFunctionDefinitions::OutputChatBox(const char* szText, CElement* pEl
99709970
{
99719971
assert(pElement);
99729972
assert(szText);
9973+
9974+
RUN_CHILDREN(OutputChatBox(szText, *iter, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain))
99739975

99749976
if (IS_PLAYER(pElement))
99759977
{
99769978
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
99779979
pPlayer->Send(CChatEchoPacket(szText, ucRed, ucGreen, ucBlue, bColorCoded));
99789980
return true;
99799981
}
9980-
else if (IS_TEAM(pElement))
9981-
{
9982-
CTeam* pTeam = static_cast<CTeam*>(pElement);
9983-
list<CPlayer*>::const_iterator iter = pTeam->PlayersBegin();
9984-
for (; iter != pTeam->PlayersEnd(); iter++)
9985-
{
9986-
CPlayer* pPlayer = *iter;
9987-
pPlayer->Send(CChatEchoPacket(szText, ucRed, ucGreen, ucBlue, bColorCoded));
9988-
}
9989-
return true;
9990-
}
9991-
else
9992-
{
9993-
// Fixes issue 1223: https://github.com/multitheftauto/mtasa-blue/issues/1223 (Luxy.c)
9994-
RUN_CHILDREN(OutputChatBox(szText, *iter, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain))
9995-
}
99969982

99979983
if (pElement == m_pMapManager->GetRootElement())
99989984
{

Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Server.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,23 @@ int CLuaFunctionDefs::OutputChatBox(lua_State* luaVM)
8383
{
8484
if (pElement)
8585
{
86-
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, pElement, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain);
87-
lua_pushboolean(luaVM, true);
88-
return 1;
86+
if (IS_TEAM(pElement))
87+
{
88+
CTeam* pTeam = static_cast<CTeam*>(pElement);
89+
for (auto iter = pTeam->PlayersBegin(); iter != pTeam->PlayersEnd(); iter++)
90+
{
91+
sendList.push_back(*iter);
92+
}
93+
}
94+
else
95+
{
96+
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, pElement, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain);
97+
lua_pushboolean(luaVM, true);
98+
return 1;
99+
}
89100
}
90-
else if (sendList.size() > 0)
101+
102+
if (sendList.size() > 0)
91103
{
92104
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, sendList, ucRed, ucGreen, ucBlue, bColorCoded);
93105
lua_pushboolean(luaVM, true);

0 commit comments

Comments
 (0)