1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Fix formatting

This commit is contained in:
Vadim Markovtsev
2016-10-28 23:37:20 +02:00
parent c696746017
commit ab7a0d64eb
4 changed files with 524 additions and 525 deletions

View File

@@ -203,15 +203,15 @@ void CClient::save(const std::string & fname)
sendRequest((CPackForClient*)&save_game, PlayerColor::NEUTRAL);
}
void CClient::endGame( bool closeConnection /*= true*/ )
void CClient::endGame(bool closeConnection /*= true*/)
{
//suggest interfaces to finish their stuff (AI should interrupt any bg working threads)
for(auto& i : playerint)
for (auto& i : playerint)
i.second->finish();
// Game is ending
// Tell the network thread to reach a stable state
if(closeConnection)
if (closeConnection)
stopConnection();
logNetwork->infoStream() << "Closed connection.";

View File

@@ -105,17 +105,17 @@
*
*/
void SetResources::applyCl( CClient *cl )
void SetResources::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(player,receivedResource,-1,-1);
}
void SetResource::applyCl( CClient *cl )
void SetResource::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(player,receivedResource,resid,val);
}
void SetPrimSkill::applyCl( CClient *cl )
void SetPrimSkill::applyCl(CClient *cl)
{
const CGHeroInstance *h = cl->getHero(id);
if(!h)
@@ -126,7 +126,7 @@ void SetPrimSkill::applyCl( CClient *cl )
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroPrimarySkillChanged,h,which,val);
}
void SetSecSkill::applyCl( CClient *cl )
void SetSecSkill::applyCl(CClient *cl)
{
const CGHeroInstance *h = cl->getHero(id);
if(!h)
@@ -137,7 +137,7 @@ void SetSecSkill::applyCl( CClient *cl )
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroSecondarySkillChanged,h,which,val);
}
void HeroVisitCastle::applyCl( CClient *cl )
void HeroVisitCastle::applyCl(CClient *cl)
{
const CGHeroInstance *h = cl->getHero(hid);
@@ -147,25 +147,25 @@ void HeroVisitCastle::applyCl( CClient *cl )
}
}
void ChangeSpells::applyCl( CClient *cl )
void ChangeSpells::applyCl(CClient *cl)
{
//TODO: inform interface?
}
void SetMana::applyCl( CClient *cl )
void SetMana::applyCl(CClient *cl)
{
const CGHeroInstance *h = cl->getHero(hid);
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroManaPointsChanged, h);
}
void SetMovePoints::applyCl( CClient *cl )
void SetMovePoints::applyCl(CClient *cl)
{
const CGHeroInstance *h = cl->getHero(hid);
cl->invalidatePaths();
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroMovePointsChanged, h);
}
void FoWChange::applyCl( CClient *cl )
void FoWChange::applyCl(CClient *cl)
{
for(auto &i : cl->playerint)
{
@@ -184,85 +184,85 @@ void FoWChange::applyCl( CClient *cl )
cl->invalidatePaths();
}
void SetAvailableHeroes::applyCl( CClient *cl )
void SetAvailableHeroes::applyCl(CClient *cl)
{
//TODO: inform interface?
}
void ChangeStackCount::applyCl( CClient *cl )
void ChangeStackCount::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stackChagedCount, sl, count, absoluteValue);
}
void SetStackType::applyCl( CClient *cl )
void SetStackType::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stackChangedType, sl, *type);
}
void EraseStack::applyCl( CClient *cl )
void EraseStack::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stacksErased, sl);
}
void SwapStacks::applyCl( CClient *cl )
void SwapStacks::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(sl1.army->tempOwner, stacksSwapped, sl1, sl2);
if(sl1.army->tempOwner != sl2.army->tempOwner)
INTERFACE_CALL_IF_PRESENT(sl2.army->tempOwner, stacksSwapped, sl1, sl2);
}
void InsertNewStack::applyCl( CClient *cl )
void InsertNewStack::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner,newStackInserted,sl, *sl.getStack());
}
void RebalanceStacks::applyCl( CClient *cl )
void RebalanceStacks::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(src.army->tempOwner, stacksRebalanced, src, dst, count);
if(src.army->tempOwner != dst.army->tempOwner)
INTERFACE_CALL_IF_PRESENT(dst.army->tempOwner,stacksRebalanced, src, dst, count);
}
void PutArtifact::applyCl( CClient *cl )
void PutArtifact::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactPut, al);
}
void EraseArtifact::applyCl( CClient *cl )
void EraseArtifact::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactRemoved, al);
}
void MoveArtifact::applyCl( CClient *cl )
void MoveArtifact::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(src.owningPlayer(), artifactMoved, src, dst);
if(src.owningPlayer() != dst.owningPlayer())
INTERFACE_CALL_IF_PRESENT(dst.owningPlayer(), artifactMoved, src, dst);
}
void AssembledArtifact::applyCl( CClient *cl )
void AssembledArtifact::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactAssembled, al);
}
void DisassembledArtifact::applyCl( CClient *cl )
void DisassembledArtifact::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactDisassembled, al);
}
void HeroVisit::applyCl( CClient *cl )
void HeroVisit::applyCl(CClient *cl)
{
assert(hero);
INTERFACE_CALL_IF_PRESENT(player, heroVisit, hero, obj, starting);
}
void NewTurn::applyCl( CClient *cl )
void NewTurn::applyCl(CClient *cl)
{
cl->invalidatePaths();
}
void GiveBonus::applyCl( CClient *cl )
void GiveBonus::applyCl(CClient *cl)
{
cl->invalidatePaths();
switch(who)
@@ -282,13 +282,13 @@ void GiveBonus::applyCl( CClient *cl )
}
}
void ChangeObjPos::applyFirstCl( CClient *cl )
void ChangeObjPos::applyFirstCl(CClient *cl)
{
CGObjectInstance *obj = GS(cl)->getObjInstance(objid);
if(flags & 1)
CGI->mh->hideObject(obj);
}
void ChangeObjPos::applyCl( CClient *cl )
void ChangeObjPos::applyCl(CClient *cl)
{
CGObjectInstance *obj = GS(cl)->getObjInstance(objid);
if(flags & 1)
@@ -297,12 +297,12 @@ void ChangeObjPos::applyCl( CClient *cl )
cl->invalidatePaths();
}
void PlayerEndsGame::applyCl( CClient *cl )
void PlayerEndsGame::applyCl(CClient *cl)
{
CALL_IN_ALL_INTERFACES(gameOver, player, victoryLossCheckResult);
}
void RemoveBonus::applyCl( CClient *cl )
void RemoveBonus::applyCl(CClient *cl)
{
cl->invalidatePaths();
switch(who)
@@ -322,7 +322,7 @@ void RemoveBonus::applyCl( CClient *cl )
}
}
void UpdateCampaignState::applyCl( CClient *cl )
void UpdateCampaignState::applyCl(CClient *cl)
{
cl->stopConnection();
cl->campaignMapFinished(camp);
@@ -333,7 +333,7 @@ void PrepareForAdvancingCampaign::applyCl(CClient *cl)
cl->serv->prepareForSendingHeroes();
}
void RemoveObject::applyFirstCl( CClient *cl )
void RemoveObject::applyFirstCl(CClient *cl)
{
const CGObjectInstance *o = cl->getObj(id);
@@ -347,12 +347,12 @@ void RemoveObject::applyFirstCl( CClient *cl )
}
}
void RemoveObject::applyCl( CClient *cl )
void RemoveObject::applyCl(CClient *cl)
{
cl->invalidatePaths();
}
void TryMoveHero::applyFirstCl( CClient *cl )
void TryMoveHero::applyFirstCl(CClient *cl)
{
CGHeroInstance *h = GS(cl)->getHero(id);
@@ -375,7 +375,7 @@ void TryMoveHero::applyFirstCl( CClient *cl )
CGI->mh->printObject(h->boat);
}
void TryMoveHero::applyCl( CClient *cl )
void TryMoveHero::applyCl(CClient *cl)
{
const CGHeroInstance *h = cl->getHero(id);
cl->invalidatePaths();
@@ -411,7 +411,7 @@ void TryMoveHero::applyCl( CClient *cl )
}
}
void NewStructures::applyCl( CClient *cl )
void NewStructures::applyCl(CClient *cl)
{
CGTownInstance *town = GS(cl)->getTown(tid);
for(const auto & id : bid)
@@ -430,7 +430,7 @@ void RazeStructures::applyCl (CClient *cl)
}
}
void SetAvailableCreatures::applyCl( CClient *cl )
void SetAvailableCreatures::applyCl(CClient *cl)
{
const CGDwelling *dw = static_cast<const CGDwelling*>(cl->getObj(tid));
@@ -445,7 +445,7 @@ void SetAvailableCreatures::applyCl( CClient *cl )
INTERFACE_CALL_IF_PRESENT(p, availableCreaturesChanged, dw);
}
void SetHeroesInTown::applyCl( CClient *cl )
void SetHeroesInTown::applyCl(CClient *cl)
{
CGTownInstance *t = GS(cl)->getTown(tid);
CGHeroInstance *hGarr = GS(cl)->getHero(this->garrison);
@@ -466,7 +466,7 @@ void SetHeroesInTown::applyCl( CClient *cl )
}
}
// void SetHeroArtifacts::applyCl( CClient *cl )
// void SetHeroArtifacts::applyCl(CClient *cl)
// {
// // CGHeroInstance *h = GS(cl)->getHero(hid);
// // CGameInterface *player = (vstd::contains(cl->playerint,h->tempOwner) ? cl->playerint[h->tempOwner] : nullptr);
@@ -486,7 +486,7 @@ void SetHeroesInTown::applyCl( CClient *cl )
// // }
// }
void HeroRecruited::applyCl( CClient *cl )
void HeroRecruited::applyCl(CClient *cl)
{
CGHeroInstance *h = GS(cl)->map->heroesOnMap.back();
if(h->subID != hid)
@@ -510,19 +510,19 @@ void HeroRecruited::applyCl( CClient *cl )
}
}
void GiveHero::applyCl( CClient *cl )
void GiveHero::applyCl(CClient *cl)
{
CGHeroInstance *h = GS(cl)->getHero(id);
CGI->mh->printObject(h);
cl->playerint[h->tempOwner]->heroCreated(h);
}
void GiveHero::applyFirstCl( CClient *cl )
void GiveHero::applyFirstCl(CClient *cl)
{
CGI->mh->hideObject(GS(cl)->getHero(id));
}
void InfoWindow::applyCl( CClient *cl )
void InfoWindow::applyCl(CClient *cl)
{
std::vector<Component*> comps;
for(auto & elem : components)
@@ -538,7 +538,7 @@ void InfoWindow::applyCl( CClient *cl )
logNetwork->warnStream() << "We received InfoWindow for not our player...";
}
void SetObjectProperty::applyCl( CClient *cl )
void SetObjectProperty::applyCl(CClient *cl)
{
//inform all players that see this object
for(auto it = cl->playerint.cbegin(); it != cl->playerint.cend(); ++it)
@@ -548,7 +548,7 @@ void SetObjectProperty::applyCl( CClient *cl )
}
}
void HeroLevelUp::applyCl( CClient *cl )
void HeroLevelUp::applyCl(CClient *cl)
{
//INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroGotLevel, h, primskill, skills, id);
if(vstd::contains(cl->playerint,hero->tempOwner))
@@ -559,7 +559,7 @@ void HeroLevelUp::applyCl( CClient *cl )
// cb->selectionMade(0, queryID);
}
void CommanderLevelUp::applyCl( CClient *cl )
void CommanderLevelUp::applyCl(CClient *cl)
{
const CCommanderInstance * commander = hero->commander;
assert (commander);
@@ -570,7 +570,7 @@ void CommanderLevelUp::applyCl( CClient *cl )
}
}
void BlockingDialog::applyCl( CClient *cl )
void BlockingDialog::applyCl(CClient *cl)
{
std::string str;
text.toString(str);
@@ -598,12 +598,12 @@ void ExchangeDialog::applyCl(CClient *cl)
INTERFACE_CALL_IF_PRESENT(heroes[0]->tempOwner, heroExchangeStarted, heroes[0]->id, heroes[1]->id, queryID);
}
void TeleportDialog::applyCl( CClient *cl )
void TeleportDialog::applyCl(CClient *cl)
{
CALL_ONLY_THAT_INTERFACE(hero->tempOwner,showTeleportDialog,channel,exits,impassable,queryID);
}
void BattleStart::applyFirstCl( CClient *cl )
void BattleStart::applyFirstCl(CClient *cl)
{
//Cannot use the usual macro because curB is not set yet
CALL_ONLY_THAT_BATTLE_INTERFACE(info->sides[0].color, battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
@@ -614,7 +614,7 @@ void BattleStart::applyFirstCl( CClient *cl )
info->tile, info->sides[0].hero, info->sides[1].hero);
}
void BattleStart::applyCl( CClient *cl )
void BattleStart::applyCl(CClient *cl)
{
cl->battleStarted(info);
}
@@ -624,30 +624,30 @@ void BattleNextRound::applyFirstCl(CClient *cl)
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewRoundFirst,round);
}
void BattleNextRound::applyCl( CClient *cl )
void BattleNextRound::applyCl(CClient *cl)
{
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewRound,round);
}
void BattleSetActiveStack::applyCl( CClient *cl )
void BattleSetActiveStack::applyCl(CClient *cl)
{
if(!askPlayerInterface)
return;
const CStack * activated = GS(cl)->curB->battleGetStackByID(stack);
const CStack *activated = GS(cl)->curB->battleGetStackByID(stack);
PlayerColor playerToCall; //player that will move activated stack
if( activated->hasBonusOfType(Bonus::HYPNOTIZED) )
if (activated->hasBonusOfType(Bonus::HYPNOTIZED))
{
playerToCall = ( GS(cl)->curB->sides[0].color == activated->owner
playerToCall = (GS(cl)->curB->sides[0].color == activated->owner
? GS(cl)->curB->sides[1].color
: GS(cl)->curB->sides[0].color );
: GS(cl)->curB->sides[0].color);
}
else
{
playerToCall = activated->owner;
}
if( vstd::contains(cl->battleints, playerToCall) )
boost::thread( std::bind(&CClient::waitForMoveAndSend, cl, playerToCall) );
if (vstd::contains(cl->battleints, playerToCall))
boost::thread(std::bind(&CClient::waitForMoveAndSend, cl, playerToCall));
}
void BattleTriggerEffect::applyCl(CClient * cl)
@@ -665,20 +665,20 @@ void BattleUpdateGateState::applyFirstCl(CClient * cl)
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleGateStateChanged, state);
}
void BattleResult::applyFirstCl( CClient *cl )
void BattleResult::applyFirstCl(CClient *cl)
{
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleEnd,this);
cl->battleFinished();
}
void BattleStackMoved::applyFirstCl( CClient *cl )
void BattleStackMoved::applyFirstCl(CClient *cl)
{
const CStack * movedStack = GS(cl)->curB->battleGetStackByID(stack);
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStackMoved,movedStack,tilesToMove,distance);
}
//void BattleStackAttacked::( CClient *cl )
void BattleStackAttacked::applyFirstCl( CClient *cl )
//void BattleStackAttacked::(CClient *cl)
void BattleStackAttacked::applyFirstCl(CClient *cl)
{
std::vector<BattleStackAttacked> bsa;
bsa.push_back(*this);
@@ -686,7 +686,7 @@ void BattleStackAttacked::applyFirstCl( CClient *cl )
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,bsa);
}
void BattleAttack::applyFirstCl( CClient *cl )
void BattleAttack::applyFirstCl(CClient *cl)
{
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleAttack,this);
for (auto & elem : bsa)
@@ -698,34 +698,34 @@ void BattleAttack::applyFirstCl( CClient *cl )
}
}
void BattleAttack::applyCl( CClient *cl )
void BattleAttack::applyCl(CClient *cl)
{
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,bsa);
}
void StartAction::applyFirstCl( CClient *cl )
void StartAction::applyFirstCl(CClient *cl)
{
cl->curbaction = ba;
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(actionStarted, ba);
}
void BattleSpellCast::applyCl( CClient *cl )
void BattleSpellCast::applyCl(CClient *cl)
{
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleSpellCast,this);
}
void SetStackEffect::applyCl( CClient *cl )
void SetStackEffect::applyCl(CClient *cl)
{
//informing about effects
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksEffectsSet,*this);
}
void StacksInjured::applyCl( CClient *cl )
void StacksInjured::applyCl(CClient *cl)
{
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,stacks);
}
void BattleResultsApplied::applyCl( CClient *cl )
void BattleResultsApplied::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(player1, battleResultsApplied);
INTERFACE_CALL_IF_PRESENT(player2, battleResultsApplied);
@@ -736,7 +736,7 @@ void BattleResultsApplied::applyCl( CClient *cl )
}
}
void StacksHealedOrResurrected::applyCl( CClient *cl )
void StacksHealedOrResurrected::applyCl(CClient *cl)
{
std::vector<std::pair<ui32, ui32> > shiftedHealed;
for(auto & elem : healedStacks)
@@ -746,13 +746,13 @@ void StacksHealedOrResurrected::applyCl( CClient *cl )
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksHealedRes, shiftedHealed, lifeDrain, tentHealing, drainedFrom);
}
void ObstaclesRemoved::applyCl( CClient *cl )
void ObstaclesRemoved::applyCl(CClient *cl)
{
//inform interfaces about removed obstacles
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleObstaclesRemoved, obstacles);
}
void CatapultAttack::applyCl( CClient *cl )
void CatapultAttack::applyCl(CClient *cl)
{
//inform interfaces about catapult attack
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleCatapultAttacked, *this);
@@ -764,30 +764,30 @@ void BattleStacksRemoved::applyFirstCl(CClient * cl)
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksRemoved, *this);
}
void BattleStackAdded::applyCl( CClient *cl )
void BattleStackAdded::applyCl(CClient *cl)
{
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewStackAppeared, GS(cl)->curB->stacks.back());
}
CGameState* CPackForClient::GS( CClient *cl )
CGameState* CPackForClient::GS(CClient *cl)
{
return cl->gs;
}
void EndAction::applyCl( CClient *cl )
void EndAction::applyCl(CClient *cl)
{
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(actionFinished, *cl->curbaction);
cl->curbaction.reset();
}
void PackageApplied::applyCl( CClient *cl )
void PackageApplied::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
if(!cl->waitingRequest.tryRemovingElement(requestID))
logNetwork->warnStream() << "Surprising server message!";
}
void SystemMessage::applyCl( CClient *cl )
void SystemMessage::applyCl(CClient *cl)
{
std::ostringstream str;
str << "System message: " << text;
@@ -797,12 +797,12 @@ void SystemMessage::applyCl( CClient *cl )
LOCPLINT->cingconsole->print(str.str());
}
void PlayerBlocked::applyCl( CClient *cl )
void PlayerBlocked::applyCl(CClient *cl)
{
INTERFACE_CALL_IF_PRESENT(player,playerBlocked,reason, startOrEnd==BLOCKADE_STARTED);
}
void YourTurn::applyCl( CClient *cl )
void YourTurn::applyCl(CClient *cl)
{
CALL_IN_ALL_INTERFACES(playerStartsTurn, player);
CALL_ONLY_THAT_INTERFACE(player,yourTurn);

File diff suppressed because it is too large Load Diff

View File

@@ -53,10 +53,10 @@ class CBattleGameInterface;
/// Small struct which contains information about the id of the attacked stack, the damage dealt,...
struct StackAttackedInfo
{
const CStack * defender; //attacked stack
const CStack *defender; //attacked stack
unsigned int dmg; //damage dealt
unsigned int amountKilled; //how many creatures in stack has been killed
const CStack * attacker; //attacking stack
const CStack *attacker; //attacking stack
bool indirectAttack; //if true, stack was attacked indirectly - spell or ranged attack
bool killed; //if true, stack has been killed
bool rebirth; //if true, play rebirth animation after all
@@ -69,7 +69,7 @@ struct BattleEffect
int x, y; //position on the screen
float currentFrame;
int maxFrame;
CDefHandler * anim; //animation to display
CDefHandler *anim; //animation to display
int effectID; //uniqueID equal ot ID of appropriate CSpellEffectAnim
BattleHex position; //Indicates if effect which hex the effect is drawn on
};
@@ -77,9 +77,9 @@ struct BattleEffect
struct BattleObjectsByHex
{
typedef std::vector<int> TWallList;
typedef std::vector<const CStack * > TStackList;
typedef std::vector<const CStack *> TStackList;
typedef std::vector<const BattleEffect *> TEffectList;
typedef std::vector<std::shared_ptr<const CObstacleInstance> > TObstacleList;
typedef std::vector<std::shared_ptr<const CObstacleInstance>> TObstacleList;
struct HexData
{
@@ -120,18 +120,18 @@ class CBattleInterface : public CIntObject
AIMED_SPELL_CREATURE
};
private:
SDL_Surface * background, * menu, * amountNormal, * amountNegative, * amountPositive, * amountEffNeutral, * cellBorders, * backgroundWithHexes;
CButton * bOptions, * bSurrender, * bFlee, * bAutofight, * bSpell,
* bWait, * bDefence, * bConsoleUp, * bConsoleDown, *btactNext, *btactEnd;
CBattleConsole * console;
CBattleHero * attackingHero, * defendingHero; //fighting heroes
SDL_Surface *background, *menu, *amountNormal, *amountNegative, *amountPositive, *amountEffNeutral, *cellBorders, *backgroundWithHexes;
CButton *bOptions, *bSurrender, *bFlee, *bAutofight, *bSpell,
* bWait, *bDefence, *bConsoleUp, *bConsoleDown, *btactNext, *btactEnd;
CBattleConsole *console;
CBattleHero *attackingHero, *defendingHero; //fighting heroes
CStackQueue *queue;
const CCreatureSet *army1, *army2; //copy of initial armies (for result window)
const CGHeroInstance * attackingHeroInstance, * defendingHeroInstance;
std::map< int, CCreatureAnimation * > creAnims; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
std::map< int, CDefHandler * > idToProjectile; //projectiles of creatures (creatureID, defhandler)
std::map< int, CDefHandler * > idToObstacle; //obstacles located on the battlefield
std::map< int, SDL_Surface * > idToAbsoluteObstacle; //obstacles located on the battlefield
const CGHeroInstance *attackingHeroInstance, *defendingHeroInstance;
std::map<int, CCreatureAnimation *> creAnims; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
std::map<int, CDefHandler *> idToProjectile; //projectiles of creatures (creatureID, defhandler)
std::map<int, CDefHandler *> idToObstacle; //obstacles located on the battlefield
std::map<int, SDL_Surface *> idToAbsoluteObstacle; //obstacles located on the battlefield
//TODO these should be loaded only when needed (and freed then) but I believe it's rather work for resource manager,
//so I didn't implement that (having ongoing RM development)
@@ -140,12 +140,12 @@ private:
CDefHandler *fireWall;
CDefHandler *smallForceField[2], *bigForceField[2]; // [side]
std::map< int, bool > creDir; // <creatureID, if false reverse creature's animation> //TODO: move it to battle callback
std::map<int, bool> creDir; // <creatureID, if false reverse creature's animation> //TODO: move it to battle callback
ui8 animCount;
const CStack * activeStack; //number of active stack; nullptr - no one
const CStack * mouseHoveredStack; // stack below mouse pointer, used for border animation
const CStack * stackToActivate; //when animation is playing, we should wait till the end to make the next stack active; nullptr of none
const CStack * selectedStack; //for Teleport / Sacrifice
const CStack *activeStack; //number of active stack; nullptr - no one
const CStack *mouseHoveredStack; // stack below mouse pointer, used for border animation
const CStack *stackToActivate; //when animation is playing, we should wait till the end to make the next stack active; nullptr of none
const CStack *selectedStack; //for Teleport / Sacrifice
void activateStack(); //sets activeStack to stackToActivate etc. //FIXME: No, it's not clear at all
std::vector<BattleHex> occupyableHexes, //hexes available for active stack
attackableHexes; //hexes attackable by active stack
@@ -159,8 +159,8 @@ private:
bool stackCanCastSpell; //if true, active stack could possibly cast some target spell
bool creatureCasting; //if true, stack currently aims to cats a spell
bool spellDestSelectMode; //if true, player is choosing destination for his spell - only for GUI / console
BattleAction * spellToCast; //spell for which player is choosing destination
const CSpell * sp; //spell pointer for convenience
BattleAction *spellToCast; //spell for which player is choosing destination
const CSpell *sp; //spell pointer for convenience
si32 creatureSpellToCast;
std::vector<PossibleActions> possibleActions; //all actions possible to call at the moment by player
std::vector<PossibleActions> localActions; //actions possible to take on hovered hex
@@ -169,18 +169,18 @@ private:
PossibleActions selectedAction; //last action chosen (and saved) by player
PossibleActions illegalAction; //most likely action that can't be performed here
void setActiveStack(const CStack * stack);
void setHoveredStack(const CStack * stack);
void setActiveStack(const CStack *stack);
void setHoveredStack(const CStack *stack);
void requestAutofightingAIToTakeAction();
void getPossibleActionsForStack (const CStack * stack, const bool forceCast); //called when stack gets its turn
void getPossibleActionsForStack (const CStack *stack, const bool forceCast); //called when stack gets its turn
void endCastingSpell(); //ends casting spell (eg. when spell has been cast or canceled)
//force active stack to cast a spell if possible
void enterCreatureCastingMode();
void printConsoleAttacked(const CStack * defender, int dmg, int killed, const CStack * attacker, bool Multiple);
void printConsoleAttacked(const CStack *defender, int dmg, int killed, const CStack *attacker, bool Multiple);
std::list<ProjectileInfo> projectiles; //projectiles flying on battlefield
void giveCommand(Battle::ActionType action, BattleHex tile, ui32 stackID, si32 additional=-1, si32 selectedStack = -1);
@@ -194,17 +194,17 @@ private:
{
private:
SDL_Surface* walls[18];
const CBattleInterface * owner;
const CBattleInterface *owner;
public:
const CGTownInstance * town; //besieged town
const CGTownInstance *town; //besieged town
SiegeHelper(const CGTownInstance * siegeTown, const CBattleInterface * _owner); //c-tor
SiegeHelper(const CGTownInstance *siegeTown, const CBattleInterface *_owner); //c-tor
~SiegeHelper(); //d-tor
std::string getSiegeName(ui16 what) const;
std::string getSiegeName(ui16 what, int state) const; // state uses EWallState enum
void printPartOfWall(SDL_Surface * to, int what);
void printPartOfWall(SDL_Surface *to, int what);
enum EWallVisual
{
@@ -229,48 +229,48 @@ private:
};
friend class CBattleInterface;
} * siegeH;
} *siegeH;
std::shared_ptr<CPlayerInterface> attackerInt, defenderInt; //because LOCPLINT is not enough in hotSeat
std::shared_ptr<CPlayerInterface> curInt; //current player interface
const CGHeroInstance * getActiveHero(); //returns hero that can currently cast a spell
const CGHeroInstance *getActiveHero(); //returns hero that can currently cast a spell
/** Methods for displaying battle screen */
void showBackground(SDL_Surface * to);
void showBackground(SDL_Surface *to);
void showBackgroundImage(SDL_Surface * to);
void showAbsoluteObstacles(SDL_Surface * to);
void showHighlightedHexes(SDL_Surface * to);
void showHighlightedHex(SDL_Surface * to, BattleHex hex);
void showInterface(SDL_Surface * to);
void showBackgroundImage(SDL_Surface *to);
void showAbsoluteObstacles(SDL_Surface *to);
void showHighlightedHexes(SDL_Surface *to);
void showHighlightedHex(SDL_Surface *to, BattleHex hex);
void showInterface(SDL_Surface *to);
void showBattlefieldObjects(SDL_Surface * to);
void showBattlefieldObjects(SDL_Surface *to);
void showAliveStacks(SDL_Surface * to, std::vector<const CStack *> stacks);
void showStacks(SDL_Surface * to, std::vector<const CStack *> stacks);
void showObstacles(SDL_Surface *to, std::vector<std::shared_ptr<const CObstacleInstance> > &obstacles);
void showPiecesOfWall(SDL_Surface * to, std::vector<int> pieces);
void showAliveStacks(SDL_Surface *to, std::vector<const CStack *> stacks);
void showStacks(SDL_Surface *to, std::vector<const CStack *> stacks);
void showObstacles(SDL_Surface *to, std::vector<std::shared_ptr<const CObstacleInstance>> &obstacles);
void showPiecesOfWall(SDL_Surface *to, std::vector<int> pieces);
void showBattleEffects(SDL_Surface *to, const std::vector<const BattleEffect *> &battleEffects);
void showProjectiles(SDL_Surface * to);
void showProjectiles(SDL_Surface *to);
BattleObjectsByHex sortObjectsByHex();
void updateBattleAnimations();
SDL_Surface *getObstacleImage(const CObstacleInstance &oi);
Point getObstaclePosition(SDL_Surface *image, const CObstacleInstance &obstacle);
void redrawBackgroundWithHexes(const CStack * activeStack);
void redrawBackgroundWithHexes(const CStack *activeStack);
/** End of battle screen blitting methods */
PossibleActions getCasterAction(const CSpell * spell, const ISpellCaster * caster, ECastingMode::ECastingMode mode) const;
PossibleActions getCasterAction(const CSpell *spell, const ISpellCaster *caster, ECastingMode::ECastingMode mode) const;
public:
std::list<std::pair<CBattleAnimation *, bool> > pendingAnims; //currently displayed animations <anim, initialized>
void addNewAnim(CBattleAnimation * anim); //adds new anim to pendingAnims
std::list<std::pair<CBattleAnimation *, bool>> pendingAnims; //currently displayed animations <anim, initialized>
void addNewAnim(CBattleAnimation *anim); //adds new anim to pendingAnims
ui32 animIDhelper; //for giving IDs for animations
static CondSh<bool> animsAreDisplayed; //for waiting with the end of battle for end of anims
CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, const CGHeroInstance *hero1, const CGHeroInstance *hero2, const SDL_Rect & myRect, std::shared_ptr<CPlayerInterface> att, std::shared_ptr<CPlayerInterface> defen); //c-tor
~CBattleInterface(); //d-tor
CBattleInterface(const CCreatureSet *army1, const CCreatureSet *army2, const CGHeroInstance *hero1, const CGHeroInstance *hero2, const SDL_Rect & myRect, std::shared_ptr<CPlayerInterface> att, std::shared_ptr<CPlayerInterface> defen); //c-tor
virtual ~CBattleInterface(); //d-tor
//std::vector<TimeInterested*> timeinterested; //animation handling
void setPrintCellBorders(bool set); //if true, cell borders will be printed
@@ -278,18 +278,18 @@ public:
void setPrintMouseShadow(bool set); //if true, hex under mouse will be shaded
void setAnimSpeed(int set); //speed of animation; range 1..100
int getAnimSpeed() const; //speed of animation; range 1..100
CPlayerInterface * getCurrentPlayerInterface() const;
CPlayerInterface *getCurrentPlayerInterface() const;
std::vector<CClickableHex*> bfield; //11 lines, 17 hexes on each
SDL_Surface * cellBorder, * cellShade;
SDL_Surface *cellBorder, *cellShade;
CondSh<BattleAction *> *givenCommand; //data != nullptr if we have i.e. moved current unit
bool myTurn; //if true, interface is active (commands can be ordered)
CBattleResultWindow * resWindow; //window of end of battle
CBattleResultWindow *resWindow; //window of end of battle
bool moveStarted; //if true, the creature that is already moving is going to make its first step
int moveSoundHander; // sound handler used when moving a unit
const BattleResult * bresult; //result of a battle; if non-zero then display when all animations end
const BattleResult *bresult; //result of a battle; if non-zero then display when all animations end
// block all UI elements, e.g. during enemy turn
// unlike activate/deactivate this method will correctly grey-out all elements
@@ -322,20 +322,20 @@ public:
//call-ins
void startAction(const BattleAction* action);
void newStack(const CStack * stack); //new stack appeared on battlefield
void newStack(const CStack *stack); //new stack appeared on battlefield
void stackRemoved(int stackID); //stack disappeared from batlefiled
void stackActivated(const CStack * stack); //active stack has been changed
void stackMoved(const CStack * stack, std::vector<BattleHex> destHex, int distance); //stack with id number moved to destHex
void stackActivated(const CStack *stack); //active stack has been changed
void stackMoved(const CStack *stack, std::vector<BattleHex> destHex, int distance); //stack with id number moved to destHex
void waitForAnims();
void stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked
void stackAttacking(const CStack * attacker, BattleHex dest, const CStack * attacked, bool shooting); //called when stack with id ID is attacking something on hex dest
void stackAttacking(const CStack *attacker, BattleHex dest, const CStack *attacked, bool shooting); //called when stack with id ID is attacking something on hex dest
void newRoundFirst( int round );
void newRound(int number); //caled when round is ended; number is the number of round
void hexLclicked(int whichOne); //hex only call-in
void stackIsCatapulting(const CatapultAttack & ca); //called when a stack is attacking walls
void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed
void displayBattleFinished(); //displays battle result
void spellCast(const BattleSpellCast * sc); //called when a hero casts a spell
void spellCast(const BattleSpellCast *sc); //called when a hero casts a spell
void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
void castThisSpell(SpellID spellID); //called when player has chosen a spell from spellbook
void displayEffect(ui32 effect, int destTile); //displays custom effect on the battlefield
@@ -355,15 +355,15 @@ public:
Rect hexPosition(BattleHex hex) const;
void handleHex(BattleHex myNumber, int eventType);
bool isCastingPossibleHere (const CStack * sactive, const CStack * shere, BattleHex myNumber);
bool canStackMoveHere (const CStack * sactive, BattleHex MyNumber); //TODO: move to BattleState / callback
bool isCastingPossibleHere (const CStack *sactive, const CStack *shere, BattleHex myNumber);
bool canStackMoveHere (const CStack *sactive, BattleHex MyNumber); //TODO: move to BattleState / callback
BattleHex fromWhichHexAttack(BattleHex myNumber);
void obstaclePlaced(const CObstacleInstance & oi);
void gateStateChanged(const EGateState state);
const CGHeroInstance * currentHero() const;
const CGHeroInstance *currentHero() const;
InfoAboutHero enemyHero() const;
friend class CPlayerInterface;