Fix handling of GRF programmable signal graphics with trace restrict

This commit is contained in:
Jonathan G Rennison
2019-04-02 18:19:28 +01:00
parent 53ff27370d
commit 5242ec4642
3 changed files with 40 additions and 22 deletions

View File

@@ -2357,33 +2357,43 @@ void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track track, Sign
uint x = TileX(tile) * TILE_SIZE + SignalPositions[side][pos].x;
uint y = TileY(tile) * TILE_SIZE + SignalPositions[side][pos].y;
SpriteID sprite = GetCustomSignalSprite(rti, tile, type, variant, condition);
bool is_custom_sprite = (sprite != 0);
if (sprite != 0) {
sprite += image;
SpriteID sprite;
bool is_custom_sprite;
if (type == SIGTYPE_PROG) {
if (variant == SIG_SEMAPHORE) {
sprite = SPR_PROGSIGNAL_BASE + image * 2 + condition;
} else {
sprite = SPR_PROGSIGNAL_BASE + 16 + image * 2 + condition;
}
extern int _progsig_grf_file_index;
is_custom_sprite = (int) GetOriginFileSlot(sprite) != _progsig_grf_file_index;
} else {
/* Normal electric signals are stored in a different sprite block than all other signals. */
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_ORIGINAL_SIGNALS_BASE : SPR_SIGNALS_BASE - 16;
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
}
sprite = GetCustomSignalSprite(rti, tile, type, variant, condition);
is_custom_sprite = (sprite != 0);
if (sprite != 0) {
sprite += image;
} else {
/* Normal electric signals are stored in a different sprite block than all other signals. */
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_ORIGINAL_SIGNALS_BASE : SPR_SIGNALS_BASE - 16;
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
}
if (type == SIGTYPE_PROG && variant == SIG_SEMAPHORE) {
sprite = SPR_PROGSIGNAL_BASE + image * 2 + condition;
is_custom_sprite = false;
} else if (type == SIGTYPE_PROG && variant == SIG_ELECTRIC) {
sprite = SPR_PROGSIGNAL_BASE + 16 + image * 2 + condition;
is_custom_sprite = false;
} else {
int origin_slot = GetOriginFileSlot(sprite);
extern int _first_user_grf_file_index;
extern int _opengfx_grf_file_index;
if (!is_custom_sprite) is_custom_sprite = origin_slot != _opengfx_grf_file_index && (origin_slot >= _first_user_grf_file_index);
if (!is_custom_sprite) {
int origin_slot = GetOriginFileSlot(sprite);
extern int _first_user_grf_file_index;
extern int _opengfx_grf_file_index;
is_custom_sprite = origin_slot != _opengfx_grf_file_index && (origin_slot >= _first_user_grf_file_index);
}
}
if (is_custom_sprite && show_restricted && _settings_client.gui.show_restricted_signal_default) {
/* Use duplicate sprite block, instead of GRF-specified signals */
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_DUP_ORIGINAL_SIGNALS_BASE : SPR_DUP_SIGNALS_BASE - 16;
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
if (type == SIGTYPE_PROG) {
sprite += SPR_DUP_PROGSIGNAL_BASE - SPR_PROGSIGNAL_BASE;
} else {
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_DUP_ORIGINAL_SIGNALS_BASE : SPR_DUP_SIGNALS_BASE - 16;
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
}
is_custom_sprite = false;
}