mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Use API identical to std classes where possible
This commit is contained in:
		| @@ -1607,7 +1607,7 @@ void AIStatus::waitTillFree() | ||||
| { | ||||
| 	boost::unique_lock<boost::mutex> lock(mx); | ||||
| 	while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement) | ||||
| 		cv.timed_wait(lock, boost::posix_time::milliseconds(10)); | ||||
| 		cv.wait_for(lock, boost::chrono::milliseconds(10)); | ||||
| } | ||||
|  | ||||
| bool AIStatus::haveTurn() | ||||
|   | ||||
| @@ -108,7 +108,7 @@ void CStupidAI::yourTacticPhase(int distance) | ||||
|  | ||||
| void CStupidAI::activeStack( const CStack * stack ) | ||||
| { | ||||
| 	//boost::this_thread::sleep(boost::posix_time::seconds(2)); | ||||
| 	//boost::this_thread::sleep_for(boost::chrono::seconds(2)); | ||||
| 	print("activeStack called for " + stack->nodeName()); | ||||
| 	ReachabilityInfo dists = cb->getReachability(stack); | ||||
| 	std::vector<EnemyInfo> enemiesShootable, enemiesReachable, enemiesUnreachable; | ||||
|   | ||||
| @@ -2677,7 +2677,7 @@ void AIStatus::waitTillFree() | ||||
| { | ||||
| 	boost::unique_lock<boost::mutex> lock(mx); | ||||
| 	while(battle != NO_BATTLE || !remainingQueries.empty() || !objectsBeingVisited.empty() || ongoingHeroMovement) | ||||
| 		cv.timed_wait(lock, boost::posix_time::milliseconds(100)); | ||||
| 		cv.wait_for(lock, boost::chrono::milliseconds(100)); | ||||
| } | ||||
|  | ||||
| bool AIStatus::haveTurn() | ||||
|   | ||||
							
								
								
									
										9
									
								
								Global.h
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								Global.h
									
									
									
									
									
								
							| @@ -149,8 +149,8 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); | ||||
