void ServerEvents::OnHostedBattle( int battleid ) { wxLogDebugFunc( _T("") ); try { Battle& battle = m_serv.GetBattle( battleid ); if ( battle.GetBattleType() == BT_Played ) { battle.CustomBattleOptions().loadOptions( OptionsWrapper::MapOption, battle.GetHostMapName() ); battle.CustomBattleOptions().loadOptions( OptionsWrapper::ModOption, battle.GetHostModName() ); } else { battle.GetBattleFromScript( true ); } wxString presetname = sett().GetModDefaultPresetName( battle.GetHostModName() ); if ( !presetname.IsEmpty() ) { battle.LoadOptionsPreset( presetname ); } battle.LoadMapDefaults( battle.GetHostMapName() ); m_serv.SendHostInfo( IBattle::HI_Send_All_opts ); ui().OnHostedBattle( battle ); } catch (assert_exception) {} }
void ServerEvents::OnStartHostedBattle( int battleid ) { wxLogDebugFunc( _T("") ); Battle& battle = m_serv.GetBattle( battleid ); battle.SetInGame( true ); battle.StartSpring(); }
void ServerEvents::OnUserQuit( const wxString& nick ) { wxLogDebugFunc( _T("") ); try { User &user=m_serv.GetUser( nick ); Battle* userbattle = user.GetBattle(); if ( userbattle ) { int battleid = userbattle->GetID(); try { if ( &userbattle->GetFounder() == &user ) { for ( int i = 0; i < int(userbattle->GetNumUsers()); i ++ ) { User& battleuser = userbattle->GetUser( i ); OnUserLeftBattle( battleid, battleuser.GetNick() ); } OnBattleClosed( battleid ); } else OnUserLeftBattle( battleid, user.GetNick() ); }catch(...){} } ui().OnUserOffline( user ); m_serv._RemoveUser( nick ); if ( useractions().DoActionOnUser( UserActions::ActNotifLogin, nick ) ) actNotifBox( SL_MAIN_ICON, nick + _(" just went offline") ); } catch (std::runtime_error &except) { } }
int OptionsWrapper::GetAIOptionIndex( const wxString& nick ) const { std::map<wxString,int>::const_iterator itor = m_ais_indexes.find(nick); int pos = -1; if ( itor != m_ais_indexes.end() ) pos = itor->second; wxLogDebugFunc( _T("bot name: ") + nick + _T(" option index: ") + TowxString( pos ) ); return pos; }
void MapSelectDialog::OnMapGridLeftDClick(wxMouseEvent& /*unused*/) { wxLogDebugFunc( _T("") ); if ( m_mapgrid->GetSelectedMap() ) { EndModal( wxID_OK ); } }
PlaybackTab<PlaybackTraits>::~PlaybackTab() { m_minimap->SetBattle( NULL ); if ( m_filter != 0 ) m_filter->SaveFilterValues(); wxLogDebugFunc( _T( "" ) ); }
void MapSelectDialog::OnInit( wxInitDialogEvent& /*unused*/ ) { wxLogDebugFunc( _T("") ); AppendSortKeys( m_horizontal_choice ); AppendSortKeys( m_vertical_choice ); m_horizontal_choice->SetSelection( sett().GetHorizontalSortkeyIndex() ); m_vertical_choice->SetSelection( sett().GetVerticalSortkeyIndex() ); m_horizontal_direction_button->SetLabel( m_horizontal_direction ? _T("<") : _T(">") ); m_vertical_direction_button->SetLabel( m_vertical_direction ? _T("ᴧ") : _T("ᴠ") ); m_maps = LSL::Util::vectorToArrayString(LSL::usync().GetMapList()); //true meaning replays, flase meaning savegames m_replays = LSL::Util::vectorToArrayString(LSL::usync().GetPlaybackList(true)); const unsigned int lastFilter = sett().GetMapSelectorFilterRadio(); m_filter_popular->Enable( ui().IsConnected() ); // due to a bug / crappy design in SpringUnitSync / unitsync itself we // get a replay list with one empty item when there are no replays.. bool no_replays = m_replays.empty() || ( m_replays.size() == 1 && m_replays[0] == wxEmptyString ); if ( no_replays ) { m_filter_all->SetValue( true ); m_filter_recent->Enable( false ); } if ( lastFilter == m_filter_popular_sett ) { if ( ui().IsConnected() ) { m_filter_popular->SetValue( true ); LoadPopular(); } else { m_filter_all->SetValue( true ); LoadAll(); } } else if ( lastFilter == m_filter_recent_sett ) { if ( !no_replays ) { m_filter_recent->Enable( true ); m_filter_recent->SetValue( true ); LoadRecent(); } else { m_filter_all->SetValue( true ); LoadAll(); } } else { m_filter_all->SetValue( true ); LoadAll(); } UpdateSortAndFilter(); m_filter_text->SetFocus(); }
UnitSyncMod SpringUnitSync::GetMod( int index ) { wxLogDebugFunc( _T("") ); UnitSyncMod m; m.name = m_mod_array[index]; m.hash = m_mods_list[m.name]; return m; }
int SpringUnitSync::GetNumUnits( const wxString& modname ) const { wxLogDebugFunc( _T("") ); susynclib().AddAllArchives( susynclib().GetPrimaryModArchive( m_unsorted_mod_array.Index( modname ) ) ); susynclib().ProcessUnitsNoChecksum(); return susynclib().GetUnitCount(); }
void SpringUnitSync::GetMinimapAsync( const wxString& mapname, int width, int height, int evtHandlerId ) { wxLogDebugFunc( mapname + _T(" size: ") + TowxString(width) + _T("x") + TowxString(height) ); GetScaledMapImageAsyncWorkItem* work; work = new GetScaledMapImageAsyncWorkItem( this, mapname, width, height, evtHandlerId, &SpringUnitSync::GetMinimap ); m_cache_thread.DoWork( work, 100 ); }
void Spring::OnTerminated( wxCommandEvent& event ) { wxLogDebugFunc( _T("") ); m_running = false; m_process = 0; // NOTE I'm not sure if this should be deleted or not, according to wx docs it shouldn't. m_wx_process = 0; event.SetEventType(GlobalEvent::OnSpringTerminated); GlobalEvent::Send(event); }
void SpringUnitSync::GetMapExAsync( const wxString& mapname, int evtHandlerId ) { wxLogDebugFunc( mapname ); GetMapExAsyncWorkItem* work; work = new GetMapExAsyncWorkItem( this, mapname, evtHandlerId ); m_cache_thread.DoWork( work, 200 /* higher prio then GetMinimapAsync */ ); }
void Spring::OnTerminated( wxCommandEvent& event ) { wxLogDebugFunc( _T("") ); m_running = false; m_process = 0; // NOTE I'm not sure if this should be deleted or not, according to wx docs it shouldn't. m_wx_process = 0; ui().OnSpringTerminated( event.GetExtraLong() ); GetGlobalEventSender(GlobalEvents::OnSpringTerminated).SendEvent( event.GetExtraLong() ); }
void ChatPanel::Part() { wxLogDebugFunc( _T( "" ) ); if ( m_type == CPT_Channel ) { if ( m_channel == 0 ) return; m_channel->Leave(); m_channel->uidata.panel = 0; } }
UnitSyncMod SpringUnitSync::GetMod( const wxString& modname ) { wxLogDebugFunc( _T("modname = \"") + modname + _T("\"") ); UnitSyncMod m; m.name = modname; m.hash = m_mods_list[modname]; return m; }
void BattleRoomTab::OnMapBrowse( wxCommandEvent& /*unused*/ ) { if ( !m_battle ) return; wxLogDebugFunc( _T( "" ) ); if ( mapSelectDialog().ShowModal() == wxID_OK && mapSelectDialog().GetSelectedMap() != NULL ) { wxString mapname = mapSelectDialog().GetSelectedMap()->name; wxLogDebugFunc( mapname ); if ( !m_battle->IsFounderMe() ) { m_battle->DoAction( _T( "suggests " ) + mapname ); return; } const int idx = m_map_combo->FindString( mapname, true /*case sensitive*/ ); if ( idx != wxNOT_FOUND ) SetMap( idx ); } }
UnitSyncMap SpringUnitSync::GetMap( const wxString& mapname ) { wxLogDebugFunc( _T("") ); UnitSyncMap m; m.name = mapname; m.hash = m_maps_list[mapname]; return m; }
UnitSyncMap SpringUnitSync::GetMap( int index ) { wxLogDebugFunc( _T("") ); UnitSyncMap m; m.name = m_map_array[index]; m.hash = m_maps_list[m.name]; return m; }
void BattleroomListCtrl::OnColourSelect( wxCommandEvent& /*unused*/ ) { wxLogDebugFunc( _T("") ); wxColour CurrentColour = m_sel_user->BattleStatus().colour; CurrentColour = GetColourFromUser(this, CurrentColour); if ( !CurrentColour.IsOk() ) return; if( m_sel_user ) ((Battle*)m_battle)->ForceColour( *m_sel_user, CurrentColour ); }
void ServerEvents::OnBattleInfoUpdated( int battleid ) { wxLogDebugFunc( _T("") ); try { Battle& battle = m_serv.GetBattle( battleid ); BattleEvents::GetBattleEventSender( BattleEvents::BattleInfoUpdate ).SendEvent( std::make_pair(&battle,wxString()) ); } catch ( assert_exception ) {} }
void SimpleServerEvents::OnBattleInfoUpdated( int /*battleid*/ ) { wxLogDebugFunc( _T("") ); try { // Battle& battle = m_serv.GetBattle( battleid ); // ui().OnBattleInfoUpdated( battle ); } catch ( assert_exception ) {} }
void BattleroomListCtrl::OnHandicapSelect( wxCommandEvent& /*unused*/ ) { wxLogDebugFunc( _T("") ); if( !m_sel_user ) return; long handicap = wxGetNumberFromUser( _("Please enter a value between 0 and 100"), _("Set Resource Bonus"), _T(""), m_sel_user->BattleStatus().handicap, 0, 100, (wxWindow*)&ui().mw(), wxDefaultPosition ); if ( handicap != -1 ) { ((Battle*)m_battle)->SetHandicap( *m_sel_user, handicap ); } }
TorrentWrapper::~TorrentWrapper() { wxLogDebugFunc( wxEmptyString ); m_info_download_thread.Wait(); m_torr->pause(); ClearFinishedTorrents(); RemoveInvalidTorrents(); /* the use of Settings seems to a problem (destruction order) therefore disabled until further notice //save torrents to resume std::vector<wxString> toResume; TorrenthandleInfoMap infomap = GetHandleInfoMap(); TorrenthandleInfoMap::iterator it = infomap.begin(); for ( ; it != infomap.end(); ++it ) { PlasmaResourceInfo info = it->first; toResume.push_back( info.m_name ); } std::vector<wxString> currentResumes = sett().GetTorrentListToResume(); for ( std::vector<wxString>::const_iterator it = currentResumes.begin(); it != currentResumes.end(); ++it ) { toResume.push_back( *it ); } //save new list sett().SetTorrentListToResume( toResume ); */ #ifndef __WXMSW__ try { m_torr->stop_upnp(); } catch (std::exception& e) { wxLogError( TowxString( e.what() ) ); } try { m_torr->stop_natpmp(); } catch (std::exception& e) { wxLogError( TowxString( e.what() ) ); } try { m_torr->stop_lsd(); } catch (std::exception& e) { wxLogError( TowxString( e.what() ) ); } #endif delete m_torr; }
void SinglePlayerTab::OnMapBrowse( wxCommandEvent& /*unused*/ ) { wxLogDebugFunc( wxEmptyString ); const wxString mapname = mapSelectDialog(); if ( !mapname.empty()) { const int idx = m_map_pick->FindString( mapname, true /*case sensitive*/ ); if ( idx != wxNOT_FOUND ) { SetMap( idx ); } } }
void SimpleServerEvents::OnUserJoinChannel( const wxString& channel, const wxString& who ) { wxLogDebugFunc( _T("") ); try { m_serv.GetChannel( channel ).Joined( m_serv.GetUser( who ) ); } catch (std::runtime_error &except) { } }
void SimpleServerEvents::OnChannelAction( const wxString& channel, const wxString& who, const wxString& action ) { wxLogDebugFunc( _T("") ); try { m_serv.GetChannel( channel ).DidAction( m_serv.GetUser( who ), action ); } catch (std::runtime_error &except) { } }
void SimpleServerEvents::OnChannelTopic( const wxString& channel, const wxString& who, const wxString& message, int /*unused*/ ) { wxLogDebugFunc( _T("") ); try { m_serv.GetChannel( channel ).SetTopic( message, who ); } catch (std::runtime_error &except) { } }
void SimpleServerEvents::OnChannelPart( const wxString& channel, const wxString& who, const wxString& message ) { wxLogDebugFunc( _T("") ); try { m_serv.GetChannel( channel ).Left( m_serv.GetUser( who ), message ); } catch (std::runtime_error &except) { } }
void SimpleServerEvents::OnBattleEnableAllUnits( int battleid ) { wxLogDebugFunc( _T("") ); try { Battle& battle = m_serv.GetBattle( battleid ); battle.UnrestrictAllUnits(); battle.Update( wxString::Format( _T("%d_restrictions"), OptionsWrapper::PrivateOptions ) ); } catch ( assert_exception ) {} }
void SimpleServerEvents::OnBattleDisableUnit( int battleid, const wxString& unitname, int count ) { wxLogDebugFunc( _T("") ); try { Battle& battle = m_serv.GetBattle( battleid ); battle.RestrictUnit( unitname, count ); battle.Update( wxString::Format( _T("%d_restrictions"), OptionsWrapper::PrivateOptions ) ); } catch ( assert_exception ) {} }