1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-22 11:44:17 +01:00

Codechange: Access temporary storage through ResolverObject during Resolve.

This commit is contained in:
frosch
2025-05-05 21:28:51 +02:00
committed by frosch
parent 99d7a775ad
commit 85be7a4d92
9 changed files with 59 additions and 34 deletions

View File

@@ -225,15 +225,16 @@ static uint32_t GetClosestObject(TileIndex tile, ObjectType type, const Object *
/**
* Implementation of var 65
* @param object ResolverObject owning the temporary storage.
* @param local_id Parameter given to the callback, which is the set id, or the local id, in our terminology.
* @param grfid The object's GRFID.
* @param tile The tile to look from.
* @param current Object for which the inquiry is made
* @return The formatted answer to the callback : rr(reserved) cc(count) dddd(manhattan distance of closest sister)
*/
static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t local_id, uint32_t grfid, TileIndex tile, const Object *current)
static uint32_t GetCountAndDistanceOfClosestInstance(const ResolverObject &object, uint8_t local_id, uint32_t grfid, TileIndex tile, const Object *current)
{
uint32_t grf_id = static_cast<uint32_t>(GetRegister(0x100)); // Get the GRFID of the definition to look for in register 100h
uint32_t grf_id = static_cast<uint32_t>(object.GetRegister(0x100)); // Get the GRFID of the definition to look for in register 100h
uint32_t idx;
/* Determine what will be the object type to look for */
@@ -361,7 +362,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t local_id, uint32_t
}
/* Count of object, distance of closest instance */
case 0x64: return GetCountAndDistanceOfClosestInstance(parameter, this->ro.grffile->grfid, this->tile, this->obj);
case 0x64: return GetCountAndDistanceOfClosestInstance(this->ro, parameter, this->ro.grffile->grfid, this->tile, this->obj);
case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->spec->badges, parameter);
}