From d98df6c88f4df51b8aa9b60bb05502eb8db16766 Mon Sep 17 00:00:00 2001 From: Kelenius Date: Thu, 21 Jan 2021 13:14:11 +0300 Subject: [PATCH] Cloning vats now stop spoiling --- .../terrain-manufactured.json | 2 +- doc/JSON_FLAGS.md | 1 + src/map.cpp | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/data/json/furniture_and_terrain/terrain-manufactured.json b/data/json/furniture_and_terrain/terrain-manufactured.json index b9cad4719f910..a6b8030a8cdd5 100644 --- a/data/json/furniture_and_terrain/terrain-manufactured.json +++ b/data/json/furniture_and_terrain/terrain-manufactured.json @@ -518,7 +518,7 @@ "move_cost": 0, "coverage": 40, "roof": "t_flat_roof", - "flags": [ "TRANSPARENT", "SEALED", "PLACE_ITEM", "WALL" ], + "flags": [ "TRANSPARENT", "SEALED", "PLACE_ITEM", "WALL", "NO_SPOIL" ], "bash": { "str_min": 2, "str_max": 80, diff --git a/doc/JSON_FLAGS.md b/doc/JSON_FLAGS.md index 56584ac9b0bbb..aa83b8104413e 100644 --- a/doc/JSON_FLAGS.md +++ b/doc/JSON_FLAGS.md @@ -565,6 +565,7 @@ List of known flags, used in both `terrain.json` and `furniture.json`. - ```NO_FLOOR``` Things should fall when placed on this tile - ```NO_SIGHT``` Creature on this tile have their sight reduced to one tile - ```NO_SCENT``` This tile cannot have scent values, which prevents scent diffusion through this tile +- ```NO_SPOIL``` Items placed in this tile do not spoil. - ```OPENCLOSE_INSIDE``` If it's a door (with an 'open' or 'close' field), it can only be opened or closed if you're inside. - ```PAINFUL``` May cause a small amount of pain. - ```PERMEABLE``` Permeable for gases. diff --git a/src/map.cpp b/src/map.cpp index d76543d6e1fd2..02d643d9950cf 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -4608,9 +4608,10 @@ void map::update_lum( item_location &loc, bool add ) } static bool process_map_items( item_stack &items, safe_reference &item_ref, - const tripoint &location, const float insulation, const temperature_flag flag ) + const tripoint &location, const float insulation, const temperature_flag flag, + const float spoil_multiplier ) { - if( item_ref->process( nullptr, location, insulation, flag ) ) { + if( item_ref->process( nullptr, location, insulation, flag, spoil_multiplier ) ) { // Item is to be destroyed so erase it from the map stack // unless it was already destroyed by processing. if( item_ref ) { @@ -4802,8 +4803,16 @@ void map::process_items_in_submap( submap ¤t_submap, const tripoint &gridp if( ter( map_location ) == t_rootcellar ) { flag = temperature_flag::ROOT_CELLAR; } + + float spoil_multiplier = 1.0f; + + if( has_flag( "NO_SPOIL", map_location ) ) { + spoil_multiplier = 0.0f; + } + map_stack items = i_at( map_location ); - process_map_items( items, active_item_ref.item_ref, map_location, 1, flag ); + + process_map_items( items, active_item_ref.item_ref, map_location, 1, flag, spoil_multiplier ); } } @@ -4878,7 +4887,7 @@ void map::process_items_in_vehicle( vehicle &cur_veh, submap ¤t_submap ) flag = temperature_flag::FREEZER; } } - if( !process_map_items( items, active_item_ref.item_ref, item_loc, it_insulation, flag ) ) { + if( !process_map_items( items, active_item_ref.item_ref, item_loc, it_insulation, flag, 1.0f ) ) { // If the item was NOT destroyed, we can skip the remainder, // which handles fallout from the vehicle being damaged. continue;