Avoid unnecessary viewport redraws for unused tile loop house triggers
This commit is contained in:
@@ -320,6 +320,8 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti
|
||||
LoadStringWidthTable();
|
||||
AnalyseEngineCallbacks();
|
||||
AnalyseIndustryTileSpriteGroups();
|
||||
extern void AnalyseHouseSpriteGroups();
|
||||
AnalyseHouseSpriteGroups();
|
||||
|
||||
/* Re-init the windowing system */
|
||||
ResetWindowSystem();
|
||||
|
@@ -95,6 +95,13 @@ enum HouseExtraFlags {
|
||||
|
||||
DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags)
|
||||
|
||||
enum HouseCtrlFlags {
|
||||
HCF_NONE = 0,
|
||||
HCF_NO_TRIGGERS = 1U << 0, ///< this house does not use random triggers
|
||||
};
|
||||
|
||||
DECLARE_ENUM_AS_BIT_SET(HouseCtrlFlags)
|
||||
|
||||
struct HouseSpec {
|
||||
/* Standard properties */
|
||||
Year min_year; ///< introduction year of the house
|
||||
@@ -116,6 +123,7 @@ struct HouseSpec {
|
||||
byte random_colour[4]; ///< 4 "random" colours
|
||||
byte probability; ///< Relative probability of appearing (16 is the standard value)
|
||||
HouseExtraFlags extra_flags; ///< some more flags
|
||||
HouseCtrlFlags ctrl_flags; ///< control flags
|
||||
HouseClassID class_id; ///< defines the class this house has (not grf file based)
|
||||
AnimationInfo animation; ///< information about the animation.
|
||||
byte processing_time; ///< Periodic refresh multiplier
|
||||
|
@@ -299,7 +299,9 @@ void RandomizedSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) const
|
||||
{
|
||||
op.result_flags |= ACORF_CB_REFIT_CAP_NON_WHITELIST_FOUND;
|
||||
|
||||
if (op.mode == ACOM_CB_VAR) op.callbacks_used |= SGCU_RANDOM_TRIGGER;
|
||||
if ((op.mode == ACOM_CB_VAR || op.mode == ACOM_FIND_RANDOM_TRIGGER) && (this->triggers != 0 || this->cmp_mode == RSG_CMP_ALL)) {
|
||||
op.callbacks_used |= SGCU_RANDOM_TRIGGER;
|
||||
}
|
||||
|
||||
for (const SpriteGroup *group: this->groups) {
|
||||
if (group != nullptr) group->AnalyseCallbacks(op);
|
||||
|
@@ -23,6 +23,7 @@ enum AnalyseCallbackOperationMode : uint8 {
|
||||
ACOM_CB36_SPEED,
|
||||
ACOM_INDUSTRY_TILE,
|
||||
ACOM_CB_REFIT_CAPACITY,
|
||||
ACOM_FIND_RANDOM_TRIGGER,
|
||||
};
|
||||
|
||||
struct AnalyseCallbackOperationIndustryTileData;
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "newgrf_animation_base.h"
|
||||
#include "newgrf_cargo.h"
|
||||
#include "station_base.h"
|
||||
#include "newgrf_analysis.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
@@ -727,8 +728,12 @@ bool NewHouseTileLoop(TileIndex tile)
|
||||
return true;
|
||||
}
|
||||
|
||||
TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP);
|
||||
if (hs->building_flags & BUILDING_HAS_1_TILE) TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP_TOP);
|
||||
bool do_triggers = !(hs->ctrl_flags & HCF_NO_TRIGGERS);
|
||||
|
||||
if (do_triggers) {
|
||||
TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP);
|
||||
if (hs->building_flags & BUILDING_HAS_1_TILE) TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP_TOP);
|
||||
}
|
||||
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
|
||||
/* If this house is marked as having a synchronised callback, all the
|
||||
@@ -758,7 +763,7 @@ bool NewHouseTileLoop(TileIndex tile)
|
||||
}
|
||||
|
||||
SetHouseProcessingTime(tile, hs->processing_time);
|
||||
MarkTileDirtyByTile(tile, VMDF_NOT_MAP_MODE);
|
||||
if (do_triggers) MarkTileDirtyByTile(tile, VMDF_NOT_MAP_MODE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -857,3 +862,21 @@ void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes)
|
||||
if (hs->building_flags & BUILDING_HAS_4_TILES) DoWatchedCargoCallback(TILE_ADDXY(north, 1, 1), tile, trigger_cargoes, r);
|
||||
}
|
||||
|
||||
void AnalyseHouseSpriteGroups()
|
||||
{
|
||||
for (uint i = 0; i < NUM_HOUSES; i++) {
|
||||
HouseSpec *spec = HouseSpec::Get(i);
|
||||
spec->ctrl_flags = HCF_NONE;
|
||||
|
||||
if (spec->grf_prop.spritegroup[0] == nullptr) {
|
||||
spec->ctrl_flags |= HCF_NO_TRIGGERS;
|
||||
continue;
|
||||
}
|
||||
|
||||
AnalyseCallbackOperation find_triggers_op(ACOM_FIND_RANDOM_TRIGGER);
|
||||
spec->grf_prop.spritegroup[0]->AnalyseCallbacks(find_triggers_op);
|
||||
if ((find_triggers_op.callbacks_used & SGCU_RANDOM_TRIGGER) == 0) {
|
||||
spec->ctrl_flags |= HCF_NO_TRIGGERS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -166,4 +166,6 @@ enum HouseTrigger {
|
||||
};
|
||||
void TriggerHouse(TileIndex t, HouseTrigger trigger);
|
||||
|
||||
void AnalyseHouseSpriteGroups();
|
||||
|
||||
#endif /* NEWGRF_HOUSE_H */
|
||||
|
@@ -952,6 +952,8 @@ bool AfterLoadGame()
|
||||
|
||||
AfterLoadEngines();
|
||||
AnalyseIndustryTileSpriteGroups();
|
||||
extern void AnalyseHouseSpriteGroups();
|
||||
AnalyseHouseSpriteGroups();
|
||||
|
||||
/* Update all vehicles */
|
||||
AfterLoadVehicles(true);
|
||||
@@ -4211,6 +4213,8 @@ void ReloadNewGRFData()
|
||||
ResetVehicleHash();
|
||||
AfterLoadEngines();
|
||||
AnalyseIndustryTileSpriteGroups();
|
||||
extern void AnalyseHouseSpriteGroups();
|
||||
AnalyseHouseSpriteGroups();
|
||||
AfterLoadVehicles(false);
|
||||
StartupEngines();
|
||||
GroupStatistics::UpdateAfterLoad();
|
||||
|
@@ -592,7 +592,7 @@ class NIHHouse : public NIHelper {
|
||||
const HouseSpec *hs = HouseSpec::Get(GetHouseType(index));
|
||||
seprintf(buffer, lastof(buffer), " building_flags: 0x%X", hs->building_flags);
|
||||
output.print(buffer);
|
||||
seprintf(buffer, lastof(buffer), " extra_flags: 0x%X", hs->extra_flags);
|
||||
seprintf(buffer, lastof(buffer), " extra_flags: 0x%X, ctrl_flags: 0x%X", hs->extra_flags, hs->ctrl_flags);
|
||||
output.print(buffer);
|
||||
seprintf(buffer, lastof(buffer), " remove_rating_decrease: %u, minimum_life: %u", hs->remove_rating_decrease, hs->minimum_life);
|
||||
output.print(buffer);
|
||||
|
@@ -1814,7 +1814,7 @@ static_assert(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
|
||||
{ca1, ca2, ca3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
|
||||
{cg1, cg2, cg3, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID}, \
|
||||
bf, ba, true, GRFFileProps(INVALID_HOUSE_ID), 0, {0, 0, 0, 0}, \
|
||||
16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, {0, 2, 0, 0}, 0, 0, 0}
|
||||
16, NO_EXTRA_FLAG, HCF_NONE, HOUSE_NO_CLASS, {0, 2, 0, 0}, 0, 0, 0}
|
||||
/** House specifications from original data */
|
||||
static const HouseSpec _original_house_specs[] = {
|
||||
/**
|
||||
|
Reference in New Issue
Block a user