|
OpenTTD Source 20251117-master-g7398d2e290
|
Handling of object NewGRFs. More...
#include "stdafx.h"#include "company_base.h"#include "company_func.h"#include "debug.h"#include "genworld.h"#include "newgrf_badge.h"#include "newgrf_object.h"#include "newgrf_sound.h"#include "object_base.h"#include "object_map.h"#include "timer/timer_game_calendar.h"#include "tile_cmd.h"#include "town.h"#include "water.h"#include "newgrf_animation_base.h"#include "table/strings.h"#include "newgrf_class_func.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | ObjectAnimationBase |
| Helper class for animation control. More... | |
Functions | |
| void | ResetObjects () |
| This function initialize the spec arrays of objects. | |
| static uint32_t | GetObjectIDAtOffset (TileIndex tile, uint32_t cur_grfid) |
| Make an analysis of a tile and get the object type. | |
| static uint32_t | GetNearbyObjectTileInformation (uint8_t parameter, TileIndex tile, ObjectID index, bool grf_version8) |
| Based on newhouses equivalent, but adapted for newobjects. | |
| static uint32_t | GetClosestObject (TileIndex tile, ObjectType type, const Object *current) |
| Get the closest object of a given type. | |
| static uint32_t | GetCountAndDistanceOfClosestInstance (const ResolverObject &object, uint8_t local_id, uint32_t grfid, TileIndex tile, const Object *current) |
| Implementation of var 65. | |
| uint16_t | GetObjectCallback (CallbackID callback, uint32_t param1, uint32_t param2, const ObjectSpec *spec, Object *o, TileIndex tile, std::span< int32_t > regs100, uint8_t view) |
| Perform a callback for an object. | |
| static void | DrawTileLayout (const TileInfo *ti, const DrawTileSpriteSpan &dts, const ObjectSpec *spec) |
| Draw an group of sprites on the map. | |
| void | DrawNewObjectTile (TileInfo *ti, const ObjectSpec *spec) |
| Draw an object on the map. | |
| void | DrawNewObjectTileInGUI (int x, int y, const ObjectSpec *spec, uint8_t view) |
| Draw representation of an object (tile) for GUI purposes. | |
| uint16_t | StubGetObjectCallback (CallbackID callback, uint32_t param1, uint32_t param2, const ObjectSpec *spec, Object *o, TileIndex tile, int) |
| Perform a callback for an object. | |
| void | AnimateNewObjectTile (TileIndex tile) |
| Handle the animation of the object tile. | |
| static bool | DoTriggerObjectTileAnimation (Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec, uint32_t random, uint32_t var18_extra=0) |
| bool | TriggerObjectTileAnimation (Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec) |
| Trigger the update of animation on a single tile. | |
| bool | TriggerObjectAnimation (Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec) |
| Trigger the update of animation on a whole object. | |
Variables | |
| ObjectOverrideManager | _object_mngr (NEW_OBJECT_OFFSET, NUM_OBJECTS, INVALID_OBJECT_TYPE) |
| The override manager for our objects. | |
| const ObjectSpec | _original_objects [NEW_OBJECT_OFFSET] |
| std::vector< ObjectSpec > | _object_specs |
| All the object specifications. | |
Handling of object NewGRFs.
Definition in file newgrf_object.cpp.
| void AnimateNewObjectTile | ( | TileIndex | tile | ) |
Handle the animation of the object tile.
| tile | The tile to animate. |
Definition at line 553 of file newgrf_object.cpp.
References AnimationBase< ObjectAnimationBase, ObjectSpec, Object, int, StubGetObjectCallback, TileAnimationFrameAnimationHelper< Object > >::AnimateTile(), Animation, AnimRandomBits, ObjectSpec::flags, ObjectSpec::GetByTile(), Object::GetByTile(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
|
static |
Definition at line 561 of file newgrf_object.cpp.
| void DrawNewObjectTile | ( | TileInfo * | ti, |
| const ObjectSpec * | spec | ||
| ) |
Draw an object on the map.
| ti | Information about the tile to draw on. |
| spec | Object spec to draw. |
Definition at line 472 of file newgrf_object.cpp.
References DrawTileLayout, Object::GetByTile(), SpriteLayoutProcessor::GetLayout(), TileLayoutSpriteGroup::ProcessRegisters(), and TileInfo::tile.
| void DrawNewObjectTileInGUI | ( | int | x, |
| int | y, | ||
| const ObjectSpec * | spec, | ||
| uint8_t | view | ||
| ) |
Draw representation of an object (tile) for GUI purposes.
| x | Position x of image. |
| y | Position y of image. |
| spec | Object spec to draw. |
| view | The object's view. |
Definition at line 492 of file newgrf_object.cpp.
References _local_company, Livery::colour1, Livery::colour2, DrawNewGRFTileSeqInGUI(), DrawSprite(), ObjectSpec::flags, GB(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetCompanyPalette(), SpriteLayoutProcessor::GetLayout(), GroundSpritePaletteTransform(), INVALID_TILE, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), PALETTE_RECOLOUR_START, TileLayoutSpriteGroup::ProcessRegisters(), SPRITE_WIDTH, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Uses2CC.
Referenced by ObjectPickerCallbacks::DrawType(), and BuildObjectWindow::DrawWidget().
|
static |
Draw an group of sprites on the map.
| ti | Information about the tile to draw on. |
| dts | The sprite layout to draw. |
| spec | Object spec to draw. |
Definition at line 447 of file newgrf_object.cpp.
References Object::colour, DrawGroundSprite(), DrawNewGRFTileSeq(), DrawWater, ObjectSpec::flags, GB(), Object::GetByTile(), DrawTileSprites::ground, GroundSpritePaletteTransform(), IsTileOnWater(), PalSpriteID::pal, PALETTE_RECOLOUR_START, PalSpriteID::sprite, SPRITE_WIDTH, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileInfo::tile, TO_STRUCTURES, and Uses2CC.
|
static |
Get the closest object of a given type.
| tile | The tile to start searching from. |
| type | The type of the object to search for. |
| current | The current object (to ignore). |
Definition at line 214 of file newgrf_object.cpp.
References DistanceManhattan(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_object_pool >::Iterate().
Referenced by GetCountAndDistanceOfClosestInstance().
|
static |
Implementation of var 65.
| object | ResolverObject owning the temporary storage. |
| local_id | Parameter given to the callback, which is the set id, or the local id, in our terminology. |
| grfid | The object's GRFID. |
| tile | The tile to look from. |
| current | Object for which the inquiry is made |
Definition at line 235 of file newgrf_object.cpp.
References _object_mngr, GetClosestObject(), OverrideManagerBase::GetID(), Object::GetTypeCount(), and NUM_OBJECTS.
|
static |
Based on newhouses equivalent, but adapted for newobjects.
| parameter | from callback. It's in fact a pair of coordinates |
| tile | TileIndex from which the callback was initiated |
| index | of the object been queried for |
| grf_version8 | True, if we are dealing with a new NewGRF which uses GRF version >= 8. |
Definition at line 199 of file newgrf_object.cpp.
References GetNearbyTile(), GetNearbyTileInformation(), GetObjectIndex(), IsTileType(), and MP_OBJECT.
Referenced by ObjectScopeResolver::GetVariable().
| uint16_t GetObjectCallback | ( | CallbackID | callback, |
| uint32_t | param1, | ||
| uint32_t | param2, | ||
| const ObjectSpec * | spec, | ||
| Object * | o, | ||
| TileIndex | tile, | ||
| std::span< int32_t > | regs100, | ||
| uint8_t | view | ||
| ) |
Perform a callback for an object.
| callback | The callback to perform. | |
| param1 | The first parameter to pass to the NewGRF. | |
| param2 | The second parameter to pass to the NewGRF. | |
| spec | The specification of the object / the entry point. | |
| o | The object to call the callback for. | |
| tile | The tile the callback is called for. | |
| view | The view of the object (only used when o == nullptr). | |
| [out] | regs100 | Additional result values from registers 100+ |
Definition at line 435 of file newgrf_object.cpp.
Referenced by BuildObject(), CmdBuildObject(), BuildObjectWindow::DrawWidget(), and StubGetObjectCallback().
|
static |
Make an analysis of a tile and get the object type.
| tile | TileIndex of the tile to query |
| cur_grfid | GRFID of the current callback chain |
Definition at line 170 of file newgrf_object.cpp.
References ObjectSpec::Get(), Object::GetByTile(), ObjectSpec::grf_prop, GRFFilePropsBase::grfid, GRFFilePropsBase::HasGrfFile(), IsTileType(), GRFFilePropsBase::local_id, MP_OBJECT, Object::type, and Object::view.
Referenced by ObjectScopeResolver::GetVariable().
| void ResetObjects | ( | ) |
This function initialize the spec arrays of objects.
Definition at line 125 of file newgrf_object.cpp.
References _object_specs, NewGRFClass< Tspec, Tindex, Tmax >::Allocate(), ObjectSpec::grf_prop, lengthof, GRFFilePropsBase::local_id, OBJECT_LIGHTHOUSE, and OBJECT_TRANSMITTER.
Referenced by ResetNewGRFData().
| uint16_t StubGetObjectCallback | ( | CallbackID | callback, |
| uint32_t | param1, | ||
| uint32_t | param2, | ||
| const ObjectSpec * | spec, | ||
| Object * | o, | ||
| TileIndex | tile, | ||
| int | |||
| ) |
Perform a callback for an object.
| callback | The callback to perform. |
| param1 | The first parameter to pass to the NewGRF. |
| param2 | The second parameter to pass to the NewGRF. |
| spec | The specification of the object / the entry point. |
| o | The object to call the callback for. |
| tile | The tile the callback is called for. |
Definition at line 535 of file newgrf_object.cpp.
References GetObjectCallback().
| bool TriggerObjectAnimation | ( | Object * | o, |
| ObjectAnimationTrigger | trigger, | ||
| const ObjectSpec * | spec | ||
| ) |
Trigger the update of animation on a whole object.
| o | The object that got triggered. |
| trigger | The trigger that is triggered. |
| spec | The spec associated with the object. |
Definition at line 587 of file newgrf_object.cpp.
References ObjectSpec::animation, Object::location, Random, and SB().
Referenced by BuildObject().
| bool TriggerObjectTileAnimation | ( | Object * | o, |
| TileIndex | tile, | ||
| ObjectAnimationTrigger | trigger, | ||
| const ObjectSpec * | spec | ||
| ) |
Trigger the update of animation on a single tile.
| o | The object that got triggered. |
| tile | The location of the triggered tile. |
| trigger | The trigger that is triggered. |
| spec | The spec associated with the object. |
Definition at line 576 of file newgrf_object.cpp.
References Random.
| std::vector<ObjectSpec> _object_specs |
All the object specifications.
Definition at line 37 of file newgrf_object.cpp.
Referenced by ObjectSpec::BindToClasses(), ObjectSpec::Get(), ObjectSpec::Index(), ResetObjects(), and ObjectOverrideManager::SetEntitySpec().