瀏覽代碼

- fixed wrong battlefield (#961)
- minor tweaks

Ivan Savenko 13 年之前
父節點
當前提交
6f6cd6814e

+ 1 - 1
client/BattleInterface/CBattleInterface.cpp

@@ -3365,7 +3365,7 @@ void CBattleInterface::obstaclePlaced(const CObstacleInstance & oi)
 	waitForAnims();
 
 	int effectID = -1;
-	soundBase::soundID sound = soundBase::invalid;
+	soundBase::soundID sound = soundBase::invalid;//FIXME: variable set but unused. Missing soundh->playSound()?
 
 	std::string defname;
 

+ 2 - 2
client/BattleInterface/CBattleInterfaceClasses.cpp

@@ -360,7 +360,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
 				bestMonsterID = it->second->type->idNumber;
 			}
 		}
-		new CAnimImage("TWCRPORT", bestMonsterID, 0, 21, 38);
+		new CAnimImage("TWCRPORT", bestMonsterID+2, 0, 21, 38);
 		//setting attackerName
 		attackerName =  CGI->creh->creatures[bestMonsterID]->namePl;
 	}
@@ -382,7 +382,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
 				bestMonsterID = it->second->type->idNumber;
 			}
 		}
-		new CAnimImage("TWCRPORT", bestMonsterID, 0, 392, 38);
+		new CAnimImage("TWCRPORT", bestMonsterID+2, 0, 392, 38);
 		//setting defenderName
 		defenderName =  CGI->creh->creatures[bestMonsterID]->namePl;
 	}

+ 3 - 3
client/UIFramework/SDL_Extensions.cpp

@@ -279,6 +279,9 @@ void CSDL_Ext::printAt( const std::string & text, int dstX, int dstY, EFonts fon
 		int lineBegin = std::max<int>(0, clipRect.y - dstY);
 		int lineEnd   = std::min<int>(f->height, clipRect.y + clipRect.h - dstY - 1);
 
+		int rowBegin = std::max(0, clipRect.x - dstX);
+		int rowEnd   = std::min(f->chars[symbol].width, clipRect.x + clipRect.w - dstX - 1);
+
 		//for each line in symbol
 		for(int dy = lineBegin; dy <lineEnd; dy++)
 		{
@@ -288,9 +291,6 @@ void CSDL_Ext::printAt( const std::string & text, int dstX, int dstY, EFonts fon
 			dstLine += (dstY+dy) * dst->pitch + dstX * bpp;
 			srcLine += dy * f->chars[symbol].width;
 
-			int rowBegin = std::max(0, clipRect.x - dstX);
-			int rowEnd   = std::min(f->chars[symbol].width, clipRect.x + clipRect.w - dstX - 1);
-
 			//for each column in line
 			for(int dx = rowBegin; dx < rowEnd; dx++)
 			{

+ 3 - 3
client/mapHandler.cpp

@@ -539,7 +539,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 				ui8 color = obj->tempOwner;
 
 				//checking if object has non-empty graphic on this tile
-				if(obj->ID != GameConstants::HEROI_TYPE && !obj->coveringAt(obj->pos.x - (top_tile.x + bx), top_tile.y + by - obj->pos.y + 5))
+				if(obj->ID != GameConstants::HEROI_TYPE && !obj->coveringAt(top_tile.x + bx - obj->pos.x, top_tile.y + by - obj->pos.y))
 					continue;
 
 				static const int notBlittedInPuzzleMode[] = {124};
@@ -655,7 +655,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 					if(color < 8 || color==255)
 						CSDL_Ext::setPlayerColor(bitmap, color);
 
-					if( obj->hasShadowAt(obj->pos.x - (top_tile.x + bx), top_tile.y + by - obj->pos.y + 5) )
+					if( obj->hasShadowAt(top_tile.x + bx - obj->pos.x, top_tile.y + by - obj->pos.y) )
 						CSDL_Ext::blit8bppAlphaTo24bpp(bitmap,&pp,extSurf,&sr2);
 					else
 						CSDL_Ext::blitSurface(bitmap,&pp,extSurf,&sr2);
@@ -803,7 +803,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 std::pair<SDL_Surface *, bool> CMapHandler::getVisBitmap( const int3 & pos, const std::vector< std::vector< std::vector<ui8> > > & visibilityMap ) const
 {
 	//NOTE: some images have unused in VCMI pair (same blockmap but a bit different look)
-	// 0-1, 2-3, 4-5, 11-13, 13-14
+	// 0-1, 2-3, 4-5, 11-13, 12-14
 	static const int visBitmaps[256] = {
 		-1,  34,   4,   4,  22,  23,   4,   4,  36,  36,  38,  38,  47,  47,  38,  38, //16
 		 3,  25,  12,  12,   3,  25,  12,  12,   9,   9,   6,   6,   9,   9,   6,   6, //32

+ 3 - 5
lib/CGameState.cpp

@@ -1574,11 +1574,9 @@ int CGameState::battleGetBattlefieldType(int3 tile) const
 
 	BOOST_FOREACH(auto &obj, map->objects)
 	{
-		if( !obj || obj->pos.z != tile.z 
-			|| obj->pos.x - tile.x < 0  ||  obj->pos.x - tile.x >= 8
-			||  tile.y - obj->pos.y + 5 < 0  ||  tile.y - obj->pos.y + 5 >=6
-			|| !obj->coveringAt(obj->pos.x - tile.x, tile.y - obj->pos.y + 5)
-			) //look only for objects covering given tile
+		//look only for objects covering given tile
+		if( !obj || obj->pos.z != tile.z
+		  || !obj->coveringAt(tile.x - obj->pos.x, tile.y - obj->pos.y))
 			continue;
 
 		switch(obj->ID)

+ 17 - 12
lib/CObjectHandler.cpp

@@ -284,13 +284,29 @@ bool CGObjectInstance::blockingAt(int x, int y) const
 
 bool CGObjectInstance::coveringAt(int x, int y) const
 {
+	//input coordinates are always negative
+	x = -x;
+	y = -y;
 #if USE_COVERAGE_MAP
+	//NOTE: this code may be broken
 	if((defInfo->coverageMap[y] >> (7-(x) )) & 1 
 		||  (defInfo->shadowCoverage[y] >> (7-(x) )) & 1)
 		return true;
 	return false;
 #else
-	return x < 8 && y < 6;// ignore unreliable msk\msg
+	return x >= 0 && y >= 0 && x < getWidth() && y < getHeight();
+#endif
+}
+
+bool CGObjectInstance::hasShadowAt( int x, int y ) const
+{
+#if USE_COVERAGE_MAP
+	//NOTE: this code may be broken
+	if( (defInfo->shadowCoverage[y] >> (7-(x) )) & 1 )
+		return true;
+	return false;
+#else
+	return coveringAt(x,y);// ignore unreliable shadowCoverage map
 #endif
 }
 
@@ -475,17 +491,6 @@ ui8 CGObjectInstance::getPassableness() const
 	return 0;
 }
 
-bool CGObjectInstance::hasShadowAt( int x, int y ) const
-{
-#if USE_COVERAGE_MAP
-	if( (defInfo->shadowCoverage[y] >> (7-(x) )) & 1 )
-		return true;
-	return false;
-#else
-	return coveringAt(x,y);// ignore unreliable shadowCoverage map
-#endif
-}
-
 int3 CGObjectInstance::visitablePos() const
 {
 	return pos - getVisitableOffset();