1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-15 11:46:56 +02:00

Fixed #50, #191, minor

This commit is contained in:
Michał W. Urbańczyk 2009-11-20 22:35:18 +00:00
parent adf3c9fd4b
commit 8f217c5cdf
7 changed files with 21 additions and 31 deletions

View File

@ -126,11 +126,15 @@ void AdventureMapButton::clickLeft(tribool down, bool previousState)
{ {
if(blocked) if(blocked)
return; return;
if (down) {
if (down)
{
CGI->soundh->playSound(soundBase::button); CGI->soundh->playSound(soundBase::button);
state=1; state=1;
} else }
else
state=0; state=0;
show(screenBuf); show(screenBuf);
if (actOnDown && down) if (actOnDown && down)
{ {
@ -201,25 +205,6 @@ void AdventureMapButton::hover (bool on)
} }
} }
//void AdventureMapButton::activate()
//{
//// if (active) return;
//// active=true;
// activateLClick();
// activateRClick();
// activateHover();
// activateKeys();
//}
//void AdventureMapButton::deactivate()
//{
//// if (!active) return;
//// active=false;
// deactivateLClick();
// deactivateRClick();
// deactivateHover();
// deactivateKeys();
//}
void AdventureMapButton::init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key) void AdventureMapButton::init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key)
{ {
used = LCLICK | RCLICK | HOVER | KEYBOARD; used = LCLICK | RCLICK | HOVER | KEYBOARD;

View File

@ -25,6 +25,8 @@
#include <sstream> #include <sstream>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#undef min;
/* /*
* CHeroWindow.cpp, part of VCMI engine * CHeroWindow.cpp, part of VCMI engine
* *
@ -219,7 +221,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
} }
//secondary skills support //secondary skills support
for(size_t g=0; g<hero->secSkills.size(); ++g) for(size_t g=0; g<std::min(secSkillAreas.size(),hero->secSkills.size()); ++g)
{ {
int skill = hero->secSkills[g].first, int skill = hero->secSkills[g].first,
level = hero->secSkills[g].second; level = hero->secSkills[g].second;
@ -317,7 +319,7 @@ void CHeroWindow::activate()
{ {
primSkillAreas[v]->activate(); primSkillAreas[v]->activate();
} }
for(size_t v=0; v<curHero->secSkills.size(); ++v) for(size_t v=0; v<std::min(secSkillAreas.size(), curHero->secSkills.size()); ++v)
{ {
secSkillAreas[v]->activate(); secSkillAreas[v]->activate();
} }
@ -351,7 +353,7 @@ void CHeroWindow::deactivate()
{ {
primSkillAreas[v]->deactivate(); primSkillAreas[v]->deactivate();
} }
for(size_t v=0; v<curHero->secSkills.size(); ++v) for(size_t v=0; v<std::min(secSkillAreas.size(), curHero->secSkills.size()); ++v)
{ {
secSkillAreas[v]->deactivate(); secSkillAreas[v]->deactivate();
} }

View File

@ -1250,6 +1250,8 @@ void CPlayerInterface::tileRevealed(const std::set<int3> &pos)
boost::unique_lock<boost::recursive_mutex> un(*pim); boost::unique_lock<boost::recursive_mutex> un(*pim);
for(std::set<int3>::const_iterator i=pos.begin(); i!=pos.end();i++) for(std::set<int3>::const_iterator i=pos.begin(); i!=pos.end();i++)
adventureInt->minimap.showTile(*i); adventureInt->minimap.showTile(*i);
if(pos.size())
GH.totalRedraw();
} }
void CPlayerInterface::tileHidden(const std::set<int3> &pos) void CPlayerInterface::tileHidden(const std::set<int3> &pos)

View File

@ -602,7 +602,7 @@ public:
void initObj(); void initObj();
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CGObjectInstance&>(*this) & static_cast<CPlayersVisited&>(*this);; h & static_cast<CPlayersVisited&>(*this);
h & allowedAbilities & ability; h & allowedAbilities & ability;
} }
}; };
@ -702,7 +702,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CGObjectInstance&>(*this) & static_cast<CPlayersVisited&>(*this);; h & static_cast<CPlayersVisited&>(*this);;
h & spell; h & spell;
} }
}; };
@ -904,7 +904,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CGObjectInstance&>(*this) & static_cast<CPlayersVisited&>(*this);; h & static_cast<CPlayersVisited&>(*this);;
h & bonusType & bonusVal; h & bonusType & bonusVal;
} }
}; };

View File

@ -2954,7 +2954,7 @@ void BattleInfo::getStackQueue( std::vector<const CStack *> &out, int howMany, i
const CStack * const s = stacks[i]; const CStack * const s = stacks[i];
if(turn <= 0 && !s->willMove() //we are considering current round and stack won't move if(turn <= 0 && !s->willMove() //we are considering current round and stack won't move
|| turn > 0 && !s->canMove(turn) //stack won't be able to move in later rounds || turn > 0 && !s->canMove(turn) //stack won't be able to move in later rounds
|| turn <= 0 && s == active) //it's active stack already added at the beginning of queue || turn <= 0 && s == active && out.size() && s == out.front()) //it's active stack already added at the beginning of queue
{ {
continue; continue;
} }

View File

@ -657,7 +657,6 @@ DLL_EXPORT void BattleSetActiveStack::applyGs( CGameState *gs )
{ {
gs->curB->activeStack = stack; gs->curB->activeStack = stack;
CStack *st = gs->curB->getStack(stack); CStack *st = gs->curB->getStack(stack);
st->state -= WAITING; //if stack was waiting it'll now make move, so it won't be "waiting" anymore
if(vstd::contains(st->state,MOVED)) //if stack is moving second time this turn it must had a high morale bonus if(vstd::contains(st->state,MOVED)) //if stack is moving second time this turn it must had a high morale bonus
st->state.insert(HAD_MORALE); st->state.insert(HAD_MORALE);
} }
@ -743,11 +742,13 @@ DLL_EXPORT void StartAction::applyGs( CGameState *gs )
break; break;
case 8: case 8:
st->state.insert(WAITING); st->state.insert(WAITING);
break; return;
case 2: case 6: case 7: case 9: case 10: case 11: case 2: case 6: case 7: case 9: case 10: case 11:
st->state.insert(MOVED); st->state.insert(MOVED);
break; break;
} }
st->state -= WAITING; //if stack was waiting it has made move, so it won't be "waiting" anymore (if the action was WAIT, then we have returned)
} }
DLL_EXPORT void SpellCast::applyGs( CGameState *gs ) DLL_EXPORT void SpellCast::applyGs( CGameState *gs )

View File

@ -2384,7 +2384,7 @@ bool CGameHandler::buyArtifact( ui32 hid, si32 aid )
if(vstd::contains(hero->artifWorn,ui16(9+aid)) && complain("Hero already has this machine!") if(vstd::contains(hero->artifWorn,ui16(9+aid)) && complain("Hero already has this machine!")
|| !vstd::contains(town->builtBuildings,si32(16)) && complain("No blackismith!") || !vstd::contains(town->builtBuildings,si32(16)) && complain("No blackismith!")
|| gs->getPlayer(hero->getOwner())->resources[6] < price && complain("Not enough gold!") //no gold || gs->getPlayer(hero->getOwner())->resources[6] < price && complain("Not enough gold!") //no gold
|| town->town->warMachine!= aid && complain("This machine is unavailale here!") ) //TODO: ballista yard in Stronghold || town->town->warMachine!= aid && complain("This machine is unavailable here!") ) //TODO: ballista yard in Stronghold
{ {
return false; return false;
} }