mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	refactor map loading, few small tweaks
This commit is contained in:
		| @@ -31,7 +31,6 @@ | ||||
| #include "CBuildingHandler.h" | ||||
| #include "JsonNode.h" | ||||
| #include "Filesystem/CResourceLoader.h" | ||||
| #include "GameConstants.h" | ||||
|  | ||||
| using namespace boost::assign; | ||||
|  | ||||
|   | ||||
| @@ -478,7 +478,6 @@ public: | ||||
| 	void initObj() override; | ||||
| 	void onHeroVisit(const CGHeroInstance * h) const override; | ||||
| 	void newTurn() const override; | ||||
| protected: | ||||
| 	void setProperty(ui8 what, ui32 val) override; | ||||
| private: | ||||
| 	void heroAcceptsCreatures(const CGHeroInstance *h, ui32 answer) const; | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
| #include "VCMI_Lib.h" | ||||
| #include "JsonNode.h" | ||||
| #include <cctype> | ||||
| #include "GameConstants.h" | ||||
| #include "BattleHex.h" | ||||
| #include "CModHandler.h" | ||||
|  | ||||
| @@ -251,40 +250,6 @@ CSpell::ETargetType CSpell::getTargetType() const //TODO: parse these at game la | ||||
| 	return NO_TARGET; | ||||
| } | ||||
|  | ||||
| bool CSpell::isPositive() const | ||||
| { | ||||
| 	return positiveness == POSITIVE; | ||||
| } | ||||
|  | ||||
| bool CSpell::isNegative() const | ||||
| { | ||||
| 	return positiveness == NEGATIVE; | ||||
| } | ||||
|  | ||||
| bool CSpell::isRisingSpell() const | ||||
| { | ||||
| 	return isRising; | ||||
| } | ||||
|  | ||||
| bool CSpell::isDamageSpell() const | ||||
| { | ||||
| 	return isDamage; | ||||
| } | ||||
|  | ||||
| bool CSpell::isMindSpell() const | ||||
| { | ||||
| 	return isMind; | ||||
| } | ||||
|  | ||||
| bool CSpell::isOffensiveSpell() const | ||||
| { | ||||
| 	return isOffensive; | ||||
| } | ||||
|  | ||||
| bool CSpell::hasEffects() const | ||||
| { | ||||
| 	return !effects[0].empty(); | ||||
| } | ||||
|  | ||||
|  | ||||
| void CSpell::getEffects(std::vector<Bonus>& lst, const int level) const | ||||
|   | ||||
| @@ -51,15 +51,19 @@ public: | ||||
| 	si16 mainEffectAnim; //main spell effect animation, in AC format (or -1 when none) | ||||
| 	ETargetType getTargetType() const; | ||||
|  | ||||
| 	bool isPositive() const; | ||||
| 	bool isNegative() const; | ||||
| 	inline bool isCombatSpell() const; | ||||
| 	inline bool isAdventureSpell() const; | ||||
| 	inline bool isCreatureAbility() const; | ||||
|  | ||||
| 	bool isRisingSpell() const; | ||||
| 	bool isDamageSpell() const; | ||||
| 	bool isMindSpell() const;	 | ||||
| 	bool isOffensiveSpell() const; | ||||
| 	 | ||||
| 	bool hasEffects() const; | ||||
| 	inline bool isPositive() const; | ||||
| 	inline bool isNegative() const; | ||||
|  | ||||
| 	inline bool isRisingSpell() const; | ||||
| 	inline bool isDamageSpell() const; | ||||
| 	inline bool isMindSpell() const; //TODO: deprecated - remove, refactor | ||||
| 	inline bool isOffensiveSpell() const; | ||||
|  | ||||
| 	inline bool hasEffects() const; | ||||
| 	void getEffects(std::vector<Bonus> &lst, const int level) const; | ||||
|  | ||||
| 	bool isImmuneBy(const IBonusBearer *obj) const; | ||||
| @@ -82,10 +86,63 @@ private: | ||||
| 	std::vector<Bonus> effects [4]; | ||||
| 	std::vector<Bonus::BonusType> immunities; //any of these hrants immunity | ||||
| 	std::vector<Bonus::BonusType> limiters; //all of them are required | ||||
| 	 | ||||
|  | ||||
|  | ||||
| }; | ||||
|  | ||||
| ///CSpell inlines | ||||
|  | ||||
| bool CSpell::isCombatSpell() const | ||||
| { | ||||
| 	return combatSpell; | ||||
| } | ||||
|  | ||||
| bool CSpell::isAdventureSpell() const | ||||
| { | ||||
| 	return !combatSpell; | ||||
| } | ||||
|  | ||||
| bool CSpell::isCreatureAbility() const | ||||
| { | ||||
| 	return creatureAbility; | ||||
| } | ||||
|  | ||||
| bool CSpell::isPositive() const | ||||
| { | ||||
| 	return positiveness == POSITIVE; | ||||
| } | ||||
|  | ||||
| bool CSpell::isNegative() const | ||||
| { | ||||
| 	return positiveness == NEGATIVE; | ||||
| } | ||||
|  | ||||
| bool CSpell::isRisingSpell() const | ||||
| { | ||||
| 	return isRising; | ||||
| } | ||||
|  | ||||
| bool CSpell::isDamageSpell() const | ||||
| { | ||||
| 	return isDamage; | ||||
| } | ||||
|  | ||||
| bool CSpell::isMindSpell() const | ||||
| { | ||||
| 	return isMind; | ||||
| } | ||||
|  | ||||
| bool CSpell::isOffensiveSpell() const | ||||
| { | ||||
| 	return isOffensive; | ||||
| } | ||||
|  | ||||
| bool CSpell::hasEffects() const | ||||
| { | ||||
| 	return !effects[0].empty(); | ||||
| } | ||||
|  | ||||
|  | ||||
| namespace Spells | ||||
| { | ||||
| 	enum | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -24,6 +24,10 @@ class CCreatureSet; | ||||
| class CInputStream; | ||||
| class IMapLoader; | ||||
|  | ||||
| #include "../vcmi_endian.h" | ||||
| #include "../int3.h" | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * The map service provides loading of VCMI/H3 map files. It can | ||||
|  * be extended to save maps later as well. | ||||
| @@ -312,6 +316,77 @@ private: | ||||
| 	 */ | ||||
| 	ui8 reverse(ui8 arg); | ||||
|  | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	* Helper to read ui8 from buffer | ||||
| 	*/ | ||||
| 	inline ui8 readUI8() | ||||
| 	{ | ||||
| 	   return buffer[pos++]; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	* Helper to read si8 from buffer | ||||
| 	*/ | ||||
| 	inline si8 readSI8() | ||||
| 	{ | ||||
| 	   return static_cast<si8>(buffer[pos++]); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	* Helper to read ui16 from buffer | ||||
| 	*/ | ||||
| 	inline ui16 readUI16() | ||||
| 	{ | ||||
| 		ui16 ret = read_le_u16(buffer+pos); | ||||
| 		pos +=2; | ||||
| 		return ret; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	* Helper to read ui32 from buffer | ||||
| 	*/ | ||||
| 	inline ui32 readUI32() | ||||
| 	{ | ||||
| 		ui32 ret = read_le_u32(buffer+pos); | ||||
| 		pos +=4; | ||||
| 		return ret; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	* Helper to read 8bit flag from buffer | ||||
| 	*/ | ||||
| 	inline bool readBool() | ||||
| 	{ | ||||
| 		return readUI8() != 0; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	* Helper to read string from buffer | ||||
| 	*/ | ||||
| 	inline std::string readString() | ||||
| 	{ | ||||
| 		return ::readString(buffer,pos); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	* Helper to skip unused data inbuffer | ||||
| 	*/ | ||||
| 	inline void skip(const int count) | ||||
| 	{ | ||||
| 		pos += count; | ||||
| 	} | ||||
|  | ||||
| 	inline int3 readInt3() | ||||
| 	{ | ||||
| 		int3 p; | ||||
| 		p.x = readUI8(); | ||||
| 		p.y = readUI8(); | ||||
| 		p.z = readUI8(); | ||||
| 		return p; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Init buffer / size. | ||||
| 	 * | ||||
|   | ||||
		Reference in New Issue
	
	Block a user