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