| #include <boost/algorithm/string.hpp> | ||||
| #include <boost/crc.hpp> | ||||
| #include <boost/current_function.hpp> | ||||
| #include <boost/date_time/posix_time/posix_time.hpp> | ||||
| #include <boost/date_time/posix_time/posix_time_io.hpp> | ||||
| #include <boost/date_time/posix_time/posix_time_types.hpp> | ||||
| #include <boost/date_time/posix_time/time_formatters.hpp> | ||||
| #include <boost/filesystem.hpp> | ||||
| #include <boost/filesystem/fstream.hpp> | ||||
| #include <boost/filesystem/path.hpp> | ||||
| @@ -165,7 +165,10 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); | ||||
| #include <boost/range/adaptor/filtered.hpp> | ||||
| #include <boost/range/adaptor/reversed.hpp> | ||||
| #include <boost/range/algorithm.hpp> | ||||
| #include <boost/thread.hpp> | ||||
| #include <boost/thread/thread_only.hpp> | ||||
| #include <boost/thread/shared_mutex.hpp> | ||||
| #include <boost/thread/recursive_mutex.hpp> | ||||
| #include <boost/thread/once.hpp> | ||||
|  | ||||
| #ifndef M_PI | ||||
| #  define M_PI 3.14159265358979323846 | ||||
|   | ||||
| @@ -54,8 +54,6 @@ | ||||
| namespace po = boost::program_options; | ||||
| namespace po_style = boost::program_options::command_line_style; | ||||
|  | ||||
| extern boost::thread_specific_ptr<bool> inGuiThread; | ||||
|  | ||||
| static po::variables_map vm; | ||||
|  | ||||
| #ifndef VCMI_IOS | ||||
| @@ -416,7 +414,7 @@ int main(int argc, char * argv[]) | ||||
| 	else | ||||
| 	{ | ||||
| 		while(true) | ||||
| 			boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); | ||||
| 			boost::this_thread::sleep_for(boost::chrono::milliseconds(1000)); | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| @@ -435,7 +433,6 @@ void playIntro() | ||||
| static void mainLoop() | ||||
| { | ||||
| 	setThreadName("MainGUI"); | ||||
| 	inGuiThread.reset(new bool(true)); | ||||
|  | ||||
| 	while(1) //main SDL events loop | ||||
| 	{ | ||||
| @@ -476,7 +473,7 @@ static void quitApplication() | ||||
|  | ||||
| 	vstd::clear_pointer(console);// should be removed after everything else since used by logging | ||||
|  | ||||
| 	boost::this_thread::sleep(boost::posix_time::milliseconds(750));//??? | ||||
| 	boost::this_thread::sleep_for(boost::chrono::milliseconds(750));//??? | ||||
|  | ||||
| 	if(!settings["session"]["headless"].Bool()) | ||||
| 		GH.screenHandler().close(); | ||||
|   | ||||
| @@ -1448,7 +1448,7 @@ void CPlayerInterface::centerView (int3 pos, int focusTime) | ||||
| 		{ | ||||
| 			auto unlockPim = vstd::makeUnlockGuard(*pim); | ||||
| 			IgnoreEvents ignore(*this); | ||||
| 			boost::this_thread::sleep(boost::posix_time::milliseconds(focusTime)); | ||||
| 			boost::this_thread::sleep_for(boost::chrono::milliseconds(focusTime)); | ||||
| 		} | ||||
| 	} | ||||
| 	CCS->curh->show(); | ||||
| @@ -1875,7 +1875,7 @@ void CPlayerInterface::waitForAllDialogs(bool unlockPim) | ||||
| 	while(!dialogs.empty()) | ||||
| 	{ | ||||
| 		auto unlock = vstd::makeUnlockGuardIf(*pim, unlockPim); | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(5)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(5)); | ||||
| 	} | ||||
| 	waitWhileDialog(unlockPim); | ||||
| } | ||||
|   | ||||
| @@ -231,7 +231,7 @@ void CServerHandler::startLocalServerAndConnect() | ||||
| 	while(!androidTestServerReadyFlag.load()) | ||||
| 	{ | ||||
| 		logNetwork->info("still waiting..."); | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(1000)); | ||||
| 	} | ||||
| 	logNetwork->info("waiting for server finished..."); | ||||
| 	androidTestServerReadyFlag = false; | ||||
| @@ -261,7 +261,7 @@ void CServerHandler::justConnectToServer(const std::string & addr, const ui16 po | ||||
| 		catch(std::runtime_error & error) | ||||
| 		{ | ||||
| 			logNetwork->warn("\nCannot establish connection. %s Retrying in 1 second", error.what()); | ||||
| 			boost::this_thread::sleep(boost::posix_time::seconds(1)); | ||||
| 			boost::this_thread::sleep_for(boost::chrono::milliseconds(1000)); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -307,7 +307,7 @@ void CServerHandler::stopServerConnection() | ||||
| { | ||||
| 	if(c->handler) | ||||
| 	{ | ||||
| 		while(!c->handler->timed_join(boost::posix_time::milliseconds(50))) | ||||
| 		while(!c->handler->timed_join(boost::chrono::milliseconds(50))) | ||||
| 			applyPacksOnLobbyScreen(); | ||||
| 		c->handler->join(); | ||||
| 	} | ||||
| @@ -761,20 +761,20 @@ void CServerHandler::debugStartTest(std::string filename, bool save) | ||||
| 	else | ||||
| 		startLocalServerAndConnect(); | ||||
|  | ||||
| 	boost::this_thread::sleep(boost::posix_time::milliseconds(100)); | ||||
| 	boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); | ||||
|  | ||||
| 	while(!settings["session"]["headless"].Bool() && !GH.windows().topWindow<CLobbyScreen>()) | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(50)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); | ||||
|  | ||||
| 	while(!mi || mapInfo->fileURI != CSH->mi->fileURI) | ||||
| 	{ | ||||
| 		setMapInfo(mapInfo); | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(50)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); | ||||
| 	} | ||||
| 	// "Click" on color to remove us from it | ||||
| 	setPlayer(myFirstColor()); | ||||
| 	while(myFirstColor() != PlayerColor::CANNOT_DETERMINE) | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(50)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); | ||||
|  | ||||
| 	while(true) | ||||
| 	{ | ||||
| @@ -787,7 +787,7 @@ void CServerHandler::debugStartTest(std::string filename, bool save) | ||||
| 		{ | ||||
|  | ||||
| 		} | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(50)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -826,7 +826,7 @@ void CServerHandler::threadHandleConnection() | ||||
| 		while(c->connected) | ||||
| 		{ | ||||
| 			while(state == EClientState::STARTING) | ||||
| 				boost::this_thread::sleep(boost::posix_time::milliseconds(10)); | ||||
| 				boost::this_thread::sleep_for(boost::chrono::milliseconds(10)); | ||||
|  | ||||
| 			CPack * pack = c->retrievePack(); | ||||
| 			if(state == EClientState::DISCONNECTING) | ||||
|   | ||||
| @@ -461,7 +461,7 @@ bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey) | ||||
| 		double frameDurationSec = packet_duration * av_q2d(format->streams[stream]->time_base); | ||||
| 		uint32_t timeToSleepMillisec = 1000 * (frameDurationSec); | ||||
|  | ||||
| 		boost::this_thread::sleep(boost::posix_time::millisec(timeToSleepMillisec)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(timeToSleepMillisec)); | ||||
| 	} | ||||
|  | ||||
| 	return true; | ||||
|   | ||||
| @@ -407,7 +407,7 @@ void BattleWindow::bFleef() | ||||
| 		auto txt = boost::format(CGI->generaltexth->allTexts[340]) % heroName; //The Shackles of War are present.  %s can not retreat! | ||||
|  | ||||
| 		//printing message | ||||
| 		owner.curInt->showInfoDialog(boost::to_string(txt), comps); | ||||
| 		owner.curInt->showInfoDialog(boost::str(txt), comps); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -36,7 +36,7 @@ | ||||
|  | ||||
| CGuiHandler GH; | ||||
|  | ||||
| boost::thread_specific_ptr<bool> inGuiThread; | ||||
| static thread_local bool inGuiThread = false; | ||||
|  | ||||
| SObjectConstruction::SObjectConstruction(CIntObject *obj) | ||||
| :myObj(obj) | ||||
| @@ -69,6 +69,8 @@ SSetCaptureState::~SSetCaptureState() | ||||
|  | ||||
| void CGuiHandler::init() | ||||
| { | ||||
| 	inGuiThread = true; | ||||
|  | ||||
| 	inputHandlerInstance = std::make_unique<InputHandler>(); | ||||
| 	eventDispatcherInstance = std::make_unique<EventDispatcher>(); | ||||
| 	windowHandlerInstance = std::make_unique<WindowHandler>(); | ||||
| @@ -117,7 +119,7 @@ void CGuiHandler::renderFrame() | ||||
|  | ||||
| 	bool acquiredTheLockOnPim = false; //for tracking whether pim mutex locking succeeded | ||||
| 	while(!terminate_cond->get() && !(acquiredTheLockOnPim = CPlayerInterface::pim->try_lock())) //try acquiring long until it succeeds or we are told to terminate | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(1)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(1)); | ||||
|  | ||||
| 	if(acquiredTheLockOnPim) | ||||
| 	{ | ||||
| @@ -207,7 +209,7 @@ void CGuiHandler::drawFPSCounter() | ||||
|  | ||||
| bool CGuiHandler::amIGuiThread() | ||||
| { | ||||
| 	return inGuiThread.get() && *inGuiThread; | ||||
| 	return inGuiThread; | ||||
| } | ||||
|  | ||||
| void CGuiHandler::dispatchMainThread(const std::function<void()> & functor) | ||||
|   | ||||
| @@ -38,7 +38,7 @@ void CMapHandler::waitForOngoingAnimations() | ||||
| 	while(CGI->mh->hasOngoingAnimations()) | ||||
| 	{ | ||||
| 		auto unlockPim = vstd::makeUnlockGuard(*CPlayerInterface::pim); | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(1)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(1)); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -562,7 +562,7 @@ void CSpellWindow::SpellArea::hover(bool on) | ||||
| 	if(mySpell) | ||||
| 	{ | ||||
| 		if(on) | ||||
| 			owner->statusBar->write(boost::to_string(boost::format("%s (%s)") % mySpell->getNameTranslated() % CGI->generaltexth->allTexts[171+mySpell->level])); | ||||
| 			owner->statusBar->write(boost::str(boost::format("%s (%s)") % mySpell->getNameTranslated() % CGI->generaltexth->allTexts[171+mySpell->level])); | ||||
| 		else | ||||
| 			owner->statusBar->clear(); | ||||
| 	} | ||||
|   | ||||
| @@ -233,7 +233,7 @@ int CConsoleHandler::run() const | ||||
| 					(*cb)(buffer, false); | ||||
| 		} | ||||
| 		else | ||||
| 			boost::this_thread::sleep(boost::posix_time::millisec(100)); | ||||
| 			boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); | ||||
|  | ||||
| 		boost::this_thread::interruption_point(); | ||||
| #else | ||||
|   | ||||
| @@ -13,8 +13,6 @@ | ||||
|  | ||||
| VCMI_LIB_NAMESPACE_BEGIN | ||||
|  | ||||
| boost::thread_specific_ptr<CRandomGenerator> CRandomGenerator::defaultRand; | ||||
|  | ||||
| CRandomGenerator::CRandomGenerator() | ||||
| { | ||||
| 	resetSeed(); | ||||
| @@ -84,11 +82,8 @@ double CRandomGenerator::nextDouble() | ||||
|  | ||||
| CRandomGenerator & CRandomGenerator::getDefault() | ||||
| { | ||||
| 	if(!defaultRand.get()) | ||||
| 	{ | ||||
| 		defaultRand.reset(new CRandomGenerator()); | ||||
| 	} | ||||
| 	return *defaultRand; | ||||
| 	static thread_local CRandomGenerator defaultRand; | ||||
| 	return defaultRand; | ||||
| } | ||||
|  | ||||
| TGenerator & CRandomGenerator::getStdGenerator() | ||||
|   | ||||
| @@ -80,7 +80,6 @@ public: | ||||
|  | ||||
| private: | ||||
| 	TGenerator rand; | ||||
| 	static boost::thread_specific_ptr<CRandomGenerator> defaultRand; | ||||
|  | ||||
| public: | ||||
| 	template <typename Handler> | ||||
|   | ||||
| @@ -29,10 +29,12 @@ CThreadHelper::CThreadHelper(std::vector<std::function<void()>> * Tasks, int Thr | ||||
| } | ||||
| void CThreadHelper::run() | ||||
| { | ||||
| 	boost::thread_group grupa; | ||||
| 	std::vector<boost::thread> group; | ||||
| 	for(int i=0;i<threads;i++) | ||||
| 		grupa.create_thread(std::bind(&CThreadHelper::processTasks,this)); | ||||
| 	grupa.join_all(); | ||||
| 		group.emplace_back(std::bind(&CThreadHelper::processTasks,this)); | ||||
|  | ||||
| 	for (auto & thread : group) | ||||
| 		thread.join(); | ||||
|  | ||||
| 	//thread group deletes threads, do not free manually | ||||
| } | ||||
|   | ||||
| @@ -46,15 +46,15 @@ public: | ||||
|  | ||||
| 	void run() | ||||
| 	{ | ||||
| 		boost::thread_group grupa; | ||||
| 		std::vector<boost::thread> group; | ||||
| 		for(size_t i=0; i<threads; i++) | ||||
| 		{ | ||||
| 			std::shared_ptr<Payload> payload = context.at(i); | ||||
|  | ||||
| 			grupa.create_thread(std::bind(&ThreadPool::processTasks, this, payload)); | ||||
| 			group.emplace_back(std::bind(&ThreadPool::processTasks, this, payload)); | ||||
| 		} | ||||
|  | ||||
| 		grupa.join_all(); | ||||
| 		for (auto & thread : group) | ||||
| 			thread.join(); | ||||
|  | ||||
| 		//thread group deletes threads, do not free manually | ||||
| 	} | ||||
|   | ||||
| @@ -288,7 +288,7 @@ std::string CLogFormatter::format(const LogRecord & record) const | ||||
| 	boost::algorithm::replace_first(message, "%m", record.message); | ||||
| 	boost::algorithm::replace_first(message, "%c", boost::posix_time::to_simple_string(record.timeStamp)); | ||||
|  | ||||
| 	//return boost::to_string (boost::format("%d %d %d[%d] - %d") % dateStream.str() % level % record.domain.getName() % record.threadId % record.message); | ||||
| 	//return boost::str (boost::format("%d %d %d[%d] - %d") % dateStream.str() % level % record.domain.getName() % record.threadId % record.message); | ||||
|  | ||||
| 	return message; | ||||
| } | ||||
|   | ||||
| @@ -69,7 +69,7 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const | ||||
| 			ms.appendLocalString(EMetaText::GENERAL_TXT,243); | ||||
| 			break; | ||||
| 		default: //decision = cost in gold | ||||
| 			ms.appendRawString(boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision)); | ||||
| 			ms.appendRawString(boost::str(boost::format(VLC->generaltexth->allTexts[244]) % decision)); | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
|   | ||||
| @@ -1463,7 +1463,7 @@ bool CGHeroInstance::hasVisions(const CGObjectInstance * target, const int subty | ||||
|  | ||||
| 	const int distance = static_cast<int>(target->pos.dist2d(visitablePos())); | ||||
|  | ||||
| 	//logGlobal->debug(boost::to_string(boost::format("Visions: dist %d, mult %d, range %d") % distance % visionsMultiplier % visionsRange)); | ||||
| 	//logGlobal->debug(boost::str(boost::format("Visions: dist %d, mult %d, range %d") % distance % visionsMultiplier % visionsRange)); | ||||
|  | ||||
| 	return (distance < visionsRange) && (target->pos.z == pos.z); | ||||
| } | ||||
|   | ||||
| @@ -421,7 +421,7 @@ int CMapGenerator::getNextMonlithIndex() | ||||
| 	while (true) | ||||
| 	{ | ||||
| 		if (monolithIndex >= VLC->objtypeh->knownSubObjects(Obj::MONOLITH_TWO_WAY).size()) | ||||
| 			throw rmgException(boost::to_string(boost::format("There is no Monolith Two Way with index %d available!") % monolithIndex)); | ||||
| 			throw rmgException(boost::str(boost::format("There is no Monolith Two Way with index %d available!") % monolithIndex)); | ||||
| 		else | ||||
| 		{ | ||||
| 			//Skip modded Monoliths which can't beplaced on every terrain | ||||
|   | ||||
| @@ -156,7 +156,7 @@ TRmgTemplateZoneId ZoneOptions::getId() const | ||||
| void ZoneOptions::setId(TRmgTemplateZoneId value) | ||||
| { | ||||
| 	if(value <= 0) | ||||
| 		throw std::runtime_error(boost::to_string(boost::format("Zone %d id should be greater than 0.") % id)); | ||||
| 		throw std::runtime_error(boost::str(boost::format("Zone %d id should be greater than 0.") % id)); | ||||
| 	id = value; | ||||
| } | ||||
|  | ||||
| @@ -650,7 +650,7 @@ std::string CRmgTemplate::CPlayerCountRange::toString() const | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			ret += boost::to_string(boost::format("%d-%d") % p.first % p.second); | ||||
| 			ret += boost::str(boost::format("%d-%d") % p.first % p.second); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -219,7 +219,7 @@ const CMapGenOptions& RmgMap::getMapGenOptions() const | ||||
| void RmgMap::assertOnMap(const int3& tile) const | ||||
| { | ||||
| 	if (!mapInstance->isInTheMap(tile)) | ||||
| 		throw rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile.toString())); | ||||
| 		throw rmgException(boost::str(boost::format("Tile %s is outside the map") % tile.toString())); | ||||
| } | ||||
|  | ||||
| RmgMap::Zones & RmgMap::getZones() | ||||
| @@ -354,7 +354,7 @@ bool RmgMap::isAllowedSpell(const SpellID & sid) const | ||||
| void RmgMap::dump(bool zoneId) const | ||||
| { | ||||
| 	static int id = 0; | ||||
| 	std::ofstream out(boost::to_string(boost::format("zone_%d.txt") % id++)); | ||||
| 	std::ofstream out(boost::str(boost::format("zone_%d.txt") % id++)); | ||||
| 	int levels = mapInstance->levels(); | ||||
| 	int width =  mapInstance->width; | ||||
| 	int height = mapInstance->height; | ||||
|   | ||||
| @@ -115,7 +115,7 @@ void Object::Instance::setAnyTemplate() | ||||
| { | ||||
| 	auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(); | ||||
| 	if(templates.empty()) | ||||
| 		throw rmgException(boost::to_string(boost::format("Did not find any graphics for object (%d,%d)") % dObject.ID % dObject.subID)); | ||||
| 		throw rmgException(boost::str(boost::format("Did not find any graphics for object (%d,%d)") % dObject.ID % dObject.subID)); | ||||
|  | ||||
| 	dObject.appearance = templates.front(); | ||||
| 	dAccessibleAreaCache.clear(); | ||||
| @@ -128,7 +128,7 @@ void Object::Instance::setTemplate(TerrainId terrain) | ||||
| 	if (templates.empty()) | ||||
| 	{ | ||||
| 		auto terrainName = VLC->terrainTypeHandler->getById(terrain)->getNameTranslated(); | ||||
| 		throw rmgException(boost::to_string(boost::format("Did not find graphics for object (%d,%d) at %s") % dObject.ID % dObject.subID % terrainName)); | ||||
| 		throw rmgException(boost::str(boost::format("Did not find graphics for object (%d,%d) at %s") % dObject.ID % dObject.subID % terrainName)); | ||||
| 	} | ||||
| 	dObject.appearance = templates.front(); | ||||
| 	dAccessibleAreaCache.clear(); | ||||
| @@ -328,7 +328,7 @@ void rmg::Object::setGuardedIfMonster(const Instance& object) | ||||
| void Object::Instance::finalize(RmgMap & map) | ||||
| { | ||||
| 	if(!map.isOnMap(getPosition(true))) | ||||
| 		throw rmgException(boost::to_string(boost::format("Position of object %d at %s is outside the map") % dObject.id % getPosition(true).toString())); | ||||
| 		throw rmgException(boost::str(boost::format("Position of object %d at %s is outside the map") % dObject.id % getPosition(true).toString())); | ||||
| 	 | ||||
| 	//If no specific template was defined for this object, select any matching | ||||
| 	if (!dObject.appearance) | ||||
| @@ -337,7 +337,7 @@ void Object::Instance::finalize(RmgMap & map) | ||||
| 		auto templates = VLC->objtypeh->getHandlerFor(dObject.ID, dObject.subID)->getTemplates(terrainType->getId()); | ||||
| 		if (templates.empty()) | ||||
| 		{ | ||||
| 			throw rmgException(boost::to_string(boost::format("Did not find graphics for object (%d,%d) at %s (terrain %d)") % dObject.ID % dObject.subID % getPosition(true).toString() % terrainType)); | ||||
| 			throw rmgException(boost::str(boost::format("Did not find graphics for object (%d,%d) at %s (terrain %d)") % dObject.ID % dObject.subID % getPosition(true).toString() % terrainType)); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -346,12 +346,12 @@ void Object::Instance::finalize(RmgMap & map) | ||||
| 	} | ||||
|  | ||||
| 	if (dObject.isVisitable() && !map.isOnMap(dObject.visitablePos())) | ||||
| 		throw rmgException(boost::to_string(boost::format("Visitable tile %s of object %d at %s is outside the map") % dObject.visitablePos().toString() % dObject.id % dObject.pos.toString())); | ||||
| 		throw rmgException(boost::str(boost::format("Visitable tile %s of object %d at %s is outside the map") % dObject.visitablePos().toString() % dObject.id % dObject.pos.toString())); | ||||
|  | ||||
| 	for(const auto & tile : dObject.getBlockedPos()) | ||||
| 	{ | ||||
| 		if(!map.isOnMap(tile)) | ||||
| 			throw rmgException(boost::to_string(boost::format("Tile %s of object %d at %s is outside the map") % tile.toString() % dObject.id % dObject.pos.toString())); | ||||
| 			throw rmgException(boost::str(boost::format("Tile %s of object %d at %s is outside the map") % tile.toString() % dObject.id % dObject.pos.toString())); | ||||
| 	} | ||||
|  | ||||
| 	for(const auto & tile : getBlockedArea().getTilesVector()) | ||||
|   | ||||
| @@ -119,7 +119,7 @@ void Modificator::postfunction(Modificator * modificator) | ||||
|  | ||||
| void Modificator::dump() | ||||
| { | ||||
| 	std::ofstream out(boost::to_string(boost::format("seed_%d_modzone_%d_%s.txt") % generator.getRandomSeed() % zone.getId() % getName())); | ||||
| 	std::ofstream out(boost::str(boost::format("seed_%d_modzone_%d_%s.txt") % generator.getRandomSeed() % zone.getId() % getName())); | ||||
| 	int levels = map.levels(); | ||||
| 	int width =  map.width(); | ||||
| 	int height = map.height(); | ||||
|   | ||||
| @@ -387,7 +387,7 @@ void RiverPlacer::connectRiver(const int3 & tile) | ||||
| 		if(tmplates.size() > 3) | ||||
| 		{ | ||||
| 			if(tmplates.size() % 4 != 0) | ||||
| 				throw rmgException(boost::to_string(boost::format("River templates for (%d,%d) at terrain %s, river %s are incorrect") % | ||||
| 				throw rmgException(boost::str(boost::format("River templates for (%d,%d) at terrain %s, river %s are incorrect") % | ||||
| 					RIVER_DELTA_ID % RIVER_DELTA_SUBTYPE % zone.getTerrainType() % river->shortIdentifier)); | ||||
| 			 | ||||
| 			std::string targetTemplateName = river->deltaName + std::to_string(deltaOrientations[pos]) + ".def"; | ||||
|   | ||||
| @@ -169,7 +169,7 @@ inline void ThreadPool::cancel() | ||||
|  | ||||
| auto ThreadPool::async(std::function<void()>&& f) const -> boost::future<void> | ||||
| { | ||||
|     using TaskT = boost::packaged_task<void>; | ||||
| 	using TaskT = boost::packaged_task<void>; | ||||
|  | ||||
|     { | ||||
|         Lock lock(mx); | ||||
| @@ -189,4 +189,4 @@ auto ThreadPool::async(std::function<void()>&& f) const -> boost::future<void> | ||||
|     return fut; | ||||
| } | ||||
|  | ||||
| VCMI_LIB_NAMESPACE_END | ||||
| VCMI_LIB_NAMESPACE_END | ||||
|   | ||||
| @@ -66,10 +66,6 @@ | ||||
| #include <vcmi/events/GenericEvents.h> | ||||
| #include <vcmi/events/AdventureEvents.h> | ||||
|  | ||||
| #ifndef _MSC_VER | ||||
| #include <boost/thread/xtime.hpp> | ||||
| #endif | ||||
|  | ||||
| #define COMPLAIN_RET_IF(cond, txt) do {if (cond){complain(txt); return;}} while(0) | ||||
| #define COMPLAIN_RET_FALSE_IF(cond, txt) do {if (cond){complain(txt); return false;}} while(0) | ||||
| #define COMPLAIN_RET(txt) {complain(txt); return false;} | ||||
| @@ -973,7 +969,6 @@ void CGameHandler::run(bool resume) | ||||
| { | ||||
| 	LOG_TRACE_PARAMS(logGlobal, "resume=%d", resume); | ||||
|  | ||||
| 	using namespace boost::posix_time; | ||||
| 	for (auto cc : lobby->connections) | ||||
| 	{ | ||||
| 		auto players = lobby->getAllClientPlayers(cc->connectionID); | ||||
| @@ -1068,8 +1063,7 @@ void CGameHandler::run(bool resume) | ||||
| 					if(gs->curB) | ||||
| 						turnTimerHandler.onBattleLoop(waitTime); | ||||
|  | ||||
| 					static time_duration p = milliseconds(waitTime); | ||||
| 					states.cv.timed_wait(lock, p); | ||||
| 					states.cv.wait_for(lock, boost::chrono::milliseconds(waitTime)); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| @@ -2575,7 +2569,7 @@ bool CGameHandler::upgradeCreature(ObjectInstanceID objid, SlotID pos, CreatureI | ||||
| 	const CArmedInstance * obj = static_cast<const CArmedInstance *>(getObjInstance(objid)); | ||||
| 	if (!obj->hasStackAtSlot(pos)) | ||||
| 	{ | ||||
| 		COMPLAIN_RET("Cannot upgrade, no stack at slot " + boost::to_string(pos)); | ||||
| 		COMPLAIN_RET("Cannot upgrade, no stack at slot " + std::to_string(pos)); | ||||
| 	} | ||||
| 	UpgradeInfo ui; | ||||
| 	fillUpgradeInfo(obj, pos, ui); | ||||
|   | ||||
| @@ -179,7 +179,7 @@ void CVCMIServer::run() | ||||
| 	} | ||||
|  | ||||
| 	while(state == EServerState::LOBBY || state == EServerState::GAMEPLAY_STARTING) | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(50)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); | ||||
|  | ||||
| 	logNetwork->info("Thread handling connections ended"); | ||||
|  | ||||
| @@ -188,14 +188,14 @@ void CVCMIServer::run() | ||||
| 		gh->run(si->mode == StartInfo::LOAD_GAME); | ||||
| 	} | ||||
| 	while(state == EServerState::GAMEPLAY_ENDED) | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(50)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); | ||||
| } | ||||
|  | ||||
| void CVCMIServer::establishRemoteConnections() | ||||
| { | ||||
| 	//wait for host connection | ||||
| 	while(connections.empty()) | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(50)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); | ||||
| 	 | ||||
| 	uuid = cmdLineOptions["lobby-uuid"].as<std::string>(); | ||||
|     int numOfConnections = cmdLineOptions["connections"].as<ui16>(); | ||||
| @@ -246,7 +246,7 @@ void CVCMIServer::threadAnnounceLobby() | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(50)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -265,7 +265,7 @@ void CVCMIServer::prepareToRestart() | ||||
| 			campaignBonus = si->campState->getBonusID(campaignMap).value_or(-1); | ||||
| 		} | ||||
| 		// FIXME: dirry hack to make sure old CGameHandler::run is finished | ||||
| 		boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); | ||||
| 		boost::this_thread::sleep_for(boost::chrono::milliseconds(1000)); | ||||
| 	} | ||||
| 	 | ||||
| 	for(auto c : connections) | ||||
|   | ||||
| @@ -11,11 +11,4 @@ | ||||
|  | ||||
| #include "../Global.h" | ||||
|  | ||||
| #include <boost/crc.hpp> | ||||
| #include <boost/date_time/posix_time/posix_time_types.hpp> //no i/o just types | ||||
| #include <boost/random/linear_congruential.hpp> | ||||
| #include <boost/random/mersenne_twister.hpp> | ||||
| #include <boost/random/variate_generator.hpp> | ||||
| #include <boost/system/system_error.hpp> | ||||
|  | ||||
| VCMI_LIB_USING_NAMESPACE | ||||
|   | ||||
| @@ -116,7 +116,7 @@ void JsonComparer::checkEqualJson(const JsonVector & actual, const JsonVector & | ||||
|  | ||||
| 	for(size_t idx = 0; idx < sz; idx ++) | ||||
| 	{ | ||||
| 		auto guard = pushName(boost::to_string(idx)); | ||||
| 		auto guard = pushName(std::to_string(idx)); | ||||
|  | ||||
| 		checkEqualJson(actual.at(idx), expected.at(idx)); | ||||
| 	} | ||||
|   | ||||
| @@ -56,7 +56,7 @@ void checkEqual(const std::set<Element> & actual, const std::set<Element> & expe | ||||
| 	for(auto elem : expected) | ||||
| 	{ | ||||
| 		if(!vstd::contains(actual, elem)) | ||||
| 			FAIL() << "Required element not found "+boost::to_string(elem); | ||||
| 			FAIL() << "Required element not found "+std::to_string(elem); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -202,8 +202,8 @@ void MapComparer::compareObject(const CGObjectInstance * actual, const CGObjectI | ||||
| 	EXPECT_EQ(actual->instanceName, expected->instanceName); | ||||
| 	EXPECT_EQ(typeid(actual).name(), typeid(expected).name());//todo: remove and use just comparison | ||||
|  | ||||
| 	std::string actualFullID = boost::to_string(boost::format("%s(%d)|%s(%d) %d") % actual->typeName % actual->ID % actual->subTypeName % actual->subID % actual->tempOwner); | ||||
| 	std::string expectedFullID = boost::to_string(boost::format("%s(%d)|%s(%d) %d") % expected->typeName % expected->ID % expected->subTypeName % expected->subID % expected->tempOwner); | ||||
| 	std::string actualFullID = boost::str(boost::format("%s(%d)|%s(%d) %d") % actual->typeName % actual->ID % actual->subTypeName % actual->subID % actual->tempOwner); | ||||
| 	std::string expectedFullID = boost::str(boost::format("%s(%d)|%s(%d) %d") % expected->typeName % expected->ID % expected->subTypeName % expected->subID % expected->tempOwner); | ||||
|  | ||||
| 	EXPECT_EQ(actualFullID, expectedFullID); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user