bool Spring::Run( OfflineBattle& battle ) { wxString path = battle.GetPlayBackFilePath(); return LaunchSpring( _T("\"") + path + _T("\"") ); }
bool Spring::Run(const IBattlePtr battle ) { BF::path path = sett().GetCurrentUsedDataDir(); path /= "script.txt"; try { BF::ofstream f( path ); if ( !f.is_open() ) { LslError( "Access denied to script.txt at %s", path.string().c_str() ); } battle->DisableHostStatusInProxyMode( true ); f << WriteScriptTxt(battle); battle->DisableHostStatusInProxyMode( false ); f.close(); } catch ( std::exception& e ) { LslError( "Couldn't write script.txt, exception caught:\n %s", e.what() ); return false; } catch (...) { LslError( "Couldn't write script.txt" ); return false; } std::string cmd; //! TODO // if ( battle->GetAutoHost().GetEnabled() ) // { // // -m, --minimise Start minimised // // -q [T], --quit=[T] Quit immediately on game over or after T seconds // cmd = "--minimise"; // } cmd += std::string(" \"" + path.string() + "\""); return LaunchSpring( cmd ); }
bool Spring::Run( NoGuiSinglePlayerBattle& battle ) { wxString path = sett().GetCurrentUsedDataDir() + wxFileName::GetPathSeparator() + _T("script.txt"); try { if ( !wxFile::Access( path, wxFile::write ) ) { wxLogError( _T("Access denied to script.txt.") ); } wxFile f( path, wxFile::write ); f.Write( WriteScriptTxt(battle) ); f.Close(); } catch (...) { wxLogError( _T("Couldn't write script.txt") ); return false; } return LaunchSpring( _T("\"") + path + _T("\"") ); }
bool Spring::Run( SinglePlayerBattle& battle ) { wxString path = sett().GetCurrentUsedDataDir() + wxFileName::GetPathSeparator() + _T("script.txt"); try { if ( !wxFile::Access( path, wxFile::write ) ) { wxLogError( _T("Access denied to script.txt.") ); } wxFile f( path, wxFile::write ); f.Write( WriteScriptTxt(battle) ); f.Close(); } catch ( std::exception& e ) { wxLogError( wxString::Format( _T("Couldn't write script.txt, exception caught:\n %s"), TowxString( e.what() ).c_str() ) ); return false; } catch (...) { wxLogError( _T("Couldn't write script.txt") ); return false; } return LaunchSpring( _T("\"") + path + _T("\"") ); }
bool Spring::Run( Battle& battle ) { wxString path = sett().GetCurrentUsedDataDir() + wxFileName::GetPathSeparator() + _T("script.txt"); try { if ( !wxFile::Access( path , wxFile::write ) ) { wxLogError( _T("Access denied to script.txt.") ); } wxFile f( path, wxFile::write ); battle.DisableHostStatusInProxyMode( true ); f.Write( WriteScriptTxt(battle) ); battle.DisableHostStatusInProxyMode( false ); f.Close(); } catch ( std::exception& e ) { wxLogError( wxString::Format( _T("Couldn't write script.txt, exception caught:\n %s"), TowxString( e.what() ).c_str() ) ); return false; } catch (...) { wxLogError( _T("Couldn't write script.txt") ); return false; } #if 0 //TODO: BD, isn't this SUPER obsolete wxString CommandForAutomaticTeamSpeak = _T("SCRIPT|") + battle.GetFounder().GetNick() + _T("|"); for ( UserList::user_map_t::size_type i = 0; i < battle.GetNumUsers(); i++ ) { CommandForAutomaticTeamSpeak << TowxString<unsigned int>( battle.GetUser(i).BattleStatus().ally) << _T("|") << battle.GetUser(i).GetNick() << _T("|"); } // torrent().SendMessageToCoordinator(CommandForAutomaticTeamSpeak); //this is gone too now, right? #endif wxString cmd; if ( battle.GetAutoHost().GetEnabled() ) { // -m, --minimise Start minimised // -q [T], --quit=[T] Quit immediately on game over or after T seconds cmd = _T("--minimise"); } cmd += _T(" \"") + path + _T("\""); return LaunchSpring( cmd ); }
bool Spring::Run(const std::string& script) { BF::path path = sett().GetCurrentUsedDataDir(); path /= "script.txt"; std::string cmd = std::string(" \"" + path.string() + "\""); try { BF::ofstream f( path ); if ( !f.is_open() ) { LslError( "Access denied to script.txt at %s", path.string().c_str() ); } f << script; f.close(); } catch ( std::exception& e ) { LslError( "Couldn't write script.txt, exception caught:\n %s", e.what() ); return false; } catch (...) { LslError( "Couldn't write script.txt" ); return false; } return LaunchSpring( cmd ); }
bool Spring::RunReplay ( const wxString& filename ) { wxLogMessage( _T("launching spring with replay: ") + filename ); return LaunchSpring( _T("\"") + filename + _T("\"") ); }
bool Spring::RunReplay ( const std::string& filename ) { LslDebug( "launching spring with replay: %s", filename.c_str() ); return LaunchSpring( "\"" + filename + "\""); }
bool Spring::Run( Battle::OfflineBattle& battle ) { std::string path = battle.GetPlayBackFilePath(); return LaunchSpring( "\"" + path + "\"" ); }