void ServerEvents::OnUserStatus( const wxString& nick, UserStatus status ) { wxLogDebugFunc( _T("") ); try { wxLogMessage( _T("calling m_serv.GetUser( nick ) ") ); User& user = m_serv.GetUser( nick ); wxLogMessage( _T("calling user.SetStatus( status ) ") ); UserStatus oldStatus = user.GetStatus(); user.SetStatus( status ); if ( useractions().DoActionOnUser( UserActions::ActNotifStatus, nick ) ) { wxString diffString = status.GetDiffString( oldStatus ) ; if ( diffString != wxEmptyString ) actNotifBox( SL_MAIN_ICON, nick + _(" is now ") + diffString ); } wxLogMessage( _T("calling ui().OnUserStatusChanged( user ) ") ); ui().OnUserStatusChanged( user ); wxLogMessage( _T("updating battles ") ); if ( user.GetBattle() != 0 ) { Battle& battle = *user.GetBattle(); try { if ( battle.GetFounder().GetNick() == user.GetNick() ) { if ( status.in_game != battle.GetInGame() ) { battle.SetInGame( status.in_game ); if ( status.in_game ) battle.StartSpring(); else BattleEvents::GetBattleEventSender( BattleEvents::BattleInfoUpdate ).SendEvent( std::make_pair(user.GetBattle(),wxString()) ); } } }catch(...){} } } catch (...) { wxLogWarning( _("OnUserStatus() failed ! (exception)") ); } }
void ServerEvents::OnUserStatus(const std::string& nick, UserStatus status) { slLogDebugFunc(""); try { User& user = m_serv.GetUser(nick); UserStatus oldStatus = user.GetStatus(); user.SetStatus(status); if (useractions().DoActionOnUser(UserActions::ActNotifStatus, TowxString(nick))) { wxString diffString = TowxString(status.GetDiffString(oldStatus)); if (diffString != wxEmptyString) actNotifBox(SL_MAIN_ICON, TowxString(nick) + _(" is now ") + diffString); } if (m_serv.IsOnline()) { //login info isn't complete yet ui().OnUserStatusChanged(user); } if (user.GetBattle() != 0) { IBattle& battle = *user.GetBattle(); try { if (battle.GetFounder().GetNick() == user.GetNick()) { if (status.in_game != battle.GetInGame()) { battle.SetInGame(status.in_game); if (m_serv.IsOnline()) { if (status.in_game) { battle.StartSpring(); } else { ui().OnBattleInfoUpdated(battle, wxEmptyString); } } } } } catch (...) { } } } catch (...) { wxLogWarning(_("OnUserStatus() failed ! (exception)")); } }