diff --git a/source/game/game.cpp b/source/game/game.cpp index 0608415..3608f70 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -144,7 +144,10 @@ int CTTRTSGame::SimulateToNextTurn() // If any unit is in this spot, or moving unit moving to said spot, reject this for ( const OrderUnitPair& pair2 : m_OrderUnitPairs ) { - if( GetNewPosition(pair2) != newpos ) + // Skip myself + if( pair.unit.getID() == pair2.unit.getID() ) continue; + + if( GetNewPosition(pair2) == newpos ) { possible = false; break; diff --git a/source/ttrts/main.cpp b/source/ttrts/main.cpp index cbdbca7..7ecc424 100644 --- a/source/ttrts/main.cpp +++ b/source/ttrts/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "game.h" @@ -26,6 +27,25 @@ inline void WaitForFile( const std::string& name, const std::chrono::millisecond while( !FileExists(name) ) std::this_thread::sleep_for(time); } +bool OutputGameStateFile(CTTRTSGame &game, std::string &gameDir) +{ + char turnFileName[128]; + snprintf(turnFileName,128,"%s/Turn_%i.txt",gameDir.c_str(),game.GetTurn()); + std::ofstream turnFile(turnFileName, std::ios_base::trunc); // truncate to overwrite if a file exists + + if ( turnFile.bad() ) + { + return false; + } + + // Output the turn description + std::string turnDescriptor = game.GetStateAsString(); + turnFile<>input; + if( !input.size() || std::tolower(input[0]) != 'y' ) + { + std::cerr<<"Aborting..."< 0 ) // We have no units left + { + std::cout<<"Starting turn "<