Explorar o código

Fixed uninitialized variables.

Frank Zago %!s(int64=16) %!d(string=hai) anos
pai
achega
6312a55bac
Modificáronse 2 ficheiros con 6 adicións e 4 borrados
  1. 1 1
      client/CBattleInterface.cpp
  2. 5 3
      hch/CDefHandler.cpp

+ 1 - 1
client/CBattleInterface.cpp

@@ -2444,7 +2444,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
 	}
 }
 
-CBattleHero::CBattleHero(const std::string & defName, int phaseG, int imageG, bool flipG, unsigned char player, const CGHeroInstance * hero, const CBattleInterface * owner): flip(flipG), myHero(hero), myOwner(owner), phase(phaseG), nextPhase(-1), image(imageG), flagAnim(0)
+CBattleHero::CBattleHero(const std::string & defName, int phaseG, int imageG, bool flipG, unsigned char player, const CGHeroInstance * hero, const CBattleInterface * owner): flip(flipG), myHero(hero), myOwner(owner), phase(phaseG), nextPhase(-1), image(imageG), flagAnim(0), flagAnimCount(0)
 {
 	dh = CDefHandler::giveDef( defName );
 	for(int i=0; i<dh->ourImages.size(); ++i) //transforming images

+ 5 - 3
hch/CDefHandler.cpp

@@ -129,7 +129,6 @@ void CDefHandler::openDef(std::string name)
 void CDefHandler::openFromMemory(unsigned char *table, std::string name)
 {
 	int i,j, totalInBlock;
-	char Buffer[13];
 	BMPPalette palette[256];
 	defName=name;
 	i = 0;
@@ -161,9 +160,12 @@ void CDefHandler::openFromMemory(unsigned char *table, std::string name)
         i+=4;
 		for (j=0; j<totalInBlock; j++)
 		{
-			for (int k=0;k<13;k++) Buffer[k]=table[i+k]; 
-			i+=13;
+			char Buffer[13];
+			memcpy(Buffer, &table[i], 12);
+			Buffer[12] = 0;
 			SEntries[totalEntries+j].name=Buffer;
+
+			i+=13;
 		}
 		for (j=0; j<totalInBlock; j++)
 		{