mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Merge pull request #2988 from IvanSavenko/configurable_extensions
Extension of configurable object functionality
This commit is contained in:
@@ -858,7 +858,7 @@ void CGameHandler::onNewTurn()
|
||||
if (player != PlayerColor::NEUTRAL) //do not reveal fow for neutral player
|
||||
{
|
||||
FoWChange fw;
|
||||
fw.mode = 1;
|
||||
fw.mode = ETileVisibility::REVEALED;
|
||||
fw.player = player;
|
||||
// find all hidden tiles
|
||||
const auto fow = getPlayerTeam(player)->fogOfWarMap;
|
||||
@@ -879,7 +879,7 @@ void CGameHandler::onNewTurn()
|
||||
{
|
||||
if (getPlayerStatus(player.first) == EPlayerStatus::INGAME &&
|
||||
getPlayerRelations(player.first, t->tempOwner) == PlayerRelations::ENEMIES)
|
||||
changeFogOfWar(t->visitablePos(), t->getBonusLocalFirst(Selector::type()(BonusType::DARKNESS))->val, player.first, true);
|
||||
changeFogOfWar(t->visitablePos(), t->getBonusLocalFirst(Selector::type()(BonusType::DARKNESS))->val, player.first, ETileVisibility::HIDDEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1174,7 +1174,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
||||
{
|
||||
obj->onHeroLeave(h);
|
||||
}
|
||||
this->getTilesInRange(tmh.fowRevealed, h->getSightCenter()+(tmh.end-tmh.start), h->getSightRadius(), h->tempOwner, 1);
|
||||
this->getTilesInRange(tmh.fowRevealed, h->getSightCenter()+(tmh.end-tmh.start), h->getSightRadius(), ETileVisibility::HIDDEN, h->tempOwner);
|
||||
};
|
||||
|
||||
auto doMove = [&](TryMoveHero::EResult result, EGuardLook lookForGuards,
|
||||
@@ -1523,7 +1523,7 @@ void CGameHandler::giveHero(ObjectInstanceID id, PlayerColor player, ObjectInsta
|
||||
|
||||
//Reveal fow around new hero, especially released from Prison
|
||||
auto h = getHero(id);
|
||||
changeFogOfWar(h->pos, h->getSightRadius(), player, false);
|
||||
changeFogOfWar(h->pos, h->getSightRadius(), player, ETileVisibility::REVEALED);
|
||||
}
|
||||
|
||||
void CGameHandler::changeObjPos(ObjectInstanceID objid, int3 newPos, const PlayerColor & initiator)
|
||||
@@ -2387,11 +2387,7 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
|
||||
processAfterBuiltStructure(builtID);
|
||||
|
||||
// now when everything is built - reveal tiles for lookout tower
|
||||
FoWChange fw;
|
||||
fw.player = t->tempOwner;
|
||||
fw.mode = 1;
|
||||
getTilesInRange(fw.tiles, t->getSightCenter(), t->getSightRadius(), t->tempOwner, 1);
|
||||
sendAndApply(&fw);
|
||||
changeFogOfWar(t->getSightCenter(), t->getSightRadius(), t->getOwner(), ETileVisibility::REVEALED);
|
||||
|
||||
if(t->visitingHero)
|
||||
visitCastleObjects(t, t->visitingHero);
|
||||
@@ -4061,10 +4057,7 @@ void CGameHandler::spawnWanderingMonsters(CreatureID creatureID)
|
||||
void CGameHandler::synchronizeArtifactHandlerLists()
|
||||
{
|
||||
UpdateArtHandlerLists uahl;
|
||||
uahl.treasures = VLC->arth->treasures;
|
||||
uahl.minors = VLC->arth->minors;
|
||||
uahl.majors = VLC->arth->majors;
|
||||
uahl.relics = VLC->arth->relics;
|
||||
uahl.allocatedArtifacts = VLC->arth->allocatedArtifacts;
|
||||
sendAndApply(&uahl);
|
||||
}
|
||||
|
||||
@@ -4111,34 +4104,40 @@ void CGameHandler::removeAfterVisit(const CGObjectInstance *object)
|
||||
assert("This function needs to be called during the object visit!");
|
||||
}
|
||||
|
||||
void CGameHandler::changeFogOfWar(int3 center, ui32 radius, PlayerColor player, bool hide)
|
||||
void CGameHandler::changeFogOfWar(int3 center, ui32 radius, PlayerColor player, ETileVisibility mode)
|
||||
{
|
||||
std::unordered_set<int3> tiles;
|
||||
getTilesInRange(tiles, center, radius, player, hide? -1 : 1);
|
||||
if (hide)
|
||||
|
||||
if (mode == ETileVisibility::HIDDEN)
|
||||
{
|
||||
getTilesInRange(tiles, center, radius, ETileVisibility::REVEALED, player);
|
||||
|
||||
std::unordered_set<int3> observedTiles; //do not hide tiles observed by heroes. May lead to disastrous AI problems
|
||||
auto p = getPlayerState(player);
|
||||
for (auto h : p->heroes)
|
||||
{
|
||||
getTilesInRange(observedTiles, h->getSightCenter(), h->getSightRadius(), h->tempOwner, -1);
|
||||
getTilesInRange(observedTiles, h->getSightCenter(), h->getSightRadius(), ETileVisibility::REVEALED, h->tempOwner);
|
||||
}
|
||||
for (auto t : p->towns)
|
||||
{
|
||||
getTilesInRange(observedTiles, t->getSightCenter(), t->getSightRadius(), t->tempOwner, -1);
|
||||
getTilesInRange(observedTiles, t->getSightCenter(), t->getSightRadius(), ETileVisibility::REVEALED, t->tempOwner);
|
||||
}
|
||||
for (auto tile : observedTiles)
|
||||
vstd::erase_if_present (tiles, tile);
|
||||
}
|
||||
changeFogOfWar(tiles, player, hide);
|
||||
else
|
||||
{
|
||||
getTilesInRange(tiles, center, radius, ETileVisibility::HIDDEN, player);
|
||||
}
|
||||
changeFogOfWar(tiles, player, mode);
|
||||
}
|
||||
|
||||
void CGameHandler::changeFogOfWar(std::unordered_set<int3> &tiles, PlayerColor player, bool hide)
|
||||
void CGameHandler::changeFogOfWar(std::unordered_set<int3> &tiles, PlayerColor player, ETileVisibility mode)
|
||||
{
|
||||
FoWChange fow;
|
||||
fow.tiles = tiles;
|
||||
fow.player = player;
|
||||
fow.mode = hide? 0 : 1;
|
||||
fow.mode = mode;
|
||||
sendAndApply(&fow);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,8 +148,8 @@ public:
|
||||
void changeObjPos(ObjectInstanceID objid, int3 newPos, const PlayerColor & initiator) override;
|
||||
void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2) override;
|
||||
|
||||
void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, bool hide) override;
|
||||
void changeFogOfWar(std::unordered_set<int3> &tiles, PlayerColor player, bool hide) override;
|
||||
void changeFogOfWar(int3 center, ui32 radius, PlayerColor player, ETileVisibility mode) override;
|
||||
void changeFogOfWar(std::unordered_set<int3> &tiles, PlayerColor player,ETileVisibility mode) override;
|
||||
|
||||
void castSpell(const spells::Caster * caster, SpellID spellID, const int3 &pos) override;
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ void PlayerMessageProcessor::cheatDefeat(PlayerColor player)
|
||||
void PlayerMessageProcessor::cheatMapReveal(PlayerColor player, bool reveal)
|
||||
{
|
||||
FoWChange fc;
|
||||
fc.mode = reveal;
|
||||
fc.mode = reveal ? ETileVisibility::REVEALED : ETileVisibility::HIDDEN;
|
||||
fc.player = player;
|
||||
const auto & fowMap = gameHandler->gameState()->getPlayerTeam(player)->fogOfWarMap;
|
||||
const auto & mapSize = gameHandler->gameState()->getMapSize();
|
||||
@@ -356,7 +356,7 @@ void PlayerMessageProcessor::cheatMapReveal(PlayerColor player, bool reveal)
|
||||
for(int z = 0; z < mapSize.z; z++)
|
||||
for(int x = 0; x < mapSize.x; x++)
|
||||
for(int y = 0; y < mapSize.y; y++)
|
||||
if(!(*fowMap)[z][x][y] || !fc.mode)
|
||||
if(!(*fowMap)[z][x][y] || fc.mode == ETileVisibility::HIDDEN)
|
||||
hlp_tab[lastUnc++] = int3(x, y, z);
|
||||
|
||||
fc.tiles.insert(hlp_tab, hlp_tab + lastUnc);
|
||||
|
||||
Reference in New Issue
Block a user