mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
MSVC compile fix #997.
CClickableHex apparently can't be held by value in vector anymore.
This commit is contained in:
parent
5dff7d64f6
commit
f378e5be31
@ -970,7 +970,7 @@ bool CSpellEffectAnimation::init()
|
|||||||
if(effect == -1 || graphics->battleACToDef[effect].size() != 0)
|
if(effect == -1 || graphics->battleACToDef[effect].size() != 0)
|
||||||
{
|
{
|
||||||
const CStack* destStack = owner->curInt->cb->battleGetStackByPos(destTile, false);
|
const CStack* destStack = owner->curInt->cb->battleGetStackByPos(destTile, false);
|
||||||
Rect &tilePos = owner->bfield[destTile].pos;
|
Rect &tilePos = owner->bfield[destTile]->pos;
|
||||||
BattleEffect be;
|
BattleEffect be;
|
||||||
be.effectID = ID;
|
be.effectID = ID;
|
||||||
if(customAnim.size())
|
if(customAnim.size())
|
||||||
|
@ -94,7 +94,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
|||||||
: queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
|
: queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
|
||||||
activeStack(NULL), stackToActivate(NULL), selectedStack(NULL), mouseHoveredStack(-1), lastMouseHoveredStackAnimationTime(-1), previouslyHoveredHex(-1),
|
activeStack(NULL), stackToActivate(NULL), selectedStack(NULL), mouseHoveredStack(-1), lastMouseHoveredStackAnimationTime(-1), previouslyHoveredHex(-1),
|
||||||
currentlyHoveredHex(-1), attackingHex(-1), tacticianInterface(NULL), stackCanCastSpell(false), creatureCasting(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(NULL), sp(NULL),
|
currentlyHoveredHex(-1), attackingHex(-1), tacticianInterface(NULL), stackCanCastSpell(false), creatureCasting(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(NULL), sp(NULL),
|
||||||
siegeH(NULL), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0), bfield(GameConstants::BFIELD_SIZE),
|
siegeH(NULL), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0),
|
||||||
givenCommand(NULL), myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL)
|
givenCommand(NULL), myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -267,17 +267,19 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
|||||||
CSDL_Ext::alphaTransform(cellBorder);
|
CSDL_Ext::alphaTransform(cellBorder);
|
||||||
cellShade = BitmapHandler::loadBitmap("CCELLSHD.BMP");
|
cellShade = BitmapHandler::loadBitmap("CCELLSHD.BMP");
|
||||||
CSDL_Ext::alphaTransform(cellShade);
|
CSDL_Ext::alphaTransform(cellShade);
|
||||||
for(int h = 0; h < bfield.size(); ++h)
|
for(int h = 0; h < GameConstants::BFIELD_SIZE; ++h)
|
||||||
{
|
{
|
||||||
bfield[h].myNumber = h;
|
CClickableHex *hex = new CClickableHex();
|
||||||
bfield[h].pos = hexPosition(h);
|
hex->myNumber = h;
|
||||||
bfield[h].accessible = true;
|
hex->pos = hexPosition(h);
|
||||||
bfield[h].myInterface = this;
|
hex->accessible = true;
|
||||||
|
hex->myInterface = this;
|
||||||
|
bfield.push_back(hex);
|
||||||
}
|
}
|
||||||
//locking occupied positions on batlefield
|
//locking occupied positions on batlefield
|
||||||
BOOST_FOREACH(const CStack *s, stacks) //stacks gained at top of this function
|
BOOST_FOREACH(const CStack *s, stacks) //stacks gained at top of this function
|
||||||
if(s->position >= 0) //turrets have position < 0
|
if(s->position >= 0) //turrets have position < 0
|
||||||
bfield[s->position].accessible = false;
|
bfield[s->position]->accessible = false;
|
||||||
|
|
||||||
//loading projectiles for units
|
//loading projectiles for units
|
||||||
BOOST_FOREACH(const CStack *s, stacks)
|
BOOST_FOREACH(const CStack *s, stacks)
|
||||||
@ -361,10 +363,8 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
|||||||
smallForceField[0] = CDefHandler::giveDef("C15SPE1.DEF");
|
smallForceField[0] = CDefHandler::giveDef("C15SPE1.DEF");
|
||||||
smallForceField[1] = CDefHandler::giveDef("C15SPE4.DEF");
|
smallForceField[1] = CDefHandler::giveDef("C15SPE4.DEF");
|
||||||
|
|
||||||
for (int i = 0; i < bfield.size(); i++)
|
BOOST_FOREACH(auto hex, bfield)
|
||||||
{
|
addChild(hex);
|
||||||
addChild(&bfield[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tacticsMode)
|
if(tacticsMode)
|
||||||
bTacticNextStack();
|
bTacticNextStack();
|
||||||
@ -405,6 +405,10 @@ CBattleInterface::~CBattleInterface()
|
|||||||
delete bSpell;
|
delete bSpell;
|
||||||
delete bWait;
|
delete bWait;
|
||||||
delete bDefence;
|
delete bDefence;
|
||||||
|
|
||||||
|
BOOST_FOREACH(auto hex, bfield)
|
||||||
|
delete hex;
|
||||||
|
|
||||||
delete bConsoleUp;
|
delete bConsoleUp;
|
||||||
delete bConsoleDown;
|
delete bConsoleDown;
|
||||||
delete console;
|
delete console;
|
||||||
@ -481,10 +485,10 @@ void CBattleInterface::activate()
|
|||||||
bSpell->activate();
|
bSpell->activate();
|
||||||
bWait->activate();
|
bWait->activate();
|
||||||
bDefence->activate();
|
bDefence->activate();
|
||||||
for(int b=0; b<GameConstants::BFIELD_SIZE; ++b)
|
|
||||||
{
|
BOOST_FOREACH(auto hex, bfield)
|
||||||
bfield[b].activate();
|
hex->activate();
|
||||||
}
|
|
||||||
if(attackingHero)
|
if(attackingHero)
|
||||||
attackingHero->activate();
|
attackingHero->activate();
|
||||||
if(defendingHero)
|
if(defendingHero)
|
||||||
@ -517,10 +521,10 @@ void CBattleInterface::deactivate()
|
|||||||
bSpell->deactivate();
|
bSpell->deactivate();
|
||||||
bWait->deactivate();
|
bWait->deactivate();
|
||||||
bDefence->deactivate();
|
bDefence->deactivate();
|
||||||
for(int b=0; b<GameConstants::BFIELD_SIZE; ++b)
|
|
||||||
{
|
BOOST_FOREACH(auto hex, bfield)
|
||||||
bfield[b].deactivate();
|
hex->deactivate();
|
||||||
}
|
|
||||||
if(attackingHero)
|
if(attackingHero)
|
||||||
attackingHero->deactivate();
|
attackingHero->deactivate();
|
||||||
if(defendingHero)
|
if(defendingHero)
|
||||||
@ -579,7 +583,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
|||||||
//printing hovered cell
|
//printing hovered cell
|
||||||
for(int b=0; b<GameConstants::BFIELD_SIZE; ++b)
|
for(int b=0; b<GameConstants::BFIELD_SIZE; ++b)
|
||||||
{
|
{
|
||||||
if(bfield[b].strictHovered && bfield[b].hovered)
|
if(bfield[b]->strictHovered && bfield[b]->hovered)
|
||||||
{
|
{
|
||||||
if(previouslyHoveredHex == -1) previouslyHoveredHex = b; //something to start with
|
if(previouslyHoveredHex == -1) previouslyHoveredHex = b; //something to start with
|
||||||
if(currentlyHoveredHex == -1) currentlyHoveredHex = b; //something to start with
|
if(currentlyHoveredHex == -1) currentlyHoveredHex = b; //something to start with
|
||||||
@ -972,17 +976,17 @@ void CBattleInterface::keyPressed(const SDL_KeyboardEvent & key)
|
|||||||
}
|
}
|
||||||
void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||||
{
|
{
|
||||||
auto hexItr = std::find_if(bfield.begin(), bfield.end(), [](const CClickableHex &hex)
|
auto hexItr = std::find_if(bfield.begin(), bfield.end(), [](const CClickableHex *hex)
|
||||||
{
|
{
|
||||||
return hex.hovered && hex.strictHovered;
|
return hex->hovered && hex->strictHovered;
|
||||||
});
|
});
|
||||||
|
|
||||||
handleHex(hexItr == bfield.end() ? -1 : hexItr->myNumber, MOVE);
|
handleHex(hexItr == bfield.end() ? -1 : (*hexItr)->myNumber, MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleInterface::setBattleCursor(const int myNumber)
|
void CBattleInterface::setBattleCursor(const int myNumber)
|
||||||
{
|
{
|
||||||
const CClickableHex & hoveredHex = bfield[myNumber];
|
const CClickableHex & hoveredHex = *bfield[myNumber];
|
||||||
CCursorHandler *cursor = CCS->curh;
|
CCursorHandler *cursor = CCS->curh;
|
||||||
|
|
||||||
const double subdividingAngle = 2.0*M_PI/6.0; // Divide a hex into six sectors.
|
const double subdividingAngle = 2.0*M_PI/6.0; // Divide a hex into six sectors.
|
||||||
|
@ -215,7 +215,7 @@ public:
|
|||||||
void setAnimSpeed(int set); //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
|
void setAnimSpeed(int set); //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
|
||||||
int getAnimSpeed() const; //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
|
int getAnimSpeed() const; //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
|
||||||
|
|
||||||
std::vector<CClickableHex> bfield; //11 lines, 17 hexes on each
|
std::vector<CClickableHex*> bfield; //11 lines, 17 hexes on each
|
||||||
//std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield
|
//std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield
|
||||||
SDL_Surface * cellBorder, * cellShade;
|
SDL_Surface * cellBorder, * cellShade;
|
||||||
CondSh<BattleAction *> *givenCommand; //data != NULL if we have i.e. moved current unit
|
CondSh<BattleAction *> *givenCommand; //data != NULL if we have i.e. moved current unit
|
||||||
|
@ -198,7 +198,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
|
|||||||
{
|
{
|
||||||
for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
|
for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
|
||||||
{
|
{
|
||||||
if(myOwner->bfield[it].hovered && myOwner->bfield[it].strictHovered)
|
if(myOwner->bfield[it]->hovered && myOwner->bfield[it]->strictHovered)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CCS->curh->changeGraphic(0,0);
|
CCS->curh->changeGraphic(0,0);
|
||||||
|
Loading…
Reference in New Issue
Block a user