|
@@ -186,13 +186,13 @@ static uint32 GetNearbyObjectTileInforma
|
|
|
static uint32 GetClosestObject(TileIndex tile, ObjectType type, const Object *current)
|
|
|
{
|
|
|
uint32 best_dist = UINT32_MAX;
|
|
|
for (const Object *o : Object::Iterate()) {
|
|
|
if (o->type != type || o == current) continue;
|
|
|
|
|
|
best_dist = min(best_dist, DistanceManhattan(tile, o->location.tile));
|
|
|
best_dist = std::min(best_dist, DistanceManhattan(tile, o->location.tile));
|
|
|
}
|
|
|
|
|
|
return best_dist;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -223,13 +223,13 @@ static uint32 GetCountAndDistanceOfClose
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* If the object type is invalid, there is none and the closest is far away. */
|
|
|
if (idx >= NUM_OBJECTS) return 0 | 0xFFFF;
|
|
|
|
|
|
return Object::GetTypeCount(idx) << 16 | min(GetClosestObject(tile, idx, current), 0xFFFF);
|
|
|
return Object::GetTypeCount(idx) << 16 | std::min(GetClosestObject(tile, idx, current), 0xFFFFu);
|
|
|
}
|
|
|
|
|
|
/** Used by the resolver to get values for feature 0F deterministic spritegroups. */
|
|
|
/* virtual */ uint32 ObjectScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const
|
|
|
{
|
|
|
/* We get the town from the object, or we calculate the closest
|
|
@@ -298,16 +298,16 @@ static uint32 GetCountAndDistanceOfClose
|
|
|
case 0x43: return GetAnimationFrame(this->tile);
|
|
|
|
|
|
/* Object founder information */
|
|
|
case 0x44: return GetTileOwner(this->tile);
|
|
|
|
|
|
/* Get town zone and Manhattan distance of closest town */
|
|
|
case 0x45: return GetTownRadiusGroup(t, this->tile) << 16 | min(DistanceManhattan(this->tile, t->xy), 0xFFFF);
|
|
|
case 0x45: return GetTownRadiusGroup(t, this->tile) << 16 | std::min(DistanceManhattan(this->tile, t->xy), 0xFFFFu);
|
|
|
|
|
|
/* Get square of Euclidian distance of closes town */
|
|
|
case 0x46: return GetTownRadiusGroup(t, this->tile) << 16 | min(DistanceSquare(this->tile, t->xy), 0xFFFF);
|
|
|
case 0x46: return GetTownRadiusGroup(t, this->tile) << 16 | std::min(DistanceSquare(this->tile, t->xy), 0xFFFFu);
|
|
|
|
|
|
/* Object colour */
|
|
|
case 0x47: return this->obj->colour;
|
|
|
|
|
|
/* Object view */
|
|
|
case 0x48: return this->obj->view;
|