1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-21 21:17:49 +02:00

Formatting cleanup

This commit is contained in:
Ivan Savenko 2022-11-28 16:43:38 +02:00
parent 3e58d1e3c5
commit 6f6d350228
11 changed files with 88 additions and 60 deletions

@ -57,6 +57,7 @@
#include "../lib/CPlayerState.h"
#include "../lib/GameConstants.h"
#include "gui/CGuiHandler.h"
#include "gui/CAnimation.h"
#include "windows/InfoWindows.h"
#include "../lib/UnlockGuard.h"
#include "../lib/CPathfinder.h"

@ -17,12 +17,13 @@
#include "CBattleSiegeController.h"
#include "CBattleInterfaceClasses.h"
#include "../CGameInfo.h"
#include "../CPlayerInterface.h"
#include "../gui/CCursorHandler.h"
#include "../gui/CGuiHandler.h"
#include "../gui/CIntObject.h"
#include "../windows/CCreatureWindow.h"
#include "../CGameInfo.h"
#include "../CPlayerInterface.h"
#include "../../CCallback.h"
#include "../../lib/CStack.h"
#include "../../lib/battle/BattleAction.h"
@ -45,7 +46,7 @@ CBattleActionsController::CBattleActionsController(CBattleInterface * owner):
creatureCasting(false),
spellDestSelectMode(false),
spellToCast(nullptr),
sp(nullptr)
currentSpell(nullptr)
{
currentAction = PossiblePlayerBattleAction::INVALID;
selectedAction = PossiblePlayerBattleAction::INVALID;
@ -57,7 +58,7 @@ void CBattleActionsController::endCastingSpell()
{
spellToCast.reset();
sp = nullptr;
currentSpell = nullptr;
spellDestSelectMode = false;
CCS->curh->changeGraphic(ECursor::COMBAT, ECursor::COMBAT_POINTER);
@ -212,8 +213,8 @@ void CBattleActionsController::castThisSpell(SpellID spellID)
//choosing possible targets
const CGHeroInstance *castingHero = (owner->attackingHeroInstance->tempOwner == owner->curInt->playerID) ? owner->attackingHeroInstance : owner->defendingHeroInstance;
assert(castingHero); // code below assumes non-null hero
sp = spellID.toSpell();
PossiblePlayerBattleAction spellSelMode = owner->curInt->cb->getCasterAction(sp, castingHero, spells::Mode::HERO);
currentSpell = spellID.toSpell();
PossiblePlayerBattleAction spellSelMode = owner->curInt->cb->getCasterAction(currentSpell, castingHero, spells::Mode::HERO);
if (spellSelMode == PossiblePlayerBattleAction::NO_LOCATION) //user does not have to select location
{
@ -498,9 +499,9 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
}
break;
case PossiblePlayerBattleAction::AIMED_SPELL_CREATURE:
sp = CGI->spellh->objects[creatureCasting ? owner->stacksController->activeStackSpellToCast() : spellToCast->actionSubtype]; //necessary if creature has random Genie spell at same time
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[27]) % sp->name % shere->getName()); //Cast %s on %s
switch (sp->id)
currentSpell = CGI->spellh->objects[creatureCasting ? owner->stacksController->activeStackSpellToCast() : spellToCast->actionSubtype]; //necessary if creature has random Genie spell at same time
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[27]) % currentSpell->name % shere->getName()); //Cast %s on %s
switch (currentSpell->id)
{
case SpellID::SACRIFICE:
case SpellID::TELEPORT:
@ -511,12 +512,12 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
isCastingPossible = true;
break;
case PossiblePlayerBattleAction::ANY_LOCATION:
sp = CGI->spellh->objects[creatureCasting ? owner->stacksController->activeStackSpellToCast() : spellToCast->actionSubtype]; //necessary if creature has random Genie spell at same time
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % sp->name); //Cast %s
currentSpell = CGI->spellh->objects[creatureCasting ? owner->stacksController->activeStackSpellToCast() : spellToCast->actionSubtype]; //necessary if creature has random Genie spell at same time
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % currentSpell->name); //Cast %s
isCastingPossible = true;
break;
case PossiblePlayerBattleAction::RANDOM_GENIE_SPELL: //we assume that teleport / sacrifice will never be available as random spell
sp = nullptr;
currentSpell = nullptr;
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[301]) % shere->getName()); //Cast a spell on %
creatureCasting = true;
isCastingPossible = true;
@ -537,7 +538,7 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
isCastingPossible = true;
break;
case PossiblePlayerBattleAction::FREE_LOCATION:
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % sp->name); //Cast %s
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % currentSpell->name); //Cast %s
isCastingPossible = true;
break;
case PossiblePlayerBattleAction::HEAL:
@ -583,7 +584,7 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
break;
case PossiblePlayerBattleAction::FREE_LOCATION:
cursorFrame = ECursor::COMBAT_BLOCKED;
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[181]) % sp->name); //No room to place %s here
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[181]) % currentSpell->name); //No room to place %s here
break;
default:
if (myNumber == -1)
@ -604,8 +605,8 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
default:
cursorType = ECursor::SPELLBOOK;
cursorFrame = 0;
if (consoleMsg.empty() && sp)
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % sp->name); //Cast %s
if (consoleMsg.empty() && currentSpell)
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % currentSpell->name); //Cast %s
break;
}
@ -615,7 +616,7 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
{
possibleActions.clear();
switch (sp->id.toEnum())
switch (currentSpell->id.toEnum())
{
case SpellID::TELEPORT: //don't cast spell yet, only select target
spellToCast->aimToUnit(shere);
@ -631,7 +632,7 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
{
if (creatureCasting)
{
if (sp)
if (currentSpell)
{
owner->giveCommand(EActionType::MONSTER_SPELL, myNumber, owner->stacksController->activeStackSpellToCast());
}
@ -642,8 +643,8 @@ void CBattleActionsController::handleHex(BattleHex myNumber, int eventType)
}
else
{
assert(sp);
switch (sp->id.toEnum())
assert(currentSpell);
switch (currentSpell->id.toEnum())
{
case SpellID::SACRIFICE:
spellToCast->aimToUnit(shere);//victim
@ -701,11 +702,11 @@ bool CBattleActionsController::isCastingPossibleHere(const CStack *sactive, cons
}
sp = nullptr;
currentSpell = nullptr;
if (spellID >= 0)
sp = CGI->spellh->objects[spellID];
currentSpell = CGI->spellh->objects[spellID];
if (sp)
if (currentSpell)
{
const spells::Caster *caster = creatureCasting ? static_cast<const spells::Caster *>(sactive) : static_cast<const spells::Caster *>(owner->curInt->cb->battleGetMyHero());
if (caster == nullptr)
@ -719,9 +720,9 @@ bool CBattleActionsController::isCastingPossibleHere(const CStack *sactive, cons
spells::Target target;
target.emplace_back(myNumber);
spells::BattleCast cast(owner->curInt->cb.get(), caster, mode, sp);
spells::BattleCast cast(owner->curInt->cb.get(), caster, mode, currentSpell);
auto m = sp->battleMechanics(&cast);
auto m = currentSpell->battleMechanics(&cast);
spells::detail::ProblemImpl problem; //todo: display problem in status bar
isCastingPossible = m->canBeCastAt(target, problem);

@ -34,7 +34,7 @@ class CBattleActionsController
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
std::shared_ptr<BattleAction> spellToCast; //spell for which player is choosing destination
const CSpell *sp; //spell pointer for convenience
const CSpell *currentSpell; //spell pointer for convenience
bool isCastingPossibleHere (const CStack *sactive, const CStack *shere, BattleHex myNumber);
bool canStackMoveHere (const CStack *sactive, BattleHex MyNumber); //TODO: move to BattleState / callback

@ -179,18 +179,23 @@ const CCreature * CAttackAnimation::getCreature()
CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, BattleHex _dest, const CStack *defender)
: CBattleStackAnimation(_owner, attacker),
shooting(false), group(CCreatureAnim::SHOOT_FRONT),
soundPlayed(false),
dest(_dest), attackedStack(defender), attackingStack(attacker)
shooting(false),
group(CCreatureAnim::SHOOT_FRONT),
soundPlayed(false),
dest(_dest),
attackedStack(defender),
attackingStack(attacker)
{
assert(attackingStack && "attackingStack is nullptr in CBattleAttack::CBattleAttack !\n");
attackingStackPosBeforeReturn = attackingStack->getPosition();
}
CDefenceAnimation::CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner)
: CBattleStackAnimation(_owner, _attackedInfo.defender),
attacker(_attackedInfo.attacker), rangedAttack(_attackedInfo.indirectAttack),
killed(_attackedInfo.killed), timeToWait(0)
: CBattleStackAnimation(_owner, _attackedInfo.defender),
attacker(_attackedInfo.attacker),
rangedAttack(_attackedInfo.indirectAttack),
killed(_attackedInfo.killed),
timeToWait(0)
{
logAnim->debug("Created defence anim for %s", _attackedInfo.defender->getName());
}
@ -323,7 +328,9 @@ CDefenceAnimation::~CDefenceAnimation()
}
CDummyAnimation::CDummyAnimation(CBattleInterface * _owner, int howManyFrames)
: CBattleAnimation(_owner), counter(0), howMany(howManyFrames)
: CBattleAnimation(_owner),
counter(0),
howMany(howManyFrames)
{
logAnim->debug("Created dummy animation for %d frames", howManyFrames);
}
@ -432,7 +439,7 @@ bool CMeleeAttackAnimation::init()
}
CMeleeAttackAnimation::CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked)
: CAttackAnimation(_owner, attacker, _dest, _attacked)
: CAttackAnimation(_owner, attacker, _dest, _attacked)
{
logAnim->debug("Created melee attack anim for %s", attacker->getName());
}
@ -599,7 +606,7 @@ CMovementEndAnimation::~CMovementEndAnimation()
}
CMovementStartAnimation::CMovementStartAnimation(CBattleInterface * _owner, const CStack * _stack)
: CBattleStackAnimation(_owner, _stack)
: CBattleStackAnimation(_owner, _stack)
{
logAnim->debug("Created movement start anim for %s", stack->getName());
}
@ -624,7 +631,9 @@ bool CMovementStartAnimation::init()
}
CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, BattleHex dest, bool _priority)
: CBattleStackAnimation(_owner, stack), hex(dest), priority(_priority)
: CBattleStackAnimation(_owner, stack),
hex(dest),
priority(_priority)
{
logAnim->debug("Created reverse anim for %s", stack->getName());
}

