diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 759693421a..47c25cc4e2 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -423,6 +423,7 @@ struct GRFLocation { static btree::btree_map _grm_sprites; typedef btree::btree_map GRFLineToSpriteOverride; static GRFLineToSpriteOverride _grf_line_to_action6_sprite_override; +static bool _action6_override_active = false; /** * DEBUG() function dedicated to newGRF debugging messages @@ -7594,6 +7595,7 @@ static void NewSpriteGroup(ByteReader *buf) DeterministicSpriteGroup *group = new DeterministicSpriteGroup(); group->nfo_line = _cur.nfo_line; group->feature = feature; + if (_action6_override_active) group->sg_flags |= SGF_ACTION6; act_group = group; group->var_scope = HasBit(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; @@ -7714,6 +7716,7 @@ static void NewSpriteGroup(ByteReader *buf) assert(RandomizedSpriteGroup::CanAllocateItem()); RandomizedSpriteGroup *group = new RandomizedSpriteGroup(); group->nfo_line = _cur.nfo_line; + if (_action6_override_active) group->sg_flags |= SGF_ACTION6; act_group = group; group->var_scope = HasBit(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; @@ -7821,6 +7824,7 @@ static void NewSpriteGroup(ByteReader *buf) assert(RealSpriteGroup::CanAllocateItem()); RealSpriteGroup *group = new RealSpriteGroup(); group->nfo_line = _cur.nfo_line; + if (_action6_override_active) group->sg_flags |= SGF_ACTION6; act_group = group; for (uint16 spriteid : loaded) { @@ -7846,6 +7850,7 @@ static void NewSpriteGroup(ByteReader *buf) assert(TileLayoutSpriteGroup::CanAllocateItem()); TileLayoutSpriteGroup *group = new TileLayoutSpriteGroup(); group->nfo_line = _cur.nfo_line; + if (_action6_override_active) group->sg_flags |= SGF_ACTION6; act_group = group; /* On error, bail out immediately. Temporary GRF data was already freed */ @@ -7862,6 +7867,7 @@ static void NewSpriteGroup(ByteReader *buf) assert(IndustryProductionSpriteGroup::CanAllocateItem()); IndustryProductionSpriteGroup *group = new IndustryProductionSpriteGroup(); group->nfo_line = _cur.nfo_line; + if (_action6_override_active) group->sg_flags |= SGF_ACTION6; act_group = group; group->version = type; if (type == 0) { @@ -12715,6 +12721,7 @@ static void DecodeSpecialSprite(byte *buf, uint num, GrfLoadingStage stage) GRFLocation location(_cur.grfconfig->ident.grfid, _cur.nfo_line); GRFLineToSpriteOverride::iterator it = _grf_line_to_action6_sprite_override.find(location); + _action6_override_active = (it != _grf_line_to_action6_sprite_override.end()); if (it == _grf_line_to_action6_sprite_override.end()) { /* No preloaded sprite to work with; read the * pseudo sprite content. */ diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index 3d0f42b543..a16dbacf37 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -798,11 +798,14 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, int padding, uint } }); + char extra_info[64] = ""; + if (sg->sg_flags & SGF_ACTION6) strecat(extra_info, " (action 6 modified)", lastof(extra_info)); + switch (sg->type) { case SGT_REAL: { const RealSpriteGroup *rsg = (const RealSpriteGroup*)sg; - seprintf(this->buffer, lastof(this->buffer), "%*sReal (loaded: %u, loading: %u) [%u]", - padding, "", (uint)rsg->loaded.size(), (uint)rsg->loading.size(), sg->nfo_line); + seprintf(this->buffer, lastof(this->buffer), "%*sReal (loaded: %u, loading: %u)%s [%u]", + padding, "", (uint)rsg->loaded.size(), (uint)rsg->loading.size(), extra_info, sg->nfo_line); print(); emit_start(); for (size_t i = 0; i < rsg->loaded.size(); i++) { @@ -849,8 +852,8 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, int padding, uint print(); return; } - seprintf(this->buffer, lastof(this->buffer), "%*sDeterministic (%s, %s), [%u]", - padding, "", _sg_scope_names[dsg->var_scope], _sg_size_names[dsg->size], dsg->nfo_line); + seprintf(this->buffer, lastof(this->buffer), "%*sDeterministic (%s, %s)%s [%u]", + padding, "", _sg_scope_names[dsg->var_scope], _sg_size_names[dsg->size], extra_info, dsg->nfo_line); print(); emit_start(); padding += 2; @@ -890,9 +893,9 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, int padding, uint } } - seprintf(this->buffer, lastof(this->buffer), "%*sRandom (%s, %s, triggers: %X, count: %X, lowest_randbit: %X, groups: %u) [%u]", + seprintf(this->buffer, lastof(this->buffer), "%*sRandom (%s, %s, triggers: %X, count: %X, lowest_randbit: %X, groups: %u)%s [%u]", padding, "", _sg_scope_names[rsg->var_scope], rsg->cmp_mode == RSG_CMP_ANY ? "ANY" : "ALL", - rsg->triggers, rsg->count, rsg->lowest_randbit, (uint)rsg->groups.size(), rsg->nfo_line); + rsg->triggers, rsg->count, rsg->lowest_randbit, (uint)rsg->groups.size(), extra_info, rsg->nfo_line); print(); emit_start(); for (const auto &group : (*groups)) { @@ -911,7 +914,7 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, int padding, uint break; case SGT_TILELAYOUT: { const TileLayoutSpriteGroup *tlsg = (const TileLayoutSpriteGroup*)sg; - seprintf(this->buffer, lastof(this->buffer), "%*sTile Layout [%u]", padding, "", sg->nfo_line); + seprintf(this->buffer, lastof(this->buffer), "%*sTile Layout%s [%u]", padding, "", extra_info, sg->nfo_line); print(); emit_start(); padding += 2; diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 63728e9561..84e940899e 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -94,6 +94,12 @@ struct AnalyseCallbackOperation { typedef Pool SpriteGroupPool; extern SpriteGroupPool _spritegroup_pool; +enum SpriteGroupFlags : uint8 { + SGF_NONE = 0, + SGF_ACTION6 = 1 << 0, +}; +DECLARE_ENUM_AS_BIT_SET(SpriteGroupFlags) + /* Common wrapper for all the different sprite group types */ struct SpriteGroup : SpriteGroupPool::PoolItem<&_spritegroup_pool> { protected: @@ -107,6 +113,7 @@ public: uint32 nfo_line; SpriteGroupType type; GrfSpecFeature feature; + SpriteGroupFlags sg_flags = SGF_NONE; virtual SpriteID GetResult() const { return 0; } virtual byte GetNumResults() const { return 0; }