Fix handling of GRF programmable signal graphics with trace restrict
This commit is contained in:
@@ -50,6 +50,7 @@ static const SpriteID * const _landscape_spriteindexes[] = {
|
|||||||
/** file index of first user-added GRF file */
|
/** file index of first user-added GRF file */
|
||||||
int _first_user_grf_file_index;
|
int _first_user_grf_file_index;
|
||||||
int _opengfx_grf_file_index;
|
int _opengfx_grf_file_index;
|
||||||
|
int _progsig_grf_file_index;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load an old fashioned GRF file.
|
* Load an old fashioned GRF file.
|
||||||
@@ -182,8 +183,14 @@ static void LoadSpriteTables()
|
|||||||
LoadGrfFile(used_set->files[GFT_BASE].filename, 0, i++);
|
LoadGrfFile(used_set->files[GFT_BASE].filename, 0, i++);
|
||||||
|
|
||||||
/* Progsignal sprites. */
|
/* Progsignal sprites. */
|
||||||
|
_progsig_grf_file_index = i;
|
||||||
LoadGrfFile("progsignals.grf", SPR_PROGSIGNAL_BASE, i++);
|
LoadGrfFile("progsignals.grf", SPR_PROGSIGNAL_BASE, i++);
|
||||||
|
|
||||||
|
/* Fill duplicate programmable signal graphics sprite block */
|
||||||
|
for (uint i = 0; i < PROGSIGNAL_SPRITE_COUNT; i++) {
|
||||||
|
DupSprite(SPR_PROGSIGNAL_BASE + i, SPR_DUP_PROGSIGNAL_BASE + i);
|
||||||
|
}
|
||||||
|
|
||||||
/* Tracerestrict sprites. */
|
/* Tracerestrict sprites. */
|
||||||
LoadGrfFile("tracerestrict.grf", SPR_TRACERESTRICT_BASE, i++);
|
LoadGrfFile("tracerestrict.grf", SPR_TRACERESTRICT_BASE, i++);
|
||||||
|
|
||||||
|
@@ -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 x = TileX(tile) * TILE_SIZE + SignalPositions[side][pos].x;
|
||||||
uint y = TileY(tile) * TILE_SIZE + SignalPositions[side][pos].y;
|
uint y = TileY(tile) * TILE_SIZE + SignalPositions[side][pos].y;
|
||||||
|
|
||||||
SpriteID sprite = GetCustomSignalSprite(rti, tile, type, variant, condition);
|
SpriteID sprite;
|
||||||
bool is_custom_sprite = (sprite != 0);
|
bool is_custom_sprite;
|
||||||
if (sprite != 0) {
|
if (type == SIGTYPE_PROG) {
|
||||||
sprite += image;
|
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 {
|
} else {
|
||||||
/* Normal electric signals are stored in a different sprite block than all other signals. */
|
sprite = GetCustomSignalSprite(rti, tile, type, variant, condition);
|
||||||
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_ORIGINAL_SIGNALS_BASE : SPR_SIGNALS_BASE - 16;
|
is_custom_sprite = (sprite != 0);
|
||||||
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 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) {
|
if (!is_custom_sprite) {
|
||||||
sprite = SPR_PROGSIGNAL_BASE + image * 2 + condition;
|
int origin_slot = GetOriginFileSlot(sprite);
|
||||||
is_custom_sprite = false;
|
extern int _first_user_grf_file_index;
|
||||||
} else if (type == SIGTYPE_PROG && variant == SIG_ELECTRIC) {
|
extern int _opengfx_grf_file_index;
|
||||||
sprite = SPR_PROGSIGNAL_BASE + 16 + image * 2 + condition;
|
is_custom_sprite = origin_slot != _opengfx_grf_file_index && (origin_slot >= _first_user_grf_file_index);
|
||||||
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 && show_restricted && _settings_client.gui.show_restricted_signal_default) {
|
if (is_custom_sprite && show_restricted && _settings_client.gui.show_restricted_signal_default) {
|
||||||
/* Use duplicate sprite block, instead of GRF-specified signals */
|
/* 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;
|
if (type == SIGTYPE_PROG) {
|
||||||
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
|
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;
|
is_custom_sprite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -312,9 +312,10 @@ static const uint16 PALETTE_SPRITE_COUNT = 1;
|
|||||||
/* Programmable signal sprites */
|
/* Programmable signal sprites */
|
||||||
static const SpriteID SPR_PROGSIGNAL_BASE = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT;
|
static const SpriteID SPR_PROGSIGNAL_BASE = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT;
|
||||||
static const uint16 PROGSIGNAL_SPRITE_COUNT = 32;
|
static const uint16 PROGSIGNAL_SPRITE_COUNT = 32;
|
||||||
|
static const SpriteID SPR_DUP_PROGSIGNAL_BASE = SPR_PROGSIGNAL_BASE + PROGSIGNAL_SPRITE_COUNT;
|
||||||
|
|
||||||
/* Zoning sprites */
|
/* Zoning sprites */
|
||||||
static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_BASE = SPR_PROGSIGNAL_BASE + PROGSIGNAL_SPRITE_COUNT;
|
static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_BASE = SPR_DUP_PROGSIGNAL_BASE + PROGSIGNAL_SPRITE_COUNT;
|
||||||
static const uint16 ZONING_INNER_HIGHLIGHT_SPRITE_COUNT = 32;
|
static const uint16 ZONING_INNER_HIGHLIGHT_SPRITE_COUNT = 32;
|
||||||
static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_RED = SPR_ZONING_INNER_HIGHLIGHT_BASE + 19;
|
static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_RED = SPR_ZONING_INNER_HIGHLIGHT_BASE + 19;
|
||||||
static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_GREEN = SPR_ZONING_INNER_HIGHLIGHT_BASE + 20;
|
static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_GREEN = SPR_ZONING_INNER_HIGHLIGHT_BASE + 20;
|
||||||
|
Reference in New Issue
Block a user