diff options
| author | SemperVinco <w.deweijer@hotmail.com> | 2017-03-03 14:21:03 +0100 | 
|---|---|---|
| committer | SemperVinco <w.deweijer@hotmail.com> | 2017-03-03 14:21:03 +0100 | 
| commit | bf5fa43b838cfea11e16a3339b10174ea28ea918 (patch) | |
| tree | 7420b208e17e6e96eecad95a8a68c633a86cafac | |
| parent | 9f38c82b01c44410bb7778d2607f38daec9dfb35 (diff) | |
add single step option -t, make step printing accurate
| -rw-r--r-- | main.cpp | 13 | ||||
| -rw-r--r-- | parse.cpp | 2 | ||||
| -rw-r--r-- | parse.h | 2 | 
3 files changed, 12 insertions, 5 deletions
@@ -48,7 +48,7 @@ int parseInt(const char *str){  }  void usage(char **argv){ -	cerr<<"Usage: "<<argv[0]<<" [-r <fname>]* [-p <fname> <x> <y> <heading>]* [-s <sleeptime>]"<<endl; +	cerr<<"Usage: "<<argv[0]<<" [-r <fname>]* [-p <fname> <x> <y> <heading>]* [-s <sleeptime>] [-t]"<<endl;  }  int main(int argc,char **argv){ @@ -61,6 +61,7 @@ int main(int argc,char **argv){  	vector<RobotSpec> robotSpecs;  	int sleeptime=3000; +	bool step = false;  	if(argc<=1){  		usage(argv); @@ -104,6 +105,10 @@ int main(int argc,char **argv){  				i+=1;  				break; +			case 't': +				step = true; +				break; +  			default:  				cerr<<"Unknown switch in '"<<argv[i]<<"'"<<endl;  				return 1; @@ -131,11 +136,13 @@ int main(int argc,char **argv){  	signal(SIGINT,signalHandler);  #endif  	world.print(*sb); +	sb->draw();  	for(int i=0;i<C::autoTimeout;i++){ -		usleep(sleeptime); +		if(step) cin.get(); +		else usleep(sleeptime);  		world.tick();  		world.print(*sb); -		sb->mvprintf(0, SIZE, "step: %5i", i); +		sb->mvprintf(0, SIZE, "step: %5i", i+2);  		sb->draw();  	}  	delete sb; @@ -199,4 +199,4 @@ string preprocess(istream &file){  	}  	return result; -}
\ No newline at end of file +} @@ -8,4 +8,4 @@ using namespace std;  Team assemble(const string &source); -string preprocess(istream &file);
\ No newline at end of file +string preprocess(istream &file);  | 
