mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Several minor fixes.
This commit is contained in:
parent
8bda10b695
commit
3111a904ae
@ -1483,7 +1483,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
||||
return;
|
||||
case SDLK_s:
|
||||
if(isActive())
|
||||
GH.pushInt(new CSavingScreen);
|
||||
GH.pushInt(new CSavingScreen(CPlayerInterface::howManyPeople > 1));
|
||||
return;
|
||||
case SDLK_d:
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ CBattleInterface * CPlayerInterface::battleInt;
|
||||
enum EMoveState {STOP_MOVE, WAITING_MOVE, CONTINUE_MOVE, DURING_MOVE};
|
||||
CondSh<EMoveState> stillMoveHero; //used during hero movement
|
||||
|
||||
int howManyPeople = 0;
|
||||
int CPlayerInterface::howManyPeople = 0;
|
||||
|
||||
|
||||
struct OCM_HLP_CGIN
|
||||
|
@ -118,6 +118,7 @@ public:
|
||||
int firstCall; // -1 - just loaded game; 1 - just started game; 0 otherwise
|
||||
int autosaveCount;
|
||||
static const int SAVES_COUNT = 5;
|
||||
static int howManyPeople;
|
||||
|
||||
SystemOptions sysOpts;
|
||||
|
||||
|
@ -2502,8 +2502,8 @@ void CBonusSelection::CRegion::show( SDL_Surface * to )
|
||||
}
|
||||
}
|
||||
|
||||
CSavingScreen::CSavingScreen()
|
||||
: CSelectionScreen(CMenuScreen::saveGame)
|
||||
CSavingScreen::CSavingScreen(bool hotseat)
|
||||
: CSelectionScreen(CMenuScreen::saveGame, hotseat)
|
||||
{
|
||||
ourGame = mapInfoFromGame();
|
||||
sInfo = *LOCPLINT->cb->getStartInfo();
|
||||
|
@ -230,7 +230,7 @@ public:
|
||||
const CMapInfo *ourGame;
|
||||
|
||||
|
||||
CSavingScreen();
|
||||
CSavingScreen(bool hotseat = false);
|
||||
~CSavingScreen();
|
||||
};
|
||||
|
||||
|
@ -3134,7 +3134,7 @@ void CSystemOptionsWindow::bmainmenuf()
|
||||
void CSystemOptionsWindow::bsavef()
|
||||
{
|
||||
GH.popIntTotally(this);
|
||||
GH.pushInt(new CSavingScreen);
|
||||
GH.pushInt(new CSavingScreen(CPlayerInterface::howManyPeople > 1));
|
||||
/*using namespace boost::posix_time;
|
||||
std::ostringstream fnameStream;
|
||||
fnameStream << second_clock::local_time();
|
||||
|
@ -1752,7 +1752,7 @@ void CGameState::getNeighbours( const TerrainTile &srct, int3 tile, std::vector<
|
||||
const TerrainTile &hlpt = map->getTile(hlp);
|
||||
|
||||
//we cannot visit things from blocked tiles
|
||||
if(srct.blocked && hlpt.visitable && srct.blockingObjects.front()->ID != HEROI_TYPE)
|
||||
if(srct.blocked && !srct.visitable && hlpt.visitable && srct.blockingObjects.front()->ID != HEROI_TYPE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -2289,27 +2289,40 @@ void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int
|
||||
*/
|
||||
int3 CGameState::guardingCreaturePosition (int3 pos) const
|
||||
{
|
||||
const int3 originalPos = pos;
|
||||
// Give monster at position priority.
|
||||
if (!map->isInTheMap(pos))
|
||||
return int3(-1, -1, -1);
|
||||
const TerrainTile &posTile = map->terrain[pos.x][pos.y][pos.z];
|
||||
if (posTile.visitable) {
|
||||
BOOST_FOREACH (CGObjectInstance* obj, posTile.visitableObjects) {
|
||||
if (obj->ID == 54) { // Monster
|
||||
return pos;
|
||||
if (posTile.visitable)
|
||||
{
|
||||
BOOST_FOREACH (CGObjectInstance* obj, posTile.visitableObjects)
|
||||
{
|
||||
if(obj->blockVisit)
|
||||
{
|
||||
if (obj->ID == 54) // Monster
|
||||
return pos;
|
||||
else
|
||||
return int3(-1, -1, -1); //blockvis objects are not guarded by neighbouring creatures
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See if there are any monsters adjacent.
|
||||
pos -= int3(1, 1, 0); // Start with top left.
|
||||
for (int dx = 0; dx < 3; dx++) {
|
||||
for (int dy = 0; dy < 3; dy++) {
|
||||
if (map->isInTheMap(pos)) {
|
||||
for (int dx = 0; dx < 3; dx++)
|
||||
{
|
||||
for (int dy = 0; dy < 3; dy++)
|
||||
{
|
||||
if (map->isInTheMap(pos))
|
||||
{
|
||||
TerrainTile &tile = map->terrain[pos.x][pos.y][pos.z];
|
||||
if (tile.visitable) {
|
||||
BOOST_FOREACH (CGObjectInstance* obj, tile.visitableObjects) {
|
||||
if (obj->ID == 54) { // Monster
|
||||
if (tile.visitable)
|
||||
{
|
||||
BOOST_FOREACH (CGObjectInstance* obj, tile.visitableObjects)
|
||||
{
|
||||
if (obj->ID == 54 && checkForVisitableDir(pos, &map->getTile(originalPos), originalPos)) // Monster being able to attack investigated tile
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
@ -1935,8 +1935,8 @@ void Mapa::readObjects( const unsigned char * bufor, int &i)
|
||||
nobj->tempOwner = readNormalNr(bufor,i); i+=4;
|
||||
break;
|
||||
}
|
||||
case 2: //Altar of Sacrifice
|
||||
case 7: //Black Market
|
||||
//case 2: //Altar of Sacrifice
|
||||
//case 7: //Black Market
|
||||
case 99: //Trading Post
|
||||
case 213: //Freelancer's Guild
|
||||
case 221: //Trading Post (snow)
|
||||
|
@ -623,6 +623,12 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
||||
}
|
||||
}
|
||||
|
||||
if(visitObjectAfterVictory && winnerHero == hero1)
|
||||
{
|
||||
visitObjectOnTile(*getTile(winnerHero->getPosition()), winnerHero);
|
||||
}
|
||||
visitObjectAfterVictory = false;
|
||||
|
||||
winLoseHandle(1<<sides[0] | 1<<sides[1]); //handle victory/loss of engaged players
|
||||
delete battleResult.data;
|
||||
}
|
||||
@ -870,6 +876,7 @@ CGameHandler::CGameHandler(void)
|
||||
gs = NULL;
|
||||
IObjectInterface::cb = this;
|
||||
applier = new CGHApplier;
|
||||
visitObjectAfterVictory = false;
|
||||
}
|
||||
|
||||
CGameHandler::~CGameHandler(void)
|
||||
@ -1734,23 +1741,17 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
|
||||
{
|
||||
const TerrainTile &guardTile = gs->map->terrain[guardPos.x][guardPos.y][guardPos.z];
|
||||
objectVisited(guardTile.visitableObjects.back(), h);
|
||||
|
||||
// TODO: Need to wait until battle is over.
|
||||
|
||||
// Do not visit anything else if hero died.
|
||||
if (h->getArmy().stacksCount() == 0)
|
||||
return true;
|
||||
visitObjectAfterVictory = true;
|
||||
//
|
||||
// // TODO: Need to wait until battle is over.
|
||||
//
|
||||
// // Do not visit anything else if hero died.
|
||||
// if (h->getArmy().stacksCount() == 0)
|
||||
// return true;
|
||||
}
|
||||
|
||||
//call objects if they are visited
|
||||
|
||||
if(t.visitableObjects.size())
|
||||
else if(t.visitableObjects.size()) //call objects if they are visited
|
||||
{
|
||||
//to prevent self-visiting heroes on space press
|
||||
if(t.visitableObjects.back() != h)
|
||||
objectVisited(t.visitableObjects.back(), h);
|
||||
else if(t.visitableObjects.size() > 1)
|
||||
objectVisited(*(t.visitableObjects.end()-2),h);
|
||||
visitObjectOnTile(t, h);
|
||||
}
|
||||
// BOOST_FOREACH(CGObjectInstance *obj, t.visitableObjects)
|
||||
// {
|
||||
@ -4603,3 +4604,12 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, int spellID, const int3 &p
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGameHandler::visitObjectOnTile(const TerrainTile &t, const CGHeroInstance * h)
|
||||
{
|
||||
//to prevent self-visiting heroes on space press
|
||||
if(t.visitableObjects.back() != h)
|
||||
objectVisited(t.visitableObjects.back(), h);
|
||||
else if(t.visitableObjects.size() > 1)
|
||||
objectVisited(*(t.visitableObjects.end()-2),h);
|
||||
}
|
@ -98,6 +98,7 @@ public:
|
||||
////used only in endBattle - don't touch elsewhere
|
||||
boost::function<void(BattleResult*)> * battleEndCallback;
|
||||
const CArmedInstance * bEndArmy1, * bEndArmy2;
|
||||
bool visitObjectAfterVictory;
|
||||
//
|
||||
void endBattle(int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2); //ends battle
|
||||
void prepareAttack(BattleAttack &bat, const CStack *att, const CStack *def, int distance); //distance - number of hexes travelled before attacking
|
||||
@ -144,6 +145,8 @@ public:
|
||||
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false); //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle//void startBattleI(int heroID, CCreatureSet army, int3 tile, boost::function<void(BattleResult*)> cb); //for hero<=>neutral army
|
||||
void setAmount(int objid, ui32 val);
|
||||
bool moveHero(si32 hid, int3 dst, ui8 instant, ui8 asker = 255);
|
||||
|
||||
void visitObjectOnTile(const TerrainTile &t, const CGHeroInstance * h);
|
||||
void giveHeroBonus(GiveBonus * bonus);
|
||||
void setMovePoints(SetMovePoints * smp);
|
||||
void setManaPoints(int hid, int val);
|
||||
|
Loading…
Reference in New Issue
Block a user