1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Teleport: rework code to support exit point selection for whirlpools

This commit is contained in:
ArseniyShestakov
2015-12-02 17:56:26 +03:00
parent f6de3f94ca
commit b5100bee94
7 changed files with 72 additions and 41 deletions

View File

@ -97,6 +97,7 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player)
{
logGlobal->traceStream() << "\tHuman player interface for player " << Player << " being constructed";
destinationTeleport = ObjectInstanceID();
destinationTeleportPos = int3();
observerInDuelMode = false;
howManyPeople++;
GH.defActionsDef = 0;
@ -1147,14 +1148,15 @@ void CPlayerInterface::showBlockingDialog( const std::string &text, const std::v
}
void CPlayerInterface::showTeleportDialog(TeleportChannelID channel, std::vector<ObjectInstanceID> exits, bool impassable, QueryID askID)
void CPlayerInterface::showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
ObjectInstanceID choosenExit;
if(destinationTeleport != ObjectInstanceID() && vstd::contains(exits, destinationTeleport))
choosenExit = destinationTeleport;
int choosenExit = -1;
auto neededExit = std::make_pair(destinationTeleport, destinationTeleportPos);
if(destinationTeleport != ObjectInstanceID() && vstd::contains(exits, neededExit))
choosenExit = vstd::find_pos(exits, neededExit);
cb->selectionMade(choosenExit.getNum(), askID);
cb->selectionMade(choosenExit, askID);
}
void CPlayerInterface::tileRevealed(const std::unordered_set<int3, ShashInt3> &pos)
@ -1414,6 +1416,7 @@ void CPlayerInterface::requestRealized( PackageApplied *pa )
&& stillMoveHero.get() == DURING_MOVE)
{ // After teleportation via CGTeleport object is finished
destinationTeleport = ObjectInstanceID();
destinationTeleportPos = int3();
stillMoveHero.setn(CONTINUE_MOVE);
}
}
@ -2663,6 +2666,7 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
{
CCS->soundh->stopSound(sh);
destinationTeleport = nextObject->id;
destinationTeleportPos = nextCoord;
doMovement(h->pos, false);
sh = CCS->soundh->playSound(CCS->soundh->horseSounds[currentTerrain], -1);
continue;