Browse Source

fixed mantiss 0002254

AlexVinS 10 years ago
parent
commit
e82dfb5a85
6 changed files with 15 additions and 11 deletions
  1. 1 1
      client/Client.h
  2. 3 0
      lib/GameConstants.h
  3. 1 1
      lib/IGameCallback.h
  4. 1 1
      lib/NetPacks.h
  5. 8 7
      server/CGameHandler.cpp
  6. 1 1
      server/CGameHandler.h

+ 1 - 1
client/Client.h

@@ -186,7 +186,7 @@ public:
 
 	void giveCreatures(const CArmedInstance * objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) override {};
 	void takeCreatures(ObjectInstanceID objid, const std::vector<CStackBasicDescriptor> &creatures) override {};
-	bool changeStackType(const StackLocation &sl, CCreature *c) override {return false;};
+	bool changeStackType(const StackLocation &sl, const CCreature *c) override {return false;};
 	bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) override {return false;};
 	bool insertNewStack(const StackLocation &sl, const CCreature *c, TQuantity count) override {return false;};
 	bool eraseStack(const StackLocation &sl, bool forceRemoval = false){return false;};

+ 3 - 0
lib/GameConstants.h

@@ -864,7 +864,10 @@ public:
 		WALKING_DEAD = 58,
 		WIGHTS = 60,
 		LICHES = 64,
+		BONE_DRAGON = 68,
 		TROGLODYTES = 70,
+		HYDRA = 110,
+		CHAOS_HYDRA = 111,
 		AIR_ELEMENTAL = 112,
 		EARTH_ELEMENTAL = 113,
 		FIRE_ELEMENTAL = 114,

+ 1 - 1
lib/IGameCallback.h

@@ -61,7 +61,7 @@ public:
 	virtual void giveCreatures(const CArmedInstance *objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) =0;
 	virtual void takeCreatures(ObjectInstanceID objid, const std::vector<CStackBasicDescriptor> &creatures) =0;
 	virtual bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) =0;
-	virtual bool changeStackType(const StackLocation &sl, CCreature *c) =0;
+	virtual bool changeStackType(const StackLocation &sl, const CCreature *c) =0;
 	virtual bool insertNewStack(const StackLocation &sl, const CCreature *c, TQuantity count = -1) =0; //count -1 => moves whole stack
 	virtual bool eraseStack(const StackLocation &sl, bool forceRemoval = false) =0;
 	virtual bool swapStacks(const StackLocation &sl1, const StackLocation &sl2) =0;

+ 1 - 1
lib/NetPacks.h

@@ -795,7 +795,7 @@ struct ChangeStackCount : CGarrisonOperationPack  //521
 struct SetStackType : CGarrisonOperationPack  //522
 {
 	StackLocation sl;
-	CCreature *type;
+	const CCreature *type;
 
 	void applyCl(CClient *cl);
 	DLL_LINKAGE void applyGs(CGameState *gs);

+ 8 - 7
server/CGameHandler.cpp

@@ -2789,7 +2789,7 @@ bool CGameHandler::upgradeCreature( ObjectInstanceID objid, SlotID pos, Creature
 	return true;
 }
 
-bool CGameHandler::changeStackType(const StackLocation &sl, CCreature *c)
+bool CGameHandler::changeStackType(const StackLocation &sl, const CCreature *c)
 {
 	if(!sl.army->hasStackAtSlot(sl.slot))
 		COMPLAIN_RET("Cannot find a stack to change type");
@@ -3208,14 +3208,15 @@ bool CGameHandler::transformInUndead(const IMarket *market, const CGHeroInstance
 
 
 	const CStackInstance &s = army->getStack(slot);
-	int resCreature;//resulting creature - bone dragons or skeletons
 
-	if	(s.hasBonusOfType(Bonus::DRAGON_NATURE))
-		resCreature = 68;
-	else
-		resCreature = 56;
+	//resulting creature - bone dragons or skeletons
+	CreatureID resCreature = CreatureID::SKELETON;
 
-	changeStackType(StackLocation(army, slot), VLC->creh->creatures.at(resCreature));
+	if(s.hasBonusOfType(Bonus::DRAGON_NATURE)
+			|| (s.getCreatureID() == CreatureID::HYDRA)
+			|| (s.getCreatureID() == CreatureID::CHAOS_HYDRA))
+		resCreature = CreatureID::BONE_DRAGON;
+	changeStackType(StackLocation(army, slot), resCreature.toCreature());
 	return true;
 }
 

+ 1 - 1
server/CGameHandler.h

@@ -142,7 +142,7 @@ public:
 
 	void giveCreatures(const CArmedInstance *objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) override;
 	void takeCreatures(ObjectInstanceID objid, const std::vector<CStackBasicDescriptor> &creatures) override;
-	bool changeStackType(const StackLocation &sl, CCreature *c) override;
+	bool changeStackType(const StackLocation &sl, const CCreature *c) override;
 	bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) override;
 	bool insertNewStack(const StackLocation &sl, const CCreature *c, TQuantity count) override;
 	bool eraseStack(const StackLocation &sl, bool forceRemoval = false) override;