@ -9,20 +9,23 @@
*/
#include "StdInc.h"
#include "CBattleControlPanel.h"
#include "CBattleInterface.h"
#include "CBattleInterfaceClasses.h"
#include "CBattleStacksController.h"
#include "CBattleActionsController.h"
#include "../widgets/Buttons.h"
#include "../widgets/Images.h"
#include "../CGameInfo.h"
#include "../../lib/CGeneralTextHandler.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
#include "../CPlayerInterface.h"
#include "../../CCallback.h"
#include "../gui/CCursorHandler.h"
#include "../gui/CGuiHandler.h"
#include "../windows/CSpellWindow.h"
#include "../widgets/Buttons.h"
#include "../widgets/Images.h"
#include "../../CCallback.h"
#include "../../lib/CGeneralTextHandler.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/CStack.h"
#include "../../lib/CConfigHandler.h"

@ -15,11 +15,13 @@
#include "CBattleInterface.h"
#include "CBattleInterfaceClasses.h"
#include "CBattleStacksController.h"
#include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
#include "../CMusicHandler.h"
#include "../CGameInfo.h"
#include "../CPlayerInterface.h"
#include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
#include "../../CCallback.h"
#include "../../lib/battle/BattleAction.h"
#include "../../lib/NetPacks.h"

