Skip to content

Commit fd1f92d

Browse files
committed
Some minor possible thread safety issues are now fixed.
1 parent d01680e commit fd1f92d

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

ghost/bnet.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,11 @@ void CBNET :: ProcessChatEvent( CIncomingChatEvent *chatEvent )
18481848
boost::mutex::scoped_lock lock( m_GHost->m_GamesMutex );
18491849

18501850
if( m_GHost->m_CurrentGame )
1851-
m_GHost->m_CurrentGame->SendAllChat( Payload );
1851+
{
1852+
boost::mutex::scoped_lock sayLock( m_GHost->m_CurrentGame->m_SayGamesMutex );
1853+
m_GHost->m_CurrentGame->m_DoSayGames.push_back( Payload );
1854+
sayLock.unlock( );
1855+
}
18521856

18531857
for( vector<CBaseGame *> :: iterator i = m_GHost->m_Games.begin( ); i != m_GHost->m_Games.end( ); ++i )
18541858
{
@@ -1997,18 +2001,27 @@ void CBNET :: ProcessChatEvent( CIncomingChatEvent *chatEvent )
19972001

19982002
if( m_GHost->m_CurrentGame && m_GHost->m_CurrentGame->GetPlayerFromName( UserName, true ) )
19992003
{
2004+
string FailMessage;
2005+
20002006
if( Message.find( "is away" ) != string :: npos )
2001-
m_GHost->m_CurrentGame->SendAllChat( m_GHost->m_Language->SpoofPossibleIsAway( UserName ) );
2007+
FailMessage = m_GHost->m_Language->SpoofPossibleIsAway( UserName );
20022008
else if( Message.find( "is unavailable" ) != string :: npos )
2003-
m_GHost->m_CurrentGame->SendAllChat( m_GHost->m_Language->SpoofPossibleIsUnavailable( UserName ) );
2009+
FailMessage = m_GHost->m_Language->SpoofPossibleIsUnavailable( UserName );
20042010
else if( Message.find( "is refusing messages" ) != string :: npos )
2005-
m_GHost->m_CurrentGame->SendAllChat( m_GHost->m_Language->SpoofPossibleIsRefusingMessages( UserName ) );
2011+
FailMessage = m_GHost->m_Language->SpoofPossibleIsRefusingMessages( UserName );
20062012
else if( Message.find( "is using Warcraft III The Frozen Throne in the channel" ) != string :: npos )
2007-
m_GHost->m_CurrentGame->SendAllChat( m_GHost->m_Language->SpoofDetectedIsNotInGame( UserName ) );
2013+
FailMessage = m_GHost->m_Language->SpoofDetectedIsNotInGame( UserName );
20082014
else if( Message.find( "is using Warcraft III The Frozen Throne in channel" ) != string :: npos )
2009-
m_GHost->m_CurrentGame->SendAllChat( m_GHost->m_Language->SpoofDetectedIsNotInGame( UserName ) );
2015+
FailMessage = m_GHost->m_Language->SpoofDetectedIsNotInGame( UserName );
20102016
else if( Message.find( "is using Warcraft III The Frozen Throne in a private channel" ) != string :: npos )
2011-
m_GHost->m_CurrentGame->SendAllChat( m_GHost->m_Language->SpoofDetectedIsInPrivateChannel( UserName ) );
2017+
FailMessage = m_GHost->m_Language->SpoofDetectedIsInPrivateChannel( UserName );
2018+
2019+
if( !FailMessage.empty( ) )
2020+
{
2021+
boost::mutex::scoped_lock sayLock( m_GHost->m_CurrentGame->m_SayGamesMutex );
2022+
m_GHost->m_CurrentGame->m_DoSayGames.push_back( FailMessage );
2023+
sayLock.unlock( );
2024+
}
20122025

20132026
if( Message.find( "is using Warcraft III The Frozen Throne in game" ) != string :: npos || Message.find( "is using Warcraft III Frozen Throne and is currently in game" ) != string :: npos )
20142027
{

ghost/ghost.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,9 @@ void CGHost :: EventBNETGameRefreshFailed( CBNET *bnet )
11951195
if( m_AdminGame )
11961196
m_AdminGame->SendAllChat( m_Language->BNETGameHostingFailed( bnet->GetServer( ), m_CurrentGame->GetGameName( ) ) );
11971197

1198-
m_CurrentGame->SendAllChat( m_Language->UnableToCreateGameTryAnotherName( bnet->GetServer( ), m_CurrentGame->GetGameName( ) ) );
1198+
boost::mutex::scoped_lock sayLock( m_CurrentGame->m_SayGamesMutex );
1199+
m_CurrentGame->m_DoSayGames.push_back( m_Language->UnableToCreateGameTryAnotherName( bnet->GetServer( ), m_CurrentGame->GetGameName( ) ) );
1200+
sayLock.unlock( );
11991201

12001202
// we take the easy route and simply close the lobby if a refresh fails
12011203
// it's possible at least one refresh succeeded and therefore the game is still joinable on at least one battle.net (plus on the local network) but we don't keep track of that

0 commit comments

Comments
 (0)