mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	* JsonReader can convert to enums
* refactoring
This commit is contained in:
		| @@ -13,6 +13,8 @@ | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| using namespace Battle; | ||||
|  | ||||
| BattleAction::BattleAction() | ||||
| { | ||||
| 	side = -1; | ||||
|   | ||||
| @@ -20,12 +20,7 @@ struct DLL_LINKAGE BattleAction | ||||
| { | ||||
| 	ui8 side; //who made this action: false - left, true - right player | ||||
| 	ui32 stackNumber;//stack ID, -1 left hero, -2 right hero, | ||||
| 	enum ActionType | ||||
| 	{ | ||||
| 		END_TACTIC_PHASE = -2, INVALID = -1, NO_ACTION = 0, HERO_SPELL, WALK, DEFEND, RETREAT, SURRENDER, WALK_AND_ATTACK, SHOOT, WAIT, CATAPULT, MONSTER_SPELL, BAD_MORALE, | ||||
| 		STACK_HEAL, DAEMON_SUMMONING | ||||
| 	}; | ||||
| 	si8 actionType; //use ActionType enum for values | ||||
| 	Battle::ActionType actionType; //use ActionType enum for values | ||||
| 	BattleHex destinationTile; | ||||
| 	si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6 | ||||
| 	si32 selectedStack; //spell subject for teleport / sacrifice | ||||
|   | ||||
| @@ -343,7 +343,7 @@ struct RangeGenerator | ||||
| 	boost::function<int()> myRand; | ||||
| }; | ||||
|  | ||||
| BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int battlefieldType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town ) | ||||
| BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType::ETerrainType terrain, BFieldType::BFieldType battlefieldType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town ) | ||||
| { | ||||
| 	CMP_stack cmpst; | ||||
| 	BattleInfo *curB = new BattleInfo; | ||||
| @@ -599,23 +599,23 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int battlefieldTyp | ||||
| 	int bonusSubtype = -1; | ||||
| 	switch(battlefieldType) | ||||
| 	{ | ||||
| 	case 9: //magic plains | ||||
| 	case BFieldType::MAGIC_PLAINS: | ||||
| 		{ | ||||
| 			bonusSubtype = 0; | ||||
| 		} | ||||
| 	case 14: //fiery fields | ||||
| 	case BFieldType::FIERY_FIELDS: | ||||
| 		{ | ||||
| 			if(bonusSubtype == -1) bonusSubtype = 1; | ||||
| 		} | ||||
| 	case 15: //rock lands | ||||
| 	case BFieldType::ROCKLANDS: | ||||
| 		{ | ||||
| 			if(bonusSubtype == -1) bonusSubtype = 8; | ||||
| 		} | ||||
| 	case 16: //magic clouds | ||||
| 	case BFieldType::MAGIC_CLOUDS: | ||||
| 		{ | ||||
| 			if(bonusSubtype == -1) bonusSubtype = 2; | ||||
| 		} | ||||
| 	case 17: //lucid pools | ||||
| 	case BFieldType::LUCID_POOLS: | ||||
| 		{ | ||||
| 			if(bonusSubtype == -1) bonusSubtype = 4; | ||||
| 		} | ||||
| @@ -625,24 +625,24 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int battlefieldTyp | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 	case 18: //holy ground | ||||
| 	case BFieldType::HOLY_GROUND: | ||||
| 		{ | ||||
| 			curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::GOOD))); | ||||
| 			curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::EVIL))); | ||||
| 			break; | ||||
| 		} | ||||
| 	case 19: //clover field | ||||
| 	case BFieldType::CLOVER_FIELD: | ||||
| 		{ //+2 luck bonus for neutral creatures | ||||
| 			curB->addNewBonus(makeFeature(Bonus::LUCK, Bonus::ONE_BATTLE, 0, +2, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureFactionLimiter>(-1))); | ||||
| 			break; | ||||
| 		} | ||||
| 	case 20: //evil fog | ||||
| 	case BFieldType::EVIL_FOG: | ||||
| 		{ | ||||
| 			curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::GOOD))); | ||||
| 			curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::EVIL))); | ||||
| 			break; | ||||
| 		} | ||||
| 	case 22: //cursed ground | ||||
| 	case BFieldType::CURSED_GROUND: | ||||
| 		{ | ||||
| 			curB->addNewBonus(makeFeature(Bonus::NO_MORALE, Bonus::ONE_BATTLE, 0, 0, Bonus::TERRAIN_OVERLAY)); | ||||
| 			curB->addNewBonus(makeFeature(Bonus::NO_LUCK, Bonus::ONE_BATTLE, 0, 0, Bonus::TERRAIN_OVERLAY)); | ||||
| @@ -705,7 +705,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int battlefieldTyp | ||||
| 	return curB; | ||||
| } | ||||
|  | ||||
| const CGHeroInstance * BattleInfo::getHero( int player ) const | ||||
| const CGHeroInstance * BattleInfo::getHero( TPlayerColor player ) const | ||||
| { | ||||
| 	assert(sides[0] == player || sides[1] == player); | ||||
| 	if(heroes[0] && heroes[0]->getOwner() == player) | ||||
| @@ -763,12 +763,12 @@ std::vector<ui32> BattleInfo::calculateResistedStacks(const CSpell * sp, const C | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| int BattleInfo::theOtherPlayer(int player) const | ||||
| TPlayerColor BattleInfo::theOtherPlayer(TPlayerColor player) const | ||||
| { | ||||
| 	return sides[!whatSide(player)]; | ||||
| } | ||||
|  | ||||
| ui8 BattleInfo::whatSide(int player) const | ||||
| ui8 BattleInfo::whatSide(TPlayerColor player) const | ||||
| { | ||||
| 	for(int i = 0; i < ARRAY_COUNT(sides); i++) | ||||
| 		if(sides[i] == player) | ||||
| @@ -801,13 +801,20 @@ shared_ptr<CObstacleInstance> BattleInfo::getObstacleOnTile(BattleHex tile) cons | ||||
| 	return shared_ptr<CObstacleInstance>(); | ||||
| } | ||||
|  | ||||
| int BattleInfo::battlefieldTypeToBI(int bfieldType) | ||||
| BattlefieldBI::BattlefieldBI BattleInfo::battlefieldTypeToBI(BFieldType::BFieldType bfieldType) | ||||
| { | ||||
| 	static const std::map<int, int> theMap = boost::assign::map_list_of(19, BattlefieldBI::CLOVER_FIELD) | ||||
| 		(22, BattlefieldBI::CURSED_GROUND)(20, BattlefieldBI::EVIL_FOG)(21, BattlefieldBI::NONE) | ||||
| 		(14, BattlefieldBI::FIERY_FIELDS)(18, BattlefieldBI::HOLY_GROUND)(17, BattlefieldBI::LUCID_POOLS) | ||||
| 		(16, BattlefieldBI::MAGIC_CLOUDS)(9, BattlefieldBI::MAGIC_PLAINS)(15, BattlefieldBI::ROCKLANDS) | ||||
| 		(1, BattlefieldBI::COASTAL); | ||||
| 	static const std::map<BFieldType::BFieldType, BattlefieldBI::BattlefieldBI> theMap = boost::assign::map_list_of | ||||
| 		(BFieldType::CLOVER_FIELD, BattlefieldBI::CLOVER_FIELD) | ||||
| 		(BFieldType::CURSED_GROUND, BattlefieldBI::CURSED_GROUND) | ||||
| 		(BFieldType::EVIL_FOG, BattlefieldBI::EVIL_FOG) | ||||
| 		(BFieldType::FAVOURABLE_WINDS, BattlefieldBI::NONE) | ||||
| 		(BFieldType::FIERY_FIELDS, BattlefieldBI::FIERY_FIELDS) | ||||
| 		(BFieldType::HOLY_GROUND, BattlefieldBI::HOLY_GROUND) | ||||
| 		(BFieldType::LUCID_POOLS, BattlefieldBI::LUCID_POOLS) | ||||
| 		(BFieldType::MAGIC_CLOUDS, BattlefieldBI::MAGIC_CLOUDS) | ||||
| 		(BFieldType::MAGIC_PLAINS, BattlefieldBI::MAGIC_PLAINS) | ||||
| 		(BFieldType::ROCKLANDS, BattlefieldBI::ROCKLANDS) | ||||
| 		(BFieldType::SAND_SHORE, BattlefieldBI::COASTAL); | ||||
|  | ||||
| 	auto itr = theMap.find(bfieldType); | ||||
| 	if(itr != theMap.end()) | ||||
|   | ||||
| @@ -45,7 +45,7 @@ struct DLL_LINKAGE SiegeInfo | ||||
|  | ||||
| struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallback | ||||
| { | ||||
| 	ui8 sides[2]; //sides[0] - attacker, sides[1] - defender | ||||
| 	TPlayerColor sides[2]; //sides[0] - attacker, sides[1] - defender | ||||
| 	si32 round, activeStack, selectedStack; | ||||
| 	CGTownInstance::EFortLevel siege; | ||||
| 	const CGTownInstance * town; //used during town siege - id of attacked town; -1 if not town defence | ||||
| @@ -59,8 +59,8 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb | ||||
| 	si16 enchanterCounter[2]; //tends to pass through 0, so sign is needed | ||||
| 	SiegeInfo si; | ||||
|  | ||||
| 	si32 battlefieldType; //like !!BA:B | ||||
| 	int terrainType; //used for some stack nativity checks (not the bonus limiters though that have their own copy) | ||||
| 	BFieldType::BFieldType battlefieldType; //like !!BA:B | ||||
| 	ETerrainType::ETerrainType terrainType; //used for some stack nativity checks (not the bonus limiters though that have their own copy) | ||||
|  | ||||
| 	ui8 tacticsSide; //which side is requested to play tactics phase | ||||
| 	ui8 tacticDistance; //how many hexes we can go forward (1 = only hexes adjacent to margin line) | ||||
| @@ -115,7 +115,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb | ||||
| 	ui32 calculateHealedHP(const CSpell * spell, int usedSpellPower, int spellSchoolLevel, const CStack * stack) const; //unused | ||||
| 	bool resurrects(TSpell spellid) const; //TODO: move it to spellHandler? | ||||
|  | ||||
| 	const CGHeroInstance * getHero(int player) const; //returns fighting hero that belongs to given player | ||||
| 	const CGHeroInstance * getHero(TPlayerColor player) const; //returns fighting hero that belongs to given player | ||||
|  | ||||
|  | ||||
| 	std::vector<ui32> calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set<const CStack*> affectedCreatures, int casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const; | ||||
| @@ -125,13 +125,13 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb | ||||
| 	void localInit(); | ||||
|  | ||||
| 	void localInitStack(CStack * s); | ||||
| 	static BattleInfo * setupBattle( int3 tile, int terrain, int battlefieldType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town ); | ||||
| 	static BattleInfo * setupBattle( int3 tile, ETerrainType::ETerrainType terrain, BFieldType::BFieldType battlefieldType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town ); | ||||
| 	//bool hasNativeStack(ui8 side) const; | ||||
|  | ||||
| 	int theOtherPlayer(int player) const; | ||||
| 	ui8 whatSide(int player) const; | ||||
| 	TPlayerColor theOtherPlayer(TPlayerColor player) const; | ||||
| 	ui8 whatSide(TPlayerColor player) const; | ||||
|  | ||||
| 	static int battlefieldTypeToBI(int bfieldType); //converts above to ERM BI format | ||||
| 	static BattlefieldBI::BattlefieldBI battlefieldTypeToBI(BFieldType::BFieldType bfieldType); //converts above to ERM BI format | ||||
| 	static int battlefieldTypeToTerrain(int bfieldType); //converts above to ERM BI format | ||||
| }; | ||||
|  | ||||
| @@ -143,8 +143,9 @@ public: | ||||
| 	ui32 ID; //unique ID of stack | ||||
| 	ui32 baseAmount; | ||||
| 	ui32 firstHPleft; //HP of first creature in stack | ||||
| 	ui8 owner, slot;  //owner - player colour (255 for neutrals), slot - position in garrison (may be 255 for neutrals/called creatures) | ||||
| 	ui8 attackerOwned; //if true, this stack is owned by attakcer (this one from left hand side of battle) | ||||
| 	TPlayerColor owner; | ||||
| 	ui8 slot;  //owner - player colour (255 for neutrals), slot - position in garrison (may be 255 for neutrals/called creatures) | ||||
| 	bool attackerOwned; //if true, this stack is owned by attakcer (this one from left hand side of battle) | ||||
| 	BattleHex position; //position on battlefield; -2 - keep, -3 - lower tower, -4 - upper tower | ||||
| 	ui8 counterAttacks; //how many counter attacks can be performed more in this turn (by default set at the beginning of the round to 1) | ||||
| 	si16 shots; //how many shots left | ||||
|   | ||||
| @@ -124,15 +124,15 @@ int CCallbackBase::getPlayerID() const | ||||
| 	return player; | ||||
| } | ||||
|  | ||||
| ui8 CBattleInfoEssentials::battleTerrainType() const | ||||
| ETerrainType::ETerrainType CBattleInfoEssentials::battleTerrainType() const | ||||
| { | ||||
| 	RETURN_IF_NOT_BATTLE(-1); | ||||
| 	RETURN_IF_NOT_BATTLE(ETerrainType::WRONG); | ||||
| 	return getBattle()->terrainType; | ||||
| } | ||||
|  | ||||
| int CBattleInfoEssentials::battleGetBattlefieldType() const | ||||
| BFieldType::BFieldType CBattleInfoEssentials::battleGetBattlefieldType() const | ||||
| { | ||||
| 	RETURN_IF_NOT_BATTLE(-1); | ||||
| 	RETURN_IF_NOT_BATTLE(BFieldType::NONE); | ||||
| 	return getBattle()->battlefieldType; | ||||
| } | ||||
|  | ||||
| @@ -347,7 +347,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(int | ||||
| 	return ESpellCastProblem::OK; | ||||
| } | ||||
|  | ||||
| bool CBattleInfoEssentials::battleCanFlee(int player) const | ||||
| bool CBattleInfoEssentials::battleCanFlee(TPlayerColor player) const | ||||
| { | ||||
| 	RETURN_IF_NOT_BATTLE(false); | ||||
| 	ui8 mySide = playerToSide(player); | ||||
| @@ -372,7 +372,7 @@ bool CBattleInfoEssentials::battleCanFlee(int player) const | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| ui8 CBattleInfoEssentials::playerToSide(int player) const | ||||
| ui8 CBattleInfoEssentials::playerToSide(TPlayerColor player) const | ||||
| { | ||||
| 	RETURN_IF_NOT_BATTLE(-1); | ||||
| 	int ret = vstd::find_pos(getBattle()->sides, player); | ||||
| @@ -388,7 +388,7 @@ ui8 CBattleInfoEssentials::battleGetSiegeLevel() const | ||||
| 	return getBattle()->siege; | ||||
| } | ||||
|  | ||||
| bool CBattleInfoEssentials::battleCanSurrender(int player) const | ||||
| bool CBattleInfoEssentials::battleCanSurrender(TPlayerColor player) const | ||||
| { | ||||
| 	RETURN_IF_NOT_BATTLE(false); | ||||
| 	//conditions like for fleeing + enemy must have a hero | ||||
| @@ -2148,7 +2148,7 @@ TSpell CBattleInfoCallback::getRandomCastedSpell(const CStack * caster) const | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| int CBattleInfoCallback::battleGetSurrenderCost(int Player) const | ||||
| int CBattleInfoCallback::battleGetSurrenderCost(TPlayerColor Player) const | ||||
| { | ||||
| 	RETURN_IF_NOT_BATTLE(-3); | ||||
| 	if(!battleCanSurrender(Player)) | ||||
|   | ||||
| @@ -164,8 +164,8 @@ public: | ||||
|  | ||||
| 	BattlePerspective::BattlePerspective battleGetMySide() const; | ||||
|  | ||||
| 	ui8 battleTerrainType() const; | ||||
| 	int battleGetBattlefieldType() const; //   1. sand/shore   2. sand/mesas   3. dirt/birches   4. dirt/hills   5. dirt/pines   6. grass/hills   7. grass/pines   8. lava   9. magic plains   10. snow/mountains   11. snow/trees   12. subterranean   13. swamp/trees   14. fiery fields   15. rock lands   16. magic clouds   17. lucid pools   18. holy ground   19. clover field   20. evil fog   21. "favourable winds" text on magic plains background   22. cursed ground   23. rough   24. ship to ship   25. ship | ||||
| 	ETerrainType::ETerrainType battleTerrainType() const; | ||||
| 	BFieldType::BFieldType battleGetBattlefieldType() const; | ||||
| 	std::vector<shared_ptr<const CObstacleInstance> > battleGetAllObstacles(boost::optional<BattlePerspective::BattlePerspective> perspective = boost::none) const; //returns all obstacles on the battlefield | ||||
| 	TStacks battleGetAllStacks() const; //returns all stacks, alive or dead or undead or mechanical :) | ||||
| 	bool battleHasNativeStack(ui8 side) const; | ||||
| @@ -175,9 +175,9 @@ public: | ||||
| 	const CStack *battleActiveStack() const; | ||||
| 	si8 battleTacticDist() const; //returns tactic distance in current tactics phase; 0 if not in tactics phase | ||||
| 	si8 battleGetTacticsSide() const; //returns which side is in tactics phase, undefined if none (?) | ||||
| 	bool battleCanFlee(int player) const; | ||||
| 	bool battleCanSurrender(int player) const; | ||||
| 	ui8 playerToSide(int player) const; | ||||
| 	bool battleCanFlee(TPlayerColor player) const; | ||||
| 	bool battleCanSurrender(TPlayerColor player) const; | ||||
| 	ui8 playerToSide(TPlayerColor player) const; | ||||
| 	ui8 battleGetSiegeLevel() const; //returns 0 when there is no siege, 1 if fort, 2 is citadel, 3 is castle | ||||
| 	bool battleHasHero(ui8 side) const; | ||||
| 	int battleCastSpells(ui8 side) const; //how many spells has given side casted | ||||
| @@ -227,7 +227,7 @@ public: | ||||
|  | ||||
| 	std::vector<BattleHex> battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = NULL) const; //returns hexes reachable by creature with id ID (valid movement destinations), DOES contain stack current position | ||||
|  | ||||
| 	int battleGetSurrenderCost(int Player) const; //returns cost of surrendering battle, -1 if surrendering is not possible | ||||
| 	int battleGetSurrenderCost(TPlayerColor Player) const; //returns cost of surrendering battle, -1 if surrendering is not possible | ||||
| 	ReachabilityInfo::TDistances battleGetDistances(const CStack * stack, BattleHex hex = BattleHex::INVALID, BattleHex * predecessors = NULL) const; //returns vector of distances to [dest hex number] | ||||
| 	std::set<BattleHex> battleGetAttackedHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos = BattleHex::INVALID) const; | ||||
| 	bool battleCanShoot(const CStack * stack, BattleHex dest) const; //determines if stack with given ID shoot at the selected destination | ||||
|   | ||||
| @@ -113,7 +113,7 @@ CScriptingModule * CDynLibHandler::getNewScriptingModule(std::string dllname) | ||||
|  | ||||
| BattleAction CGlobalAI::activeStack( const CStack * stack ) | ||||
| { | ||||
| 	BattleAction ba; ba.actionType = BattleAction::DEFEND; | ||||
| 	BattleAction ba; ba.actionType = Battle::DEFEND; | ||||
| 	ba.stackNumber = stack->ID; | ||||
| 	return ba; | ||||
| } | ||||
|   | ||||
| @@ -773,11 +773,11 @@ CGameState::~CGameState() | ||||
| BattleInfo * CGameState::setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town) | ||||
| { | ||||
| 	const TerrainTile &t = map->getTile(tile); | ||||
|     int terrain = t.terType; | ||||
|     ETerrainType::ETerrainType terrain = t.terType; | ||||
| 	if(t.isCoastal() && !t.isWater()) | ||||
|         terrain = ETerrainType::SAND; | ||||
|  | ||||
| 	int terType = battleGetBattlefieldType(tile); | ||||
| 	BFieldType::BFieldType terType = battleGetBattlefieldType(tile); | ||||
| 	return BattleInfo::setupBattle(tile, terrain, terType, armies, heroes, creatureBank, town); | ||||
| } | ||||
|  | ||||
| @@ -1679,23 +1679,23 @@ void CGameState::initDuel() | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	curB = BattleInfo::setupBattle(int3(), dp.bfieldType, dp.terType, armies, heroes, false, town); | ||||
| 	curB = BattleInfo::setupBattle(int3(), dp.terType, dp.bfieldType, armies, heroes, false, town); | ||||
| 	curB->obstacles = dp.obstacles; | ||||
| 	curB->localInit(); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| int CGameState::battleGetBattlefieldType(int3 tile) const | ||||
| BFieldType::BFieldType CGameState::battleGetBattlefieldType(int3 tile) const | ||||
| { | ||||
| 	if(tile==int3() && curB) | ||||
| 		tile = curB->tile; | ||||
| 	else if(tile==int3() && !curB) | ||||
| 		return -1; | ||||
| 		return BFieldType::NONE; | ||||
|  | ||||
| 	const TerrainTile &t = map->getTile(tile); | ||||
| 	//fight in mine -> subterranean | ||||
| 	if(dynamic_cast<const CGMine *>(t.visitableObjects.front())) | ||||
| 		return 12; | ||||
| 		return BFieldType::SUBTERRANEAN; | ||||
|  | ||||
| 	BOOST_FOREACH(auto &obj, map->objects) | ||||
| 	{ | ||||
| @@ -1707,55 +1707,55 @@ int CGameState::battleGetBattlefieldType(int3 tile) const | ||||
| 		switch(obj->ID) | ||||
| 		{ | ||||
| 		case Obj::CLOVER_FIELD: | ||||
| 			return 19; | ||||
| 			return BFieldType::CLOVER_FIELD; | ||||
| 		case Obj::CURSED_GROUND1: case Obj::CURSED_GROUND2: | ||||
| 			return 22; | ||||
| 			return BFieldType::CURSED_GROUND; | ||||
| 		case Obj::EVIL_FOG: | ||||
| 			return 20; | ||||
| 			return BFieldType::EVIL_FOG; | ||||
| 		case Obj::FAVORABLE_WINDS: | ||||
| 			return 21; | ||||
| 			return BFieldType::FAVOURABLE_WINDS; | ||||
| 		case Obj::FIERY_FIELDS: | ||||
| 			return 14; | ||||
| 			return BFieldType::FIERY_FIELDS; | ||||
| 		case Obj::HOLY_GROUNDS: | ||||
| 			return 18; | ||||
| 			return BFieldType::HOLY_GROUND; | ||||
| 		case Obj::LUCID_POOLS: | ||||
| 			return 17; | ||||
| 			return BFieldType::LUCID_POOLS; | ||||
| 		case Obj::MAGIC_CLOUDS: | ||||
| 			return 16; | ||||
| 			return BFieldType::MAGIC_CLOUDS; | ||||
| 		case Obj::MAGIC_PLAINS1: case Obj::MAGIC_PLAINS2: | ||||
| 			return 9; | ||||
| 			return BFieldType::MAGIC_PLAINS; | ||||
| 		case Obj::ROCKLANDS: | ||||
| 			return 15; | ||||
| 			return BFieldType::ROCKLANDS; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if(!t.isWater() && t.isCoastal()) | ||||
| 		return 1; //sand/beach | ||||
| 		return BFieldType::SAND_SHORE; | ||||
|  | ||||
|     switch(t.terType) | ||||
| 	{ | ||||
|     case ETerrainType::DIRT: | ||||
| 		return rand()%3+3; | ||||
| 		return static_cast<BFieldType::BFieldType>(rand()%3+3); | ||||
|     case ETerrainType::SAND: | ||||
| 		return 2; //TODO: coast support | ||||
| 		return BFieldType::SAND_MESAS; //TODO: coast support | ||||
|     case ETerrainType::GRASS: | ||||
| 		return rand()%2+6; | ||||
| 		return static_cast<BFieldType::BFieldType>(rand()%2+6); | ||||
|     case ETerrainType::SNOW: | ||||
| 		return rand()%2+10; | ||||
| 		return static_cast<BFieldType::BFieldType>(rand()%2+10); | ||||
|     case ETerrainType::SWAMP: | ||||
| 		return 13; | ||||
| 		return BFieldType::SWAMP_TREES; | ||||
|     case ETerrainType::ROUGH: | ||||
| 		return 23; | ||||
| 		return BFieldType::ROUGH; | ||||
|     case ETerrainType::SUBTERRANEAN: | ||||
| 		return 12; | ||||
| 		return BFieldType::SUBTERRANEAN; | ||||
|     case ETerrainType::LAVA: | ||||
| 		return 8; | ||||
| 		return BFieldType::LAVA; | ||||
|     case ETerrainType::WATER: | ||||
| 		return 25; | ||||
| 		return BFieldType::SHIP; | ||||
|     case ETerrainType::ROCK: | ||||
| 		return 15; | ||||
| 		return BFieldType::ROCKLANDS; | ||||
| 	default: | ||||
| 		return -1; | ||||
| 		return BFieldType::NONE; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -1820,17 +1820,17 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack) | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| int CGameState::getPlayerRelations( ui8 color1, ui8 color2 ) | ||||
| PlayerRelations::PlayerRelations CGameState::getPlayerRelations( TPlayerColor color1, TPlayerColor color2 ) | ||||
| { | ||||
| 	if ( color1 == color2 ) | ||||
| 		return 2; | ||||
| 	if(color1 == 255 || color2 == 255) //neutral player has no friends | ||||
| 		return  0; | ||||
| 		return PlayerRelations::SAME_PLAYER; | ||||
| 	if(color1 == GameConstants::NEUTRAL_PLAYER || color2 == GameConstants::NEUTRAL_PLAYER) //neutral player has no friends | ||||
| 		return PlayerRelations::ENEMIES; | ||||
|  | ||||
| 	const TeamState * ts = getPlayerTeam(color1); | ||||
| 	if (ts && vstd::contains(ts->players, color2)) | ||||
| 		return 1; | ||||
| 	return 0; | ||||
| 		return PlayerRelations::ALLIES; | ||||
| 	return PlayerRelations::ENEMIES; | ||||
| } | ||||
|  | ||||
| void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vector<int3> &vec, const boost::logic::tribool &onLand, bool limitCoastSailing) | ||||
| @@ -2293,7 +2293,7 @@ ui8 CGameState::checkForStandardWin() const | ||||
| 	return supposedWinner; | ||||
| } | ||||
|  | ||||
| bool CGameState::checkForStandardLoss( ui8 player ) const | ||||
| bool CGameState::checkForStandardLoss( TPlayerColor player ) const | ||||
| { | ||||
| 	//std loss condition is: player lost all towns and heroes | ||||
| 	const PlayerState &p = *CGameInfoCallback::getPlayer(player); | ||||
| @@ -2496,7 +2496,7 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level) | ||||
| #undef FILL_FIELD | ||||
| } | ||||
|  | ||||
| int CGameState::lossCheck( ui8 player ) const | ||||
| int CGameState::lossCheck( TPlayerColor player ) const | ||||
| { | ||||
| 	const PlayerState *p = CGameInfoCallback::getPlayer(player); | ||||
| 	//if(map->lossCondition.typeOfLossCon == lossStandard) | ||||
| @@ -2900,7 +2900,7 @@ DuelParameters::SideSettings::SideSettings() | ||||
| DuelParameters::DuelParameters() | ||||
| { | ||||
|     terType = ETerrainType::DIRT; | ||||
| 	bfieldType = 15; | ||||
| 	bfieldType = BFieldType::ROCKLANDS; | ||||
| } | ||||
|  | ||||
| DuelParameters DuelParameters::fromJSON(const std::string &fname) | ||||
| @@ -2908,8 +2908,8 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname) | ||||
| 	DuelParameters ret; | ||||
|  | ||||
| 	const JsonNode duelData(ResourceID("DATA/" + fname, EResType::TEXT)); | ||||
| 	ret.terType = duelData["terType"].Float(); | ||||
| 	ret.bfieldType = duelData["bfieldType"].Float(); | ||||
| 	ret.terType = static_cast<ETerrainType::ETerrainType>((int)duelData["terType"].Float()); | ||||
| 	ret.bfieldType = static_cast<BFieldType::BFieldType>((int)duelData["bfieldType"].Float()); | ||||
| 	BOOST_FOREACH(const JsonNode &n, duelData["sides"].Vector()) | ||||
| 	{ | ||||
| 		SideSettings &ss = ret.sides[(int)n["side"].Float()]; | ||||
|   | ||||
| @@ -286,7 +286,8 @@ struct DLL_LINKAGE CPathsInfo | ||||
|  | ||||
| struct DLL_EXPORT DuelParameters | ||||
| { | ||||
| 	si32 terType, bfieldType; | ||||
| 	ETerrainType::ETerrainType terType; | ||||
| 	BFieldType::BFieldType bfieldType; | ||||
| 	struct DLL_EXPORT SideSettings | ||||
| 	{ | ||||
| 		struct DLL_EXPORT StackSettings | ||||
| @@ -415,19 +416,19 @@ public: | ||||
| 	void giveHeroArtifact(CGHeroInstance *h, int aid); | ||||
|  | ||||
| 	void apply(CPack *pack); | ||||
| 	int battleGetBattlefieldType(int3 tile) const;//   1. sand/shore   2. sand/mesas   3. dirt/birches   4. dirt/hills   5. dirt/pines   6. grass/hills   7. grass/pines   8. lava   9. magic plains   10. snow/mountains   11. snow/trees   12. subterranean   13. swamp/trees   14. fiery fields   15. rock lands   16. magic clouds   17. lucid pools   18. holy ground   19. clover field   20. evil fog   21. "favourable winds" text on magic plains background   22. cursed ground   23. rough   24. ship to ship   25. ship | ||||
| 	BFieldType::BFieldType battleGetBattlefieldType(int3 tile) const; | ||||
| 	UpgradeInfo getUpgradeInfo(const CStackInstance &stack); | ||||
| 	int getPlayerRelations(ui8 color1, ui8 color2);// 0 = enemy, 1 = ally, 2 = same player | ||||
| 	PlayerRelations::PlayerRelations getPlayerRelations(TPlayerColor color1, TPlayerColor color2); | ||||
| 	bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile | ||||
| 	bool checkForVisitableDir(const int3 & src, const TerrainTile *pom, const int3 & dst) const; //check if src tile is visitable from dst tile | ||||
| 	bool getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret); //calculates path between src and dest; returns pointer to newly allocated CPath or NULL if path does not exists | ||||
| 	void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src = int3(-1,-1,-1), int movement = -1); //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or NULL if path does not exists | ||||
| 	int3 guardingCreaturePosition (int3 pos) const; | ||||
| 	std::vector<CGObjectInstance*> guardingCreatures (int3 pos) const; | ||||
| 	int victoryCheck(ui8 player) const; //checks if given player is winner; -1 if std victory, 1 if special victory, 0 else | ||||
| 	int lossCheck(ui8 player) const; //checks if given player is loser;  -1 if std loss, 1 if special, 0 else | ||||
| 	int victoryCheck(TPlayerColor player) const; //checks if given player is winner; -1 if std victory, 1 if special victory, 0 else | ||||
| 	int lossCheck(TPlayerColor player) const; //checks if given player is loser;  -1 if std loss, 1 if special, 0 else | ||||
| 	ui8 checkForStandardWin() const; //returns color of player that accomplished standard victory conditions or 255 if no winner | ||||
| 	bool checkForStandardLoss(ui8 player) const; //checks if given player lost the game | ||||
| 	bool checkForStandardLoss(TPlayerColor player) const; //checks if given player lost the game | ||||
| 	void obtainPlayersStats(SThievesGuildInfo & tgi, int level); //fills tgi with info about other players that is available at given level of thieves' guild | ||||
| 	bmap<ui32, ConstTransitivePtr<CGHeroInstance> > unusedHeroesFromPool(); //heroes pool without heroes that are available in taverns | ||||
| 	BattleInfo * setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town); | ||||
|   | ||||
| @@ -70,7 +70,7 @@ std::vector<BattleHex> CObstacleInfo::getBlocked(BattleHex hex) const | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| bool CObstacleInfo::isAppropriate(int terrainType, int specialBattlefield /*= -1*/) const | ||||
| bool CObstacleInfo::isAppropriate(ETerrainType::ETerrainType terrainType, int specialBattlefield /*= -1*/) const | ||||
| { | ||||
| 	if(specialBattlefield != -1) | ||||
| 		return vstd::contains(allowedSpecialBfields, specialBattlefield); | ||||
| @@ -366,8 +366,8 @@ void CHeroHandler::loadObstacles() | ||||
| 			obi.defName = obs["defname"].String(); | ||||
| 			obi.width = obs["width"].Float(); | ||||
| 			obi.height = obs["height"].Float(); | ||||
| 			obi.allowedTerrains = obs["allowedTerrain"].convertTo<std::vector<ui8> >(); | ||||
| 			obi.allowedSpecialBfields = obs["specialBattlefields"].convertTo<std::vector<ui8> >(); | ||||
| 			obi.allowedTerrains = obs["allowedTerrain"].convertTo<std::vector<ETerrainType::ETerrainType> >(); | ||||
| 			obi.allowedSpecialBfields = obs["specialBattlefields"].convertTo<std::vector<BFieldType::BFieldType> >(); | ||||
| 			obi.blockedTiles = obs["blockedTiles"].convertTo<std::vector<si16> >(); | ||||
| 			obi.isAbsoluteObstacle = absolute; | ||||
| 		} | ||||
|   | ||||
| @@ -131,8 +131,8 @@ struct DLL_LINKAGE CObstacleInfo | ||||
| { | ||||
| 	si32 ID; | ||||
| 	std::string defName; | ||||
| 	std::vector<ui8> allowedTerrains; | ||||
| 	std::vector<ui8> allowedSpecialBfields; | ||||
| 	std::vector<ETerrainType::ETerrainType> allowedTerrains; | ||||
| 	std::vector<BFieldType::BFieldType> allowedSpecialBfields; | ||||
|  | ||||
| 	ui8 isAbsoluteObstacle; //there may only one such obstacle in battle and its position is always the same | ||||
| 	si32 width, height; //how much space to the right and up is needed to place obstacle (affects only placement algorithm) | ||||
| @@ -140,7 +140,7 @@ struct DLL_LINKAGE CObstacleInfo | ||||
|  | ||||
| 	std::vector<BattleHex> getBlocked(BattleHex hex) const; //returns vector of hexes blocked by obstacle when it's placed on hex 'hex' | ||||
|  | ||||
| 	bool isAppropriate(int terrainType, int specialBattlefield = -1) const; | ||||
| 	bool isAppropriate(ETerrainType::ETerrainType terrainType, int specialBattlefield = -1) const; | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
|   | ||||
| @@ -525,7 +525,8 @@ void CTownHandler::load(const JsonNode &source) | ||||
| 		faction.creatureBg120 = node.second["creatureBackground"]["120px"].String(); | ||||
| 		faction.creatureBg130 = node.second["creatureBackground"]["130px"].String(); | ||||
|  | ||||
| 		faction.nativeTerrain = vstd::find_pos(GameConstants::TERRAIN_NAMES, node.second["nativeTerrain"].String()); | ||||
| 		faction.nativeTerrain = static_cast<ETerrainType::ETerrainType>(vstd::find_pos(GameConstants::TERRAIN_NAMES, | ||||
| 			node.second["nativeTerrain"].String())); | ||||
| 		int alignment = vstd::find_pos(EAlignment::names, node.second["alignment"].String()); | ||||
| 		if (alignment == -1) | ||||
| 			faction.alignment = EAlignment::NEUTRAL; | ||||
|   | ||||
| @@ -173,7 +173,7 @@ public: | ||||
|  | ||||
| 	TFaction factionID; | ||||
|  | ||||
| 	ui8 nativeTerrain; | ||||
| 	ETerrainType::ETerrainType nativeTerrain; | ||||
| 	EAlignment::EAlignment alignment; | ||||
|  | ||||
| 	TCreature commander; | ||||
|   | ||||
| @@ -242,7 +242,7 @@ CPack * CConnection::retreivePack() | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| void CConnection::sendPackToServer(const CPack &pack, ui8 player, ui32 requestID) | ||||
| void CConnection::sendPackToServer(const CPack &pack, TPlayerColor player, ui32 requestID) | ||||
| { | ||||
| 	boost::unique_lock<boost::mutex> lock(*wmx); | ||||
| 	tlog5 << "Sending to server a pack of type " << typeid(pack).name() << std::endl; | ||||
|   | ||||
| @@ -1172,7 +1172,7 @@ public: | ||||
| 	virtual ~CConnection(void); | ||||
|  | ||||
| 	CPack *retreivePack(); //gets from server next pack (allocates it with new) | ||||
| 	void sendPackToServer(const CPack &pack, ui8 player, ui32 requestID); | ||||
| 	void sendPackToServer(const CPack &pack, TPlayerColor player, ui32 requestID); | ||||
|  | ||||
| 	void disableStackSendingByID(); | ||||
| 	void enableStackSendingByID(); | ||||
|   | ||||
| @@ -401,17 +401,16 @@ namespace SecSkillLevel | ||||
| 	}; | ||||
| } | ||||
|  | ||||
|  | ||||
| //follows ERM BI (battle image) format | ||||
| namespace BattlefieldBI | ||||
| { | ||||
| 	enum | ||||
| 	enum BattlefieldBI | ||||
| 	{ | ||||
| 		NONE = -1, | ||||
| 		COASTAL, | ||||
| 		//Discrepency from ERM BI description - we have magic plains and cursed gronds swapped | ||||
| 		MAGIC_PLAINS, | ||||
| 		CURSED_GROUND, | ||||
| 		// | ||||
| 		MAGIC_PLAINS, | ||||
| 		HOLY_GROUND, | ||||
| 		EVIL_FOG, | ||||
| 		CLOVER_FIELD, | ||||
| @@ -434,6 +433,44 @@ namespace Date | ||||
| 	}; | ||||
| } | ||||
|  | ||||
| namespace Battle | ||||
| { | ||||
| 	enum ActionType | ||||
| 	{ | ||||
| 		END_TACTIC_PHASE = -2, INVALID = -1, NO_ACTION = 0, HERO_SPELL, WALK, DEFEND, RETREAT, SURRENDER, WALK_AND_ATTACK, SHOOT, WAIT, CATAPULT, MONSTER_SPELL, BAD_MORALE, | ||||
| 		STACK_HEAL, DAEMON_SUMMONING | ||||
| 	}; | ||||
| } | ||||
|  | ||||
| namespace ETerrainType | ||||
| { | ||||
| 	enum ETerrainType | ||||
| 	{ | ||||
| 		WRONG = -2, BORDER = -1, DIRT, SAND, GRASS, SNOW, SWAMP, | ||||
| 		ROUGH, SUBTERRANEAN, LAVA, WATER, ROCK | ||||
| 	}; | ||||
| } | ||||
|  | ||||
|  | ||||
| namespace BFieldType | ||||
| { | ||||
| 	//   1. sand/shore   2. sand/mesas   3. dirt/birches   4. dirt/hills   5. dirt/pines   6. grass/hills   7. grass/pines  | ||||
| 	//8. lava   9. magic plains   10. snow/mountains   11. snow/trees   12. subterranean   13. swamp/trees   14. fiery fields | ||||
| 	//15. rock lands   16. magic clouds   17. lucid pools   18. holy ground   19. clover field   20. evil fog | ||||
| 	//21. "favourable winds" text on magic plains background   22. cursed ground   23. rough   24. ship to ship   25. ship | ||||
| 	enum BFieldType {NONE = -1, NONE2, SAND_SHORE, SAND_MESAS, DIRT_BIRCHES, DIRT_HILLS, DIRT_PINES, GRASS_HILLS, | ||||
| 		GRASS_PINES, LAVA, MAGIC_PLAINS, SNOW_MOUNTAINS, SNOW_TREES, SUBTERRANEAN, SWAMP_TREES, FIERY_FIELDS, | ||||
| 		ROCKLANDS, MAGIC_CLOUDS, LUCID_POOLS, HOLY_GROUND, CLOVER_FIELD, EVIL_FOG, FAVOURABLE_WINDS, CURSED_GROUND, | ||||
| 		ROUGH, SHIP_TO_SHIP, SHIP | ||||
| 	}; | ||||
| } | ||||
|  | ||||
| namespace PlayerRelations | ||||
| { | ||||
| 	enum PlayerRelations {ENEMIES, ALLIES, SAME_PLAYER}; | ||||
| } | ||||
|  | ||||
|  | ||||
| // Typedef declarations | ||||
| typedef si8 TFaction; | ||||
| typedef si64 TExpType; | ||||
|   | ||||
| @@ -651,14 +651,14 @@ const CMapHeader * CGameInfoCallback::getMapHeader() const | ||||
|  | ||||
| bool CGameInfoCallback::hasAccess(int playerId) const | ||||
| { | ||||
| 	return player < 0 || gs->getPlayerRelations( playerId, player ); | ||||
| 	return player < 0 || gs->getPlayerRelations( playerId, player ) != PlayerRelations::ENEMIES; | ||||
| } | ||||
|  | ||||
| int CGameInfoCallback::getPlayerStatus(int player) const | ||||
| { | ||||
| 	const PlayerState *ps = gs->getPlayer(player, false); | ||||
| 	if(!ps) | ||||
| 		return -1; | ||||
| 	ERROR_RET_VAL_IF(!ps, "No such player!", -1); | ||||
|  | ||||
| 	return ps->status; | ||||
| } | ||||
|  | ||||
| @@ -667,7 +667,7 @@ std::string CGameInfoCallback::getTavernGossip(const CGObjectInstance * townOrTa | ||||
| 	return "GOSSIP TEST"; | ||||
| } | ||||
|  | ||||
| int CGameInfoCallback::getPlayerRelations( ui8 color1, ui8 color2 ) const | ||||
| PlayerRelations::PlayerRelations CGameInfoCallback::getPlayerRelations( TPlayerColor color1, TPlayerColor color2 ) const | ||||
| { | ||||
| 	return gs->getPlayerRelations(color1, color2); | ||||
| } | ||||
|   | ||||
| @@ -83,7 +83,7 @@ public: | ||||
| 	const PlayerState * getPlayer(int color, bool verbose = true) const; | ||||
| 	int getResource(int Player, int which) const; | ||||
| 	bool isVisible(int3 pos) const; | ||||
| 	int getPlayerRelations(ui8 color1, ui8 color2) const;// 0 = enemy, 1 = ally, 2 = same player  | ||||
| 	PlayerRelations::PlayerRelations getPlayerRelations(TPlayerColor color1, TPlayerColor color2) const; | ||||
| 	void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object | ||||
| 	int getPlayerStatus(int player) const; //-1 if no such player | ||||
| 	int getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns | ||||
|   | ||||
| @@ -151,14 +151,37 @@ namespace JsonUtils | ||||
| namespace JsonDetail | ||||
| { | ||||
| 	// convertion helpers for JsonNode::convertTo (partial template function instantiation is illegal in c++) | ||||
|  | ||||
| 	template <typename T, int arithm>  | ||||
| 	struct JsonConvImpl; | ||||
|  | ||||
| 	template <typename T> | ||||
| 	struct JsonConvImpl<T, 0> | ||||
| 	{ | ||||
| 		static T convertImpl(const JsonNode & node) | ||||
| 		{ | ||||
| 			return (T)(int)node.Float(); | ||||
| 		} | ||||
| 	}; | ||||
|  | ||||
| 	template <typename T> | ||||
| 	struct JsonConvImpl<T, 1> | ||||
| 	{ | ||||
| 		static T convertImpl(const JsonNode & node) | ||||
| 		{ | ||||
| 			return node.Float(); | ||||
| 		} | ||||
| 	}; | ||||
|  | ||||
| 	template<typename Type> | ||||
| 	struct JsonConverter | ||||
| 	{ | ||||
| 		static Type convert(const JsonNode & node) | ||||
| 		{ | ||||
| 			///this should be triggered only for numeric types | ||||
| 			static_assert(std::is_arithmetic<Type>::value, "Unsupported type for JsonNode::convertTo()!"); | ||||
| 			return node.Float(); | ||||
| 			///this should be triggered only for numeric types and enums | ||||
| 			static_assert(boost::mpl::or_<std::is_arithmetic<Type>, std::is_enum<Type> >::value, "Unsupported type for JsonNode::convertTo()!"); | ||||
| 			return JsonConvImpl<Type, std::is_arithmetic<Type>::value>::convertImpl(node); | ||||
| 				 | ||||
| 		} | ||||
| 	}; | ||||
|  | ||||
|   | ||||
| @@ -380,15 +380,6 @@ public: | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| namespace ETerrainType | ||||
| { | ||||
| 	enum ETerrainType | ||||
| 	{ | ||||
| 		BORDER = -1, DIRT, SAND, GRASS, SNOW, SWAMP, | ||||
| 		ROUGH, SUBTERRANEAN, LAVA, WATER, ROCK | ||||
| 	}; | ||||
| } | ||||
|  | ||||
| namespace ERiverType | ||||
| { | ||||
| 	enum ERiverType | ||||
|   | ||||
| @@ -1180,7 +1180,7 @@ DLL_LINKAGE void StartAction::applyGs( CGameState *gs ) | ||||
| { | ||||
| 	CStack *st = gs->curB->getStack(ba.stackNumber); | ||||
|  | ||||
| 	if(ba.actionType == BattleAction::END_TACTIC_PHASE) | ||||
| 	if(ba.actionType == Battle::END_TACTIC_PHASE) | ||||
| 	{ | ||||
| 		gs->curB->tacticDistance = 0; | ||||
| 		return; | ||||
| @@ -1193,7 +1193,7 @@ DLL_LINKAGE void StartAction::applyGs( CGameState *gs ) | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if(ba.actionType != BattleAction::HERO_SPELL) //don't check for stack if it's custom action by hero | ||||
| 	if(ba.actionType != Battle::HERO_SPELL) //don't check for stack if it's custom action by hero | ||||
| 	{ | ||||
| 		assert(st); | ||||
| 	} | ||||
| @@ -1204,13 +1204,13 @@ DLL_LINKAGE void StartAction::applyGs( CGameState *gs ) | ||||
|  | ||||
| 	switch(ba.actionType) | ||||
| 	{ | ||||
| 	case BattleAction::DEFEND: | ||||
| 	case Battle::DEFEND: | ||||
| 		st->state.insert(EBattleStackState::DEFENDING); | ||||
| 		break; | ||||
| 	case BattleAction::WAIT: | ||||
| 	case Battle::WAIT: | ||||
| 		st->state.insert(EBattleStackState::WAITING); | ||||
| 		return; | ||||
| 	case BattleAction::HERO_SPELL: //no change in current stack state | ||||
| 	case Battle::HERO_SPELL: //no change in current stack state | ||||
| 		return; | ||||
| 	default: //any active stack action - attack, catapult, heal, spell... | ||||
| 		st->state.insert(EBattleStackState::MOVED); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user