mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
Added initiator-player to packs that add/remove/move objects
This commit is contained in:
@ -168,7 +168,7 @@ void MapViewController::tick(uint32_t timeDelta)
|
||||
if(!hero)
|
||||
hero = boat->hero;
|
||||
|
||||
double heroMoveTime = LOCPLINT->makingTurn ?
|
||||
double heroMoveTime = LOCPLINT->playerID == hero->getOwner() ?
|
||||
settings["adventure"]["heroMoveTime"].Float() :
|
||||
settings["adventure"]["enemyMoveTime"].Float();
|
||||
|
||||
@ -267,31 +267,35 @@ void MapViewController::afterRender()
|
||||
}
|
||||
}
|
||||
|
||||
bool MapViewController::isEventInstant(const CGObjectInstance * obj)
|
||||
bool MapViewController::isEventInstant(const CGObjectInstance * obj, const PlayerColor & initiator)
|
||||
{
|
||||
if (!isEventVisible(obj))
|
||||
if (!isEventVisible(obj, initiator))
|
||||
return true;
|
||||
|
||||
if(!LOCPLINT->makingTurn && settings["adventure"]["enemyMoveTime"].Float() <= 0)
|
||||
if(initiator != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() <= 0)
|
||||
return true; // instant movement speed
|
||||
|
||||
if(LOCPLINT->makingTurn && settings["adventure"]["heroMoveTime"].Float() <= 0)
|
||||
if(initiator == LOCPLINT->playerID && settings["adventure"]["heroMoveTime"].Float() <= 0)
|
||||
return true; // instant movement speed
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MapViewController::isEventVisible(const CGObjectInstance * obj)
|
||||
bool MapViewController::isEventVisible(const CGObjectInstance * obj, const PlayerColor & initiator)
|
||||
{
|
||||
if(adventureContext == nullptr)
|
||||
return false;
|
||||
|
||||
if(!LOCPLINT->makingTurn && settings["adventure"]["enemyMoveTime"].Float() < 0)
|
||||
if(initiator != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() < 0)
|
||||
return false; // enemy move speed set to "hidden/none"
|
||||
|
||||
if(!GH.windows().isTopWindow(adventureInt))
|
||||
return false;
|
||||
|
||||
// do not focus on actions of other players during our turn (e.g. simturns)
|
||||
if (LOCPLINT->makingTurn && initiator != LOCPLINT->playerID)
|
||||
return false;
|
||||
|
||||
if(obj->isVisitable())
|
||||
return context->isVisible(obj->visitablePos());
|
||||
else
|
||||
@ -303,12 +307,16 @@ bool MapViewController::isEventVisible(const CGHeroInstance * obj, const int3 &
|
||||
if(adventureContext == nullptr)
|
||||
return false;
|
||||
|
||||
if(!LOCPLINT->makingTurn && settings["adventure"]["enemyMoveTime"].Float() < 0)
|
||||
if(obj->getOwner() != LOCPLINT->playerID && settings["adventure"]["enemyMoveTime"].Float() < 0)
|
||||
return false; // enemy move speed set to "hidden/none"
|
||||
|
||||
if(!GH.windows().isTopWindow(adventureInt))
|
||||
return false;
|
||||
|
||||
// do not focus on actions of other players during our turn (e.g. simturns)
|
||||
if (LOCPLINT->makingTurn && obj->getOwner() != LOCPLINT->playerID)
|
||||
return false;
|
||||
|
||||
if(context->isVisible(obj->convertToVisitablePos(from)))
|
||||
return true;
|
||||
|
||||
@ -394,7 +402,7 @@ void MapViewController::onBeforeHeroEmbark(const CGHeroInstance * obj, const int
|
||||
{
|
||||
if(isEventVisible(obj, from, dest))
|
||||
{
|
||||
if (!isEventInstant(obj))
|
||||
if (!isEventInstant(obj, obj->getOwner()))
|
||||
fadeOutObject(obj);
|
||||
setViewCenter(obj->getSightCenter());
|
||||
}
|
||||
@ -418,39 +426,39 @@ void MapViewController::onAfterHeroDisembark(const CGHeroInstance * obj, const i
|
||||
{
|
||||
if(isEventVisible(obj, from, dest))
|
||||
{
|
||||
if (!isEventInstant(obj))
|
||||
if (!isEventInstant(obj, obj->getOwner()))
|
||||
fadeInObject(obj);
|
||||
setViewCenter(obj->getSightCenter());
|
||||
}
|
||||
addObject(obj);
|
||||
}
|
||||
|
||||
void MapViewController::onObjectFadeIn(const CGObjectInstance * obj)
|
||||
void MapViewController::onObjectFadeIn(const CGObjectInstance * obj, const PlayerColor & initiator)
|
||||
{
|
||||
assert(!hasOngoingAnimations());
|
||||
|
||||
if(isEventVisible(obj) && !isEventInstant(obj) )
|
||||
if(isEventVisible(obj, initiator) && !isEventInstant(obj, initiator) )
|
||||
fadeInObject(obj);
|
||||
|
||||
addObject(obj);
|
||||
}
|
||||
|
||||
void MapViewController::onObjectFadeOut(const CGObjectInstance * obj)
|
||||
void MapViewController::onObjectFadeOut(const CGObjectInstance * obj, const PlayerColor & initiator)
|
||||
{
|
||||
assert(!hasOngoingAnimations());
|
||||
|
||||
if(isEventVisible(obj) && !isEventInstant(obj) )
|
||||
if(isEventVisible(obj, initiator) && !isEventInstant(obj, initiator) )
|
||||
fadeOutObject(obj);
|
||||
else
|
||||
removeObject(obj);
|
||||
}
|
||||
|
||||
void MapViewController::onObjectInstantAdd(const CGObjectInstance * obj)
|
||||
void MapViewController::onObjectInstantAdd(const CGObjectInstance * obj, const PlayerColor & initiator)
|
||||
{
|
||||
addObject(obj);
|
||||
};
|
||||
|
||||
void MapViewController::onObjectInstantRemove(const CGObjectInstance * obj)
|
||||
void MapViewController::onObjectInstantRemove(const CGObjectInstance * obj, const PlayerColor & initiator)
|
||||
{
|
||||
removeObject(obj);
|
||||
};
|
||||
|
Reference in New Issue
Block a user