mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Replaced a few iterators with BOOST_FOREACH.
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| #include <boost/bind.hpp> | ||||
| #include <boost/algorithm/string/trim.hpp> | ||||
| #include <boost/foreach.hpp> | ||||
|  | ||||
| #include <SDL_image.h> | ||||
|  | ||||
| @@ -947,17 +948,11 @@ void CAnimation::init(CDefFile * file) | ||||
|  | ||||
| 		if (!config["sequences"].isNull()) | ||||
| 		{ | ||||
| 			const JsonVector &groups = config["sequences"].Vector(); | ||||
| 			for (JsonVector::const_iterator groupsIter = groups.begin(); groupsIter!=groups.end(); ++groupsIter) | ||||
| 			{ | ||||
| 				JsonNode group = *groupsIter; | ||||
| 			BOOST_FOREACH(const JsonNode &group, config["sequences"].Vector()) { | ||||
| 				size_t groupID = group["group"].Float();//TODO: string-to-value conversion | ||||
| 				source[groupID].clear(); | ||||
|  | ||||
| 				const JsonVector &frames = group["frames"].Vector(); | ||||
| 				for (JsonVector::const_iterator framesIter = frames.begin(); framesIter!=frames.end(); ++framesIter) | ||||
| 				{ | ||||
| 					const JsonNode &frame = *framesIter; | ||||
| 				BOOST_FOREACH(const JsonNode &frame, group["frames"].Vector()) { | ||||
| 					source[groupID].push_back(frame); | ||||
| 					std::string filename =  frame["file"].String(); | ||||
| 					source[groupID].back()["file"].String() = basepath + filename; | ||||
| @@ -967,12 +962,7 @@ void CAnimation::init(CDefFile * file) | ||||
|  | ||||
| 		if (!config["images"].isNull()) | ||||
| 		{ | ||||
| 			const JsonVector &vector = config["images"].Vector(); | ||||
| 			 | ||||
| 			for (JsonVector::const_iterator it = vector.begin(); it!=vector.end(); ++it) | ||||
| 			{ | ||||
| 				const JsonNode &node = *it; | ||||
|  | ||||
| 			BOOST_FOREACH(const JsonNode &node, config["images"].Vector()) { | ||||
| 				size_t group=0; | ||||
| 				if (!node["group"].isNull()) | ||||
| 					group = node["group"].Float(); | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
| #include <boost/assign/std/vector.hpp>  | ||||
| #include <boost/assign/list_of.hpp> | ||||
| #include <boost/bimap.hpp> | ||||
| #include <boost/foreach.hpp> | ||||
|  | ||||
| #include <SDL_mixer.h> | ||||
|  | ||||
| @@ -171,15 +172,13 @@ soundBase::soundID CSoundHandler::getSoundID(const std::string &fileName) | ||||
| void CSoundHandler::initCreaturesSounds(const std::vector<ConstTransitivePtr< CCreature> > &creatures) | ||||
| { | ||||
| 	tlog5 << "\t\tReading config/cr_sounds.json" << std::endl; | ||||
| 	class JsonNode config(DATA_DIR "/config/cr_sounds.json"); | ||||
| 	const JsonNode config(DATA_DIR "/config/cr_sounds.json"); | ||||
|  | ||||
| 	CBattleSounds.resize(creatures.size()); | ||||
|  | ||||
| 	if (!config["creature_sounds"].isNull()) { | ||||
| 		const JsonVector &vector = config["creature_sounds"].Vector(); | ||||
| 	 | ||||
| 		for (JsonVector::const_iterator it = vector.begin(); it!=vector.end(); ++it) { | ||||
| 			const JsonNode &node = *it; | ||||
| 		 | ||||
| 		BOOST_FOREACH(const JsonNode &node, config["creature_sounds"].Vector()) { | ||||
| 			const JsonNode *value; | ||||
| 			int id; | ||||
|  | ||||
| @@ -231,13 +230,10 @@ void CSoundHandler::initCreaturesSounds(const std::vector<ConstTransitivePtr< CC | ||||
|  | ||||
| void CSoundHandler::initSpellsSounds(const std::vector< ConstTransitivePtr<CSpell> > &spells) | ||||
| { | ||||
| 	class JsonNode config(DATA_DIR "/config/sp_sounds.json"); | ||||
| 	const JsonNode config(DATA_DIR "/config/sp_sounds.json"); | ||||
|  | ||||
| 	if (!config["spell_sounds"].isNull()) { | ||||
| 		const JsonVector &vector = config["spell_sounds"].Vector(); | ||||
| 	 | ||||
| 		for (JsonVector::const_iterator it = vector.begin(); it!=vector.end(); ++it) { | ||||
| 			const JsonNode &node = *it; | ||||
| 		BOOST_FOREACH(const JsonNode &node, config["spell_sounds"].Vector()) { | ||||
| 			int spellid = node["id"].Float(); | ||||
| 			const CSpell *s = CGI->spellh->spells[spellid]; | ||||
|  | ||||
|   | ||||
| @@ -343,10 +343,8 @@ Graphics::Graphics() | ||||
| void Graphics::loadHeroPortraits() | ||||
| {	 | ||||
| 	const JsonNode config(DATA_DIR "/config/portraits.json"); | ||||
| 	const JsonVector &portraits_vec = config["hero_portrait"].Vector(); | ||||
|  | ||||
| 	for (JsonVector::const_iterator it = portraits_vec.begin(); it!=portraits_vec.end(); ++it) { | ||||
| 		const JsonNode &portrait_node = *it; | ||||
| 	BOOST_FOREACH(const JsonNode &portrait_node, config["hero_portrait"].Vector()) { | ||||
| 		std::string filename = portrait_node["filename"].String(); | ||||
|  | ||||
| 		/* Small portrait. */ | ||||
|   | ||||
| @@ -432,11 +432,8 @@ void CCreatureHandler::loadCreatures() | ||||
| 		const JsonNode *value; | ||||
|  | ||||
| 		/* A creature can have several names. */ | ||||
| 		const JsonVector &names_vec = creature["name"].Vector(); | ||||
| 		for (JsonVector::const_iterator it = names_vec.begin(); it!=names_vec.end(); ++it) { | ||||
| 			const std::string name = (*it).String(); | ||||
|  | ||||
| 			boost::assign::insert(nameToID)(name, creatureID); | ||||
| 		BOOST_FOREACH(const JsonNode &name, creature["name"].Vector()) { | ||||
| 			boost::assign::insert(nameToID)(name.String(), creatureID); | ||||
| 		} | ||||
|  | ||||
| 		// Set various creature properties | ||||
| @@ -485,10 +482,8 @@ void CCreatureHandler::loadCreatures() | ||||
|  | ||||
| 	//reading creature ability names | ||||
| 	const JsonNode config2(DATA_DIR "/config/bonusnames.json"); | ||||
| 	const JsonVector &bonuses_vec = config2["bonuses"].Vector(); | ||||
|  | ||||
| 	for (JsonVector::const_iterator it = bonuses_vec.begin(); it!=bonuses_vec.end(); ++it) { | ||||
| 		const JsonNode &bonus = *it; | ||||
| 	BOOST_FOREACH(const JsonNode &bonus, config2["bonuses"].Vector()) { | ||||
| 		std::map<std::string,int>::const_iterator it_map; | ||||
| 		std::string bonusID = bonus["id"].String(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user