mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	- moved ParseBonus to JsonNode.cpp (linkage errors)
- fixes to CMakeLists - vcmi can be compiled and started with cmake - gcc\clang warnings fixes
This commit is contained in:
		| @@ -8,5 +8,5 @@ set(emptyAI_SRCS | ||||
|         exp_funcs.cpp | ||||
| ) | ||||
|  | ||||
| add_library(emptyAI SHARED ${emptyAI_SRCS}) | ||||
| target_link_libraries(emptyAI vcmi) | ||||
| add_library(EmptyAI SHARED ${emptyAI_SRCS}) | ||||
| target_link_libraries(EmptyAI vcmi) | ||||
|   | ||||
| @@ -464,7 +464,7 @@ void VCAI::heroMoved(const TryMoveHero & details) | ||||
| 	LOG_ENTRY; | ||||
| 	if(details.result == TryMoveHero::TELEPORTATION) | ||||
| 	{ | ||||
| 		const int3 from = CGHeroInstance::convertPosition(details.start, false),  | ||||
| 		const int3 from = CGHeroInstance::convertPosition(details.start, false), | ||||
| 			to = CGHeroInstance::convertPosition(details.end, false); | ||||
| 		const CGObjectInstance *o1 = frontOrNull(cb->getVisitableObjs(from)), | ||||
| 			*o2 = frontOrNull(cb->getVisitableObjs(to)); | ||||
| @@ -699,7 +699,7 @@ void VCAI::objectRemoved(const CGObjectInstance *obj) | ||||
|  | ||||
| 	//TODO | ||||
| 	//there are other places where CGObjectinstance ptrs are stored... | ||||
| 	//  | ||||
| 	// | ||||
|  | ||||
| 	if(obj->ID == GameConstants::HEROI_TYPE  &&  obj->tempOwner == playerID) | ||||
| 	{ | ||||
| @@ -873,7 +873,7 @@ void VCAI::showBlockingDialog(const std::string &text, const std::vector<Compone | ||||
| 	NET_EVENT_HANDLER; | ||||
| 	LOG_ENTRY; | ||||
| 	int sel = 0; | ||||
| 	status.addQuery(askID, boost::str(boost::format("Blocking dialog query with %d components - %s")  | ||||
| 	status.addQuery(askID, boost::str(boost::format("Blocking dialog query with %d components - %s") | ||||
| 									  % components.size() % text)); | ||||
|  | ||||
| 	if(selection) //select from multiple components -> take the last one (they're indexed [1-size]) | ||||
| @@ -956,7 +956,7 @@ void VCAI::makeTurn() | ||||
| 			BOOST_FOREACH(const CGObjectInstance *obj, objs) | ||||
| 			{ | ||||
| 				if (isWeeklyRevisitable(obj)) | ||||
| 				{  | ||||
| 				{ | ||||
| 					if (!vstd::contains(visitableObjs, obj)) | ||||
| 						visitableObjs.push_back(obj); | ||||
| 					auto o = std::find (alreadyVisited.begin(), alreadyVisited.end(), obj); | ||||
| @@ -1052,7 +1052,7 @@ void VCAI::makeTurnInternal() | ||||
| 		auto quests = myCb->getMyQuests(); | ||||
| 		BOOST_FOREACH (auto quest, quests) | ||||
| 		{ | ||||
| 			striveToQuest (quest);  | ||||
| 			striveToQuest (quest); | ||||
| 		} | ||||
|  | ||||
| 		striveToGoal(CGoal(BUILD)); //TODO: smarter building management | ||||
| @@ -1109,7 +1109,7 @@ void VCAI::pickBestCreatures(const CArmedInstance * army, const CArmedInstance * | ||||
| 	std::map<const CCreature*, int> creToPower; | ||||
| 	BOOST_FOREACH(auto armyPtr, armies) | ||||
| 		BOOST_FOREACH(auto &i, armyPtr->Slots()) | ||||
| 			creToPower[i.second->type] += i.second->getPower();  | ||||
| 			creToPower[i.second->type] += i.second->getPower(); | ||||
| 	//TODO - consider more than just power (ie morale penalty, hero specialty in certain stacks, etc) | ||||
|  | ||||
| 	std::vector<const CCreature *> bestArmy; //types that'll be in final dst army | ||||
| @@ -1125,10 +1125,10 @@ void VCAI::pickBestCreatures(const CArmedInstance * army, const CArmedInstance * | ||||
| 		if(creToPower.empty()) | ||||
| 			break; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	//foreach best type -> iterate over slots in both armies and if it's the appropriate type, send it to the slot where it belongs | ||||
| 	for (int i = 0; i < bestArmy.size(); i++) //i-th strongest creature type will go to i-th slot | ||||
| 		BOOST_FOREACH(auto armyPtr, armies)  | ||||
| 		BOOST_FOREACH(auto armyPtr, armies) | ||||
| 			for (int j = 0; j < GameConstants::ARMY_SIZE; j++) | ||||
| 				if(armyPtr->getCreature(j) == bestArmy[i]  &&  (i != j || armyPtr != army)) //it's a searched creature not in dst slot | ||||
| 						cb->mergeOrSwapStacks(armyPtr, army, j, i); | ||||
| @@ -1341,7 +1341,7 @@ std::vector<const CGObjectInstance *> VCAI::getPossibleDestinations(HeroPtr h) | ||||
|  | ||||
| 			if (!shouldVisit(h, obj)) | ||||
| 				return true; | ||||
| 			 | ||||
|  | ||||
| 			if (vstd::contains(reservedObjs, obj)) //does checking for our own reserved objects make sense? here? | ||||
| 				return true; | ||||
|  | ||||
| @@ -1372,7 +1372,7 @@ void VCAI::wander(HeroPtr h) | ||||
| 	        { | ||||
| 				return howManyReinforcementsCanGet(h, lhs) < howManyReinforcementsCanGet(h, rhs); | ||||
| 	        }; | ||||
| 	 | ||||
|  | ||||
| 	        std::vector<const CGTownInstance *> townsReachable; | ||||
| 	        std::vector<const CGTownInstance *> townsNotReachable; | ||||
| 	        BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo()) | ||||
| @@ -1713,7 +1713,7 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h) | ||||
| 			{ | ||||
| 				lostHero(h); | ||||
| 				//we need to throw, otherwise hero will be assigned to sth again | ||||
| 				throw std::runtime_error("Hero was lost!");  | ||||
| 				throw std::runtime_error("Hero was lost!"); | ||||
| 				break; | ||||
| 			} | ||||
|  | ||||
| @@ -1996,7 +1996,7 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal) | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if (goal.isAbstract)  | ||||
| 			if (goal.isAbstract) | ||||
| 			{ | ||||
| 				abstractGoal = goal; //allow only one abstract goal per call | ||||
| 				BNLOG("Choosing abstract goal %s", goalName(goal.goalType)); | ||||
| @@ -2391,7 +2391,7 @@ void VCAI::answerQuery(int queryID, int selection) | ||||
| 	BNLOG("I'll answer the query %d giving the choice %d", queryID % selection); | ||||
| 	if(queryID != -1) | ||||
| 	{ | ||||
| 		int requestID = cb->selectionMade(selection, queryID); | ||||
| 		cb->selectionMade(selection, queryID); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| @@ -2774,9 +2774,9 @@ TSubgoal CGoal::whatToDoToAchieve() | ||||
|  | ||||
| 			erase(hs, [](const CGHeroInstance *h) | ||||
| 			{ | ||||
| 				return contains(ai->lockedHeroes, h);  | ||||
| 				return contains(ai->lockedHeroes, h); | ||||
| 			}); | ||||
| 			if(hs.empty()) //all heroes are busy. buy new one  | ||||
| 			if(hs.empty()) //all heroes are busy. buy new one | ||||
| 			{ | ||||
| 				if (howManyHeroes < 3  && ai->findTownWithTavern()) //we may want to recruit second hero. TODO: make it smart finally | ||||
| 					return CGoal(RECRUIT_HERO); | ||||
| @@ -2946,9 +2946,9 @@ TSubgoal CGoal::whatToDoToAchieve() | ||||
|  | ||||
| 			erase(hs, [](const CGHeroInstance *h) | ||||
| 			{ | ||||
| 				return contains(ai->lockedHeroes, h);  | ||||
| 				return contains(ai->lockedHeroes, h); | ||||
| 			}); | ||||
| 			if(hs.empty()) //all heroes are busy. buy new one  | ||||
| 			if(hs.empty()) //all heroes are busy. buy new one | ||||
| 			{ | ||||
| 				if (howManyHeroes < 3  && ai->findTownWithTavern()) //we may want to recruit second hero. TODO: make it smart finally | ||||
| 					return CGoal(RECRUIT_HERO); | ||||
| @@ -3216,7 +3216,7 @@ bool isWeeklyRevisitable (const CGObjectInstance * obj) | ||||
| 			return true; | ||||
| 		case Obj::BORDER_GATE: | ||||
| 		case Obj::BORDERGUARD: | ||||
| 			return (dynamic_cast <const CGKeys *>(obj))->wasMyColorVisited (ai->playerID); //FIXME: they could be revisited sooner than in a week  | ||||
| 			return (dynamic_cast <const CGKeys *>(obj))->wasMyColorVisited (ai->playerID); //FIXME: they could be revisited sooner than in a week | ||||
| 			break; | ||||
| 	} | ||||
| 	return false; | ||||
| @@ -3556,7 +3556,7 @@ bool HeroPtr::operator<(const HeroPtr &rhs) const | ||||
| const CGHeroInstance * HeroPtr::get(bool doWeExpectNull /*= false*/) const | ||||
| { | ||||
| 	//TODO? check if these all assertions every time we get info about hero affect efficiency | ||||
| 	//  | ||||
| 	// | ||||
| 	//behave terribly when attempting unauthorised access to hero that is not ours (or was lost) | ||||
| 	assert(doWeExpectNull || h); | ||||
| 	if(h) | ||||
|   | ||||
| @@ -7,9 +7,12 @@ INCLUDE(CheckLibraryExists) | ||||
| # where to look for cmake modules | ||||
| set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) | ||||
|  | ||||
| set(CMAKE_BUILD_TYPE Debug) | ||||
| # enable Release mode but only if it was not set | ||||
| if (NOT CMAKE_BUILD_TYPE) | ||||
| 	set(CMAKE_BUILD_TYPE Release) | ||||
| endif() | ||||
|  | ||||
| find_package(Boost COMPONENTS program_options filesystem system thread iostreams REQUIRED) | ||||
| find_package(Boost 1.46.0 COMPONENTS program_options filesystem system thread iostreams REQUIRED) | ||||
| find_package(SDL REQUIRED) | ||||
| find_package(SDL_image REQUIRED) | ||||
| find_package(SDL_mixer REQUIRED) | ||||
| @@ -29,7 +32,7 @@ if(HAVE_DL_LIB) | ||||
| endif() | ||||
|  | ||||
| if(CMAKE_CXX_COMPILER MATCHES ".*clang") | ||||
|     set(CMAKE_COMPILER_IS_CLANGXX 1) | ||||
|     set(CMAKE_COMPILER_IS_CLANGXX ON) | ||||
| endif() | ||||
|  | ||||
| if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) | ||||
| @@ -37,12 +40,13 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) | ||||
| endif() | ||||
|  | ||||
| #define required constants | ||||
| add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share") | ||||
| add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/lib/vcmi") | ||||
| add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/bin") | ||||
| add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/vcmi") | ||||
| add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/bin") | ||||
| add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/lib/vcmi") | ||||
|  | ||||
| add_subdirectory(lib) | ||||
| add_subdirectory(client) | ||||
| add_subdirectory(server) | ||||
| add_subdirectory(AI) | ||||
| add_subdirectory(Scripting/ERM) | ||||
| add_subdirectory(Scripting/ERM) | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/BattleInterface ${CMAKE_CURRENT_ | ||||
| include_directories(${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} ${SDLMIXER_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR}) | ||||
| include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIR}) | ||||
|  | ||||
|  | ||||
| set(client_SRCS | ||||
|         ../CCallback.cpp | ||||
|         BattleInterface/CBattleAnimations.cpp | ||||
| @@ -44,7 +43,6 @@ set(client_SRCS | ||||
|         GUIClasses.cpp | ||||
|         mapHandler.cpp | ||||
|         NetPacksClient.cpp | ||||
|         SDL_framerate.cpp | ||||
| ) | ||||
|  | ||||
| IF(UNIX) | ||||
| @@ -53,4 +51,4 @@ ELSEIF(WIN32) | ||||
|     add_executable(vcmiclient WIN32 ${client_SRCS}) | ||||
| ENDIF() | ||||
|  | ||||
| target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES}) | ||||
| target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${RT_LIB} ${DL_LIB}) | ||||
|   | ||||
| @@ -141,8 +141,10 @@ void CQuestMinimap::showAll(SDL_Surface * to) | ||||
|  | ||||
| CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests) : | ||||
| 	CWindowObject(PLAYER_COLORED, "QuestLog.pcx"), | ||||
| 	quests (Quests), slider (NULL), | ||||
| 	questIndex(0), currentQuest(NULL) | ||||
| 	questIndex(0), | ||||
| 	currentQuest(NULL), | ||||
| 	quests (Quests), | ||||
| 	slider(NULL) | ||||
| { | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	init(); | ||||
| @@ -229,4 +231,4 @@ void CQuestLog::sliderMoved (int newpos) | ||||
| { | ||||
| 	recreateQuestList (newpos); //move components | ||||
| 	redraw(); | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -3323,7 +3323,7 @@ CSystemOptionsWindow::CSystemOptionsWindow(): | ||||
| 	save->swappedImages = true; | ||||
| 	save->update(); | ||||
|  | ||||
| 	restart = new CAdventureMapButton (CGI->generaltexth->zelp[323].first, CGI->generaltexth->zelp[323].second,  | ||||
| 	restart = new CAdventureMapButton (CGI->generaltexth->zelp[323].first, CGI->generaltexth->zelp[323].second, | ||||
| 									   boost::bind(&CSystemOptionsWindow::brestartf, this), 246, 357, "SORSTRT", SDLK_r); | ||||
| 	restart->swappedImages = true; | ||||
| 	restart->update(); | ||||
| @@ -3633,7 +3633,7 @@ void CInGameConsole::show(SDL_Surface * to) | ||||
|  | ||||
| 	std::vector<std::list< std::pair< std::string, int > >::iterator> toDel; | ||||
|  | ||||
| 	boost::unique_lock<boost::mutex> lock(texts_mx);  | ||||
| 	boost::unique_lock<boost::mutex> lock(texts_mx); | ||||
| 	for(std::list< std::pair< std::string, int > >::iterator it = texts.begin(); it != texts.end(); ++it, ++number) | ||||
| 	{ | ||||
| 		SDL_Color green = {0,0xff,0,0}; | ||||
| @@ -3657,7 +3657,7 @@ void CInGameConsole::show(SDL_Surface * to) | ||||
|  | ||||
| void CInGameConsole::print(const std::string &txt) | ||||
| { | ||||
| 	boost::unique_lock<boost::mutex> lock(texts_mx);  | ||||
| 	boost::unique_lock<boost::mutex> lock(texts_mx); | ||||
| 	int lineLen = conf.go()->ac.outputLineLength; | ||||
|  | ||||
| 	if(txt.size() < lineLen) | ||||
| @@ -5664,7 +5664,7 @@ void MoraleLuckBox::set(const IBonusBearer *node) | ||||
| 				text += "\n" + mrl[it].second; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	std::string imageName; | ||||
| 	if (small) | ||||
| 		imageName = morale ? "IMRL30": "ILCK30"; | ||||
| @@ -5787,8 +5787,7 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town): | ||||
|     CWindowObject(RCLICK_POPUP | PLAYER_COLORED, "TOWNQVBK", toScreen(position)) | ||||
| { | ||||
| 	InfoAboutTown iah; | ||||
| 	bool gotInfo = LOCPLINT->cb->getTownInfo(town, iah); | ||||
| 	assert(gotInfo); | ||||
| 	LOCPLINT->cb->getTownInfo(town, iah); | ||||
|  | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	new CTownTooltip(Point(9, 10), iah); | ||||
| @@ -5798,8 +5797,7 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero): | ||||
|     CWindowObject(RCLICK_POPUP | PLAYER_COLORED, "HEROQVBK", toScreen(position)) | ||||
| { | ||||
| 	InfoAboutHero iah; | ||||
| 	bool gotInfo = LOCPLINT->cb->getHeroInfo(hero, iah); | ||||
| 	assert(gotInfo); | ||||
| 	LOCPLINT->cb->getHeroInfo(hero, iah); | ||||
|  | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	new CHeroTooltip(Point(9, 10), iah); | ||||
| @@ -5809,8 +5807,7 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr): | ||||
|     CWindowObject(RCLICK_POPUP | PLAYER_COLORED, "TOWNQVBK", toScreen(position)) | ||||
| { | ||||
| 	InfoAboutTown iah; | ||||
| 	bool gotInfo = LOCPLINT->cb->getTownInfo(garr, iah); | ||||
| 	assert(gotInfo); | ||||
| 	LOCPLINT->cb->getTownInfo(garr, iah); | ||||
|  | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	new CArmyTooltip(Point(9, 10), iah); | ||||
|   | ||||
| @@ -51,39 +51,20 @@ namespace Colors | ||||
| template<typename IntType> | ||||
| std::string makeNumberShort(IntType number) //the output is a string containing at most 5 characters [4 if positive] (eg. intead 10000 it gives 10k) | ||||
| { | ||||
| 	int initialLength; | ||||
| 	bool negative = (number < 0); | ||||
| 	std::ostringstream ost, rets; | ||||
| 	ost<<number; | ||||
| 	initialLength = ost.str().size(); | ||||
| 	if (abs(number) < 1000) | ||||
| 		return boost::lexical_cast<std::string>(number); | ||||
|  | ||||
| 	if(negative) | ||||
| 	std::string symbols = "kMGTPE"; | ||||
| 	auto iter = symbols.begin(); | ||||
|  | ||||
| 	while (number >= 1000) | ||||
| 	{ | ||||
| 		if(initialLength <= 4) | ||||
| 			return ost.str(); | ||||
| 		number /= 1000; | ||||
| 		iter++; | ||||
|  | ||||
| 		assert(iter != symbols.end());//should be enough even for int64 | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		if(initialLength <= 5) | ||||
| 			return ost.str(); | ||||
| 	} | ||||
|  | ||||
| 	//make the number int | ||||
| 	char symbol[] = {'G', 'M', 'k'}; | ||||
|  | ||||
| 	if(negative) number = (-number); //absolute value | ||||
|  | ||||
| 	for(int divisor = 1000000000, it = 0; divisor > 1; divisor /= 1000, ++it) | ||||
| 	{ | ||||
| 		if(number >= divisor) | ||||
| 		{ | ||||
| 			if(negative) rets <<'-'; | ||||
| 			rets << (number / divisor) << symbol[it]; | ||||
| 			return rets.str(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	throw std::runtime_error("We shouldn't be here - makeNumberShort"); | ||||
| 	return boost::lexical_cast<std::string>(number) + *iter; | ||||
| } | ||||
|  | ||||
| typedef void (*TColorPutter)(Uint8 *&ptr, const Uint8 & R, const Uint8 & G, const Uint8 & B); | ||||
|   | ||||
| @@ -53,10 +53,10 @@ std::map<ui8, ui8> CGObelisk::visited; //map: team_id => how many obelisks has b | ||||
| std::vector<const CArtifact *> CGTownInstance::merchantArtifacts; | ||||
| std::vector<int> CGTownInstance::universitySkills; | ||||
|  | ||||
| void IObjectInterface::onHeroVisit(const CGHeroInstance * h) const  | ||||
| void IObjectInterface::onHeroVisit(const CGHeroInstance * h) const | ||||
| {}; | ||||
|  | ||||
| void IObjectInterface::onHeroLeave(const CGHeroInstance * h) const  | ||||
| void IObjectInterface::onHeroLeave(const CGHeroInstance * h) const | ||||
| {}; | ||||
|  | ||||
| void IObjectInterface::newTurn () const | ||||
| @@ -289,7 +289,7 @@ bool CGObjectInstance::coveringAt(int x, int y) const | ||||
| 	y = -y; | ||||
| #if USE_COVERAGE_MAP | ||||
| 	//NOTE: this code may be broken | ||||
| 	if((defInfo->coverageMap[y] >> (7-(x) )) & 1  | ||||
| 	if((defInfo->coverageMap[y] >> (7-(x) )) & 1 | ||||
| 		||  (defInfo->shadowCoverage[y] >> (7-(x) )) & 1) | ||||
| 		return true; | ||||
| 	return false; | ||||
| @@ -432,7 +432,7 @@ void CGObjectInstance::getNameVis( std::string &hname ) const | ||||
| { | ||||
| 	const CGHeroInstance *h = cb->getSelectedHero(cb->getCurrentPlayer()); | ||||
| 	hname = VLC->generaltexth->names[ID]; | ||||
| 	if(h)  | ||||
| 	if(h) | ||||
| 	{ | ||||
| 		if(!h->hasBonusFrom(Bonus::OBJECT,ID)) | ||||
| 			hname += " " + VLC->generaltexth->allTexts[353]; //not visited | ||||
| @@ -531,9 +531,9 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro | ||||
|  | ||||
| 	//base move cost | ||||
| 	unsigned ret = 100; | ||||
| 	 | ||||
|  | ||||
| 	//if there is road both on dest and src tiles - use road movement cost | ||||
| 	if(dest.malle && from.malle)  | ||||
| 	if(dest.malle && from.malle) | ||||
| 	{ | ||||
| 		int road = std::min(dest.malle,from.malle); //used road ID | ||||
| 		switch(road) | ||||
| @@ -552,7 +552,7 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	else  | ||||
| 	else | ||||
| 	{ | ||||
| 		ret = type->heroClass->terrCosts[from.tertype]; | ||||
| 		ret = std::max(ret - 25*unsigned(getSecSkillLevel(CGHeroInstance::PATHFINDING)), 100u); //reduce 25% of terrain penalty for each pathfinding level | ||||
| @@ -560,7 +560,7 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro | ||||
| 	return ret; | ||||
| } | ||||
| #if 0 | ||||
| // Unused and buggy method.  | ||||
| // Unused and buggy method. | ||||
| //  - for loop is wrong. will not find all creatures. must use iterator instead. | ||||
| //  - -> is the slot number. use second->first for creature index | ||||
| // Is lowestSpeed() the correct equivalent ? | ||||
| @@ -657,7 +657,7 @@ int CGHeroInstance::maxMovePoints(bool onLand) const | ||||
| 	{ | ||||
| 		base = 1500; //on water base movement is always 1500 (speed of army doesn't matter) | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	int bonus = valOfBonuses(Bonus::MOVEMENT) + (onLand ? valOfBonuses(Bonus::LAND_MOVEMENT) : valOfBonuses(Bonus::SEA_MOVEMENT)); | ||||
|  | ||||
| 	double modifier = 0; | ||||
| @@ -741,7 +741,7 @@ void CGHeroInstance::initHero() | ||||
|  | ||||
| 	if(!getArt(ArtifactPosition::MACH4)) | ||||
| 		putArtifact(ArtifactPosition::MACH4, CArtifactInstance::createNewArtifactInstance(3)); //everyone has a catapult | ||||
| 	 | ||||
|  | ||||
| 	if(portrait < 0 || portrait == 255) | ||||
| 		portrait = subID; | ||||
| 	if(!hasBonus(Selector::sourceType(Bonus::HERO_BASE_SKILL))) | ||||
| @@ -927,7 +927,7 @@ const std::string & CGHeroInstance::getBiography() const | ||||
| 	if (biography.length()) | ||||
| 		return biography; | ||||
| 	else | ||||
| 		return VLC->generaltexth->hTxts[subID].biography;		 | ||||
| 		return VLC->generaltexth->hTxts[subID].biography; | ||||
| } | ||||
| void CGHeroInstance::initObj() | ||||
| { | ||||
| @@ -965,7 +965,7 @@ void CGHeroInstance::initObj() | ||||
| 					} | ||||
|  | ||||
| 					bonus->limiter.reset(new CCreatureTypeLimiter (specCreature, true)); //with upgrades | ||||
| 					bonus->type = Bonus::PRIMARY_SKILL;  | ||||
| 					bonus->type = Bonus::PRIMARY_SKILL; | ||||
| 					bonus->additionalInfo = it->additionalinfo; | ||||
| 					bonus->valType = Bonus::ADDITIVE_VALUE; | ||||
|  | ||||
| @@ -1182,7 +1182,7 @@ void CGHeroInstance::updateSkill(int which, int val) | ||||
| 	} | ||||
| 	else if(which == DIPLOMACY) //surrender discount: 20% per level | ||||
| 	{ | ||||
| 		 | ||||
|  | ||||
| 		if(Bonus *b = getBonus(Selector::type(Bonus::SURRENDER_DISCOUNT) && Selector::sourceType(Bonus::SECONDARY_SKILL))) | ||||
| 			b->val = +val; | ||||
| 		else | ||||
| @@ -1230,7 +1230,7 @@ void CGHeroInstance::updateSkill(int which, int val) | ||||
| 		case ESTATES: | ||||
| 			skillVal = 125 << (val-1); break; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
|  | ||||
| 	int skillValType = skillVal ? Bonus::BASE_NUMBER : Bonus::INDEPENDENT_MIN; | ||||
| 	if(Bonus * b = getBonusList().getFirst(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, which) && Selector::sourceType(Bonus::SECONDARY_SKILL))) //only local hero bonus | ||||
| @@ -1244,7 +1244,7 @@ void CGHeroInstance::updateSkill(int which, int val) | ||||
| 		bonus->source = Bonus::SECONDARY_SKILL; | ||||
| 		addNewBonus(bonus); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| } | ||||
| void CGHeroInstance::setPropertyDer( ui8 what, ui32 val ) | ||||
| { | ||||
| @@ -1331,7 +1331,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b | ||||
| 	const ui8 necromancyLevel = getSecSkillLevel(CGHeroInstance::NECROMANCY); | ||||
|  | ||||
| 	// Hero knows necromancy. | ||||
| 	if (necromancyLevel > 0)  | ||||
| 	if (necromancyLevel > 0) | ||||
| 	{ | ||||
| 		double necromancySkill = valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, NECROMANCY)/100.0; | ||||
| 		vstd::amin(necromancySkill, 1.0); //it's impossible to raise more creatures than all... | ||||
| @@ -1358,7 +1358,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b | ||||
|  | ||||
| 		// Make room for new units. | ||||
| 		int slot = getSlotFor(raisedUnitType->idNumber); | ||||
| 		if (slot == -1)  | ||||
| 		if (slot == -1) | ||||
| 		{ | ||||
| 			// If there's no room for unit, try it's upgraded version 2/3rds the size. | ||||
| 			raisedUnitType = VLC->creh->creatures[*raisedUnitType->upgrades.begin()]; | ||||
| @@ -1388,13 +1388,13 @@ void CGHeroInstance::showNecromancyDialog(const CStackBasicDescriptor &raisedSta | ||||
| 	iw.components.push_back(Component(raisedStack)); | ||||
|  | ||||
| 	if (raisedStack.count > 1) // Practicing the dark arts of necromancy, ... (plural) | ||||
| 	{  | ||||
| 	{ | ||||
| 		iw.text.addTxt(MetaString::GENERAL_TXT, 145); | ||||
| 		iw.text.addReplacement(raisedStack.count); | ||||
| 		iw.text.addReplacement(MetaString::CRE_PL_NAMES, raisedStack.type->idNumber); | ||||
| 	}  | ||||
| 	} | ||||
| 	else // Practicing the dark arts of necromancy, ... (singular) | ||||
| 	{  | ||||
| 	{ | ||||
| 		iw.text.addTxt(MetaString::GENERAL_TXT, 146); | ||||
| 		iw.text.addReplacement(MetaString::CRE_SING_NAMES, raisedStack.type->idNumber); | ||||
| 	} | ||||
| @@ -1417,7 +1417,7 @@ si32 CGHeroInstance::manaRegain() const | ||||
| 	if (hasBonusOfType(Bonus::FULL_MANA_REGENERATION)) | ||||
| 		return manaLimit(); | ||||
|  | ||||
| 	return 1 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, 8) + valOfBonuses(Bonus::MANA_REGENERATION); //1 + Mysticism level  | ||||
| 	return 1 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, 8) + valOfBonuses(Bonus::MANA_REGENERATION); //1 + Mysticism level | ||||
| } | ||||
|  | ||||
| // /** | ||||
| @@ -1433,7 +1433,7 @@ si32 CGHeroInstance::manaRegain() const | ||||
|  | ||||
| int CGHeroInstance::getBoatType() const | ||||
| { | ||||
| 	int alignment = type->heroType / 6;  | ||||
| 	int alignment = type->heroType / 6; | ||||
| 	switch(alignment) | ||||
| 	{ | ||||
| 	case 0: | ||||
| @@ -1570,14 +1570,14 @@ void CGDwelling::initObj() | ||||
| 		if(subID == 1) //Golem Factory | ||||
| 		{ | ||||
| 			creatures[0].second.push_back(32);  //Stone Golem | ||||
| 			creatures[1].second.push_back(33);  //Iron Golem   | ||||
| 			creatures[1].second.push_back(33);  //Iron Golem | ||||
| 			creatures[2].second.push_back(116); //Gold Golem | ||||
| 			creatures[3].second.push_back(117); //Diamond Golem | ||||
| 			//guards | ||||
| 			putStack(0, new CStackInstance(116, 9)); | ||||
| 			putStack(1, new CStackInstance(117, 6)); | ||||
| 		} | ||||
| 		else if(subID == 0) // Elemental Conflux  | ||||
| 		else if(subID == 0) // Elemental Conflux | ||||
| 		{ | ||||
| 			creatures[0].second.push_back(112); //Air Elemental | ||||
| 			creatures[1].second.push_back(114); //Fire Elemental | ||||
| @@ -1595,11 +1595,11 @@ void CGDwelling::initObj() | ||||
|  | ||||
| 	case 78: //Refugee Camp | ||||
| 		//is handled within newturn func | ||||
| 		break;  | ||||
| 		break; | ||||
|  | ||||
| 	case 106: //War Machine Factory | ||||
| 		creatures.resize(3); | ||||
| 		creatures[0].second.push_back(146); //Ballista  | ||||
| 		creatures[0].second.push_back(146); //Ballista | ||||
| 		creatures[1].second.push_back(147); //First Aid Tent | ||||
| 		creatures[2].second.push_back(148); //Ammo Cart | ||||
| 		break; | ||||
| @@ -1647,10 +1647,10 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 	} | ||||
|  | ||||
| 	int relations = cb->gameState()->getPlayerRelations( h->tempOwner, tempOwner ); | ||||
| 	 | ||||
|  | ||||
| 	if ( relations == 1 )//ally | ||||
| 		return;//do not allow recruiting or capturing | ||||
| 		 | ||||
|  | ||||
| 	if( !relations  &&  stacksCount() > 0) //object is guarded, owned by enemy | ||||
| 	{ | ||||
| 		BlockingDialog bd; | ||||
| @@ -1799,7 +1799,7 @@ void CGDwelling::heroAcceptsCreatures( const CGHeroInstance *h, ui32 answer ) co | ||||
| 		ow.id1 = id; | ||||
| 		ow.id2 = h->id; | ||||
| 		ow.window = (ID == 17 || ID == 78) | ||||
| 			? OpenWindow::RECRUITMENT_FIRST  | ||||
| 			? OpenWindow::RECRUITMENT_FIRST | ||||
| 			: OpenWindow::RECRUITMENT_ALL; | ||||
| 		cb->sendAndApply(&ow); | ||||
| 	} | ||||
| @@ -1850,7 +1850,7 @@ void CGTownInstance::setPropertyDer(ui8 what, ui32 val) | ||||
| 			break; | ||||
| 		case 15: | ||||
| 			bonusValue.second = val; | ||||
| 			break;			 | ||||
| 			break; | ||||
| 	} | ||||
| } | ||||
| CGTownInstance::EFortLevel CGTownInstance::fortLevel() const //0 - none, 1 - fort, 2 - citadel, 3 - castle | ||||
| @@ -1943,7 +1943,7 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const | ||||
|  | ||||
| 	if(dwellingBonus) | ||||
| 		ret.entries.push_back(GrowthInfo::Entry(VLC->generaltexth->allTexts[591], dwellingBonus));// \nExternal dwellings %+d | ||||
| 		 | ||||
|  | ||||
| 	//other *-of-legion-like bonuses (%d to growth cumulative with grail) | ||||
| 	TBonusListPtr bonuses = getBonuses(Selector::type(Bonus::CREATURE_GROWTH) && Selector::subtype(level)); | ||||
| 	BOOST_FOREACH(const Bonus *b, *bonuses) | ||||
| @@ -1993,7 +1993,7 @@ CGTownInstance::CGTownInstance() | ||||
|  | ||||
| CGTownInstance::~CGTownInstance() | ||||
| { | ||||
| 	for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++)  | ||||
| 	for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++) | ||||
| 		delete *i; | ||||
| } | ||||
|  | ||||
| @@ -2003,7 +2003,7 @@ int CGTownInstance::spellsAtLevel(int level, bool checkGuild) const | ||||
| 		return 0; | ||||
| 	int ret = 6 - level; //how many spells are available at this level | ||||
| 	if(subID == 2   &&   vstd::contains(builtBuildings,22)) //magic library in Tower | ||||
| 		ret++;  | ||||
| 		ret++; | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| @@ -2033,8 +2033,8 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const | ||||
|  | ||||
| 			bool outsideTown = (defendingHero == visitingHero && garrisonHero); | ||||
|  | ||||
| 			//TODO  | ||||
| 			//"borrowing" army from garrison to visiting hero  | ||||
| 			//TODO | ||||
| 			//"borrowing" army from garrison to visiting hero | ||||
|  | ||||
| 			cb->startBattleI(h, defendingArmy, getSightCenter(), h, defendingHero, false, boost::bind(&CGTownInstance::fightOver, this, h, _1), (outsideTown ? NULL : this)); | ||||
| 		} | ||||
| @@ -2152,7 +2152,7 @@ void CGTownInstance::newTurn() const | ||||
| 					int i = rand() % std::min (GameConstants::ARMY_SIZE, cb->getDate(3)<<1); | ||||
| 					TCreature c = town->basicCreatures[i]; | ||||
| 					TSlot n = -1; | ||||
| 					 | ||||
|  | ||||
| 					TQuantity count = creatureGrowth(i); | ||||
| 					if (!count) // no dwelling | ||||
| 						count = VLC->creh->creatures[c]->growth; | ||||
| @@ -2160,7 +2160,7 @@ void CGTownInstance::newTurn() const | ||||
| 					{//no lower tiers or above current month | ||||
|  | ||||
| 						if ((n = getSlotFor(c))>=0) | ||||
| 						{  | ||||
| 						{ | ||||
| 							StackLocation sl(this, n); | ||||
| 							if (slotEmpty(n)) | ||||
| 								cb->insertNewStack(sl, VLC->creh->creatures[c], count); | ||||
| @@ -2168,7 +2168,7 @@ void CGTownInstance::newTurn() const | ||||
| 								cb->changeStackCount(sl, count); | ||||
| 						} | ||||
| 					} | ||||
| 				}		 | ||||
| 				} | ||||
| 			} | ||||
| 	} | ||||
| } | ||||
| @@ -2184,12 +2184,12 @@ ui8 CGTownInstance::getPassableness() const | ||||
| 		return GameConstants::ALL_PLAYERS; | ||||
| 	if ( tempOwner == 255 )//neutral guarded - no one can visit | ||||
| 		return 0; | ||||
| 		 | ||||
|  | ||||
| 	ui8 mask = 0; | ||||
| 	TeamState * ts = cb->gameState()->getPlayerTeam(tempOwner); | ||||
| 	BOOST_FOREACH(ui8 it, ts->players) | ||||
| 		mask |= 1<<it;//allies - add to possible visitors | ||||
| 	 | ||||
|  | ||||
| 	return mask; | ||||
| } | ||||
|  | ||||
| @@ -2213,24 +2213,24 @@ void CGTownInstance::fightOver( const CGHeroInstance *h, BattleResult *result ) | ||||
| } | ||||
|  | ||||
| void CGTownInstance::removeCapitols (ui8 owner) const | ||||
| {  | ||||
| { | ||||
| 	if (hasCapitol()) // search if there's an older capitol | ||||
| 	{  | ||||
| 	{ | ||||
| 		PlayerState* state = cb->gameState()->getPlayer (owner); //get all towns owned by player | ||||
| 		for (std::vector<ConstTransitivePtr<CGTownInstance> >::const_iterator i = state->towns.begin(); i < state->towns.end(); ++i)  | ||||
| 		{  | ||||
| 			if (*i != this && (*i)->hasCapitol())  | ||||
| 			{  | ||||
| 				RazeStructures rs;  | ||||
| 				rs.tid = id;  | ||||
| 				rs.bid.insert(13);  | ||||
| 				rs.destroyed = destroyed;   | ||||
| 				cb->sendAndApply(&rs);  | ||||
| 				return;  | ||||
| 			}  | ||||
| 		}  | ||||
| 	}  | ||||
| }  | ||||
| 		for (std::vector<ConstTransitivePtr<CGTownInstance> >::const_iterator i = state->towns.begin(); i < state->towns.end(); ++i) | ||||
| 		{ | ||||
| 			if (*i != this && (*i)->hasCapitol()) | ||||
| 			{ | ||||
| 				RazeStructures rs; | ||||
| 				rs.tid = id; | ||||
| 				rs.bid.insert(13); | ||||
| 				rs.destroyed = destroyed; | ||||
| 				cb->sendAndApply(&rs); | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| int CGTownInstance::getBoatType() const | ||||
| { | ||||
| @@ -2245,7 +2245,7 @@ int CGTownInstance::getBoatType() const | ||||
|  | ||||
| int CGTownInstance::getMarketEfficiency() const | ||||
| { | ||||
| 	if(!vstd::contains(builtBuildings, 14))  | ||||
| 	if(!vstd::contains(builtBuildings, 14)) | ||||
| 		return 0; | ||||
|  | ||||
| 	const PlayerState *p = cb->getPlayer(tempOwner); | ||||
| @@ -2325,7 +2325,7 @@ void CGTownInstance::recreateBuildingsBonuses() | ||||
|  | ||||
| 	if(subID != 0 || !addBonusIfBuilt(22, Bonus::MORALE, +2)) //tricky! -> checks tavern only if no bratherhood of sword or not a castle | ||||
| 		addBonusIfBuilt(5, Bonus::MORALE, +1); | ||||
| 	 | ||||
|  | ||||
| 	if(subID == 0) //castle | ||||
| 	{ | ||||
| 		addBonusIfBuilt(17, Bonus::SEA_MOVEMENT, +500, make_shared<CPropagatorNodeType>(PLAYER)); //lighthouses | ||||
| @@ -2737,19 +2737,19 @@ const std::string & CGVisitableOPH::getHoverText() const | ||||
| 		pom = -1; | ||||
| 		break; | ||||
| 	case 51: | ||||
| 		pom = 8;  | ||||
| 		pom = 8; | ||||
| 		break; | ||||
| 	case 23: | ||||
| 		pom = 7; | ||||
| 		break; | ||||
| 	case 61: | ||||
| 		pom = 11;  | ||||
| 		pom = 11; | ||||
| 		break; | ||||
| 	case 32: | ||||
| 		pom = 4;  | ||||
| 		pom = 4; | ||||
| 		break; | ||||
| 	case 100: | ||||
| 		pom = 5;  | ||||
| 		pom = 5; | ||||
| 		break; | ||||
| 	case 102: | ||||
| 		pom = 18; | ||||
| @@ -2772,7 +2772,7 @@ const std::string & CGVisitableOPH::getHoverText() const | ||||
| 	if(h) | ||||
| 	{ | ||||
| 		hoverName += "\n\n"; | ||||
| 		hoverName += (vstd::contains(visitors,h->id))  | ||||
| 		hoverName += (vstd::contains(visitors,h->id)) | ||||
| 							? (VLC->generaltexth->allTexts[352])  //visited | ||||
| 							: ( VLC->generaltexth->allTexts[353]); //not visited | ||||
| 	} | ||||
| @@ -2843,7 +2843,7 @@ void COPWBonus::onHeroVisit (const CGHeroInstance * h) const | ||||
| 			case 5: //Mana Vortex | ||||
| 				if (visitors.empty() && h->mana <= h->manaLimit() * 2) | ||||
| 				{ | ||||
| 					cb->setManaPoints (heroID, 2 * h->manaLimit());  | ||||
| 					cb->setManaPoints (heroID, 2 * h->manaLimit()); | ||||
| 					cb->setObjProperty (id, ObjProperty::VISITED, true); | ||||
| 					iw.text << VLC->generaltexth->allTexts[579]; | ||||
| 					cb->showInfoDialog(&iw); | ||||
| @@ -2973,7 +2973,7 @@ void CGCreature::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 		{ | ||||
| 			BlockingDialog ynd(true,false); | ||||
| 			ynd.player = h->tempOwner; | ||||
| 			ynd.text << std::pair<ui8,ui32>(MetaString::ADVOB_TXT, 86);  | ||||
| 			ynd.text << std::pair<ui8,ui32>(MetaString::ADVOB_TXT, 86); | ||||
| 			ynd.text.addReplacement(MetaString::CRE_PL_NAMES, subID); | ||||
| 			cb->showBlockingDialog(&ynd,boost::bind(&CGCreature::joinDecision,this,h,0,_1)); | ||||
| 			break; | ||||
| @@ -3009,7 +3009,7 @@ void CGCreature::endBattle( BattleResult *result ) const | ||||
| 		//for(std::set<std::pair<ui32,si32> >::iterator i=result->casualties[1].begin(); i!=result->casualties[1].end(); i++) | ||||
| 		//	if(i->first == subID) | ||||
| 		//		killedAmount += i->second; | ||||
| 		//cb->setAmount(id, slots.find(0)->second.second - killedAmount);	 | ||||
| 		//cb->setAmount(id, slots.find(0)->second.second - killedAmount); | ||||
|  | ||||
| 		/* | ||||
| 		MetaString ms; | ||||
| @@ -3139,7 +3139,7 @@ int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const | ||||
| 	std::set<ui32> myKindCres; //what creatures are the same kind as we | ||||
| 	myKindCres.insert(subID); //we | ||||
| 	myKindCres.insert(VLC->creh->creatures[subID]->upgrades.begin(),VLC->creh->creatures[subID]->upgrades.end()); //our upgrades | ||||
| 	 | ||||
|  | ||||
| 	BOOST_FOREACH(ConstTransitivePtr<CCreature> &crea, VLC->creh->creatures) | ||||
| 	{ | ||||
| 		if(vstd::contains(crea->upgrades, (ui32) id)) //it's our base creatures | ||||
| @@ -3309,7 +3309,7 @@ void CGCreature::flee( const CGHeroInstance * h ) const | ||||
| { | ||||
| 	BlockingDialog ynd(true,false); | ||||
| 	ynd.player = h->tempOwner; | ||||
| 	ynd.text << std::pair<ui8,ui32>(11,91);  | ||||
| 	ynd.text << std::pair<ui8,ui32>(11,91); | ||||
| 	ynd.text.addReplacement(MetaString::CRE_PL_NAMES, subID); | ||||
| 	cb->showBlockingDialog(&ynd,boost::bind(&CGCreature::fleeDecision,this,h,_1)); | ||||
| } | ||||
| @@ -3317,11 +3317,11 @@ void CGCreature::flee( const CGHeroInstance * h ) const | ||||
| void CGMine::onHeroVisit( const CGHeroInstance * h ) const | ||||
| { | ||||
| 	int relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); | ||||
| 	 | ||||
|  | ||||
| 	if(relations == 2) //we're visiting our mine | ||||
| 	{ | ||||
| 		cb->showGarrisonDialog(id,h->id,true,0); | ||||
| 		return;  | ||||
| 		return; | ||||
| 	} | ||||
| 	else if (relations == 1)//ally | ||||
| 		return; | ||||
| @@ -3330,7 +3330,7 @@ void CGMine::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 	{ | ||||
| 		BlockingDialog ynd(true,false); | ||||
| 		ynd.player = h->tempOwner; | ||||
| 		ynd.text << std::pair<ui8,ui32>(MetaString::ADVOB_TXT, subID == 7 ? 84 : 187);  | ||||
| 		ynd.text << std::pair<ui8,ui32>(MetaString::ADVOB_TXT, subID == 7 ? 84 : 187); | ||||
| 		cb->showBlockingDialog(&ynd,boost::bind(&CGMine::fight, this, _1, h)); | ||||
| 		return; | ||||
| 	} | ||||
| @@ -3377,7 +3377,7 @@ void CGMine::initObj() | ||||
| 		MetaString ms; | ||||
| 		ms << std::pair<ui8,ui32>(9,producedResource); | ||||
| 		if(tempOwner >= GameConstants::PLAYER_LIMIT) | ||||
| 			tempOwner = GameConstants::NEUTRAL_PLAYER;	 | ||||
| 			tempOwner = GameConstants::NEUTRAL_PLAYER; | ||||
| 		else | ||||
| 			ms << " (" << std::pair<ui8,ui32>(6,23+tempOwner) << ")"; | ||||
| 		ms.toString(hoverName); | ||||
| @@ -3557,7 +3557,7 @@ void CGVisitableOPW::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 	{ | ||||
| 		if (ID!=112) | ||||
| 			mid++; | ||||
| 		else  | ||||
| 		else | ||||
| 			mid--; | ||||
|  | ||||
| 		InfoWindow iw; | ||||
| @@ -4015,7 +4015,7 @@ void CGPickable::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 			if (subID) //not OH3 treasure chest | ||||
| 			{ | ||||
| 				tlog2 << "Not supported WoG treasure chest!\n"; | ||||
| 				return;  | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			if(type) //there is an artifact | ||||
| @@ -4115,7 +4115,7 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const | ||||
| 		case MISSION_RESOURCES: | ||||
| 			for (int i = 0; i < 7; ++i) //including Mithril ? | ||||
| 			{	//Quest has no direct access to callback | ||||
| 				if (h->cb->getResource (h->tempOwner, i) < m7resources[i])  | ||||
| 				if (h->cb->getResource (h->tempOwner, i) < m7resources[i]) | ||||
| 					return false; | ||||
| 			} | ||||
| 			return true; | ||||
| @@ -4136,7 +4136,7 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component | ||||
| 	std::string text; | ||||
| 	bool failRequirements = (h ? !checkQuest(h) : true); | ||||
|  | ||||
| 	if (firstVisit)  | ||||
| 	if (firstVisit) | ||||
| 	{ | ||||
| 		isCustom = isCustomFirst; | ||||
| 		iwText << firstVisitText; | ||||
| @@ -4164,7 +4164,7 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component | ||||
| 					loot << "%d %s"; | ||||
| 					loot.addReplacement(m2stats[i]); | ||||
| 					loot.addReplacement(VLC->generaltexth->primarySkillNames[i]); | ||||
| 				}		 | ||||
| 				} | ||||
| 			} | ||||
| 			if (!isCustom) | ||||
| 				iwText.addReplacement(loot.buildList()); | ||||
| @@ -4259,7 +4259,7 @@ void CQuest::getRolloverText (MetaString &ms, bool onHover) const | ||||
| 						loot << "%d %s"; | ||||
| 						loot.addReplacement(m2stats[i]); | ||||
| 						loot.addReplacement(VLC->generaltexth->primarySkillNames[i]); | ||||
| 					}		 | ||||
| 					} | ||||
| 				} | ||||
| 				ms.addReplacement(loot.buildList()); | ||||
| 			} | ||||
| @@ -4422,9 +4422,9 @@ void CGSeerHut::initObj() | ||||
| 	if (missionType) | ||||
| 	{ | ||||
| 		if (!isCustomFirst) | ||||
| 			firstVisitText = VLC->generaltexth->quests[missionType-1][0][textOption];	 | ||||
| 			firstVisitText = VLC->generaltexth->quests[missionType-1][0][textOption]; | ||||
| 		if (!isCustomNext) | ||||
| 			nextVisitText = VLC->generaltexth->quests[missionType-1][1][textOption];	 | ||||
| 			nextVisitText = VLC->generaltexth->quests[missionType-1][1][textOption]; | ||||
| 		if (!isCustomComplete) | ||||
| 			completedText = VLC->generaltexth->quests[missionType-1][2][textOption]; | ||||
| 	} | ||||
| @@ -4457,7 +4457,7 @@ const std::string & CGSeerHut::getHoverText() const | ||||
| 	if (progress & missionType) //rollover when the quest is active | ||||
| 	{ | ||||
| 		MetaString ms; | ||||
| 		getRolloverText (ms, true);  | ||||
| 		getRolloverText (ms, true); | ||||
| 		hoverName += ms.toString(); | ||||
| 	} | ||||
| 	return hoverName; | ||||
| @@ -4539,7 +4539,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 		bool failRequirements = !checkQuest(h); | ||||
| 		bool isCustom=false; | ||||
|  | ||||
| 		if (firstVisit)  | ||||
| 		if (firstVisit) | ||||
| 		{ | ||||
| 			isCustom = isCustomFirst; | ||||
| 			cb->setObjProperty (id, 10, IN_PROGRESS); | ||||
| @@ -4565,9 +4565,9 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 			BlockingDialog bd (true, false); | ||||
| 			bd.player = h->getOwner(); | ||||
| 			bd.soundID = soundBase::QUEST; | ||||
| 			 | ||||
|  | ||||
| 			getCompletionText (bd.text, bd.components, isCustom, h); | ||||
| 			 | ||||
|  | ||||
| 			cb->showBlockingDialog (&bd, boost::bind (&CGSeerHut::finishQuest, this, h, _1)); | ||||
| 			return; | ||||
| 		} | ||||
| @@ -4637,7 +4637,7 @@ void CGSeerHut::finishQuest(const CGHeroInstance * h, ui32 accept) const | ||||
| 		} | ||||
| 		cb->setObjProperty (id, 10, COMPLETE); //mission complete - for AI | ||||
| 		cb->setObjProperty (id, 11, 0); //no more mission available - redundant? | ||||
| 		completeQuest(h); //make sure to remove QuestQuard at the very end	 | ||||
| 		completeQuest(h); //make sure to remove QuestQuard at the very end | ||||
| 	} | ||||
| } | ||||
| void CGSeerHut::completeQuest (const CGHeroInstance * h) const //reward | ||||
| @@ -4977,7 +4977,7 @@ const std::string & CGBonusingObject::getHoverText() const | ||||
| { | ||||
| 	const CGHeroInstance *h = cb->getSelectedHero(cb->getCurrentPlayer()); | ||||
| 	hoverName = VLC->generaltexth->names[ID]; | ||||
| 	if(h)  | ||||
| 	if(h) | ||||
| 	{ | ||||
| 		if(!h->hasBonusFrom(Bonus::OBJECT,ID)) | ||||
| 			hoverName += " " + VLC->generaltexth->allTexts[353]; //not visited | ||||
| @@ -4995,38 +4995,38 @@ void CGBonusingObject::initObj() | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CGMagicSpring::onHeroVisit(const CGHeroInstance * h) const  | ||||
| {  | ||||
| 	int messageID;  | ||||
| 	InfoWindow iw;  | ||||
| 	iw.player = h->tempOwner;  | ||||
| 	iw.soundID = soundBase::GENIE;  | ||||
| 	if (!visited)  | ||||
| 	{  | ||||
| 		if (h->mana > h->manaLimit())   | ||||
| 			messageID = 76;  | ||||
| 		else  | ||||
| 		{  | ||||
| 			messageID = 74;  | ||||
| 			cb->setManaPoints (h->id, 2 * h->manaLimit());  | ||||
| 			cb->setObjProperty (id, ObjProperty::VISITED, true);  | ||||
| 		}  | ||||
| 	}  | ||||
| 	else  | ||||
| 		messageID = 75;  | ||||
| 	iw.text << std::pair<ui8,ui32>(11,messageID);  | ||||
| 	cb->showInfoDialog(&iw);  | ||||
| }  | ||||
| void CGMagicSpring::onHeroVisit(const CGHeroInstance * h) const | ||||
| { | ||||
| 	int messageID; | ||||
| 	InfoWindow iw; | ||||
| 	iw.player = h->tempOwner; | ||||
| 	iw.soundID = soundBase::GENIE; | ||||
| 	if (!visited) | ||||
| 	{ | ||||
| 		if (h->mana > h->manaLimit()) | ||||
| 			messageID = 76; | ||||
| 		else | ||||
| 		{ | ||||
| 			messageID = 74; | ||||
| 			cb->setManaPoints (h->id, 2 * h->manaLimit()); | ||||
| 			cb->setObjProperty (id, ObjProperty::VISITED, true); | ||||
| 		} | ||||
| 	} | ||||
| 	else | ||||
| 		messageID = 75; | ||||
| 	iw.text << std::pair<ui8,ui32>(11,messageID); | ||||
| 	cb->showInfoDialog(&iw); | ||||
| } | ||||
|  | ||||
| const std::string & CGMagicSpring::getHoverText() const  | ||||
| {  | ||||
| const std::string & CGMagicSpring::getHoverText() const | ||||
| { | ||||
| 	hoverName = VLC->generaltexth->names[ID]; | ||||
| 	if(!visited) | ||||
| 		hoverName += " " + VLC->generaltexth->allTexts[353]; //not visited | ||||
| 	else | ||||
| 		hoverName += " " + VLC->generaltexth->allTexts[352]; //visited | ||||
| 	return hoverName; | ||||
| }  | ||||
| } | ||||
|  | ||||
| void CGMagicWell::onHeroVisit( const CGHeroInstance * h ) const | ||||
| { | ||||
| @@ -5069,7 +5069,7 @@ void CGPandoraBox::onHeroVisit(const CGHeroInstance * h) const | ||||
| 		bd.player = h->getOwner(); | ||||
| 		bd.soundID = soundBase::QUEST; | ||||
| 		bd.text.addTxt (MetaString::ADVOB_TXT, 14); | ||||
| 		cb->showBlockingDialog (&bd, boost::bind (&CGPandoraBox::open, this, h, _1));	 | ||||
| 		cb->showBlockingDialog (&bd, boost::bind (&CGPandoraBox::open, this, h, _1)); | ||||
| } | ||||
|  | ||||
| void CGPandoraBox::open( const CGHeroInstance * h, ui32 accept ) const | ||||
| @@ -5284,7 +5284,7 @@ void CGPandoraBox::giveContents( const CGHeroInstance *h, bool afterBattle ) con | ||||
|  | ||||
| 	if (creatures.Slots().size()) | ||||
| 	{ //this part is taken straight from creature bank | ||||
| 		MetaString loot;  | ||||
| 		MetaString loot; | ||||
| 		for(TSlots::const_iterator i = creatures.Slots().begin(); i != creatures.Slots().end(); i++) | ||||
| 		{ //build list of joined creatures | ||||
| 			iw.components.push_back(Component(*i->second)); | ||||
| @@ -5344,7 +5344,7 @@ void CGPandoraBox::getText( InfoWindow &iw, bool &afterBattle, int val, int nega | ||||
|  | ||||
| void CGEvent::onHeroVisit( const CGHeroInstance * h ) const | ||||
| { | ||||
| 	if(!(availableFor & (1 << h->tempOwner)))  | ||||
| 	if(!(availableFor & (1 << h->tempOwner))) | ||||
| 		return; | ||||
| 	if(cb->getPlayerSettings(h->tempOwner)->human) | ||||
| 	{ | ||||
| @@ -5608,12 +5608,12 @@ ui8 CGGarrison::getPassableness() const | ||||
| 		return GameConstants::ALL_PLAYERS; | ||||
| 	if ( tempOwner == 255 )//neutral guarded - no one can visit | ||||
| 		return 0; | ||||
| 		 | ||||
|  | ||||
| 	ui8 mask = 0; | ||||
| 	TeamState * ts = cb->gameState()->getPlayerTeam(tempOwner); | ||||
| 	BOOST_FOREACH(ui8 it, ts->players) | ||||
| 		mask |= 1<<it;//allies - add to possible visitors | ||||
| 	 | ||||
|  | ||||
| 	return mask; | ||||
| } | ||||
|  | ||||
| @@ -5625,7 +5625,7 @@ void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 	switch(ID) | ||||
| 	{ | ||||
| 	case 22: //Corpse | ||||
| 		txtid = 37;  | ||||
| 		txtid = 37; | ||||
| 		sound = soundBase::MYSTERY; | ||||
| 		break; | ||||
| 	case 39: //Lean To | ||||
| @@ -5690,7 +5690,7 @@ void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 			cb->giveResource(h->getOwner(), bonusType, bonusVal); | ||||
| 			break; | ||||
| 		} | ||||
| 		if(ID == 105  &&  artOrRes == 1)  | ||||
| 		if(ID == 105  &&  artOrRes == 1) | ||||
| 		{ | ||||
| 			iw.text.localStrings.back().second++; | ||||
| 			iw.text.addReplacement(MetaString::ART_NAMES, bonusType); | ||||
| @@ -5799,11 +5799,11 @@ void CGOnceVisitable::searchTomb(const CGHeroInstance *h, ui32 accept) const | ||||
| 			iw.text.addReplacement(MetaString::ART_NAMES, bonusType); | ||||
|  | ||||
| 			cb->giveHeroNewArtifact(h, VLC->arth->artifacts[bonusType],-2); | ||||
| 		}		 | ||||
| 		 | ||||
| 		} | ||||
|  | ||||
| 		if(!h->hasBonusFrom(Bonus::OBJECT,ID)) //we don't have modifier from this object yet | ||||
| 		{ | ||||
| 			//ruin morale  | ||||
| 			//ruin morale | ||||
| 			GiveBonus gb; | ||||
| 			gb.id = h->id; | ||||
| 			gb.bonus = Bonus(Bonus::ONE_BATTLE,Bonus::MORALE,Bonus::OBJECT,-3,id,""); | ||||
| @@ -5835,7 +5835,7 @@ void CBank::reset(ui16 var1) //prevents desync | ||||
| { | ||||
| 	ui8 chance = 0; | ||||
| 	for (ui8 i = 0; i < VLC->objh->banksInfo[index].size(); i++) | ||||
| 	{	 | ||||
| 	{ | ||||
| 		if (var1 < (chance += VLC->objh->banksInfo[index][i]->chance)) | ||||
| 		{ | ||||
|  			bc = VLC->objh->banksInfo[index][i]; | ||||
| @@ -5851,7 +5851,7 @@ void CBank::initialize() const | ||||
| 	for (ui8 i = 0; i <= 3; i++) | ||||
| 	{ | ||||
| 		for (ui8 n = 0; n < bc->artifacts[i]; n++) //new function using proper randomization algorithm | ||||
| 		{	 | ||||
| 		{ | ||||
| 				cb->setObjProperty (id, 18 + i, ran()); //synchronic artifacts | ||||
| 		} | ||||
| 	} | ||||
| @@ -5960,7 +5960,7 @@ void CBank::setPropertyDer (ui8 what, ui32 val) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CBank::newTurn() const  | ||||
| void CBank::newTurn() const | ||||
| { | ||||
| 	if (bc == NULL) | ||||
| 	{ | ||||
| @@ -6043,7 +6043,7 @@ void CBank::onHeroVisit (const CGHeroInstance * h) const | ||||
| 		cb->showInfoDialog(&iw); | ||||
| 	} | ||||
| } | ||||
| void CBank::fightGuards (const CGHeroInstance * h, ui32 accept) const  | ||||
| void CBank::fightGuards (const CGHeroInstance * h, ui32 accept) const | ||||
| { | ||||
| 	if (accept) | ||||
| 	{ | ||||
| @@ -6105,7 +6105,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons | ||||
| 				if (bc->resources.size()) | ||||
| 					textID = 124; | ||||
| 				else | ||||
| 					textID = 123;	 | ||||
| 					textID = 123; | ||||
| 				break; | ||||
| 		} | ||||
|  | ||||
| @@ -6113,7 +6113,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons | ||||
| 		if (textID != 42) //empty derelict ship gives no cash | ||||
| 		{ | ||||
| 			for (int it = 0; it < bc->resources.size(); it++) | ||||
| 			{	 | ||||
| 			{ | ||||
| 				if (bc->resources[it] != 0) | ||||
| 				{ | ||||
| 					iw.components.push_back (Component (Component::RESOURCE, it, bc->resources[it], 0)); | ||||
| @@ -6121,7 +6121,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons | ||||
| 					loot.addReplacement(iw.components.back().val); | ||||
| 					loot.addReplacement(MetaString::RES_NAMES, iw.components.back().subtype); | ||||
| 					cb->giveResource (h->getOwner(), it, bc->resources[it]); | ||||
| 				}		 | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		//grant artifacts | ||||
| @@ -6212,7 +6212,7 @@ void CGPyramid::onHeroVisit (const CGHeroInstance * h) const | ||||
| 		bd.player = h->getOwner(); | ||||
| 		bd.soundID = soundBase::MYSTERY; | ||||
| 		bd.text << VLC->generaltexth->advobtxt[105]; | ||||
| 		cb->showBlockingDialog (&bd, boost::bind (&CBank::fightGuards, this, h, _1));	 | ||||
| 		cb->showBlockingDialog (&bd, boost::bind (&CBank::fightGuards, this, h, _1)); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| @@ -6236,9 +6236,9 @@ void CGPyramid::endBattle (const CGHeroInstance *h, const BattleResult *result) | ||||
| 		iw.player = h->getOwner(); | ||||
| 		iw.text.addTxt (MetaString::ADVOB_TXT, 106); | ||||
| 		iw.text.addTxt (MetaString::SPELL_NAME, spell); | ||||
| 		if (!h->getArt(17))						 | ||||
| 		if (!h->getArt(17)) | ||||
| 			iw.text.addTxt (MetaString::ADVOB_TXT, 109); //no spellbook | ||||
| 		else if (h->getSecSkillLevel(CGHeroInstance::WISDOM) < 3)	 | ||||
| 		else if (h->getSecSkillLevel(CGHeroInstance::WISDOM) < 3) | ||||
| 			iw.text.addTxt (MetaString::ADVOB_TXT, 108); //no expert Wisdom | ||||
| 		else | ||||
| 		{ | ||||
| @@ -6304,7 +6304,7 @@ void CGKeymasterTent::onHeroVisit( const CGHeroInstance * h ) const | ||||
|  | ||||
| void CGBorderGuard::initObj() | ||||
| { | ||||
| 	ui32 m13489val = subID; //store color as quest info | ||||
| 	//ui32 m13489val = subID; //store color as quest info | ||||
| 	blockVisit = true; | ||||
| } | ||||
|  | ||||
| @@ -6334,7 +6334,7 @@ bool CGBorderGuard::checkQuest (const CGHeroInstance * h) const | ||||
| 	return wasMyColorVisited (h->tempOwner); | ||||
| } | ||||
|  | ||||
| void CGBorderGuard::onHeroVisit( const CGHeroInstance * h ) const  | ||||
| void CGBorderGuard::onHeroVisit( const CGHeroInstance * h ) const | ||||
| { | ||||
| 	if (wasMyColorVisited (h->getOwner()) ) | ||||
| 	{ | ||||
| @@ -6342,8 +6342,8 @@ void CGBorderGuard::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 		bd.player = h->getOwner(); | ||||
| 		bd.soundID = soundBase::QUEST; | ||||
| 		bd.text.addTxt (MetaString::ADVOB_TXT, 17); | ||||
| 		cb->showBlockingDialog (&bd, boost::bind (&CGBorderGuard::openGate, this, h, _1));	 | ||||
| 	}	 | ||||
| 		cb->showBlockingDialog (&bd, boost::bind (&CGBorderGuard::openGate, this, h, _1)); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		InfoWindow iw; | ||||
| @@ -6366,7 +6366,7 @@ void CGBorderGuard::openGate(const CGHeroInstance *h, ui32 accept) const | ||||
| 		cb->removeObject(id); | ||||
| } | ||||
|  | ||||
| void CGBorderGate::onHeroVisit( const CGHeroInstance * h ) const //TODO: passability  | ||||
| void CGBorderGate::onHeroVisit( const CGHeroInstance * h ) const //TODO: passability | ||||
| { | ||||
| 	if (!wasMyColorVisited (h->getOwner()) ) | ||||
| 	{ | ||||
| @@ -6423,9 +6423,9 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const | ||||
| 			cv.pos = eye->pos; | ||||
| 			cv.focusTime = 2000; | ||||
| 			cb->sendAndApply(&cv); | ||||
| 		}	 | ||||
| 		} | ||||
| 		cv.pos = h->getPosition(false); | ||||
| 		cb->sendAndApply(&cv);	 | ||||
| 		cb->sendAndApply(&cv); | ||||
| 	} | ||||
| 	else if (ID == 27) | ||||
| 	{ | ||||
| @@ -6541,7 +6541,7 @@ int IBoatGenerator::getBoatType() const | ||||
| } | ||||
|  | ||||
|  | ||||
| IBoatGenerator::IBoatGenerator(const CGObjectInstance *O)  | ||||
| IBoatGenerator::IBoatGenerator(const CGObjectInstance *O) | ||||
| : o(O) | ||||
| { | ||||
| } | ||||
| @@ -6550,7 +6550,7 @@ void IBoatGenerator::getProblemText(MetaString &out, const CGHeroInstance *visit | ||||
| { | ||||
| 	switch(state()) | ||||
| 	{ | ||||
| 	case 1:  | ||||
| 	case 1: | ||||
| 		out.addTxt(MetaString::GENERAL_TXT, 51); | ||||
| 		break; | ||||
| 	case 2: | ||||
| @@ -6575,7 +6575,7 @@ void IShipyard::getBoatCost( std::vector<si32> &cost ) const | ||||
| 	cost[6] = 1000; | ||||
| } | ||||
|  | ||||
| IShipyard::IShipyard(const CGObjectInstance *O)  | ||||
| IShipyard::IShipyard(const CGObjectInstance *O) | ||||
| 	: IBoatGenerator(O) | ||||
| { | ||||
| } | ||||
| @@ -6643,7 +6643,7 @@ void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CCartographer::onHeroVisit( const CGHeroInstance * h ) const  | ||||
| void CCartographer::onHeroVisit( const CGHeroInstance * h ) const | ||||
| { | ||||
| 	if (!wasVisited (h->getOwner()) ) //if hero has not visited yet this cartographer | ||||
| 	{ | ||||
| @@ -6662,7 +6662,7 @@ void CCartographer::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 				case 2: | ||||
| 					text = 27; | ||||
| 					break; | ||||
| 				default:	 | ||||
| 				default: | ||||
| 					tlog2 << "Unrecognized subtype of cartographer" << std::endl; | ||||
| 			} | ||||
| 			assert(text); | ||||
| @@ -6680,7 +6680,7 @@ void CCartographer::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 			iw.text << std::pair<ui8,ui32>(11,28); | ||||
| 			cb->showInfoDialog (&iw); | ||||
| 		} | ||||
| 	}	 | ||||
| 	} | ||||
| 	else //if he already visited carographer | ||||
| 	{ | ||||
| 		InfoWindow iw; | ||||
| @@ -6720,7 +6720,7 @@ void CGObelisk::onHeroVisit( const CGHeroInstance * h ) const | ||||
| 	TeamState *ts = cb->gameState()->getPlayerTeam(h->tempOwner); | ||||
| 	assert(ts); | ||||
| 	int team = ts->id; | ||||
| 	 | ||||
|  | ||||
| 	if(!wasVisited(team)) | ||||
| 	{ | ||||
| 		iw.text.addTxt(MetaString::ADVOB_TXT, 96); | ||||
| @@ -6892,7 +6892,7 @@ void CArmedInstance::updateMoraleBonusFromArmy() | ||||
| 	 		factions.insert(faction); | ||||
| 	 	} | ||||
| 	} | ||||
| 	  | ||||
|  | ||||
| 	if(factions.size() == 1) | ||||
| 	{ | ||||
| 		b->val = +1; | ||||
| @@ -6904,7 +6904,7 @@ void CArmedInstance::updateMoraleBonusFromArmy() | ||||
| 		b->description = boost::str(boost::format(VLC->generaltexth->arraytxt[114]) % factions.size() % b->val); //Troops of %d alignments %d | ||||
| 	} | ||||
| 	boost::algorithm::trim(b->description); | ||||
| 	  | ||||
|  | ||||
| 	//-1 modifier for any Necropolis unit in army | ||||
| 	const ui8 UNDEAD_MODIFIER_ID = -2; | ||||
| 	Bonus *undeadModifier = getBonusList().getFirst(Selector::source(Bonus::ARMY, UNDEAD_MODIFIER_ID)); | ||||
| @@ -6915,7 +6915,7 @@ void CArmedInstance::updateMoraleBonusFromArmy() | ||||
| 	} | ||||
| 	else if(undeadModifier) | ||||
| 		removeBonus(undeadModifier); | ||||
| 	 | ||||
|  | ||||
| } | ||||
|  | ||||
| void CArmedInstance::armyChanged() | ||||
| @@ -6988,9 +6988,9 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar | ||||
| 			double effectiveness = std::min((getMarketEfficiency() + 3.0) / 20.0, 0.6); | ||||
| 			double r = VLC->objh->resVals[id1], //value of offered resource | ||||
| 				g = VLC->arth->artifacts[id2]->price / effectiveness; //value of bought artifact in gold | ||||
| 			 | ||||
|  | ||||
| 			if(id1 != 6) //non-gold prices are doubled | ||||
| 				r /= 2;  | ||||
| 				r /= 2; | ||||
|  | ||||
| 			val1 = std::max(1, (int)((g / r) + 0.5)); //don't sell arts for less than 1 resource | ||||
| 			val2 = 1; | ||||
| @@ -7000,10 +7000,10 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar | ||||
| 		{ | ||||
| 			double effectiveness = std::min((getMarketEfficiency() + 3.0) / 20.0, 0.6); | ||||
| 			double r = VLC->arth->artifacts[id1]->price * effectiveness, | ||||
| 				g = VLC->objh->resVals[id2];  | ||||
| 				g = VLC->objh->resVals[id2]; | ||||
|  | ||||
| // 			if(id2 != 6) //non-gold prices are doubled | ||||
| // 				r /= 2;  | ||||
| // 				r /= 2; | ||||
|  | ||||
| 			val1 = 1; | ||||
| 			val2 = std::max(1, (int)((r / g) + 0.5)); //at least one resource is given in return | ||||
| @@ -7217,7 +7217,7 @@ void CGUniversity::initObj() | ||||
| 		tlog0<<"Warning: less then 4 available skills was found by University initializer!\n"; | ||||
| 		return; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	for (int i=0; i<4; i++)//get 4 skills | ||||
| 	{ | ||||
| 		int skillPos = ran()%toChoose.size(); | ||||
| @@ -7232,7 +7232,7 @@ std::vector<int> CGUniversity::availableItemsIds(EMarketMode::EMarketMode mode) | ||||
| 	{ | ||||
| 		case EMarketMode::RESOURCE_SKILL: | ||||
| 			return skills; | ||||
| 			 | ||||
|  | ||||
| 		default: | ||||
| 			return std::vector <int> (); | ||||
| 	} | ||||
|   | ||||
| @@ -53,6 +53,7 @@ std::vector<BattleHex> CObstacleInstance::getAffectedTiles() const | ||||
| 		return getInfo().getBlocked(pos); | ||||
| 	default: | ||||
| 		assert(0); | ||||
| 		return std::vector<BattleHex>(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -60,7 +61,7 @@ std::vector<BattleHex> CObstacleInstance::getAffectedTiles() const | ||||
| // { | ||||
| // 	if(obstacleType == USUAL  ||  obstacleType == ABSOLUTE_OBSTACLE) | ||||
| // 		return false; | ||||
| //  | ||||
| // | ||||
| // 	return true; | ||||
| // } | ||||
|  | ||||
| @@ -105,6 +106,7 @@ bool SpellCreatedObstacle::visibleForSide(ui8 side, bool hasNativeStack) const | ||||
| 		return casterSide == side  ||  visibleForAnotherSide  ||  hasNativeStack; | ||||
| 	default: | ||||
| 		assert(0); | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -121,6 +123,7 @@ std::vector<BattleHex> SpellCreatedObstacle::getAffectedTiles() const | ||||
| 		//TODO Fire Wall | ||||
| 	default: | ||||
| 		assert(0); | ||||
| 		return std::vector<BattleHex>(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -135,4 +138,4 @@ std::vector<BattleHex> MoatObstacle::getAffectedTiles() const | ||||
| 	//rrr... need initializer lists | ||||
| 	static const BattleHex moatHexes[] = {11, 28, 44, 61, 77, 111, 129, 146, 164, 181}; | ||||
| 	return std::vector<BattleHex>(moatHexes, moatHexes + ARRAY_COUNT(moatHexes)); | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -12,7 +12,7 @@ struct DLL_LINKAGE CObstacleInstance | ||||
|  | ||||
| 	enum EObstacleType | ||||
| 	{ | ||||
| 		//ABSOLUTE needs an underscore because it's a Win  | ||||
| 		//ABSOLUTE needs an underscore because it's a Win | ||||
| 		USUAL, ABSOLUTE_OBSTACLE, QUICKSAND, LAND_MINE, FORCE_FIELD, FIRE_WALL, MOAT | ||||
| 	}; | ||||
|  | ||||
| @@ -32,7 +32,7 @@ struct DLL_LINKAGE CObstacleInstance | ||||
| 	//additional effects (like hurting stack or disappearing) are hardcoded for appropriate obstacleTypes | ||||
| 	bool blocksTiles() const; | ||||
| 	bool stopsMovement() const; //if unit stepping onto obstacle, can't continue movement (in general, doesn't checks for the side) | ||||
| 	 | ||||
|  | ||||
| 	virtual std::vector<BattleHex> getAffectedTiles() const; | ||||
| 	virtual bool visibleForSide(ui8 side, bool hasNativeStack) const; //0 attacker | ||||
|  | ||||
| @@ -56,12 +56,12 @@ struct DLL_LINKAGE SpellCreatedObstacle : CObstacleInstance | ||||
| 	si8 spellLevel; | ||||
| 	si8 casterSide; //0 - obstacle created by attacker; 1 - by defender | ||||
| 	si8 visibleForAnotherSide; | ||||
| 	 | ||||
|  | ||||
| 	SpellCreatedObstacle(); | ||||
|  | ||||
| 	virtual std::vector<BattleHex> getAffectedTiles() const OVERRIDE; //for special effects (not blocking) | ||||
| 	virtual bool visibleForSide(ui8 side, bool hasNativeStack) const OVERRIDE; //0 attacker | ||||
| 	 | ||||
|  | ||||
| 	virtual void battleTurnPassed() OVERRIDE; | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
|   | ||||
| @@ -1,8 +1,7 @@ | ||||
| #include "StdInc.h" | ||||
| #include "JsonNode.h" | ||||
|  | ||||
|  | ||||
| class Bonus; | ||||
| #include "HeroBonus.h" | ||||
|  | ||||
| const JsonNode JsonNode::nullNode; | ||||
|  | ||||
| @@ -243,7 +242,7 @@ void JsonWriter::writeContainer(Iterator begin, Iterator end) | ||||
| { | ||||
| 	if (begin == end) | ||||
| 		return; | ||||
| 	 | ||||
|  | ||||
| 	prefix += '\t'; | ||||
| 	end--; | ||||
| 	while (begin != end) | ||||
| @@ -251,7 +250,7 @@ void JsonWriter::writeContainer(Iterator begin, Iterator end) | ||||
| 		writeEntry(begin++); | ||||
| 		out<<",\n"; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	writeEntry(begin); | ||||
| 	out<<"\n"; | ||||
| 	prefix.resize(prefix.size()-1); | ||||
| @@ -280,7 +279,7 @@ void JsonWriter::writeString(const std::string &string) | ||||
| 	for (; pos<string.size(); pos++) | ||||
| 	{ | ||||
| 		size_t escapedChar = escaped.find(string[pos]); | ||||
| 		 | ||||
|  | ||||
| 		if (escapedChar != std::string::npos) | ||||
| 		{ | ||||
| 			out.write(string.data()+start, pos - start); | ||||
| @@ -872,4 +871,23 @@ JsonValidator::JsonValidator(JsonNode &root, const JsonNode &schema, bool Minimi | ||||
| 	if (schema.isNull()) | ||||
| 		addMessage("Schema not found!"); | ||||
| 	tlog3<<errors; | ||||
| } | ||||
| } | ||||
|  | ||||
| Bonus * ParseBonus (const JsonVector &ability_vec) //TODO: merge with AddAbility, create universal parser for all bonus properties | ||||
| { | ||||
| 	Bonus * b = new Bonus(); | ||||
| 	std::string type = ability_vec[0].String(); | ||||
| 	auto it = bonusNameMap.find(type); | ||||
| 	if (it == bonusNameMap.end()) | ||||
| 	{ | ||||
| 		tlog1 << "Error: invalid ability type " << type << " in creatures.txt" << std::endl; | ||||
| 		return b; | ||||
| 	} | ||||
| 	b->type = it->second; | ||||
| 	b->val = ability_vec[1].Float(); | ||||
| 	b->subtype = ability_vec[2].Float(); | ||||
| 	b->additionalInfo = ability_vec[3].Float(); | ||||
| 	b->duration = Bonus::PERMANENT; | ||||
| 	b->turnsRemain = 0; | ||||
| 	return b; | ||||
| } | ||||
|   | ||||
| @@ -1,12 +1,10 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "HeroBonus.h" | ||||
|  | ||||
| class JsonNode; | ||||
| typedef std::map <std::string, JsonNode> JsonMap; | ||||
| typedef std::vector <JsonNode> JsonVector; | ||||
|  | ||||
| class Bonus; | ||||
| struct Bonus; | ||||
|  | ||||
| class DLL_LINKAGE JsonNode | ||||
| { | ||||
| @@ -199,23 +197,4 @@ public: | ||||
| 	JsonValidator(JsonNode &root, const JsonNode &schema, bool minimize=false); | ||||
| }; | ||||
|  | ||||
| //Bonus * ParseBonus (const JsonVector &ability_vec); | ||||
|  | ||||
| static Bonus * ParseBonus (const JsonVector &ability_vec) //TODO: merge with AddAbility, create universal parser for all bonus properties | ||||
| { | ||||
| 	Bonus * b = new Bonus(); | ||||
| 	std::string type = ability_vec[0].String(); | ||||
| 	auto it = bonusNameMap.find(type); | ||||
| 	if (it == bonusNameMap.end()) | ||||
| 	{ | ||||
| 		tlog1 << "Error: invalid ability type " << type << " in creatures.txt" << std::endl; | ||||
| 		return b; | ||||
| 	} | ||||
| 	b->type = it->second; | ||||
| 	b->val = ability_vec[1].Float(); | ||||
| 	b->subtype = ability_vec[2].Float(); | ||||
| 	b->additionalInfo = ability_vec[3].Float(); | ||||
| 	b->duration = Bonus::PERMANENT; | ||||
| 	b->turnsRemain = 0; | ||||
| 	return b; | ||||
| } | ||||
| DLL_LINKAGE Bonus * ParseBonus (const JsonVector &ability_vec); | ||||
|   | ||||
| @@ -16,4 +16,4 @@ ELSEIF(WIN32) | ||||
|     add_executable(vcmiserver WIN32 ${server_SRCS}) | ||||
| ENDIF() | ||||
|  | ||||
| target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES}) | ||||
| target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES} ${RT_LIB} ${DL_LIB}) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user