Prechádzať zdrojové kódy

* better positioning of moat/mlip
* minor change

mateuszb 16 rokov pred
rodič
commit
ea5a836a7e

+ 5 - 2
client/CBattleInterface.cpp

@@ -109,10 +109,13 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
 			SDL_Surface * moat = BitmapHandler::loadBitmap( siegeH->getSiegeName(13) ),
 			SDL_Surface * moat = BitmapHandler::loadBitmap( siegeH->getSiegeName(13) ),
 				* mlip = BitmapHandler::loadBitmap( siegeH->getSiegeName(14) );
 				* mlip = BitmapHandler::loadBitmap( siegeH->getSiegeName(14) );
 
 
+			std::pair<int, int> moatPos = CGI->heroh->wallPositions[siegeH->town->town->typeID][10],
+				mlipPos = CGI->heroh->wallPositions[siegeH->town->town->typeID][11];
+
 			if(moat) //eg. tower has no moat
 			if(moat) //eg. tower has no moat
-				blitAt(moat, 410, background->h - moat->h, background);
+				blitAt(moat, moatPos.first,moatPos.second, background);
 			if(mlip) //eg. tower has no mlip
 			if(mlip) //eg. tower has no mlip
-				blitAt(mlip, 410, background->h - mlip->h, background);
+				blitAt(mlip, mlipPos.first, mlipPos.second, background);
 
 
 			SDL_FreeSurface(moat);
 			SDL_FreeSurface(moat);
 			SDL_FreeSurface(mlip);
 			SDL_FreeSurface(mlip);

+ 6 - 3
client/CPlayerInterface.cpp

