Browse Source

Fixed crash on closing. Fixed #326. Max movement points values follow H3 more closely. Minor fixes.

Michał W. Urbańczyk 16 years ago
parent
commit
5be449b6ca
4 changed files with 18 additions and 1 deletions
  1. 1 0
      client/Client.cpp
  2. 2 0
      client/NetPacksClient.cpp
  3. 6 1
      hch/CObjectHandler.cpp
  4. 9 0
      lib/Connection.h

+ 1 - 0
client/Client.cpp

@@ -173,6 +173,7 @@ void CClient::stop()
 	// Tell the network thread and interface thread to reach a stable state
 	terminate = true;
 	LOCPLINT->terminate = true;
+	LOCPLINT->pim->lock();
 	endGame();
 }
 

+ 2 - 0
client/NetPacksClient.cpp

@@ -97,6 +97,8 @@ void FoWChange::applyCl( CClient *cl )
 		cl->playerint[player]->tileRevealed(tiles);
 	else
 		cl->playerint[player]->tileHidden(tiles);
+
+	GS(cl)->calculatePaths(cl->IGameCallback::getSelectedHero(player), *cl->pathInfo);
 }
 
 void SetAvailableHeroes::applyCl( CClient *cl )

+ 6 - 1
hch/CObjectHandler.cpp

@@ -578,7 +578,12 @@ ui8 CGHeroInstance::getSecSkillLevel(const int & ID) const
 }
 int CGHeroInstance::maxMovePoints(bool onLand) const
 {
-	int ret = std::min(2000, 1270+70*lowestSpeed(this)),
+	static const int moveForSpeed[] = { 1500, 1560, 1630, 1700, 1760, 1830, 1900, 1960, 2000 }; //first element for 3 and lower; last for 11 and more
+	int index = lowestSpeed(this) - 3;
+	amin(index, ARRAY_COUNT(moveForSpeed)-1);
+	amax(index, 0);
+
+	int ret = moveForSpeed[index],
 		bonus = valOfBonuses(HeroBonus::MOVEMENT) + (onLand ? valOfBonuses(HeroBonus::LAND_MOVEMENT) : valOfBonuses(HeroBonus::SEA_MOVEMENT));
 
 	double modifier = 0;

+ 9 - 0
lib/Connection.h

@@ -234,6 +234,7 @@ class CBasicPointerSaver
 {
 public:
 	virtual void savePtr(CSaverBase &ar, const void *data) const =0;
+	~CBasicPointerSaver(){}
 };
 
 template <typename Serializer, typename T> class CPointerSaver : public CBasicPointerSaver
@@ -263,6 +264,13 @@ public:
 		saving=true;
 		smartPointerSerialization = true;
 	}
+	~COSer()
+	{
+		std::map<ui16,CBasicPointerSaver*>::iterator iter;
+
+		for(iter = savers.begin(); iter != savers.end(); iter++)
+			delete iter->second;
+	}
 
 	template<typename T> void registerType(const T * t=NULL)
 	{
@@ -431,6 +439,7 @@ class CBasicPointerLoader
 {
 public:
 	virtual void loadPtr(CLoaderBase &ar, void *data) const =0; //data is pointer to the ACTUAL POINTER
+	virtual ~CBasicPointerLoader(){}
 };
 
 template <typename Serializer, typename T> class CPointerLoader : public CBasicPointerLoader