Update to 14.0-beta1

This commit is contained in:
dP
2024-02-04 02:18:17 +05:30
parent 79037e2c65
commit 33ef333b57
1325 changed files with 138465 additions and 70987 deletions

View File

@@ -27,6 +27,7 @@
#include "company_base.h"
#include "error.h"
#include "strings_func.h"
#include "string_func.h"
#include "table/strings.h"
@@ -38,27 +39,16 @@
* @param maximum of entities this manager can deal with. i.e: houses = 512
* @param invalid is the ID used to identify an invalid entity id
*/
OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid)
OverrideManagerBase::OverrideManagerBase(uint16_t offset, uint16_t maximum, uint16_t invalid)
{
max_offset = offset;
max_new_entities = maximum;
invalid_ID = invalid;
this->max_offset = offset;
this->max_entities = maximum;
this->invalid_id = invalid;
mapping_ID = CallocT<EntityIDMapping>(max_new_entities);
entity_overrides = MallocT<uint16>(max_offset);
for (size_t i = 0; i < max_offset; i++) entity_overrides[i] = invalid;
grfid_overrides = CallocT<uint32>(max_offset);
}
/**
* Destructor of the generic class.
* Frees allocated memory of constructor
*/
OverrideManagerBase::~OverrideManagerBase()
{
free(mapping_ID);
free(entity_overrides);
free(grfid_overrides);
this->mappings.resize(this->max_entities);
this->entity_overrides.resize(this->max_offset);
std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_id);
this->grfid_overrides.resize(this->max_offset);
}
/**
@@ -69,28 +59,26 @@ OverrideManagerBase::~OverrideManagerBase()
* @param grfid ID of the grf file
* @param entity_type original entity type
*/
void OverrideManagerBase::Add(uint8 local_id, uint32 grfid, uint entity_type)
void OverrideManagerBase::Add(uint16_t local_id, uint32_t grfid, uint entity_type)
{
assert(entity_type < max_offset);
assert(entity_type < this->max_offset);
/* An override can be set only once */
if (entity_overrides[entity_type] != invalid_ID) return;
entity_overrides[entity_type] = local_id;
grfid_overrides[entity_type] = grfid;
if (this->entity_overrides[entity_type] != this->invalid_id) return;
this->entity_overrides[entity_type] = local_id;
this->grfid_overrides[entity_type] = grfid;
}
/** Resets the mapping, which is used while initializing game */
void OverrideManagerBase::ResetMapping()
{
memset(mapping_ID, 0, (max_new_entities - 1) * sizeof(EntityIDMapping));
std::fill(this->mappings.begin(), this->mappings.end(), EntityIDMapping{});
}
/** Resets the override, which is used while initializing game */
void OverrideManagerBase::ResetOverride()
{
for (uint16 i = 0; i < max_offset; i++) {
entity_overrides[i] = invalid_ID;
grfid_overrides[i] = 0;
}
std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_id);
std::fill(this->grfid_overrides.begin(), this->grfid_overrides.end(), uint32_t());
}
/**
@@ -99,18 +87,16 @@ void OverrideManagerBase::ResetOverride()
* @param grfid ID of the grf file
* @return the ID of the candidate, of the Invalid flag item ID
*/
uint16 OverrideManagerBase::GetID(uint8 grf_local_id, uint32 grfid) const
uint16_t OverrideManagerBase::GetID(uint16_t grf_local_id, uint32_t grfid) const
{
const EntityIDMapping *map;
for (uint16 id = 0; id < max_new_entities; id++) {
map = &mapping_ID[id];
for (uint16_t id = 0; id < this->max_entities; id++) {
const EntityIDMapping *map = &this->mappings[id];
if (map->entity_id == grf_local_id && map->grfid == grfid) {
return id;
}
}
return invalid_ID;
return this->invalid_id;
}
/**
@@ -120,22 +106,19 @@ uint16 OverrideManagerBase::GetID(uint8 grf_local_id, uint32 grfid) const
* @param substitute_id is the original entity from which data is copied for the new one
* @return the proper usable slot id, or invalid marker if none is found
*/
uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id)
uint16_t OverrideManagerBase::AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id)
{
uint16 id = this->GetID(grf_local_id, grfid);
EntityIDMapping *map;
uint16_t id = this->GetID(grf_local_id, grfid);
/* Look to see if this entity has already been added. This is done
* separately from the loop below in case a GRF has been deleted, and there
* are any gaps in the array.
*/
if (id != invalid_ID) {
return id;
}
if (id != this->invalid_id) return id;
/* This entity hasn't been defined before, so give it an ID now. */
for (id = max_offset; id < max_new_entities; id++) {
map = &mapping_ID[id];
for (id = this->max_offset; id < this->max_entities; id++) {
EntityIDMapping *map = &this->mappings[id];
if (CheckValidNewID(id) && map->entity_id == 0 && map->grfid == 0) {
map->entity_id = grf_local_id;
@@ -145,7 +128,7 @@ uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte su
}
}
return invalid_ID;
return this->invalid_id;
}
/**
@@ -153,9 +136,9 @@ uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte su
* @param entity_id ID of the entity being queried.
* @return GRFID.
*/
uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const
uint32_t OverrideManagerBase::GetGRFID(uint16_t entity_id) const
{
return mapping_ID[entity_id].grfid;
return this->mappings[entity_id].grfid;
}
/**
@@ -163,9 +146,9 @@ uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const
* @param entity_id of the entity being queried
* @return mapped id
*/
uint16 OverrideManagerBase::GetSubstituteID(uint16 entity_id) const
uint16_t OverrideManagerBase::GetSubstituteID(uint16_t entity_id) const
{
return mapping_ID[entity_id].substitute_id;
return this->mappings[entity_id].substitute_id;
}
/**
@@ -177,22 +160,22 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs)
{
HouseID house_id = this->AddEntityID(hs->grf_prop.local_id, hs->grf_prop.grffile->grfid, hs->grf_prop.subst_id);
if (house_id == invalid_ID) {
grfmsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring.");
if (house_id == this->invalid_id) {
GrfMsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring.");
return;
}
MemCpyT(HouseSpec::Get(house_id), hs);
*HouseSpec::Get(house_id) = *hs;
/* Now add the overrides. */
for (int i = 0; i != max_offset; i++) {
for (int i = 0; i < this->max_offset; i++) {
HouseSpec *overridden_hs = HouseSpec::Get(i);
if (entity_overrides[i] != hs->grf_prop.local_id || grfid_overrides[i] != hs->grf_prop.grffile->grfid) continue;
if (this->entity_overrides[i] != hs->grf_prop.local_id || this->grfid_overrides[i] != hs->grf_prop.grffile->grfid) continue;
overridden_hs->grf_prop.override = house_id;
entity_overrides[i] = invalid_ID;
grfid_overrides[i] = 0;
this->entity_overrides[i] = this->invalid_id;
this->grfid_overrides[i] = 0;
}
}
@@ -202,17 +185,17 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs)
* @param grfid ID of the grf file
* @return the ID of the candidate, of the Invalid flag item ID
*/
uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid) const
uint16_t IndustryOverrideManager::GetID(uint16_t grf_local_id, uint32_t grfid) const
{
uint16 id = OverrideManagerBase::GetID(grf_local_id, grfid);
if (id != invalid_ID) return id;
uint16_t id = OverrideManagerBase::GetID(grf_local_id, grfid);
if (id != this->invalid_id) return id;
/* No mapping found, try the overrides */
for (id = 0; id < max_offset; id++) {
if (entity_overrides[id] == grf_local_id && grfid_overrides[id] == grfid) return id;
for (id = 0; id < this->max_offset; id++) {
if (this->entity_overrides[id] == grf_local_id && this->grfid_overrides[id] == grfid) return id;
}
return invalid_ID;
return this->invalid_id;
}
/**
@@ -222,12 +205,12 @@ uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid) const
* @param substitute_id industry from which data has been copied
* @return a free entity id (slotid) if ever one has been found, or Invalid_ID marker otherwise
*/
uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id)
uint16_t IndustryOverrideManager::AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id)
{
/* This entity hasn't been defined before, so give it an ID now. */
for (uint16 id = 0; id < max_new_entities; id++) {
for (uint16_t id = 0; id < this->max_entities; id++) {
/* Skip overridden industries */
if (id < max_offset && entity_overrides[id] != invalid_ID) continue;
if (id < this->max_offset && this->entity_overrides[id] != this->invalid_id) continue;
/* Get the real live industry */
const IndustrySpec *inds = GetIndustrySpec(id);
@@ -236,7 +219,7 @@ uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byt
* And it must not already be used by a grf (grffile == nullptr).
* So reserve this slot here, as it is the chosen one */
if (!inds->enabled && inds->grf_prop.grffile == nullptr) {
EntityIDMapping *map = &mapping_ID[id];
EntityIDMapping *map = &this->mappings[id];
if (map->entity_id == 0 && map->grfid == 0) {
/* winning slot, mark it as been used */
@@ -248,7 +231,7 @@ uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byt
}
}
return invalid_ID;
return this->invalid_id;
}
/**
@@ -262,17 +245,17 @@ void IndustryOverrideManager::SetEntitySpec(IndustrySpec *inds)
/* First step : We need to find if this industry is already specified in the savegame data. */
IndustryType ind_id = this->GetID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid);
if (ind_id == invalid_ID) {
if (ind_id == this->invalid_id) {
/* Not found.
* Or it has already been overridden, so you've lost your place.
* Or it is a simple substitute.
* We need to find a free available slot */
ind_id = this->AddEntityID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid, inds->grf_prop.subst_id);
inds->grf_prop.override = invalid_ID; // make sure it will not be detected as overridden
inds->grf_prop.override = this->invalid_id; // make sure it will not be detected as overridden
}
if (ind_id == invalid_ID) {
grfmsg(1, "Industry.SetEntitySpec: Too many industries allocated. Ignoring.");
if (ind_id == this->invalid_id) {
GrfMsg(1, "Industry.SetEntitySpec: Too many industries allocated. Ignoring.");
return;
}
@@ -286,23 +269,23 @@ void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its)
{
IndustryGfx indt_id = this->AddEntityID(its->grf_prop.local_id, its->grf_prop.grffile->grfid, its->grf_prop.subst_id);
if (indt_id == invalid_ID) {
grfmsg(1, "IndustryTile.SetEntitySpec: Too many industry tiles allocated. Ignoring.");
if (indt_id == this->invalid_id) {
GrfMsg(1, "IndustryTile.SetEntitySpec: Too many industry tiles allocated. Ignoring.");
return;
}
memcpy(&_industry_tile_specs[indt_id], its, sizeof(*its));
_industry_tile_specs[indt_id] = *its;
/* Now add the overrides. */
for (int i = 0; i < max_offset; i++) {
for (int i = 0; i < this->max_offset; i++) {
IndustryTileSpec *overridden_its = &_industry_tile_specs[i];
if (entity_overrides[i] != its->grf_prop.local_id || grfid_overrides[i] != its->grf_prop.grffile->grfid) continue;
if (this->entity_overrides[i] != its->grf_prop.local_id || this->grfid_overrides[i] != its->grf_prop.grffile->grfid) continue;
overridden_its->grf_prop.override = indt_id;
overridden_its->enabled = false;
entity_overrides[i] = invalid_ID;
grfid_overrides[i] = 0;
this->entity_overrides[i] = this->invalid_id;
this->grfid_overrides[i] = 0;
}
}
@@ -317,7 +300,7 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec)
/* First step : We need to find if this object is already specified in the savegame data. */
ObjectType type = this->GetID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid);
if (type == invalid_ID) {
if (type == this->invalid_id) {
/* Not found.
* Or it has already been overridden, so you've lost your place.
* Or it is a simple substitute.
@@ -325,16 +308,16 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec)
type = this->AddEntityID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid, OBJECT_TRANSMITTER);
}
if (type == invalid_ID) {
grfmsg(1, "Object.SetEntitySpec: Too many objects allocated. Ignoring.");
if (type == this->invalid_id) {
GrfMsg(1, "Object.SetEntitySpec: Too many objects allocated. Ignoring.");
return;
}
extern ObjectSpec _object_specs[NUM_OBJECTS];
extern std::vector<ObjectSpec> _object_specs;
/* Now that we know we can use the given id, copy the spec to its final destination. */
memcpy(&_object_specs[type], spec, sizeof(*spec));
ObjectClass::Assign(&_object_specs[type]);
if (type >= _object_specs.size()) _object_specs.resize(type + 1);
_object_specs[type] = *spec;
}
/**
@@ -345,7 +328,7 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec)
* @return value corresponding to the grf expected format:
* Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline
*/
uint32 GetTerrainType(TileIndex tile, TileContext context)
uint32_t GetTerrainType(TileIndex tile, TileContext context)
{
switch (_settings_game.game_creation.landscape) {
case LT_TROPIC: return GetTropicZone(tile);
@@ -422,8 +405,8 @@ uint32 GetTerrainType(TileIndex tile, TileContext context)
*/
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis)
{
int8 x = GB(parameter, 0, 4);
int8 y = GB(parameter, 4, 4);
int8_t x = GB(parameter, 0, 4);
int8_t y = GB(parameter, 4, 4);
if (signed_offsets && x >= 8) x -= 16;
if (signed_offsets && y >= 8) y -= 16;
@@ -433,7 +416,7 @@ TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axi
if (axis == AXIS_Y) Swap(x, y);
/* Make sure we never roam outside of the map, better wrap in that case */
return TILE_MASK(tile + TileDiffXY(x, y));
return Map::WrapToMap(tile + TileDiffXY(x, y));
}
/**
@@ -443,7 +426,7 @@ TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axi
* @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
* @return 0czzbbss: c = TileType; zz = TileZ; bb: 7-3 zero, 4-2 TerrainType, 1 water/shore, 0 zero; ss = TileSlope
*/
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8)
{
TileType tile_type = GetTileType(tile);
@@ -455,7 +438,7 @@ uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
/* Return 0 if the tile is a land tile */
byte terrain_type = (HasTileWaterClass(tile) ? (GetWaterClass(tile) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
if (grf_version8) z /= TILE_HEIGHT;
return tile_type << 24 | Clamp(z, 0, 0xFF) << 16 | terrain_type << 8 | tileh;
return tile_type << 24 | ClampTo<uint8_t>(z) << 16 | terrain_type << 8 | tileh;
}
/**
@@ -464,7 +447,7 @@ uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
* @param l Livery of the object; nullptr to use default.
* @return NewGRF company information.
*/
uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
uint32_t GetCompanyInfo(CompanyID owner, const Livery *l)
{
if (l == nullptr && Company::IsValidID(owner)) l = &Company::Get(owner)->livery[LS_DEFAULT];
return owner | (Company::IsValidAiID(owner) ? 0x10000 : 0) | (l != nullptr ? (l->colour1 << 24) | (l->colour2 << 28) : 0);
@@ -477,7 +460,7 @@ uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
* @param default_error Error message to use for the generic error.
* @return CommandCost indicating success or the error message.
*/
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error)
CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, const GRFFile *grffile, StringID default_error)
{
CommandCost res;
@@ -513,7 +496,7 @@ CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFi
* @param cbid Callback causing the problem.
* @param cb_res Invalid result returned by the callback.
*/
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
{
GRFConfig *grfconfig = GetGRFConfig(grfid);
@@ -526,16 +509,12 @@ void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
}
/* debug output */
char buffer[512];
SetDParamStr(0, grfconfig->GetName());
GetString(buffer, STR_NEWGRF_BUGGY, lastof(buffer));
Debug(grf, 0, "{}", buffer + 3);
Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY)));
SetDParam(1, cbid);
SetDParam(2, cb_res);
GetString(buffer, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, lastof(buffer));
Debug(grf, 0, "{}", buffer + 3);
Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT)));
}
/**
@@ -547,7 +526,7 @@ void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
* @param cb_res Callback result.
* @return Boolean value. True if cb_res != 0.
*/
bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
{
assert(cb_res != CALLBACK_FAILED); // We do not know what to return
@@ -566,7 +545,7 @@ bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
* @param cb_res Callback result.
* @return Boolean value. True if cb_res != 0.
*/
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
{
assert(cb_res != CALLBACK_FAILED); // We do not know what to return
@@ -657,10 +636,10 @@ void NewGRFSpriteLayout::AllocateRegisters()
* @param separate_ground Whether the ground sprite shall be resolved by a separate action-1-2-3 chain by default.
* @return Bitmask of values for variable 10 to resolve action-1-2-3 chains for.
*/
uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const
uint32_t NewGRFSpriteLayout::PrepareLayout(uint32_t orig_offset, uint32_t newgrf_ground_offset, uint32_t newgrf_offset, uint constr_stage, bool separate_ground) const
{
result_seq.clear();
uint32 var10_values = 0;
uint32_t var10_values = 0;
/* Create a copy of the spritelayout, so we can modify some values.
* Also include the groundsprite into the sequence for easier processing. */
@@ -668,7 +647,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
result->image = ground;
result->delta_x = 0;
result->delta_y = 0;
result->delta_z = (int8)0x80;
result->delta_z = (int8_t)0x80;
const DrawTileSeqStruct *dtss;
foreach_draw_tile_seq(dtss, this->seq) {
@@ -685,7 +664,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
/* Record var10 value for the sprite */
if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) {
uint8 var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0);
uint8_t var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0);
SetBit(var10_values, var10);
}
@@ -701,7 +680,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
/* Record var10 value for the palette */
if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_PALETTE_REG_FLAGS)) {
uint8 var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0);
uint8_t var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0);
SetBit(var10_values, var10);
}
@@ -728,7 +707,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
* @param separate_ground Whether the ground sprite is resolved by a separate action-1-2-3 chain.
* @return Resulting spritelayout after processing the registers.
*/
void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const
void NewGRFSpriteLayout::ProcessRegisters(uint8_t resolved_var10, uint32_t resolved_sprite, bool separate_ground) const
{
DrawTileSeqStruct *result;
const TileLayoutRegisters *regs = this->registers;
@@ -740,7 +719,7 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_
/* Is the sprite or bounding box affected by an action-1-2-3 chain? */
if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) {
/* Does the var10 value apply to this sprite? */
uint8 var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0);
uint8_t var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0);
if (var10 == resolved_var10) {
/* Apply registers */
if ((flags & TLF_DODRAW) && GetRegister(regs->dodraw) == 0) {
@@ -748,7 +727,7 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_
} else {
if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) result->image.sprite += resolved_sprite;
if (flags & TLF_SPRITE) {
int16 offset = (int16)GetRegister(regs->sprite); // mask to 16 bits to avoid trouble
int16_t offset = (int16_t)GetRegister(regs->sprite); // mask to 16 bits to avoid trouble
if (!HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_sprite_offset)) {
result->image.sprite += offset;
} else {
@@ -758,13 +737,13 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_
if (result->IsParentSprite()) {
if (flags & TLF_BB_XY_OFFSET) {
result->delta_x += (int32)GetRegister(regs->delta.parent[0]);
result->delta_y += (int32)GetRegister(regs->delta.parent[1]);
result->delta_x += (int32_t)GetRegister(regs->delta.parent[0]);
result->delta_y += (int32_t)GetRegister(regs->delta.parent[1]);
}
if (flags & TLF_BB_Z_OFFSET) result->delta_z += (int32)GetRegister(regs->delta.parent[2]);
if (flags & TLF_BB_Z_OFFSET) result->delta_z += (int32_t)GetRegister(regs->delta.parent[2]);
} else {
if (flags & TLF_CHILD_X_OFFSET) result->delta_x += (int32)GetRegister(regs->delta.child[0]);
if (flags & TLF_CHILD_Y_OFFSET) result->delta_y += (int32)GetRegister(regs->delta.child[1]);
if (flags & TLF_CHILD_X_OFFSET) result->delta_x += (int32_t)GetRegister(regs->delta.child[0]);
if (flags & TLF_CHILD_Y_OFFSET) result->delta_y += (int32_t)GetRegister(regs->delta.child[1]);
}
}
}
@@ -773,12 +752,12 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_
/* Is the palette affected by an action-1-2-3 chain? */
if (result->image.sprite != 0 && (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_PALETTE_REG_FLAGS))) {
/* Does the var10 value apply to this sprite? */
uint8 var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0);
uint8_t var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0);
if (var10 == resolved_var10) {
/* Apply registers */
if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) result->image.pal += resolved_sprite;
if (flags & TLF_PALETTE) {
int16 offset = (int16)GetRegister(regs->palette); // mask to 16 bits to avoid trouble
int16_t offset = (int16_t)GetRegister(regs->palette); // mask to 16 bits to avoid trouble
if (!HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_palette_offset)) {
result->image.pal += offset;
} else {