@ -9,19 +9,22 @@
*/
#include "StdInc.h"
#include "CBattleFieldController.h"
#include "CBattleInterface.h"
#include "CBattleActionsController.h"
#include "CBattleInterfaceClasses.h"
#include "CBattleSiegeController.h"
#include "CBattleStacksController.h"
#include "CBattleObstacleController.h"
#include "../CGameInfo.h"
#include "../../CCallback.h"
#include "../CPlayerInterface.h"
#include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
#include "../gui/CGuiHandler.h"
#include "../CPlayerInterface.h"
#include "../gui/CCursorHandler.h"
#include "../../CCallback.h"
#include "../../lib/BattleFieldHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CStack.h"

@ -9,16 +9,19 @@
*/
#include "StdInc.h"
#include "CBattleObstacleController.h"
#include "CBattleInterface.h"
#include "CBattleFieldController.h"
#include "CBattleAnimations.h"
#include "CBattleStacksController.h"
#include "../CPlayerInterface.h"
#include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
#include "../../CCallback.h"
#include "../../lib/battle/CObstacleInstance.h"
#include "../../lib/ObstacleHandler.h"
#include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
CBattleObstacleController::CBattleObstacleController(CBattleInterface * owner):
owner(owner)

@ -9,17 +9,20 @@
*/
#include "StdInc.h"
#include "CBattleProjectileController.h"
#include "../gui/Geometries.h"
#include "../../lib/CStack.h"
#include "../../lib/mapObjects/CGTownInstance.h"
#include "../CGameInfo.h"
#include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
#include "CBattleInterface.h"
#include "CBattleSiegeController.h"
#include "CBattleStacksController.h"
#include "CCreatureAnimation.h"
#include "../gui/Geometries.h"
#include "../gui/CAnimation.h"
#include "../gui/CCanvas.h"
#include "../CGameInfo.h"
#include "../../lib/CStack.h"
#include "../../lib/mapObjects/CGTownInstance.h"
static double calculateCatapultParabolaY(const Point & from, const Point & dest, int x)
{
double facA = 0.005; // seems to be constant

@ -9,6 +9,7 @@
*/
#include "StdInc.h"
#include "CBattleStacksController.h"
#include "CBattleSiegeController.h"
#include "CBattleInterfaceClasses.h"
#include "CBattleInterface.h"
@ -17,18 +18,21 @@
#include "CBattleEffectsController.h"
#include "CBattleProjectileController.h"
#include "CBattleControlPanel.h"
#include "CCreatureAnimation.h"
#include "../CPlayerInterface.h"
#include "../CMusicHandler.h"
#include "../CGameInfo.h"
#include "../gui/CAnimation.h"
#include "../gui/CGuiHandler.h"
#include "../gui/CCanvas.h"
#include "../../lib/battle/BattleHex.h"
#include "../CPlayerInterface.h"
#include "CCreatureAnimation.h"
#include "../../lib/CGameState.h"
#include "../../CCallback.h"
#include "../../lib/battle/BattleHex.h"
#include "../../lib/CGameState.h"
#include "../../lib/CStack.h"
#include "../../lib/CondSh.h"
#include "../CMusicHandler.h"
#include "../CGameInfo.h"
static void onAnimationFinished(const CStack *stack, std::weak_ptr<CCreatureAnimation> anim)
{

@ -70,7 +70,6 @@ void CCanvas::drawText(const Point & position, const EFonts & font, const SDL_Co
case ETextAlignment::CENTER: return graphics->fonts[font]->renderTextLinesCenter(surface, text, colorDest, position);
case ETextAlignment::BOTTOMRIGHT: return graphics->fonts[font]->renderTextLinesRight (surface, text, colorDest, position);
}
}
SDL_Surface * CCanvas::getSurface()