1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* minor refactoring

This commit is contained in:
mateuszb 2013-01-31 20:11:25 +00:00
parent 4ae4b998a3
commit a1da195b85
8 changed files with 24 additions and 22 deletions

View File

@ -564,7 +564,7 @@ bool CMovementStartAnimation::init()
return false;
if(!stack || myAnim()->getType() == 5)
if(!stack || myAnim()->getType() == CCreatureAnim::DEATH)
{
CMovementStartAnimation::endAnim();
return false;
@ -602,7 +602,7 @@ CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * s
bool CReverseAnimation::init()
{
if(myAnim() == NULL || myAnim()->getType() == 5)
if(myAnim() == NULL || myAnim()->getType() == CCreatureAnim::DEATH)
{
endAnim();
@ -699,7 +699,7 @@ bool CShootingAnimation::init()
const CStack * shooter = attackingStack;
if(!shooter || myAnim()->getType() == 5)
if(!shooter || myAnim()->getType() == CCreatureAnim::DEATH)
{
endAnim();
return false;

View File

@ -581,7 +581,7 @@ void CBattleInterface::show(SDL_Surface * to)
SDL_SetClipRect(to, &pos);
//printing background and hexes
if(activeStack != NULL && creAnims[activeStack->ID]->getType() != 0) //show everything with range
if(activeStack != NULL && creAnims[activeStack->ID]->getType() != CCreatureAnim::MOVING) //show everything with range
{
blitAt(backgroundWithHexes, pos.x, pos.y, to);
}
@ -711,7 +711,7 @@ void CBattleInterface::show(SDL_Surface * to)
const CStack *s = stacks[i];
if(creAnims.find(s->ID) == creAnims.end()) //e.g. for summoned but not yet handled stacks
continue;
if(creAnims[s->ID]->getType() != 5 && s->position >= 0) //don't show turrets here
if(creAnims[s->ID]->getType() != CCreatureAnim::DEATH && s->position >= 0) //don't show turrets here
stackAliveByHex[s->position].push_back(s);
}
std::vector<const CStack *> stackDeadByHex[GameConstants::BFIELD_SIZE];
@ -720,7 +720,7 @@ void CBattleInterface::show(SDL_Surface * to)
const CStack *s = stacks[i];
if(creAnims.find(s->ID) == creAnims.end()) //e.g. for summoned but not yet handled stacks
continue;
if(creAnims[s->ID]->getType() == 5)
if(creAnims[s->ID]->getType() == CCreatureAnim::DEATH)
stackDeadByHex[s->position].push_back(s);
}
@ -956,7 +956,7 @@ void CBattleInterface::showAliveStacks(std::vector<const CStack *> *aliveStacks,
{
const CStack *s = aliveStacks[hex][v];
if(!s->hasBonusOfType(Bonus::FLYING) || creAnims[s->ID]->getType() != 0)
if(!s->hasBonusOfType(Bonus::FLYING) || creAnims[s->ID]->getType() != CCreatureAnim::DEATH)
showAliveStack(s, to);
else
flyingStacks->push_back(s);
@ -2171,12 +2171,13 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
const CCreature *creature = stack->getCreature();
SDL_Rect unitRect = {creAnims[ID]->pos.x, creAnims[ID]->pos.y, uint16_t(creAnims[ID]->fullWidth), uint16_t(creAnims[ID]->fullHeight)};
int animType = creAnims[ID]->getType();
CCreatureAnim::EAnimType animType = creAnims[ID]->getType();
int affectingSpeed = getAnimSpeed();
if(animType == 1 || animType == 2) //standing stacks should not stand faster :)
if(animType == CCreatureAnim::MOUSEON || animType == CCreatureAnim::HOLDING) //standing stacks should not stand faster :)
affectingSpeed = 2;
bool incrementFrame = (animCount%(4/affectingSpeed)==0) && animType!=5 && animType!=20 && animType!=2;
bool incrementFrame = (animCount%(4/affectingSpeed)==0) && animType!=CCreatureAnim::DEATH &&
animType!=CCreatureAnim::MOVE_START && animType!=CCreatureAnim::HOLDING;
if (creature->idNumber == 149)
{
@ -2186,7 +2187,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
else
{
// standing animation
if(animType == 2)
if(animType == CCreatureAnim::HOLDING)
{
if(standingFrame.find(ID)!=standingFrame.end())
{
@ -2521,7 +2522,8 @@ void CBattleInterface::endAction(const BattleAction* action)
attackingHero->setPhase(0);
}
if(stack && action->actionType == BattleAction::WALK && creAnims[action->stackNumber]->getType() != 2) //walk or walk & attack
if(stack && action->actionType == BattleAction::WALK &&
creAnims[action->stackNumber]->getType() != CCreatureAnim::HOLDING) //walk or walk & attack
{
pendingAnims.push_back(std::make_pair(new CMovementEndAnimation(this, stack, action->destinationTile), false));
}

View File

@ -1141,7 +1141,7 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
switch(spellBeingCasted->id)
{
case Spells::SCUTTLE_BOAT: //Scuttle Boat
if(topBlocking && topBlocking->ID == 8)
if(topBlocking && topBlocking->ID == Obj::BOAT)
leaveCastingMode(true, mapPos);
break;
case Spells::DIMENSION_DOOR:

View File

@ -2586,9 +2586,9 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan
{
switch (market->o->ID)
{
break; case 7: title = CGI->generaltexth->allTexts[349];
break; case 99: title = CGI->generaltexth->allTexts[159];
break; case 221: title = CGI->generaltexth->allTexts[159];
break; case Obj::BLACK_MARKET: title = CGI->generaltexth->allTexts[349];
break; case Obj::TRADING_POST: title = CGI->generaltexth->allTexts[159];
break; case Obj::TRADING_POST_SNOW: title = CGI->generaltexth->allTexts[159];
break; default: title = market->o->getHoverText();
}
}

View File

@ -547,7 +547,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
: static_cast<const CGHeroInstance*>(obj));
//print hero / boat and flag
if((themp && themp->moveDir && themp->type) || (obj->ID == 8)) //it's hero or boat
if((themp && themp->moveDir && themp->type) || (obj->ID == Obj::BOAT)) //it's hero or boat
{
const int IMGVAL = 8; //frames per group of movement animation
ui8 dir;

View File

@ -1123,7 +1123,7 @@ void CGHeroInstance::initObj() //TODO: use bonus system
//initialize bonuses
BOOST_FOREACH(auto skill_info, secSkills)
updateSkill(skill_info.first, skill_info.second);
updateSkill(static_cast<CGHeroInstance::SecondarySkill>(skill_info.first), skill_info.second);
Updatespecialty();
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
@ -1184,7 +1184,7 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse
}
}
}
void CGHeroInstance::updateSkill(int which, int val)
void CGHeroInstance::updateSkill(SecondarySkill which, int val)
{
if(which == LEADERSHIP || which == LUCK)
{ //luck-> VLC->generaltexth->arraytxt[73+luckSkill]; VLC->generaltexth->arraytxt[104+moraleSkill]

View File

@ -417,7 +417,7 @@ public:
void initHeroDefInfo();
void pushPrimSkill(int which, int val);
void Updatespecialty();
void updateSkill(int which, int val);
void updateSkill(SecondarySkill which, int val);
CGHeroInstance();
virtual ~CGHeroInstance();

View File

@ -1669,7 +1669,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
//OR hero is on land and dest is water and (there is not present only one object - boat)
if(((t.terType == ETerrainType::ROCK || (t.blocked && !t.visitable && !h->hasBonusOfType(Bonus::FLYING_MOVEMENT) ))
&& complain("Cannot move hero, destination tile is blocked!"))
|| ((!h->boat && !h->canWalkOnSea() && t.terType == ETerrainType::WATER && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != 8 && t.visitableObjects.back()->ID != Obj::HERO))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
|| ((!h->boat && !h->canWalkOnSea() && t.terType == ETerrainType::WATER && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != Obj::BOAT && t.visitableObjects.back()->ID != Obj::HERO))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
&& complain("Cannot move hero, destination tile is on water!"))
|| ((h->boat && t.terType != ETerrainType::WATER && t.blocked)
&& complain("Cannot disembark hero, tile is blocked!"))