From 5ec934d6be66c7b5858cd416eb2de80463541263 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Sun, 3 Aug 2008 13:39:34 +0000 Subject: [PATCH] * resolved #69 --- CGameState.cpp | 22 ++++++---------------- CGameState.h | 4 ++-- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/CGameState.cpp b/CGameState.cpp index 11a4477bf..942e10c0b 100644 --- a/CGameState.cpp +++ b/CGameState.cpp @@ -32,7 +32,7 @@ void CGameState::battle(CCreatureSet * army1, CCreatureSet * army2, int3 tile, C curB->stackActionPerformed = false; for(std::map >::iterator i = army1->slots.begin(); i!=army1->slots.end(); i++) { - stacks.push_back(new CStack(i->second.first,i->second.second,0, stacks.size(), true)); + stacks.push_back(new CStack(i->second.first,i->second.second, hero1->tempOwner, stacks.size(), true)); stacks[stacks.size()-1]->ID = stacks.size()-1; } //initialization of positions @@ -86,7 +86,7 @@ void CGameState::battle(CCreatureSet * army1, CCreatureSet * army2, int3 tile, C break; } for(std::map >::iterator i = army2->slots.begin(); i!=army2->slots.end(); i++) - stacks.push_back(new CStack(i->second.first,i->second.second,1, stacks.size(), false)); + stacks.push_back(new CStack(i->second.first,i->second.second, hero2 ? hero2->tempOwner : 255, stacks.size(), false)); switch(army2->slots.size()) //for defender { case 0: @@ -198,22 +198,12 @@ void CGameState::battle(CCreatureSet * army1, CCreatureSet * army2, int3 tile, C curB->stackActionPerformed = false; if(stacks[i]->alive) //indicate posiibility of making action for this unit { - unsigned char owner = (stacks[i]->owner)?(hero2 ? hero2->tempOwner : 255):(hero1->tempOwner); - unsigned char serialOwner = -1; - for(int g=0; gplayerint.size(); ++g) - { - if(CGI->playerint[g]->playerID == owner) - { - serialOwner = g; - break; - } - } - if(serialOwner==255) //neutral unit + if(stacks[i]->owner==255) //neutral unit { } - else if(CGI->playerint[serialOwner]->human) + else if(CGI->playerint[stacks[i]->owner]->human) { - BattleAction ba = ((CPlayerInterface*)CGI->playerint[serialOwner])->activeStack(stacks[i]->ID); + BattleAction ba = ((CPlayerInterface*)CGI->playerint[stacks[i]->owner])->activeStack(stacks[i]->ID); switch(ba.actionType) { case 2: //walk @@ -246,7 +236,7 @@ void CGameState::battle(CCreatureSet * army1, CCreatureSet * army2, int3 tile, C } else { - //CGI->playerint[serialOwner]->activeStack(stacks[i]->ID); + //CGI->playerint[stacks[i]->owner]->activeStack(stacks[i]->ID); } } if(battleEnd) diff --git a/CGameState.h b/CGameState.h index e3c6f65d1..a8a0b4fdb 100644 --- a/CGameState.h +++ b/CGameState.h @@ -49,11 +49,11 @@ public: CCreature * creature; int amount; int firstHPleft; //HP of first creature in stack - int owner; + unsigned char owner; bool attackerOwned; //if true, this stack is owned by attakcer (this one from left hand side of battle) int position; //position on battlefield bool alive; //true if it is alive - CStack(CCreature * C, int A, int O, int I, bool AO):creature(C),amount(A),owner(O), alive(true), position(-1), ID(I), attackerOwned(AO), firstHPleft(C->hitPoints){}; + CStack(CCreature * C, int A, unsigned char O, int I, bool AO):creature(C),amount(A),owner(O), alive(true), position(-1), ID(I), attackerOwned(AO), firstHPleft(C->hitPoints){}; CStack() : creature(NULL),amount(-1),owner(255), alive(true), position(-1), ID(-1), attackerOwned(true), firstHPleft(-1){}; };