Skip to content

Commit

Permalink
Fix #1223: Regression: double chat messages if player is in team (#1241)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrixG committed Jan 31, 2020
1 parent 19eb2e6 commit a5508d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
18 changes: 2 additions & 16 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Expand Up @@ -9970,29 +9970,15 @@ bool CStaticFunctionDefinitions::OutputChatBox(const char* szText, CElement* pEl
{
assert(pElement);
assert(szText);

RUN_CHILDREN(OutputChatBox(szText, *iter, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain))

if (IS_PLAYER(pElement))
{
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
pPlayer->Send(CChatEchoPacket(szText, ucRed, ucGreen, ucBlue, bColorCoded));
return true;
}
else if (IS_TEAM(pElement))
{
CTeam* pTeam = static_cast<CTeam*>(pElement);
list<CPlayer*>::const_iterator iter = pTeam->PlayersBegin();
for (; iter != pTeam->PlayersEnd(); iter++)
{
CPlayer* pPlayer = *iter;
pPlayer->Send(CChatEchoPacket(szText, ucRed, ucGreen, ucBlue, bColorCoded));
}
return true;
}
else
{
// Fixes issue 1223: https://github.com/multitheftauto/mtasa-blue/issues/1223 (Luxy.c)
RUN_CHILDREN(OutputChatBox(szText, *iter, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain))
}

if (pElement == m_pMapManager->GetRootElement())
{
Expand Down
20 changes: 16 additions & 4 deletions Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Server.cpp
Expand Up @@ -83,11 +83,23 @@ int CLuaFunctionDefs::OutputChatBox(lua_State* luaVM)
{
if (pElement)
{
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, pElement, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain);
lua_pushboolean(luaVM, true);
return 1;
if (IS_TEAM(pElement))
{
CTeam* pTeam = static_cast<CTeam*>(pElement);
for (auto iter = pTeam->PlayersBegin(); iter != pTeam->PlayersEnd(); iter++)
{
sendList.push_back(*iter);
}
}
else
{
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, pElement, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain);
lua_pushboolean(luaVM, true);
return 1;
}
}
else if (sendList.size() > 0)

if (sendList.size() > 0)
{
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, sendList, ucRed, ucGreen, ucBlue, bColorCoded);
lua_pushboolean(luaVM, true);
Expand Down

0 comments on commit a5508d8

Please sign in to comment.