mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Make GetRegister return a signed integer, matching the underlying TemporaryStorageArray.
parent
74030a63e6
commit
99d7a775ad
|
@ -684,13 +684,13 @@ void SpriteLayoutProcessor::ProcessRegisters(uint8_t resolved_var10, uint32_t re
|
|||
|
||||
if (result.IsParentSprite()) {
|
||||
if (flags & TLF_BB_XY_OFFSET) {
|
||||
result.delta_x += static_cast<int32_t>(GetRegister(regs->delta.parent[0]));
|
||||
result.delta_y += static_cast<int32_t>(GetRegister(regs->delta.parent[1]));
|
||||
result.delta_x += GetRegister(regs->delta.parent[0]);
|
||||
result.delta_y += GetRegister(regs->delta.parent[1]);
|
||||
}
|
||||
if (flags & TLF_BB_Z_OFFSET) result.delta_z += static_cast<int32_t>(GetRegister(regs->delta.parent[2]));
|
||||
if (flags & TLF_BB_Z_OFFSET) result.delta_z += GetRegister(regs->delta.parent[2]);
|
||||
} else {
|
||||
if (flags & TLF_CHILD_X_OFFSET) result.delta_x += static_cast<int32_t>(GetRegister(regs->delta.child[0]));
|
||||
if (flags & TLF_CHILD_Y_OFFSET) result.delta_y += static_cast<int32_t>(GetRegister(regs->delta.child[1]));
|
||||
if (flags & TLF_CHILD_X_OFFSET) result.delta_x += GetRegister(regs->delta.child[0]);
|
||||
if (flags & TLF_CHILD_Y_OFFSET) result.delta_y += GetRegister(regs->delta.child[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -621,7 +621,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
|||
if (object->ro.callback == CBID_NO_CALLBACK || object->ro.callback == CBID_RANDOM_TRIGGER || object->ro.callback == CBID_TRAIN_ALLOW_WAGON_ATTACH ||
|
||||
object->ro.callback == CBID_VEHICLE_START_STOP_CHECK || object->ro.callback == CBID_VEHICLE_32DAY_CALLBACK || object->ro.callback == CBID_VEHICLE_COLOUR_MAPPING ||
|
||||
object->ro.callback == CBID_VEHICLE_SPAWN_VISUAL_EFFECT) {
|
||||
Vehicle *u = v->Move((int32_t)GetRegister(0x10F));
|
||||
Vehicle *u = v->Move(GetRegister(0x10F));
|
||||
if (u == nullptr) return 0; // available, but zero
|
||||
|
||||
if (parameter == 0x5F) {
|
||||
|
@ -1102,7 +1102,7 @@ static void GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction d
|
|||
object.ResetState();
|
||||
object.callback_param1 = image_type | (stack << 8);
|
||||
const auto *group = object.Resolve<ResultSpriteGroup>();
|
||||
uint32_t reg100 = sprite_stack ? GetRegister(0x100) : 0;
|
||||
int32_t reg100 = sprite_stack ? GetRegister(0x100) : 0;
|
||||
if (group != nullptr && group->num_sprites != 0) {
|
||||
result->seq[result->count].sprite = group->sprite + (direction % group->num_sprites);
|
||||
result->seq[result->count].pal = GB(reg100, 0, 16); // zero means default recolouring
|
||||
|
@ -1145,7 +1145,7 @@ static void GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, En
|
|||
object.ResetState();
|
||||
object.callback_param1 = image_type | (stack << 8);
|
||||
const auto *group = object.Resolve<ResultSpriteGroup>();
|
||||
uint32_t reg100 = sprite_stack ? GetRegister(0x100) : 0;
|
||||
int32_t reg100 = sprite_stack ? GetRegister(0x100) : 0;
|
||||
if (group != nullptr && group->num_sprites != 0) {
|
||||
result->seq[result->count].sprite = group->sprite + (rotor_pos % group->num_sprites);
|
||||
result->seq[result->count].pal = GB(reg100, 0, 16); // zero means default recolouring
|
||||
|
|
|
@ -115,7 +115,7 @@ static uint32_t GetClosestIndustry(TileIndex tile, IndustryType type, const Indu
|
|||
*/
|
||||
static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t param_set_id, uint8_t layout_filter, bool town_filter, const Industry *current)
|
||||
{
|
||||
uint32_t grf_id = GetRegister(0x100); ///< Get the GRFID of the definition to look for in register 100h
|
||||
uint32_t grf_id = static_cast<uint32_t>(GetRegister(0x100)); ///< Get the GRFID of the definition to look for in register 100h
|
||||
IndustryType industry_type;
|
||||
uint32_t closest_dist = UINT32_MAX;
|
||||
uint8_t count = 0;
|
||||
|
@ -311,7 +311,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t param_set_id, uint8
|
|||
uint8_t layout_filter = 0;
|
||||
bool town_filter = false;
|
||||
if (variable == 0x68) {
|
||||
uint32_t reg = GetRegister(0x101);
|
||||
int32_t reg = GetRegister(0x101);
|
||||
layout_filter = GB(reg, 0, 8);
|
||||
town_filter = HasBit(reg, 8);
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ uint32_t GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityC
|
|||
|
||||
static int32_t DerefIndProd(int field, bool use_register)
|
||||
{
|
||||
return use_register ? (int32_t)GetRegister(field) : field;
|
||||
return use_register ? GetRegister(field) : field;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -233,7 +233,7 @@ static uint32_t GetClosestObject(TileIndex tile, ObjectType type, const Object *
|
|||
*/
|
||||
static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t local_id, uint32_t grfid, TileIndex tile, const Object *current)
|
||||
{
|
||||
uint32_t grf_id = GetRegister(0x100); // Get the GRFID of the definition to look for in register 100h
|
||||
uint32_t grf_id = static_cast<uint32_t>(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 */
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* @pre i < 0x110
|
||||
* @return the value of the register
|
||||
*/
|
||||
inline uint32_t GetRegister(uint i)
|
||||
inline int32_t GetRegister(uint i)
|
||||
{
|
||||
extern TemporaryStorageArray<int32_t, 0x110> _temp_store;
|
||||
return _temp_store.GetValue(i);
|
||||
|
|
|
@ -655,7 +655,7 @@ SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseS
|
|||
|
||||
const auto *group = object.Resolve<ResultSpriteGroup>();
|
||||
/* Note: SpriteGroup::Resolve zeroes all registers, so register 0x100 is initialised to 0. (compatibility) */
|
||||
auto offset = GetRegister(0x100);
|
||||
uint32_t offset = static_cast<uint32_t>(GetRegister(0x100));
|
||||
if (group == nullptr || group->num_sprites <= offset) return 0;
|
||||
|
||||
return group->sprite + offset;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
/* Get a variable from the persistent storage */
|
||||
case 0x7C: {
|
||||
/* Check the persistent storage for the GrfID stored in register 100h. */
|
||||
uint32_t grfid = GetRegister(0x100);
|
||||
uint32_t grfid = static_cast<uint32_t>(GetRegister(0x100));
|
||||
if (grfid == 0xFFFFFFFF) {
|
||||
if (this->ro.grffile == nullptr) return 0;
|
||||
grfid = this->ro.grffile->grfid;
|
||||
|
@ -132,7 +132,7 @@
|
|||
if (this->ro.grffile == nullptr) return;
|
||||
|
||||
/* Check the persistent storage for the GrfID stored in register 100h. */
|
||||
uint32_t grfid = GetRegister(0x100);
|
||||
uint32_t grfid = static_cast<uint32_t>(GetRegister(0x100));
|
||||
|
||||
/* A NewGRF can only write in the persistent storage associated to its own GRFID. */
|
||||
if (grfid == 0xFFFFFFFF) grfid = this->ro.grffile->grfid;
|
||||
|
|
|
@ -2725,7 +2725,7 @@ static void SpawnAdvancedVisualEffect(const Vehicle *v)
|
|||
int8_t y_center = _vehicle_smoke_pos[t_dir] * l_center;
|
||||
|
||||
for (uint i = 0; i < count; i++) {
|
||||
uint32_t reg = GetRegister(0x100 + i);
|
||||
int32_t reg = GetRegister(0x100 + i);
|
||||
uint type = GB(reg, 0, 8);
|
||||
int8_t x = GB(reg, 8, 8);
|
||||
int8_t y = GB(reg, 16, 8);
|
||||
|
|
Loading…
Reference in New Issue