1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

printing casualties in battles and minor things

This commit is contained in:
mateuszb 2008-09-07 15:39:19 +00:00
parent 4edd375ddb
commit 062f59a583
4 changed files with 61 additions and 5 deletions

View File

@ -1391,13 +1391,13 @@ CBattleReslutWindow::CBattleReslutWindow(const BattleResult &br, SDL_Rect & pos,
if(br.winner==0) //attacker won
{
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 60, 122, GEOR16, zwykly, background);
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 410, 122, GEOR16, zwykly, background);
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 60, 122, GEOR13, zwykly, background);
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 410, 122, GEOR13, zwykly, background);
}
else //if(br.winner==1)
{
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 60, 122, GEOR16, zwykly, background);
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 410, 122, GEOR16, zwykly, background);
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 60, 122, GEOR13, zwykly, background);
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 410, 122, GEOR13, zwykly, background);
}
@ -1455,6 +1455,41 @@ CBattleReslutWindow::CBattleReslutWindow(const BattleResult &br, SDL_Rect & pos,
//printing attacker and defender's names
CSDL_Ext::printAtMiddle(attackerName, 156, 44, GEOR16, zwykly, background);
CSDL_Ext::printAtMiddle(defenderName, 314, 44, GEOR16, zwykly, background);
//printing casualities
if(br.s1.size()==0)
{
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[523], 235, 360, GEOR16, zwykly, background);
}
else
{
int xPos = 235 - (br.s1.size()*32 + (br.s1.size() - 1)*10)/2; //increment by 42 with each picture
int yPos = 344;
for(std::set<std::pair<ui32,si32> >::const_iterator it=br.s1.begin(); it!=br.s1.end(); ++it)
{
blitAt(graphics->smallImgs[it->first], xPos, yPos, background);
std::stringstream amount;
amount<<it->second;
CSDL_Ext::printAtMiddle(amount.str(), xPos+16, yPos + 42, GEOR13, zwykly, background);
xPos += 42;
}
}
if(br.s2.size()==0)
{
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[523], 235, 457, GEOR16, zwykly, background);
}
else
{
int xPos = 235 - (br.s2.size()*32 + (br.s2.size() - 1)*10)/2; //increment by 42 with each picture
int yPos = 441;
for(std::set<std::pair<ui32,si32> >::const_iterator it=br.s2.begin(); it!=br.s2.end(); ++it)
{
blitAt(graphics->smallImgs[it->first], xPos, yPos, background);
std::stringstream amount;
amount<<it->second;
CSDL_Ext::printAtMiddle(amount.str(), xPos+16, yPos + 42, GEOR13, zwykly, background);
xPos += 42;
}
}
}

View File

@ -552,6 +552,23 @@ void CGameState::applyNL(IPack * pack)
at->amount = br->newAmount;
at->firstHPleft = br->newHP;
at->alive = !br->killed();
if(br->killedAmount>0) //setting casualities
{
bool found = false;
for(std::set<std::pair<ui32,si32> >::iterator it = curB->cas[1 - at->attackerOwned].begin(); it!=curB->cas[1 - at->attackerOwned].end(); ++it)
{
if(it->first == at->creature->idNumber)
{
found = true;
it->second += br->killedAmount;
}
}
if(!found)
{
curB->cas[1 - at->attackerOwned].insert(std::make_pair(at->creature->idNumber, br->killedAmount));
}
}
break;
}
case 3006:

View File

@ -58,10 +58,11 @@ struct DLL_EXPORT BattleInfo
si32 hero1, hero2;
CCreatureSet army1, army2;
std::vector<CStack*> stacks;
std::set<std::pair<ui32,si32> > cas[2]; //first => casualties of attackers - set of pairs crid<>number
template <typename Handler> void serialize(Handler &h, const int version)
{
h & side1 & side2 & round & activeStack & siege & tile & stacks & army1 & army2 & hero1 & hero2;
h & side1 & side2 & round & activeStack & siege & tile & stacks & army1 & army2 & hero1 & hero2 & cas[0] & cas[1];
}
CStack * getStack(int stackID);
CStack * getStackT(int tileID);

View File

@ -866,6 +866,9 @@ upgend:
//TODO: remove retreating hero from map and place it in recrutation list
BattleResult *br = new BattleResult;
br->result = 1;
br->winner = !ba.side; //fleeing side loses
br->s1 = gs->curB->cas[0]; //setting casualities
br->s2 = gs->curB->cas[1]; //as above - second side ;]
battleResult.set(br);
break;
}