diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 494340fa35..043b6f2fa9 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4309,6 +4309,11 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, const G } break; + case A0RPI_OBJECT_FLOOD_RESISTANT: + if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; + SB(spec->ctrl_flags, OBJECT_CTRL_FLAG_FLOOD_RESISTANT, 1, (buf->ReadByte() != 0 ? 1 : 0)); + break; + default: ret = HandleAction0PropertyDefault(buf, prop); break; diff --git a/src/newgrf_extension.cpp b/src/newgrf_extension.cpp index e95df4862c..9fe94b966f 100644 --- a/src/newgrf_extension.cpp +++ b/src/newgrf_extension.cpp @@ -44,6 +44,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = { GRFFeatureInfo("action3_signals_custom_signal_sprites", 1), GRFFeatureInfo("action0_object_use_land_ground", 1), GRFFeatureInfo("action0_object_edge_foundation_mode", 1), + GRFFeatureInfo("action0_object_flood_resistant", 1), GRFFeatureInfo(), }; @@ -70,6 +71,7 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = { GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_EXTRA_ASPECTS, "signals_extra_aspects"), GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_USE_LAND_GROUND, "object_use_land_ground"), GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_EDGE_FOUNDATION_MODE, "object_edge_foundation_mode"), + GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_FLOOD_RESISTANT, "object_flood_resistant"), GRFPropertyMapDefinition(), }; diff --git a/src/newgrf_extension.h b/src/newgrf_extension.h index 0604ce2f7d..2c4b6aeafc 100644 --- a/src/newgrf_extension.h +++ b/src/newgrf_extension.h @@ -34,6 +34,7 @@ enum Action0RemapPropertyIds { A0RPI_SIGNALS_EXTRA_ASPECTS, A0RPI_OBJECT_USE_LAND_GROUND, A0RPI_OBJECT_EDGE_FOUNDATION_MODE, + A0RPI_OBJECT_FLOOD_RESISTANT, }; diff --git a/src/newgrf_object.h b/src/newgrf_object.h index 8174bd065b..0288466b87 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -44,6 +44,7 @@ enum ObjectCtrlFlags { OBJECT_CTRL_FLAG_NONE = 0, ///< Just nothing. OBJECT_CTRL_FLAG_USE_LAND_GROUND = 1 << 0, ///< Use land for ground sprite. OBJECT_CTRL_FLAG_EDGE_FOUNDATION = 1 << 2, ///< Use edge foundation mode. + OBJECT_CTRL_FLAG_FLOOD_RESISTANT = 1 << 3, ///< Object is flood-resistant. }; DECLARE_ENUM_AS_BIT_SET(ObjectCtrlFlags) diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index 599c6d2ae3..f59a99f6bb 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -717,7 +717,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags) /* Removing with the cheat costs more in TTDPatch / the specs. */ cost.MultiplyCost(25); } - } else if ((spec->flags & (OBJECT_FLAG_BUILT_ON_WATER | OBJECT_FLAG_NOT_ON_LAND)) != 0) { + } else if ((spec->flags & (OBJECT_FLAG_BUILT_ON_WATER | OBJECT_FLAG_NOT_ON_LAND)) != 0 || (spec->ctrl_flags & OBJECT_CTRL_FLAG_FLOOD_RESISTANT) != 0) { /* Water can't remove objects that are buildable on water. */ return CMD_ERROR; } diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index eb7029811a..e40f9226bc 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -902,6 +902,7 @@ class NIHObject : public NIHelper { check_flag(OBJECT_FLAG_SCALE_BY_WATER, "OBJECT_FLAG_SCALE_BY_WATER"); check_ctrl_flag(OBJECT_CTRL_FLAG_USE_LAND_GROUND, "OBJECT_CTRL_FLAG_USE_LAND_GROUND"); check_ctrl_flag(OBJECT_CTRL_FLAG_EDGE_FOUNDATION, "OBJECT_CTRL_FLAG_EDGE_FOUNDATION"); + check_ctrl_flag(OBJECT_CTRL_FLAG_FLOOD_RESISTANT, "OBJECT_CTRL_FLAG_FLOOD_RESISTANT"); } } }