Bläddra i källkod

* small changes

mateuszb 17 år sedan
förälder
incheckning
b75161788e
3 ändrade filer med 18 tillägg och 29 borttagningar
  1. 13 28
      CBattleInterface.cpp
  2. 4 0
      SDL_Extensions.cpp
  3. 1 1
      config/cr_shots.txt

+ 13 - 28
CBattleInterface.cpp

@@ -303,20 +303,12 @@ void CBattleInterface::show(SDL_Surface * to)
 			//printing amount
 			if(stacks[stackDeadByHex[b][v]].amount > 0) //don't print if stack is not alive
 			{
-				if(stacks[stackDeadByHex[b][v]].attackerOwned)
-				{
-					CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackDeadByHex[b][v]]->pos.x + 220, creAnims[stackDeadByHex[b][v]]->pos.y + 260));
-					std::stringstream ss;
-					ss<<stacks[stackDeadByHex[b][v]].amount;
-					CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackDeadByHex[b][v]]->pos.x + 220 + 14, creAnims[stackDeadByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
-				}
-				else
-				{
-					CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackDeadByHex[b][v]]->pos.x + 202, creAnims[stackDeadByHex[b][v]]->pos.y + 260));
-					std::stringstream ss;
-					ss<<stacks[stackDeadByHex[b][v]].amount;
-					CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackDeadByHex[b][v]]->pos.x + 202 + 14, creAnims[stackDeadByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
-				}
+				int xAdd = stacks[stackDeadByHex[b][v]].attackerOwned ? 220 : 202;
+
+				CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackDeadByHex[b][v]]->pos.x + xAdd, creAnims[stackDeadByHex[b][v]]->pos.y + 260));
+				std::stringstream ss;
+				ss<<stacks[stackDeadByHex[b][v]].amount;
+				CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackDeadByHex[b][v]]->pos.x + xAdd + 14, creAnims[stackDeadByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
 			}
 		}
 	}
@@ -328,20 +320,12 @@ void CBattleInterface::show(SDL_Surface * to)
 			//printing amount
 			if(stacks[stackAliveByHex[b][v]].amount > 0) //don't print if stack is not alive
 			{
-				if(stacks[stackAliveByHex[b][v]].attackerOwned)
-				{
-					CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + 220, creAnims[stackAliveByHex[b][v]]->pos.y + 260));
-					std::stringstream ss;
-					ss<<stacks[stackAliveByHex[b][v]].amount;
-					CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackAliveByHex[b][v]]->pos.x + 220 + 14, creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
-				}
-				else
-				{
-					CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + 202, creAnims[stackAliveByHex[b][v]]->pos.y + 260));
-					std::stringstream ss;
-					ss<<stacks[stackAliveByHex[b][v]].amount;
-					CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackAliveByHex[b][v]]->pos.x + 202 + 14, creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
-				}
+				int xAdd = stacks[stackAliveByHex[b][v]].attackerOwned ? 220 : 202;
+
+				CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + xAdd, creAnims[stackAliveByHex[b][v]]->pos.y + 260));
+				std::stringstream ss;
+				ss<<stacks[stackAliveByHex[b][v]].amount;
+				CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackAliveByHex[b][v]]->pos.x + xAdd + 14, creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
 			}
 		}
 	}
@@ -398,6 +382,7 @@ void CBattleInterface::bSurrenderf()
 void CBattleInterface::bFleef()
 {
 	giveCommand(4,0,0);
+	CGI->curh->changeGraphic(0, 0);
 }
 
 void CBattleInterface::bAutofightf()

+ 4 - 0
SDL_Extensions.cpp

@@ -595,6 +595,9 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 			sr.w = dstRect->w = w;
 			sr.h = dstRect->h = h;
 
+			if(SDL_LockSurface(dst))
+				return -1; //if we cannot lock the surface
+
 			if(dst->format->Rshift==0) //like in most surfaces
 			{
 				for(int y=0; y<sr.h; ++y)
@@ -679,6 +682,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 					}
 				}
 			}
+			SDL_UnlockSurface(dst);
 		}
 	}
 	return 0;

+ 1 - 1
config/cr_shots.txt

@@ -5,7 +5,7 @@
 9 SMBALX.DEF 1
 18 PELFX.DEF 0
 19 PELFX.DEF 0
-29 CPGRE.DEF 1
+29 CPRGRE.DEF 1
 34 PMAGX.DEF 1
 35 PMAGX.DEF 1
 41 SMBALX.DEF 0