1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

#1100 - fix visiting allied dwellings

This commit is contained in:
Andrii Danylchenko
2022-11-13 11:01:32 +02:00
committed by Nordsoft91
parent 61eca7e3be
commit e31beafa17

View File

@@ -237,7 +237,7 @@ bool isObjectPassable(const Nullkiller * ai, const CGObjectInstance * obj)
bool isObjectPassable(const CGObjectInstance * obj) bool isObjectPassable(const CGObjectInstance * obj)
{ {
return isObjectPassable(obj, ai->playerID, cb->getPlayerRelations(obj->tempOwner, ai->playerID)); return isObjectPassable(obj, ai->playerID, ai->myCb->getPlayerRelations(obj->tempOwner, ai->playerID));
} }
// Pathfinder internal helper // Pathfinder internal helper
@@ -344,11 +344,14 @@ uint64_t timeElapsed(std::chrono::time_point<std::chrono::high_resolution_clock>
// todo: move to obj manager // todo: move to obj manager
bool shouldVisit(const Nullkiller * ai, const CGHeroInstance * h, const CGObjectInstance * obj) bool shouldVisit(const Nullkiller * ai, const CGHeroInstance * h, const CGObjectInstance * obj)
{ {
auto relations = ai->cb->getPlayerRelations(obj->tempOwner, h->tempOwner);
switch(obj->ID) switch(obj->ID)
{ {
case Obj::TOWN: case Obj::TOWN:
case Obj::HERO: //never visit our heroes at random case Obj::HERO: //never visit our heroes at random
return obj->tempOwner != h->tempOwner; //do not visit our towns at random return relations == PlayerRelations::ENEMIES; //do not visit our towns at random
case Obj::BORDER_GATE: case Obj::BORDER_GATE:
{ {
for(auto q : ai->cb->getMyQuests()) for(auto q : ai->cb->getMyQuests())
@@ -378,9 +381,12 @@ bool shouldVisit(const Nullkiller * ai, const CGHeroInstance * h, const CGObject
} }
case Obj::CREATURE_GENERATOR1: case Obj::CREATURE_GENERATOR1:
{ {
if(obj->tempOwner != h->tempOwner) if(relations == PlayerRelations::ENEMIES)
return true; //flag just in case return true; //flag just in case
if(relations == PlayerRelations::ALLIES)
return false;
const CGDwelling * d = dynamic_cast<const CGDwelling *>(obj); const CGDwelling * d = dynamic_cast<const CGDwelling *>(obj);
for(auto level : d->creatures) for(auto level : d->creatures)
@@ -420,7 +426,7 @@ bool shouldVisit(const Nullkiller * ai, const CGHeroInstance * h, const CGObject
break; break;
} }
case Obj::LIBRARY_OF_ENLIGHTENMENT: case Obj::LIBRARY_OF_ENLIGHTENMENT:
if(h->level < 12) if(h->level < 10)
return false; return false;
break; break;
case Obj::TREE_OF_KNOWLEDGE: case Obj::TREE_OF_KNOWLEDGE: