Jelajahi Sumber

New command line option for testing: testingsavefrequency

Saving is slowest part of VCMI and for testing purposes like benchmarking it's helpful to create saves less often.
When --testingsavefrequency=N is specified client going to save only once in N days.

Option only active if other testing options are specified too.
Arseniy Shestakov 9 tahun lalu
induk
melakukan
9963b9e02b
2 mengubah file dengan 4 tambahan dan 2 penghapusan
  1. 3 1
      client/CMT.cpp
  2. 1 1
      client/CPlayerInterface.cpp

+ 3 - 1
client/CMT.cpp

@@ -248,7 +248,8 @@ int main(int argc, char** argv)
         ("loadserverip",po::value<std::string>(),"IP for loaded game server")
 		("loadserverport",po::value<std::string>(),"port for loaded game server")
 		("testingport",po::value<std::string>(),"port for testing, override specified in config file")
-		("testingfileprefix",po::value<std::string>(),"prefix for auto save files");
+		("testingfileprefix",po::value<std::string>(),"prefix for auto save files")
+		("testingsavefrequency",po::value<int>(),"how often auto save should be created");
 
 	if(argc > 1)
 	{
@@ -313,6 +314,7 @@ int main(int argc, char** argv)
 		testingSettings["enabled"].Bool() = true;
 		testingSettings["port"].String() = vm["testingport"].as<std::string>();
 		testingSettings["prefix"].String() = vm["testingfileprefix"].as<std::string>();
+		testingSettings["savefrequency"].Float() = vm.count("testingsavefrequency") ? vm["testingsavefrequency"].as<int>() : 1;
 	}
 
 	// Initialize logging based on settings

+ 1 - 1
client/CPlayerInterface.cpp

@@ -178,7 +178,7 @@ void CPlayerInterface::yourTurn()
 			}
 			firstCall = 0;
 		}
-		else
+		else if(settings["testing"].isNull() || cb->getDate() % static_cast<int>(settings["testing"]["savefrequency"].Float()) == 0)
 		{
 			LOCPLINT->cb->save("Saves/" + prefix + "Autosave_" + boost::lexical_cast<std::string>(autosaveCount++ + 1));
 			autosaveCount %= 5;