@@ -998,9 +998,12 @@ void CPlayerInterface::battleObstaclesRemoved(const std::set<si32> & removedObst
 
 
 void CPlayerInterface::battleCatapultAttacked(const CatapultAttack & ca)
 void CPlayerInterface::battleCatapultAttacked(const CatapultAttack & ca)
 {
 {
-	SDL_FreeSurface(battleInt->siegeH->walls[ca.attackedPartOfWall + 2]);
-	battleInt->siegeH->walls[ca.attackedPartOfWall + 2] = BitmapHandler::loadBitmap(
-		battleInt->siegeH->getSiegeName(ca.attackedPartOfWall + 2, cb->battleGetWallState(ca.attackedPartOfWall)) );
+	for(std::set< std::pair<ui8, ui8> >::const_iterator it = ca.attackedParts.begin(); it != ca.attackedParts.end(); ++it)
+	{
+		SDL_FreeSurface(battleInt->siegeH->walls[it->first + 2]);
+		battleInt->siegeH->walls[it->first + 2] = BitmapHandler::loadBitmap(
+			battleInt->siegeH->getSiegeName(it->first + 2, cb->battleGetWallState(it->first)) );
+	}
 }
 }
 
 
 void CPlayerInterface::battleStacksRemoved(const BattleStacksRemoved & bsr)
 void CPlayerInterface::battleStacksRemoved(const BattleStacksRemoved & bsr)

+ 20 - 2
config/wall_pos.txt

@@ -1,4 +1,4 @@
-//this file is a description of positions of wall parts' positions, following lines contain positions of: bottom tower, bottom wall, wall below gate, wall over gate, upper wall, upper tower, gate, gate arch, bottom static wall and upper static wall (x, y)
+//this file is a description of positions of wall parts' positions, following lines contain positions of: bottom tower, bottom wall, wall below gate, wall over gate, upper wall, upper tower, gate, gate arch, bottom static wall and upper static wall, moat, mlip (x, y)
 //Castle 
 //Castle 
 601 500 
 601 500 
 528 350 
 528 350 
@@ -10,6 +10,8 @@
 476 238 
 476 238 
 511 347 
 511 347 
 488 79 
 488 79 
+410 90 
+410 80 
 //Rampart 
 //Rampart 
 593 511 
 593 511 
 548 451 
 548 451 
@@ -21,6 +23,8 @@
 459 220 
 459 220 
 509 364 
 509 364 
 491 103 
 491 103 
+410 77 
+410 97 
 //Tower 
 //Tower 
 591 516 
 591 516 
 547 452 
 547 452 
@@ -32,6 +36,8 @@
 470 187 
 470 187 
 516 365 
 516 365 
 513 79 
 513 79 
+410 90 
+410 80 
 //Inferno 
 //Inferno 
 594 514 
 594 514 
 560 451 
 560 451 
@@ -43,6 +49,8 @@
 476 221 
 476 221 
 521 376 
 521 376 
 501 92 
 501 92 
+410 68 
+410 68 
 //Necropolis 
 //Necropolis 
 591 512 
 591 512 
 535 445 
 535 445 
@@ -54,6 +62,8 @@
 473 240 
 473 240 
 508 372 
 508 372 
 503 97 
 503 97 
+410 78 
+412 77 
 //Dungeon 
 //Dungeon 
 599 495 
 599 495 
 558 448 
 558 448 
@@ -65,6 +75,8 @@
 470 164 
 470 164 
 521 305 
 521 305 
 493 53 
 493 53 
+277 94 
+277 94 
 //Stronghold 
 //Stronghold 
 585 508 
 585 508 
 552 440 
 552 440 
@@ -76,6 +88,8 @@
 477 235 
 477 235 
 510 380 
 510 380 
 498 107 
 498 107 
+410 90 
+410 91 
 //Fortress 
 //Fortress 
 599 505 
 599 505 
 545 441 
 545 441 
@@ -87,6 +101,8 @@
 482 236 
 482 236 
 521 382 
 521 382 
 507 130 
 507 130 
+369 95 
+363 70 
 //Conflux 
 //Conflux 
 607 505 
 607 505 
 508 346 
 508 346 
@@ -97,4 +113,6 @@
 408 254 
 408 254 
 485 232 
 485 232 
 508 346 
 508 346 
-489 97
+489 97 
+410 80 
+410 80 

+ 1 - 1
hch/CHeroHandler.cpp

@@ -143,7 +143,7 @@ void CHeroHandler::loadWallPositions()
 		for(int g=0; g<ARRAY_COUNT(wallPositions); ++g)
 		for(int g=0; g<ARRAY_COUNT(wallPositions); ++g)
 		{
 		{
 			inp >> dump;
 			inp >> dump;
-			for(int b=0; b<10; ++b)
+			for(int b=0; b<12; ++b)
 			{
 			{
 				std::pair<int, int> pt;
 				std::pair<int, int> pt;
 				inp >> pt.first;
 				inp >> pt.first;

+ 6 - 3
lib/NetPacks.h

@@ -999,12 +999,15 @@ struct CatapultAttack : public CPackForClient //3015
 	DLL_EXPORT void applyGs(CGameState *gs);
 	DLL_EXPORT void applyGs(CGameState *gs);
 	void applyCl(CClient *cl);
 	void applyCl(CClient *cl);
 
 
-	ui8 attackedPartOfWall;//[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate;
-	ui8 damageDealt;
+	std::set< std::pair<ui8, ui8> > attackedParts; // <attackedPartOfWall, damageDealt>
+	//attackedPartOfWall; //[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate;
+	//damageDealt;
+
+	bool byCatapult; //if true, by catapult, if false - by something else (ie. spell)
 
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 	{
-		h & attackedPartOfWall & damageDealt;
+		h & attackedParts & byCatapult;
 	}
 	}
 };
 };
 
 

+ 5 - 2
lib/NetPacksLib.cpp

@@ -1077,8 +1077,11 @@ DLL_EXPORT void CatapultAttack::applyGs( CGameState *gs )
 {
 {
 	if(gs->curB && gs->curB->siege != 0) //if there is a battle and it's a siege
 	if(gs->curB && gs->curB->siege != 0) //if there is a battle and it's a siege
 	{
 	{
-		gs->curB->si.wallState[attackedPartOfWall] = 
-			std::min( gs->curB->si.wallState[attackedPartOfWall] + damageDealt, 3 );
+		for(std::set< std::pair<ui8, ui8> >::const_iterator it = attackedParts.begin(); it != attackedParts.end(); ++it)
+		{
+			gs->curB->si.wallState[it->first] = 
+				std::min( gs->curB->si.wallState[it->first] + it->second, 3 );
+		}
 	}
 	}
 }
 }
 
 

+ 7 - 4
server/CGameHandler.cpp

@@ -2562,8 +2562,9 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
 					continue;
 					continue;
 				
 				
 				CatapultAttack ca; //package for clients
 				CatapultAttack ca; //package for clients
-				ca.attackedPartOfWall = attackedPart;
-				ca.damageDealt = 0;
+				std::pair<ui8, ui8> attack;
+				attack.first = attackedPart;
+				attack.second = 0;
 
 
 				int chanceForHit = 0;
 				int chanceForHit = 0;
 				int dmgChance[3] = {sbi.noDmg, sbi.oneDmg, sbi.twoDmg}; //dmgChance[i] - chance for doing i dmg when hit is successful
 				int dmgChance[3] = {sbi.noDmg, sbi.oneDmg, sbi.twoDmg}; //dmgChance[i] - chance for doing i dmg when hit is successful
@@ -2598,11 +2599,11 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
 					{
 					{
 						if(dmgRand <= dmgChance[v])
 						if(dmgRand <= dmgChance[v])
 						{
 						{
-							ca.damageDealt = v;
+							attack.second = v;
 							break;
 							break;
 						}
 						}
 					}
 					}
-					if(ca.damageDealt > 0 && (attackedPart == 0 || attackedPart == 1 || attackedPart == 6))
+					if(attack.second > 0 && (attackedPart == 0 || attackedPart == 1 || attackedPart == 6))
 					{
 					{
 						int posRemove = -1;
 						int posRemove = -1;
 						switch(attackedPart)
 						switch(attackedPart)
@@ -2631,6 +2632,8 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
 						sendAndApply(&bsr);
 						sendAndApply(&bsr);
 					}
 					}
 				}
 				}
+				ca.byCatapult = true;
+				ca.attackedParts.insert(attack);
 
 
 				sendAndApply(&ca);
 				sendAndApply(&ca);
 			}
 			}