From 59fa12da5182795ba0543f54455ca3caf63260bc Mon Sep 17 00:00:00 2001 From: Valiant Date: Wed, 31 Jul 2019 19:48:18 +0400 Subject: [PATCH 001/113] Default r keybinding to Reload Item instead of a Reload Wielded Item --- data/raw/keybindings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/raw/keybindings.json b/data/raw/keybindings.json index 587e2365c7114..b6009b688826f 100644 --- a/data/raw/keybindings.json +++ b/data/raw/keybindings.json @@ -1613,8 +1613,7 @@ "type": "keybinding", "name": "Reload Wielded Item", "category": "DEFAULTMODE", - "id": "reload_weapon", - "bindings": [ { "input_method": "keyboard", "key": "r" } ] + "id": "reload_weapon" }, { "type": "keybinding", @@ -1911,7 +1910,8 @@ "type": "keybinding", "name": "Reload Item", "category": "DEFAULTMODE", - "id": "reload_item" + "id": "reload_item", + "bindings": [ { "input_method": "keyboard", "key": "r" } ] }, { "type": "keybinding", From fbe9b1bc2a497bf7a0bf23988da3d11da528650e Mon Sep 17 00:00:00 2001 From: KorGgenT Date: Fri, 16 Aug 2019 13:15:48 -0400 Subject: [PATCH 002/113] use get_int() for reading --- src/avatar.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/avatar.cpp b/src/avatar.cpp index 22bd1e4934986..e0b1cd4fda273 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -565,7 +565,7 @@ int avatar::time_to_read( const item &book, const player &reader, const player * int retval = type->time * reading_speed; retval *= std::min( fine_detail_vision_mod(), reader.fine_detail_vision_mod() ); - const int effective_int = std::min( {int_cur, reader.get_int(), learner ? learner->get_int() : INT_MAX } ); + const int effective_int = std::min( { get_int(), reader.get_int(), learner ? learner->get_int() : INT_MAX } ); if( type->intel > effective_int && !reader.has_trait( trait_PROF_DICEMASTER ) ) { retval += type->time * ( type->intel - effective_int ) * 100; } @@ -816,9 +816,10 @@ bool avatar::read( int inventory_position, const bool continuous ) reader->disp_name() ); } - const bool complex_penalty = type->intel > std::min( int_cur, reader->get_int() ) && + const int intelligence = get_int(); + const bool complex_penalty = type->intel > std::min( intelligence, reader->get_int() ) && !reader->has_trait( trait_PROF_DICEMASTER ); - const player *complex_player = reader->get_int() < int_cur ? reader : this; + const player *complex_player = reader->get_int() < intelligence ? reader : this; if( complex_penalty && !continuous ) { add_msg( m_warning, _( "This book is too complex for %s to easily understand. It will take longer to read." ), From fac93a7df855a6a6f5fac716278c191a6bea2877 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 9 Aug 2019 10:28:15 -0700 Subject: [PATCH 003/113] Add the ability to strap mattresses to vehicles --- data/json/vehicleparts/rams.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/data/json/vehicleparts/rams.json b/data/json/vehicleparts/rams.json index 74d257d886361..77cb7c640e7c7 100644 --- a/data/json/vehicleparts/rams.json +++ b/data/json/vehicleparts/rams.json @@ -129,6 +129,23 @@ "breaks_into": [ { "item": "chitin_piece", "count": [ 6, 19 ] } ], "damage_reduction": { "all": 110 } }, + { + "id": "ram_mattress", + "copy-from": "ram_blaze", + "type": "vehicle_part", + "name": "tied mattress", + "symbol": "=", + "item": "mattress", + "color": "white", + "difficulty": 0, + "requirements": { "install": { "time": 30000, "using": [ [ "rope_natural_short", 2 ] ] } }, + "damage_modifier": 50, + "durability": 40, + "description": "A mattress, strapped onto the vehicle. It could serve to blunt any impact.", + "breaks_into": [ { "item": "rag", "count": [ 40, 55 ] } ], + "damage_reduction": { "bash": 20 }, + "flags": [ "PROTRUSION", "OBSTACLE", "OPAQUE", "TOOL_NONE" ] + }, { "id": "tearer", "type": "vehicle_part", From 69198cb6f711eaee976f8c5f69d85195adc57c4a Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 16 Aug 2019 10:57:59 -0700 Subject: [PATCH 004/113] Set a default container for dog and cat food --- data/json/items/comestibles/other.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/json/items/comestibles/other.json b/data/json/items/comestibles/other.json index 43229d656c064..b9b73d7621869 100644 --- a/data/json/items/comestibles/other.json +++ b/data/json/items/comestibles/other.json @@ -586,6 +586,7 @@ "description": "This is food for dogs. It smells strange, but dogs seem to love it.", "weight": 554, "spoils_in": "1 day", + "container": "can_food", "volume": 1, "price": 300, "to_hit": -5, @@ -609,6 +610,7 @@ "description": "This is food for cats. It smells strange, but cats seem to love it.", "weight": 223, "spoils_in": "1 day", + "container": "can_food", "volume": 1, "price": 300, "to_hit": -5, From 2e85ef4cde79ed823dfa3c15af872d2e9ea7c3a4 Mon Sep 17 00:00:00 2001 From: Valiant Date: Fri, 16 Aug 2019 21:59:23 +0400 Subject: [PATCH 005/113] Removed luminance from all turret types --- data/json/monsters/defense_bot.json | 1 - data/json/monsters/military.json | 3 --- 2 files changed, 4 deletions(-) diff --git a/data/json/monsters/defense_bot.json b/data/json/monsters/defense_bot.json index fad13990741c5..6653cede633f4 100644 --- a/data/json/monsters/defense_bot.json +++ b/data/json/monsters/defense_bot.json @@ -45,7 +45,6 @@ "morale": 100, "armor_bash": 14, "armor_cut": 16, - "luminance": 200, "revert_to_itype": "bot_turret", "starting_ammo": { "9mm": 100 }, "special_attacks": [ diff --git a/data/json/monsters/military.json b/data/json/monsters/military.json index 8e5929665ce40..e1689fa64d46e 100644 --- a/data/json/monsters/military.json +++ b/data/json/monsters/military.json @@ -18,7 +18,6 @@ "morale": 100, "armor_bash": 14, "armor_cut": 16, - "luminance": 200, "revert_to_itype": "bot_laserturret", "special_attacks": [ { @@ -54,7 +53,6 @@ "morale": 100, "armor_bash": 14, "armor_cut": 16, - "luminance": 210, "revert_to_itype": "bot_antimateriel", "starting_ammo": { "50bmg": 100 }, "special_attacks": [ @@ -100,7 +98,6 @@ "morale": 100, "armor_bash": 14, "armor_cut": 16, - "luminance": 210, "revert_to_itype": "bot_rifleturret", "starting_ammo": { "556": 100 }, "special_attacks": [ From 79758a70892a5805f2a551259027933fe0921321 Mon Sep 17 00:00:00 2001 From: Valiant Date: Fri, 16 Aug 2019 22:01:48 +0400 Subject: [PATCH 006/113] Added a 3 tile night vision radius to most turret types --- data/json/monsters/defense_bot.json | 1 + data/json/monsters/military.json | 2 ++ 2 files changed, 3 insertions(+) diff --git a/data/json/monsters/defense_bot.json b/data/json/monsters/defense_bot.json index 6653cede633f4..daa4d8c99a48f 100644 --- a/data/json/monsters/defense_bot.json +++ b/data/json/monsters/defense_bot.json @@ -45,6 +45,7 @@ "morale": 100, "armor_bash": 14, "armor_cut": 16, + "vision_night": 3, "revert_to_itype": "bot_turret", "starting_ammo": { "9mm": 100 }, "special_attacks": [ diff --git a/data/json/monsters/military.json b/data/json/monsters/military.json index e1689fa64d46e..276adc28e37fe 100644 --- a/data/json/monsters/military.json +++ b/data/json/monsters/military.json @@ -53,6 +53,7 @@ "morale": 100, "armor_bash": 14, "armor_cut": 16, + "vision_night": 3, "revert_to_itype": "bot_antimateriel", "starting_ammo": { "50bmg": 100 }, "special_attacks": [ @@ -98,6 +99,7 @@ "morale": 100, "armor_bash": 14, "armor_cut": 16, + "vision_night": 3, "revert_to_itype": "bot_rifleturret", "starting_ammo": { "556": 100 }, "special_attacks": [ From faac35e2e4dc955300b028cfea8d81fbddd1014e Mon Sep 17 00:00:00 2001 From: Valiant Date: Fri, 16 Aug 2019 22:28:37 +0400 Subject: [PATCH 007/113] Increased maximum fire ranges for most turrets Also removed explicit M4 carbine mention from description of milspec turret. Now it's a vague "5.56mm carbine". --- data/json/monsters/defense_bot.json | 2 +- data/json/monsters/military.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/json/monsters/defense_bot.json b/data/json/monsters/defense_bot.json index daa4d8c99a48f..fb06540a1f133 100644 --- a/data/json/monsters/defense_bot.json +++ b/data/json/monsters/defense_bot.json @@ -49,7 +49,7 @@ "revert_to_itype": "bot_turret", "starting_ammo": { "9mm": 100 }, "special_attacks": [ - { "type": "gun", "cooldown": 1, "gun_type": "hk_mp5", "ranges": [ [ 0, 6, "AUTO" ], [ 7, 12, "DEFAULT" ] ] }, + { "type": "gun", "cooldown": 1, "gun_type": "hk_mp5", "ranges": [ [ 0, 6, "AUTO" ], [ 7, 14, "DEFAULT" ] ] }, [ "PARROT", 40 ] ], "death_drops": { }, diff --git a/data/json/monsters/military.json b/data/json/monsters/military.json index 276adc28e37fe..a55dfa1bce70c 100644 --- a/data/json/monsters/military.json +++ b/data/json/monsters/military.json @@ -65,7 +65,7 @@ "ammo_type": "50bmg", "fake_skills": [ [ "gun", 8 ], [ "rifle", 8 ] ], "fake_dex": 12, - "ranges": [ [ 0, 30, "DEFAULT" ] ], + "ranges": [ [ 0, 40, "DEFAULT" ] ], "require_targeting_npc": true, "require_targeting_monster": true, "laser_lock": true, @@ -84,7 +84,7 @@ "id": "mon_turret_rifle", "type": "MONSTER", "name": "milspec turret", - "description": "Leadworks LLC's T-4A1 Sentry. It features improved firmware over General Atomics' TX-1 9x19mm model and an automated M4 carbine.", + "description": "Leadworks LLC's T-4A1 Sentry. It features improved firmware over General Atomics' TX-1 9x19mm model and an automated 5.56mm carbine.", "default_faction": "military", "species": [ "ROBOT" ], "diff": 20, @@ -111,7 +111,7 @@ "fake_skills": [ [ "gun", 6 ], [ "rifle", 8 ] ], "fake_dex": 10, "range": 18, - "ranges": [ [ 0, 8, "AUTO" ], [ 9, 16, "DEFAULT" ] ] + "ranges": [ [ 0, 10, "AUTO" ], [ 11, 30, "DEFAULT" ] ] } ], "death_drops": { }, From 41875b2f68988e8e2ee732f9b27850bea2144749 Mon Sep 17 00:00:00 2001 From: Valiant Date: Fri, 16 Aug 2019 22:37:32 +0400 Subject: [PATCH 008/113] Added a laser turret to a military bunker mapgen --- data/json/mapgen/outpost.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/data/json/mapgen/outpost.json b/data/json/mapgen/outpost.json index b28294ed67fe6..4e945795d7679 100644 --- a/data/json/mapgen/outpost.json +++ b/data/json/mapgen/outpost.json @@ -95,13 +95,13 @@ "toilets": { "&": { } }, "place_monster": [ { "monster": "mon_turret_rifle", "x": 10, "y": 1 }, - { "monster": "mon_turret_rifle", "x": 13, "y": 1 }, + { "monster": "mon_laserturret", "x": 13, "y": 1 }, { "monster": "mon_turret_rifle", "x": 1, "y": 10 }, - { "monster": "mon_turret_rifle", "x": 1, "y": 13 }, + { "monster": "mon_laserturret", "x": 1, "y": 13 }, { "monster": "mon_turret_rifle", "x": 22, "y": 10 }, - { "monster": "mon_turret_rifle", "x": 22, "y": 13 }, + { "monster": "mon_laserturret", "x": 22, "y": 13 }, { "monster": "mon_turret_rifle", "x": 10, "y": 22 }, - { "monster": "mon_turret_rifle", "x": 13, "y": 22 }, + { "monster": "mon_laserturret", "x": 13, "y": 22 }, { "monster": "mon_turret_searchlight", "x": 1, "y": 1 }, { "monster": "mon_turret_searchlight", "x": 22, "y": 22 }, { "monster": "mon_turret_searchlight", "x": 1, "y": 22 }, @@ -220,13 +220,13 @@ "toilets": { "&": { } }, "place_monster": [ { "monster": "mon_turret_rifle", "x": 10, "y": 1 }, - { "monster": "mon_turret_rifle", "x": 13, "y": 1 }, + { "monster": "mon_laserturret", "x": 13, "y": 1 }, { "monster": "mon_turret_rifle", "x": 1, "y": 10 }, - { "monster": "mon_turret_rifle", "x": 1, "y": 13 }, + { "monster": "mon_laserturret", "x": 1, "y": 13 }, { "monster": "mon_turret_rifle", "x": 22, "y": 10 }, - { "monster": "mon_turret_rifle", "x": 22, "y": 13 }, + { "monster": "mon_laserturret", "x": 22, "y": 13 }, { "monster": "mon_turret_rifle", "x": 10, "y": 22 }, - { "monster": "mon_turret_rifle", "x": 13, "y": 22 }, + { "monster": "mon_laserturret", "x": 13, "y": 22 }, { "monster": "mon_turret_searchlight", "x": 1, "y": 1 }, { "monster": "mon_turret_searchlight", "x": 22, "y": 22 }, { "monster": "mon_turret_searchlight", "x": 1, "y": 22 }, From 8b2986858991361047a62c8e859eb30bf16a79cf Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 14:29:26 -0400 Subject: [PATCH 009/113] repeat_clang_tidy tweaks - Fix the regex command line argument (this didn't work before because of a copy/paste error). - Limit the number of passes to 10 (because I accidentally left this running for many hours). --- tools/repeat_clang_tidy.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/repeat_clang_tidy.sh b/tools/repeat_clang_tidy.sh index 50e6175da1c0e..b31ed1d5171c7 100755 --- a/tools/repeat_clang_tidy.sh +++ b/tools/repeat_clang_tidy.sh @@ -5,11 +5,12 @@ # It runs clang-tidy on all files (or, if you provide suitable arguments, all # files matching a particular regex). # It notes any file which had an error, and runs again on all those files. -# It repeats until there are no more errors. +# It repeats until there are no more errors or until it has performed 10 +# passes. # This is useful to catch refactoring changes from checks which open the # possibility for more refactoring changes. # There are a couple of limitations: -# - If an error has no FIX-IT, then the script will just run forever repeating +# - If an error has no FIX-IT, then the script will just keep repeating # that error. You can go fix it by hand while the script is still running. # - If you run clang-tidy in parallel (pass the number of jobs as an argument # to this script) and multiple clang-tidy runs try to fix the same header at @@ -31,7 +32,7 @@ fi if [ $# -ge 2 ] then - file_regex="$1" + file_regex="$2" else file_regex='.' fi @@ -49,6 +50,7 @@ fi temp_file=$(mktemp) trap "rm -f $temp_file" EXIT +num_iterations=0 while [ -n "$list_of_files" ] do @@ -60,4 +62,8 @@ do "$script_dir/repeat_clang_tidy_helper.sh" \ -quiet -fix ${plugin_opt:+"$plugin_opt"} list_of_files="$(cat $temp_file)" + if (( ++num_iterations >= 10 )) + then + break + fi done From f7e1d4154e894a048e3fdf8502b493e281505b35 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Fri, 16 Aug 2019 21:42:29 +0200 Subject: [PATCH 010/113] Show item-related move costs in moves, instead of time duration: The costs are in moves, faster characters can do those tasks quicker than slower characters. Showing it in moves is also more accurate, and avoids showing "0 seconds" caused by rounding down a value of 99 moves (99/100 is 0). And it makes values like 100 and 199 (which both show up as "1 seconds") better to compare. --- src/item.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/item.cpp b/src/item.cpp index e55fad09fe289..ecd28828c58a0 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1382,8 +1382,8 @@ std::string item::info( std::vector &info, const iteminfo_query *parts } } if( parts->test( iteminfo_parts::MAGAZINE_RELOAD ) ) { - info.emplace_back( "MAGAZINE", _( "Reload time: " ), _( " per round" ), - iteminfo::lower_is_better, type->magazine->reload_time / 100 ); + info.emplace_back( "MAGAZINE", _( "Reload time: " ), _( " moves per round" ), + iteminfo::lower_is_better, type->magazine->reload_time ); } insert_separation_line(); } @@ -1548,9 +1548,9 @@ std::string item::info( std::vector &info, const iteminfo_query *parts info.emplace_back( "GUN", _( "Even chance of good hit at range: " ), _( "" ), iteminfo::no_flags, range ); int aim_mv = g->u.gun_engagement_moves( *mod, type.threshold ); - info.emplace_back( "GUN", _( "Time to reach aim level: " ), _( " seconds" ), + info.emplace_back( "GUN", _( "Time to reach aim level: " ), _( " moves " ), iteminfo::is_decimal | iteminfo::lower_is_better, - TICKS_TO_SECONDS( aim_mv ) ); + aim_mv ); } } @@ -1686,9 +1686,9 @@ std::string item::info( std::vector &info, const iteminfo_query *parts if( parts->test( iteminfo_parts::GUN_RELOAD_TIME ) ) { info.emplace_back( "GUN", _( "Reload time: " ), - has_flag( "RELOAD_ONE" ) ? _( " seconds per round" ) : _( " seconds" ), + has_flag( "RELOAD_ONE" ) ? _( " moves per round" ) : _( " moves " ), iteminfo::lower_is_better, - mod->get_reload_time() / 100 ); + mod->get_reload_time() ); } if( parts->test( iteminfo_parts::GUN_FIRE_MODES ) ) { From 6ba7585a57ba6c569534755817852f04e3fe179e Mon Sep 17 00:00:00 2001 From: free-coffee Date: Fri, 16 Aug 2019 21:47:36 +0200 Subject: [PATCH 011/113] fix: missing roofs (on lab entrances). --- data/json/furniture_and_terrain/terrain-floors_indoor.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/json/furniture_and_terrain/terrain-floors_indoor.json b/data/json/furniture_and_terrain/terrain-floors_indoor.json index d5a2ca42ba50e..ef10c44a37b93 100644 --- a/data/json/furniture_and_terrain/terrain-floors_indoor.json +++ b/data/json/furniture_and_terrain/terrain-floors_indoor.json @@ -7,6 +7,7 @@ "symbol": ".", "color": "cyan", "move_cost": 2, + "roof": "t_flat_roof", "flags": [ "TRANSPARENT", "SUPPORTS_ROOF", "COLLAPSES", "INDOORS", "FLAT", "ROAD" ], "bash": { "sound": "SMASH!", @@ -30,6 +31,7 @@ "color": "yellow", "looks_like": "t_wall_y", "move_cost": 2, + "roof": "t_flat_roof", "flags": [ "TRANSPARENT", "SUPPORTS_ROOF", "COLLAPSES", "INDOORS", "FLAT", "ROAD" ], "bash": { "sound": "SMASH!", From 8beef198d7b71f09c843883a13b7e25cd2e091f2 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 13:04:31 -0400 Subject: [PATCH 012/113] Generalize name-matching for UsePointApis Previously it only detected parameters whose name ended in 'x'. Now supports 'X', and names starting with 'x' or 'X'. --- tools/clang-tidy-plugin/CMakeLists.txt | 1 + tools/clang-tidy-plugin/UsePointApisCheck.cpp | 39 ++++++------ tools/clang-tidy-plugin/Utils.cpp | 62 +++++++++++++++++++ tools/clang-tidy-plugin/Utils.h | 35 ++++++++++- .../clang-tidy-plugin/test/use-point-apis.cpp | 30 +++++++++ 5 files changed, 148 insertions(+), 19 deletions(-) create mode 100644 tools/clang-tidy-plugin/Utils.cpp diff --git a/tools/clang-tidy-plugin/CMakeLists.txt b/tools/clang-tidy-plugin/CMakeLists.txt index 992d8d90003b2..f249d2dc8e5f8 100644 --- a/tools/clang-tidy-plugin/CMakeLists.txt +++ b/tools/clang-tidy-plugin/CMakeLists.txt @@ -12,6 +12,7 @@ add_library( UseNamedPointConstantsCheck.cpp UsePointApisCheck.cpp UsePointArithmeticCheck.cpp + Utils.cpp XYCheck.cpp ) diff --git a/tools/clang-tidy-plugin/UsePointApisCheck.cpp b/tools/clang-tidy-plugin/UsePointApisCheck.cpp index 33dc7968a4433..4fa92382c6801 100644 --- a/tools/clang-tidy-plugin/UsePointApisCheck.cpp +++ b/tools/clang-tidy-plugin/UsePointApisCheck.cpp @@ -22,7 +22,7 @@ void UsePointApisCheck::registerMatchers( MatchFinder *Finder ) expr().bind( "xarg" ), parmVarDecl( anyOf( hasType( asString( "int" ) ), hasType( asString( "const int" ) ) ), - matchesName( "x$" ) + isXParam() ).bind( "xparam" ) ), callee( functionDecl().bind( "callee" ) ) @@ -74,8 +74,6 @@ static void CheckCall( UsePointApisCheck &Check, const MatchFinder::MatchResult return; } - llvm::StringRef XPrefix = XParam->getName().drop_back(); - const Expr *YArg = nullptr; const Expr *ZArg = nullptr; unsigned int MinArg = UINT_MAX; @@ -97,26 +95,31 @@ static void CheckCall( UsePointApisCheck &Check, const MatchFinder::MatchResult return; } + NameConvention NameMatcher( XParam->getName() ); + + if( !NameMatcher ) { + return; + } + for( unsigned int i = SkipArgs; i < Call->getNumArgs(); ++i ) { const ParmVarDecl *Param = Callee->getParamDecl( i - SkipArgs ); - StringRef Name = Param->getName(); - if( Name.size() > 0 && Name.drop_back() == XPrefix ) { - bool Matched = false; - - if( Name.endswith( "x" ) ) { - Matched = true; - } else if( Name.endswith( "y" ) ) { + bool Matched = true; + switch( NameMatcher.Match( Param->getName() ) ) { + case NameConvention::XName: + break; + case NameConvention::YName: YArg = Call->getArg( i ); - Matched = true; - } else if( Name.endswith( "z" ) ) { + break; + case NameConvention::ZName: ZArg = Call->getArg( i ); - Matched = true; - } + break; + default: + Matched = false; + } - if( Matched ) { - MinArg = std::min( MinArg, i ); - MaxArg = std::max( MaxArg, i ); - } + if( Matched ) { + MinArg = std::min( MinArg, i ); + MaxArg = std::max( MaxArg, i ); } } diff --git a/tools/clang-tidy-plugin/Utils.cpp b/tools/clang-tidy-plugin/Utils.cpp new file mode 100644 index 0000000000000..3f41424db2680 --- /dev/null +++ b/tools/clang-tidy-plugin/Utils.cpp @@ -0,0 +1,62 @@ +#include "Utils.h" + +namespace clang +{ +namespace tidy +{ +namespace cata +{ + +NameConvention::NameConvention( StringRef xName ) +{ + if( xName.endswith( "x" ) ) { + root = xName.drop_back(); + capital = false; + atEnd = true; + } else if( xName.endswith( "X" ) ) { + root = xName.drop_back(); + capital = true; + atEnd = true; + } else if( xName.startswith( "x" ) ) { + root = xName.drop_front(); + capital = false; + atEnd = false; + } else if( xName.startswith( "X" ) ) { + root = xName.drop_front(); + capital = true; + atEnd = false; + } else { + valid = false; + } +} + +NameConvention::MatchResult NameConvention::Match( StringRef name ) +{ + if( name.empty() ) { + return None; + } + + StringRef Root = atEnd ? name.drop_back() : name.drop_front(); + if( Root != root ) { + return None; + } + + char Dim = atEnd ? name.back() : name.front(); + switch( Dim ) { + case 'x': + case 'X': + return XName; + case 'y': + case 'Y': + return YName; + case 'z': + case 'Z': + return ZName; + default: + return None; + } +} + +} // namespace cata +} // namespace tidy +} // namespace clang diff --git a/tools/clang-tidy-plugin/Utils.h b/tools/clang-tidy-plugin/Utils.h index bce510ffba826..ba0321009e5f1 100644 --- a/tools/clang-tidy-plugin/Utils.h +++ b/tools/clang-tidy-plugin/Utils.h @@ -1,7 +1,8 @@ #ifndef CATA_TOOLS_CLANG_TIDY_UTILS_H #define CATA_TOOLS_CLANG_TIDY_UTILS_H -#include "clang/ASTMatchers/ASTMatchFinder.h" +#include +#include namespace clang { @@ -82,6 +83,38 @@ inline auto testWhetherConstructingTemporary() ); } +inline auto isXParam() +{ + using namespace clang::ast_matchers; + return matchesName( "[xX]" ); +} + +// Struct to help identify and construct names of associated points and +// coordinates +class NameConvention +{ + public: + NameConvention( StringRef xName ); + + enum MatchResult { + XName, + YName, + ZName, + None + }; + + MatchResult Match( StringRef name ); + + bool operator!() const { + return !valid; + } + private: + std::string root; + bool capital; + bool atEnd; + bool valid = true; +}; + } // namespace cata } // namespace tidy } // namespace clang diff --git a/tools/clang-tidy-plugin/test/use-point-apis.cpp b/tools/clang-tidy-plugin/test/use-point-apis.cpp index 362a2258e4395..d58bd2f70ee73 100644 --- a/tools/clang-tidy-plugin/test/use-point-apis.cpp +++ b/tools/clang-tidy-plugin/test/use-point-apis.cpp @@ -143,3 +143,33 @@ int g12() // CHECK-MESSAGES: warning: Call to 'f12' could instead call overload using a point parameter. [cata-use-point-apis] // CHECK-FIXES: return f12( point( 0, 1 ) ); } + +int f13( int X, int Y ); +int f13( const point &p ); + +int g13() +{ + return f13( 0, 1 ); + // CHECK-MESSAGES: warning: Call to 'f13' could instead call overload using a point parameter. [cata-use-point-apis] + // CHECK-FIXES: return f13( point( 0, 1 ) ); +} + +int f14( int x1, int y1 ); +int f14( const point &p ); + +int g14() +{ + return f14( 0, 1 ); + // CHECK-MESSAGES: warning: Call to 'f14' could instead call overload using a point parameter. [cata-use-point-apis] + // CHECK-FIXES: return f14( point( 0, 1 ) ); +} + +int f15( int foo_x, int foo_y ); +int f15( const point &p ); + +int g15() +{ + return f15( 0, 1 ); + // CHECK-MESSAGES: warning: Call to 'f15' could instead call overload using a point parameter. [cata-use-point-apis] + // CHECK-FIXES: return f15( point( 0, 1 ) ); +} From 296c2e5d7a651a4c37a20ec2ed4de0f7271fbd8b Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 14:13:14 -0400 Subject: [PATCH 013/113] UsePointApis: Handle all-default arguments Previously a call to a function where every argument was defaulted would cause a crash. Detect and handle that case. --- tools/clang-tidy-plugin/UsePointApisCheck.cpp | 5 +++++ tools/clang-tidy-plugin/test/use-point-apis.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/tools/clang-tidy-plugin/UsePointApisCheck.cpp b/tools/clang-tidy-plugin/UsePointApisCheck.cpp index 4fa92382c6801..1708a1773c545 100644 --- a/tools/clang-tidy-plugin/UsePointApisCheck.cpp +++ b/tools/clang-tidy-plugin/UsePointApisCheck.cpp @@ -186,6 +186,11 @@ static void CheckCall( UsePointApisCheck &Check, const MatchFinder::MatchResult // Construct range to be replaced while( isa( Call->getArg( MaxArg ) ) ) { --MaxArg; + if( MaxArg == UINT_MAX ) { + // We underflowed; that means every argument was defaulted. In + // this case, we don't want to change the call at all + return; + } } SourceRange SourceRangeToReplace( Call->getArg( MinArg )->getBeginLoc(), Call->getArg( MaxArg )->getEndLoc() ); diff --git a/tools/clang-tidy-plugin/test/use-point-apis.cpp b/tools/clang-tidy-plugin/test/use-point-apis.cpp index d58bd2f70ee73..952c01eb1c5bd 100644 --- a/tools/clang-tidy-plugin/test/use-point-apis.cpp +++ b/tools/clang-tidy-plugin/test/use-point-apis.cpp @@ -173,3 +173,11 @@ int g15() // CHECK-MESSAGES: warning: Call to 'f15' could instead call overload using a point parameter. [cata-use-point-apis] // CHECK-FIXES: return f15( point( 0, 1 ) ); } + +int f16( int x = 0, int y = 0 ); +int f16( const point &p ); + +int g16() +{ + return f16(); +} From 4a768d02fa2910da9864901b004c282a98f6decd Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Wed, 14 Aug 2019 21:17:04 -0400 Subject: [PATCH 014/113] Add point overloads for map member functions --- src/map.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/src/map.h b/src/map.h index 899ec09e62d2c..6bc62910f0087 100644 --- a/src/map.h +++ b/src/map.h @@ -385,9 +385,13 @@ class map // Move cost: 2D overloads int move_cost( int x, int y, const vehicle *ignored_vehicle = nullptr ) const; + int move_cost( const point &p, const vehicle *ignored_vehicle = nullptr ) const; bool impassable( int x, int y ) const; + bool impassable( const point &p ) const; bool passable( int x, int y ) const; + bool passable( const point &p ) const; int move_cost_ter_furn( int x, int y ) const; + int move_cost_ter_furn( const point &p ) const; // Move cost: 3D @@ -809,20 +813,37 @@ class map // mapgen void draw_line_ter( ter_id type, int x1, int y1, int x2, int y2 ); + void draw_line_ter( ter_id type, const point &p1, int x2, int y2 ); + void draw_line_ter( ter_id type, const point &p1, const point &p2 ); void draw_line_furn( furn_id type, int x1, int y1, int x2, int y2 ); + void draw_line_furn( furn_id type, const point &p1, int x2, int y2 ); + void draw_line_furn( furn_id type, const point &p1, const point &p2 ); void draw_fill_background( ter_id type ); void draw_fill_background( ter_id( *f )() ); void draw_fill_background( const weighted_int_list &f ); void draw_square_ter( ter_id type, int x1, int y1, int x2, int y2 ); + void draw_square_ter( ter_id type, const point &p1, int x2, int y2 ); + void draw_square_ter( ter_id type, const point &p1, const point &p2 ); void draw_square_furn( furn_id type, int x1, int y1, int x2, int y2 ); + void draw_square_furn( furn_id type, const point &p1, int x2, int y2 ); + void draw_square_furn( furn_id type, const point &p1, const point &p2 ); void draw_square_ter( ter_id( *f )(), int x1, int y1, int x2, int y2 ); + void draw_square_ter( ter_id( *f )(), const point &p1, int x2, int y2 ); + void draw_square_ter( ter_id( *f )(), const point &p1, const point &p2 ); void draw_square_ter( const weighted_int_list &f, int x1, int y1, int x2, int y2 ); + void draw_square_ter( const weighted_int_list &f, const point &p1, int x2, int y2 ); + void draw_square_ter( const weighted_int_list &f, const point &p1, + const point &p2 ); void draw_rough_circle_ter( ter_id type, int x, int y, int rad ); void draw_rough_circle_furn( furn_id type, int x, int y, int rad ); void draw_circle_ter( ter_id type, double x, double y, double rad ); void draw_circle_ter( ter_id type, int x, int y, int rad ); void draw_circle_furn( furn_id type, int x, int y, int rad ); + void draw_rough_circle_ter( ter_id type, const point &p, int rad ); + void draw_rough_circle_furn( furn_id type, const point &p, int rad ); + void draw_circle_ter( ter_id type, const point &p, int rad ); + void draw_circle_furn( furn_id type, const point &p, int rad ); void add_corpse( const tripoint &p ); @@ -918,24 +939,42 @@ class map // Items: 2D map_stack i_at( int x, int y ); + map_stack i_at( const point &p ); void i_clear( int x, int y ); + void i_clear( const point &p ); map_stack::iterator i_rem( const point &location, map_stack::const_iterator it ); void i_rem( int x, int y, item *it ); + void i_rem( const point &p, item *it ); void spawn_item( int x, int y, const std::string &itype_id, unsigned quantity = 1, int charges = 0, const time_point &birthday = calendar::turn_zero, int damlevel = 0 ); + void spawn_item( const point &p, const std::string &itype_id, + unsigned quantity = 1, int charges = 0, + const time_point &birthday = calendar::turn_zero, int damlevel = 0 ); item &add_item_or_charges( int x, int y, item obj, bool overflow = true ); + item &add_item_or_charges( const point &p, item obj, bool overflow = true ); void add_item( int x, int y, item new_item ); + void add_item( const point &p, item new_item ); void spawn_an_item( int x, int y, item new_item, int charges, int damlevel ); + void spawn_an_item( const point &p, item new_item, + int charges, int damlevel ); std::vector place_items( const items_location &loc, int chance, int x1, int y1, int x2, int y2, bool ongrass, const time_point &turn, int magazine = 0, int ammo = 0 ); + std::vector place_items( const items_location &loc, int chance, const point &p1, + int x2, int y2, bool ongrass, const time_point &turn, + int magazine = 0, int ammo = 0 ); + std::vector place_items( const items_location &loc, int chance, const point &p1, + const point &p2, bool ongrass, const time_point &turn, + int magazine = 0, int ammo = 0 ); void spawn_items( int x, int y, const std::vector &new_items ); + void spawn_items( const point &p, const std::vector &new_items ); void create_anomaly( int cx, int cy, artifact_natural_property prop ); + void create_anomaly( const point &c, artifact_natural_property prop ); // Items: 3D // Accessor that returns a wrapped reference to an item stack for safe modification. map_stack i_at( const tripoint &p ); @@ -1008,6 +1047,7 @@ class map basecamp *bcp = nullptr ); /*@}*/ std::list > get_rc_items( int x = -1, int y = -1, int z = -1 ); + std::list > get_rc_items( const tripoint &p ); /** * Place items from item group in the rectangle f - t. Several items may be spawned @@ -1176,6 +1216,12 @@ class map void scent_blockers( std::array, MAPSIZE_Y> &blocks_scent, std::array, MAPSIZE_Y> &reduces_scent, int minx, int miny, int maxx, int maxy ); + void scent_blockers( std::array, MAPSIZE_Y> &blocks_scent, + std::array, MAPSIZE_Y> &reduces_scent, + int minx, int miny, const point &max ); + void scent_blockers( std::array, MAPSIZE_Y> &blocks_scent, + std::array, MAPSIZE_Y> &reduces_scent, + const point &min, const point &max ); // Computers computer *computer_at( const tripoint &p ); @@ -1238,19 +1284,35 @@ class map void place_spawns( const mongroup_id &group, int chance, int x1, int y1, int x2, int y2, float intensity, bool individual = false, bool friendly = false ); + void place_spawns( const mongroup_id &group, int chance, + const point &p1, int x2, int y2, float intensity, + bool individual = false, bool friendly = false ); + void place_spawns( const mongroup_id &group, int chance, + const point &p1, const point &p2, float intensity, + bool individual = false, bool friendly = false ); void place_gas_pump( int x, int y, int charges ); + void place_gas_pump( const point &p, int charges ); void place_gas_pump( int x, int y, int charges, const std::string &fuel_type ); + void place_gas_pump( const point &p, int charges, const std::string &fuel_type ); // 6 liters at 250 ml per charge void place_toilet( int x, int y, int charges = 6 * 4 ); + void place_toilet( const point &p, int charges = 6 * 4 ); void place_vending( int x, int y, const std::string &type, bool reinforced = false ); + void place_vending( const point &p, const std::string &type, bool reinforced = false ); // places an NPC, if static NPCs are enabled or if force is true int place_npc( int x, int y, const string_id &type, bool force = false ); - void apply_faction_ownership( int x1, int y1, int x2, int y2, - faction_id id ); + int place_npc( const point &p, const string_id &type, bool force = false ); + void apply_faction_ownership( int x1, int y1, int x2, int y2, faction_id id ); + void apply_faction_ownership( const point &p1, int x2, int y2, faction_id id ); + void apply_faction_ownership( const point &p1, const point &p2, faction_id id ); void add_spawn( const mtype_id &type, int count, int x, int y, bool friendly = false, int faction_id = -1, int mission_id = -1, const std::string &name = "NONE" ); + void add_spawn( const mtype_id &type, int count, const point &p, + bool friendly = false, + int faction_id = -1, int mission_id = -1, + const std::string &name = "NONE" ); vehicle *add_vehicle( const vgroup_id &type, const point &p, int dir, int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true ); @@ -1367,17 +1429,22 @@ class map protected: void saven( int gridx, int gridy, int gridz ); + void saven( const tripoint &grid ); void loadn( int gridx, int gridy, bool update_vehicles ); + void loadn( const point &grid, bool update_vehicles ); void loadn( int gridx, int gridy, int gridz, bool update_vehicles ); + void loadn( const tripoint &grid, bool update_vehicles ); /** * Fast forward a submap that has just been loading into this map. * This is used to rot and remove rotten items, grow plants, fill funnels etc. */ void actualize( int gridx, int gridy, int gridz ); + void actualize( const tripoint &grid ); /** * Hacks in missing roofs. Should be removed when 3D mapgen is done. */ void add_roofs( int gridx, int gridy, int gridz ); + void add_roofs( const tripoint &grid ); /** * Whether the item has to be removed as it has rotten away completely. * @param itm Item to check for rotting From 12c6431b2462be43eb75303591827ede51828289 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Thu, 15 Aug 2019 06:59:54 -0400 Subject: [PATCH 015/113] An automated refactoring pass --- src/activity_handlers.cpp | 8 +- src/computer.cpp | 20 +- src/defense.cpp | 2 +- src/explosion.cpp | 6 +- src/faction_camp.cpp | 8 +- src/game.cpp | 16 +- src/handle_action.cpp | 2 +- src/iuse.cpp | 6 +- src/iuse_actor.cpp | 4 +- src/map.cpp | 32 +- src/map_extras.cpp | 120 +++---- src/map_field.cpp | 2 +- src/mapgen.cpp | 720 +++++++++++++++++++------------------- src/mapgen_functions.cpp | 319 +++++++++-------- src/mapgenformat.cpp | 2 +- src/mission_companion.cpp | 38 +- src/mission_start.cpp | 141 ++++---- src/monster.cpp | 2 +- src/npctalk_funcs.cpp | 4 +- src/player.cpp | 4 +- src/scent_map.cpp | 4 +- src/start_location.cpp | 2 +- src/trap.cpp | 2 +- src/trapfunc.cpp | 2 +- src/tutorial.cpp | 6 +- src/veh_interact.cpp | 2 +- tests/npc_talk_test.cpp | 2 +- tests/npc_test.cpp | 2 +- 28 files changed, 752 insertions(+), 726 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 7585509593acc..47a6a094180af 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -3487,11 +3487,11 @@ void activity_handlers::chop_logs_finish( player_activity *act, player *p ) const tripoint &pos = act->placement; if( g->m.ter( pos ) == t_trunk ) { - g->m.spawn_item( pos.x, pos.y, "log", rng( 2, 3 ), 0, calendar::turn ); - g->m.spawn_item( pos.x, pos.y, "stick_long", rng( 0, 1 ), 0, calendar::turn ); + g->m.spawn_item( pos.xy(), "log", rng( 2, 3 ), 0, calendar::turn ); + g->m.spawn_item( pos.xy(), "stick_long", rng( 0, 1 ), 0, calendar::turn ); } else if( g->m.ter( pos ) == t_stump ) { - g->m.spawn_item( pos.x, pos.y, "log", rng( 0, 2 ), 0, calendar::turn ); - g->m.spawn_item( pos.x, pos.y, "splinter", rng( 5, 15 ), 0, calendar::turn ); + g->m.spawn_item( pos.xy(), "log", rng( 0, 2 ), 0, calendar::turn ); + g->m.spawn_item( pos.xy(), "splinter", rng( 5, 15 ), 0, calendar::turn ); } g->m.ter_set( pos, t_dirt ); diff --git a/src/computer.cpp b/src/computer.cpp index e8c449901626f..3e9ef14308abe 100644 --- a/src/computer.cpp +++ b/src/computer.cpp @@ -423,7 +423,7 @@ void computer::activate_function( computer_action action ) if( g->m.furn( x1, y1 ) == f_counter ) { bool found_item = false; item sewage( "sewage", calendar::turn ); - auto candidates = g->m.i_at( x1, y1 ); + auto candidates = g->m.i_at( point( x1, y1 ) ); for( auto &candidate : candidates ) { int capa = candidate.get_remaining_capacity_for_liquid( sewage ); if( capa <= 0 ) { @@ -441,7 +441,7 @@ void computer::activate_function( computer_action action ) break; } if( !found_item ) { - g->m.add_item_or_charges( x1, y1, sewage ); + g->m.add_item_or_charges( point( x1, y1 ), sewage ); } } } @@ -716,7 +716,7 @@ void computer::activate_function( computer_action action ) int more = 0; for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - for( auto &elem : g->m.i_at( x, y ) ) { + for( auto &elem : g->m.i_at( point( x, y ) ) ) { if( elem.is_bionic() ) { if( static_cast( names.size() ) < TERMY - 8 ) { names.push_back( elem.tname() ); @@ -942,7 +942,7 @@ PERTINENT FOREMAN LOGS WILL BE PREPENDED TO NOTES" ), if( items.only_item().typeId() == "black_box" ) { print_line( _( "Memory Bank: Military Hexron Encryption\nPrinting Transcript\n" ) ); item transcript( "black_box_transcript", calendar::turn ); - g->m.add_item_or_charges( g->u.posx(), g->u.posy(), transcript ); + g->m.add_item_or_charges( point( g->u.posx(), g->u.posy() ), transcript ); } else { print_line( _( "Memory Bank: Unencrypted\nNothing of interest.\n" ) ); } @@ -1585,16 +1585,16 @@ void computer::activate_failure( computer_failure_type fail ) int leak_size = rng( 4, 10 ); for( int i = 0; i < leak_size; i++ ) { std::vector next_move; - if( g->m.passable( p.x, p.y - 1 ) ) { + if( g->m.passable( p + point_north ) ) { next_move.push_back( p + point_north ); } - if( g->m.passable( p.x + 1, p.y ) ) { + if( g->m.passable( p + point_east ) ) { next_move.push_back( p + point_east ); } - if( g->m.passable( p.x, p.y + 1 ) ) { + if( g->m.passable( p + point_south ) ) { next_move.push_back( p + point_south ); } - if( g->m.passable( p.x - 1, p.y ) ) { + if( g->m.passable( p + point_west ) ) { next_move.push_back( p + point_west ); } @@ -1651,7 +1651,7 @@ void computer::activate_failure( computer_failure_type fail ) for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { if( g->m.ter( x, y ) == t_floor_blue ) { - map_stack items = g->m.i_at( x, y ); + map_stack items = g->m.i_at( point( x, y ) ); if( items.empty() ) { print_error( _( "ERROR: Please place memory bank in scan area." ) ); } else if( items.size() > 1 ) { @@ -1662,7 +1662,7 @@ void computer::activate_failure( computer_failure_type fail ) print_error( _( "ERROR: Memory bank is empty." ) ); } else { print_error( _( "ERROR: Data bank destroyed." ) ); - g->m.i_clear( x, y ); + g->m.i_clear( point( x, y ) ); } } } diff --git a/src/defense.cpp b/src/defense.cpp index 85952c52e603c..7278c85a347a8 100644 --- a/src/defense.cpp +++ b/src/defense.cpp @@ -1136,7 +1136,7 @@ Press %s to buy everything in your cart, %s to buy nothing." ), g->u.i_add( tmp ); } else { // Could fit it in the inventory! dropped_some = true; - g->m.add_item_or_charges( g->u.posx(), g->u.posy(), tmp ); + g->m.add_item_or_charges( point( g->u.posx(), g->u.posy() ), tmp ); } } } diff --git a/src/explosion.cpp b/src/explosion.cpp index e58ebcb2d8320..4c97db7123ec3 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -674,10 +674,10 @@ void emp_blast( const tripoint &p ) if( sight ) { add_msg( _( "The %s beeps erratically and deactivates!" ), critter.name() ); } - g->m.add_item_or_charges( x, y, critter.to_item() ); + g->m.add_item_or_charges( point( x, y ), critter.to_item() ); for( auto &ammodef : critter.ammo ) { if( ammodef.second > 0 ) { - g->m.spawn_item( x, y, ammodef.first, 1, ammodef.second, calendar::turn ); + g->m.spawn_item( point( x, y ), ammodef.first, 1, ammodef.second, calendar::turn ); } } g->remove_zombie( critter ); @@ -727,7 +727,7 @@ void emp_blast( const tripoint &p ) } } // Drain any items of their battery charge - for( auto &it : g->m.i_at( x, y ) ) { + for( auto &it : g->m.i_at( point( x, y ) ) ) { if( it.is_tool() && it.ammo_current() == "battery" ) { it.charges = 0; } diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index f0cc17f01af75..8095996251070 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -1641,7 +1641,7 @@ void basecamp::start_relay_hide_site() tinymap target_bay; target_bay.load( tripoint( forest.x * 2, forest.y * 2, forest.z ), false ); std::vector hide_inv; - for( item &i : target_bay.i_at( 11, 10 ) ) { + for( item &i : target_bay.i_at( point( 11, 10 ) ) ) { hide_inv.push_back( &i ); } std::vector gaining_equipment; @@ -3009,10 +3009,10 @@ bool om_set_hide_site( npc &comp, const tripoint &omt_tgt, target_bay.ter_set( point( 11, 10 ), t_improvised_shelter ); for( auto i : itms_rem ) { comp.companion_mission_inv.add_item( *i ); - target_bay.i_rem( 11, 10, i ); + target_bay.i_rem( point( 11, 10 ), i ); } for( auto i : itms ) { - target_bay.add_item_or_charges( 11, 10, *i ); + target_bay.add_item_or_charges( point( 11, 10 ), *i ); g->u.use_amount( i->typeId(), 1 ); } target_bay.save(); @@ -3603,7 +3603,7 @@ void apply_camp_ownership( const tripoint &camp_pos, int radius ) { for( const tripoint &p : g->m.points_in_rectangle( camp_pos + point( -radius, -radius ), camp_pos + point( radius, radius ) ) ) { - auto items = g->m.i_at( p.x, p.y ); + auto items = g->m.i_at( p.xy() ); for( item &elem : items ) { elem.set_owner( g->faction_manager_ptr->get( faction_id( "your_followers" ) ) ); } diff --git a/src/game.cpp b/src/game.cpp index 5ede0bf4cf83a..2d858d2e9eb68 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4387,7 +4387,7 @@ void game::knockback( std::vector &traj, int force, int stun, int dam_ add_msg( _( "%s was stunned!" ), targ->name() ); } for( size_t i = 1; i < traj.size(); i++ ) { - if( m.impassable( traj[i].x, traj[i].y ) ) { + if( m.impassable( point( traj[i].x, traj[i].y ) ) ) { targ->setpos( traj[i - 1] ); force_remaining = traj.size() - i; if( stun != 0 ) { @@ -4445,7 +4445,7 @@ void game::knockback( std::vector &traj, int force, int stun, int dam_ add_msg( _( "%s was stunned!" ), targ->name ); } for( size_t i = 1; i < traj.size(); i++ ) { - if( m.impassable( traj[i].x, traj[i].y ) ) { // oops, we hit a wall! + if( m.impassable( point( traj[i].x, traj[i].y ) ) ) { // oops, we hit a wall! targ->setpos( traj[i - 1] ); force_remaining = traj.size() - i; if( stun != 0 ) { @@ -5152,11 +5152,11 @@ bool game::forced_door_closing( const tripoint &p, const ter_id &door_type, int return false; } } - if( bash_dmg < 0 && !m.i_at( x, y ).empty() ) { + if( bash_dmg < 0 && !m.i_at( point( x, y ) ).empty() ) { return false; } if( bash_dmg == 0 ) { - for( auto &elem : m.i_at( x, y ) ) { + for( auto &elem : m.i_at( point( x, y ) ) ) { if( elem.made_of( LIQUID ) ) { // Liquids are OK, will be destroyed later continue; @@ -5171,7 +5171,7 @@ bool game::forced_door_closing( const tripoint &p, const ter_id &door_type, int m.ter_set( point( x, y ), door_type ); if( m.has_flag( "NOITEM", x, y ) ) { - map_stack items = m.i_at( x, y ); + map_stack items = m.i_at( point( x, y ) ); for( map_stack::iterator it = items.begin(); it != items.end(); ) { if( it->made_of( LIQUID ) ) { it = items.erase( it ); @@ -5186,7 +5186,7 @@ bool game::forced_door_closing( const tripoint &p, const ter_id &door_type, int it = items.erase( it ); continue; } - m.add_item_or_charges( kbx, kby, *it ); + m.add_item_or_charges( point( kbx, kby ), *it ); it = items.erase( it ); } } @@ -8833,11 +8833,11 @@ bool game::disable_robot( const tripoint &p ) query_yn( _( "Deactivate the %s?" ), critter.name() ) ) { u.moves -= 100; - m.add_item_or_charges( p.x, p.y, critter.to_item() ); + m.add_item_or_charges( p.xy(), critter.to_item() ); if( !critter.has_flag( MF_INTERIOR_AMMO ) ) { for( auto &ammodef : critter.ammo ) { if( ammodef.second > 0 ) { - m.spawn_item( p.x, p.y, ammodef.first, 1, ammodef.second, calendar::turn ); + m.spawn_item( p.xy(), ammodef.first, 1, ammodef.second, calendar::turn ); } } } diff --git a/src/handle_action.cpp b/src/handle_action.cpp index f2f64b41e357f..0c2a04550e15c 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -340,7 +340,7 @@ static void rcdrive( int dx, int dy ) int cz = 0; car_location_string >> cx >> cy >> cz; - auto rc_pairs = m.get_rc_items( cx, cy, cz ); + auto rc_pairs = m.get_rc_items( tripoint( cx, cy, cz ) ); auto rc_pair = rc_pairs.begin(); for( ; rc_pair != rc_pairs.end(); ++rc_pair ) { if( rc_pair->second->typeId() == "radio_car_on" && rc_pair->second->active ) { diff --git a/src/iuse.cpp b/src/iuse.cpp index ca05554b7db12..a9da978c409d2 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -4362,7 +4362,7 @@ int iuse::blood_draw( player *p, item *it, bool, const tripoint & ) item blood( "blood", calendar::turn ); bool drew_blood = false; bool acid_blood = false; - for( auto &map_it : g->m.i_at( p->posx(), p->posy() ) ) { + for( auto &map_it : g->m.i_at( point( p->posx(), p->posy() ) ) ) { if( map_it.is_corpse() && query_yn( _( "Draw blood from %s?" ), colorize( map_it.tname(), map_it.color_in_inventory() ) ) ) { @@ -4414,7 +4414,7 @@ int iuse::blood_draw( player *p, item *it, bool, const tripoint & ) //This is just used for robofac_intercom_mission_2 int iuse::mind_splicer( player *p, item *it, bool, const tripoint & ) { - for( auto &map_it : g->m.i_at( p->posx(), p->posy() ) ) { + for( auto &map_it : g->m.i_at( point( p->posx(), p->posy() ) ) ) { if( map_it.typeId() == "rmi2_corpse" && query_yn( _( "Use the mind splicer kit on the %s?" ), colorize( map_it.tname(), map_it.color_in_inventory() ) ) ) { @@ -4680,7 +4680,7 @@ int iuse::boltcutters( player *p, item *it, bool, const tripoint & ) p->moves -= to_moves( 1_seconds ); g->m.ter_set( pnt, t_chaingate_c ); sounds::sound( pnt, 5, sounds::sound_t::combat, _( "Gachunk!" ), true, "tool", "boltcutters" ); - g->m.spawn_item( p->posx(), p->posy(), "scrap", 3 ); + g->m.spawn_item( point( p->posx(), p->posy() ), "scrap", 3 ); } else if( g->m.ter( pnt ) == t_chainfence ) { p->moves -= to_moves( 5_seconds ); g->m.ter_set( pnt, t_chainfence_posts ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index c357782cb4b2c..8734e08a93b99 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1538,7 +1538,7 @@ int salvage_actor::cut_up( player &p, item &it, item_location &cut ) const p.i_add_or_drop( result, amount ); } else { for( int i = 0; i < amount; i++ ) { - g->m.spawn_an_item( pos.x, pos.y, result, amount, 0 ); + g->m.spawn_an_item( pos.xy(), result, amount, 0 ); } } } else { @@ -1812,7 +1812,7 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const return 0; } - auto items = g->m.i_at( p.posx(), p.posy() ); + auto items = g->m.i_at( point( p.posx(), p.posy() ) ); std::vector corpses; for( auto &it : items ) { diff --git a/src/map.cpp b/src/map.cpp index 42633aff7ee2a..3c4463026dc04 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1647,7 +1647,7 @@ int map::move_cost( const int x, const int y, const vehicle *ignored_vehicle ) c bool map::impassable( const int x, const int y ) const { - return !passable( x, y ); + return !passable( point( x, y ) ); } bool map::passable( const int x, const int y ) const @@ -6349,7 +6349,7 @@ bool map::clear_path( const tripoint &f, const tripoint &t, const int range, return false; } - const int cost = this->move_cost( new_point.x, new_point.y ); + const int cost = this->move_cost( new_point ); if( cost < cost_min || cost > cost_max ) { is_clear = false; return false; @@ -6453,10 +6453,10 @@ void map::save() for( int gridy = 0; gridy < my_MAPSIZE; gridy++ ) { if( zlevels ) { for( int gridz = -OVERMAP_DEPTH; gridz <= OVERMAP_HEIGHT; gridz++ ) { - saven( gridx, gridy, gridz ); + saven( tripoint( gridx, gridy, gridz ) ); } } else { - saven( gridx, gridy, abs_sub.z ); + saven( tripoint( gridx, gridy, abs_sub.z ) ); } } } @@ -6472,7 +6472,7 @@ void map::load( const int wx, const int wy, const int wz, const bool update_vehi set_abs_sub( wx, wy, wz ); for( int gridx = 0; gridx < my_MAPSIZE; gridx++ ) { for( int gridy = 0; gridy < my_MAPSIZE; gridy++ ) { - loadn( gridx, gridy, update_vehicle ); + loadn( point( gridx, gridy ), update_vehicle ); } } } @@ -6587,7 +6587,7 @@ void map::shift( const int sx, const int sy ) tripoint( gridx + sx, gridy + sy, gridz ) ); update_vehicle_list( get_submap_at_grid( {gridx, gridy, gridz} ), gridz ); } else { - loadn( gridx, gridy, gridz, true ); + loadn( tripoint( gridx, gridy, gridz ), true ); } } } else { // sy < 0; work through it backwards @@ -6600,7 +6600,7 @@ void map::shift( const int sx, const int sy ) tripoint( gridx + sx, gridy + sy, gridz ) ); update_vehicle_list( get_submap_at_grid( { gridx, gridy, gridz } ), gridz ); } else { - loadn( gridx, gridy, gridz, true ); + loadn( tripoint( gridx, gridy, gridz ), true ); } } } @@ -6617,7 +6617,7 @@ void map::shift( const int sx, const int sy ) tripoint( gridx + sx, gridy + sy, gridz ) ); update_vehicle_list( get_submap_at_grid( { gridx, gridy, gridz } ), gridz ); } else { - loadn( gridx, gridy, gridz, true ); + loadn( tripoint( gridx, gridy, gridz ), true ); } } } else { // sy < 0; work through it backwards @@ -6630,7 +6630,7 @@ void map::shift( const int sx, const int sy ) tripoint( gridx + sx, gridy + sy, gridz ) ); update_vehicle_list( get_submap_at_grid( { gridx, gridy, gridz } ), gridz ); } else { - loadn( gridx, gridy, gridz, true ); + loadn( tripoint( gridx, gridy, gridz ), true ); } } } @@ -6719,16 +6719,16 @@ void map::loadn( const int gridx, const int gridy, const bool update_vehicles ) { if( zlevels ) { for( int gridz = -OVERMAP_DEPTH; gridz <= OVERMAP_HEIGHT; gridz++ ) { - loadn( gridx, gridy, gridz, update_vehicles ); + loadn( tripoint( gridx, gridy, gridz ), update_vehicles ); } // Note: we want it in a separate loop! It is a post-load cleanup // Since we're adding roofs, we want it to go up (from lowest to highest) for( int gridz = -OVERMAP_DEPTH; gridz <= OVERMAP_HEIGHT; gridz++ ) { - add_roofs( gridx, gridy, gridz ); + add_roofs( tripoint( gridx, gridy, gridz ) ); } } else { - loadn( gridx, gridy, abs_sub.z, update_vehicles ); + loadn( tripoint( gridx, gridy, abs_sub.z ), update_vehicles ); } } @@ -6846,7 +6846,7 @@ void map::loadn( const int gridx, const int gridy, const int gridz, const bool u } } - actualize( gridx, gridy, gridz ); + actualize( tripoint( gridx, gridy, gridz ) ); abs_sub.z = old_abs_z; } @@ -6913,7 +6913,7 @@ void map::rotten_item_spawn( const item &item, const tripoint &pnt ) const int chance = ( comest->rot_spawn_chance * get_option( "CARRION_SPAWNRATE" ) ) / 100; if( rng( 0, 100 ) < chance ) { MonsterGroupResult spawn_details = MonsterGroupManager::GetResultFromGroup( mgroup ); - add_spawn( spawn_details.name, 1, pnt.x, pnt.y, false ); + add_spawn( spawn_details.name, 1, pnt.xy(), false ); if( g->u.sees( pnt ) ) { if( item.is_seed() ) { add_msg( m_warning, _( "Something has crawled out of the %s plants!" ), item.get_plant_name() ); @@ -8126,11 +8126,11 @@ void map::draw_fill_background( const ter_id type ) void map::draw_fill_background( ter_id( *f )() ) { - draw_square_ter( f, 0, 0, SEEX * my_MAPSIZE - 1, SEEY * my_MAPSIZE - 1 ); + draw_square_ter( f, point_zero, point( SEEX * my_MAPSIZE - 1, SEEY * my_MAPSIZE - 1 ) ); } void map::draw_fill_background( const weighted_int_list &f ) { - draw_square_ter( f, 0, 0, SEEX * my_MAPSIZE - 1, SEEY * my_MAPSIZE - 1 ); + draw_square_ter( f, point_zero, point( SEEX * my_MAPSIZE - 1, SEEY * my_MAPSIZE - 1 ) ); } void map::draw_square_ter( const ter_id type, int x1, int y1, int x2, int y2 ) diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 832af4f4e795f..8b72d66502078 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -205,9 +205,9 @@ static void mx_house_wasp( map &m, const tripoint & ) } } } - m.add_spawn( mon_wasp, 1, podx, pody ); + m.add_spawn( mon_wasp, 1, point( podx, pody ) ); } - m.place_items( "rare", 70, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, false, 0 ); + m.place_items( "rare", 70, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), false, 0 ); } static void mx_house_spider( map &m, const tripoint & ) @@ -222,7 +222,7 @@ static void mx_house_spider( map &m, const tripoint & ) for( int j = 0; j < SEEY * 2; j++ ) { if( m.ter( i, j ) == t_floor ) { if( one_in( 15 ) ) { - m.add_spawn( spider_type, rng( 1, 2 ), i, j ); + m.add_spawn( spider_type, rng( 1, 2 ), point( i, j ) ); for( int x = i - 1; x <= i + 1; x++ ) { for( int y = j - 1; y <= j + 1; y++ ) { if( m.ter( x, y ) == t_floor ) { @@ -234,13 +234,13 @@ static void mx_house_spider( map &m, const tripoint & ) } } } - } else if( m.passable( i, j ) && one_in( 5 ) ) { + } else if( m.passable( point( i, j ) ) && one_in( 5 ) ) { madd_field( &m, i, j, fd_web, 1 ); } } } } - m.place_items( "rare", 60, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, false, 0 ); + m.place_items( "rare", 60, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), false, 0 ); } @@ -336,14 +336,14 @@ static void mx_helicopter( map &m, const tripoint &abs_sub ) const tripoint pos = vp.pos(); // Spawn pilots in seats with controls.CTRL_ELECTRONIC if( controls_at( wreckage, pos ) ) { - m.add_spawn( mon_zombie_military_pilot, 1, pos.x, pos.y ); + m.add_spawn( mon_zombie_military_pilot, 1, pos.xy() ); } else { if( one_in( 5 ) ) { - m.add_spawn( mon_zombie_bio_op, 1, pos.x, pos.y ); + m.add_spawn( mon_zombie_bio_op, 1, pos.xy() ); } else if( one_in( 5 ) ) { - m.add_spawn( mon_zombie_scientist, 1, pos.x, pos.y ); + m.add_spawn( mon_zombie_scientist, 1, pos.xy() ); } else { - m.add_spawn( mon_zombie_soldier, 1, pos.x, pos.y ); + m.add_spawn( mon_zombie_soldier, 1, pos.xy() ); } } @@ -363,10 +363,10 @@ static void mx_helicopter( map &m, const tripoint &abs_sub ) const tripoint pos = vp.pos(); // Spawn pilots in seats with controls. if( controls_at( wreckage, pos ) ) { - m.add_spawn( mon_zombie_military_pilot, 1, pos.x, pos.y ); + m.add_spawn( mon_zombie_military_pilot, 1, pos.xy() ); } else { if( !one_in( 3 ) ) { - m.add_spawn( mon_zombie_soldier, 1, pos.x, pos.y ); + m.add_spawn( mon_zombie_soldier, 1, pos.xy() ); } } @@ -383,7 +383,7 @@ static void mx_helicopter( map &m, const tripoint &abs_sub ) case 6: // Just pilots for( const vpart_reference &vp : wreckage->get_any_parts( VPFLAG_CONTROLS ) ) { const tripoint pos = vp.pos(); - m.add_spawn( mon_zombie_military_pilot, 1, pos.x, pos.y ); + m.add_spawn( mon_zombie_military_pilot, 1, pos.xy() ); // Delete the items that would have spawned here from a "corpse" for( auto sp : wreckage->parts_at_relative( vp.mount(), true ) ) { @@ -417,12 +417,12 @@ static void mx_military( map &m, const tripoint & ) return m.passable( n ); } ) ) { if( one_in( 10 ) ) { - m.add_spawn( mon_zombie_soldier, 1, p->x, p->y ); + m.add_spawn( mon_zombie_soldier, 1, point( p->x, p->y ) ); } else if( one_in( 25 ) ) { if( one_in( 2 ) ) { - m.add_spawn( mon_zombie_bio_op, 1, p->x, p->y ); + m.add_spawn( mon_zombie_bio_op, 1, point( p->x, p->y ) ); } else { - m.add_spawn( mon_dispatch, 1, p->x, p->y ); + m.add_spawn( mon_dispatch, 1, point( p->x, p->y ) ); } } else { m.place_items( "map_extra_military", 100, *p, *p, true, 0 ); @@ -433,11 +433,11 @@ static void mx_military( map &m, const tripoint & ) int num_monsters = rng( 0, 3 ); for( int i = 0; i < num_monsters; i++ ) { int mx = rng( 1, SEEX * 2 - 2 ), my = rng( 1, SEEY * 2 - 2 ); - m.place_spawns( GROUP_NETHER_CAPTURED, 1, mx, my, mx, my, 1, true ); + m.place_spawns( GROUP_NETHER_CAPTURED, 1, point( mx, my ), point( mx, my ), 1, true ); } - m.place_spawns( GROUP_MAYBE_MIL, 2, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, + m.place_spawns( GROUP_MAYBE_MIL, 2, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), 0.1f ); //0.1 = 1-5 - m.place_items( "rare", 25, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, 0 ); + m.place_items( "rare", 25, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, 0 ); } static void mx_science( map &m, const tripoint & ) @@ -448,7 +448,7 @@ static void mx_science( map &m, const tripoint & ) return m.passable( n ); } ) ) { if( one_in( 10 ) ) { - m.add_spawn( mon_zombie_scientist, 1, p->x, p->y ); + m.add_spawn( mon_zombie_scientist, 1, point( p->x, p->y ) ); } else { m.place_items( "map_extra_science", 100, *p, *p, true, 0 ); } @@ -457,9 +457,9 @@ static void mx_science( map &m, const tripoint & ) int num_monsters = rng( 0, 3 ); for( int i = 0; i < num_monsters; i++ ) { int mx = rng( 1, SEEX * 2 - 2 ), my = rng( 1, SEEY * 2 - 2 ); - m.place_spawns( GROUP_NETHER_CAPTURED, 1, mx, my, mx, my, 1, true ); + m.place_spawns( GROUP_NETHER_CAPTURED, 1, point( mx, my ), point( mx, my ), 1, true ); } - m.place_items( "rare", 45, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, 0 ); + m.place_items( "rare", 45, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, 0 ); } static void mx_collegekids( map &m, const tripoint & ) @@ -473,7 +473,7 @@ static void mx_collegekids( map &m, const tripoint & ) return m.passable( n ); } ) ) { if( one_in( 10 ) ) { - m.add_spawn( mon_zombie_tough, 1, p->x, p->y ); + m.add_spawn( mon_zombie_tough, 1, point( p->x, p->y ) ); } else { if( type < 6 ) { // kids going to a cabin in the woods m.place_items( "map_extra_college_camping", 100, *p, *p, true, 0 ); @@ -488,7 +488,7 @@ static void mx_collegekids( map &m, const tripoint & ) int num_monsters = rng( 0, 3 ); for( int i = 0; i < num_monsters; i++ ) { int mx = rng( 1, SEEX * 2 - 2 ), my = rng( 1, SEEY * 2 - 2 ); - m.place_spawns( GROUP_NETHER_CAPTURED, 1, mx, my, mx, my, 1, true ); + m.place_spawns( GROUP_NETHER_CAPTURED, 1, point( mx, my ), point( mx, my ), 1, true ); } } @@ -507,9 +507,9 @@ static void mx_roadblock( map &m, const tripoint &abs_sub ) const auto spawn_turret = [&]( int x, int y ) { if( one_in( 2 ) ) { - m.add_spawn( mon_turret_bmg, 1, x, y ); + m.add_spawn( mon_turret_bmg, 1, point( x, y ) ); } else { - m.add_spawn( mon_turret_rifle, 1, x, y ); + m.add_spawn( mon_turret_rifle, 1, point( x, y ) ); } }; bool mil = false; @@ -557,11 +557,11 @@ static void mx_roadblock( map &m, const tripoint &abs_sub ) if( one_in( 3 ) ) { // Chicken delivery m.add_vehicle( vgroup_id( "military_vehicles" ), tripoint( 12, SEEY * 2 - 7, abs_sub.z ), 0, 70, -1 ); - m.add_spawn( mon_chickenbot, 1, 12, 12 ); + m.add_spawn( mon_chickenbot, 1, point( 12, 12 ) ); } else if( one_in( 2 ) ) { // TAAANK // The truck's wrecked...with fuel. Explosive barrel? m.add_vehicle( vproto_id( "military_cargo_truck" ), 12, SEEY * 2 - 8, 0, 70, -1 ); - m.add_spawn( mon_tankbot, 1, 12, 12 ); + m.add_spawn( mon_tankbot, 1, point( 12, 12 ) ); } else { // Vehicle & turrets m.add_vehicle( vgroup_id( "military_vehicles" ), tripoint( 12, SEEY * 2 - 10, abs_sub.z ), 0, 70, -1 ); @@ -597,22 +597,22 @@ static void mx_roadblock( map &m, const tripoint &abs_sub ) if( road_at_north ) { line_furn( &m, f_barricade_road, 4, 3, 10, 3 ); line_furn( &m, f_barricade_road, 13, 3, 19, 3 ); - m.add_spawn( mon_turret, 1, 12, 1 ); + m.add_spawn( mon_turret, 1, point( 12, 1 ) ); } if( road_at_east ) { line_furn( &m, f_barricade_road, SEEX * 2 - 3, 4, SEEX * 2 - 3, 10 ); line_furn( &m, f_barricade_road, SEEX * 2 - 3, 13, SEEX * 2 - 3, 19 ); - m.add_spawn( mon_turret, 1, SEEX * 2 - 1, 12 ); + m.add_spawn( mon_turret, 1, point( SEEX * 2 - 1, 12 ) ); } if( road_at_south ) { line_furn( &m, f_barricade_road, 4, SEEY * 2 - 3, 10, SEEY * 2 - 3 ); line_furn( &m, f_barricade_road, 13, SEEY * 2 - 3, 19, SEEY * 2 - 3 ); - m.add_spawn( mon_turret, 1, 12, SEEY * 2 - 1 ); + m.add_spawn( mon_turret, 1, point( 12, SEEY * 2 - 1 ) ); } if( road_at_west ) { line_furn( &m, f_barricade_road, 3, 4, 3, 10 ); line_furn( &m, f_barricade_road, 3, 13, 3, 19 ); - m.add_spawn( mon_turret, 1, 1, 12 ); + m.add_spawn( mon_turret, 1, point( 1, 12 ) ); } m.add_vehicle( vproto_id( "policecar" ), 8, 6, 20 ); @@ -640,12 +640,12 @@ static void mx_marloss_pilgrimage( map &m, const tripoint &abs_sub ) const int rad = 3; tripoint_range spawnzone = m.points_in_radius( leader_pos, rad ); - m.place_npc( leader_pos.x, leader_pos.y, string_id( "marloss_voice" ) ); + m.place_npc( leader_pos.xy(), string_id( "marloss_voice" ) ); for( int spawned = 0 ; spawned <= max_followers ; spawned++ ) { tripoint where = random_entry( spawnzone ); if( g->is_empty( where ) ) { - one_in( 2 ) ? m.add_spawn( mon_marloss_zealot_f, 1, where.x, - where.y ) : m.add_spawn( mon_marloss_zealot_m, 1, where.x, where.y ); + one_in( 2 ) ? m.add_spawn( mon_marloss_zealot_f, 1, + where.xy() ) : m.add_spawn( mon_marloss_zealot_m, 1, where.xy() ); } } } @@ -677,9 +677,9 @@ static void mx_bandits_block( map &m, const tripoint &abs_sub ) m.ter_set( point( 1, 2 ), t_stump ); m.ter_set( point( 1, 20 ), t_stump ); m.ter_set( point_south_east, t_improvised_shelter ); - m.place_npc( 2, 19, string_id( "bandit" ) ); + m.place_npc( point( 2, 19 ), string_id( "bandit" ) ); if( one_in( 2 ) ) { - m.place_npc( 1, 1, string_id( "bandit" ) ); + m.place_npc( point_south_east, string_id( "bandit" ) ); } } else if( forest_at_west && forest_at_east && road_at_north && road_at_south ) { @@ -689,9 +689,9 @@ static void mx_bandits_block( map &m, const tripoint &abs_sub ) line( &m, t_trunk, 17, 2, 21, 2 ); m.ter_set( point( 22, 2 ), t_stump ); m.ter_set( point_south, t_improvised_shelter ); - m.place_npc( 20, 3, string_id( "bandit" ) ); + m.place_npc( point( 20, 3 ), string_id( "bandit" ) ); if( one_in( 2 ) ) { - m.place_npc( 0, 1, string_id( "bandit" ) ); + m.place_npc( point_south, string_id( "bandit" ) ); } } } @@ -749,7 +749,7 @@ static void mx_drugdeal( map &m, const tripoint &abs_sub ) y_offset = 0; } tries++; - } while( tries < 10 && m.impassable( x, y ) ); + } while( tries < 10 && m.impassable( point( x, y ) ) ); if( tries < 10 ) { // We found a valid spot! if( a_has_drugs && num_drugs > 0 ) { @@ -758,12 +758,12 @@ static void mx_drugdeal( map &m, const tripoint &abs_sub ) drugs_placed = num_drugs; num_drugs = 0; } - m.spawn_item( x, y, drugtype, 0, drugs_placed ); + m.spawn_item( point( x, y ), drugtype, 0, drugs_placed ); } if( one_in( 10 ) ) { - m.add_spawn( mon_zombie_spitter, 1, x, y ); + m.add_spawn( mon_zombie_spitter, 1, point( x, y ) ); } else { - m.place_items( "map_extra_drugdeal", 100, x, y, x, y, true, 0 ); + m.place_items( "map_extra_drugdeal", 100, point( x, y ), point( x, y ), true, 0 ); int splatter_range = rng( 1, 3 ); for( int j = 0; j <= splatter_range; j++ ) { m.add_field( {x + j * x_offset, y + j * y_offset, abs_sub.z}, fd_blood, 1, 0_turns ); @@ -790,13 +790,13 @@ static void mx_drugdeal( map &m, const tripoint &abs_sub ) y_offset = 0; } tries++; - } while( tries < 10 && m.impassable( x, y ) ); + } while( tries < 10 && m.impassable( point( x, y ) ) ); if( tries < 10 ) { // We found a valid spot! if( one_in( 20 ) ) { - m.add_spawn( mon_zombie_smoker, 1, x, y ); + m.add_spawn( mon_zombie_smoker, 1, point( x, y ) ); } else { - m.place_items( "map_extra_drugdeal", 100, x, y, x, y, true, 0 ); + m.place_items( "map_extra_drugdeal", 100, point( x, y ), point( x, y ), true, 0 ); int splatter_range = rng( 1, 3 ); for( int j = 0; j <= splatter_range; j++ ) { m.add_field( {x + j * x_offset, y + j * y_offset, abs_sub.z}, fd_blood, 1, 0_turns ); @@ -807,7 +807,7 @@ static void mx_drugdeal( map &m, const tripoint &abs_sub ) drugs_placed = num_drugs; num_drugs = 0; } - m.spawn_item( x, y, drugtype, 0, drugs_placed ); + m.spawn_item( point( x, y ), drugtype, 0, drugs_placed ); } } } @@ -815,7 +815,7 @@ static void mx_drugdeal( map &m, const tripoint &abs_sub ) int num_monsters = rng( 0, 3 ); for( int i = 0; i < num_monsters; i++ ) { int mx = rng( 1, SEEX * 2 - 2 ), my = rng( 1, SEEY * 2 - 2 ); - m.place_spawns( GROUP_NETHER_CAPTURED, 1, mx, my, mx, my, 1, true ); + m.place_spawns( GROUP_NETHER_CAPTURED, 1, point( mx, my ), point( mx, my ), 1, true ); } } @@ -874,7 +874,7 @@ static void mx_portal( map &m, const tripoint &abs_sub ) for( int i = 0; i < num_monsters; i++ ) { int mx = rng( 1, SEEX * 2 - 2 ), my = rng( 1, SEEY * 2 - 2 ); m.make_rubble( tripoint( mx, my, abs_sub.z ), f_rubble_rock, true ); - m.place_spawns( GROUP_NETHER_PORTAL, 1, mx, my, mx, my, 1, true ); + m.place_spawns( GROUP_NETHER_PORTAL, 1, point( mx, my ), point( mx, my ), 1, true ); } } @@ -1414,7 +1414,7 @@ static void place_fumarole( map &m, int x1, int y1, int x2, int y2, std::setm.points_in_radius( portal_location, 5 ) ) { - m.place_spawns( GROUP_NETHER_PORTAL, 15, loc.x - 5, loc.y - 5, loc.x + 5, loc.y + 5, 1, true ); + m.place_spawns( GROUP_NETHER_PORTAL, 15, loc.xy() + point( -5, -5 ), loc.xy() + point( 5, 5 ), 1, + true ); } break; } @@ -1575,7 +1576,8 @@ static void mx_portal_in( map &m, const tripoint &abs_sub ) //Mi-go went through the portal and began constructing their base of operations m.add_field( portal_location, fd_fatigue, 3 ); for( const auto &loc : g->m.points_in_radius( portal_location, 5 ) ) { - m.place_spawns( GROUP_MI_GO_CAMP_OM, 30, loc.x - 5, loc.y - 5, loc.x + 5, loc.y + 5, 1, true ); + m.place_spawns( GROUP_MI_GO_CAMP_OM, 30, loc.xy() + point( -5, -5 ), loc.xy() + point( 5, 5 ), 1, + true ); } const int x_pos = x + rng( -5, 5 ); const int y_pos = y + rng( -5, 5 ); @@ -1612,7 +1614,7 @@ static void mx_shia( map &m, const tripoint & ) // otherwise the extreme rarity of this event wildly skewed the values for all of the // other extras. if( one_in( 5000 ) ) { - m.add_spawn( mon_shia, 1, SEEX, SEEY ); + m.add_spawn( mon_shia, 1, point( SEEX, SEEY ) ); } } @@ -1638,7 +1640,7 @@ static void mx_spider( map &m, const tripoint &abs_sub ) m.ter_set( point( 12, 12 ), t_dirt ); m.furn_set( point( 12, 12 ), f_egg_sackws ); m.remove_field( { 12, 12, m.get_abs_sub().z }, fd_web ); - m.add_spawn( mon_spider_web, rng( 1, 2 ), SEEX, SEEY ); + m.add_spawn( mon_spider_web, rng( 1, 2 ), point( SEEX, SEEY ) ); } static void mx_jabberwock( map &m, const tripoint & ) @@ -1649,7 +1651,7 @@ static void mx_jabberwock( map &m, const tripoint & ) // into the monster group, but again the hardcoded rarity it had in the forest mapgen was // not easily replicated there. if( one_in( 50 ) ) { - m.add_spawn( mon_jabberwock, 1, SEEX, SEEY ); + m.add_spawn( mon_jabberwock, 1, point( SEEX, SEEY ) ); } } @@ -1782,7 +1784,7 @@ static void mx_pond( map &m, const tripoint &abs_sub ) } } - m.place_spawns( GROUP_FISH, 1, 0, 0, width, height, 0.15f ); + m.place_spawns( GROUP_FISH, 1, point_zero, point( width, height ), 0.15f ); } static void mx_clay_deposit( map &m, const tripoint &abs_sub ) @@ -2298,8 +2300,8 @@ static void mx_roadworks( map &m, const tripoint &abs_sub ) } // soil generator for( int i = 1; i <= 10; i++ ) { - m.spawn_item( rng( defects_from.x, defects_to.x ), - rng( defects_from.y, defects_to.y ), "material_soil" ); + m.spawn_item( point( rng( defects_from.x, defects_to.x ), + rng( defects_from.y, defects_to.y ) ), "material_soil" ); } // vehicle placer switch( rng( 1, 6 ) ) { @@ -2452,7 +2454,7 @@ static void mx_casings( map &m, const tripoint &abs_sub ) for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { if( one_in( 20 ) ) { - m.spawn_items( i, j, items ); + m.spawn_items( point( i, j ), items ); } } } diff --git a/src/map_field.cpp b/src/map_field.cpp index 0eaf7145dde41..9f0847c4b36b5 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1082,7 +1082,7 @@ bool map::process_fields_in_submap( submap *const current_submap, cur.monster_spawn_radius() ), [this]( const tripoint & n ) { return passable( n ); } ) ) { - add_spawn( spawn_details.name, spawn_details.pack_size, spawn_point->x, spawn_point->y ); + add_spawn( spawn_details.name, spawn_details.pack_size, point( spawn_point->x, spawn_point->y ) ); } } } diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 959764f33f600..51d851d4ada10 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -189,7 +189,7 @@ void map::generate( const int x, const int y, const int z, const time_point &whe if( const auto p = random_point( *this, [this]( const tripoint & n ) { return passable( n ); } ) ) { - add_spawn( spawn_details.name, spawn_details.pack_size, p->x, p->y ); + add_spawn( spawn_details.name, spawn_details.pack_size, point( p->x, p->y ) ); } } } @@ -201,7 +201,7 @@ void map::generate( const int x, const int y, const int z, const time_point &whe dbg( D_INFO ) << "map::generate: submap (" << i << "," << j << ")"; if( i <= 1 && j <= 1 ) { - saven( i, j, z ); + saven( tripoint( i, j, z ) ); } else { delete get_submap_at_grid( { i, j, z } ); } @@ -785,7 +785,7 @@ class jmapgen_npc : public jmapgen_piece } void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, const float /*mon_density*/, mission *miss = nullptr ) const override { - int npc_id = dat.m.place_npc( x.get(), y.get(), npc_class ); + int npc_id = dat.m.place_npc( point( x.get(), y.get() ), npc_class ); if( miss && target ) { miss->set_target_npc_id( npc_id ); } @@ -811,7 +811,7 @@ class jmapgen_faction : public jmapgen_piece } void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, const float /*mdensity*/, mission * ) const override { - dat.m.apply_faction_ownership( x.val, y.val, x.valmax, y.valmax, id ); + dat.m.apply_faction_ownership( point( x.val, y.val ), point( x.valmax, y.valmax ), id ); } }; /** @@ -939,7 +939,7 @@ class jmapgen_vending_machine : public jmapgen_piece const int rx = x.get(); const int ry = y.get(); dat.m.furn_set( point( rx, ry ), f_null ); - dat.m.place_vending( rx, ry, item_group_id, reinforced ); + dat.m.place_vending( point( rx, ry ), item_group_id, reinforced ); } bool has_vehicle_collision( const mapgendata &dat, int x, int y ) const override { return dat.m.veh_at( tripoint( x, y, dat.zlevel ) ).has_value(); @@ -963,9 +963,9 @@ class jmapgen_toilet : public jmapgen_piece const int charges = amount.get(); dat.m.furn_set( point( rx, ry ), f_null ); if( charges == 0 ) { - dat.m.place_toilet( rx, ry ); // Use the default charges supplied as default values + dat.m.place_toilet( point( rx, ry ) ); // Use the default charges supplied as default values } else { - dat.m.place_toilet( rx, ry, charges ); + dat.m.place_toilet( point( rx, ry ), charges ); } } bool has_vehicle_collision( const mapgendata &dat, int x, int y ) const override { @@ -1002,9 +1002,9 @@ class jmapgen_gaspump : public jmapgen_piece charges = rng( 10000, 50000 ); } if( !fuel.empty() ) { - dat.m.place_gas_pump( rx, ry, charges, fuel ); + dat.m.place_gas_pump( point( rx, ry ), charges, fuel ); } else { - dat.m.place_gas_pump( rx, ry, charges ); + dat.m.place_gas_pump( point( rx, ry ), charges ); } } bool has_vehicle_collision( const mapgendata &dat, int x, int y ) const override { @@ -1065,7 +1065,8 @@ class jmapgen_item_group : public jmapgen_piece } void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, const float /*mon_density*/, mission * ) const override { - dat.m.place_items( group_id, chance.get(), x.val, y.val, x.valmax, y.valmax, true, 0 ); + dat.m.place_items( group_id, chance.get(), point( x.val, y.val ), point( x.valmax, y.valmax ), true, + 0 ); } }; @@ -1137,7 +1138,7 @@ class jmapgen_monster_group : public jmapgen_piece } void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, const float mdensity, mission * ) const override { - dat.m.place_spawns( id, chance.get(), x.val, y.val, x.valmax, y.valmax, + dat.m.place_spawns( id, chance.get(), point( x.val, y.val ), point( x.valmax, y.valmax ), density == -1.0f ? mdensity : density ); } }; @@ -1229,7 +1230,7 @@ class jmapgen_monster : public jmapgen_piece mission_id = miss->get_id(); } - dat.m.add_spawn( *( ids.pick() ), spawn_count * pack_size.get(), x.get(), y.get(), + dat.m.add_spawn( *( ids.pick() ), spawn_count * pack_size.get(), point( x.get(), y.get() ), friendly, -1, mission_id, name ); } }; @@ -1308,7 +1309,7 @@ class jmapgen_spawn_item : public jmapgen_piece const float spawn_rate = get_option( "ITEM_SPAWNRATE" ); int spawn_count = ( c == 100 ) ? 1 : roll_remainder( c * spawn_rate / 100.0f ); for( int i = 0; i < spawn_count; i++ ) { - dat.m.spawn_item( x.get(), y.get(), type, amount.get() ); + dat.m.spawn_item( point( x.get(), y.get() ), type, amount.get() ); } } }; @@ -2432,12 +2433,12 @@ bool jmapgen_setmap::apply( const mapgendata &dat, const point &offset, mission case JMAPGEN_SETMAP_LINE_TER: { // TODO: the ter_id should be stored separately and not be wrapped in an jmapgen_int - m.draw_line_ter( ter_id( val.get() ), x_get(), y_get(), x2_get(), y2_get() ); + m.draw_line_ter( ter_id( val.get() ), point( x_get(), y_get() ), point( x2_get(), y2_get() ) ); } break; case JMAPGEN_SETMAP_LINE_FURN: { // TODO: the furn_id should be stored separately and not be wrapped in an jmapgen_int - m.draw_line_furn( furn_id( val.get() ), x_get(), y_get(), x2_get(), y2_get() ); + m.draw_line_furn( furn_id( val.get() ), point( x_get(), y_get() ), point( x2_get(), y2_get() ) ); } break; case JMAPGEN_SETMAP_LINE_TRAP: { @@ -2457,12 +2458,12 @@ bool jmapgen_setmap::apply( const mapgendata &dat, const point &offset, mission break; case JMAPGEN_SETMAP_SQUARE_TER: { // TODO: the ter_id should be stored separately and not be wrapped in an jmapgen_int - m.draw_square_ter( ter_id( val.get() ), x_get(), y_get(), x2_get(), y2_get() ); + m.draw_square_ter( ter_id( val.get() ), point( x_get(), y_get() ), point( x2_get(), y2_get() ) ); } break; case JMAPGEN_SETMAP_SQUARE_FURN: { // TODO: the furn_id should be stored separately and not be wrapped in an jmapgen_int - m.draw_square_furn( furn_id( val.get() ), x_get(), y_get(), x2_get(), y2_get() ); + m.draw_square_furn( furn_id( val.get() ), point( x_get(), y_get() ), point( x2_get(), y2_get() ) ); } break; case JMAPGEN_SETMAP_SQUARE_TRAP: { @@ -2810,15 +2811,15 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, "ss __,,__ _,,,,_ \n" "ssssss__,,__ss__,,__ssss\n" "ssssss______ss______ssss\n", ter_key, fur_key ); - place_items( "office", 75, 4, 2, 6, 2, false, 0 ); - place_items( "office", 75, 19, 6, 19, 6, false, 0 ); - place_items( "office", 75, 12, 8, 14, 8, false, 0 ); + place_items( "office", 75, point( 4, 2 ), point( 6, 2 ), false, 0 ); + place_items( "office", 75, point( 19, 6 ), point( 19, 6 ), false, 0 ); + place_items( "office", 75, point( 12, 8 ), point( 14, 8 ), false, 0 ); if( density > 1 ) { - place_spawns( GROUP_ZOMBIE, 2, 0, 0, 12, 3, density ); + place_spawns( GROUP_ZOMBIE, 2, point_zero, point( 12, 3 ), density ); } else { - place_spawns( GROUP_PLAIN, 2, 15, 1, 22, 7, 1, true ); - place_spawns( GROUP_PLAIN, 2, 15, 1, 22, 7, 0.15 ); - place_spawns( GROUP_ZOMBIE_COP, 2, 10, 10, 14, 10, 0.1 ); + place_spawns( GROUP_PLAIN, 2, point( 15, 1 ), point( 22, 7 ), 1, true ); + place_spawns( GROUP_PLAIN, 2, point( 15, 1 ), point( 22, 7 ), 0.15 ); + place_spawns( GROUP_ZOMBIE_COP, 2, point( 10, 10 ), point( 14, 10 ), 0.1 ); } place_office_chairs(); @@ -2864,22 +2865,22 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, "ss%|----|...|.R>|EEE|...\n" "ss%|rrrr|...|.R.|EEED...\n", ter_key, fur_key ); if( density > 1 ) { - place_spawns( GROUP_ZOMBIE, 2, 0, 0, 2, 8, density ); + place_spawns( GROUP_ZOMBIE, 2, point_zero, point( 2, 8 ), density ); } else { - place_spawns( GROUP_PLAIN, 1, 5, 7, 15, 20, 0.1 ); - } - place_items( "office", 75, 4, 23, 7, 23, false, 0 ); - place_items( "office", 75, 4, 19, 7, 19, false, 0 ); - place_items( "office", 75, 4, 14, 7, 14, false, 0 ); - place_items( "office", 75, 5, 16, 7, 16, false, 0 ); - place_items( "fridge", 80, 14, 17, 14, 17, false, 0 ); - place_items( "cleaning", 75, 19, 17, 20, 17, false, 0 ); - place_items( "cubical_office", 75, 6, 12, 7, 12, false, 0 ); - place_items( "cubical_office", 75, 12, 11, 12, 12, false, 0 ); - place_items( "cubical_office", 75, 16, 11, 17, 12, false, 0 ); - place_items( "cubical_office", 75, 4, 5, 5, 5, false, 0 ); - place_items( "cubical_office", 75, 11, 5, 12, 5, false, 0 ); - place_items( "cubical_office", 75, 14, 5, 16, 5, false, 0 ); + place_spawns( GROUP_PLAIN, 1, point( 5, 7 ), point( 15, 20 ), 0.1 ); + } + place_items( "office", 75, point( 4, 23 ), point( 7, 23 ), false, 0 ); + place_items( "office", 75, point( 4, 19 ), point( 7, 19 ), false, 0 ); + place_items( "office", 75, point( 4, 14 ), point( 7, 14 ), false, 0 ); + place_items( "office", 75, point( 5, 16 ), point( 7, 16 ), false, 0 ); + place_items( "fridge", 80, point( 14, 17 ), point( 14, 17 ), false, 0 ); + place_items( "cleaning", 75, point( 19, 17 ), point( 20, 17 ), false, 0 ); + place_items( "cubical_office", 75, point( 6, 12 ), point( 7, 12 ), false, 0 ); + place_items( "cubical_office", 75, point( 12, 11 ), point( 12, 12 ), false, 0 ); + place_items( "cubical_office", 75, point( 16, 11 ), point( 17, 12 ), false, 0 ); + place_items( "cubical_office", 75, point( 4, 5 ), point( 5, 5 ), false, 0 ); + place_items( "cubical_office", 75, point( 11, 5 ), point( 12, 5 ), false, 0 ); + place_items( "cubical_office", 75, point( 14, 5 ), point( 16, 5 ), false, 0 ); place_office_chairs(); if( dat.west() == "office_tower_1_entrance" ) { @@ -2920,16 +2921,16 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, " ssssssss ss\n" "ssssssssssssssssssssssss\n" "ssssssssssssssssssssssss\n", ter_key, fur_key ); - place_items( "office", 75, 19, 1, 19, 3, false, 0 ); - place_items( "office", 75, 17, 3, 18, 3, false, 0 ); - place_items( "office", 90, 8, 7, 9, 7, false, 0 ); - place_items( "cubical_office", 75, 19, 5, 19, 7, false, 0 ); - place_items( "cleaning", 80, 1, 7, 2, 7, false, 0 ); + place_items( "office", 75, point( 19, 1 ), point( 19, 3 ), false, 0 ); + place_items( "office", 75, point( 17, 3 ), point( 18, 3 ), false, 0 ); + place_items( "office", 90, point( 8, 7 ), point( 9, 7 ), false, 0 ); + place_items( "cubical_office", 75, point( 19, 5 ), point( 19, 7 ), false, 0 ); + place_items( "cleaning", 80, point( 1, 7 ), point( 2, 7 ), false, 0 ); if( density > 1 ) { - place_spawns( GROUP_ZOMBIE, 2, 0, 0, 14, 10, density ); + place_spawns( GROUP_ZOMBIE, 2, point_zero, point( 14, 10 ), density ); } else { - place_spawns( GROUP_PLAIN, 1, 10, 10, 14, 10, 0.15 ); - place_spawns( GROUP_ZOMBIE_COP, 2, 10, 10, 14, 10, 0.1 ); + place_spawns( GROUP_PLAIN, 1, point( 10, 10 ), point( 14, 10 ), 0.15 ); + place_spawns( GROUP_ZOMBIE_COP, 2, point( 10, 10 ), point( 14, 10 ), 0.1 ); } place_office_chairs(); @@ -2968,19 +2969,19 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, "...|---|---|..|l.dddV%ss\n" "...|xEE|.R>|......hdV%ss\n" "...DEEE|.R.|..|.....V%ss\n", ter_key, fur_key ); - spawn_item( 18, 15, "record_accounting" ); - place_items( "cleaning", 75, 3, 5, 5, 5, false, 0 ); - place_items( "office", 75, 10, 7, 16, 8, false, 0 ); - place_items( "cubical_office", 75, 15, 15, 19, 15, false, 0 ); - place_items( "cubical_office", 75, 16, 12, 16, 13, false, 0 ); - place_items( "cubical_office", 75, 17, 19, 19, 19, false, 0 ); - place_items( "office", 75, 17, 21, 19, 21, false, 0 ); - place_items( "office", 75, 16, 11, 17, 12, false, 0 ); - place_items( "cleaning", 75, 8, 20, 10, 20, false, 0 ); + spawn_item( point( 18, 15 ), "record_accounting" ); + place_items( "cleaning", 75, point( 3, 5 ), point( 5, 5 ), false, 0 ); + place_items( "office", 75, point( 10, 7 ), point( 16, 8 ), false, 0 ); + place_items( "cubical_office", 75, point( 15, 15 ), point( 19, 15 ), false, 0 ); + place_items( "cubical_office", 75, point( 16, 12 ), point( 16, 13 ), false, 0 ); + place_items( "cubical_office", 75, point( 17, 19 ), point( 19, 19 ), false, 0 ); + place_items( "office", 75, point( 17, 21 ), point( 19, 21 ), false, 0 ); + place_items( "office", 75, point( 16, 11 ), point( 17, 12 ), false, 0 ); + place_items( "cleaning", 75, point( 8, 20 ), point( 10, 20 ), false, 0 ); if( density > 1 ) { - place_spawns( GROUP_ZOMBIE, 2, 0, 0, 9, 15, density ); + place_spawns( GROUP_ZOMBIE, 2, point_zero, point( 9, 15 ), density ); } else { - place_spawns( GROUP_PLAIN, 1, 0, 0, 9, 15, 0.1 ); + place_spawns( GROUP_PLAIN, 1, point_zero, point( 9, 15 ), 0.1 ); } place_office_chairs(); @@ -3020,9 +3021,9 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, "ssssssssssssssssssssssss\n" "ssssssssssssssssssssssss\n", ter_key, fur_key ); if( density > 1 ) { - place_spawns( GROUP_ZOMBIE, 2, 0, 0, EAST_EDGE, SOUTH_EDGE, density ); + place_spawns( GROUP_ZOMBIE, 2, point_zero, point( EAST_EDGE, SOUTH_EDGE ), density ); } else { - place_spawns( GROUP_PLAIN, 1, 0, 0, EAST_EDGE, SOUTH_EDGE, 0.1 ); + place_spawns( GROUP_PLAIN, 1, point_zero, point( EAST_EDGE, SOUTH_EDGE ), 0.1 ); } if( dat.north() == "office_tower_b" && dat.west() == "office_tower_b" ) { rotate( 3 ); @@ -3066,9 +3067,9 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, "sss|........|.R<|EEE|___\n" "sss|........|.R.|EEED___\n", b_ter_key, b_fur_key ); if( density > 1 ) { - place_spawns( GROUP_ZOMBIE, 2, 0, 0, EAST_EDGE, SOUTH_EDGE, density ); + place_spawns( GROUP_ZOMBIE, 2, point_zero, point( EAST_EDGE, SOUTH_EDGE ), density ); } else { - place_spawns( GROUP_PLAIN, 1, 0, 0, EAST_EDGE, SOUTH_EDGE, 0.1 ); + place_spawns( GROUP_PLAIN, 1, point_zero, point( EAST_EDGE, SOUTH_EDGE ), 0.1 ); } if( dat.west() == "office_tower_b_entrance" ) { rotate( 1 ); @@ -3153,9 +3154,9 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, "ssssssssssssssssssssssss\n" "ssssssssssssssssssssssss\n", b_ter_key, b_fur_key ); if( density > 1 ) { - place_spawns( GROUP_ZOMBIE, 2, 0, 0, EAST_EDGE, SOUTH_EDGE, density ); + place_spawns( GROUP_ZOMBIE, 2, point_zero, point( EAST_EDGE, SOUTH_EDGE ), density ); } else { - place_spawns( GROUP_PLAIN, 1, 0, 0, EAST_EDGE, SOUTH_EDGE, 0.1 ); + place_spawns( GROUP_PLAIN, 1, point_zero, point( EAST_EDGE, SOUTH_EDGE ), 0.1 ); } if( dat.north() == "office_tower_b_entrance" ) { rotate( 1 ); @@ -3232,9 +3233,9 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, "___|xEE|.R<|........|sss\n" "___DEEE|.R.|...,,...|sss\n", b_ter_key, b_fur_key ); if( density > 1 ) { - place_spawns( GROUP_ZOMBIE, 2, 0, 0, EAST_EDGE, SOUTH_EDGE, density ); + place_spawns( GROUP_ZOMBIE, 2, point_zero, point( EAST_EDGE, SOUTH_EDGE ), density ); } else { - place_spawns( GROUP_PLAIN, 1, 0, 0, EAST_EDGE, SOUTH_EDGE, 0.1 ); + place_spawns( GROUP_PLAIN, 1, point_zero, point( EAST_EDGE, SOUTH_EDGE ), 0.1 ); } if( dat.west() == "office_tower_b" && dat.north() == "office_tower_b" ) { rotate( 1 ); @@ -3376,7 +3377,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi science_room( this, 2, 2, SEEX - 3, SEEY * 2 - 3, dat.zlevel, 1 ); science_room( this, SEEX + 2, 2, SEEX * 2 - 3, SEEY * 2 - 3, dat.zlevel, 3 ); - place_spawns( GROUP_TURRET_SMG, 1, SEEX, 5, SEEX, 5, 1, true ); + place_spawns( GROUP_TURRET_SMG, 1, point( SEEX, 5 ), point( SEEX, 5 ), 1, true ); if( is_ot_match( "road", dat.east(), ot_match_type::type ) ) { rotate( 1 ); @@ -3820,7 +3821,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi } if( tower_lab ) { - place_spawns( GROUP_LAB, 1, 0, 0, EAST_EDGE, EAST_EDGE, abs_sub.z * 0.02f ); + place_spawns( GROUP_LAB, 1, point_zero, point( EAST_EDGE, EAST_EDGE ), abs_sub.z * 0.02f ); } // Lab special effects. @@ -3950,16 +3951,16 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi ter_set( point( x, y ), t_thconc_floor ); }, center.x, center.y, 1 ); - place_spawns( GROUP_HAZMATBOT, 1, center.x - 1, center.y, - center.x - 1, center.y, 1, true ); - place_spawns( GROUP_HAZMATBOT, 2, center.x - 1, center.y, - center.x - 1, center.y, 1, true ); + place_spawns( GROUP_HAZMATBOT, 1, center.xy() + point_west, + center.xy() + point_west, 1, true ); + place_spawns( GROUP_HAZMATBOT, 2, center.xy() + point_west, + center.xy() + point_west, 1, true ); // damaged mininuke/plut thrown past edge of rubble so the player can see it. int marker_x = center.x - 2 + 4 * rng( 0, 1 ); int marker_y = center.y + rng( -2, 2 ); if( one_in( 4 ) ) { - spawn_item( marker_x, marker_y, + spawn_item( point( marker_x, marker_y ), "mininuke", 1, 1, 0, rng( 2, 4 ) ); } else { item newliquid( "plut_slurry_dense", calendar::start_of_cataclysm ); @@ -4009,8 +4010,8 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi ter_set( center.xy(), t_fungus_floor_in ); furn_set( center.xy(), f_null ); trap_set( center, tr_portal ); - place_spawns( GROUP_FUNGI_FUNGALOID, 1, center.x - 2, center.y - 2, - center.x + 2, center.y + 2, 1, true ); + place_spawns( GROUP_FUNGI_FUNGALOID, 1, center.xy() + point( -2, -2 ), + center.xy() + point( 2, 2 ), 1, true ); break; } @@ -4127,14 +4128,14 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi case 1: case 2: loot_variant = rng( 1, 100 ); //The variants have a 67/22/7/4 split. - place_spawns( GROUP_ROBOT_SECUBOT, 1, 6, 6, 6, 6, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, SEEX * 2 - 7, 6, - SEEX * 2 - 7, 6, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, 6, SEEY * 2 - 7, - 6, SEEY * 2 - 7, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, SEEX * 2 - 7, SEEY * 2 - 7, - SEEX * 2 - 7, SEEY * 2 - 7, 1, true ); - spawn_item( SEEX - 4, SEEY - 2, "id_science" ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( 6, 6 ), point( 6, 6 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( SEEX * 2 - 7, 6 ), + point( SEEX * 2 - 7, 6 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( 6, SEEY * 2 - 7 ), + point( 6, SEEY * 2 - 7 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( SEEX * 2 - 7, SEEY * 2 - 7 ), + point( SEEX * 2 - 7, SEEY * 2 - 7 ), 1, true ); + spawn_item( point( SEEX - 4, SEEY - 2 ), "id_science" ); if( loot_variant <= 96 ) { mtrap_set( this, SEEX - 3, SEEY - 3, tr_dissector ); mtrap_set( this, SEEX + 2, SEEY - 3, tr_dissector ); @@ -4150,26 +4151,26 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi furn_set( point( SEEX - 1, SEEY ), f_table ); furn_set( point( SEEX, SEEY ), f_table ); if( loot_variant <= 67 ) { - spawn_item( SEEX, SEEY - 1, "UPS_off" ); - spawn_item( SEEX, SEEY - 1, "battery", dice( 4, 3 ) ); - spawn_item( SEEX - 1, SEEY, "v29" ); - spawn_item( SEEX - 1, SEEY, "laser_rifle", dice( 1, 0 ) ); - spawn_item( SEEX, SEEY, "plasma_gun" ); - spawn_item( SEEX, SEEY, "plasma" ); - spawn_item( SEEX - 1, SEEY, "recipe_atomic_battery" ); - spawn_item( SEEX, SEEY - 1, "solar_panel_v3" ); + spawn_item( point( SEEX, SEEY - 1 ), "UPS_off" ); + spawn_item( point( SEEX, SEEY - 1 ), "battery", dice( 4, 3 ) ); + spawn_item( point( SEEX - 1, SEEY ), "v29" ); + spawn_item( point( SEEX - 1, SEEY ), "laser_rifle", dice( 1, 0 ) ); + spawn_item( point( SEEX, SEEY ), "plasma_gun" ); + spawn_item( point( SEEX, SEEY ), "plasma" ); + spawn_item( point( SEEX - 1, SEEY ), "recipe_atomic_battery" ); + spawn_item( point( SEEX, SEEY - 1 ), "solar_panel_v3" ); } else if( loot_variant > 67 && loot_variant < 89 ) { - spawn_item( SEEX - 1, SEEY - 1, "mininuke", dice( 3, 6 ) ); - spawn_item( SEEX, SEEY - 1, "mininuke", dice( 3, 6 ) ); - spawn_item( SEEX - 1, SEEY, "mininuke", dice( 3, 6 ) ); - spawn_item( SEEX, SEEY, "mininuke", dice( 3, 6 ) ); - spawn_item( SEEX, SEEY, "recipe_atomic_battery" ); - spawn_item( SEEX, SEEY, "solar_panel_v3" ); + spawn_item( point( SEEX - 1, SEEY - 1 ), "mininuke", dice( 3, 6 ) ); + spawn_item( point( SEEX, SEEY - 1 ), "mininuke", dice( 3, 6 ) ); + spawn_item( point( SEEX - 1, SEEY ), "mininuke", dice( 3, 6 ) ); + spawn_item( point( SEEX, SEEY ), "mininuke", dice( 3, 6 ) ); + spawn_item( point( SEEX, SEEY ), "recipe_atomic_battery" ); + spawn_item( point( SEEX, SEEY ), "solar_panel_v3" ); } else { // loot_variant between 90 and 96. - spawn_item( SEEX - 1, SEEY - 1, "rm13_armor" ); - spawn_item( SEEX, SEEY - 1, "plut_cell" ); - spawn_item( SEEX - 1, SEEY, "plut_cell" ); - spawn_item( SEEX, SEEY, "recipe_caseless" ); + spawn_item( point( SEEX - 1, SEEY - 1 ), "rm13_armor" ); + spawn_item( point( SEEX, SEEY - 1 ), "plut_cell" ); + spawn_item( point( SEEX - 1, SEEY ), "plut_cell" ); + spawn_item( point( SEEX, SEEY ), "recipe_caseless" ); } } else { // 4% of the lab ends will be this weapons testing end. mtrap_set( this, SEEX - 4, SEEY - 3, tr_dissector ); @@ -4191,10 +4192,10 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi SEEX + 1, SEEY + 1 ); line( this, t_reinforced_glass, SEEX - 3, SEEY - 2, SEEX - 3, SEEY + 1 ); line( this, t_reinforced_glass, SEEX + 2, SEEY - 2, SEEX + 2, SEEY + 1 ); - place_items( "ammo_rare", 96, SEEX - 2, SEEY - 1, - SEEX + 1, SEEY - 1, false, 0 ); - place_items( "guns_rare", 96, SEEX - 2, SEEY, SEEX + 1, SEEY, false, 0 ); - spawn_item( SEEX + 1, SEEY, "solar_panel_v3" ); + place_items( "ammo_rare", 96, point( SEEX - 2, SEEY - 1 ), + point( SEEX + 1, SEEY - 1 ), false, 0 ); + place_items( "guns_rare", 96, point( SEEX - 2, SEEY ), point( SEEX + 1, SEEY ), false, 0 ); + spawn_item( point( SEEX + 1, SEEY ), "solar_panel_v3" ); } break; // Netherworld access @@ -4219,13 +4220,13 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi } else if( j == tw + 2 ) { ter_set( point( i, j ), t_concrete_wall ); } else { // Empty space holds monsters! - place_spawns( GROUP_NETHER, 1, i, j, i, j, 1, true ); + place_spawns( GROUP_NETHER, 1, point( i, j ), point( i, j ), 1, true ); } } } } - spawn_item( SEEX - 1, 8, "id_science" ); + spawn_item( point( SEEX - 1, 8 ), "id_science" ); tmpcomp = add_computer( tripoint( SEEX, 8, abs_sub.z ), _( "Sub-prime contact console" ), 7 ); if( monsters_end ) { //only add these options when there are monsters. @@ -4245,13 +4246,13 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi // Bionics case 4: { - place_spawns( GROUP_ROBOT_SECUBOT, 1, 6, 6, 6, 6, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, SEEX * 2 - 7, 6, - SEEX * 2 - 7, 6, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, 6, SEEY * 2 - 7, - 6, SEEY * 2 - 7, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, SEEX * 2 - 7, SEEY * 2 - 7, - SEEX * 2 - 7, SEEY * 2 - 7, 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( 6, 6 ), point( 6, 6 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( SEEX * 2 - 7, 6 ), + point( SEEX * 2 - 7, 6 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( 6, SEEY * 2 - 7 ), + point( 6, SEEY * 2 - 7 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( SEEX * 2 - 7, SEEY * 2 - 7 ), + point( SEEX * 2 - 7, SEEY * 2 - 7 ), 1, true ); mtrap_set( this, SEEX - 2, SEEY - 2, tr_dissector ); mtrap_set( this, SEEX + 1, SEEY - 2, tr_dissector ); mtrap_set( this, SEEX - 2, SEEY + 1, tr_dissector ); @@ -4259,14 +4260,14 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi square_furn( this, f_counter, SEEX - 1, SEEY - 1, SEEX, SEEY ); int item_count = 0; while( item_count < 5 ) { - item_count += place_items( "bionics", 75, SEEX - 1, SEEY - 1, - SEEX, SEEY, false, 0 ).size(); + item_count += place_items( "bionics", 75, point( SEEX - 1, SEEY - 1 ), + point( SEEX, SEEY ), false, 0 ).size(); } line( this, t_reinforced_glass, SEEX - 2, SEEY - 2, SEEX + 1, SEEY - 2 ); line( this, t_reinforced_glass, SEEX - 2, SEEY + 1, SEEX + 1, SEEY + 1 ); line( this, t_reinforced_glass, SEEX - 2, SEEY - 1, SEEX - 2, SEEY ); line( this, t_reinforced_glass, SEEX + 1, SEEY - 1, SEEX + 1, SEEY ); - spawn_item( SEEX - 4, SEEY - 3, "id_science" ); + spawn_item( point( SEEX - 4, SEEY - 3 ), "id_science" ); ter_set( point( SEEX - 3, SEEY - 3 ), t_console ); tmpcomp = add_computer( tripoint( SEEX - 3, SEEY - 3, abs_sub.z ), _( "Bionic access" ), 3 ); @@ -4279,19 +4280,19 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi // CVD Forge case 5: - place_spawns( GROUP_ROBOT_SECUBOT, 1, 6, 6, 6, 6, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, SEEX * 2 - 7, 6, - SEEX * 2 - 7, 6, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, 6, SEEY * 2 - 7, - 6, SEEY * 2 - 7, 1, true ); - place_spawns( GROUP_ROBOT_SECUBOT, 1, SEEX * 2 - 7, SEEY * 2 - 7, - SEEX * 2 - 7, SEEY * 2 - 7, 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( 6, 6 ), point( 6, 6 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( SEEX * 2 - 7, 6 ), + point( SEEX * 2 - 7, 6 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( 6, SEEY * 2 - 7 ), + point( 6, SEEY * 2 - 7 ), 1, true ); + place_spawns( GROUP_ROBOT_SECUBOT, 1, point( SEEX * 2 - 7, SEEY * 2 - 7 ), + point( SEEX * 2 - 7, SEEY * 2 - 7 ), 1, true ); line( this, t_cvdbody, SEEX - 2, SEEY - 2, SEEX - 2, SEEY + 1 ); line( this, t_cvdbody, SEEX - 1, SEEY - 2, SEEX - 1, SEEY + 1 ); line( this, t_cvdbody, SEEX, SEEY - 1, SEEX, SEEY + 1 ); line( this, t_cvdbody, SEEX + 1, SEEY - 2, SEEX + 1, SEEY + 1 ); ter_set( point( SEEX, SEEY - 2 ), t_cvdmachine ); - spawn_item( SEEX, SEEY - 3, "id_science" ); + spawn_item( point( SEEX, SEEY - 3 ), "id_science" ); break; } } // end use_hardcoded_lab_finale @@ -4459,10 +4460,10 @@ void map::draw_temple( const oter_id &terrain_type, mapgendata &dat, const time_ square( this, t_water_dp, 4, 4, 5, 5 ); // replaced mon_sewer_snake spawn with GROUP_SEWER // Decide whether a group of only sewer snakes be made, probably not worth it - place_spawns( GROUP_SEWER, 1, 4, 4, 4, 4, 1, true ); + place_spawns( GROUP_SEWER, 1, point( 4, 4 ), point( 4, 4 ), 1, true ); square( this, t_water_dp, SEEX * 2 - 5, 4, SEEX * 2 - 4, 6 ); - place_spawns( GROUP_SEWER, 1, 1, SEEX * 2 - 5, 1, SEEX * 2 - 5, 1, true ); + place_spawns( GROUP_SEWER, 1, point( 1, SEEX * 2 - 5 ), point( 1, SEEX * 2 - 5 ), 1, true ); square( this, t_water_dp, 4, SEEY * 2 - 5, 6, SEEY * 2 - 4 ); @@ -4722,7 +4723,7 @@ void map::draw_sewer( const oter_id &terrain_type, mapgendata &dat, const time_p tmpcomp = add_computer( tripoint( 6, 19, abs_sub.z ), _( "EnviroCom OS v2.03" ), 1 ); tmpcomp->add_option( _( "Unlock stairs" ), COMPACT_OPEN, 0 ); tmpcomp->add_failure( COMPFAIL_SHUTDOWN ); - place_items( "sewage_plant", 80, 1, 6, 1, 13, false, 0 ); + place_items( "sewage_plant", 80, point( 1, 6 ), point( 1, 13 ), false, 0 ); } else if( terrain_type == "sewage_treatment_hub" ) { // Stairs up, center of 3x3 of treatment_below @@ -4745,7 +4746,7 @@ void map::draw_sewer( const oter_id &terrain_type, mapgendata &dat, const time_p line( this, t_wall, 9, 14, 9, 23 ); line( this, t_wall_glass, 9, 16, 9, 19 ); square_furn( this, f_counter, 5, 16, 6, 20 ); - place_items( "sewage_plant", 80, 5, 16, 6, 20, false, 0 ); + place_items( "sewage_plant", 80, point( 5, 16 ), point( 6, 20 ), false, 0 ); ter_set( point( 0, 20 ), t_door_c ); ter_set( point( 9, 20 ), t_door_c ); @@ -4843,7 +4844,7 @@ void map::draw_sewer( const oter_id &terrain_type, mapgendata &dat, const time_p // Possibility of extra equipment shelves if( !one_in( 3 ) ) { line_furn( this, f_rack, 23, 1, 23, 4 ); - place_items( "sewage_plant", 60, 23, 1, 23, 4, false, 0 ); + place_items( "sewage_plant", 60, point( 23, 1 ), point( 23, 4 ), false, 0 ); } // Finally, choose what the top-left and bottom-right rooms do. @@ -4864,15 +4865,15 @@ void map::draw_sewer( const oter_id &terrain_type, mapgendata &dat, const time_p tmpcomp->add_failure( COMPFAIL_PUMP_LEAK ); // Lower right... line_furn( this, f_counter, 15, 23, 22, 23 ); - place_items( "sewer", 65, 15, 23, 22, 23, false, 0 ); + place_items( "sewer", 65, point( 15, 23 ), point( 22, 23 ), false, 0 ); line_furn( this, f_counter, 23, 15, 23, 19 ); - place_items( "sewer", 65, 23, 15, 23, 19, false, 0 ); + place_items( "sewer", 65, point( 23, 15 ), point( 23, 19 ), false, 0 ); } else { // Upper left is valuable finds, lower right is sampling // Upper left... line_furn( this, f_counter, 1, 1, 1, 7 ); - place_items( "sewer", 65, 1, 1, 1, 7, false, 0 ); + place_items( "sewer", 65, point_south_east, point( 1, 7 ), false, 0 ); line_furn( this, f_counter, 7, 1, 7, 7 ); - place_items( "sewer", 65, 7, 1, 7, 7, false, 0 ); + place_items( "sewer", 65, point( 7, 1 ), point( 7, 7 ), false, 0 ); // Lower right... line( this, t_wall, 17, 22, 17, 23 ); line( this, t_wall, 19, 22, 19, 23 ); @@ -5014,7 +5015,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po ter_set( point( 11, 10 ), t_elevator ); ter_set( point( 10, 12 ), t_ladder_up ); line_furn( this, f_counter, 10, 15, 15, 15 ); - place_items( "mine_equipment", 86, 10, 15, 15, 15, false, 0 ); + place_items( "mine_equipment", 86, point( 10, 15 ), point( 15, 15 ), false, 0 ); if( one_in( 2 ) ) { ter_set( point( 9, 12 ), t_door_c ); } else { @@ -5058,7 +5059,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po } } } - place_items( "wreckage", 70, x - 3, y - 3, x + 2, y + 2, false, 0 ); + place_items( "wreckage", 70, point( x - 3, y - 3 ), point( x + 2, y + 2 ), false, 0 ); } break; @@ -5093,7 +5094,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po sides.push_back( WEST ); } if( sides.empty() ) { - place_spawns( GROUP_DARK_WYRM, 1, SEEX, SEEY, SEEX, SEEY, 1, true ); + place_spawns( GROUP_DARK_WYRM, 1, point( SEEX, SEEY ), point( SEEX, SEEY ), 1, true ); i = num_worms; } else { point p; @@ -5114,7 +5115,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po break; } ter_set( p, t_rock_floor ); - place_spawns( GROUP_DARK_WYRM, 1, p.x, p.y, p.x, p.y, 1, true ); + place_spawns( GROUP_DARK_WYRM, 1, p, p, 1, true ); } } } @@ -5128,8 +5129,8 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po line( this, t_rock, orx + 1, ory + 2, orx + 1, ory + 4 ); line( this, t_rock, orx + 1, ory + 2, orx + 3, ory + 2 ); ter_set( point( orx + 3, ory + 3 ), t_rock ); - add_item( orx + 2, ory + 3, item::make_corpse() ); - place_items( "mine_equipment", 60, orx + 2, ory + 3, orx + 2, ory + 3, + add_item( point( orx + 2, ory + 3 ), item::make_corpse() ); + place_items( "mine_equipment", 60, point( orx + 2, ory + 3 ), point( orx + 2, ory + 3 ), false, 0 ); } break; @@ -5306,7 +5307,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po case 1: { // Wyrms int x = rng( SEEX, SEEX + 1 ), y = rng( SEEY, SEEY + 1 ); ter_set( point( x, y ), t_pedestal_wyrm ); - spawn_item( x, y, "petrified_eye" ); + spawn_item( point( x, y ), "petrified_eye" ); } break; // That's it! game::examine handles the pedestal/wyrm spawns @@ -5315,10 +5316,10 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po for( int i = 0; i < num_bodies; i++ ) { int x = rng( 4, SEEX * 2 - 5 ); int y = rng( 4, SEEX * 2 - 5 ); - add_item( x, y, item::make_corpse() ); - place_items( "mine_equipment", 60, x, y, x, y, false, 0 ); + add_item( point( x, y ), item::make_corpse() ); + place_items( "mine_equipment", 60, point( x, y ), point( x, y ), false, 0 ); } - place_spawns( GROUP_DOG_THING, 1, SEEX, SEEX, SEEX + 1, SEEX + 1, 1, true, true ); + place_spawns( GROUP_DOG_THING, 1, point( SEEX, SEEX ), point( SEEX + 1, SEEX + 1 ), 1, true, true ); spawn_artifact( tripoint( rng( SEEX, SEEX + 1 ), rng( SEEY, SEEY + 1 ), abs_sub.z ) ); } break; @@ -5427,7 +5428,7 @@ void map::draw_spiral( const oter_id &terrain_type, mapgendata &/*dat*/, const t line( this, t_rock, orx + 1, ory + 2, orx + 3, ory + 2 ); ter_set( point( orx + 3, ory + 3 ), t_rock ); ter_set( point( orx + 2, ory + 3 ), t_rock_floor ); - place_items( "spiral", 60, orx + 2, ory + 3, orx + 2, ory + 3, false, 0 ); + place_items( "spiral", 60, point( orx + 2, ory + 3 ), point( orx + 2, ory + 3 ), false, 0 ); } } } @@ -5504,12 +5505,12 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, " _______ \n" " _______ \n" " _______ \n", ter_key, fur_key ); - spawn_item( 19, 3, "cleansuit" ); - place_items( "office", 80, 4, 19, 6, 19, false, 0 ); - place_items( "cleaning", 90, 7, 3, 7, 5, false, 0 ); - place_items( "toxic_dump_equipment", 85, 19, 1, 19, 3, false, 0 ); - place_items( "toxic_dump_equipment", 85, 19, 5, 19, 7, false, 0 ); - place_spawns( GROUP_HAZMATBOT, 2, 10, 5, 10, 5, 1, true ); + spawn_item( point( 19, 3 ), "cleansuit" ); + place_items( "office", 80, point( 4, 19 ), point( 6, 19 ), false, 0 ); + place_items( "cleaning", 90, point( 7, 3 ), point( 7, 5 ), false, 0 ); + place_items( "toxic_dump_equipment", 85, point( 19, 1 ), point( 19, 3 ), false, 0 ); + place_items( "toxic_dump_equipment", 85, point( 19, 5 ), point( 19, 7 ), false, 0 ); + place_spawns( GROUP_HAZMATBOT, 2, point( 10, 5 ), point( 10, 5 ), 1, true ); //lazy radiation mapping for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { @@ -5556,12 +5557,12 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, " f ##!!!!!!!!x|x.r| \n" " f |!!!!!!!!!%..r| |-\n" " f |!!!!!!!!!%..r| |^\n", ter_key, fur_key ); - spawn_item( 19, 22, "cleansuit" ); - place_items( "cleaning", 85, 6, 11, 6, 14, false, 0 ); - place_items( "tools_common", 85, 10, 6, 13, 6, false, 0 ); - place_items( "toxic_dump_equipment", 85, 22, 14, 23, 15, false, 0 ); - place_spawns( GROUP_HAZMATBOT, 2, 22, 12, 22, 12, 1, true ); - place_spawns( GROUP_HAZMATBOT, 2, 23, 18, 23, 18, 1, true ); + spawn_item( point( 19, 22 ), "cleansuit" ); + place_items( "cleaning", 85, point( 6, 11 ), point( 6, 14 ), false, 0 ); + place_items( "tools_common", 85, point( 10, 6 ), point( 13, 6 ), false, 0 ); + place_items( "toxic_dump_equipment", 85, point( 22, 14 ), point( 23, 15 ), false, 0 ); + place_spawns( GROUP_HAZMATBOT, 2, point( 22, 12 ), point( 22, 12 ), 1, true ); + place_spawns( GROUP_HAZMATBOT, 2, point( 23, 18 ), point( 23, 18 ), 1, true ); //lazy radiation mapping for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { @@ -5616,10 +5617,10 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, " \n" " \n" " \n", ter_key, fur_key ); - spawn_item( 1, 2, "id_military" ); - place_items( "office", 85, 1, 1, 1, 3, false, 0 ); - place_items( "office", 85, 11, 3, 13, 3, false, 0 ); - place_items( "office", 85, 17, 3, 19, 3, false, 0 ); + spawn_item( point( 1, 2 ), "id_military" ); + place_items( "office", 85, point_south_east, point( 1, 3 ), false, 0 ); + place_items( "office", 85, point( 11, 3 ), point( 13, 3 ), false, 0 ); + place_items( "office", 85, point( 17, 3 ), point( 19, 3 ), false, 0 ); //lazy radiation mapping for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { @@ -5661,12 +5662,12 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, " f \n" "------|---|--|---www| f \n" ".x6x..|S.T|l.|^.ddd.| f \n", ter_key, fur_key ); - place_items( "office", 85, 16, 23, 18, 23, false, 0 ); - place_items( "cleaning", 85, 11, 23, 12, 23, false, 0 ); - place_items( "robots", 90, 2, 11, 3, 11, false, 0 ); + place_items( "office", 85, point( 16, 23 ), point( 18, 23 ), false, 0 ); + place_items( "cleaning", 85, point( 11, 23 ), point( 12, 23 ), false, 0 ); + place_items( "robots", 90, point( 2, 11 ), point( 3, 11 ), false, 0 ); // TODO: change to monster group - place_spawns( GROUP_HAZMATBOT, 2, 7, 10, 7, 10, 1, true ); - place_spawns( GROUP_HAZMATBOT, 2, 11, 16, 11, 16, 1, true ); + place_spawns( GROUP_HAZMATBOT, 2, point( 7, 10 ), point( 7, 10 ), 1, true ); + place_spawns( GROUP_HAZMATBOT, 2, point( 11, 16 ), point( 11, 16 ), 1, true ); //lazy radiation mapping for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { @@ -5728,10 +5729,10 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, for( int j = 0; j < SEEY * 2; j++ ) { if( this->ter( i, j ) == t_rock_floor ) { if( one_in( 250 ) ) { - add_item( i, j, item::make_corpse() ); - place_items( "science", 70, i, j, i, j, true, 0 ); + add_item( point( i, j ), item::make_corpse() ); + place_items( "science", 70, point( i, j ), point( i, j ), true, 0 ); } - place_spawns( GROUP_PLAIN, 80, i, j, i, j, 1, true ); + place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } if( this->ter( i, j ) != t_metal_floor ) { adjust_radiation( i, j, rng( 10, 70 ) ); @@ -5746,12 +5747,12 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, if( one_in( 2 ) ) { make_rubble( tripoint( i, j, abs_sub.z ), f_wreckage, true ); } - place_items( "trash", 50, i, j, i, j, false, 0 ); - place_items( "sewer", 50, i, j, i, j, false, 0 ); + place_items( "trash", 50, point( i, j ), point( i, j ), false, 0 ); + place_items( "sewer", 50, point( i, j ), point( i, j ), false, 0 ); if( one_in( 40 ) ) { - spawn_item( i, j, "nanomaterial", 1, 5 ); + spawn_item( point( i, j ), "nanomaterial", 1, 5 ); } - place_spawns( GROUP_VANILLA, 5, i, j, i, j, 1, true ); + place_spawns( GROUP_VANILLA, 5, point( i, j ), point( i, j ), 1, true ); } } } @@ -5798,14 +5799,14 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { if( this->furn( i, j ) == f_rack ) { - place_items( "mechanics", 60, i, j, i, j, false, 0 ); + place_items( "mechanics", 60, point( i, j ), point( i, j ), false, 0 ); } if( this->ter( i, j ) == t_rock_floor ) { if( one_in( 250 ) ) { - add_item( i, j, item::make_corpse() ); - place_items( "science", 70, i, j, i, j, true, 0 ); + add_item( point( i, j ), item::make_corpse() ); + place_items( "science", 70, point( i, j ), point( i, j ), true, 0 ); } else { - place_spawns( GROUP_PLAIN, 1, i, j, i, j, 1, true ); + place_spawns( GROUP_PLAIN, 1, point( i, j ), point( i, j ), 1, true ); } } if( this->ter( i, j ) != t_metal_floor ) { @@ -5821,12 +5822,12 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, if( one_in( 2 ) ) { make_rubble( tripoint( i, j, abs_sub.z ), f_wreckage, true ); } - place_items( "trash", 50, i, j, i, j, false, 0 ); - place_items( "sewer", 50, i, j, i, j, false, 0 ); + place_items( "trash", 50, point( i, j ), point( i, j ), false, 0 ); + place_items( "sewer", 50, point( i, j ), point( i, j ), false, 0 ); if( one_in( 40 ) ) { - spawn_item( i, j, "nanomaterial", 1, 5 ); + spawn_item( point( i, j ), "nanomaterial", 1, 5 ); } - place_spawns( GROUP_VANILLA, 5, i, j, i, j, 1, true ); + place_spawns( GROUP_VANILLA, 5, point( i, j ), point( i, j ), 1, true ); } } } @@ -5870,10 +5871,10 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, for( int j = 0; j < SEEY * 2; j++ ) { if( this->ter( i, j ) == t_rock_floor ) { if( one_in( 250 ) ) { - add_item( i, j, item::make_corpse() ); - place_items( "science", 70, i, j, i, j, true, 0 ); + add_item( point( i, j ), item::make_corpse() ); + place_items( "science", 70, point( i, j ), point( i, j ), true, 0 ); } - place_spawns( GROUP_PLAIN, 80, i, j, i, j, 1, true ); + place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } if( this->ter( i, j ) != t_metal_floor ) { adjust_radiation( i, j, rng( 10, 70 ) ); @@ -5888,12 +5889,12 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, if( one_in( 2 ) ) { make_rubble( tripoint( i, j, abs_sub.z ), f_wreckage, true ); } - place_items( "trash", 50, i, j, i, j, false, 0 ); - place_items( "sewer", 50, i, j, i, j, false, 0 ); + place_items( "trash", 50, point( i, j ), point( i, j ), false, 0 ); + place_items( "sewer", 50, point( i, j ), point( i, j ), false, 0 ); if( one_in( 20 ) ) { - spawn_item( i, j, "nanomaterial", 1, 5 ); + spawn_item( point( i, j ), "nanomaterial", 1, 5 ); } - place_spawns( GROUP_VANILLA, 5, i, j, i, j, 1, true ); + place_spawns( GROUP_VANILLA, 5, point( i, j ), point( i, j ), 1, true ); } } } @@ -5932,24 +5933,24 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, ",,,,,+,,,,,,+,,c6c,|####\n" ",,,,M|,,,,,,|r,,,,,|####\n" "$$$$-|-|=HH-|-HHHH-|####\n", b_ter_key, b_fur_key ); - spawn_item( 3, 16, "sarcophagus_access_code" ); + spawn_item( point( 3, 16 ), "sarcophagus_access_code" ); for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { if( this->furn( i, j ) == f_locker ) { - place_items( "cleaning", 60, i, j, i, j, false, 0 ); + place_items( "cleaning", 60, point( i, j ), point( i, j ), false, 0 ); } if( this->furn( i, j ) == f_desk ) { - place_items( "cubical_office", 60, i, j, i, j, false, 0 ); + place_items( "cubical_office", 60, point( i, j ), point( i, j ), false, 0 ); } if( this->furn( i, j ) == f_rack ) { - place_items( "sewage_plant", 60, i, j, i, j, false, 0 ); + place_items( "sewage_plant", 60, point( i, j ), point( i, j ), false, 0 ); } if( this->ter( i, j ) == t_rock_floor ) { if( one_in( 250 ) ) { - add_item( i, j, item::make_corpse() ); - place_items( "science", 70, i, j, i, j, true, 0 ); + add_item( point( i, j ), item::make_corpse() ); + place_items( "science", 70, point( i, j ), point( i, j ), true, 0 ); } - place_spawns( GROUP_PLAIN, 80, i, j, i, j, 1, true ); + place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } if( this->ter( i, j ) != t_metal_floor ) { adjust_radiation( i, j, rng( 10, 70 ) ); @@ -5964,12 +5965,12 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, if( one_in( 2 ) ) { make_rubble( tripoint( i, j, abs_sub.z ), f_wreckage, true ); } - place_items( "trash", 50, i, j, i, j, false, 0 ); - place_items( "sewer", 50, i, j, i, j, false, 0 ); + place_items( "trash", 50, point( i, j ), point( i, j ), false, 0 ); + place_items( "sewer", 50, point( i, j ), point( i, j ), false, 0 ); if( one_in( 40 ) ) { - spawn_item( i, j, "nanomaterial", 1, 5 ); + spawn_item( point( i, j ), "nanomaterial", 1, 5 ); } - place_spawns( GROUP_VANILLA, 5, i, j, i, j, 1, true ); + place_spawns( GROUP_VANILLA, 5, point( i, j ), point( i, j ), 1, true ); } } } @@ -6021,15 +6022,15 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti for( int a = 0; a < vnum; a++ ) { if( vset[a] < 12 ) { if( one_in( 2 ) ) { - place_vending( vset[a], 1, "vending_food" ); + place_vending( point( vset[a], 1 ), "vending_food" ); } else { - place_vending( vset[a], 1, "vending_drink" ); + place_vending( point( vset[a], 1 ), "vending_drink" ); } } else { if( one_in( 2 ) ) { - place_vending( vset[a] + 2, 1, "vending_food" ); + place_vending( point( vset[a] + 2, 1 ), "vending_food" ); } else { - place_vending( vset[a] + 2, 1, "vending_drink" ); + place_vending( point( vset[a] + 2, 1 ), "vending_drink" ); } } } @@ -6038,13 +6039,13 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti for( int x = 2; x <= 18; x += 4 ) { line_furn( this, f_counter, x, 4, x, 14 ); line_furn( this, f_rack, x + 3, 4, x + 3, 14 ); - place_items( "snacks", 80, x + 3, 4, x + 3, 14, false, 0 ); - place_items( "magazines", 70, x + 3, 4, x + 3, 14, false, 0 ); + place_items( "snacks", 80, point( x + 3, 4 ), point( x + 3, 14 ), false, 0 ); + place_items( "magazines", 70, point( x + 3, 4 ), point( x + 3, 14 ), false, 0 ); } if( const auto p = random_point( *this, [this]( const tripoint & n ) { return ter( n ) == t_floor; } ) ) { - place_spawns( GROUP_PLAIN, 1, p->x, p->y, p->x, p->y, 1, true ); + place_spawns( GROUP_PLAIN, 1, point( p->x, p->y ), point( p->x, p->y ), 1, true ); } // Finally, figure out where the road is; construct our entrance facing that. std::vector faces_road; @@ -6074,20 +6075,20 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti if( fridge ) { line_furn( this, f_glass_fridge, x, y, x, y + SEEY - 4 ); if( one_in( 3 ) ) { - place_items( "fridgesnacks", 80, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "fridgesnacks", 80, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } else { - place_items( "fridge", 70, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "fridge", 70, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } } else { line_furn( this, f_rack, x, y, x, y + SEEY - 4 ); if( one_in( 3 ) ) { - place_items( "cannedfood", 78, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "cannedfood", 78, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } else if( one_in( 2 ) ) { - place_items( "pasta", 82, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "pasta", 82, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } else if( one_in( 2 ) ) { - place_items( "produce", 65, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "produce", 65, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } else { - place_items( "snacks", 72, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "snacks", 72, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } } } @@ -6098,13 +6099,13 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti for( int x = 2; x <= 22; x += 4 ) { line_furn( this, f_rack, x, 4, x, SEEY * 2 - 5 ); if( one_in( 3 ) ) { - place_items( "tools_carpentry", 70, x, 4, x, SEEY * 2 - 5, false, 0 ); + place_items( "tools_carpentry", 70, point( x, 4 ), point( x, SEEY * 2 - 5 ), false, 0 ); } else if( one_in( 2 ) ) { - place_items( "tools_construction", 70, x, 4, x, SEEY * 2 - 5, false, 0 ); + place_items( "tools_construction", 70, point( x, 4 ), point( x, SEEY * 2 - 5 ), false, 0 ); } else if( one_in( 3 ) ) { - place_items( "hardware", 70, x, 4, x, SEEY * 2 - 5, false, 0 ); + place_items( "hardware", 70, point( x, 4 ), point( x, SEEY * 2 - 5 ), false, 0 ); } else { - place_items( "mischw", 70, x, 4, x, SEEY * 2 - 5, false, 0 ); + place_items( "mischw", 70, point( x, 4 ), point( x, SEEY * 2 - 5 ), false, 0 ); } } break; @@ -6113,26 +6114,26 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti for( int y = 3; y <= 9; y += 6 ) { square_furn( this, f_rack, x, y, x + 1, y + 1 ); if( one_in( 2 ) ) { - place_items( "shirts", 75, x, y, x + 1, y + 1, false, 0 ); + place_items( "shirts", 75, point( x, y ), point( x + 1, y + 1 ), false, 0 ); } else if( one_in( 2 ) ) { - place_items( "pants", 72, x, y, x + 1, y + 1, false, 0 ); + place_items( "pants", 72, point( x, y ), point( x + 1, y + 1 ), false, 0 ); } else if( one_in( 2 ) ) { - place_items( "jackets", 65, x, y, x + 1, y + 1, false, 0 ); + place_items( "jackets", 65, point( x, y ), point( x + 1, y + 1 ), false, 0 ); } else { - place_items( "winter", 62, x, y, x + 1, y + 1, false, 0 ); + place_items( "winter", 62, point( x, y ), point( x + 1, y + 1 ), false, 0 ); } } } for( int y = 13; y <= SEEY * 2 - 2; y += 3 ) { line_furn( this, f_rack, 2, y, SEEX * 2 - 3, y ); if( one_in( 3 ) ) { - place_items( "shirts", 75, 2, y, SEEX * 2 - 3, y, false, 0 ); + place_items( "shirts", 75, point( 2, y ), point( SEEX * 2 - 3, y ), false, 0 ); } else if( one_in( 2 ) ) { - place_items( "shoes", 75, 2, y, SEEX * 2 - 3, y, false, 0 ); + place_items( "shoes", 75, point( 2, y ), point( SEEX * 2 - 3, y ), false, 0 ); } else if( one_in( 2 ) ) { - place_items( "bags", 75, 2, y, SEEX * 2 - 3, y, false, 0 ); + place_items( "bags", 75, point( 2, y ), point( SEEX * 2 - 3, y ), false, 0 ); } else { - place_items( "allclothes", 75, 2, y, SEEX * 2 - 3, y, false, 0 ); + place_items( "allclothes", 75, point( 2, y ), point( SEEX * 2 - 3, y ), false, 0 ); } } break; @@ -6141,11 +6142,11 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti for( int y = 2; y <= SEEY; y += SEEY - 2 ) { line_furn( this, f_rack, x, y, x, y + SEEY - 4 ); if( one_in( 3 ) ) { - place_items( "cleaning", 78, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "cleaning", 78, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } else if( one_in( 2 ) ) { - place_items( "softdrugs", 72, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "softdrugs", 72, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } else { - place_items( "novels", 84, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "novels", 84, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } } } @@ -6155,11 +6156,11 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti for( int y = 2; y <= SEEY; y += SEEY - 2 ) { line_furn( this, f_rack, x, y, x, y + SEEY - 4 ); if( one_in( 2 ) ) { - place_items( "sports", 72, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "sports", 72, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } else if( one_in( 10 ) ) { - place_items( "guns_rifle_common", 20, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "guns_rifle_common", 20, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } else { - place_items( "camping", 68, x, y, x, y + SEEY - 4, false, 0 ); + place_items( "camping", 68, point( x, y ), point( x, y + SEEY - 4 ), false, 0 ); } } } @@ -6170,7 +6171,7 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti for( int i = 0; i < 15; i++ ) { int x = rng( 0, EAST_EDGE ), y = rng( 0, SOUTH_EDGE ); if( ter( x, y ) == t_floor ) { - place_spawns( GROUP_PLAIN, 1, x, y, x, y, 1, true ); + place_spawns( GROUP_PLAIN, 1, point( x, y ), point( x, y ), 1, true ); } } // Rotate randomly... @@ -6215,9 +6216,9 @@ void map::draw_fema( const oter_id &terrain_type, mapgendata &dat, const time_po line_furn( this, f_chair, 5, 16, 5, 18 ); line_furn( this, f_desk, 6, 16, 6, 18 ); line_furn( this, f_chair, 7, 16, 7, 18 ); - place_items( "office", 80, 3, 16, 3, 18, false, 0 ); - place_items( "office", 80, 6, 16, 6, 18, false, 0 ); - place_spawns( GROUP_MIL_WEAK, 1, 3, 15, 4, 17, 0.2 ); + place_items( "office", 80, point( 3, 16 ), point( 3, 18 ), false, 0 ); + place_items( "office", 80, point( 6, 16 ), point( 6, 18 ), false, 0 ); + place_spawns( GROUP_MIL_WEAK, 1, point( 3, 15 ), point( 4, 17 ), 0.2 ); // Rotate to face the road if( is_ot_match( "road", dat.east(), ot_match_type::type ) || @@ -6273,13 +6274,13 @@ void map::draw_fema( const oter_id &terrain_type, mapgendata &dat, const time_po line( this, t_reinforced_glass, 13, 14, 18, 14 ); line( this, t_reinforced_glass, 13, 14, 13, 18 ); ter_set( point( 15, 14 ), t_door_metal_locked ); - place_items( "dissection", 90, 10, 8, 10, 17, false, 0 ); - place_items( "hospital_lab", 70, 5, 5, 18, 18, false, 0 ); - place_items( "harddrugs", 50, 6, 5, 9, 5, false, 0 ); - place_items( "harddrugs", 50, 14, 5, 17, 5, false, 0 ); - place_items( "hospital_samples", 50, 6, 5, 9, 5, false, 0 ); - place_items( "hospital_samples", 50, 14, 5, 17, 5, false, 0 ); - place_spawns( GROUP_LAB_FEMA, 1, 11, 12, 16, 17, 0.1 ); + place_items( "dissection", 90, point( 10, 8 ), point( 10, 17 ), false, 0 ); + place_items( "hospital_lab", 70, point( 5, 5 ), point( 18, 18 ), false, 0 ); + place_items( "harddrugs", 50, point( 6, 5 ), point( 9, 5 ), false, 0 ); + place_items( "harddrugs", 50, point( 14, 5 ), point( 17, 5 ), false, 0 ); + place_items( "hospital_samples", 50, point( 6, 5 ), point( 9, 5 ), false, 0 ); + place_items( "hospital_samples", 50, point( 14, 5 ), point( 17, 5 ), false, 0 ); + place_spawns( GROUP_LAB_FEMA, 1, point( 11, 12 ), point( 16, 17 ), 0.1 ); } else if( dat.west() == "fema_entrance" ) { square( this, t_dirt, 1, 1, 22, 22 ); //Supply tent line_furn( this, f_canvas_wall, 4, 4, 19, 4 ); @@ -6314,14 +6315,14 @@ void map::draw_fema( const oter_id &terrain_type, mapgendata &dat, const time_po line( this, t_chainfence, 15, 9, 15, 14 ); line( this, t_chaingate_c, 15, 11, 15, 12 ); line_furn( this, f_locker, 18, 9, 18, 14 ); - place_items( "allclothes", 90, 5, 6, 7, 7, false, 0 ); - place_items( "softdrugs", 90, 5, 11, 7, 12, false, 0 ); - place_items( "hardware", 90, 5, 16, 7, 17, false, 0 ); + place_items( "allclothes", 90, point( 5, 6 ), point( 7, 7 ), false, 0 ); + place_items( "softdrugs", 90, point( 5, 11 ), point( 7, 12 ), false, 0 ); + place_items( "hardware", 90, point( 5, 16 ), point( 7, 17 ), false, 0 ); if( one_in( 3 ) ) { - place_items( "guns_rifle_milspec", 90, 18, 9, 18, 14, false, 0, 100, 100 ); + place_items( "guns_rifle_milspec", 90, point( 18, 9 ), point( 18, 14 ), false, 0, 100, 100 ); } - place_items( "office", 80, 10, 11, 13, 12, false, 0 ); - place_spawns( GROUP_MIL_WEAK, 1, 3, 15, 4, 17, 0.2 ); + place_items( "office", 80, point( 10, 11 ), point( 13, 12 ), false, 0 ); + place_spawns( GROUP_MIL_WEAK, 1, point( 3, 15 ), point( 4, 17 ), 0.2 ); } else { switch( rng( 1, 5 ) ) { case 1: @@ -6351,8 +6352,8 @@ void map::draw_fema( const oter_id &terrain_type, mapgendata &dat, const time_po square_furn( this, f_fema_groundsheet, 11, 5, 12, 18 ); line_furn( this, f_fema_groundsheet, 14, 5, 14, 18 ); line_furn( this, f_fema_groundsheet, 16, 5, 16, 18 ); - place_items( "livingroom", 80, 5, 5, 18, 18, false, 0 ); - place_spawns( GROUP_PLAIN, 1, 11, 12, 13, 14, 0.1 ); + place_items( "livingroom", 80, point( 5, 5 ), point( 18, 18 ), false, 0 ); + place_spawns( GROUP_PLAIN, 1, point( 11, 12 ), point( 13, 14 ), 0.1 ); break; case 4: square( this, t_dirt, 1, 1, 22, 22 ); @@ -6384,22 +6385,22 @@ void map::draw_fema( const oter_id &terrain_type, mapgendata &dat, const time_po line_furn( this, f_table, 6, 16, 10, 16 ); line_furn( this, f_bench, 6, 17, 10, 17 ); - place_items( "mil_food_nodrugs", 80, 5, 5, 5, 6, false, 0 ); - place_items( "snacks", 80, 5, 5, 18, 18, false, 0 ); - place_items( "kitchen", 70, 6, 5, 10, 8, false, 0 ); - place_items( "dining", 80, 13, 7, 17, 7, false, 0 ); - place_items( "dining", 80, 13, 12, 17, 12, false, 0 ); - place_items( "dining", 80, 13, 16, 17, 16, false, 0 ); - place_items( "dining", 80, 6, 12, 10, 12, false, 0 ); - place_items( "dining", 80, 6, 16, 10, 16, false, 0 ); - place_spawns( GROUP_PLAIN, 1, 11, 12, 13, 14, 0.1 ); + place_items( "mil_food_nodrugs", 80, point( 5, 5 ), point( 5, 6 ), false, 0 ); + place_items( "snacks", 80, point( 5, 5 ), point( 18, 18 ), false, 0 ); + place_items( "kitchen", 70, point( 6, 5 ), point( 10, 8 ), false, 0 ); + place_items( "dining", 80, point( 13, 7 ), point( 17, 7 ), false, 0 ); + place_items( "dining", 80, point( 13, 12 ), point( 17, 12 ), false, 0 ); + place_items( "dining", 80, point( 13, 16 ), point( 17, 16 ), false, 0 ); + place_items( "dining", 80, point( 6, 12 ), point( 10, 12 ), false, 0 ); + place_items( "dining", 80, point( 6, 16 ), point( 10, 16 ), false, 0 ); + place_spawns( GROUP_PLAIN, 1, point( 11, 12 ), point( 13, 14 ), 0.1 ); break; case 5: square( this, t_dirt, 1, 1, 22, 22 ); square( this, t_fence_barbed, 4, 4, 19, 19 ); square( this, t_dirt, 5, 5, 18, 18 ); square( this, t_pit_corpsed, 6, 6, 17, 17 ); - place_spawns( GROUP_PLAIN, 1, 11, 12, 13, 14, 0.5 ); + place_spawns( GROUP_PLAIN, 1, point( 11, 12 ), point( 13, 14 ), 0.5 ); break; } } @@ -6424,7 +6425,7 @@ void map::draw_spider_pit( const oter_id &terrain_type, mapgendata &/*dat*/, } } ter_set( point( rng( 3, SEEX * 2 - 4 ), rng( 3, SEEY * 2 - 4 ) ), t_slope_up ); - place_items( "spider", 85, 0, 0, EAST_EDGE, SOUTH_EDGE, false, 0 ); + place_items( "spider", 85, point_zero, point( EAST_EDGE, SOUTH_EDGE ), false, 0 ); } } @@ -6484,8 +6485,8 @@ void map::draw_slimepit( const oter_id &terrain_type, mapgendata &dat, const tim ter_set( point( SEEX * 2 - rng( 1, 3 ), SEEY * 2 - rng( 1, 3 ) ), t_slope_up ); } } - place_spawns( GROUP_BLOB, 1, SEEX, SEEY, SEEX, SEEY, 0.15 ); - place_items( "sewer", 40, 0, 0, EAST_EDGE, SOUTH_EDGE, true, 0 ); + place_spawns( GROUP_BLOB, 1, point( SEEX, SEEY ), point( SEEX, SEEY ), 0.15 ); + place_items( "sewer", 40, point_zero, point( EAST_EDGE, SOUTH_EDGE ), true, 0 ); } } @@ -6512,15 +6513,15 @@ void map::draw_triffid( const oter_id &terrain_type, mapgendata &/*dat*/, int monrng = rng( 1, 25 ); int spawnx = nodex + rng( 0, 3 ), spawny = nodey + rng( 0, 3 ); if( monrng <= 24 ) { - place_spawns( GROUP_TRIFFID_OUTER, 1, nodex, nodey, - nodex + 3, nodey + 3, 1, true ); + place_spawns( GROUP_TRIFFID_OUTER, 1, point( nodex, nodey ), + point( nodex + 3, nodey + 3 ), 1, true ); } else { for( int webx = nodex; webx <= nodex + 3; webx++ ) { for( int weby = nodey; weby <= nodey + 3; weby++ ) { add_field( {webx, weby, abs_sub.z}, fd_web, rng( 1, 3 ) ); } } - place_spawns( GROUP_SPIDER, 1, spawnx, spawny, spawnx, spawny, 1, true ); + place_spawns( GROUP_SPIDER, 1, point( spawnx, spawny ), point( spawnx, spawny ), 1, true ); } } // TODO: Non-monster hazards? @@ -6581,7 +6582,7 @@ void map::draw_triffid( const oter_id &terrain_type, mapgendata &/*dat*/, ter_set( point( x, y ), t_dirt ); if( chance >= 10 && one_in( 10 ) ) { // Add a spawn - place_spawns( GROUP_TRIFFID, 1, x, y, x, y, 1, true ); + place_spawns( GROUP_TRIFFID, 1, point( x, y ), point( x, y ), 1, true ); } if( rng( 0, 99 ) < chance ) { // Force movement down or to the right @@ -6630,7 +6631,7 @@ void map::draw_triffid( const oter_id &terrain_type, mapgendata &/*dat*/, } // Done with drunken walk } while( x < 19 || y < 19 ); square( this, t_slope_up, 1, 1, 2, 2 ); - place_spawns( GROUP_TRIFFID_HEART, 1, 21, 21, 21, 21, 1, true ); + place_spawns( GROUP_TRIFFID_HEART, 1, point( 21, 21 ), point( 21, 21 ), 1, true ); } } @@ -6827,12 +6828,12 @@ void map::place_spawns( const mongroup_id &group, const int chance, x = rng( x1, x2 ); y = rng( y1, y2 ); tries--; - } while( impassable( x, y ) && tries > 0 ); + } while( impassable( point( x, y ) ) && tries > 0 ); // Pick a monster type MonsterGroupResult spawn_details = MonsterGroupManager::GetResultFromGroup( group, &num ); - add_spawn( spawn_details.name, spawn_details.pack_size, x, y, friendly ); + add_spawn( spawn_details.name, spawn_details.pack_size, point( x, y ), friendly ); } } @@ -6844,14 +6845,14 @@ void map::place_gas_pump( int x, int y, int charges ) } else { fuel_type = "gasoline"; } - place_gas_pump( x, y, charges, fuel_type ); + place_gas_pump( point( x, y ), charges, fuel_type ); } void map::place_gas_pump( int x, int y, int charges, const std::string &fuel_type ) { item fuel( fuel_type, 0 ); fuel.charges = charges; - add_item( x, y, fuel ); + add_item( point( x, y ), fuel ); ter_set( point( x, y ), ter_id( fuel.fuel_pump_terrain() ) ); } @@ -6859,7 +6860,7 @@ void map::place_toilet( int x, int y, int charges ) { item water( "water", 0 ); water.charges = charges; - add_item( x, y, water ); + add_item( point( x, y ), water ); furn_set( point( x, y ), f_toilet ); } @@ -6867,14 +6868,14 @@ void map::place_vending( int x, int y, const std::string &type, bool reinforced { if( reinforced ) { furn_set( point( x, y ), f_vending_reinforced ); - place_items( type, 100, x, y, x, y, false, 0 ); + place_items( type, 100, point( x, y ), point( x, y ), false, 0 ); } else { const bool broken = one_in( 5 ); if( broken ) { furn_set( point( x, y ), f_vending_o ); } else { furn_set( point( x, y ), f_vending_c ); - place_items( type, 100, x, y, x, y, false, 0 ); + place_items( type, 100, point( x, y ), point( x, y ), false, 0 ); } } } @@ -6899,7 +6900,7 @@ void map::apply_faction_ownership( const int x1, const int y1, const int x2, con faction *fac = g->faction_manager_ptr->get( id ); for( const tripoint &p : points_in_rectangle( tripoint( x1, y1, abs_sub.z ), tripoint( x2, y2, abs_sub.z ) ) ) { - auto items = i_at( p.x, p.y ); + auto items = i_at( p.xy() ); for( item &elem : items ) { elem.set_owner( fac ); } @@ -6918,7 +6919,7 @@ std::vector map::place_items( const items_location &loc, const int chanc const int magazine, const int ammo ) { // TODO: implement for 3D - return place_items( loc, chance, f.x, f.y, t.x, t.y, ongrass, turn, magazine, ammo ); + return place_items( loc, chance, f.xy(), t.xy(), ongrass, turn, magazine, ammo ); } // A chance of 100 indicates that items should always spawn, @@ -7383,7 +7384,7 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) int trapy = rng( y1 + 1, y2 - 1 ); switch( random_entry( valid_rooms ) ) { case room_closet: - m->place_items( "cleaning", 80, x1, y1, x2, y2, false, 0 ); + m->place_items( "cleaning", 80, point( x1, y1 ), point( x2, y2 ), false, 0 ); break; case room_lobby: if( rotate % 2 == 0 ) { // Vertical @@ -7426,9 +7427,9 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) m->furn_set( point( x, y ), f_counter ); } if( one_in( 3 ) ) { - m->place_items( "mut_lab", 35, x, y1 + 1, x, y2 - 1, false, 0 ); + m->place_items( "mut_lab", 35, point( x, y1 + 1 ), point( x, y2 - 1 ), false, 0 ); } else { - m->place_items( "chem_lab", 70, x, y1 + 1, x, y2 - 1, false, 0 ); + m->place_items( "chem_lab", 70, point( x, y1 + 1 ), point( x, y2 - 1 ), false, 0 ); } } } @@ -7439,9 +7440,9 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) m->furn_set( point( x, y ), f_counter ); } if( one_in( 3 ) ) { - m->place_items( "mut_lab", 35, x1 + 1, y, x2 - 1, y, false, 0 ); + m->place_items( "mut_lab", 35, point( x1 + 1, y ), point( x2 - 1, y ), false, 0 ); } else { - m->place_items( "chem_lab", 70, x1 + 1, y, x2 - 1, y, false, 0 ); + m->place_items( "chem_lab", 70, point( x1 + 1, y ), point( x2 - 1, y ), false, 0 ); } } } @@ -7457,9 +7458,9 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) static_cast( ( y1 + y2 ) / 2 ) + 1 ), f_counter ); mtrap_set( m, trapx, trapy, tr_telepad ); - m->place_items( "teleport", 70, static_cast( ( x1 + x2 ) / 2 ), - static_cast( ( y1 + y2 ) / 2 ), static_cast( ( x1 + x2 ) / 2 ) + 1, - static_cast( ( y1 + y2 ) / 2 ) + 1, false, 0 ); + m->place_items( "teleport", 70, point( ( x1 + x2 ) / 2, static_cast( ( y1 + y2 ) / 2 ) ), + point( static_cast( ( x1 + x2 ) / 2 ) + 1, static_cast( ( y1 + y2 ) / 2 ) + 1 ), false, + 0 ); break; case room_goo: do { @@ -7470,19 +7471,19 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) if( rotate == 0 ) { mremove_trap( m, x1, y2 ); m->furn_set( point( x1, y2 ), f_fridge ); - m->place_items( "goo", 60, x1, y2, x1, y2, false, 0 ); + m->place_items( "goo", 60, point( x1, y2 ), point( x1, y2 ), false, 0 ); } else if( rotate == 1 ) { mremove_trap( m, x1, y1 ); m->furn_set( point( x1, y1 ), f_fridge ); - m->place_items( "goo", 60, x1, y1, x1, y1, false, 0 ); + m->place_items( "goo", 60, point( x1, y1 ), point( x1, y1 ), false, 0 ); } else if( rotate == 2 ) { mremove_trap( m, x2, y1 ); m->furn_set( point( x2, y1 ), f_fridge ); - m->place_items( "goo", 60, x2, y1, x2, y1, false, 0 ); + m->place_items( "goo", 60, point( x2, y1 ), point( x2, y1 ), false, 0 ); } else { mremove_trap( m, x2, y2 ); m->furn_set( point( x2, y2 ), f_fridge ); - m->place_items( "goo", 60, x2, y2, x2, y2, false, 0 ); + m->place_items( "goo", 60, point( x2, y2 ), point( x2, y2 ), false, 0 ); } break; case room_cloning: @@ -7490,7 +7491,7 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) for( int y = y1 + 1; y <= y2 - 1; y++ ) { if( x % 3 == 0 && y % 3 == 0 ) { m->ter_set( point( x, y ), t_vat ); - m->place_items( "cloning_vat", 20, x, y, x, y, false, 0 ); + m->place_items( "cloning_vat", 20, point( x, y ), point( x, y ), false, 0 ); } } } @@ -7500,22 +7501,22 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) for( int x = x1; x <= x2; x++ ) { m->furn_set( point( x, y2 - 1 ), f_counter ); } - m->place_items( "dissection", 80, x1, y2 - 1, x2, y2 - 1, false, 0 ); + m->place_items( "dissection", 80, point( x1, y2 - 1 ), point( x2, y2 - 1 ), false, 0 ); } else if( rotate == 1 ) { for( int y = y1; y <= y2; y++ ) { m->furn_set( point( x1 + 1, y ), f_counter ); } - m->place_items( "dissection", 80, x1 + 1, y1, x1 + 1, y2, false, 0 ); + m->place_items( "dissection", 80, point( x1 + 1, y1 ), point( x1 + 1, y2 ), false, 0 ); } else if( rotate == 2 ) { for( int x = x1; x <= x2; x++ ) { m->furn_set( point( x, y1 + 1 ), f_counter ); } - m->place_items( "dissection", 80, x1, y1 + 1, x2, y1 + 1, false, 0 ); + m->place_items( "dissection", 80, point( x1, y1 + 1 ), point( x2, y1 + 1 ), false, 0 ); } else if( rotate == 3 ) { for( int y = y1; y <= y2; y++ ) { m->furn_set( point( x2 - 1, y ), f_counter ); } - m->place_items( "dissection", 80, x2 - 1, y1, x2 - 1, y2, false, 0 ); + m->place_items( "dissection", 80, point( x2 - 1, y1 ), point( x2 - 1, y2 ), false, 0 ); } mtrap_set( m, static_cast( ( x1 + x2 ) / 2 ), static_cast( ( y1 + y2 ) / 2 ), tr_dissector ); @@ -7535,7 +7536,7 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) -=-\n", mapf::ter_bind( "- | =", t_concrete_wall, t_concrete_wall, t_reinforced_glass ), mapf::furn_bind( "c", f_counter ) ); - m->place_items( "bionics_common", 70, biox, bioy, biox, bioy, false, 0 ); + m->place_items( "bionics_common", 70, point( biox, bioy ), point( biox, bioy ), false, 0 ); m->ter_set( point( biox, bioy + 2 ), t_console ); computer *tmpcomp = m->add_computer( tripoint( biox, bioy + 2, z ), _( "Bionic access" ), 2 ); @@ -7552,7 +7553,7 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) ---\n", mapf::ter_bind( "- | =", t_concrete_wall, t_concrete_wall, t_reinforced_glass ), mapf::furn_bind( "c", f_counter ) ); - m->place_items( "bionics_common", 70, biox, bioy, biox, bioy, false, 0 ); + m->place_items( "bionics_common", 70, point( biox, bioy ), point( biox, bioy ), false, 0 ); m->ter_set( point( biox, bioy - 2 ), t_console ); computer *tmpcomp2 = m->add_computer( tripoint( biox, bioy - 2, z ), _( "Bionic access" ), 2 ); @@ -7570,7 +7571,7 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) |-|\n", mapf::ter_bind( "- | =", t_concrete_wall, t_concrete_wall, t_reinforced_glass ), mapf::furn_bind( "c", f_counter ) ); - m->place_items( "bionics_common", 70, biox, bioy, biox, bioy, false, 0 ); + m->place_items( "bionics_common", 70, point( biox, bioy ), point( biox, bioy ), false, 0 ); m->ter_set( point( biox + 2, bioy ), t_console ); computer *tmpcomp = m->add_computer( tripoint( biox + 2, bioy, z ), _( "Bionic access" ), 2 ); @@ -7587,7 +7588,7 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) |-|\n", mapf::ter_bind( "- | =", t_concrete_wall, t_concrete_wall, t_reinforced_glass ), mapf::furn_bind( "c", f_counter ) ); - m->place_items( "bionics_common", 70, biox, bioy, biox, bioy, false, 0 ); + m->place_items( "bionics_common", 70, point( biox, bioy ), point( biox, bioy ), false, 0 ); m->ter_set( point( biox - 2, bioy ), t_console ); computer *tmpcomp2 = m->add_computer( tripoint( biox - 2, bioy, z ), _( "Bionic access" ), 2 ); @@ -7601,35 +7602,35 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) if( rotate % 2 == 0 ) { for( int y = y1 + 1; y <= y2 - 1; y += 3 ) { m->furn_set( point( x1, y ), f_bed ); - m->place_items( "bed", 60, x1, y, x1, y, false, 0 ); + m->place_items( "bed", 60, point( x1, y ), point( x1, y ), false, 0 ); m->furn_set( point( x1 + 1, y ), f_bed ); - m->place_items( "bed", 60, x1 + 1, y, x1 + 1, y, false, 0 ); + m->place_items( "bed", 60, point( x1 + 1, y ), point( x1 + 1, y ), false, 0 ); m->furn_set( point( x2, y ), f_bed ); - m->place_items( "bed", 60, x2, y, x2, y, false, 0 ); + m->place_items( "bed", 60, point( x2, y ), point( x2, y ), false, 0 ); m->furn_set( point( x2 - 1, y ), f_bed ); - m->place_items( "bed", 60, x2 - 1, y, x2 - 1, y, false, 0 ); + m->place_items( "bed", 60, point( x2 - 1, y ), point( x2 - 1, y ), false, 0 ); m->furn_set( point( x1, y + 1 ), f_dresser ); m->furn_set( point( x2, y + 1 ), f_dresser ); - m->place_items( "dresser", 70, x1, y + 1, x1, y + 1, false, 0 ); - m->place_items( "dresser", 70, x2, y + 1, x2, y + 1, false, 0 ); + m->place_items( "dresser", 70, point( x1, y + 1 ), point( x1, y + 1 ), false, 0 ); + m->place_items( "dresser", 70, point( x2, y + 1 ), point( x2, y + 1 ), false, 0 ); } } else if( rotate % 2 == 1 ) { for( int x = x1 + 1; x <= x2 - 1; x += 3 ) { m->furn_set( point( x, y1 ), f_bed ); - m->place_items( "bed", 60, x, y1, x, y1, false, 0 ); + m->place_items( "bed", 60, point( x, y1 ), point( x, y1 ), false, 0 ); m->furn_set( point( x, y1 + 1 ), f_bed ); - m->place_items( "bed", 60, x, y1 + 1, x, y1 + 1, false, 0 ); + m->place_items( "bed", 60, point( x, y1 + 1 ), point( x, y1 + 1 ), false, 0 ); m->furn_set( point( x, y2 ), f_bed ); - m->place_items( "bed", 60, x, y2, x, y2, false, 0 ); + m->place_items( "bed", 60, point( x, y2 ), point( x, y2 ), false, 0 ); m->furn_set( point( x, y2 - 1 ), f_bed ); - m->place_items( "bed", 60, x, y2 - 1, x, y2 - 1, false, 0 ); + m->place_items( "bed", 60, point( x, y2 - 1 ), point( x, y2 - 1 ), false, 0 ); m->furn_set( point( x + 1, y1 ), f_dresser ); m->furn_set( point( x + 1, y2 ), f_dresser ); - m->place_items( "dresser", 70, x + 1, y1, x + 1, y1, false, 0 ); - m->place_items( "dresser", 70, x + 1, y2, x + 1, y2, false, 0 ); + m->place_items( "dresser", 70, point( x + 1, y1 ), point( x + 1, y1 ), false, 0 ); + m->place_items( "dresser", 70, point( x + 1, y2 ), point( x + 1, y2 ), false, 0 ); } } - m->place_items( "lab_dorm", 84, x1, y1, x2, y2, false, 0 ); + m->place_items( "lab_dorm", 84, point( x1, y1 ), point( x2, y2 ), false, 0 ); break; case room_split: if( rotate % 2 == 0 ) { @@ -7683,9 +7684,9 @@ void set_science_room( map *m, int x1, int y1, bool faces_right, const time_poin } } } - m->place_items( "chem_lab", 85, x1 + 1, y1, x2 - 1, y1, false, 0 ); - m->place_items( "chem_lab", 85, x1 + 1, y2, x2 - 1, y2, false, 0 ); - m->place_items( "chem_lab", 85, x1, y1 + 1, x1, y2 - 1, false, 0 ); + m->place_items( "chem_lab", 85, point( x1 + 1, y1 ), point( x2 - 1, y1 ), false, 0 ); + m->place_items( "chem_lab", 85, point( x1 + 1, y2 ), point( x2 - 1, y2 ), false, 0 ); + m->place_items( "chem_lab", 85, point( x1, y1 + 1 ), point( x1, y2 - 1 ), false, 0 ); break; case 2: // Hydroponics. @@ -7703,9 +7704,9 @@ void set_science_room( map *m, int x1, int y1, bool faces_right, const time_poin } } } - m->place_items( "chem_lab", 80, x1, y1, x1, y2, false, when - 50_turns ); - m->place_items( "hydro", 92, x1 + 1, y1 + 1, x2 - 1, y1 + 1, false, when ); - m->place_items( "hydro", 92, x1 + 1, y2 - 1, x2 - 1, y2 - 1, false, when ); + m->place_items( "chem_lab", 80, point( x1, y1 ), point( x1, y2 ), false, when - 50_turns ); + m->place_items( "hydro", 92, point( x1 + 1, y1 + 1 ), point( x2 - 1, y1 + 1 ), false, when ); + m->place_items( "hydro", 92, point( x1 + 1, y2 - 1 ), point( x2 - 1, y2 - 1 ), false, when ); break; case 3: // Electronics. @@ -7721,9 +7722,12 @@ void set_science_room( map *m, int x1, int y1, bool faces_right, const time_poin } } } - m->place_items( "electronics", 85, x1 + 1, y1, x2 - 1, y1, false, when - 50_turns ); - m->place_items( "electronics", 85, x1 + 1, y2, x2 - 1, y2, false, when - 50_turns ); - m->place_items( "electronics", 85, x1, y1 + 1, x1, y2 - 1, false, when - 50_turns ); + m->place_items( "electronics", 85, point( x1 + 1, y1 ), point( x2 - 1, y1 ), false, + when - 50_turns ); + m->place_items( "electronics", 85, point( x1 + 1, y2 ), point( x2 - 1, y2 ), false, + when - 50_turns ); + m->place_items( "electronics", 85, point( x1, y1 + 1 ), point( x1, y2 - 1 ), false, + when - 50_turns ); break; case 4: // Monster research. @@ -7744,8 +7748,8 @@ void set_science_room( map *m, int x1, int y1, bool faces_right, const time_poin } } // TODO: Place a monster in the sealed areas. - m->place_items( "monparts", 70, x1 + 3, y1, 2 - 1, y1, false, when - 100_turns ); - m->place_items( "monparts", 70, x1 + 3, y2, 2 - 1, y2, false, when - 100_turns ); + m->place_items( "monparts", 70, point( x1 + 3, y1 ), point( 2 - 1, y1 ), false, when - 100_turns ); + m->place_items( "monparts", 70, point( x1 + 3, y2 ), point( 2 - 1, y2 ), false, when - 100_turns ); break; } @@ -7755,16 +7759,16 @@ void set_science_room( map *m, int x1, int y1, bool faces_right, const time_poin for( int i = x1; i <= x2; i++ ) { for( int j = y1; j <= y2; j++ ) { rotated[i][j] = m->ter( i, j ); - auto items = m->i_at( i, j ); + auto items = m->i_at( point( i, j ) ); itrot[i][j].reserve( items.size() ); std::copy( items.begin(), items.end(), std::back_inserter( itrot[i][j] ) ); - m->i_clear( i, j ); + m->i_clear( point( i, j ) ); } } for( int i = x1; i <= x2; i++ ) { for( int j = y1; j <= y2; j++ ) { m->ter_set( point( i, j ), rotated[x2 - ( i - x1 )][j] ); - m->spawn_items( i, j, itrot[x2 - ( i - x1 )][j] ); + m->spawn_items( point( i, j ), itrot[x2 - ( i - x1 )][j] ); } } } @@ -7851,10 +7855,10 @@ void silo_rooms( map *m ) break; } if( used1 != "none" ) { - m->place_items( used1, 78, x, y, x + width, y + height, false, 0 ); + m->place_items( used1, 78, point( x, y ), point( x + width, y + height ), false, 0 ); } if( used2 != "none" ) { - m->place_items( used2, 64, x, y, x + width, y + height, false, 0 ); + m->place_items( used2, 64, point( x, y ), point( x + width, y + height ), false, 0 ); } } } while( okay ); @@ -7983,11 +7987,11 @@ void build_mine_room( map *m, room_type type, int x1, int y1, int x2, int y2, ma line( m, t_window, midx - 1, y2, midx + 1, y2 ); line( m, t_window, x1, midy - 1, x1, midy + 1 ); line( m, t_window, x2, midy - 1, x2, midy + 1 ); - m->place_items( "office", 80, x1 + 1, y1 + 1, x2 - 1, y2 - 1, false, 0 ); + m->place_items( "office", 80, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 1 ), false, 0 ); break; case room_mine_storage: - m->place_items( "mine_storage", 85, x1 + 2, y1 + 2, x2 - 2, y2 - 2, false, 0 ); + m->place_items( "mine_storage", 85, point( x1 + 2, y1 + 2 ), point( x2 - 2, y2 - 2 ), false, 0 ); break; case room_mine_fuel: { @@ -7995,12 +7999,12 @@ void build_mine_room( map *m, room_type type, int x1, int y1, int x2, int y2, ma if( door_side == NORTH || door_side == SOUTH ) { int y = ( door_side == NORTH ? y1 + 2 : y2 - 2 ); for( int x = x1 + 1; x <= x2 - 1; x += spacing ) { - m->place_gas_pump( x, y, rng( 10000, 50000 ) ); + m->place_gas_pump( point( x, y ), rng( 10000, 50000 ) ); } } else { int x = ( door_side == EAST ? x2 - 2 : x1 + 2 ); for( int y = y1 + 1; y <= y2 - 1; y += spacing ) { - m->place_gas_pump( x, y, rng( 10000, 50000 ) ); + m->place_gas_pump( point( x, y ), rng( 10000, 50000 ) ); } } } @@ -8011,38 +8015,38 @@ void build_mine_room( map *m, room_type type, int x1, int y1, int x2, int y2, ma for( int y = y1 + 2; y <= y2 - 2; y += 2 ) { m->ter_set( point( x1, y ), t_window ); m->furn_set( point( x1 + 1, y ), f_bed ); - m->place_items( "bed", 60, x1 + 1, y, x1 + 1, y, false, 0 ); + m->place_items( "bed", 60, point( x1 + 1, y ), point( x1 + 1, y ), false, 0 ); m->furn_set( point( x1 + 2, y ), f_bed ); - m->place_items( "bed", 60, x1 + 2, y, x1 + 2, y, false, 0 ); + m->place_items( "bed", 60, point( x1 + 2, y ), point( x1 + 2, y ), false, 0 ); m->ter_set( point( x2, y ), t_window ); m->furn_set( point( x2 - 1, y ), f_bed ); - m->place_items( "bed", 60, x2 - 1, y, x2 - 1, y, false, 0 ); + m->place_items( "bed", 60, point( x2 - 1, y ), point( x2 - 1, y ), false, 0 ); m->furn_set( point( x2 - 2, y ), f_bed ); - m->place_items( "bed", 60, x2 - 2, y, x2 - 2, y, false, 0 ); + m->place_items( "bed", 60, point( x2 - 2, y ), point( x2 - 2, y ), false, 0 ); m->furn_set( point( x1 + 1, y + 1 ), f_dresser ); - m->place_items( "dresser", 78, x1 + 1, y + 1, x1 + 1, y + 1, false, 0 ); + m->place_items( "dresser", 78, point( x1 + 1, y + 1 ), point( x1 + 1, y + 1 ), false, 0 ); m->furn_set( point( x2 - 1, y + 1 ), f_dresser ); - m->place_items( "dresser", 78, x2 - 1, y + 1, x2 - 1, y + 1, false, 0 ); + m->place_items( "dresser", 78, point( x2 - 1, y + 1 ), point( x2 - 1, y + 1 ), false, 0 ); } } else { for( int x = x1 + 2; x <= x2 - 2; x += 2 ) { m->ter_set( point( x, y1 ), t_window ); m->furn_set( point( x, y1 + 1 ), f_bed ); - m->place_items( "bed", 60, x, y1 + 1, x, y1 + 1, false, 0 ); + m->place_items( "bed", 60, point( x, y1 + 1 ), point( x, y1 + 1 ), false, 0 ); m->furn_set( point( x, y1 + 2 ), f_bed ); - m->place_items( "bed", 60, x, y1 + 2, x, y1 + 2, false, 0 ); + m->place_items( "bed", 60, point( x, y1 + 2 ), point( x, y1 + 2 ), false, 0 ); m->ter_set( point( x, y2 ), t_window ); m->furn_set( point( x, y2 - 1 ), f_bed ); - m->place_items( "bed", 60, x, y2 - 1, x, y2 - 1, false, 0 ); + m->place_items( "bed", 60, point( x, y2 - 1 ), point( x, y2 - 1 ), false, 0 ); m->furn_set( point( x, y2 - 2 ), f_bed ); - m->place_items( "bed", 60, x, y2 - 2, x, y2 - 2, false, 0 ); + m->place_items( "bed", 60, point( x, y2 - 2 ), point( x, y2 - 2 ), false, 0 ); m->furn_set( point( x + 1, y1 + 1 ), f_dresser ); - m->place_items( "dresser", 78, x + 1, y1 + 1, x + 1, y1 + 1, false, 0 ); + m->place_items( "dresser", 78, point( x + 1, y1 + 1 ), point( x + 1, y1 + 1 ), false, 0 ); m->furn_set( point( x + 1, y2 - 1 ), f_dresser ); - m->place_items( "dresser", 78, x + 1, y2 - 1, x + 1, y2 - 1, false, 0 ); + m->place_items( "dresser", 78, point( x + 1, y2 - 1 ), point( x + 1, y2 - 1 ), false, 0 ); } } - m->place_items( "bedroom", 65, x1 + 1, y1 + 1, x2 - 1, y2 - 1, false, 0 ); + m->place_items( "bedroom", 65, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 1 ), false, 0 ); break; default: //Suppress warnings @@ -8098,7 +8102,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo if( furn( i, j ) == f_rubble ) { add_field( {i, j, abs_sub.z}, fd_push_items, 1 ); if( one_in( 3 ) ) { - spawn_item( i, j, "rock" ); + spawn_item( point( i, j ), "rock" ); } } } @@ -8200,13 +8204,13 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo break; case ARTPROP_FRACTAL: - create_anomaly( cx - 4, cy - 4, + create_anomaly( point( cx - 4, cy - 4 ), static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); - create_anomaly( cx + 4, cy - 4, + create_anomaly( point( cx + 4, cy - 4 ), static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); - create_anomaly( cx - 4, cy + 4, + create_anomaly( point( cx - 4, cy + 4 ), static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); - create_anomaly( cx + 4, cy - 4, + create_anomaly( point( cx + 4, cy - 4 ), static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); break; default: @@ -8217,11 +8221,11 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo void line( map *m, const ter_id type, int x1, int y1, int x2, int y2 ) { - m->draw_line_ter( type, x1, y1, x2, y2 ); + m->draw_line_ter( type, point( x1, y1 ), point( x2, y2 ) ); } void line_furn( map *m, furn_id type, int x1, int y1, int x2, int y2 ) { - m->draw_line_furn( type, x1, y1, x2, y2 ); + m->draw_line_furn( type, point( x1, y1 ), point( x2, y2 ) ); } void fill_background( map *m, ter_id type ) { @@ -8233,27 +8237,27 @@ void fill_background( map *m, ter_id( *f )() ) } void square( map *m, ter_id type, int x1, int y1, int x2, int y2 ) { - m->draw_square_ter( type, x1, y1, x2, y2 ); + m->draw_square_ter( type, point( x1, y1 ), point( x2, y2 ) ); } void square_furn( map *m, furn_id type, int x1, int y1, int x2, int y2 ) { - m->draw_square_furn( type, x1, y1, x2, y2 ); + m->draw_square_furn( type, point( x1, y1 ), point( x2, y2 ) ); } void square( map *m, ter_id( *f )(), int x1, int y1, int x2, int y2 ) { - m->draw_square_ter( f, x1, y1, x2, y2 ); + m->draw_square_ter( f, point( x1, y1 ), point( x2, y2 ) ); } void square( map *m, const weighted_int_list &f, int x1, int y1, int x2, int y2 ) { - m->draw_square_ter( f, x1, y1, x2, y2 ); + m->draw_square_ter( f, point( x1, y1 ), point( x2, y2 ) ); } void rough_circle( map *m, ter_id type, int x, int y, int rad ) { - m->draw_rough_circle_ter( type, x, y, rad ); + m->draw_rough_circle_ter( type, point( x, y ), rad ); } void rough_circle_furn( map *m, furn_id type, int x, int y, int rad ) { - m->draw_rough_circle_furn( type, x, y, rad ); + m->draw_rough_circle_furn( type, point( x, y ), rad ); } void circle( map *m, ter_id type, double x, double y, double rad ) { @@ -8261,11 +8265,11 @@ void circle( map *m, ter_id type, double x, double y, double rad ) } void circle( map *m, ter_id type, int x, int y, int rad ) { - m->draw_circle_ter( type, x, y, rad ); + m->draw_circle_ter( type, point( x, y ), rad ); } void circle_furn( map *m, furn_id type, int x, int y, int rad ) { - m->draw_circle_furn( type, x, y, rad ); + m->draw_circle_furn( type, point( x, y ), rad ); } void add_corpse( map *m, int x, int y ) { diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 35a770eb7123d..4820e8d3b732b 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -273,7 +273,7 @@ ter_id clay_or_sand() void mapgendata::square_groundcover( const int x1, const int y1, const int x2, const int y2 ) { - m.draw_square_ter( this->default_groundcover, x1, y1, x2, y2 ); + m.draw_square_ter( this->default_groundcover, point( x1, y1 ), point( x2, y2 ) ); } void mapgendata::fill_groundcover() { @@ -369,7 +369,7 @@ void mapgen_crater( map *m, oter_id, mapgendata dat, const time_point &turn, flo } } } - m->place_items( "wreckage", 83, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "wreckage", 83, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); } // TODO: make void map::ter_or_furn_set(const int x, const int y, const ter_furn_id & tfid); @@ -413,7 +413,7 @@ void mapgen_field( map *m, oter_id, mapgendata dat, const time_point &turn, floa } } - m->place_items( "field", 60, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, + m->place_items( "field", 60, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); // FIXME: take 'rock' out and add as regional biome setting } @@ -449,8 +449,8 @@ void mapgen_hive( map *m, oter_id, mapgendata dat, const time_point &turn, float m->ter_set( point( i + k, j + l ), t_floor_wax ); } } - m->add_spawn( mon_bee, 2, i, j ); - m->add_spawn( mon_beekeeper, 1, i, j ); + m->add_spawn( mon_bee, 2, point( i, j ) ); + m->add_spawn( mon_beekeeper, 1, point( i, j ) ); m->ter_set( point( i, j - 3 ), t_floor_wax ); m->ter_set( point( i, j + 3 ), t_floor_wax ); m->ter_set( point( i - 1, j - 2 ), t_floor_wax ); @@ -563,16 +563,16 @@ void mapgen_hive( map *m, oter_id, mapgendata dat, const time_point &turn, float } if( is_center ) { - m->place_items( "hive_center", 90, i - 2, j - 2, i + 2, j + 2, false, turn ); + m->place_items( "hive_center", 90, point( i - 2, j - 2 ), point( i + 2, j + 2 ), false, turn ); } else { - m->place_items( "hive", 80, i - 2, j - 2, i + 2, j + 2, false, turn ); + m->place_items( "hive", 80, point( i - 2, j - 2 ), point( i + 2, j + 2 ), false, turn ); } } } } if( is_center ) { - m->place_npc( SEEX, SEEY, string_id( "apis" ) ); + m->place_npc( point( SEEX, SEEY ), string_id( "apis" ) ); } } @@ -622,7 +622,7 @@ void mapgen_spider_pit( map *m, oter_id, mapgendata dat, const time_point &turn, } } } - m->place_items( "forest", 60, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "forest", 60, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); // Next, place webs and sinkholes for( int i = 0; i < 4; i++ ) { int x = rng( 3, SEEX * 2 - 4 ), y = rng( 3, SEEY * 2 - 4 ); @@ -667,7 +667,7 @@ void mapgen_fungal_bloom( map *m, oter_id, mapgendata dat, const time_point &, f } } square( m, t_fungus, SEEX - 2, SEEY - 2, SEEX + 2, SEEY + 2 ); - m->add_spawn( mon_fungaloid_queen, 1, 12, 12 ); + m->add_spawn( mon_fungaloid_queen, 1, point( 12, 12 ) ); } void mapgen_fungal_tower( map *m, oter_id, mapgendata dat, const time_point &, float ) @@ -690,7 +690,7 @@ void mapgen_fungal_tower( map *m, oter_id, mapgendata dat, const time_point &, f } } square( m, t_fungus, SEEX - 2, SEEY - 2, SEEX + 2, SEEY + 2 ); - m->add_spawn( mon_fungaloid_tower, 1, 12, 12 ); + m->add_spawn( mon_fungaloid_tower, 1, point( 12, 12 ) ); } void mapgen_fungal_flowers( map *m, oter_id, mapgendata dat, const time_point &, float ) @@ -719,7 +719,7 @@ void mapgen_fungal_flowers( map *m, oter_id, mapgendata dat, const time_point &, } } square( m, t_fungus, SEEX - 2, SEEY - 2, SEEX + 2, SEEY + 2 ); - m->add_spawn( mon_fungaloid_seeder, 1, 12, 12 ); + m->add_spawn( mon_fungaloid_seeder, 1, point( 12, 12 ) ); } int terrain_type_to_nesw_array( oter_id terrain_type, bool array[4] ) @@ -1076,16 +1076,18 @@ void mapgen_road( map *m, oter_id terrain_type, mapgendata dat, const time_point // spawn some monsters if( neighbor_sidewalks ) { - m->place_spawns( mongroup_id( "GROUP_ZOMBIE" ), 2, 0, 0, SEEX * 2 - 1, SEEX * 2 - 1, density ); + m->place_spawns( mongroup_id( "GROUP_ZOMBIE" ), 2, point_zero, point( SEEX * 2 - 1, SEEX * 2 - 1 ), + density ); // 1 per 10 overmaps if( one_in( 10000 ) ) { - m->add_spawn( mon_zombie_jackson, 1, SEEX, SEEY ); + m->add_spawn( mon_zombie_jackson, 1, point( SEEX, SEEY ) ); } } // add some items bool plaza = ( plaza_dir > -1 ); - m->place_items( plaza ? "trash" : "road", 5, 0, 0, SEEX * 2 - 1, SEEX * 2 - 1, plaza, turn ); + m->place_items( plaza ? "trash" : "road", 5, point_zero, point( SEEX * 2 - 1, SEEX * 2 - 1 ), plaza, + turn ); // add a manhole if appropriate if( terrain_type == "road_nesw_manhole" ) { @@ -1449,7 +1451,7 @@ void mapgen_sewer_straight( map *m, oter_id terrain_type, mapgendata dat, const } } } - m->place_items( "sewer", 10, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "sewer", 10, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); if( terrain_type == "sewer_ew" ) { m->rotate( 1 ); } @@ -1468,7 +1470,7 @@ void mapgen_sewer_curved( map *m, oter_id terrain_type, mapgendata dat, const ti } } } - m->place_items( "sewer", 18, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "sewer", 18, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); if( terrain_type == "sewer_es" ) { m->rotate( 1 ); } @@ -1492,7 +1494,7 @@ void mapgen_sewer_tee( map *m, oter_id terrain_type, mapgendata dat, const time_ } } } - m->place_items( "sewer", 23, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "sewer", 23, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); if( terrain_type == "sewer_esw" ) { m->rotate( 1 ); } @@ -1526,7 +1528,7 @@ void mapgen_sewer_four_way( map *m, oter_id, mapgendata dat, const time_point &t } } } - m->place_items( "sewer", 28, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "sewer", 28, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); } /////////////////// @@ -1564,7 +1566,7 @@ void mapgen_bridge( map *m, oter_id terrain_type, mapgendata dat, const time_poi VehicleSpawn::apply( vspawn_id( "default_bridge" ), *m, "bridge" ); m->rotate( static_cast( terrain_type->get_dir() ) ); - m->place_items( "road", 5, 0, 0, SEEX * 2 - 1, SEEX * 2 - 1, false, turn ); + m->place_items( "road", 5, point_zero, point( SEEX * 2 - 1, SEEX * 2 - 1 ), false, turn ); } void mapgen_highway( map *m, oter_id terrain_type, mapgendata dat, const time_point &turn, float ) @@ -1591,7 +1593,7 @@ void mapgen_highway( map *m, oter_id terrain_type, mapgendata dat, const time_po if( terrain_type == "hiway_ew" ) { m->rotate( 1 ); } - m->place_items( "road", 8, 0, 0, SEEX * 2 - 1, SEEX * 2 - 1, false, turn ); + m->place_items( "road", 8, point_zero, point( SEEX * 2 - 1, SEEX * 2 - 1 ), false, turn ); } // mapgen_railroad @@ -2045,7 +2047,7 @@ void mapgen_parking_lot( map *m, oter_id, mapgendata dat, const time_point &turn VehicleSpawn::apply( vspawn_id( "default_parkinglot" ), *m, "parkinglot" ); - m->place_items( "road", 8, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, false, turn ); + m->place_items( "road", 8, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), false, turn ); for( int i = 1; i < 4; i++ ) { const std::string &id = dat.t_nesw[i].id().str(); if( id.size() > 5 && id.find( "road_" ) == 0 ) { @@ -2195,8 +2197,8 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend case room_kitchen: { placed = "kitchen"; chance = 75; - m->place_items( "cleaning", 58, x1 + 1, y1 + 1, x2 - 1, y2 - 2, false, turn ); - m->place_items( "home_hw", 40, x1 + 1, y1 + 1, x2 - 1, y2 - 2, false, turn ); + m->place_items( "cleaning", 58, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 2 ), false, turn ); + m->place_items( "home_hw", 40, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 2 ), false, turn ); int oven_x = -1; int oven_y = -1; int cupboard_x = -1; @@ -2205,7 +2207,7 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend switch( rng( 1, 4 ) ) { //fridge, sink, oven and some cupboards near them case 1: m->furn_set( point( x1 + 2, y1 + 1 ), f_fridge ); - m->place_items( "fridge", 82, x1 + 2, y1 + 1, x1 + 2, y1 + 1, false, turn ); + m->place_items( "fridge", 82, point( x1 + 2, y1 + 1 ), point( x1 + 2, y1 + 1 ), false, turn ); m->furn_set( point( x1 + 1, y1 + 1 ), f_sink ); if( x1 + 4 < x2 ) { oven_x = x1 + 3; @@ -2216,7 +2218,7 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend break; case 2: m->furn_set( point( x2 - 2, y1 + 1 ), f_fridge ); - m->place_items( "fridge", 82, x2 - 2, y1 + 1, x2 - 2, y1 + 1, false, turn ); + m->place_items( "fridge", 82, point( x2 - 2, y1 + 1 ), point( x2 - 2, y1 + 1 ), false, turn ); m->furn_set( point( x2 - 1, y1 + 1 ), f_sink ); if( x2 - 4 > x1 ) { oven_x = x2 - 3; @@ -2226,7 +2228,7 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend break; case 3: m->furn_set( point( x1 + 2, y2 - 1 ), f_fridge ); - m->place_items( "fridge", 82, x1 + 2, y2 - 1, x1 + 2, y2 - 1, false, turn ); + m->place_items( "fridge", 82, point( x1 + 2, y2 - 1 ), point( x1 + 2, y2 - 1 ), false, turn ); m->furn_set( point( x1 + 1, y2 - 1 ), f_sink ); if( x1 + 4 < x2 ) { oven_x = x1 + 3; @@ -2236,7 +2238,7 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend break; case 4: m->furn_set( point( x2 - 2, y2 - 1 ), f_fridge ); - m->place_items( "fridge", 82, x2 - 2, y2 - 1, x2 - 2, y2 - 1, false, turn ); + m->place_items( "fridge", 82, point( x2 - 2, y2 - 1 ), point( x2 - 2, y2 - 1 ), false, turn ); m->furn_set( point( x2 - 1, y2 - 1 ), f_sink ); if( x2 - 4 > x1 ) { oven_x = x2 - 3; @@ -2249,16 +2251,20 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend // oven and it's contents if( oven_x != -1 && oven_y != -1 ) { m->furn_set( point( oven_x, oven_y ), f_oven ); - m->place_items( "oven", 70, oven_x, oven_y, oven_x, oven_y, false, turn ); + m->place_items( "oven", 70, point( oven_x, oven_y ), point( oven_x, oven_y ), false, turn ); } // cupboard and it's contents if( cupboard_x != -1 && cupboard_y != -1 ) { m->furn_set( point( cupboard_x, cupboard_y ), f_cupboard ); - m->place_items( "cleaning", 30, cupboard_x, cupboard_y, cupboard_x, cupboard_y, false, turn ); - m->place_items( "home_hw", 30, cupboard_x, cupboard_y, cupboard_x, cupboard_y, false, turn ); - m->place_items( "cannedfood", 30, cupboard_x, cupboard_y, cupboard_x, cupboard_y, false, turn ); - m->place_items( "pasta", 30, cupboard_x, cupboard_y, cupboard_x, cupboard_y, false, turn ); + m->place_items( "cleaning", 30, point( cupboard_x, cupboard_y ), point( cupboard_x, cupboard_y ), + false, turn ); + m->place_items( "home_hw", 30, point( cupboard_x, cupboard_y ), point( cupboard_x, cupboard_y ), + false, turn ); + m->place_items( "cannedfood", 30, point( cupboard_x, cupboard_y ), point( cupboard_x, cupboard_y ), + false, turn ); + m->place_items( "pasta", 30, point( cupboard_x, cupboard_y ), point( cupboard_x, cupboard_y ), + false, turn ); } if( one_in( 2 ) ) { //dining table in the kitchen @@ -2266,9 +2272,9 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend static_cast( ( y1 + y2 ) / 2 ) - 1, static_cast( ( x1 + x2 ) / 2 ), static_cast( ( y1 + y2 ) / 2 ) ); - m->place_items( "dining", 20, static_cast( ( x1 + x2 ) / 2 ) - 1, - static_cast( ( y1 + y2 ) / 2 ) - 1, - static_cast( ( x1 + x2 ) / 2 ), static_cast( ( y1 + y2 ) / 2 ), false, turn ); + m->place_items( "dining", 20, point( static_cast( ( x1 + x2 ) / 2 ) - 1, + static_cast( ( y1 + y2 ) / 2 ) - 1 ), + point( ( x1 + x2 ) / 2, static_cast( ( y1 + y2 ) / 2 ) ), false, turn ); } if( one_in( 2 ) ) { for( int i = 0; i <= 2; i++ ) { @@ -2288,80 +2294,80 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend placed = "bedroom"; chance = 78; if( one_in( 14 ) ) { - m->place_items( "homeguns", 58, x1 + 1, y1 + 1, x2 - 1, y2 - 1, false, turn ); + m->place_items( "homeguns", 58, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 1 ), false, turn ); } if( one_in( 10 ) ) { - m->place_items( "home_hw", 40, x1 + 1, y1 + 1, x2 - 1, y2 - 1, false, turn ); + m->place_items( "home_hw", 40, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 1 ), false, turn ); } switch( rng( 1, 5 ) ) { case 1: m->furn_set( point( x1 + 1, y1 + 2 ), f_bed ); m->furn_set( point( x1 + 1, y1 + 3 ), f_bed ); - m->place_items( "bed", 60, x1 + 1, y1 + 2, x1 + 1, y1 + 2, false, turn ); - m->place_items( "bed", 60, x1 + 1, y1 + 3, x1 + 1, y1 + 3, false, turn ); + m->place_items( "bed", 60, point( x1 + 1, y1 + 2 ), point( x1 + 1, y1 + 2 ), false, turn ); + m->place_items( "bed", 60, point( x1 + 1, y1 + 3 ), point( x1 + 1, y1 + 3 ), false, turn ); break; case 2: m->furn_set( point( x1 + 2, y2 - 1 ), f_bed ); m->furn_set( point( x1 + 3, y2 - 1 ), f_bed ); - m->place_items( "bed", 60, x1 + 2, y2 - 1, x1 + 2, y2 - 1, false, turn ); - m->place_items( "bed", 60, x1 + 2, y2 - 1, x1 + 2, y2 - 1, false, turn ); + m->place_items( "bed", 60, point( x1 + 2, y2 - 1 ), point( x1 + 2, y2 - 1 ), false, turn ); + m->place_items( "bed", 60, point( x1 + 2, y2 - 1 ), point( x1 + 2, y2 - 1 ), false, turn ); break; case 3: m->furn_set( point( x2 - 1, y2 - 3 ), f_bed ); m->furn_set( point( x2 - 1, y2 - 2 ), f_bed ); - m->place_items( "bed", 60, x2 - 1, y2 - 3, x2 - 1, y2 - 3, false, turn ); - m->place_items( "bed", 60, x2 - 1, y2 - 2, x2 - 1, y2 - 2, false, turn ); + m->place_items( "bed", 60, point( x2 - 1, y2 - 3 ), point( x2 - 1, y2 - 3 ), false, turn ); + m->place_items( "bed", 60, point( x2 - 1, y2 - 2 ), point( x2 - 1, y2 - 2 ), false, turn ); break; case 4: m->furn_set( point( x2 - 3, y1 + 1 ), f_bed ); m->furn_set( point( x2 - 2, y1 + 1 ), f_bed ); - m->place_items( "bed", 60, x2 - 3, y1 + 1, x2 - 3, y1 + 1, false, turn ); - m->place_items( "bed", 60, x2 - 2, y1 + 1, x2 - 2, y1 + 1, false, turn ); + m->place_items( "bed", 60, point( x2 - 3, y1 + 1 ), point( x2 - 3, y1 + 1 ), false, turn ); + m->place_items( "bed", 60, point( x2 - 2, y1 + 1 ), point( x2 - 2, y1 + 1 ), false, turn ); break; case 5: m->furn_set( point( ( x1 + x2 ) / 2, y2 - 1 ), f_bed ); m->furn_set( point( static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 1 ), f_bed ); m->furn_set( point( ( x1 + x2 ) / 2, y2 - 2 ), f_bed ); m->furn_set( point( static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 2 ), f_bed ); - m->place_items( "bed", 60, static_cast( ( x1 + x2 ) / 2 ), y2 - 1, - static_cast( ( x1 + x2 ) / 2 ), y2 - 1, false, + m->place_items( "bed", 60, point( ( x1 + x2 ) / 2, y2 - 1 ), + point( ( x1 + x2 ) / 2, y2 - 1 ), false, turn ); - m->place_items( "bed", 60, static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 1, - static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 1, + m->place_items( "bed", 60, point( static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 1 ), + point( static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 1 ), false, turn ); - m->place_items( "bed", 60, static_cast( ( x1 + x2 ) / 2 ), y2 - 2, - static_cast( ( x1 + x2 ) / 2 ), y2 - 2, false, + m->place_items( "bed", 60, point( ( x1 + x2 ) / 2, y2 - 2 ), + point( ( x1 + x2 ) / 2, y2 - 2 ), false, turn ); - m->place_items( "bed", 60, static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 2, - static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 2, + m->place_items( "bed", 60, point( static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 2 ), + point( static_cast( ( x1 + x2 ) / 2 ) + 1, y2 - 2 ), false, turn ); break; } switch( rng( 1, 4 ) ) { case 1: m->furn_set( point( x1 + 2, y1 + 1 ), f_dresser ); - m->place_items( "dresser", 80, x1 + 2, y1 + 1, x1 + 2, y1 + 1, false, turn ); + m->place_items( "dresser", 80, point( x1 + 2, y1 + 1 ), point( x1 + 2, y1 + 1 ), false, turn ); break; case 2: m->furn_set( point( x2 - 2, y2 - 1 ), f_dresser ); - m->place_items( "dresser", 80, x2 - 2, y2 - 1, x2 - 2, y2 - 1, false, turn ); + m->place_items( "dresser", 80, point( x2 - 2, y2 - 1 ), point( x2 - 2, y2 - 1 ), false, turn ); break; case 3: rn = static_cast( ( x1 + x2 ) / 2 ); m->furn_set( point( rn, y1 + 1 ), f_dresser ); - m->place_items( "dresser", 80, rn, y1 + 1, rn, y1 + 1, false, turn ); + m->place_items( "dresser", 80, point( rn, y1 + 1 ), point( rn, y1 + 1 ), false, turn ); break; case 4: rn = static_cast( ( y1 + y2 ) / 2 ); m->furn_set( point( x1 + 1, rn ), f_dresser ); - m->place_items( "dresser", 80, x1 + 1, rn, x1 + 1, rn, false, turn ); + m->place_items( "dresser", 80, point( x1 + 1, rn ), point( x1 + 1, rn ), false, turn ); break; } break; case room_bathroom: - m->place_toilet( x2 - 1, y2 - 1 ); - m->place_items( "harddrugs", 18, x1 + 1, y1 + 1, x2 - 1, y2 - 2, false, turn ); - m->place_items( "cleaning", 48, x1 + 1, y1 + 1, x2 - 1, y2 - 2, false, turn ); + m->place_toilet( point( x2 - 1, y2 - 1 ) ); + m->place_items( "harddrugs", 18, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 2 ), false, turn ); + m->place_items( "cleaning", 48, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 2 ), false, turn ); placed = "softdrugs"; chance = 72; m->furn_set( point( x2 - 1, y2 - 2 ), f_bathtub ); @@ -2388,7 +2394,7 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend default: break; } - m->place_items( placed, chance, x1 + 1, y1 + 1, x2 - 1, y2 - 1, false, turn ); + m->place_items( placed, chance, point( x1 + 1, y1 + 1 ), point( x2 - 1, y2 - 1 ), false, turn ); } void mapgen_generic_house_boxy( map *m, oter_id terrain_type, mapgendata dat, @@ -2707,10 +2713,10 @@ void mapgen_generic_house( map *m, oter_id terrain_type, mapgendata dat, const t m->furn_set( point( lw + 1, cw + 2 ), f_table ); m->ter_set( point( lw + 1, cw + 3 ), t_console_broken ); m->furn_set( point( lw + 3, bw - 1 ), f_bookcase ); - m->place_items( "magazines", 30, lw + 3, bw - 1, lw + 3, bw - 1, false, turn ); - m->place_items( "novels", 40, lw + 3, bw - 1, lw + 3, bw - 1, false, turn ); - m->place_items( "alcohol", 20, lw + 3, bw - 1, lw + 3, bw - 1, false, turn ); - m->place_items( "manuals", 30, lw + 3, bw - 1, lw + 3, bw - 1, false, turn ); + m->place_items( "magazines", 30, point( lw + 3, bw - 1 ), point( lw + 3, bw - 1 ), false, turn ); + m->place_items( "novels", 40, point( lw + 3, bw - 1 ), point( lw + 3, bw - 1 ), false, turn ); + m->place_items( "alcohol", 20, point( lw + 3, bw - 1 ), point( lw + 3, bw - 1 ), false, turn ); + m->place_items( "manuals", 30, point( lw + 3, bw - 1 ), point( lw + 3, bw - 1 ), false, turn ); //========================= m->ter_set( point( rng( lw + 2, mw - 3 ), cw ), t_door_c ); if( one_in( 4 ) ) { @@ -2739,10 +2745,10 @@ void mapgen_generic_house( map *m, oter_id terrain_type, mapgendata dat, const t m->furn_set( point( rw - 1, cw + 2 ), f_table ); m->ter_set( point( rw - 1, cw + 3 ), t_console_broken ); m->furn_set( point( rw - 3, bw - 1 ), f_bookcase ); - m->place_items( "magazines", 40, rw - 3, bw - 1, rw - 3, bw - 1, false, turn ); - m->place_items( "novels", 40, rw - 3, bw - 1, rw - 3, bw - 1, false, turn ); - m->place_items( "alcohol", 20, rw - 3, bw - 1, rw - 3, bw - 1, false, turn ); - m->place_items( "manuals", 20, rw - 3, bw - 1, rw - 3, bw - 1, false, turn ); + m->place_items( "magazines", 40, point( rw - 3, bw - 1 ), point( rw - 3, bw - 1 ), false, turn ); + m->place_items( "novels", 40, point( rw - 3, bw - 1 ), point( rw - 3, bw - 1 ), false, turn ); + m->place_items( "alcohol", 20, point( rw - 3, bw - 1 ), point( rw - 3, bw - 1 ), false, turn ); + m->place_items( "manuals", 20, point( rw - 3, bw - 1 ), point( rw - 3, bw - 1 ), false, turn ); //========================= if( one_in( 4 ) ) { @@ -2786,7 +2792,8 @@ void mapgen_generic_house( map *m, oter_id terrain_type, mapgendata dat, const t place_stairs( m, terrain_type, dat ); // Just boring old zombies - m->place_spawns( mongroup_id( "GROUP_ZOMBIE" ), 2, 0, 0, SEEX * 2 - 1, SEEX * 2 - 1, density ); + m->place_spawns( mongroup_id( "GROUP_ZOMBIE" ), 2, point_zero, point( SEEX * 2 - 1, SEEX * 2 - 1 ), + density ); m->rotate( static_cast( terrain_type->get_dir() ) ); } @@ -2871,41 +2878,41 @@ void mapgen_basement_junk( map *m, oter_id terrain_type, mapgendata dat, const t if( one_in( 1600 ) ) { m->furn_set( p, furn_str_id( "f_gun_safe_el" ) ); - m->place_items( "basement_op_guns", 96, p.x, p.y, p.x, p.y, false, turn ); - m->place_items( "ammo", 90, p.x, p.y, p.x, p.y, false, turn ); + m->place_items( "basement_op_guns", 96, p.xy(), p.xy(), false, turn ); + m->place_items( "ammo", 90, p.xy(), p.xy(), false, turn ); } if( one_in( 20 ) ) { int rn = rng( 1, 8 ); if( rn == 1 ) { m->furn_set( p, f_dresser ); - m->place_items( "dresser", 30, p.x, p.y, p.x, p.y, false, turn ); - m->place_items( "trash_forest", 60, p.x, p.y, p.x, p.y, false, turn ); + m->place_items( "dresser", 30, p.xy(), p.xy(), false, turn ); + m->place_items( "trash_forest", 60, p.xy(), p.xy(), false, turn ); } else if( rn == 2 ) { m->furn_set( p, f_chair ); } else if( rn == 3 ) { m->furn_set( p, f_cupboard ); - m->place_items( "trash", 60, p.x, p.y, p.x, p.y, false, turn ); - m->place_items( "dining", 40, p.x, p.y, p.x, p.y, false, turn ); + m->place_items( "trash", 60, p.xy(), p.xy(), false, turn ); + m->place_items( "dining", 40, p.xy(), p.xy(), false, turn ); } else if( rn == 4 ) { tripoint rs = p + furn_space::best_expand( *m, p, rng( 0, 4 ), 0 ); square_furn( m, f_bookcase, p.x, p.y, rs.x, rs.y ); - m->place_items( "novels", 60, p.x, p.y, rs.x, rs.y, false, turn ); - m->place_items( "magazines", 20, p.x, p.y, rs.x, rs.y, false, turn ); + m->place_items( "novels", 60, p.xy(), rs.xy(), false, turn ); + m->place_items( "magazines", 20, p.xy(), rs.xy(), false, turn ); } else if( rn == 5 ) { tripoint rs = p + furn_space::best_expand( *m, p, 0, rng( 0, 4 ) ); square_furn( m, f_bookcase, p.x, p.y, rs.x, rs.y ); - m->place_items( "novels", 60, p.x, p.y, rs.x, rs.y, false, turn ); - m->place_items( "magazines", 20, p.x, p.y, rs.x, rs.y, false, turn ); + m->place_items( "novels", 60, p.xy(), rs.xy(), false, turn ); + m->place_items( "magazines", 20, p.xy(), rs.xy(), false, turn ); } else if( rn == 6 ) { tripoint rs = p + furn_space::best_expand( *m, p, rng( 0, 2 ), 0 ); square_furn( m, f_locker, p.x, p.y, rs.x, rs.y ); - m->place_items( "trash", 60, p.x, p.y, rs.x, rs.y, false, turn ); - m->place_items( "home_hw", 20, p.x, p.y, rs.x, rs.y, false, turn ); + m->place_items( "trash", 60, p.xy(), rs.xy(), false, turn ); + m->place_items( "home_hw", 20, p.xy(), rs.xy(), false, turn ); } else if( rn == 7 ) { tripoint rs = p + furn_space::best_expand( *m, p, 0, rng( 0, 2 ) ); square_furn( m, f_locker, p.x, p.y, rs.x, rs.y ); - m->place_items( "trash", 60, p.x, p.y, rs.x, rs.y, false, turn ); - m->place_items( "home_hw", 20, p.x, p.y, rs.x, rs.y, false, turn ); + m->place_items( "trash", 60, p.xy(), rs.xy(), false, turn ); + m->place_items( "home_hw", 20, p.xy(), rs.xy(), false, turn ); } else { tripoint rs = p + furn_space::best_expand( *m, p, rng( 0, 2 ), rng( 0, 2 ) ); square_furn( m, f_table, p.x, p.y, rs.x, rs.y ); @@ -2913,11 +2920,13 @@ void mapgen_basement_junk( map *m, oter_id terrain_type, mapgendata dat, const t } } - m->place_items( "bedroom", 60, 1, 1, SEEX * 2 - 2, SEEY * 2 - 2, false, turn ); - m->place_items( "home_hw", 80, 1, 1, SEEX * 2 - 2, SEEY * 2 - 2, false, turn ); - m->place_items( "homeguns", 10, 1, 1, SEEX * 2 - 2, SEEY * 2 - 2, false, turn ); + m->place_items( "bedroom", 60, point_south_east, point( SEEX * 2 - 2, SEEY * 2 - 2 ), false, turn ); + m->place_items( "home_hw", 80, point_south_east, point( SEEX * 2 - 2, SEEY * 2 - 2 ), false, turn ); + m->place_items( "homeguns", 10, point_south_east, point( SEEX * 2 - 2, SEEY * 2 - 2 ), false, + turn ); // Chance of zombies in the basement - m->place_spawns( mongroup_id( "GROUP_ZOMBIE" ), 2, 1, 1, SEEX * 2 - 2, SEEY * 2 - 2, density ); + m->place_spawns( mongroup_id( "GROUP_ZOMBIE" ), 2, point_south_east, point( SEEX * 2 - 2, + SEEY * 2 - 2 ), density ); } void mapgen_basement_spiders( map *m, oter_id terrain_type, mapgendata dat, const time_point &turn, @@ -2941,14 +2950,14 @@ void mapgen_basement_spiders( map *m, oter_id terrain_type, mapgendata dat, cons if( !one_in( 3 ) ) { madd_field( m, i, j, fd_web, rng( 1, 3 ) ); } - if( one_in( 30 ) && m->passable( i, j ) ) { + if( one_in( 30 ) && m->passable( point( i, j ) ) ) { m->furn_set( point( i, j ), egg_type ); - m->add_spawn( spider_type, rng( 1, 2 ), i, j ); //hope you like'em spiders + m->add_spawn( spider_type, rng( 1, 2 ), point( i, j ) ); //hope you like'em spiders m->remove_field( { i, j, m->get_abs_sub().z }, fd_web ); } } } - m->place_items( "rare", 70, 1, 1, SEEX * 2 - 1, SEEY * 2 - 5, false, turn ); + m->place_items( "rare", 70, point_south_east, point( SEEX * 2 - 1, SEEY * 2 - 5 ), false, turn ); } void mapgen_cave( map *m, oter_id, mapgendata dat, const time_point &turn, float density ) @@ -2970,26 +2979,26 @@ void mapgen_cave( map *m, oter_id, mapgendata dat, const time_point &turn, float switch( rng( 1, 10 ) ) { case 1: // natural refuse, chance of minerals - m->place_items( "cave_minerals", 50, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); - m->place_items( "monparts", 80, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "cave_minerals", 50, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); + m->place_items( "monparts", 80, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); break; case 2: // trash, minerals less likely - m->place_items( "cave_minerals", 25, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); - m->place_items( "trash", 70, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "cave_minerals", 25, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); + m->place_items( "trash", 70, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); break; case 3: // bat corpses - m->place_items( "cave_minerals", 50, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "cave_minerals", 50, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); for( int i = rng( 1, 12 ); i > 0; i-- ) { - m->add_item_or_charges( rng( 1, SEEX * 2 - 1 ), rng( 1, SEEY * 2 - 1 ), + m->add_item_or_charges( point( rng( 1, SEEX * 2 - 1 ), rng( 1, SEEY * 2 - 1 ) ), item::make_corpse( mon_bat ) ); } break; case 4: // ant food, chance of 80 - m->place_items( "cave_minerals", 25, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); - m->place_items( "ant_food", 85, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "cave_minerals", 25, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); + m->place_items( "ant_food", 85, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); break; case 5: { // hermitage @@ -3001,22 +3010,28 @@ void mapgen_cave( map *m, oter_id, mapgendata dat, const time_point &turn, float for( auto &ii : bloodline ) { madd_field( m, ii.x, ii.y, fd_blood, 2 ); } - m->add_item_or_charges( hermx, hermy, item::make_corpse() ); + m->add_item_or_charges( point( hermx, hermy ), item::make_corpse() ); // This seems verbose. Maybe a function to spawn from a list of item groups? - m->place_items( "stash_food", 50, hermx - 1, hermy - 1, hermx + 1, hermy + 1, true, turn ); - m->place_items( "gear_survival", 50, hermx - 1, hermy - 1, hermx + 1, hermy + 1, true, turn ); - m->place_items( "survival_armor", 50, hermx - 1, hermy - 1, hermx + 1, hermy + 1, true, turn ); - m->place_items( "weapons", 40, hermx - 1, hermy - 1, hermx + 1, hermy + 1, true, turn ); - m->place_items( "magazines", 40, hermx - 1, hermy - 1, hermx + 1, hermy + 1, true, turn ); - m->place_items( "rare", 30, hermx - 1, hermy - 1, hermx + 1, hermy + 1, true, turn ); + m->place_items( "stash_food", 50, point( hermx - 1, hermy - 1 ), point( hermx + 1, hermy + 1 ), + true, turn ); + m->place_items( "gear_survival", 50, point( hermx - 1, hermy - 1 ), point( hermx + 1, hermy + 1 ), + true, turn ); + m->place_items( "survival_armor", 50, point( hermx - 1, hermy - 1 ), point( hermx + 1, hermy + 1 ), + true, turn ); + m->place_items( "weapons", 40, point( hermx - 1, hermy - 1 ), point( hermx + 1, hermy + 1 ), true, + turn ); + m->place_items( "magazines", 40, point( hermx - 1, hermy - 1 ), point( hermx + 1, hermy + 1 ), true, + turn ); + m->place_items( "rare", 30, point( hermx - 1, hermy - 1 ), point( hermx + 1, hermy + 1 ), true, + turn ); break; } default: // nothing except maybe minerals, default occurs half the time - m->place_items( "cave_minerals", 50, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "cave_minerals", 50, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); break; } - m->place_spawns( mongroup_id( "GROUP_CAVE" ), 2, 6, 6, 18, 18, 1.0 ); + m->place_spawns( mongroup_id( "GROUP_CAVE" ), 2, point( 6, 6 ), point( 18, 18 ), 1.0 ); } else { // We're above ground! // First, draw a forest /* @@ -3060,12 +3075,12 @@ void mapgen_cave_rat( map *m, oter_id, mapgendata dat, const time_point &turn, f for( int i = SEEX - 4; i <= SEEX + 4; i++ ) { for( int j = SEEY - 4; j <= SEEY + 4; j++ ) { if( ( i <= SEEX - 2 || i >= SEEX + 2 ) && ( j <= SEEY - 2 || j >= SEEY + 2 ) ) { - m->add_spawn( mon_sewer_rat, 1, i, j ); + m->add_spawn( mon_sewer_rat, 1, point( i, j ) ); } } } - m->add_spawn( mon_rat_king, 1, SEEX, SEEY ); - m->place_items( "rare", 75, SEEX - 4, SEEY - 4, SEEX + 4, SEEY + 4, true, turn ); + m->add_spawn( mon_rat_king, 1, point( SEEX, SEEY ) ); + m->place_items( "rare", 75, point( SEEX - 4, SEEY - 4 ), point( SEEX + 4, SEEY + 4 ), true, turn ); } else { // Level 1 int cavex = SEEX; int cavey = SEEY * 2 - 3; @@ -3081,7 +3096,7 @@ void mapgen_cave_rat( map *m, oter_id, mapgendata dat, const time_point &turn, f madd_field( m, cx, cy, fd_blood, rng( 1, 3 ) ); } if( one_in( 20 ) ) { - m->add_spawn( mon_sewer_rat, 1, cx, cy ); + m->add_spawn( mon_sewer_rat, 1, point( cx, cy ) ); } } } @@ -3101,7 +3116,7 @@ void mapgen_cave_rat( map *m, oter_id, mapgendata dat, const time_point &turn, f madd_field( m, cx, cy, fd_blood, rng( 1, 3 ) ); } if( one_in( 20 ) ) { - m->add_spawn( mon_sewer_rat, 1, cx, cy ); + m->add_spawn( mon_sewer_rat, 1, point( cx, cy ) ); } } } @@ -3181,22 +3196,22 @@ void mapgen_cavern( map *m, oter_id, mapgendata dat, const time_point &turn, flo } } } - m->place_items( "cavern", 60, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, false, turn ); + m->place_items( "cavern", 60, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), false, turn ); if( one_in( 6 ) ) { // Miner remains int x = 0; int y = 0; do { x = rng( 0, SEEX * 2 - 1 ); y = rng( 0, SEEY * 2 - 1 ); - } while( m->impassable( x, y ) ); + } while( m->impassable( point( x, y ) ) ); if( !one_in( 3 ) ) { - m->spawn_item( x, y, "jackhammer" ); + m->spawn_item( point( x, y ), "jackhammer" ); } if( one_in( 3 ) ) { - m->spawn_item( x, y, "mask_dust" ); + m->spawn_item( point( x, y ), "mask_dust" ); } if( one_in( 2 ) ) { - m->spawn_item( x, y, "hat_hard" ); + m->spawn_item( point( x, y ), "hat_hard" ); } while( !one_in( 3 ) ) { for( int i = 0; i < 3; ++i ) { @@ -3635,14 +3650,14 @@ static void mapgen_ants_generic( map *m, oter_id terrain_type, mapgendata dat, } } if( terrain_type == "ants_food" ) { - m->place_items( "ant_food", 92, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "ant_food", 92, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); } else { - m->place_items( "ant_egg", 98, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "ant_egg", 98, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); } if( terrain_type == "ants_queen" ) { - m->add_spawn( mon_ant_queen, 1, SEEX, SEEY ); + m->add_spawn( mon_ant_queen, 1, point( SEEX, SEEY ) ); } else if( terrain_type == "ants_larvae" ) { - m->add_spawn( mon_ant_larva, 10, SEEX, SEEY ); + m->add_spawn( mon_ant_larva, 10, point( SEEX, SEEY ) ); } } @@ -3651,23 +3666,23 @@ void mapgen_ants_food( map *m, oter_id terrain_type, mapgendata dat, const time_ float density ) { mapgen_ants_generic( m, terrain_type, dat, turn, density ); - m->place_items( "ant_food", 92, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( "ant_food", 92, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); } void mapgen_ants_larvae( map *m, oter_id terrain_type, mapgendata dat, const time_point &turn, float density ) { mapgen_ants_generic( m, terrain_type, dat, turn, density ); - m->place_items( "ant_egg", 98, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); - m->add_spawn( mon_ant_larva, 10, SEEX, SEEY ); + m->place_items( "ant_egg", 98, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); + m->add_spawn( mon_ant_larva, 10, point( SEEX, SEEY ) ); } void mapgen_ants_queen( map *m, oter_id terrain_type, mapgendata dat, const time_point &turn, float density ) { mapgen_ants_generic( m, terrain_type, dat, turn, density ); - m->place_items( "ant_egg", 98, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); - m->add_spawn( mon_ant_queen, 1, SEEX, SEEY ); + m->place_items( "ant_egg", 98, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); + m->add_spawn( mon_ant_queen, 1, point( SEEX, SEEY ) ); } @@ -3697,7 +3712,7 @@ void mapgen_tutorial( map *m, oter_id terrain_type, mapgendata dat, const time_p } } m->furn_set( point( 7, SEEY * 2 - 4 ), f_rack ); - m->place_gas_pump( SEEX * 2 - 2, SEEY * 2 - 4, rng( 500, 1000 ) ); + m->place_gas_pump( point( SEEX * 2 - 2, SEEY * 2 - 4 ), rng( 500, 1000 ) ); if( dat.zlevel < 0 ) { m->ter_set( point( SEEX - 2, SEEY + 2 ), t_stairs_up ); m->ter_set( point( 2, 2 ), t_water_sh ); @@ -3705,20 +3720,20 @@ void mapgen_tutorial( map *m, oter_id terrain_type, mapgendata dat, const time_p m->ter_set( point( 3, 2 ), t_water_sh ); m->ter_set( point( 3, 3 ), t_water_sh ); } else { - m->spawn_item( 5, SEEY + 1, "helmet_bike" ); - m->spawn_item( 4, SEEY + 1, "backpack" ); - m->spawn_item( 3, SEEY + 1, "pants_cargo" ); - m->spawn_item( 7, SEEY * 2 - 4, "machete" ); - m->spawn_item( 7, SEEY * 2 - 4, "9mm" ); - m->spawn_item( 7, SEEY * 2 - 4, "9mmP" ); - m->spawn_item( 7, SEEY * 2 - 4, "uzi" ); - m->spawn_item( 7, SEEY * 2 - 4, "uzimag" ); - m->spawn_item( SEEX * 2 - 2, SEEY + 5, "bubblewrap" ); - m->spawn_item( SEEX * 2 - 2, SEEY + 6, "grenade" ); - m->spawn_item( SEEX * 2 - 3, SEEY + 6, "flashlight" ); - m->spawn_item( SEEX * 2 - 2, SEEY + 7, "cig" ); - m->spawn_item( SEEX * 2 - 2, SEEY + 7, "codeine" ); - m->spawn_item( SEEX * 2 - 3, SEEY + 7, "water" ); + m->spawn_item( point( 5, SEEY + 1 ), "helmet_bike" ); + m->spawn_item( point( 4, SEEY + 1 ), "backpack" ); + m->spawn_item( point( 3, SEEY + 1 ), "pants_cargo" ); + m->spawn_item( point( 7, SEEY * 2 - 4 ), "machete" ); + m->spawn_item( point( 7, SEEY * 2 - 4 ), "9mm" ); + m->spawn_item( point( 7, SEEY * 2 - 4 ), "9mmP" ); + m->spawn_item( point( 7, SEEY * 2 - 4 ), "uzi" ); + m->spawn_item( point( 7, SEEY * 2 - 4 ), "uzimag" ); + m->spawn_item( point( SEEX * 2 - 2, SEEY + 5 ), "bubblewrap" ); + m->spawn_item( point( SEEX * 2 - 2, SEEY + 6 ), "grenade" ); + m->spawn_item( point( SEEX * 2 - 3, SEEY + 6 ), "flashlight" ); + m->spawn_item( point( SEEX * 2 - 2, SEEY + 7 ), "cig" ); + m->spawn_item( point( SEEX * 2 - 2, SEEY + 7 ), "codeine" ); + m->spawn_item( point( SEEX * 2 - 3, SEEY + 7 ), "water" ); m->ter_set( point( SEEX - 2, SEEY + 2 ), t_stairs_down ); } } @@ -3968,8 +3983,8 @@ void mapgen_forest( map *m, oter_id terrain_type, mapgendata dat, const time_poi // Place items on this terrain as defined in the biome. for( int i = 0; i < current_biome_def.item_spawn_iterations; i++ ) { - m->place_items( current_biome_def.item_group, current_biome_def.item_group_chance, 0, 0, - SEEX * 2 - 1, SEEY * 2 - 1, true, turn ); + m->place_items( current_biome_def.item_group, current_biome_def.item_group_chance, point_zero, + point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, turn ); } } @@ -4006,7 +4021,8 @@ void mapgen_forest_trail_straight( map *m, oter_id terrain_type, mapgendata dat, m->rotate( 1 ); } - m->place_items( "forest_trail", 75, center_x - 2, center_y - 2, center_x + 2, center_y + 2, true, + m->place_items( "forest_trail", 75, point( center_x - 2, center_y - 2 ), point( center_x + 2, + center_y + 2 ), true, turn ); } @@ -4051,7 +4067,8 @@ void mapgen_forest_trail_curved( map *m, oter_id terrain_type, mapgendata dat, m->rotate( 3 ); } - m->place_items( "forest_trail", 75, center_x - 2, center_y - 2, center_x + 2, center_y + 2, true, + m->place_items( "forest_trail", 75, point( center_x - 2, center_y - 2 ), point( center_x + 2, + center_y + 2 ), true, turn ); } @@ -4094,7 +4111,8 @@ void mapgen_forest_trail_tee( map *m, oter_id terrain_type, mapgendata dat, cons m->rotate( 3 ); } - m->place_items( "forest_trail", 75, center_x - 2, center_y - 2, center_x + 2, center_y + 2, true, + m->place_items( "forest_trail", 75, point( center_x - 2, center_y - 2 ), point( center_x + 2, + center_y + 2 ), true, turn ); } @@ -4127,7 +4145,8 @@ void mapgen_forest_trail_four_way( map *m, oter_id, mapgendata dat, const time_p } } - m->place_items( "forest_trail", 75, center_x - 2, center_y - 2, center_x + 2, center_y + 2, true, + m->place_items( "forest_trail", 75, point( center_x - 2, center_y - 2 ), point( center_x + 2, + center_y + 2 ), true, turn ); } @@ -4180,7 +4199,7 @@ void mapgen_lake_shore( map *m, oter_id, mapgendata dat, const time_point &turn, if( did_extend_adjacent_terrain ) { for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - m->i_clear( x, y ); + m->i_clear( point( x, y ) ); } } } diff --git a/src/mapgenformat.cpp b/src/mapgenformat.cpp index 0492a136088fd..429fb7534b02b 100644 --- a/src/mapgenformat.cpp +++ b/src/mapgenformat.cpp @@ -28,7 +28,7 @@ void formatted_set_simple( map *m, const int startx, const int starty, const cha } if( furn != f_null ) { if( furn == f_toilet ) { - m->place_toilet( x, y ); + m->place_toilet( point( x, y ) ); } else { m->furn_set( point( x, y ), furn ); } diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index c83d16233a4a1..8b2981ff258ab 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -897,12 +897,12 @@ void talk_function::field_build_1( npc &p ) false ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_ter( t_dirt, 5, 4, 15, 14 ); - bay.draw_square_ter( t_dirtmound, 6, 5, 6, 13 ); - bay.draw_square_ter( t_dirtmound, 8, 5, 8, 13 ); - bay.draw_square_ter( t_dirtmound, 10, 5, 10, 13 ); - bay.draw_square_ter( t_dirtmound, 12, 5, 12, 13 ); - bay.draw_square_ter( t_dirtmound, 14, 5, 14, 13 ); + bay.draw_square_ter( t_dirt, point( 5, 4 ), point( 15, 14 ) ); + bay.draw_square_ter( t_dirtmound, point( 6, 5 ), point( 6, 13 ) ); + bay.draw_square_ter( t_dirtmound, point( 8, 5 ), point( 8, 13 ) ); + bay.draw_square_ter( t_dirtmound, point( 10, 5 ), point( 10, 13 ) ); + bay.draw_square_ter( t_dirtmound, point( 12, 5 ), point( 12, 13 ) ); + bay.draw_square_ter( t_dirtmound, point( 14, 5 ), point( 14, 13 ) ); bay.save(); popup( _( "%s jots your name down on a ledger and yells out to nearby laborers to begin " "plowing your new field." ), p.name ); @@ -921,13 +921,13 @@ void talk_function::field_build_2( npc &p ) 20, false ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_ter( t_fence, 4, 3, 16, 3 ); - bay.draw_square_ter( t_fence, 4, 15, 16, 15 ); - bay.draw_square_ter( t_fence, 4, 3, 4, 15 ); - bay.draw_square_ter( t_fence, 16, 3, 16, 15 ); - bay.draw_square_ter( t_fencegate_c, 10, 3, 10, 3 ); - bay.draw_square_ter( t_fencegate_c, 10, 15, 10, 15 ); - bay.draw_square_ter( t_fencegate_c, 4, 9, 4, 9 ); + bay.draw_square_ter( t_fence, point( 4, 3 ), point( 16, 3 ) ); + bay.draw_square_ter( t_fence, point( 4, 15 ), point( 16, 15 ) ); + bay.draw_square_ter( t_fence, point( 4, 3 ), point( 4, 15 ) ); + bay.draw_square_ter( t_fence, point( 16, 3 ), point( 16, 15 ) ); + bay.draw_square_ter( t_fencegate_c, point( 10, 3 ), point( 10, 3 ) ); + bay.draw_square_ter( t_fencegate_c, point( 10, 15 ), point( 10, 15 ) ); + bay.draw_square_ter( t_fencegate_c, point( 4, 9 ), point( 4, 9 ) ); bay.save(); popup( _( "After counting your money %s directs a nearby laborer to begin constructing a " "fence around your plot..." ), p.name ); @@ -1017,13 +1017,13 @@ void talk_function::field_plant( npc &p, const std::string &place ) used_seed = g->u.use_amount( seed_id, 1 ); } used_seed.front().set_age( 0_turns ); - bay.add_item_or_charges( x, y, used_seed.front() ); + bay.add_item_or_charges( point( x, y ), used_seed.front() ); bay.set( point( x, y ), t_dirt, f_plant_seed ); limiting_number--; } } } - bay.draw_square_ter( t_fence, 4, 3, 16, 3 ); + bay.draw_square_ter( t_fence, point( 4, 3 ), point( 16, 3 ) ); bay.save(); popup( _( "After counting your money and collecting your seeds, %s calls forth a labor party " "to plant your field." ), p.name ); @@ -1042,9 +1042,9 @@ void talk_function::field_harvest( npc &p, const std::string &place ) bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); for( int x = 0; x < SEEX * 2 - 1; x++ ) { for( int y = 0; y < SEEY * 2 - 1; y++ ) { - if( bay.furn( x, y ) == furn_str_id( "f_plant_harvest" ) && !bay.i_at( x, y ).empty() ) { + if( bay.furn( x, y ) == furn_str_id( "f_plant_harvest" ) && !bay.i_at( point( x, y ) ).empty() ) { // Can't use item_stack::only_item() since there might be fertilizer - map_stack items = bay.i_at( x, y ); + map_stack items = bay.i_at( point( x, y ) ); map_stack::iterator seed = std::find_if( items.begin(), items.end(), []( const item & it ) { return it.is_seed(); } ); @@ -1092,7 +1092,7 @@ void talk_function::field_harvest( npc &p, const std::string &place ) for( int y = 0; y < SEEY * 2 - 1; y++ ) { if( bay.furn( x, y ) == furn_str_id( "f_plant_harvest" ) ) { // Can't use item_stack::only_item() since there might be fertilizer - map_stack items = bay.i_at( x, y ); + map_stack items = bay.i_at( point( x, y ) ); map_stack::iterator seed = std::find_if( items.begin(), items.end(), []( const item & it ) { return it.is_seed(); } ); @@ -1102,7 +1102,7 @@ void talk_function::field_harvest( npc &p, const std::string &place ) tmp = item( seed_data.fruit_id, calendar::turn ); if( tmp.typeId() == plant_types[plant_index] ) { number_plots++; - bay.i_clear( x, y ); + bay.i_clear( point( x, y ) ); bay.furn_set( point( x, y ), f_null ); bay.ter_set( point( x, y ), t_dirtmound ); int plantCount = rng( skillLevel / 2, skillLevel ); diff --git a/src/mission_start.cpp b/src/mission_start.cpp index 21df804ab6ad5..4bb9d431c4d5b 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -64,7 +64,7 @@ void mission_start::place_dog( mission *miss ) tinymap doghouse; doghouse.load( tripoint( house.x * 2, house.y * 2, house.z ), false ); - doghouse.add_spawn( mon_dog, 1, SEEX, SEEY, true, -1, miss->uid ); + doghouse.add_spawn( mon_dog, 1, point( SEEX, SEEY ), true, -1, miss->uid ); doghouse.save(); } @@ -77,7 +77,7 @@ void mission_start::place_zombie_mom( mission *miss ) tinymap zomhouse; zomhouse.load( tripoint( house.x * 2, house.y * 2, house.z ), false ); - zomhouse.add_spawn( mon_zombie, 1, SEEX, SEEY, false, -1, miss->uid, + zomhouse.add_spawn( mon_zombie, 1, point( SEEX, SEEY ), false, -1, miss->uid, Name::get( nameIsFemaleName | nameIsGivenName ) ); zomhouse.save(); } @@ -107,20 +107,21 @@ void mission_start::kill_horde_master( mission *miss ) overmap_buffer.reveal( site, 6 ); tinymap tile; tile.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - tile.add_spawn( mon_zombie_master, 1, SEEX, SEEY, false, -1, miss->uid, _( "Demonic Soul" ) ); - tile.add_spawn( mon_zombie_brute, 3, SEEX, SEEY ); - tile.add_spawn( mon_zombie_dog, 3, SEEX, SEEY ); + tile.add_spawn( mon_zombie_master, 1, point( SEEX, SEEY ), false, -1, miss->uid, + _( "Demonic Soul" ) ); + tile.add_spawn( mon_zombie_brute, 3, point( SEEX, SEEY ) ); + tile.add_spawn( mon_zombie_dog, 3, point( SEEX, SEEY ) ); if( overmap::inbounds( tripoint( SEEX, SEEY, 0 ), 1 ) ) { for( int x = SEEX - 1; x <= SEEX + 1; x++ ) { for( int y = SEEY - 1; y <= SEEY + 1; y++ ) { - tile.add_spawn( mon_zombie, rng( 3, 10 ), x, y ); + tile.add_spawn( mon_zombie, rng( 3, 10 ), point( x, y ) ); } - tile.add_spawn( mon_zombie_dog, rng( 0, 2 ), SEEX, SEEY ); + tile.add_spawn( mon_zombie_dog, rng( 0, 2 ), point( SEEX, SEEY ) ); } } - tile.add_spawn( mon_zombie_necro, 2, SEEX, SEEY ); - tile.add_spawn( mon_zombie_hulk, 1, SEEX, SEEY ); + tile.add_spawn( mon_zombie_necro, 2, point( SEEX, SEEY ) ); + tile.add_spawn( mon_zombie_hulk, 1, point( SEEX, SEEY ) ); tile.save(); } @@ -363,9 +364,9 @@ void mission_start::ranch_nurse_1( mission *miss ) tripoint site = mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_furn( f_rack, 16, 9, 17, 9 ); - bay.spawn_item( 16, 9, "bandages", rng( 1, 3 ) ); - bay.spawn_item( 17, 9, "aspirin", rng( 1, 2 ) ); + bay.draw_square_furn( f_rack, point( 16, 9 ), point( 17, 9 ) ); + bay.spawn_item( point( 16, 9 ), "bandages", rng( 1, 3 ) ); + bay.spawn_item( point( 17, 9 ), "aspirin", rng( 1, 2 ) ); bay.save(); } @@ -375,9 +376,9 @@ void mission_start::ranch_nurse_2( mission *miss ) tripoint site = mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_furn( f_counter, 3, 7, 5, 7 ); - bay.draw_square_furn( f_rack, 8, 4, 8, 5 ); - bay.spawn_item( 8, 4, "manual_first_aid" ); + bay.draw_square_furn( f_counter, point( 3, 7 ), point( 5, 7 ) ); + bay.draw_square_furn( f_rack, point( 8, 4 ), point( 8, 5 ) ); + bay.spawn_item( point( 8, 4 ), "manual_first_aid" ); bay.save(); } @@ -387,15 +388,15 @@ void mission_start::ranch_nurse_3( mission *miss ) tripoint site = mission_util::target_om_ter_random( "ranch_camp_50", 1, miss, false, RANCH_SIZE ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_ter( t_dirt, 2, 16, 9, 23 ); - bay.draw_square_ter( t_dirt, 13, 16, 20, 23 ); - bay.draw_square_ter( t_dirt, 10, 17, 12, 23 ); + bay.draw_square_ter( t_dirt, point( 2, 16 ), point( 9, 23 ) ); + bay.draw_square_ter( t_dirt, point( 13, 16 ), point( 20, 23 ) ); + bay.draw_square_ter( t_dirt, point( 10, 17 ), point( 12, 23 ) ); bay.save(); site = mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_ter( t_dirt, 2, 0, 20, 2 ); - bay.draw_square_ter( t_dirt, 10, 3, 12, 4 ); + bay.draw_square_ter( t_dirt, point( 2, 0 ), point( 20, 2 ) ); + bay.draw_square_ter( t_dirt, point( 10, 3 ), point( 12, 4 ) ); bay.save(); } @@ -405,23 +406,23 @@ void mission_start::ranch_nurse_4( mission *miss ) tripoint site = mission_util::target_om_ter_random( "ranch_camp_50", 1, miss, false, RANCH_SIZE ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_ter( t_wall_half, 2, 16, 9, 23 ); - bay.draw_square_ter( t_dirt, 3, 17, 8, 22 ); - bay.draw_square_ter( t_wall_half, 13, 16, 20, 23 ); - bay.draw_square_ter( t_dirt, 14, 17, 19, 22 ); - bay.draw_square_ter( t_wall_half, 10, 17, 12, 23 ); - bay.draw_square_ter( t_dirt, 10, 18, 12, 23 ); + bay.draw_square_ter( t_wall_half, point( 2, 16 ), point( 9, 23 ) ); + bay.draw_square_ter( t_dirt, point( 3, 17 ), point( 8, 22 ) ); + bay.draw_square_ter( t_wall_half, point( 13, 16 ), point( 20, 23 ) ); + bay.draw_square_ter( t_dirt, point( 14, 17 ), point( 19, 22 ) ); + bay.draw_square_ter( t_wall_half, point( 10, 17 ), point( 12, 23 ) ); + bay.draw_square_ter( t_dirt, point( 10, 18 ), point( 12, 23 ) ); bay.ter_set( point( 9, 19 ), t_door_frame ); bay.ter_set( point( 13, 19 ), t_door_frame ); bay.save(); site = mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_ter( t_wall_half, 4, 0, 18, 2 ); - bay.draw_square_ter( t_wall_half, 10, 3, 12, 4 ); - bay.draw_square_ter( t_dirt, 5, 0, 8, 2 ); - bay.draw_square_ter( t_dirt, 10, 0, 12, 4 ); - bay.draw_square_ter( t_dirt, 14, 0, 17, 2 ); + bay.draw_square_ter( t_wall_half, point( 4, 0 ), point( 18, 2 ) ); + bay.draw_square_ter( t_wall_half, point( 10, 3 ), point( 12, 4 ) ); + bay.draw_square_ter( t_dirt, point( 5, 0 ), point( 8, 2 ) ); + bay.draw_square_ter( t_dirt, point( 10, 0 ), point( 12, 4 ) ); + bay.draw_square_ter( t_dirt, point( 14, 0 ), point( 17, 2 ) ); bay.ter_set( point( 9, 1 ), t_door_frame ); bay.ter_set( point( 13, 1 ), t_door_frame ); bay.save(); @@ -444,7 +445,7 @@ void mission_start::ranch_nurse_5( mission *miss ) site = mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); bay.translate( t_wall_half, t_wall_wood ); - bay.draw_square_ter( t_dirt, 10, 0, 12, 4 ); + bay.draw_square_ter( t_dirt, point( 10, 0 ), point( 12, 4 ) ); bay.save(); } @@ -456,17 +457,17 @@ void mission_start::ranch_nurse_6( mission *miss ) bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); bay.translate( t_window_frame, t_window_boarded_noglass ); bay.translate( t_door_frame, t_door_c ); - bay.draw_square_ter( t_dirtfloor, 3, 17, 8, 22 ); - bay.draw_square_ter( t_dirtfloor, 14, 17, 19, 22 ); - bay.draw_square_ter( t_dirtfloor, 10, 18, 12, 23 ); + bay.draw_square_ter( t_dirtfloor, point( 3, 17 ), point( 8, 22 ) ); + bay.draw_square_ter( t_dirtfloor, point( 14, 17 ), point( 19, 22 ) ); + bay.draw_square_ter( t_dirtfloor, point( 10, 18 ), point( 12, 23 ) ); bay.save(); site = mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); bay.translate( t_door_frame, t_door_c ); - bay.draw_square_ter( t_dirtfloor, 5, 0, 8, 2 ); - bay.draw_square_ter( t_dirtfloor, 10, 0, 12, 4 ); - bay.draw_square_ter( t_dirtfloor, 14, 0, 17, 2 ); + bay.draw_square_ter( t_dirtfloor, point( 5, 0 ), point( 8, 2 ) ); + bay.draw_square_ter( t_dirtfloor, point( 10, 0 ), point( 12, 4 ) ); + bay.draw_square_ter( t_dirtfloor, point( 14, 0 ), point( 17, 2 ) ); bay.save(); } @@ -482,8 +483,8 @@ void mission_start::ranch_nurse_7( mission *miss ) site = mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); bay.translate( t_dirtfloor, t_floor ); - bay.draw_square_ter( t_floor, 10, 5, 12, 5 ); - bay.draw_square_furn( f_rack, 17, 0, 17, 2 ); + bay.draw_square_ter( t_floor, point( 10, 5 ), point( 12, 5 ) ); + bay.draw_square_furn( f_rack, point( 17, 0 ), point( 17, 2 ) ); bay.save(); } @@ -493,21 +494,21 @@ void mission_start::ranch_nurse_8( mission *miss ) tripoint site = mission_util::target_om_ter_random( "ranch_camp_50", 1, miss, false, RANCH_SIZE ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_furn( f_makeshift_bed, 4, 21, 4, 22 ); - bay.draw_square_furn( f_makeshift_bed, 7, 21, 7, 22 ); - bay.draw_square_furn( f_makeshift_bed, 15, 21, 15, 22 ); - bay.draw_square_furn( f_makeshift_bed, 18, 21, 18, 22 ); - bay.draw_square_furn( f_makeshift_bed, 4, 17, 4, 18 ); - bay.draw_square_furn( f_makeshift_bed, 7, 17, 7, 18 ); - bay.draw_square_furn( f_makeshift_bed, 15, 17, 15, 18 ); - bay.draw_square_furn( f_makeshift_bed, 18, 17, 18, 18 ); + bay.draw_square_furn( f_makeshift_bed, point( 4, 21 ), point( 4, 22 ) ); + bay.draw_square_furn( f_makeshift_bed, point( 7, 21 ), point( 7, 22 ) ); + bay.draw_square_furn( f_makeshift_bed, point( 15, 21 ), point( 15, 22 ) ); + bay.draw_square_furn( f_makeshift_bed, point( 18, 21 ), point( 18, 22 ) ); + bay.draw_square_furn( f_makeshift_bed, point( 4, 17 ), point( 4, 18 ) ); + bay.draw_square_furn( f_makeshift_bed, point( 7, 17 ), point( 7, 18 ) ); + bay.draw_square_furn( f_makeshift_bed, point( 15, 17 ), point( 15, 18 ) ); + bay.draw_square_furn( f_makeshift_bed, point( 18, 17 ), point( 18, 18 ) ); bay.save(); site = mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); bay.translate( t_dirtfloor, t_floor ); - bay.place_items( "cleaning", 75, 17, 0, 17, 2, true, 0 ); - bay.place_items( "surgery", 75, 15, 4, 18, 4, true, 0 ); + bay.place_items( "cleaning", 75, point( 17, 0 ), point( 17, 2 ), true, 0 ); + bay.place_items( "surgery", 75, point( 15, 4 ), point( 18, 4 ), true, 0 ); bay.save(); } @@ -525,7 +526,7 @@ void mission_start::ranch_nurse_9( mission *miss ) bay.furn_set( point( 8, 17 ), f_dresser ); bay.furn_set( point( 14, 17 ), f_dresser ); bay.furn_set( point( 19, 17 ), f_dresser ); - bay.place_npc( 16, 19, string_id( "ranch_doctor" ) ); + bay.place_npc( point( 16, 19 ), string_id( "ranch_doctor" ) ); bay.save(); mission_util::target_om_ter_random( "ranch_camp_59", 1, miss, false, RANCH_SIZE ); @@ -536,17 +537,17 @@ void mission_start::ranch_scavenger_1( mission *miss ) tripoint site = mission_util::target_om_ter_random( "ranch_camp_48", 1, miss, false, RANCH_SIZE ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.draw_square_ter( t_chainfence, 15, 13, 15, 22 ); - bay.draw_square_ter( t_chainfence, 16, 13, 23, 13 ); - bay.draw_square_ter( t_chainfence, 16, 22, 23, 22 ); + bay.draw_square_ter( t_chainfence, point( 15, 13 ), point( 15, 22 ) ); + bay.draw_square_ter( t_chainfence, point( 16, 13 ), point( 23, 13 ) ); + bay.draw_square_ter( t_chainfence, point( 16, 22 ), point( 23, 22 ) ); bay.save(); site = mission_util::target_om_ter_random( "ranch_camp_49", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.place_items( "mechanics", 65, 9, 13, 10, 16, true, 0 ); - bay.draw_square_ter( t_chainfence, 0, 22, 7, 22 ); - bay.draw_square_ter( t_dirt, 2, 22, 3, 22 ); - bay.spawn_item( 7, 19, "30gal_drum" ); + bay.place_items( "mechanics", 65, point( 9, 13 ), point( 10, 16 ), true, 0 ); + bay.draw_square_ter( t_chainfence, point( 0, 22 ), point( 7, 22 ) ); + bay.draw_square_ter( t_dirt, point( 2, 22 ), point( 3, 22 ) ); + bay.spawn_item( point( 7, 19 ), "30gal_drum" ); bay.save(); } @@ -556,16 +557,16 @@ void mission_start::ranch_scavenger_2( mission *miss ) tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); bay.add_vehicle( vproto_id( "car_chassis" ), 20, 15, 0 ); - bay.draw_square_ter( t_wall_half, 18, 19, 21, 22 ); - bay.draw_square_ter( t_dirt, 19, 20, 20, 21 ); + bay.draw_square_ter( t_wall_half, point( 18, 19 ), point( 21, 22 ) ); + bay.draw_square_ter( t_dirt, point( 19, 20 ), point( 20, 21 ) ); bay.ter_set( point( 19, 19 ), t_door_frame ); bay.save(); site = mission_util::target_om_ter_random( "ranch_camp_49", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.place_items( "mischw", 65, 12, 13, 13, 16, true, 0 ); - bay.draw_square_ter( t_chaingate_l, 2, 22, 3, 22 ); - bay.spawn_item( 7, 20, "30gal_drum" ); + bay.place_items( "mischw", 65, point( 12, 13 ), point( 13, 16 ), true, 0 ); + bay.draw_square_ter( t_chaingate_l, point( 2, 22 ), point( 3, 22 ) ); + bay.spawn_item( point( 7, 20 ), "30gal_drum" ); bay.save(); } @@ -576,10 +577,10 @@ void mission_start::ranch_scavenger_3( mission *miss ) bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); bay.translate( t_door_frame, t_door_locked ); bay.translate( t_wall_half, t_wall_wood ); - bay.draw_square_ter( t_dirtfloor, 19, 20, 20, 21 ); - bay.spawn_item( 16, 21, "wheel_wide" ); - bay.spawn_item( 17, 21, "wheel_wide" ); - bay.spawn_item( 23, 18, "v8_combustion" ); + bay.draw_square_ter( t_dirtfloor, point( 19, 20 ), point( 20, 21 ) ); + bay.spawn_item( point( 16, 21 ), "wheel_wide" ); + bay.spawn_item( point( 17, 21 ), "wheel_wide" ); + bay.spawn_item( point( 23, 18 ), "v8_combustion" ); bay.furn_set( point( 23, 17 ), furn_str_id( "f_arcade_machine" ) ); bay.ter_set( point( 23, 16 ), ter_str_id( "t_machinery_light" ) ); bay.furn_set( point( 20, 21 ), f_woodstove ); @@ -587,10 +588,10 @@ void mission_start::ranch_scavenger_3( mission *miss ) site = mission_util::target_om_ter_random( "ranch_camp_49", 1, miss, false, RANCH_SIZE ); bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.place_items( "mischw", 65, 2, 10, 4, 10, true, 0 ); - bay.place_items( "mischw", 65, 2, 13, 4, 13, true, 0 ); + bay.place_items( "mischw", 65, point( 2, 10 ), point( 4, 10 ), true, 0 ); + bay.place_items( "mischw", 65, point( 2, 13 ), point( 4, 13 ), true, 0 ); bay.furn_set( point( 1, 15 ), f_fridge ); - bay.spawn_item( 2, 15, "hdframe" ); + bay.spawn_item( point( 2, 15 ), "hdframe" ); bay.furn_set( point( 3, 15 ), f_washer ); bay.save(); } diff --git a/src/monster.cpp b/src/monster.cpp index b322508266b0b..cb92529031bde 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -448,7 +448,7 @@ void monster::try_reproduce() if( season_match && female && one_in( chance ) ) { int spawn_cnt = rng( 1, type->baby_count ); if( type->baby_monster ) { - g->m.add_spawn( type->baby_monster, spawn_cnt, pos().x, pos().y ); + g->m.add_spawn( type->baby_monster, spawn_cnt, pos().xy() ); } else { g->m.add_item_or_charges( pos(), item( type->baby_egg, DAYS( baby_timer ), spawn_cnt ), true ); } diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index 73204193c6092..6005a32ab3eb6 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -596,7 +596,7 @@ void talk_function::buy_10_logs( npc &p ) const tripoint site = random_entry( places_om ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.spawn_item( 7, 15, "log", 10 ); + bay.spawn_item( point( 7, 15 ), "log", 10 ); bay.save(); p.add_effect( effect_currently_busy, 1_days ); @@ -622,7 +622,7 @@ void talk_function::buy_100_logs( npc &p ) const tripoint site = random_entry( places_om ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.spawn_item( 7, 15, "log", 100 ); + bay.spawn_item( point( 7, 15 ), "log", 100 ); bay.save(); p.add_effect( effect_currently_busy, 7_days ); diff --git a/src/player.cpp b/src/player.cpp index 206f3aff2133f..ee4c90751244f 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -11493,7 +11493,7 @@ void player::place_corpse( const tripoint &om_target ) std::vector tmp = inv_dump(); item body = item::make_corpse( mtype_id::NULL_ID(), calendar::turn, name ); for( auto itm : tmp ) { - bay.add_item_or_charges( finX, finY, *itm ); + bay.add_item_or_charges( point( finX, finY ), *itm ); } for( auto &bio : *my_bionics ) { if( item::type_is_defined( bio.id.str() ) ) { @@ -11509,7 +11509,7 @@ void player::place_corpse( const tripoint &om_target ) for( int i = 0; i < storage_modules.second; ++i ) { body.emplace_back( "bio_power_storage_mkII" ); } - bay.add_item_or_charges( finX, finY, body ); + bay.add_item_or_charges( point( finX, finY ), body ); } bool player::sees_with_infrared( const Creature &critter ) const diff --git a/src/scent_map.cpp b/src/scent_map.cpp index 03a24268cda9f..66bfed18f7519 100644 --- a/src/scent_map.cpp +++ b/src/scent_map.cpp @@ -165,8 +165,8 @@ void scent_map::update( const tripoint ¢er, map &m ) const int diffusivity = 100; // The new scent flag searching function. Should be wayyy faster than the old one. - m.scent_blockers( blocks_scent, reduces_scent, scentmap_minx - 1, scentmap_miny - 1, - scentmap_maxx + 1, scentmap_maxy + 1 ); + m.scent_blockers( blocks_scent, reduces_scent, point( scentmap_minx - 1, scentmap_miny - 1 ), + point( scentmap_maxx + 1, scentmap_maxy + 1 ) ); // Sum neighbors in the y direction. This way, each square gets called 3 times instead of 9 // times. This cost us an extra loop here, but it also eliminated a loop at the end, so there // is a net performance improvement over the old code. Could probably still be better. diff --git a/src/start_location.cpp b/src/start_location.cpp index e69f601e3e0bd..3d25da47dd194 100644 --- a/src/start_location.cpp +++ b/src/start_location.cpp @@ -442,7 +442,7 @@ static void add_monsters( const tripoint &omtstart, const mongroup_id &type, flo m.load( spawn_location, false ); // map::place_spawns internally multiplies density by rng(10, 50) const float density = expected_points / ( ( 10 + 50 ) / 2.0 ); - m.place_spawns( type, 1, 0, 0, SEEX * 2 - 1, SEEY * 2 - 1, density ); + m.place_spawns( type, 1, point_zero, point( SEEX * 2 - 1, SEEY * 2 - 1 ), density ); m.save(); } diff --git a/src/trap.cpp b/src/trap.cpp index da3f2aa7bd5c0..3090ad3491820 100644 --- a/src/trap.cpp +++ b/src/trap.cpp @@ -229,7 +229,7 @@ void trap::on_disarmed( map &m, const tripoint &p ) const const std::string &item_type = std::get<0>( i ); const int quantity = std::get<1>( i ); const int charges = std::get<2>( i ); - m.spawn_item( p.x, p.y, item_type, quantity, charges ); + m.spawn_item( p.xy(), item_type, quantity, charges ); } for( const tripoint &dest : m.points_in_radius( p, trap_radius ) ) { m.remove_trap( dest ); diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 0e41b11989a52..a20580e4fed1e 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -667,7 +667,7 @@ void trapfunc::telepad( const tripoint &p, Creature *c, item * ) newposx = rng( z->posx() - SEEX, z->posx() + SEEX ); newposy = rng( z->posy() - SEEY, z->posy() + SEEY ); tries++; - } while( g->m.impassable( newposx, newposy ) && tries != 10 ); + } while( g->m.impassable( point( newposx, newposy ) ) && tries != 10 ); if( tries == 10 ) { z->die_in_explosion( nullptr ); diff --git a/src/tutorial.cpp b/src/tutorial.cpp index 53895b4e9d6df..f83c2686bbbec 100644 --- a/src/tutorial.cpp +++ b/src/tutorial.cpp @@ -117,7 +117,7 @@ void tutorial_game::per_turn() } if( !tutorials_seen[LESSON_BUTCHER] ) { - for( const item &it : g->m.i_at( g->u.posx(), g->u.posy() ) ) { + for( const item &it : g->m.i_at( point( g->u.posx(), g->u.posy() ) ) ) { if( it.is_corpse() ) { add_message( LESSON_BUTCHER ); break; @@ -137,7 +137,7 @@ void tutorial_game::per_turn() } else if( g->m.ter( x, y ) == t_window ) { add_message( LESSON_SMASH ); showed_message = true; - } else if( g->m.furn( x, y ) == f_rack && !g->m.i_at( x, y ).empty() ) { + } else if( g->m.furn( x, y ) == f_rack && !g->m.i_at( point( x, y ) ).empty() ) { add_message( LESSON_EXAMINE ); showed_message = true; } else if( g->m.ter( x, y ) == t_stairs_down ) { @@ -150,7 +150,7 @@ void tutorial_game::per_turn() } } - if( !g->m.i_at( g->u.posx(), g->u.posy() ).empty() ) { + if( !g->m.i_at( point( g->u.posx(), g->u.posy() ) ).empty() ) { add_message( LESSON_PICKUP ); } } diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index c2ff59d7443d9..1471315ba85a2 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -3140,7 +3140,7 @@ void veh_interact::complete_vehicle() } // Place the removed wheel on the map last so consume_vpart_item() doesn't pick it. if( !broken ) { - g->m.add_item_or_charges( g->u.posx(), g->u.posy(), removed_wheel ); + g->m.add_item_or_charges( point( g->u.posx(), g->u.posy() ), removed_wheel ); } add_msg( _( "You replace one of the %1$s's tires with a %2$s." ), veh->name, veh->parts[ partnum ].name() ); diff --git a/tests/npc_talk_test.cpp b/tests/npc_talk_test.cpp index 5c0087ab5c279..45807eb7c4873 100644 --- a/tests/npc_talk_test.cpp +++ b/tests/npc_talk_test.cpp @@ -39,7 +39,7 @@ static const trait_id trait_PROF_SWAT( "PROF_SWAT" ); static npc &create_test_talker() { const string_id test_talker( "test_talker" ); - const int model_id = g->m.place_npc( 25, 25, test_talker, true ); + const int model_id = g->m.place_npc( point( 25, 25 ), test_talker, true ); g->load_npcs(); npc *model_npc = g->find_npc( model_id ); diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index c47f2d17d6aec..ec59a3b7b7e4c 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -440,7 +440,7 @@ TEST_CASE( "npc_can_target_player" ) const auto spawn_npc = []( const int x, const int y, const std::string & npc_class ) { const string_id test_guy( npc_class ); - const int model_id = g->m.place_npc( 10, 10, test_guy, true ); + const int model_id = g->m.place_npc( point( 10, 10 ), test_guy, true ); g->load_npcs(); npc *guy = g->find_npc( model_id ); From 8a9899e8c2fac1561486fdda32d7f632841422f2 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 14:11:56 -0400 Subject: [PATCH 016/113] Use coordinate transform in map spawn function Don't roll our own coordinate transformations. --- src/map.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/map.cpp b/src/map.cpp index 3c4463026dc04..e0f54204e2fc1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -7453,8 +7453,10 @@ void map::spawn_monsters_submap( const tripoint &gp, bool ignore_sight ) } submap *const current_submap = get_submap_at_grid( gp ); + const tripoint gp_ms = sm_to_ms_copy( gp ); + for( auto &i : current_submap->spawns ) { - const tripoint center( i.pos.x + gp.x * SEEX, i.pos.y + gp.y * SEEX, gp.z ); + const tripoint center = gp_ms + i.pos; const tripoint_range points = points_in_radius( center, 3 ); for( int j = 0; j < i.count; j++ ) { From 386e8fb4c32fa37dc2e74f741d2c90026d8d61d7 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 17:16:45 -0400 Subject: [PATCH 017/113] Port map function implementations --- src/drawing_primitives.h | 9 ++ src/map.cpp | 191 +++++++++++++++++++-------------------- src/map.h | 73 +-------------- src/mapgen.cpp | 89 +++++++++--------- 4 files changed, 150 insertions(+), 212 deletions(-) diff --git a/src/drawing_primitives.h b/src/drawing_primitives.h index 4b66954914704..37d21c8f09c37 100644 --- a/src/drawing_primitives.h +++ b/src/drawing_primitives.h @@ -4,14 +4,23 @@ #include +struct point; +struct rl_vec2d; + void draw_line( std::functionset, int x1, int y1, int x2, int y2 ); +void draw_line( std::functionset, const point &p1, const point &p2 ); void draw_square( std::functionset, int x1, int y1, int x2, int y2 ); +void draw_square( std::functionset, const point &p1, + const point &p2 ); void draw_rough_circle( std::functionset, int x, int y, int rad ); +void draw_rough_circle( std::functionset, const point &p, int rad ); void draw_circle( std::functionset, double x, double y, double rad ); +void draw_circle( std::functionset, const rl_vec2d &p, double rad ); void draw_circle( std::functionset, int x, int y, int rad ); +void draw_circle( std::functionset, const point &p, int rad ); #endif diff --git a/src/map.cpp b/src/map.cpp index e0f54204e2fc1..0f7e10141948e 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1640,24 +1640,23 @@ int map::move_cost_internal( const furn_t &furniture, const ter_t &terrain, cons // Move cost: 2D overloads -int map::move_cost( const int x, const int y, const vehicle *ignored_vehicle ) const +int map::move_cost( const point &p, const vehicle *ignored_vehicle ) const { - return move_cost( tripoint( x, y, abs_sub.z ), ignored_vehicle ); + return move_cost( tripoint( p, abs_sub.z ), ignored_vehicle ); } -bool map::impassable( const int x, const int y ) const +bool map::impassable( const point &p ) const { - return !passable( point( x, y ) ); + return !passable( p ); } -bool map::passable( const int x, const int y ) const +bool map::passable( const point &p ) const { - return passable( tripoint( x, y, abs_sub.z ) ); + return passable( tripoint( p, abs_sub.z ) ); } -int map::move_cost_ter_furn( const int x, const int y ) const +int map::move_cost_ter_furn( const point &p ) const { - const point p( x, y ); if( !inbounds( p ) ) { return 0; } @@ -4034,9 +4033,8 @@ void map::set_temperature( const int x, const int y, int new_temperature ) } // Items: 2D -map_stack map::i_at( const int x, const int y ) +map_stack map::i_at( const point &p ) { - const point p( x, y ); if( !inbounds( p ) ) { nulitems.clear(); return map_stack{ &nulitems, tripoint( p, abs_sub.z ), this }; @@ -4053,43 +4051,43 @@ map_stack::iterator map::i_rem( const point &location, map_stack::const_iterator return i_rem( tripoint( location, abs_sub.z ), it ); } -void map::i_rem( const int x, const int y, item *it ) +void map::i_rem( const point &p, item *it ) { - i_rem( tripoint( x, y, abs_sub.z ), it ); + i_rem( tripoint( p, abs_sub.z ), it ); } -void map::i_clear( const int x, const int y ) +void map::i_clear( const point &p ) { - i_clear( tripoint( x, y, abs_sub.z ) ); + i_clear( tripoint( p, abs_sub.z ) ); } -void map::spawn_an_item( const int x, const int y, item new_item, +void map::spawn_an_item( const point &p, item new_item, const int charges, const int damlevel ) { - spawn_an_item( tripoint( x, y, abs_sub.z ), new_item, charges, damlevel ); + spawn_an_item( tripoint( p, abs_sub.z ), new_item, charges, damlevel ); } -void map::spawn_items( const int x, const int y, const std::vector &new_items ) +void map::spawn_items( const point &p, const std::vector &new_items ) { - spawn_items( tripoint( x, y, abs_sub.z ), new_items ); + spawn_items( tripoint( p, abs_sub.z ), new_items ); } -void map::spawn_item( const int x, const int y, const std::string &type_id, +void map::spawn_item( const point &p, const std::string &type_id, const unsigned quantity, const int charges, const time_point &birthday, const int damlevel ) { - spawn_item( tripoint( x, y, abs_sub.z ), type_id, + spawn_item( tripoint( p, abs_sub.z ), type_id, quantity, charges, birthday, damlevel ); } -item &map::add_item_or_charges( const int x, const int y, item obj, bool overflow ) +item &map::add_item_or_charges( const point &p, item obj, bool overflow ) { - return add_item_or_charges( tripoint( x, y, abs_sub.z ), obj, overflow ); + return add_item_or_charges( tripoint( p, abs_sub.z ), obj, overflow ); } -void map::add_item( const int x, const int y, item new_item ) +void map::add_item( const point &p, item new_item ) { - add_item( tripoint( x, y, abs_sub.z ), new_item ); + add_item( tripoint( p, abs_sub.z ), new_item ); } // Items: 3D @@ -5062,18 +5060,17 @@ std::list map::use_charges( const tripoint &origin, const int range, return ret; } -std::list > map::get_rc_items( int x, int y, int z ) +std::list > map::get_rc_items( const tripoint &p ) { std::list > rc_pairs; tripoint pos; - ( void )z; pos.z = abs_sub.z; for( pos.x = 0; pos.x < MAPSIZE_X; pos.x++ ) { - if( x != -1 && x != pos.x ) { + if( p.x != -1 && p.x != pos.x ) { continue; } for( pos.y = 0; pos.y < MAPSIZE_Y; pos.y++ ) { - if( y != -1 && y != pos.y ) { + if( p.y != -1 && p.y != pos.y ) { continue; } auto items = i_at( pos ); @@ -6679,33 +6676,31 @@ void map::vertical_shift( const int newz ) // 0,2 1,2 2,2 // (worldx,worldy,worldz) denotes the absolute coordinate of the submap // in grid[0]. -void map::saven( const int gridx, const int gridy, const int gridz ) +void map::saven( const tripoint &grid ) { dbg( D_INFO ) << "map::saven(worldx[" << abs_sub.x << "], worldy[" << abs_sub.y << "], worldz[" << abs_sub.z - << "], gridx[" << gridx << "], gridy[" << gridy << "], gridz[" << gridz << "])"; - const int gridn = get_nonant( { gridx, gridy, gridz } ); + << "], gridx[" << grid.x << "], gridy[" << grid.y << "], gridz[" << grid.z << "])"; + const int gridn = get_nonant( grid ); submap *submap_to_save = getsubmap( gridn ); if( submap_to_save == nullptr || submap_to_save->get_ter( point_zero ) == t_null ) { // This is a serious error and should be signaled as soon as possible - debugmsg( "map::saven grid (%d,%d,%d) %s!", gridx, gridy, gridz, + debugmsg( "map::saven grid (%d,%d,%d) %s!", grid.x, grid.y, grid.z, submap_to_save == nullptr ? "null" : "uninitialized" ); return; } - const int abs_x = abs_sub.x + gridx; - const int abs_y = abs_sub.y + gridy; - const int abs_z = gridz; + const tripoint abs = abs_sub.xy() + grid; - if( !zlevels && gridz != abs_sub.z ) { + if( !zlevels && grid.z != abs_sub.z ) { debugmsg( "Tried to save submap (%d,%d,%d) as (%d,%d,%d), which isn't supported in non-z-level builds", - abs_x, abs_y, abs_sub.z, abs_x, abs_y, gridz ); + abs.x, abs.y, abs_sub.z, abs.x, abs.y, grid.z ); } - dbg( D_INFO ) << "map::saven abs_x: " << abs_x << " abs_y: " << abs_y << " abs_z: " << abs_z + dbg( D_INFO ) << "map::saven abs: " << abs << " gridn: " << gridn; submap_to_save->last_touched = calendar::turn; - MAPBUFFER.add_submap( tripoint( abs_x, abs_y, abs_z ), submap_to_save ); + MAPBUFFER.add_submap( abs, submap_to_save ); } // worldx & worldy specify where in the world this is; @@ -6715,20 +6710,20 @@ void map::saven( const int gridx, const int gridy, const int gridz ) // 0,2 1,2 2,2 etc // (worldx,worldy,worldz) denotes the absolute coordinate of the submap // in grid[0]. -void map::loadn( const int gridx, const int gridy, const bool update_vehicles ) +void map::loadn( const point &grid, const bool update_vehicles ) { if( zlevels ) { for( int gridz = -OVERMAP_DEPTH; gridz <= OVERMAP_HEIGHT; gridz++ ) { - loadn( tripoint( gridx, gridy, gridz ), update_vehicles ); + loadn( tripoint( grid, gridz ), update_vehicles ); } // Note: we want it in a separate loop! It is a post-load cleanup // Since we're adding roofs, we want it to go up (from lowest to highest) for( int gridz = -OVERMAP_DEPTH; gridz <= OVERMAP_HEIGHT; gridz++ ) { - add_roofs( tripoint( gridx, gridy, gridz ) ); + add_roofs( tripoint( grid, gridz ) ); } } else { - loadn( tripoint( gridx, gridy, abs_sub.z ), update_vehicles ); + loadn( tripoint( grid, abs_sub.z ), update_vehicles ); } } @@ -6751,23 +6746,22 @@ static void generate_uniform( const tripoint &p, const ter_id &terrain_type ) } } -void map::loadn( const int gridx, const int gridy, const int gridz, const bool update_vehicles ) +void map::loadn( const tripoint &grid, const bool update_vehicles ) { // Cache empty overmap types static const oter_id rock( "empty_rock" ); static const oter_id air( "open_air" ); dbg( D_INFO ) << "map::loadn(game[" << g.get() << "], worldx[" << abs_sub.x - << "], worldy[" << abs_sub.y << "], gridx[" - << gridx << "], gridy[" << gridy << "], gridz[" << gridz << "])"; + << "], worldy[" << abs_sub.y << "], grid " << grid << ")"; - const tripoint grid_abs_sub( abs_sub.x + gridx, abs_sub.y + gridy, gridz ); - const size_t gridn = get_nonant( { gridx, gridy, gridz } ); + const tripoint grid_abs_sub = abs_sub.xy() + grid; + const size_t gridn = get_nonant( grid ); dbg( D_INFO ) << "map::loadn grid_abs_sub: " << grid_abs_sub << " gridn: " << gridn; const int old_abs_z = abs_sub.z; // Ugly, but necessary at the moment - abs_sub.z = gridz; + abs_sub.z = grid.z; submap *tmpsub = MAPBUFFER.lookup_submap( grid_abs_sub ); if( tmpsub == nullptr ) { @@ -6802,16 +6796,16 @@ void map::loadn( const int gridx, const int gridy, const int gridz, const bool u } // New submap changes the content of the map and all caches must be recalculated - set_transparency_cache_dirty( gridz ); - set_outside_cache_dirty( gridz ); - set_floor_cache_dirty( gridz ); - set_pathfinding_cache_dirty( gridz ); + set_transparency_cache_dirty( grid.z ); + set_outside_cache_dirty( grid.z ); + set_floor_cache_dirty( grid.z ); + set_pathfinding_cache_dirty( grid.z ); setsubmap( gridn, tmpsub ); if( !tmpsub->active_items.empty() ) { submaps_with_active_items.emplace( grid_abs_sub ); } if( tmpsub->field_count > 0 ) { - get_cache( gridz ).field_cache.set( gridx + gridy * MAPSIZE ); + get_cache( grid.z ).field_cache.set( grid.x + grid.y * MAPSIZE ); } // Destroy bugged no-part vehicles auto &veh_vec = tmpsub->vehicles; @@ -6819,10 +6813,10 @@ void map::loadn( const int gridx, const int gridy, const int gridz, const bool u vehicle *veh = iter->get(); if( !veh->parts.empty() ) { // Always fix submap coordinates for easier Z-level-related operations - veh->sm_pos = tripoint( gridx, gridy, gridz ); + veh->sm_pos = grid; iter++; } else { - reset_vehicle_cache( gridz ); + reset_vehicle_cache( grid.z ); if( veh->tracking_on ) { overmap_buffer.remove_vehicle( veh ); } @@ -6833,7 +6827,7 @@ void map::loadn( const int gridx, const int gridy, const int gridz, const bool u // Update vehicle data if( update_vehicles ) { - auto &map_cache = get_cache( gridz ); + auto &map_cache = get_cache( grid.z ); for( const auto &veh : tmpsub->vehicles ) { // Only add if not tracking already. if( map_cache.vehicle_list.find( veh.get() ) == map_cache.vehicle_list.end() ) { @@ -6846,7 +6840,7 @@ void map::loadn( const int gridx, const int gridy, const int gridz, const bool u } } - actualize( tripoint( gridx, gridy, gridz ) ); + actualize( grid ); abs_sub.z = old_abs_z; } @@ -7198,21 +7192,21 @@ void map::decay_cosmetic_fields( const tripoint &p, const time_duration &time_si } } -void map::actualize( const int gridx, const int gridy, const int gridz ) +void map::actualize( const tripoint &grid ) { - submap *const tmpsub = get_submap_at_grid( {gridx, gridy, gridz} ); + submap *const tmpsub = get_submap_at_grid( grid ); if( tmpsub == nullptr ) { - debugmsg( "Actualize called on null submap (%d,%d,%d)", gridx, gridy, gridz ); + debugmsg( "Actualize called on null submap (%d,%d,%d)", grid.x, grid.y, grid.z ); return; } const time_duration time_since_last_actualize = calendar::turn - tmpsub->last_touched; - const bool do_funnels = ( gridz >= 0 ); + const bool do_funnels = ( grid.z >= 0 ); // check spoiled stuff, and fill up funnels while we're at it for( int x = 0; x < SEEX; x++ ) { for( int y = 0; y < SEEY; y++ ) { - const tripoint pnt( gridx * SEEX + x, gridy * SEEY + y, gridz ); + const tripoint pnt = sm_to_ms_copy( grid ) + point( x, y ); const point p( x, y ); const auto &furn = this->furn( pnt ).obj(); if( furn.has_flag( "EMITTER" ) ) { @@ -7252,7 +7246,7 @@ void map::actualize( const int gridx, const int gridy, const int gridz ) tmpsub->last_touched = calendar::turn; } -void map::add_roofs( const int gridx, const int gridy, const int gridz ) +void map::add_roofs( const tripoint &grid ) { if( !zlevels ) { // No roofs required! @@ -7260,20 +7254,20 @@ void map::add_roofs( const int gridx, const int gridy, const int gridz ) return; } - submap *const sub_here = get_submap_at_grid( {gridx, gridy, gridz} ); + submap *const sub_here = get_submap_at_grid( grid ); if( sub_here == nullptr ) { debugmsg( "Tried to add roofs/floors on null submap on %d,%d,%d", - gridx, gridy, gridz ); + grid.x, grid.y, grid.z ); return; } - bool check_roof = gridz > -OVERMAP_DEPTH; + bool check_roof = grid.z > -OVERMAP_DEPTH; - submap *const sub_below = check_roof ? get_submap_at_grid( { gridx, gridy, gridz - 1 } ) : nullptr; + submap *const sub_below = check_roof ? get_submap_at_grid( grid + tripoint_below ) : nullptr; if( check_roof && sub_below == nullptr ) { debugmsg( "Tried to add roofs to sm at %d,%d,%d, but sm below doesn't exist", - gridx, gridy, gridz ); + grid.x, grid.y, grid.z ); return; } @@ -8094,18 +8088,18 @@ tinymap::tinymap( int mapsize, bool zlevels ) { } -void map::draw_line_ter( const ter_id type, int x1, int y1, int x2, int y2 ) +void map::draw_line_ter( const ter_id type, const point &p1, const point &p2 ) { draw_line( [this, type]( int x, int y ) { this->ter_set( point( x, y ), type ); - }, x1, y1, x2, y2 ); + }, p1, p2 ); } -void map::draw_line_furn( const furn_id type, int x1, int y1, int x2, int y2 ) +void map::draw_line_furn( const furn_id type, const point &p1, const point &p2 ) { draw_line( [this, type]( int x, int y ) { this->furn_set( point( x, y ), type ); - }, x1, y1, x2, y2 ); + }, p1, p2 ); } void map::draw_fill_background( const ter_id type ) @@ -8135,68 +8129,68 @@ void map::draw_fill_background( const weighted_int_list &f ) draw_square_ter( f, point_zero, point( SEEX * my_MAPSIZE - 1, SEEY * my_MAPSIZE - 1 ) ); } -void map::draw_square_ter( const ter_id type, int x1, int y1, int x2, int y2 ) +void map::draw_square_ter( const ter_id type, const point &p1, const point &p2 ) { draw_square( [this, type]( int x, int y ) { this->ter_set( point( x, y ), type ); - }, x1, y1, x2, y2 ); + }, p1, p2 ); } -void map::draw_square_furn( const furn_id type, int x1, int y1, int x2, int y2 ) +void map::draw_square_furn( const furn_id type, const point &p1, const point &p2 ) { draw_square( [this, type]( int x, int y ) { this->furn_set( point( x, y ), type ); - }, x1, y1, x2, y2 ); + }, p1, p2 ); } -void map::draw_square_ter( ter_id( *f )(), int x1, int y1, int x2, int y2 ) +void map::draw_square_ter( ter_id( *f )(), const point &p1, const point &p2 ) { draw_square( [this, f]( int x, int y ) { this->ter_set( point( x, y ), f() ); - }, x1, y1, x2, y2 ); + }, p1, p2 ); } -void map::draw_square_ter( const weighted_int_list &f, int x1, int y1, int x2, int y2 ) +void map::draw_square_ter( const weighted_int_list &f, const point &p1, const point &p2 ) { draw_square( [this, f]( int x, int y ) { const ter_id *tid = f.pick(); this->ter_set( point( x, y ), tid != nullptr ? *tid : t_null ); - }, x1, y1, x2, y2 ); + }, p1, p2 ); } -void map::draw_rough_circle_ter( const ter_id type, int x, int y, int rad ) +void map::draw_rough_circle_ter( const ter_id type, const point &p, int rad ) { draw_rough_circle( [this, type]( int x, int y ) { this->ter_set( point( x, y ), type ); - }, x, y, rad ); + }, p, rad ); } -void map::draw_rough_circle_furn( const furn_id type, int x, int y, int rad ) +void map::draw_rough_circle_furn( const furn_id type, const point &p, int rad ) { draw_rough_circle( [this, type]( int x, int y ) { this->furn_set( point( x, y ), type ); - }, x, y, rad ); + }, p, rad ); } -void map::draw_circle_ter( const ter_id type, double x, double y, double rad ) +void map::draw_circle_ter( const ter_id type, const rl_vec2d &p, double rad ) { draw_circle( [this, type]( int x, int y ) { this->ter_set( point( x, y ), type ); - }, x, y, rad ); + }, p, rad ); } -void map::draw_circle_ter( const ter_id type, int x, int y, int rad ) +void map::draw_circle_ter( const ter_id type, const point &p, int rad ) { draw_circle( [this, type]( int x, int y ) { this->ter_set( point( x, y ), type ); - }, x, y, rad ); + }, p, rad ); } -void map::draw_circle_furn( const furn_id type, int x, int y, int rad ) +void map::draw_circle_furn( const furn_id type, const point &p, int rad ) { draw_circle( [this, type]( int x, int y ) { this->furn_set( point( x, y ), type ); - }, x, y, rad ); + }, p, rad ); } void map::add_corpse( const tripoint &p ) @@ -8309,7 +8303,7 @@ void map::function_over( const int stx, const int sty, const int stz, void map::scent_blockers( std::array, MAPSIZE_Y> &blocks_scent, std::array, MAPSIZE_Y> &reduces_scent, - const int minx, const int miny, const int maxx, const int maxy ) + const point &min, const point &max ) { auto reduce = TFLAG_REDUCE_SCENT; auto block = TFLAG_WALL; @@ -8332,21 +8326,18 @@ void map::scent_blockers( std::array, MAPSIZE_Y> &bl return ITER_CONTINUE; }; - function_over( minx, miny, abs_sub.z, maxx, maxy, abs_sub.z, fill_values ); + function_over( min.x, min.y, abs_sub.z, max.x, max.y, abs_sub.z, fill_values ); - // Now vehicles + const rectangle local_bounds( min, max ); - // Currently the scentmap is limited to an area around the player rather than entire map - auto local_bounds = [ = ]( const tripoint & coord ) { - return coord.x >= minx && coord.x <= maxx && coord.y >= miny && coord.y <= maxy; - }; + // Now vehicles auto vehs = get_vehicles(); for( auto &wrapped_veh : vehs ) { vehicle &veh = *( wrapped_veh.v ); for( const vpart_reference &vp : veh.get_any_parts( VPFLAG_OBSTACLE ) ) { const tripoint part_pos = vp.pos(); - if( local_bounds( part_pos ) ) { + if( local_bounds.contains_inclusive( part_pos.xy() ) ) { reduces_scent[part_pos.x][part_pos.y] = true; } } @@ -8358,7 +8349,7 @@ void map::scent_blockers( std::array, MAPSIZE_Y> &bl } const tripoint part_pos = vp.pos(); - if( local_bounds( part_pos ) ) { + if( local_bounds.contains_inclusive( part_pos.xy() ) ) { reduces_scent[part_pos.x][part_pos.y] = true; } } diff --git a/src/map.h b/src/map.h index 6bc62910f0087..3400464047da2 100644 --- a/src/map.h +++ b/src/map.h @@ -45,6 +45,7 @@ class optional_vpart_position; class player; class monster; class Creature; +struct rl_vec2d; class tripoint_range; class field; @@ -384,13 +385,9 @@ class map // Movement and LOS // Move cost: 2D overloads - int move_cost( int x, int y, const vehicle *ignored_vehicle = nullptr ) const; int move_cost( const point &p, const vehicle *ignored_vehicle = nullptr ) const; - bool impassable( int x, int y ) const; bool impassable( const point &p ) const; - bool passable( int x, int y ) const; bool passable( const point &p ) const; - int move_cost_ter_furn( int x, int y ) const; int move_cost_ter_furn( const point &p ) const; // Move cost: 3D @@ -812,36 +809,20 @@ class map point random_outdoor_tile(); // mapgen - void draw_line_ter( ter_id type, int x1, int y1, int x2, int y2 ); - void draw_line_ter( ter_id type, const point &p1, int x2, int y2 ); void draw_line_ter( ter_id type, const point &p1, const point &p2 ); - void draw_line_furn( furn_id type, int x1, int y1, int x2, int y2 ); - void draw_line_furn( furn_id type, const point &p1, int x2, int y2 ); void draw_line_furn( furn_id type, const point &p1, const point &p2 ); void draw_fill_background( ter_id type ); void draw_fill_background( ter_id( *f )() ); void draw_fill_background( const weighted_int_list &f ); - void draw_square_ter( ter_id type, int x1, int y1, int x2, int y2 ); - void draw_square_ter( ter_id type, const point &p1, int x2, int y2 ); void draw_square_ter( ter_id type, const point &p1, const point &p2 ); - void draw_square_furn( furn_id type, int x1, int y1, int x2, int y2 ); - void draw_square_furn( furn_id type, const point &p1, int x2, int y2 ); void draw_square_furn( furn_id type, const point &p1, const point &p2 ); - void draw_square_ter( ter_id( *f )(), int x1, int y1, int x2, int y2 ); - void draw_square_ter( ter_id( *f )(), const point &p1, int x2, int y2 ); void draw_square_ter( ter_id( *f )(), const point &p1, const point &p2 ); - void draw_square_ter( const weighted_int_list &f, int x1, int y1, int x2, int y2 ); - void draw_square_ter( const weighted_int_list &f, const point &p1, int x2, int y2 ); void draw_square_ter( const weighted_int_list &f, const point &p1, const point &p2 ); - void draw_rough_circle_ter( ter_id type, int x, int y, int rad ); - void draw_rough_circle_furn( furn_id type, int x, int y, int rad ); - void draw_circle_ter( ter_id type, double x, double y, double rad ); - void draw_circle_ter( ter_id type, int x, int y, int rad ); - void draw_circle_furn( furn_id type, int x, int y, int rad ); void draw_rough_circle_ter( ter_id type, const point &p, int rad ); void draw_rough_circle_furn( furn_id type, const point &p, int rad ); + void draw_circle_ter( ter_id type, const rl_vec2d &p, double rad ); void draw_circle_ter( ter_id type, const point &p, int rad ); void draw_circle_furn( furn_id type, const point &p, int rad ); @@ -938,42 +919,23 @@ class map void trigger_rc_items( const std::string &signal ); // Items: 2D - map_stack i_at( int x, int y ); map_stack i_at( const point &p ); - void i_clear( int x, int y ); void i_clear( const point &p ); map_stack::iterator i_rem( const point &location, map_stack::const_iterator it ); - void i_rem( int x, int y, item *it ); void i_rem( const point &p, item *it ); - void spawn_item( int x, int y, const std::string &itype_id, - unsigned quantity = 1, int charges = 0, - const time_point &birthday = calendar::turn_zero, int damlevel = 0 ); void spawn_item( const point &p, const std::string &itype_id, unsigned quantity = 1, int charges = 0, const time_point &birthday = calendar::turn_zero, int damlevel = 0 ); - item &add_item_or_charges( int x, int y, item obj, bool overflow = true ); item &add_item_or_charges( const point &p, item obj, bool overflow = true ); - void add_item( int x, int y, item new_item ); void add_item( const point &p, item new_item ); - void spawn_an_item( int x, int y, item new_item, - int charges, int damlevel ); void spawn_an_item( const point &p, item new_item, int charges, int damlevel ); - std::vector place_items( const items_location &loc, int chance, int x1, - int y1, - int x2, int y2, bool ongrass, const time_point &turn, - int magazine = 0, int ammo = 0 ); - std::vector place_items( const items_location &loc, int chance, const point &p1, - int x2, int y2, bool ongrass, const time_point &turn, - int magazine = 0, int ammo = 0 ); std::vector place_items( const items_location &loc, int chance, const point &p1, const point &p2, bool ongrass, const time_point &turn, int magazine = 0, int ammo = 0 ); - void spawn_items( int x, int y, const std::vector &new_items ); void spawn_items( const point &p, const std::vector &new_items ); - void create_anomaly( int cx, int cy, artifact_natural_property prop ); void create_anomaly( const point &c, artifact_natural_property prop ); // Items: 3D // Accessor that returns a wrapped reference to an item stack for safe modification. @@ -1046,8 +1008,7 @@ class map int &amount, const std::function &filter = return_true, basecamp *bcp = nullptr ); /*@}*/ - std::list > get_rc_items( int x = -1, int y = -1, int z = -1 ); - std::list > get_rc_items( const tripoint &p ); + std::list > get_rc_items( const tripoint &p = { -1, -1, -1 } ); /** * Place items from item group in the rectangle f - t. Several items may be spawned @@ -1213,12 +1174,6 @@ class map * Build the map of scent-resistant tiles. * Should be way faster than if done in `game.cpp` using public map functions. */ - void scent_blockers( std::array, MAPSIZE_Y> &blocks_scent, - std::array, MAPSIZE_Y> &reduces_scent, - int minx, int miny, int maxx, int maxy ); - void scent_blockers( std::array, MAPSIZE_Y> &blocks_scent, - std::array, MAPSIZE_Y> &reduces_scent, - int minx, int miny, const point &max ); void scent_blockers( std::array, MAPSIZE_Y> &blocks_scent, std::array, MAPSIZE_Y> &reduces_scent, const point &min, const point &max ); @@ -1281,34 +1236,17 @@ class map void generate( const tripoint &p, const time_point &when ) { generate( p.x, p.y, p.z, when ); } - void place_spawns( const mongroup_id &group, int chance, - int x1, int y1, int x2, int y2, float intensity, - bool individual = false, bool friendly = false ); - void place_spawns( const mongroup_id &group, int chance, - const point &p1, int x2, int y2, float intensity, - bool individual = false, bool friendly = false ); void place_spawns( const mongroup_id &group, int chance, const point &p1, const point &p2, float intensity, bool individual = false, bool friendly = false ); - void place_gas_pump( int x, int y, int charges ); void place_gas_pump( const point &p, int charges ); - void place_gas_pump( int x, int y, int charges, const std::string &fuel_type ); void place_gas_pump( const point &p, int charges, const std::string &fuel_type ); // 6 liters at 250 ml per charge - void place_toilet( int x, int y, int charges = 6 * 4 ); void place_toilet( const point &p, int charges = 6 * 4 ); - void place_vending( int x, int y, const std::string &type, bool reinforced = false ); void place_vending( const point &p, const std::string &type, bool reinforced = false ); // places an NPC, if static NPCs are enabled or if force is true - int place_npc( int x, int y, const string_id &type, bool force = false ); int place_npc( const point &p, const string_id &type, bool force = false ); - void apply_faction_ownership( int x1, int y1, int x2, int y2, faction_id id ); - void apply_faction_ownership( const point &p1, int x2, int y2, faction_id id ); void apply_faction_ownership( const point &p1, const point &p2, faction_id id ); - void add_spawn( const mtype_id &type, int count, int x, int y, - bool friendly = false, - int faction_id = -1, int mission_id = -1, - const std::string &name = "NONE" ); void add_spawn( const mtype_id &type, int count, const point &p, bool friendly = false, int faction_id = -1, int mission_id = -1, @@ -1428,22 +1366,17 @@ class map void spawn_monsters_submap_group( const tripoint &gp, mongroup &group, bool ignore_sight ); protected: - void saven( int gridx, int gridy, int gridz ); void saven( const tripoint &grid ); - void loadn( int gridx, int gridy, bool update_vehicles ); void loadn( const point &grid, bool update_vehicles ); - void loadn( int gridx, int gridy, int gridz, bool update_vehicles ); void loadn( const tripoint &grid, bool update_vehicles ); /** * Fast forward a submap that has just been loading into this map. * This is used to rot and remove rotten items, grow plants, fill funnels etc. */ - void actualize( int gridx, int gridy, int gridz ); void actualize( const tripoint &grid ); /** * Hacks in missing roofs. Should be removed when 3D mapgen is done. */ - void add_roofs( int gridx, int gridy, int gridz ); void add_roofs( const tripoint &grid ); /** * Whether the item has to be removed as it has rotten away completely. diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 51d851d4ada10..36116d0e44e31 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -6789,7 +6789,7 @@ void map::draw_connections( const oter_id &terrain_type, mapgendata &dat, } void map::place_spawns( const mongroup_id &group, const int chance, - const int x1, const int y1, const int x2, const int y2, const float density, + const point &p1, const point &p2, const float density, const bool individual, const bool friendly ) { if( !group.is_valid() ) { @@ -6825,8 +6825,8 @@ void map::place_spawns( const mongroup_id &group, const int chance, // Pick a spot for the spawn do { - x = rng( x1, x2 ); - y = rng( y1, y2 ); + x = rng( p1.x, p2.x ); + y = rng( p1.y, p2.y ); tries--; } while( impassable( point( x, y ) ) && tries > 0 ); @@ -6837,7 +6837,7 @@ void map::place_spawns( const mongroup_id &group, const int chance, } } -void map::place_gas_pump( int x, int y, int charges ) +void map::place_gas_pump( const point &p, int charges ) { std::string fuel_type; if( one_in( 4 ) ) { @@ -6845,42 +6845,42 @@ void map::place_gas_pump( int x, int y, int charges ) } else { fuel_type = "gasoline"; } - place_gas_pump( point( x, y ), charges, fuel_type ); + place_gas_pump( p, charges, fuel_type ); } -void map::place_gas_pump( int x, int y, int charges, const std::string &fuel_type ) +void map::place_gas_pump( const point &p, int charges, const std::string &fuel_type ) { item fuel( fuel_type, 0 ); fuel.charges = charges; - add_item( point( x, y ), fuel ); - ter_set( point( x, y ), ter_id( fuel.fuel_pump_terrain() ) ); + add_item( p, fuel ); + ter_set( p, ter_id( fuel.fuel_pump_terrain() ) ); } -void map::place_toilet( int x, int y, int charges ) +void map::place_toilet( const point &p, int charges ) { item water( "water", 0 ); water.charges = charges; - add_item( point( x, y ), water ); - furn_set( point( x, y ), f_toilet ); + add_item( p, water ); + furn_set( p, f_toilet ); } -void map::place_vending( int x, int y, const std::string &type, bool reinforced ) +void map::place_vending( const point &p, const std::string &type, bool reinforced ) { if( reinforced ) { - furn_set( point( x, y ), f_vending_reinforced ); - place_items( type, 100, point( x, y ), point( x, y ), false, 0 ); + furn_set( p, f_vending_reinforced ); + place_items( type, 100, p, p, false, 0 ); } else { const bool broken = one_in( 5 ); if( broken ) { - furn_set( point( x, y ), f_vending_o ); + furn_set( p, f_vending_o ); } else { - furn_set( point( x, y ), f_vending_c ); - place_items( type, 100, point( x, y ), point( x, y ), false, 0 ); + furn_set( p, f_vending_c ); + place_items( type, 100, p, p, false, 0 ); } } } -int map::place_npc( int x, int y, const string_id &type, bool force ) +int map::place_npc( const point &p, const string_id &type, bool force ) { if( !force && !get_option( "STATIC_NPC" ) ) { return -1; //Do not generate an npc. @@ -6888,17 +6888,17 @@ int map::place_npc( int x, int y, const string_id &type, bool forc std::shared_ptr temp = std::make_shared(); temp->normalize(); temp->load_npc_template( type ); - temp->spawn_at_precise( { abs_sub.xy() }, { x, y, abs_sub.z } ); + temp->spawn_at_precise( { abs_sub.xy() }, { p, abs_sub.z } ); temp->toggle_trait( trait_id( "NPC_STATIC_NPC" ) ); overmap_buffer.insert_npc( temp ); return temp->getID(); } -void map::apply_faction_ownership( const int x1, const int y1, const int x2, const int y2, +void map::apply_faction_ownership( const point &p1, const point &p2, const faction_id id ) { faction *fac = g->faction_manager_ptr->get( id ); - for( const tripoint &p : points_in_rectangle( tripoint( x1, y1, abs_sub.z ), tripoint( x2, y2, + for( const tripoint &p : points_in_rectangle( tripoint( p1, abs_sub.z ), tripoint( p2, abs_sub.z ) ) ) { auto items = i_at( p.xy() ); for( item &elem : items ) { @@ -6924,8 +6924,8 @@ std::vector map::place_items( const items_location &loc, const int chanc // A chance of 100 indicates that items should always spawn, // the item group should be responsible for determining the amount of items. -std::vector map::place_items( const items_location &loc, int chance, int x1, int y1, - int x2, int y2, bool ongrass, const time_point &turn, +std::vector map::place_items( const items_location &loc, int chance, const point &p1, + const point &p2, bool ongrass, const time_point &turn, int magazine, int ammo ) { std::vector res; @@ -6958,8 +6958,8 @@ std::vector map::place_items( const items_location &loc, int chance, int int px = 0; int py = 0; do { - px = rng( x1, x2 ); - py = rng( y1, y2 ); + px = rng( p1.x, p2.x ); + py = rng( p1.y, p2.y ); tries++; } while( is_valid_terrain( px, py ) && tries < 20 ); if( tries < 20 ) { @@ -6987,19 +6987,19 @@ std::vector map::put_items_from_loc( const items_location &loc, const tr return spawn_items( p, items ); } -void map::add_spawn( const mtype_id &type, int count, int x, int y, bool friendly, +void map::add_spawn( const mtype_id &type, int count, const point &p, bool friendly, int faction_id, int mission_id, const std::string &name ) { - if( x < 0 || x >= SEEX * my_MAPSIZE || y < 0 || y >= SEEY * my_MAPSIZE ) { - debugmsg( "Bad add_spawn(%s, %d, %d, %d)", type.c_str(), count, x, y ); + if( p.x < 0 || p.x >= SEEX * my_MAPSIZE || p.y < 0 || p.y >= SEEY * my_MAPSIZE ) { + debugmsg( "Bad add_spawn(%s, %d, %d, %d)", type.c_str(), count, p.x, p.y ); return; } point offset; - submap *place_on_submap = get_submap_at( { x, y }, offset ); + submap *place_on_submap = get_submap_at( p, offset ); if( !place_on_submap ) { debugmsg( "centadodecamonant doesn't exist in grid; within add_spawn(%s, %d, %d, %d)", - type.c_str(), count, x, y ); + type.c_str(), count, p.x, p.y ); return; } if( MonsterGroupManager::monster_is_blacklisted( type ) ) { @@ -7400,8 +7400,9 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) tmpcomp->add_failure( COMPFAIL_SHUTDOWN ); tmpcomp->add_failure( COMPFAIL_ALARM ); tmpcomp->add_failure( COMPFAIL_DAMAGE ); - m->place_spawns( GROUP_TURRET_SMG, 1, static_cast( ( x1 + x2 ) / 2 ), desk, - static_cast( ( x1 + x2 ) / 2 ), desk, 1, true ); + m->place_spawns( GROUP_TURRET_SMG, 1, + point( static_cast( ( x1 + x2 ) / 2 ), desk ), + point( static_cast( ( x1 + x2 ) / 2 ), desk ), 1, true ); } else { int desk = x1 + rng( static_cast( height / 2 ) - static_cast( height / 4 ), static_cast( height / 2 ) + 1 ); @@ -7415,8 +7416,9 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) tmpcomp->add_failure( COMPFAIL_SHUTDOWN ); tmpcomp->add_failure( COMPFAIL_ALARM ); tmpcomp->add_failure( COMPFAIL_DAMAGE ); - m->place_spawns( GROUP_TURRET_SMG, 1, desk, static_cast( ( y1 + y2 ) / 2 ), - desk, static_cast( ( y1 + y2 ) / 2 ), 1, true ); + m->place_spawns( GROUP_TURRET_SMG, 1, + point( desk, static_cast( ( y1 + y2 ) / 2 ) ), + point( desk, static_cast( ( y1 + y2 ) / 2 ) ), 1, true ); } break; case room_chemistry: @@ -7520,9 +7522,11 @@ void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ) } mtrap_set( m, static_cast( ( x1 + x2 ) / 2 ), static_cast( ( y1 + y2 ) / 2 ), tr_dissector ); - m->place_spawns( GROUP_LAB_CYBORG, 10, static_cast( ( ( x1 + x2 ) / 2 ) + 1 ), - static_cast( ( ( y1 + y2 ) / 2 ) + 1 ), static_cast( ( ( x1 + x2 ) / 2 ) + 1 ), - static_cast( ( ( y1 + y2 ) / 2 ) + 1 ), 1, true ); + m->place_spawns( GROUP_LAB_CYBORG, 10, + point( static_cast( ( ( x1 + x2 ) / 2 ) + 1 ), + static_cast( ( ( y1 + y2 ) / 2 ) + 1 ) ), + point( static_cast( ( ( x1 + x2 ) / 2 ) + 1 ), + static_cast( ( ( y1 + y2 ) / 2 ) + 1 ) ), 1, true ); break; case room_bionics: @@ -8079,9 +8083,9 @@ void build_mine_room( map *m, room_type type, int x1, int y1, int x2, int y2, ma } } -void map::create_anomaly( int cx, int cy, artifact_natural_property prop ) +void map::create_anomaly( const point &cp, artifact_natural_property prop ) { - create_anomaly( tripoint( cx, cy, abs_sub.z ), prop ); + create_anomaly( tripoint( cp, abs_sub.z ), prop ); } void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bool create_rubble ) @@ -8146,9 +8150,10 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo for( int i = cx - 1; i <= cx + 1; i++ ) { for( int j = cy - 1; j <= cy + 1; j++ ) { if( i == cx && j == cy ) { - place_spawns( GROUP_BREATHER_HUB, 1, i, j, i, j, 1, true ); + place_spawns( GROUP_BREATHER_HUB, 1, point( i, j ), point( i, j ), 1, + true ); } else { - place_spawns( GROUP_BREATHER, 1, i, j, i, j, 1, true ); + place_spawns( GROUP_BREATHER, 1, point( i, j ), point( i, j ), 1, true ); } } } @@ -8261,7 +8266,7 @@ void rough_circle_furn( map *m, furn_id type, int x, int y, int rad ) } void circle( map *m, ter_id type, double x, double y, double rad ) { - m->draw_circle_ter( type, x, y, rad ); + m->draw_circle_ter( type, rl_vec2d( x, y ), rad ); } void circle( map *m, ter_id type, int x, int y, int rad ) { From f05763d8a42d8cf74aa465e8627a3494bb1b7b4c Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 19:13:34 -0400 Subject: [PATCH 018/113] Refactor calls to drawing_primitives --- src/mapgen.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 36116d0e44e31..c3817f48dae5e 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -3875,7 +3875,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi ter_set( point( x, y ), fluid_type ); furn_set( point( x, y ), f_null ); } - }, rng( 1, SEEX * 2 - 2 ), rng( 1, SEEY * 2 - 2 ), rng( 3, 6 ) ); + }, point( rng( 1, SEEX * 2 - 2 ), rng( 1, SEEY * 2 - 2 ) ), rng( 3, 6 ) ); } break; } @@ -3916,7 +3916,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi } make_rubble( {x, y, abs_sub.z } ); ter_set( point( x, y ), t_thconc_floor ); - }, center.x, center.y, 4 ); + }, center.xy(), 4 ); furn_set( center.xy(), f_null ); trap_set( center, tr_portal ); create_anomaly( center, random_entry( valid_props ), false ); @@ -3931,16 +3931,16 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi } draw_rough_circle( [this]( int x, int y ) { set_radiation( x, y, 10 ); - }, center.x, center.y, rng( 7, 12 ) ); + }, center.xy(), rng( 7, 12 ) ); draw_circle( [this]( int x, int y ) { set_radiation( x, y, 20 ); - }, center.x, center.y, rng( 5, 8 ) ); + }, center.xy(), rng( 5, 8 ) ); draw_circle( [this]( int x, int y ) { set_radiation( x, y, 30 ); - }, center.x, center.y, rng( 2, 4 ) ); + }, center.xy(), rng( 2, 4 ) ); draw_circle( [this]( int x, int y ) { set_radiation( x, y, 50 ); - }, center.x, center.y, 1 ); + }, center.xy(), 1 ); draw_circle( [this]( int x, int y ) { if( has_flag_ter( "GOES_DOWN", x, y ) || has_flag_ter( "GOES_UP", x, y ) || @@ -3949,7 +3949,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi } make_rubble( {x, y, abs_sub.z } ); ter_set( point( x, y ), t_thconc_floor ); - }, center.x, center.y, 1 ); + }, center.xy(), 1 ); place_spawns( GROUP_HAZMATBOT, 1, center.xy() + point_west, center.xy() + point_west, 1, true ); @@ -4006,7 +4006,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi ter_set( point( x, y ), t_marloss ); } } - }, center.x, center.y, 3 ); + }, center.xy(), 3 ); ter_set( center.xy(), t_fungus_floor_in ); furn_set( center.xy(), f_null ); trap_set( center, tr_portal ); From 02be1d579aa8fb6e44fe803e45ca00b2a95881cc Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 19:30:18 -0400 Subject: [PATCH 019/113] Port drawing_primitives implementations --- src/drawing_primitives.cpp | 44 +++++++++++++++++++------------------- src/drawing_primitives.h | 8 +------ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/drawing_primitives.cpp b/src/drawing_primitives.cpp index 9e175a8b5d73f..ebbdcf7479926 100644 --- a/src/drawing_primitives.cpp +++ b/src/drawing_primitives.cpp @@ -8,57 +8,57 @@ #include "rng.h" #include "point.h" -void draw_line( std::functionset, int x1, int y1, int x2, int y2 ) +void draw_line( std::functionset, const point &p1, const point &p2 ) { - std::vector line = line_to( x1, y1, x2, y2, 0 ); + std::vector line = line_to( p1, p2, 0 ); for( auto &i : line ) { set( i.x, i.y ); } - set( x1, y1 ); + set( p1.x, p1.y ); } -void draw_square( std::functionset, int x1, int y1, int x2, int y2 ) +void draw_square( std::functionset, point p1, point p2 ) { - if( x1 > x2 ) { - std::swap( x1, x2 ); + if( p1.x > p2.x ) { + std::swap( p1.x, p2.x ); } - if( y1 > y2 ) { - std::swap( y1, y2 ); + if( p1.y > p2.y ) { + std::swap( p1.y, p2.y ); } - for( int x = x1; x <= x2; x++ ) { - for( int y = y1; y <= y2; y++ ) { + for( int x = p1.x; x <= p2.x; x++ ) { + for( int y = p1.y; y <= p2.y; y++ ) { set( x, y ); } } } -void draw_rough_circle( std::functionset, int x, int y, int rad ) +void draw_rough_circle( std::functionset, const point &p, int rad ) { - for( int i = x - rad; i <= x + rad; i++ ) { - for( int j = y - rad; j <= y + rad; j++ ) { - if( trig_dist( x, y, i, j ) + rng( 0, 3 ) <= rad ) { + for( int i = p.x - rad; i <= p.x + rad; i++ ) { + for( int j = p.y - rad; j <= p.y + rad; j++ ) { + if( trig_dist( p.x, p.y, i, j ) + rng( 0, 3 ) <= rad ) { set( i, j ); } } } } -void draw_circle( std::functionset, double x, double y, double rad ) +void draw_circle( std::functionset, const rl_vec2d &p, double rad ) { - for( int i = x - rad - 1; i <= x + rad + 1; i++ ) { - for( int j = y - rad - 1; j <= y + rad + 1; j++ ) { - if( ( x - i ) * ( x - i ) + ( y - j ) * ( y - j ) <= rad * rad ) { + for( int i = p.x - rad - 1; i <= p.x + rad + 1; i++ ) { + for( int j = p.y - rad - 1; j <= p.y + rad + 1; j++ ) { + if( ( p.x - i ) * ( p.x - i ) + ( p.y - j ) * ( p.y - j ) <= rad * rad ) { set( i, j ); } } } } -void draw_circle( std::functionset, int x, int y, int rad ) +void draw_circle( std::functionset, const point &p, int rad ) { - for( int i = x - rad; i <= x + rad; i++ ) { - for( int j = y - rad; j <= y + rad; j++ ) { - if( trig_dist( x, y, i, j ) <= rad ) { + for( int i = p.x - rad; i <= p.x + rad; i++ ) { + for( int j = p.y - rad; j <= p.y + rad; j++ ) { + if( trig_dist( p.x, p.y, i, j ) <= rad ) { set( i, j ); } } diff --git a/src/drawing_primitives.h b/src/drawing_primitives.h index 37d21c8f09c37..6a53127a2fb80 100644 --- a/src/drawing_primitives.h +++ b/src/drawing_primitives.h @@ -7,20 +7,14 @@ struct point; struct rl_vec2d; -void draw_line( std::functionset, int x1, int y1, int x2, int y2 ); void draw_line( std::functionset, const point &p1, const point &p2 ); -void draw_square( std::functionset, int x1, int y1, int x2, int y2 ); -void draw_square( std::functionset, const point &p1, - const point &p2 ); +void draw_square( std::functionset, point p1, point p2 ); -void draw_rough_circle( std::functionset, int x, int y, int rad ); void draw_rough_circle( std::functionset, const point &p, int rad ); -void draw_circle( std::functionset, double x, double y, double rad ); void draw_circle( std::functionset, const rl_vec2d &p, double rad ); -void draw_circle( std::functionset, int x, int y, int rad ); void draw_circle( std::functionset, const point &p, int rad ); #endif From 86c8ad46c3070509d4148a996339f031c61314d7 Mon Sep 17 00:00:00 2001 From: curstwist <39442864+curstwist@users.noreply.github.com> Date: Fri, 16 Aug 2019 19:47:40 -0400 Subject: [PATCH 020/113] add roofs to 2story apartments --- data/json/mapgen/apartment_con.json | 4 ++-- data/json/mapgen/apartment_mod.json | 8 ++++---- data/json/overmap/multitile_city_buildings.json | 12 ++++++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/data/json/mapgen/apartment_con.json b/data/json/mapgen/apartment_con.json index ac3b1674f0974..d370d7ad78020 100644 --- a/data/json/mapgen/apartment_con.json +++ b/data/json/mapgen/apartment_con.json @@ -26,8 +26,8 @@ " Rssw..A.....F.|+-|......|-+|..........wssR ", " Rss|.....FFFF^|.Y|......|Y.|^....FFF.o|ssR ", " |------------||--|......|--||------------| ", - " |############|EEE=......=xEE|############| ", - " |############|EEx=......=EEE|############| ", + " |############|...=......=xEE|############| ", + " |############|<..=......=EEE|############| ", " |------|-|-|-|---|......|---|-|-|-|------| ", " |.dBBd.+r|u+..e32|......|23e..+u|r+.dBBd.| ", " w..BB..|-|-|....u|......|u....|-|-|..BB..w ", diff --git a/data/json/mapgen/apartment_mod.json b/data/json/mapgen/apartment_mod.json index 5d65d2a93b811..9ddd7673b3809 100644 --- a/data/json/mapgen/apartment_mod.json +++ b/data/json/mapgen/apartment_mod.json @@ -15,10 +15,10 @@ " |--|-----+--|+|--| |--|+|--+-----|--| ", " RsswFFFF...^|.STb| |bTS.|...FFFF.wssR ", " Rssw........+...b|-WW-|b...+........wssR ", - " RssX........|--|-|EEEE|-|--|........XssR ", - " Rss|1.htth...oo|Y|EEEE|Y|..........1|ssR ", - " Rss|e.htth.....+.|xEEE|.+..........e|ssR ", - " |-----|2.........A|-|-==-|-|..hh......u|-----| ", + " RssX........|--|-|....|-|--|........XssR ", + " Rss|1.htth...oo|Y|<...|Y|..........1|ssR ", + " Rss|e.htth.....+.|....|.+..........e|ssR ", + " |-----|2.........A|-|-..-|-|..hh......u|-----| ", " |..BBd|uO3........|........|..tt....3O2|dBB..| ", " w..BB.|--|+|......D........D..tt..|+|--|.BB..w ", " |d....+.r|u|^....t|........|..hh.^|u|r.+....d| ", diff --git a/data/json/overmap/multitile_city_buildings.json b/data/json/overmap/multitile_city_buildings.json index be0bd5c3c706f..d30c6feecf236 100644 --- a/data/json/overmap/multitile_city_buildings.json +++ b/data/json/overmap/multitile_city_buildings.json @@ -851,9 +851,13 @@ "locations": [ "land" ], "overmaps": [ { "point": [ 1, 1, 0 ], "overmap": "apartments_con_tower_NW_south" }, + { "point": [ 1, 1, 1 ], "overmap": "apartments_con_tower_114_south" }, { "point": [ 0, 1, 0 ], "overmap": "apartments_con_tower_NE_south" }, + { "point": [ 0, 1, 1 ], "overmap": "apartments_con_tower_014_south" }, { "point": [ 1, 0, 0 ], "overmap": "apartments_con_tower_SW_south" }, - { "point": [ 0, 0, 0 ], "overmap": "apartments_con_tower_SE_south" } + { "point": [ 1, 0, 1 ], "overmap": "apartments_con_tower_104_south" }, + { "point": [ 0, 0, 0 ], "overmap": "apartments_con_tower_SE_south" }, + { "point": [ 0, 0, 1 ], "overmap": "apartments_con_tower_004_south" } ] }, { @@ -862,9 +866,13 @@ "locations": [ "land" ], "overmaps": [ { "point": [ 1, 1, 0 ], "overmap": "apartments_mod_tower_NW_south" }, + { "point": [ 1, 1, 1 ], "overmap": "apartments_mod_tower_113_south" }, { "point": [ 0, 1, 0 ], "overmap": "apartments_mod_tower_NE_south" }, + { "point": [ 0, 1, 1 ], "overmap": "apartments_mod_tower_013_south" }, { "point": [ 1, 0, 0 ], "overmap": "apartments_mod_tower_SW_south" }, - { "point": [ 0, 0, 0 ], "overmap": "apartments_mod_tower_SE_south" } + { "point": [ 1, 0, 1 ], "overmap": "apartments_mod_tower_103_south" }, + { "point": [ 0, 0, 0 ], "overmap": "apartments_mod_tower_SE_south" }, + { "point": [ 0, 0, 1 ], "overmap": "apartments_mod_tower_003_south" } ] }, { From 53c51b46d78d403750c3b4d8d5340992fbe24a73 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 21:03:41 -0400 Subject: [PATCH 021/113] drawing_primitives functions now take point arguments Had to add some more map overloads for this. --- src/drawing_primitives.cpp | 22 ++++++------ src/drawing_primitives.h | 10 +++--- src/map.cpp | 44 +++++++++++------------ src/map.h | 3 ++ src/mapgen.cpp | 74 +++++++++++++++++++------------------- 5 files changed, 78 insertions(+), 75 deletions(-) diff --git a/src/drawing_primitives.cpp b/src/drawing_primitives.cpp index ebbdcf7479926..e379118f3b638 100644 --- a/src/drawing_primitives.cpp +++ b/src/drawing_primitives.cpp @@ -8,16 +8,16 @@ #include "rng.h" #include "point.h" -void draw_line( std::functionset, const point &p1, const point &p2 ) +void draw_line( std::functionset, const point &p1, const point &p2 ) { std::vector line = line_to( p1, p2, 0 ); for( auto &i : line ) { - set( i.x, i.y ); + set( i ); } - set( p1.x, p1.y ); + set( p1 ); } -void draw_square( std::functionset, point p1, point p2 ) +void draw_square( std::functionset, point p1, point p2 ) { if( p1.x > p2.x ) { std::swap( p1.x, p2.x ); @@ -27,39 +27,39 @@ void draw_square( std::functionset, point p1, poin } for( int x = p1.x; x <= p2.x; x++ ) { for( int y = p1.y; y <= p2.y; y++ ) { - set( x, y ); + set( point( x, y ) ); } } } -void draw_rough_circle( std::functionset, const point &p, int rad ) +void draw_rough_circle( std::functionset, const point &p, int rad ) { for( int i = p.x - rad; i <= p.x + rad; i++ ) { for( int j = p.y - rad; j <= p.y + rad; j++ ) { if( trig_dist( p.x, p.y, i, j ) + rng( 0, 3 ) <= rad ) { - set( i, j ); + set( point( i, j ) ); } } } } -void draw_circle( std::functionset, const rl_vec2d &p, double rad ) +void draw_circle( std::functionset, const rl_vec2d &p, double rad ) { for( int i = p.x - rad - 1; i <= p.x + rad + 1; i++ ) { for( int j = p.y - rad - 1; j <= p.y + rad + 1; j++ ) { if( ( p.x - i ) * ( p.x - i ) + ( p.y - j ) * ( p.y - j ) <= rad * rad ) { - set( i, j ); + set( point( i, j ) ); } } } } -void draw_circle( std::functionset, const point &p, int rad ) +void draw_circle( std::functionset, const point &p, int rad ) { for( int i = p.x - rad; i <= p.x + rad; i++ ) { for( int j = p.y - rad; j <= p.y + rad; j++ ) { if( trig_dist( p.x, p.y, i, j ) <= rad ) { - set( i, j ); + set( point( i, j ) ); } } } diff --git a/src/drawing_primitives.h b/src/drawing_primitives.h index 6a53127a2fb80..279716cc34ac1 100644 --- a/src/drawing_primitives.h +++ b/src/drawing_primitives.h @@ -7,14 +7,14 @@ struct point; struct rl_vec2d; -void draw_line( std::functionset, const point &p1, const point &p2 ); +void draw_line( std::functionset, const point &p1, const point &p2 ); -void draw_square( std::functionset, point p1, point p2 ); +void draw_square( std::functionset, point p1, point p2 ); -void draw_rough_circle( std::functionset, const point &p, int rad ); +void draw_rough_circle( std::functionset, const point &p, int rad ); -void draw_circle( std::functionset, const rl_vec2d &p, double rad ); +void draw_circle( std::functionset, const rl_vec2d &p, double rad ); -void draw_circle( std::functionset, const point &p, int rad ); +void draw_circle( std::functionset, const point &p, int rad ); #endif diff --git a/src/map.cpp b/src/map.cpp index 0f7e10141948e..2d64d37924fb0 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -8090,15 +8090,15 @@ tinymap::tinymap( int mapsize, bool zlevels ) void map::draw_line_ter( const ter_id type, const point &p1, const point &p2 ) { - draw_line( [this, type]( int x, int y ) { - this->ter_set( point( x, y ), type ); + draw_line( [this, type]( const point & p ) { + this->ter_set( p, type ); }, p1, p2 ); } void map::draw_line_furn( const furn_id type, const point &p1, const point &p2 ) { - draw_line( [this, type]( int x, int y ) { - this->furn_set( point( x, y ), type ); + draw_line( [this, type]( const point & p ) { + this->furn_set( p, type ); }, p1, p2 ); } @@ -8131,65 +8131,65 @@ void map::draw_fill_background( const weighted_int_list &f ) void map::draw_square_ter( const ter_id type, const point &p1, const point &p2 ) { - draw_square( [this, type]( int x, int y ) { - this->ter_set( point( x, y ), type ); + draw_square( [this, type]( const point & p ) { + this->ter_set( p, type ); }, p1, p2 ); } void map::draw_square_furn( const furn_id type, const point &p1, const point &p2 ) { - draw_square( [this, type]( int x, int y ) { - this->furn_set( point( x, y ), type ); + draw_square( [this, type]( const point & p ) { + this->furn_set( p, type ); }, p1, p2 ); } void map::draw_square_ter( ter_id( *f )(), const point &p1, const point &p2 ) { - draw_square( [this, f]( int x, int y ) { - this->ter_set( point( x, y ), f() ); + draw_square( [this, f]( const point & p ) { + this->ter_set( p, f() ); }, p1, p2 ); } void map::draw_square_ter( const weighted_int_list &f, const point &p1, const point &p2 ) { - draw_square( [this, f]( int x, int y ) { + draw_square( [this, f]( const point & p ) { const ter_id *tid = f.pick(); - this->ter_set( point( x, y ), tid != nullptr ? *tid : t_null ); + this->ter_set( p, tid != nullptr ? *tid : t_null ); }, p1, p2 ); } void map::draw_rough_circle_ter( const ter_id type, const point &p, int rad ) { - draw_rough_circle( [this, type]( int x, int y ) { - this->ter_set( point( x, y ), type ); + draw_rough_circle( [this, type]( const point & q ) { + this->ter_set( q, type ); }, p, rad ); } void map::draw_rough_circle_furn( const furn_id type, const point &p, int rad ) { - draw_rough_circle( [this, type]( int x, int y ) { - this->furn_set( point( x, y ), type ); + draw_rough_circle( [this, type]( const point & q ) { + this->furn_set( q, type ); }, p, rad ); } void map::draw_circle_ter( const ter_id type, const rl_vec2d &p, double rad ) { - draw_circle( [this, type]( int x, int y ) { - this->ter_set( point( x, y ), type ); + draw_circle( [this, type]( const point & q ) { + this->ter_set( q, type ); }, p, rad ); } void map::draw_circle_ter( const ter_id type, const point &p, int rad ) { - draw_circle( [this, type]( int x, int y ) { - this->ter_set( point( x, y ), type ); + draw_circle( [this, type]( const point & q ) { + this->ter_set( q, type ); }, p, rad ); } void map::draw_circle_furn( const furn_id type, const point &p, int rad ) { - draw_circle( [this, type]( int x, int y ) { - this->furn_set( point( x, y ), type ); + draw_circle( [this, type]( const point & q ) { + this->furn_set( q, type ); }, p, rad ); } diff --git a/src/map.h b/src/map.h index 3400464047da2..d65f717996326 100644 --- a/src/map.h +++ b/src/map.h @@ -628,6 +628,7 @@ class map // Terrain: 2D overloads // Terrain integer id at coordinates (x, y); {x|y}=(0, SEE{X|Y}*3] ter_id ter( int x, int y ) const; + ter_id ter( const point &p ) const; bool ter_set( int x, int y, const ter_id &new_terrain ); @@ -703,6 +704,7 @@ class map bool can_put_items_ter_furn( int x, int y ) const; // checks terrain bool has_flag_ter( const std::string &flag, int x, int y ) const; + bool has_flag_ter( const std::string &flag, const point &p ) const; // checks furniture bool has_flag_furn( const std::string &flag, int x, int y ) const; // checks terrain or furniture @@ -898,6 +900,7 @@ class map void set_radiation( const tripoint &p, int value ); // Overload for mapgen void set_radiation( int x, int y, int value ); + void set_radiation( const point &p, int value ); /** Increment the radiation in the given tile by the given delta * (decrement it if delta is negative) diff --git a/src/mapgen.cpp b/src/mapgen.cpp index c3817f48dae5e..4383da4a9fcf3 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -3865,15 +3865,15 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi } auto fluid_type = one_in( 3 ) ? t_sewage : t_water_sh; for( int i = 0; i < 2; ++i ) { - draw_rough_circle( [this, fluid_type]( int x, int y ) { - if( t_thconc_floor == ter( x, y ) || t_strconc_floor == ter( x, y ) || - t_thconc_floor_olight == ter( x, y ) ) { - ter_set( point( x, y ), fluid_type ); - } else if( has_flag_ter( "DOOR", x, y ) ) { + draw_rough_circle( [this, fluid_type]( const point & p ) { + if( t_thconc_floor == ter( p ) || t_strconc_floor == ter( p ) || + t_thconc_floor_olight == ter( p ) ) { + ter_set( p, fluid_type ); + } else if( has_flag_ter( "DOOR", p ) ) { // We want the actual debris, but not the rubble marker or dirt. - make_rubble( { x, y, abs_sub.z } ); - ter_set( point( x, y ), fluid_type ); - furn_set( point( x, y ), f_null ); + make_rubble( { p, abs_sub.z } ); + ter_set( p, fluid_type ); + furn_set( p, f_null ); } }, point( rng( 1, SEEX * 2 - 2 ), rng( 1, SEEY * 2 - 2 ) ), rng( 3, 6 ) ); } @@ -3908,14 +3908,14 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi ARTPROP_WHISPERING, ARTPROP_GLOWING }; - draw_rough_circle( [this]( int x, int y ) { - if( has_flag_ter( "GOES_DOWN", x, y ) || - has_flag_ter( "GOES_UP", x, y ) || - has_flag_ter( "CONSOLE", x, y ) ) { + draw_rough_circle( [this]( const point & p ) { + if( has_flag_ter( "GOES_DOWN", p ) || + has_flag_ter( "GOES_UP", p ) || + has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } - make_rubble( {x, y, abs_sub.z } ); - ter_set( point( x, y ), t_thconc_floor ); + make_rubble( {p, abs_sub.z } ); + ter_set( p, t_thconc_floor ); }, center.xy(), 4 ); furn_set( center.xy(), f_null ); trap_set( center, tr_portal ); @@ -3929,26 +3929,26 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi // just skip it, we don't want to risk embedding radiation out of sight. break; } - draw_rough_circle( [this]( int x, int y ) { - set_radiation( x, y, 10 ); + draw_rough_circle( [this]( const point & p ) { + set_radiation( p, 10 ); }, center.xy(), rng( 7, 12 ) ); - draw_circle( [this]( int x, int y ) { - set_radiation( x, y, 20 ); + draw_circle( [this]( const point & p ) { + set_radiation( p, 20 ); }, center.xy(), rng( 5, 8 ) ); - draw_circle( [this]( int x, int y ) { - set_radiation( x, y, 30 ); + draw_circle( [this]( const point & p ) { + set_radiation( p, 30 ); }, center.xy(), rng( 2, 4 ) ); - draw_circle( [this]( int x, int y ) { - set_radiation( x, y, 50 ); + draw_circle( [this]( const point & p ) { + set_radiation( p, 50 ); }, center.xy(), 1 ); - draw_circle( [this]( int x, int y ) { - if( has_flag_ter( "GOES_DOWN", x, y ) || - has_flag_ter( "GOES_UP", x, y ) || - has_flag_ter( "CONSOLE", x, y ) ) { + draw_circle( [this]( const point & p ) { + if( has_flag_ter( "GOES_DOWN", p ) || + has_flag_ter( "GOES_UP", p ) || + has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } - make_rubble( {x, y, abs_sub.z } ); - ter_set( point( x, y ), t_thconc_floor ); + make_rubble( {p, abs_sub.z } ); + ter_set( p, t_thconc_floor ); }, center.xy(), 1 ); place_spawns( GROUP_HAZMATBOT, 1, center.xy() + point_west, @@ -3990,20 +3990,20 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi tripoint center( rng( 6, SEEX * 2 - 7 ), rng( 6, SEEY * 2 - 7 ), abs_sub.z ); // Make a portal surrounded by more dense fungal stuff and a fungaloid. - draw_rough_circle( [this]( int x, int y ) { - if( has_flag_ter( "GOES_DOWN", x, y ) || - has_flag_ter( "GOES_UP", x, y ) || - has_flag_ter( "CONSOLE", x, y ) ) { + draw_rough_circle( [this]( const point & p ) { + if( has_flag_ter( "GOES_DOWN", p ) || + has_flag_ter( "GOES_UP", p ) || + has_flag_ter( "CONSOLE", p ) ) { return; // spare stairs and consoles. } - if( has_flag_ter( "WALL", x, y ) ) { - ter_set( point( x, y ), t_fungus_wall ); + if( has_flag_ter( "WALL", p ) ) { + ter_set( p, t_fungus_wall ); } else { - ter_set( point( x, y ), t_fungus_floor_in ); + ter_set( p, t_fungus_floor_in ); if( one_in( 3 ) ) { - furn_set( point( x, y ), f_flower_fungal ); + furn_set( p, f_flower_fungal ); } else if( one_in( 10 ) ) { - ter_set( point( x, y ), t_marloss ); + ter_set( p, t_marloss ); } } }, center.xy(), 3 ); From 7c474485ee9a7fcdca5f7995af9412408ff95c61 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 16 Aug 2019 21:08:16 -0400 Subject: [PATCH 022/113] Add more map overloads --- src/map.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/map.h b/src/map.h index d65f717996326..1d77643a0e431 100644 --- a/src/map.h +++ b/src/map.h @@ -595,10 +595,13 @@ class map } std::string name( int x, int y ); + std::string name( const point &p ); bool has_furn( int x, int y ) const; + bool has_furn( const point &p ) const; // Furniture at coordinates (x, y); {x|y}=(0, SEE{X|Y}*3] furn_id furn( int x, int y ) const; + furn_id furn( const point &p ) const; void furn_set( int x, int y, const furn_id &new_furniture ); @@ -607,6 +610,7 @@ class map } std::string furnname( int x, int y ); + std::string furnname( const point &p ); // Furniture: 3D void set( const tripoint &p, const ter_id &new_terrain, const furn_id &new_furniture ); @@ -637,6 +641,7 @@ class map } std::string tername( int x, int y ) const; // Name of terrain at (x, y) + std::string tername( const point &p ) const; // Name of terrain at (x, y) // Terrain: 3D ter_id ter( const tripoint &p ) const; @@ -698,26 +703,35 @@ class map // Flags: 2D overloads // Words relevant to terrain (sharp, etc) std::string features( int x, int y ); + std::string features( const point &p ); // checks terrain, furniture and vehicles bool has_flag( const std::string &flag, int x, int y ) const; + bool has_flag( const std::string &flag, const point &p ) const; // True if items can be placed in this tile bool can_put_items_ter_furn( int x, int y ) const; + bool can_put_items_ter_furn( const point &p ) const; // checks terrain bool has_flag_ter( const std::string &flag, int x, int y ) const; bool has_flag_ter( const std::string &flag, const point &p ) const; // checks furniture bool has_flag_furn( const std::string &flag, int x, int y ) const; + bool has_flag_furn( const std::string &flag, const point &p ) const; // checks terrain or furniture bool has_flag_ter_or_furn( const std::string &flag, int x, int y ) const; + bool has_flag_ter_or_furn( const std::string &flag, const point &p ) const; // fast "oh hai it's update_scent/lightmap/draw/monmove/self/etc again, what about this one" flag checking // checks terrain, furniture and vehicles bool has_flag( ter_bitflags flag, int x, int y ) const; + bool has_flag( ter_bitflags flag, const point &p ) const; // checks terrain bool has_flag_ter( ter_bitflags flag, int x, int y ) const; + bool has_flag_ter( ter_bitflags flag, const point &p ) const; // checks furniture bool has_flag_furn( ter_bitflags flag, int x, int y ) const; + bool has_flag_furn( ter_bitflags flag, const point &p ) const; // checks terrain or furniture bool has_flag_ter_or_furn( ter_bitflags flag, int x, int y ) const; + bool has_flag_ter_or_furn( ter_bitflags flag, const point &p ) const; // Flags: 3D // Words relevant to terrain (sharp, etc) std::string features( const tripoint &p ); @@ -751,6 +765,13 @@ class map int bash_strength( int x, int y ) const; int bash_resistance( int x, int y ) const; int bash_rating( int str, int x, int y ) const; + bool is_bashable( const point &p ) const; + bool is_bashable_ter( const point &p ) const; + bool is_bashable_furn( const point &p ) const; + bool is_bashable_ter_furn( const point &p ) const; + int bash_strength( const point &p ) const; + int bash_resistance( const point &p ) const; + int bash_rating( int str, const point &p ) const; // Bashable: 3D /** Returns true if there is a bashable vehicle part or the furn/terrain is bashable at p */ bool is_bashable( const tripoint &p, bool allow_floor = false ) const; @@ -778,6 +799,9 @@ class map bool is_divable( int x, int y ) const; bool is_water_shallow_current( int x, int y ) const; bool is_outside( int x, int y ) const; + bool is_divable( const point &p ) const; + bool is_water_shallow_current( const point &p ) const; + bool is_outside( const point &p ) const; bool is_divable( const tripoint &p ) const; bool is_outside( const tripoint &p ) const; bool is_water_shallow_current( const tripoint &p ) const; @@ -793,6 +817,8 @@ class map * all terrain is floor and the last terrain is a wall */ bool is_last_ter_wall( bool no_furn, int x, int y, int xmax, int ymax, direction dir ) const; + bool is_last_ter_wall( bool no_furn, const point &p, + int xmax, int ymax, direction dir ) const; /** * Checks if there are any tinder flagged items on the tile. From e1166b459a10eea26703237f42d6788f3a4c2869 Mon Sep 17 00:00:00 2001 From: Tonkatsu Date: Fri, 16 Aug 2019 19:49:56 -0500 Subject: [PATCH 023/113] Update help text on magazine compat .270 and .30-06, .40 and 10mm aren't the same! --- data/help/texts.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/help/texts.json b/data/help/texts.json index 54aa270990417..2359674f61df5 100644 --- a/data/help/texts.json +++ b/data/help/texts.json @@ -174,7 +174,7 @@ "To attack a monster with a melee weapon, simply move into them. The time it takes to attack depends on the size and weight of your weapon. Small, light weapons are the fastest; unarmed attacks increase in speed with your Unarmed Combat skill, and will eventually be VERY fast. A successful hit with a bashing weapon may stun the monster temporarily. A miss may make you stumble and lose movement points. If a monster hits you, your clothing may absorb some damage, but you will absorb the excess.", "Swarms of monsters may call for firearms. Most firearms in the game require compatible magazines to hold the ammunition. Compatible magazines are listed in a given firearm's description. Fortunately, a firearm often spawns with one such magazine in it.", "You can eject a magazine from a firearm by pressing and load it with compatible ammunition separately, or if you have a firearm with a partially filled magazine in it, and some matching loose ammo in the inventory, you can simply order a reload by pressing , so you will automatically eject the magazine, fill it with as much ammo as possible, and then put the magazine back in. You don't have to worry about chambering a round though. Of course all this takes some time, so try not to do it if there are monsters nearby.", - "While magazines are often firearm-specific, on some occasions a magazine is compatible with several other firearms. The firearms in the game often reflect real-world prototypes in terms of caliber and compatibility. Below are some examples of interchangeable ammo:\n.308 = 7.62x51mm,\n.223 = 5.56 NATO,\n.270 = .30-06,\n.40 S&W = 10mm.", + "While magazines and clips are often firearm-specific, on some occasions a magazine/speedloader is compatible with several other firearms or calibers. Below are some examples of calibers that might share magazines or speedloaders:\n.380 ACP and 9mm Luger,\n .40 S&W and 10mm Auto 3\n.45 ACP and .460 Rowland,\n.45 Colt and .454 Casull.", "Magazine descriptions also list the compatible ammo.", "Note that while several ammo types exist for a given caliber and magazine type, you can't mix and match these types into a single magazine. You can't for example load 9x19mm JHP and 9x19mm FMJ ammo into the same magazine, since a magazine always requires identical rounds to be loaded in it.", "Magazines can be stored inside several worn accessories for quicker access, such as chest rigs and ammo pouches. All these compatible storage items are listed in a given magazine's description. To store a magazine into a clothing item, activate () appropriate clothing item, at which point you'll get to choose which magazine to store.", From a09aa8b65b65e1f464c621491895208c074faa48 Mon Sep 17 00:00:00 2001 From: free-coffee <43655436+free-coffee@users.noreply.github.com> Date: Sat, 17 Aug 2019 09:20:06 +0200 Subject: [PATCH 024/113] doc: Mapgen elements "density" and "roof" of "terrain". (#33284) * doc: Mapgen elements "density" and "roof" of "terrain". * doc: the implementation is roll (float<1) in 1, so it is confusing. --- doc/MAPGEN.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/MAPGEN.md b/doc/MAPGEN.md index 965053ccec788..721ddf0d871e9 100644 --- a/doc/MAPGEN.md +++ b/doc/MAPGEN.md @@ -377,11 +377,13 @@ Example: "x": 12, "y": [ 5, 15 ] These values will produce a rectangle for map::place_spawns from ( 12, 5 ) to ( 12, 15 ) inclusive. #### 2.3.0.1 "density" -**optional** magic sauce spawn amount number that somehow determines how many monsters from the group can appear. This argument is optional, but for place_monsters to work the density must be set either here or in the overmap terrain definition. Otherwise it defaults to zero and no monsters will spawn. How density actually works is a strange mystery that someone should solve and put into this document. +**optional** This is a multipier to the following "chance". If the result is bigger than 100% it gurantees one spawn point for every 100% and the rest is evaluated by chance (one added or not). Then the monsters are spawned according to their spawn-point cost "cost_multiplier" defined in the monster groups. +Additionally all overmap densities within a square of raduis 3 (7x7 around player) [exact value in mapgen.cpp/MON_RADIUS makro] are added to this. +The "pack_size" modifier in monstergroups is a random multiplier to the rolled spawn point amount. > Value: *floating point number* #### 2.3.0.2 "chance" -**optional** one-in-??? chance to apply +**optional** ???-in-100 chance to apply > Value: *number* ### 2.3.1 "item" @@ -617,7 +619,7 @@ Places furniture. Values: - "furn": (required, string) type id of the furniture (e.g. f_chair). ### 2.5.12 "terrain" -Places terrain. Values: +Places terrain. If the terrain has the value "roof" set and is in an enclosed space it's indoors. Values: - "ter": (required, string) type id of the terrain (e.g. t_floor). ### 2.5.13 "monster" From 7200131eea31ac62108ce09db7acab631f8cc19b Mon Sep 17 00:00:00 2001 From: LaVeyanFiend <51099123+LaVeyanFiend@users.noreply.github.com> Date: Sat, 17 Aug 2019 03:22:08 -0400 Subject: [PATCH 025/113] Opiate addict profession, retired drug war snippet, smoke shop only has legal drugs (#33125) * Pillhead profession * Smoke shops no longer have illegal drugs * War on Drugs snippet retired + astyle Missing space Astyling --- data/json/itemgroups/mall_item_groups.json | 5 ----- data/json/professions.json | 13 +++++++++++++ data/json/snippets/snippets.json | 1 - 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/data/json/itemgroups/mall_item_groups.json b/data/json/itemgroups/mall_item_groups.json index 36e1c38002c2d..2ccb58c50549e 100644 --- a/data/json/itemgroups/mall_item_groups.json +++ b/data/json/itemgroups/mall_item_groups.json @@ -249,11 +249,6 @@ [ "seed_tobacco", 5 ], [ "rolling_paper", 45 ], [ "pipe_glass", 20 ], - [ "coke", 5 ], - [ "meth", 2 ], - [ "heroin", 1 ], - [ "crack", 4 ], - [ "crackpipe", 7 ], [ "cig", 60 ], [ "chaw", 60 ] ] diff --git a/data/json/professions.json b/data/json/professions.json index 6b3e17f1c2ea8..f6fea04566014 100644 --- a/data/json/professions.json +++ b/data/json/professions.json @@ -921,6 +921,19 @@ "items": { "both": [ "pants", "boxer_shorts" ], "male": [ "undershirt" ], "female": [ "camisole" ] }, "addictions": [ { "intensity": 30, "type": "amphetamine" } ] }, + { + "type": "profession", + "ident": "pillhead", + "name": "Pillhead", + "description": "After an accident in your youth, you got addicted to the opiates treating your pain. With the pharmacies shut down and dealers turned undead, satisfying your fix just got a lot more difficult.", + "points": -1, + "items": { + "both": [ "sneakers", "socks", "jeans", "tshirt", "wristwatch", "oxycodone" ], + "male": [ "boxer_shorts" ], + "female": [ "panties", "bra" ] + }, + "addictions": [ { "intensity": 20, "type": "opiate" } ] + }, { "type": "profession", "ident": "k9_cop", diff --git a/data/json/snippets/snippets.json b/data/json/snippets/snippets.json index b93bef8e8b017..100a51a11fc92 100644 --- a/data/json/snippets/snippets.json +++ b/data/json/snippets/snippets.json @@ -390,7 +390,6 @@ "SPACE TELEPORTATION - TRUTH OR FICTION? Scientists addressed a growing conspiracy theory today \"The plutonium consumed is massive. We cannot use teleportation to reach aliens, unless they live on some kind of parallel world.\"", "LASERS - NEXT BIG THING?: Top defense researchers remarked during demonstration of a prototype today: \"We are still working on it, the laser weapon lacks power, but has a technically almost unlimited range,\" one said", "DRUG USE ON THE RISE: Recent statistic suggest drug use has climbed more than 40% in the last two years. \"People are scared for their jobs, their country, even their life... of course some will turn to drugs,\" said an expert.", - "WAR ON DRUGS DEAD: The government has finally reacted to long accumulated evidence that suggests that decriminalized drugs cause fewer health problems and are generally better managed while providing valuable tax revenues.", "FEELING BLUE? Try \"Greens\" for Magazines! Your local Supermarket! Nothing cheers you up like a good magazine... Unless it's JUNK FOOD! Or why not buy an MP3 PLAYER or a GAME CONSOLE? Chase those blues away at GREENS Supermarket", "GLAMOPOLITAN! We've got ALL the latest tips! Whether you want to know what the elite are eating, wearing or discussing, Glamopolitan is YOUR magazine! So pick up a copy today and \"Sizzle Like A Star\"!", "POPULAR MECHANICS: People say mechanics is boring? We say, Prove them Wrong! We've got all the articles that make it interesting to talk about, so you can \"Make Mechanics Popular\"!", From e23659dd030805334023773fe50748809f7f196a Mon Sep 17 00:00:00 2001 From: nshcat Date: Sat, 17 Aug 2019 09:25:24 +0200 Subject: [PATCH 026/113] Add additional, realistic RPG-7 ammunition types (#33098) * Implemented additional RPG7 ammunition types * Changed RPG7 ammo type name to allow different rocket calibers * Added new RPG-7 ammunition types to loot tables --- data/json/item_groups.json | 6 ++++ data/json/itemgroups/main.json | 8 ++++- data/json/items/ammo.json | 57 +++++++++++++++++++++++++++++++++ data/json/items/ammo_types.json | 2 +- 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/data/json/item_groups.json b/data/json/item_groups.json index 9dc26cdc5ed20..1c74e6f68045f 100644 --- a/data/json/item_groups.json +++ b/data/json/item_groups.json @@ -3320,6 +3320,9 @@ [ "file", 5 ], [ "RPG", 1 ], [ "RPG-7_ammo", 1 ], + [ "RPG-7_og7v", 2 ], + [ "RPG-7_tbg7v", 1 ], + [ "RPG-7_pg7vr", 1 ], [ "clown_suit", 2 ], [ "clownshoes", 2 ], [ "bondage_suit", 1 ], @@ -7575,6 +7578,9 @@ [ "u_shotgun", 4 ], [ "RPG", 1 ], [ "RPG-7_ammo", 1 ], + [ "RPG-7_og7v", 2 ], + [ "RPG-7_tbg7v", 1 ], + [ "RPG-7_pg7vr", 1 ], [ "flask_hip", 10 ], [ "chemistry_set", 2 ], [ "knife_trench", 7 ], diff --git a/data/json/itemgroups/main.json b/data/json/itemgroups/main.json index c0aab836e9bf5..c0ed065244054 100644 --- a/data/json/itemgroups/main.json +++ b/data/json/itemgroups/main.json @@ -67,6 +67,9 @@ [ "royal_jelly", 80 ], [ "RPG", 10 ], [ "RPG-7_ammo", 10 ], + [ "RPG-7_og7v", 25 ], + [ "RPG-7_tbg7v", 8 ], + [ "RPG-7_pg7vr", 8 ], [ "atgm_heat", 1 ], [ "rx11_stimpack", 50 ], [ "rx12_injector", 50 ], @@ -174,7 +177,10 @@ [ "m3_carlgustav", 10 ], [ "m202_flash", 20 ], [ "RPG", 40 ], - [ "RPG-7_ammo", 40 ], + [ "RPG-7_ammo", 35 ], + [ "RPG-7_og7v", 45 ], + [ "RPG-7_tbg7v", 15 ], + [ "RPG-7_pg7vr", 20 ], [ "atgm_launcher", 3 ], [ "atgm_heat", 6 ], [ "flamethrower", 50 ], diff --git a/data/json/items/ammo.json b/data/json/items/ammo.json index 666c57c05b534..5836f91f607a1 100644 --- a/data/json/items/ammo.json +++ b/data/json/items/ammo.json @@ -659,6 +659,63 @@ "recoil": 450, "effects": [ "COOKOFF", "EXPLOSIVE", "TRAIL", "NEVER_MISFIRES" ] }, + { + "type": "AMMO", + "id": "RPG-7_pg7vr", + "price": 10000, + "name": "PG-7VR 64mm/105mm rocket", + "symbol": "=", + "color": "dark_gray", + "description": "64mm/105mm high-explosive tandem ammunition for the RPG-7.", + "material": [ "steel", "powder" ], + "volume": 9, + "weight": 4500, + "ammo_type": "RPG-7", + "damage": 3250, + "pierce": 1450, + "range": 30, + "dispersion": 75, + "recoil": 450, + "effects": [ "COOKOFF", "EXPLOSIVE", "TRAIL", "NEVER_MISFIRES" ] + }, + { + "type": "AMMO", + "id": "RPG-7_tbg7v", + "price": 10000, + "name": "TBG-7V 105mm rocket", + "symbol": "=", + "color": "dark_gray", + "description": "105mm thermobaric ammunition for the RPG-7.", + "material": [ "plastic", "powder" ], + "volume": 9, + "weight": 4500, + "ammo_type": "RPG-7", + "damage": 150, + "pierce": 10, + "range": 30, + "dispersion": 50, + "recoil": 450, + "effects": [ "COOKOFF", "TRAIL", "NEVER_MISFIRES", "NAPALM_BIG" ] + }, + { + "type": "AMMO", + "id": "RPG-7_og7v", + "price": 8000, + "name": "OG-7V 40mm rocket", + "symbol": "=", + "color": "dark_gray", + "description": "40mm high-explosive fragmentation antipersonnel ammunition for the RPG-7.", + "material": [ "steel", "powder" ], + "volume": 4, + "weight": 2000, + "ammo_type": "RPG-7", + "damage": 80, + "pierce": 10, + "range": 45, + "dispersion": 50, + "recoil": 350, + "effects": [ "COOKOFF", "TRAIL", "NEVER_MISFIRES", "FRAG" ] + }, { "type": "AMMO", "id": "m235tpa", diff --git a/data/json/items/ammo_types.json b/data/json/items/ammo_types.json index ded3b0b8ca640..abca068ed5bb3 100644 --- a/data/json/items/ammo_types.json +++ b/data/json/items/ammo_types.json @@ -428,7 +428,7 @@ { "type": "ammunition_type", "id": "RPG-7", - "name": "93mm RPG-7", + "name": "RPG-7 rocket", "default": "RPG-7_ammo" }, { From e90a9f9c0b4c729477cc3304d85a1a1d85fa8610 Mon Sep 17 00:00:00 2001 From: ipcyborg Date: Sat, 17 Aug 2019 12:32:39 +0300 Subject: [PATCH 027/113] Fixed "Mutation Bad Knees applies when walking diagonally. #33158" --- src/player.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/player.cpp b/src/player.cpp index 206f3aff2133f..a8968a6c48196 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1567,13 +1567,6 @@ int player::run_cost( int base_cost, bool diag ) const const bool on_road = flatground && g->m.has_flag( "ROAD", pos() ); const bool on_fungus = g->m.has_flag_ter_or_furn( "FUNGUS", pos() ); - if( movecost > 100 ) { - movecost *= Character::mutation_value( "movecost_obstacle_modifier" ); - if( movecost < 100 ) { - movecost = 100; - } - } - if( !is_mounted() ) { if( movecost > 100 ) { movecost *= Character::mutation_value( "movecost_obstacle_modifier" ); From 9af72fe6e070577220f5e4d90e3b119395fdbcee Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 17 Aug 2019 08:03:56 -0400 Subject: [PATCH 028/113] Another refactoring pass --- src/computer.cpp | 34 +++---- src/construction.cpp | 6 +- src/explosion.cpp | 10 +- src/game.cpp | 2 +- src/iuse.cpp | 2 +- src/map.cpp | 16 ++-- src/map_extras.cpp | 24 ++--- src/mapgen.cpp | 186 +++++++++++++++++++------------------- src/mapgen_functions.cpp | 54 +++++------ src/mission_companion.cpp | 23 ++--- src/mission_start.cpp | 27 +++--- src/monattack.cpp | 4 +- src/player.cpp | 4 +- src/start_location.cpp | 2 +- src/timed_event.cpp | 24 ++--- src/tutorial.cpp | 12 +-- src/weather.cpp | 2 +- 17 files changed, 218 insertions(+), 214 deletions(-) diff --git a/src/computer.cpp b/src/computer.cpp index 3e9ef14308abe..2dd8cf78e970c 100644 --- a/src/computer.cpp +++ b/src/computer.cpp @@ -417,10 +417,10 @@ void computer::activate_function( computer_action action ) g->u.moves -= 30; for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.ter( x, y ) == t_sewage_pump ) { + if( g->m.ter( point( x, y ) ) == t_sewage_pump ) { for( int x1 = x - 1; x1 <= x + 1; x1++ ) { for( int y1 = y - 1; y1 <= y + 1; y1++ ) { - if( g->m.furn( x1, y1 ) == f_counter ) { + if( g->m.furn( point( x1, y1 ) ) == f_counter ) { bool found_item = false; item sewage( "sewage", calendar::turn ); auto candidates = g->m.i_at( point( x1, y1 ) ); @@ -479,10 +479,10 @@ void computer::activate_function( computer_action action ) tripoint p( x, y, g->u.posz() ); monster *const mon = g->critter_at( p ); if( mon && - ( ( g->m.ter( x, y - 1 ) == t_reinforced_glass && - g->m.ter( x, y + 1 ) == t_concrete_wall ) || - ( g->m.ter( x, y + 1 ) == t_reinforced_glass && - g->m.ter( x, y - 1 ) == t_concrete_wall ) ) ) { + ( ( g->m.ter( point( x, y - 1 ) ) == t_reinforced_glass && + g->m.ter( point( x, y + 1 ) ) == t_concrete_wall ) || + ( g->m.ter( point( x, y + 1 ) ) == t_reinforced_glass && + g->m.ter( point( x, y - 1 ) ) == t_concrete_wall ) ) ) { mon->die( &g->u ); } } @@ -749,7 +749,7 @@ void computer::activate_function( computer_action action ) case COMPACT_ELEVATOR_ON: for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.ter( x, y ) == t_elevator_control_off ) { + if( g->m.ter( point( x, y ) ) == t_elevator_control_off ) { g->m.ter_set( point( x, y ), t_elevator_control ); } } @@ -1195,18 +1195,18 @@ SHORTLY. TO ENSURE YOUR SAFETY PLEASE FOLLOW THE STEPS BELOW. \n\ for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { tripoint p( x, y, g->get_levz() ); - if( g->m.ter( x, y ) == t_elevator || g->m.ter( x, y ) == t_vat ) { + if( g->m.ter( point( x, y ) ) == t_elevator || g->m.ter( point( x, y ) ) == t_vat ) { g->m.make_rubble( p, f_rubble_rock, true ); explosion_handler::explosion( p, 40, 0.7, true ); } - if( g->m.ter( x, y ) == t_wall_glass ) { + if( g->m.ter( point( x, y ) ) == t_wall_glass ) { g->m.make_rubble( p, f_rubble_rock, true ); } - if( g->m.ter( x, y ) == t_sewage_pipe || g->m.ter( x, y ) == t_sewage || - g->m.ter( x, y ) == t_grate ) { + if( g->m.ter( point( x, y ) ) == t_sewage_pipe || g->m.ter( point( x, y ) ) == t_sewage || + g->m.ter( point( x, y ) ) == t_grate ) { g->m.make_rubble( p, f_rubble_rock, true ); } - if( g->m.ter( x, y ) == t_sewage_pump ) { + if( g->m.ter( point( x, y ) ) == t_sewage_pump ) { g->m.make_rubble( p, f_rubble_rock, true ); explosion_handler::explosion( p, 50, 0.7, true ); } @@ -1226,7 +1226,7 @@ SHORTLY. TO ENSURE YOUR SAFETY PLEASE FOLLOW THE STEPS BELOW. \n\ _( "\nPower: Backup Only\nRadiation Level: Very Dangerous\nOperational: Overridden\n\n" ) ); for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.ter( x, y ) == t_elevator_control_off ) { + if( g->m.ter( point( x, y ) ) == t_elevator_control_off ) { g->m.ter_set( point( x, y ), t_elevator_control ); } @@ -1498,7 +1498,7 @@ void computer::activate_failure( computer_failure_type fail ) } for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.has_flag( "CONSOLE", x, y ) ) { + if( g->m.has_flag( "CONSOLE", point( x, y ) ) ) { g->m.ter_set( point( x, y ), t_console_broken ); add_msg( m_bad, _( "The console shuts down." ) ); } @@ -1567,7 +1567,7 @@ void computer::activate_failure( computer_failure_type fail ) add_msg( m_warning, _( "The pump explodes!" ) ); for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.ter( x, y ) == t_sewage_pump ) { + if( g->m.ter( point( x, y ) ) == t_sewage_pump ) { tripoint p( x, y, g->get_levz() ); g->m.make_rubble( p ); explosion_handler::explosion( p, 10 ); @@ -1580,7 +1580,7 @@ void computer::activate_failure( computer_failure_type fail ) add_msg( m_warning, _( "Sewage leaks!" ) ); for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.ter( x, y ) == t_sewage_pump ) { + if( g->m.ter( point( x, y ) ) == t_sewage_pump ) { point p( x, y ); int leak_size = rng( 4, 10 ); for( int i = 0; i < leak_size; i++ ) { @@ -1650,7 +1650,7 @@ void computer::activate_failure( computer_failure_type fail ) print_error( _( "ERROR: ACCESSING DATA MALFUNCTION" ) ); for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - if( g->m.ter( x, y ) == t_floor_blue ) { + if( g->m.ter( point( x, y ) ) == t_floor_blue ) { map_stack items = g->m.i_at( point( x, y ) ); if( items.empty() ) { print_error( _( "ERROR: Please place memory bank in scan area." ) ); diff --git a/src/construction.cpp b/src/construction.cpp index 636b96452f293..1ff982dc09309 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -972,11 +972,11 @@ bool construct::check_support( const tripoint &p ) bool construct::check_deconstruct( const tripoint &p ) { - if( g->m.has_furn( p.x, p.y ) ) { - return g->m.furn( p.x, p.y ).obj().deconstruct.can_do; + if( g->m.has_furn( p.xy() ) ) { + return g->m.furn( p.xy() ).obj().deconstruct.can_do; } // terrain can only be deconstructed when there is no furniture in the way - return g->m.ter( p.x, p.y ).obj().deconstruct.can_do; + return g->m.ter( p.xy() ).obj().deconstruct.can_do; } bool construct::check_empty_up_OK( const tripoint &p ) diff --git a/src/explosion.cpp b/src/explosion.cpp index 4c97db7123ec3..ccb9849bab5ad 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -618,16 +618,16 @@ void emp_blast( const tripoint &p ) int x = p.x; int y = p.y; const bool sight = g->u.sees( p ); - if( g->m.has_flag( "CONSOLE", x, y ) ) { + if( g->m.has_flag( "CONSOLE", point( x, y ) ) ) { if( sight ) { - add_msg( _( "The %s is rendered non-functional!" ), g->m.tername( x, y ) ); + add_msg( _( "The %s is rendered non-functional!" ), g->m.tername( point( x, y ) ) ); } g->m.ter_set( point( x, y ), t_console_broken ); return; } // TODO: More terrain effects. - if( g->m.ter( x, y ) == t_card_science || g->m.ter( x, y ) == t_card_military || - g->m.ter( x, y ) == t_card_industrial ) { + if( g->m.ter( point( x, y ) ) == t_card_science || g->m.ter( point( x, y ) ) == t_card_military || + g->m.ter( point( x, y ) ) == t_card_industrial ) { int rn = rng( 1, 100 ); if( rn > 92 || rn < 40 ) { if( sight ) { @@ -641,7 +641,7 @@ void emp_blast( const tripoint &p ) } for( int i = -3; i <= 3; i++ ) { for( int j = -3; j <= 3; j++ ) { - if( g->m.ter( x + i, y + j ) == t_door_metal_locked ) { + if( g->m.ter( point( x + i, y + j ) ) == t_door_metal_locked ) { g->m.ter_set( point( x + i, y + j ), t_floor ); } } diff --git a/src/game.cpp b/src/game.cpp index 2d858d2e9eb68..237cb2f8e7a44 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -5170,7 +5170,7 @@ bool game::forced_door_closing( const tripoint &p, const ter_id &door_type, int } m.ter_set( point( x, y ), door_type ); - if( m.has_flag( "NOITEM", x, y ) ) { + if( m.has_flag( "NOITEM", point( x, y ) ) ) { map_stack items = m.i_at( point( x, y ) ); for( map_stack::iterator it = items.begin(); it != items.end(); ) { if( it->made_of( LIQUID ) ) { diff --git a/src/iuse.cpp b/src/iuse.cpp index a9da978c409d2..d6fe00cd491ed 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -7483,7 +7483,7 @@ int iuse::ehandcuffs( player *p, item *it, bool t, const tripoint &pos ) { if( t ) { - if( g->m.has_flag( "SWIMMABLE", pos.x, pos.y ) ) { + if( g->m.has_flag( "SWIMMABLE", pos.xy() ) ) { it->item_tags.erase( "NO_UNWIELD" ); it->ammo_unset(); it->active = false; diff --git a/src/map.cpp b/src/map.cpp index 2d64d37924fb0..1288b2ce6c132 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1180,7 +1180,7 @@ std::string map::name( const int x, const int y ) bool map::has_furn( const int x, const int y ) const { - return furn( x, y ) != f_null; + return furn( point( x, y ) ) != f_null; } furn_id map::furn( const int x, const int y ) const @@ -2189,7 +2189,7 @@ bool map::has_flag( const std::string &flag, const int x, const int y ) const bool map::can_put_items_ter_furn( const int x, const int y ) const { - return !has_flag( "NOITEM", x, y ) && !has_flag( "SEALED", x, y ); + return !has_flag( "NOITEM", point( x, y ) ) && !has_flag( "SEALED", point( x, y ) ); } bool map::has_flag_ter( const std::string &flag, const int x, const int y ) const @@ -2564,12 +2564,12 @@ void map::make_rubble( const tripoint &p, const furn_id &rubble_type, const bool */ bool map::is_divable( const int x, const int y ) const { - return has_flag( "SWIMMABLE", x, y ) && has_flag( TFLAG_DEEP_WATER, x, y ); + return has_flag( "SWIMMABLE", point( x, y ) ) && has_flag( TFLAG_DEEP_WATER, x, y ); } bool map::is_water_shallow_current( const int x, const int y ) const { - return has_flag( "CURRENT", x, y ) && !has_flag( TFLAG_DEEP_WATER, x, y ); + return has_flag( "CURRENT", point( x, y ) ) && !has_flag( TFLAG_DEEP_WATER, x, y ); } bool map::is_water_shallow_current( const tripoint &p ) const @@ -2632,12 +2632,12 @@ bool map::is_last_ter_wall( const bool no_furn, const int x, const int y, ( dir == SOUTH && y2 < ymax ) || ( dir == WEST && x2 >= 0 ) || ( dir == EAST && x2 < xmax ) ) ) { - if( no_furn && has_furn( x2, y2 ) ) { + if( no_furn && has_furn( point( x2, y2 ) ) ) { loop = false; result = false; - } else if( !has_flag_ter( "FLAT", x2, y2 ) ) { + } else if( !has_flag_ter( "FLAT", point( x2, y2 ) ) ) { loop = false; - if( !has_flag_ter( "WALL", x2, y2 ) ) { + if( !has_flag_ter( "WALL", point( x2, y2 ) ) ) { result = false; } } @@ -2767,7 +2767,7 @@ point map::random_outdoor_tile() std::vector options; for( int x = 0; x < SEEX * my_MAPSIZE; x++ ) { for( int y = 0; y < SEEY * my_MAPSIZE; y++ ) { - if( is_outside( x, y ) ) { + if( is_outside( point( x, y ) ) ) { options.push_back( point( x, y ) ); } } diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 8b72d66502078..9582a064dfc1f 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -177,13 +177,13 @@ static void mx_house_wasp( map &m, const tripoint & ) { for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( m.ter( i, j ) == t_door_c || m.ter( i, j ) == t_door_locked ) { + if( m.ter( point( i, j ) ) == t_door_c || m.ter( point( i, j ) ) == t_door_locked ) { m.ter_set( point( i, j ), t_door_frame ); } - if( m.ter( i, j ) == t_window_domestic && !one_in( 3 ) ) { + if( m.ter( point( i, j ) ) == t_window_domestic && !one_in( 3 ) ) { m.ter_set( point( i, j ), t_window_frame ); } - if( m.ter( i, j ) == t_wall && one_in( 8 ) ) { + if( m.ter( point( i, j ) ) == t_wall && one_in( 8 ) ) { m.ter_set( point( i, j ), t_paper ); } } @@ -220,12 +220,12 @@ static void mx_house_spider( map &m, const tripoint & ) } for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( m.ter( i, j ) == t_floor ) { + if( m.ter( point( i, j ) ) == t_floor ) { if( one_in( 15 ) ) { m.add_spawn( spider_type, rng( 1, 2 ), point( i, j ) ); for( int x = i - 1; x <= i + 1; x++ ) { for( int y = j - 1; y <= j + 1; y++ ) { - if( m.ter( x, y ) == t_floor ) { + if( m.ter( point( x, y ) ) == t_floor ) { madd_field( &m, x, y, fd_web, rng( 2, 3 ) ); if( one_in( 4 ) ) { m.furn_set( point( i, j ), egg_type ); @@ -268,7 +268,7 @@ static void mx_helicopter( map &m, const tripoint &abs_sub ) if( m.ter( tripoint( x, y, abs_sub.z ) )->has_flag( TFLAG_DIGGABLE ) ) { m.ter_set( tripoint( x, y, abs_sub.z ), t_dirtmound ); } - } else if( m.is_bashable( x, y ) ) { + } else if( m.is_bashable( point( x, y ) ) ) { m.destroy( tripoint( x, y, abs_sub.z ), true ); if( m.ter( tripoint( x, y, abs_sub.z ) )->has_flag( TFLAG_DIGGABLE ) ) { m.ter_set( tripoint( x, y, abs_sub.z ), t_dirtmound ); @@ -964,7 +964,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) //Spawn ordinary mine on asphalt, otherwise spawn buried mine for( int i = 0; i < num_mines; i++ ) { const int x = rng( 1, SEEX * 2 ), y = rng( SEEY, SEEY * 2 - 2 ); - if( m.has_flag( "DIGGABLE", x, y ) ) { + if( m.has_flag( "DIGGABLE", point( x, y ) ) ) { mtrap_set( &m, x, y, tr_landmine_buried ); } else { mtrap_set( &m, x, y, tr_landmine ); @@ -1065,7 +1065,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) //Spawn ordinary mine on asphalt, otherwise spawn buried mine for( int i = 0; i < num_mines; i++ ) { const int x = rng( 1, SEEX * 2 ), y = rng( 1, SEEY ); - if( m.has_flag( "DIGGABLE", x, y ) ) { + if( m.has_flag( "DIGGABLE", point( x, y ) ) ) { mtrap_set( &m, x, y, tr_landmine_buried ); } else { mtrap_set( &m, x, y, tr_landmine ); @@ -1209,7 +1209,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) //Spawn ordinary mine on asphalt, otherwise spawn buried mine for( int i = 0; i < num_mines; i++ ) { const int x = rng( SEEX + 1, SEEX * 2 - 2 ), y = rng( 1, SEEY * 2 ); - if( m.has_flag( "DIGGABLE", x, y ) ) { + if( m.has_flag( "DIGGABLE", point( x, y ) ) ) { mtrap_set( &m, x, y, tr_landmine_buried ); } else { mtrap_set( &m, x, y, tr_landmine ); @@ -1341,7 +1341,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) //Spawn ordinary mine on asphalt, otherwise spawn buried mine for( int i = 0; i < num_mines; i++ ) { const int x = rng( 1, SEEX ), y = rng( 1, SEEY * 2 ); - if( m.has_flag( "DIGGABLE", x, y ) ) { + if( m.has_flag( "DIGGABLE", point( x, y ) ) ) { mtrap_set( &m, x, y, tr_landmine_buried ); } else { mtrap_set( &m, x, y, tr_landmine ); @@ -1460,7 +1460,7 @@ static void mx_fumarole( map &m, const tripoint &abs_sub ) for( auto &i : ignited ) { // Don't need to do anything to tiles that already have lava on them - if( m.ter( i.x, i.y ) != t_lava ) { + if( m.ter( i ) != t_lava ) { // Spawn an intense but short-lived fire // Any furniture or buildings will catch fire, otherwise it will burn out quickly m.add_field( tripoint( i, abs_sub.z ), fd_fire, 15, 1_minutes ); @@ -1563,7 +1563,7 @@ static void mx_portal_in( map &m, const tripoint &abs_sub ) for( auto &i : ignited ) { // Don't need to do anything to tiles that already have lava on them - if( m.ter( i.x, i.y ) != t_lava ) { + if( m.ter( i ) != t_lava ) { // Spawn an intense but short-lived fire // Any furniture or buildings will catch fire, otherwise it will burn out quickly m.add_field( tripoint( i, abs_sub.z ), fd_fire, 15, 1_minutes ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 4383da4a9fcf3..48dfdbd782159 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1379,10 +1379,10 @@ class jmapgen_terrain : public jmapgen_piece const float /*mdensity*/, mission * ) const override { dat.m.ter_set( point( x.get(), y.get() ), id ); // Delete furniture if a wall was just placed over it. TODO: need to do anything for fluid, monsters? - if( dat.m.has_flag_ter( "WALL", x.get(), y.get() ) ) { + if( dat.m.has_flag_ter( "WALL", point( x.get(), y.get() ) ) ) { dat.m.furn_set( point( x.get(), y.get() ), f_null ); // and items, unless the wall has PLACE_ITEM flag indicating it stores things. - if( !dat.m.has_flag_ter( "PLACE_ITEM", x.get(), y.get() ) ) { + if( !dat.m.has_flag_ter( "PLACE_ITEM", point( x.get(), y.get() ) ) ) { dat.m.i_clear( tripoint( x.get(), y.get(), dat.m.get_abs_sub().z ) ); } } @@ -2423,7 +2423,7 @@ bool jmapgen_setmap::apply( const mapgendata &dat, const point &offset, mission } break; case JMAPGEN_SETMAP_RADIATION: { - m.set_radiation( x_get(), y_get(), val.get() ); + m.set_radiation( point( x_get(), y_get() ), val.get() ); } break; case JMAPGEN_SETMAP_BASH: { @@ -2452,7 +2452,7 @@ bool jmapgen_setmap::apply( const mapgendata &dat, const point &offset, mission case JMAPGEN_SETMAP_LINE_RADIATION: { const std::vector line = line_to( x_get(), y_get(), x2_get(), y2_get(), 0 ); for( auto &i : line ) { - m.set_radiation( i.x, i.y, static_cast( val.get() ) ); + m.set_radiation( i, static_cast( val.get() ) ); } } break; @@ -2486,7 +2486,7 @@ bool jmapgen_setmap::apply( const mapgendata &dat, const point &offset, mission const int cy2 = y2_get(); for( int tx = cx; tx <= cx2; tx++ ) { for( int ty = cy; ty <= cy2; ty++ ) { - m.set_radiation( tx, ty, static_cast( val.get() ) ); + m.set_radiation( point( tx, ty ), static_cast( val.get() ) ); } } } @@ -3395,7 +3395,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi ter_set( point( i, j ), t_sewage ); } if( ( i == 0 && is_ot_match( "lab", dat.east(), ot_match_type::contains ) ) || i == EAST_EDGE ) { - if( ter( i, j ) == t_sewage ) { + if( ter( point( i, j ) ) == t_sewage ) { ter_set( point( i, j ), t_bars ); } else if( j == SEEY - 1 || j == SEEY ) { ter_set( point( i, j ), t_door_metal_c ); @@ -3404,7 +3404,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi } } else if( ( j == 0 && is_ot_match( "lab", dat.north(), ot_match_type::contains ) ) || j == SOUTH_EDGE ) { - if( ter( i, j ) == t_sewage ) { + if( ter( point( i, j ) ) == t_sewage ) { ter_set( point( i, j ), t_bars ); } else if( i == SEEX - 1 || i == SEEX ) { ter_set( point( i, j ), t_door_metal_c ); @@ -3752,7 +3752,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi if( i + j > 10 && i + j < 36 && abs( i - j ) < 13 ) { // Doors and walls get sometimes destroyed: // 100% at the edge, usually in a central cross, occasionally elsewhere. - if( ( has_flag_ter( "DOOR", i, j ) || has_flag_ter( "WALL", i, j ) ) ) { + if( ( has_flag_ter( "DOOR", point( i, j ) ) || has_flag_ter( "WALL", point( i, j ) ) ) ) { if( ( i == 0 || j == 0 || i == 23 || j == 23 ) || ( !one_in( 3 ) && ( i == 11 || i == 12 || j == 11 || j == 12 ) ) || one_in( 4 ) ) { @@ -3765,11 +3765,11 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi } // and then randomly destroy 5% of the remaining nonstairs. } else if( one_in( 20 ) && - !has_flag_ter( "GOES_DOWN", x, y ) && - !has_flag_ter( "GOES_UP", x, y ) ) { + !has_flag_ter( "GOES_DOWN", point( x, y ) ) && + !has_flag_ter( "GOES_UP", point( x, y ) ) ) { destroy( { i, j, abs_sub.z } ); // bashed squares can create dirt & floors, but we want rock floors. - if( t_dirt == ter( i, j ) || t_floor == ter( i, j ) ) { + if( t_dirt == ter( point( i, j ) ) || t_floor == ter( point( i, j ) ) ) { ter_set( point( i, j ), t_rock_floor ); } } @@ -3812,7 +3812,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { if( !( ( i * j ) % 2 || ( i + j ) % 4 ) && one_in( light_odds ) ) { - if( t_thconc_floor == ter( i, j ) || t_strconc_floor == ter( i, j ) ) { + if( t_thconc_floor == ter( point( i, j ) ) || t_strconc_floor == ter( point( i, j ) ) ) { ter_set( point( i, j ), t_thconc_floor_olight ); } } @@ -3840,11 +3840,11 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi for( int i = 0; i < EAST_EDGE; i++ ) { for( int j = 0; j < SOUTH_EDGE; j++ ) { // We spare some terrain to make it look better visually. - if( !one_in( 10 ) && ( t_thconc_floor == ter( i, j ) || - t_strconc_floor == ter( i, j ) || - t_thconc_floor_olight == ter( i, j ) ) ) { + if( !one_in( 10 ) && ( t_thconc_floor == ter( point( i, j ) ) || + t_strconc_floor == ter( point( i, j ) ) || + t_thconc_floor_olight == ter( point( i, j ) ) ) ) { ter_set( point( i, j ), fluid_type ); - } else if( has_flag_ter( "DOOR", i, j ) && !one_in( 3 ) ) { + } else if( has_flag_ter( "DOOR", point( i, j ) ) && !one_in( 3 ) ) { // We want the actual debris, but not the rubble marker or dirt. make_rubble( { i, j, abs_sub.z } ); ter_set( point( i, j ), fluid_type ); @@ -3885,8 +3885,8 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi bool is_toxic = one_in( 3 ); for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( one_in( 200 ) && ( t_thconc_floor == ter( i, j ) || - t_strconc_floor == ter( i, j ) ) ) { + if( one_in( 200 ) && ( t_thconc_floor == ter( point( i, j ) ) || + t_strconc_floor == ter( point( i, j ) ) ) ) { if( is_toxic ) { add_field( {i, j, abs_sub.z}, fd_gas_vent, 1 ); } else { @@ -3925,7 +3925,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi // radioactive accident. case 6: { tripoint center( rng( 6, SEEX * 2 - 7 ), rng( 6, SEEY * 2 - 7 ), abs_sub.z ); - if( has_flag_ter( "WALL", center.x, center.y ) ) { + if( has_flag_ter( "WALL", center.xy() ) ) { // just skip it, we don't want to risk embedding radiation out of sight. break; } @@ -3975,14 +3975,14 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi for( int i = 0; i < EAST_EDGE; i++ ) { for( int j = 0; j < SOUTH_EDGE; j++ ) { // Create a mostly spread fungal area throughout entire lab. - if( !one_in( 5 ) && ( has_flag( "FLAT", i, j ) ) ) { + if( !one_in( 5 ) && ( has_flag( "FLAT", point( i, j ) ) ) ) { ter_set( point( i, j ), t_fungus_floor_in ); - if( has_flag_furn( "ORGANIC", i, j ) ) { + if( has_flag_furn( "ORGANIC", point( i, j ) ) ) { furn_set( point( i, j ), f_fungal_clump ); } - } else if( has_flag_ter( "DOOR", i, j ) && !one_in( 5 ) ) { + } else if( has_flag_ter( "DOOR", point( i, j ) ) && !one_in( 5 ) ) { ter_set( point( i, j ), t_fungus_floor_in ); - } else if( has_flag_ter( "WALL", i, j ) && one_in( 3 ) ) { + } else if( has_flag_ter( "WALL", point( i, j ) ) && one_in( 3 ) ) { ter_set( point( i, j ), t_fungus_wall ); } } @@ -4326,7 +4326,7 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { if( !( ( i * j ) % 2 || ( i + j ) % 4 ) && one_in( light_odds ) ) { - if( t_thconc_floor == ter( i, j ) || t_strconc_floor == ter( i, j ) ) { + if( t_thconc_floor == ter( point( i, j ) ) || t_strconc_floor == ter( point( i, j ) ) ) { ter_set( point( i, j ), t_thconc_floor_olight ); } } @@ -4477,7 +4477,7 @@ void map::draw_temple( const oter_id &terrain_type, mapgendata &dat, const time_ mtrap_set( this, SEEX + 1, SEEY * 2 - 2, tr_temple_flood ); for( int y = 2; y < SEEY * 2 - 2; y++ ) { for( int x = 2; x < SEEX * 2 - 2; x++ ) { - if( ter( x, y ) == t_rock_floor && one_in( 4 ) ) { + if( ter( point( x, y ) ) == t_rock_floor && one_in( 4 ) ) { mtrap_set( this, x, y, tr_temple_flood ); } } @@ -4514,51 +4514,51 @@ void map::draw_temple( const oter_id &terrain_type, mapgendata &dat, const time_ for( int x = SEEX; x <= SEEX + 1; x++ ) { switch( action ) { case 1: // Toggle RG - if( ter( x, y ) == t_floor_red ) { + if( ter( point( x, y ) ) == t_floor_red ) { ter_set( point( x, y ), t_rock_red ); - } else if( ter( x, y ) == t_rock_red ) { + } else if( ter( point( x, y ) ) == t_rock_red ) { ter_set( point( x, y ), t_floor_red ); - } else if( ter( x, y ) == t_floor_green ) { + } else if( ter( point( x, y ) ) == t_floor_green ) { ter_set( point( x, y ), t_rock_green ); - } else if( ter( x, y ) == t_rock_green ) { + } else if( ter( point( x, y ) ) == t_rock_green ) { ter_set( point( x, y ), t_floor_green ); } break; case 2: // Toggle GB - if( ter( x, y ) == t_floor_blue ) { + if( ter( point( x, y ) ) == t_floor_blue ) { ter_set( point( x, y ), t_rock_blue ); - } else if( ter( x, y ) == t_rock_blue ) { + } else if( ter( point( x, y ) ) == t_rock_blue ) { ter_set( point( x, y ), t_floor_blue ); - } else if( ter( x, y ) == t_floor_green ) { + } else if( ter( point( x, y ) ) == t_floor_green ) { ter_set( point( x, y ), t_rock_green ); - } else if( ter( x, y ) == t_rock_green ) { + } else if( ter( point( x, y ) ) == t_rock_green ) { ter_set( point( x, y ), t_floor_green ); } break; case 3: // Toggle RB - if( ter( x, y ) == t_floor_blue ) { + if( ter( point( x, y ) ) == t_floor_blue ) { ter_set( point( x, y ), t_rock_blue ); - } else if( ter( x, y ) == t_rock_blue ) { + } else if( ter( point( x, y ) ) == t_rock_blue ) { ter_set( point( x, y ), t_floor_blue ); - } else if( ter( x, y ) == t_floor_red ) { + } else if( ter( point( x, y ) ) == t_floor_red ) { ter_set( point( x, y ), t_rock_red ); - } else if( ter( x, y ) == t_rock_red ) { + } else if( ter( point( x, y ) ) == t_rock_red ) { ter_set( point( x, y ), t_floor_red ); } break; case 4: // Toggle Even if( y % 2 == 0 ) { - if( ter( x, y ) == t_floor_blue ) { + if( ter( point( x, y ) ) == t_floor_blue ) { ter_set( point( x, y ), t_rock_blue ); - } else if( ter( x, y ) == t_rock_blue ) { + } else if( ter( point( x, y ) ) == t_rock_blue ) { ter_set( point( x, y ), t_floor_blue ); - } else if( ter( x, y ) == t_floor_red ) { + } else if( ter( point( x, y ) ) == t_floor_red ) { ter_set( point( x, y ), t_rock_red ); - } else if( ter( x, y ) == t_rock_red ) { + } else if( ter( point( x, y ) ) == t_rock_red ) { ter_set( point( x, y ), t_floor_red ); - } else if( ter( x, y ) == t_floor_green ) { + } else if( ter( point( x, y ) ) == t_floor_green ) { ter_set( point( x, y ), t_rock_green ); - } else if( ter( x, y ) == t_rock_green ) { + } else if( ter( point( x, y ) ) == t_rock_green ) { ter_set( point( x, y ), t_floor_green ); } } @@ -4592,7 +4592,7 @@ void map::draw_temple( const oter_id &terrain_type, mapgendata &dat, const time_ std::vector next; for( int nx = x - 1; nx <= x + 1; nx++ ) { for( int ny = y; ny <= y + 1; ny++ ) { - if( ter( nx, ny ) == t_rock_floor ) { + if( ter( point( nx, ny ) ) == t_rock_floor ) { next.push_back( point( nx, ny ) ); } } @@ -4611,17 +4611,17 @@ void map::draw_temple( const oter_id &terrain_type, mapgendata &dat, const time_ bool toggle_green = false; bool toggle_blue = false; for( int i = path.size() - 1; i >= 0; i-- ) { - if( ter( path[i].x, path[i].y ) == t_floor_red ) { + if( ter( point( path[i].x, path[i].y ) ) == t_floor_red ) { toggle_green = !toggle_green; if( toggle_red ) { ter_set( point( path[i].x, path[i].y ), t_rock_red ); } - } else if( ter( path[i].x, path[i].y ) == t_floor_green ) { + } else if( ter( point( path[i].x, path[i].y ) ) == t_floor_green ) { toggle_blue = !toggle_blue; if( toggle_green ) { ter_set( point( path[i].x, path[i].y ), t_rock_green ); } - } else if( ter( path[i].x, path[i].y ) == t_floor_blue ) { + } else if( ter( point( path[i].x, path[i].y ) ) == t_floor_blue ) { toggle_red = !toggle_red; if( toggle_blue ) { ter_set( point( path[i].x, path[i].y ), t_rock_blue ); @@ -4632,7 +4632,7 @@ void map::draw_temple( const oter_id &terrain_type, mapgendata &dat, const time_ for( int i = SEEX - 3; i <= SEEX + 4; i++ ) { for( int j = 2; j <= SEEY * 2 - 2; j++ ) { mtrap_set( this, i, j, tr_temple_toggle ); - if( ter( i, j ) == t_rock_floor ) { + if( ter( point( i, j ) ) == t_rock_floor ) { ter_set( point( i, j ), ter_id( rng( t_rock_red, t_floor_blue ) ) ); } } @@ -4943,7 +4943,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po bool okay = true; for( int x = x1 - 1; x <= x2 + 1 && okay; x++ ) { for( int y = y1 - 1; y <= y2 + 1 && okay; y++ ) { - okay = dat.is_groundcover( ter( x, y ) ); + okay = dat.is_groundcover( ter( point( x, y ) ) ); } } if( okay ) { @@ -4956,7 +4956,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po } } while( tries < 5 ); int ladderx = rng( 0, EAST_EDGE ), laddery = rng( 0, SOUTH_EDGE ); - while( !dat.is_groundcover( ter( ladderx, laddery ) ) ) { + while( !dat.is_groundcover( ter( point( ladderx, laddery ) ) ) ) { ladderx = rng( 0, EAST_EDGE ); laddery = rng( 0, SOUTH_EDGE ); } @@ -5161,7 +5161,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po okay = true; for( int i = p.x; ( i <= p.x + 5 ) && okay; i++ ) { for( int j = p.y; ( j <= p.y + 5 ) && okay; j++ ) { - if( ter( i, j ) != t_rock_floor ) { + if( ter( point( i, j ) ) != t_rock_floor ) { okay = false; } } @@ -5200,16 +5200,16 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po if( dat.above() == "mine_down" ) { // Don't forget to build a slope up! std::vector open; - if( dat.n_fac == 6 && ter( SEEX, 6 ) != t_slope_down ) { + if( dat.n_fac == 6 && ter( point( SEEX, 6 ) ) != t_slope_down ) { open.push_back( NORTH ); } - if( dat.e_fac == 6 && ter( SEEX * 2 - 7, SEEY ) != t_slope_down ) { + if( dat.e_fac == 6 && ter( point( SEEX * 2 - 7, SEEY ) ) != t_slope_down ) { open.push_back( EAST ); } - if( dat.s_fac == 6 && ter( SEEX, SEEY * 2 - 7 ) != t_slope_down ) { + if( dat.s_fac == 6 && ter( point( SEEX, SEEY * 2 - 7 ) ) != t_slope_down ) { open.push_back( SOUTH ); } - if( dat.w_fac == 6 && ter( 6, SEEY ) != t_slope_down ) { + if( dat.w_fac == 6 && ter( point( 6, SEEY ) ) != t_slope_down ) { open.push_back( WEST ); } @@ -5223,7 +5223,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po okay = true; for( int i = p.x; ( i <= p.x + 5 ) && okay; i++ ) { for( int j = p.y; ( j <= p.y + 5 ) && okay; j++ ) { - if( ter( i, j ) != t_rock_floor ) { + if( ter( point( i, j ) ) != t_rock_floor ) { okay = false; } } @@ -5727,17 +5727,17 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, "####|-------------------\n", b_ter_key, b_fur_key ); for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( this->ter( i, j ) == t_rock_floor ) { + if( this->ter( point( i, j ) ) == t_rock_floor ) { if( one_in( 250 ) ) { add_item( point( i, j ), item::make_corpse() ); place_items( "science", 70, point( i, j ), point( i, j ), true, 0 ); } place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } - if( this->ter( i, j ) != t_metal_floor ) { + if( this->ter( point( i, j ) ) != t_metal_floor ) { adjust_radiation( i, j, rng( 10, 70 ) ); } - if( this->ter( i, j ) == t_sewage ) { + if( this->ter( point( i, j ) ) == t_sewage ) { if( one_in( 2 ) ) { ter_set( point( i, j ), t_dirtfloor ); } @@ -5798,10 +5798,10 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, "|---------|#.........|-$\n", b_ter_key, b_fur_key ); for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( this->furn( i, j ) == f_rack ) { + if( this->furn( point( i, j ) ) == f_rack ) { place_items( "mechanics", 60, point( i, j ), point( i, j ), false, 0 ); } - if( this->ter( i, j ) == t_rock_floor ) { + if( this->ter( point( i, j ) ) == t_rock_floor ) { if( one_in( 250 ) ) { add_item( point( i, j ), item::make_corpse() ); place_items( "science", 70, point( i, j ), point( i, j ), true, 0 ); @@ -5809,10 +5809,10 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, place_spawns( GROUP_PLAIN, 1, point( i, j ), point( i, j ), 1, true ); } } - if( this->ter( i, j ) != t_metal_floor ) { + if( this->ter( point( i, j ) ) != t_metal_floor ) { adjust_radiation( i, j, rng( 10, 70 ) ); } - if( this->ter( i, j ) == t_sewage ) { + if( this->ter( point( i, j ) ) == t_sewage ) { if( one_in( 2 ) ) { ter_set( point( i, j ), t_dirtfloor ); } @@ -5869,17 +5869,17 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, "|-------------------|###\n", b_ter_key, b_fur_key ); for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( this->ter( i, j ) == t_rock_floor ) { + if( this->ter( point( i, j ) ) == t_rock_floor ) { if( one_in( 250 ) ) { add_item( point( i, j ), item::make_corpse() ); place_items( "science", 70, point( i, j ), point( i, j ), true, 0 ); } place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } - if( this->ter( i, j ) != t_metal_floor ) { + if( this->ter( point( i, j ) ) != t_metal_floor ) { adjust_radiation( i, j, rng( 10, 70 ) ); } - if( this->ter( i, j ) == t_sewage ) { + if( this->ter( point( i, j ) ) == t_sewage ) { if( one_in( 2 ) ) { ter_set( point( i, j ), t_dirtfloor ); } @@ -5936,26 +5936,26 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, spawn_item( point( 3, 16 ), "sarcophagus_access_code" ); for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( this->furn( i, j ) == f_locker ) { + if( this->furn( point( i, j ) ) == f_locker ) { place_items( "cleaning", 60, point( i, j ), point( i, j ), false, 0 ); } - if( this->furn( i, j ) == f_desk ) { + if( this->furn( point( i, j ) ) == f_desk ) { place_items( "cubical_office", 60, point( i, j ), point( i, j ), false, 0 ); } - if( this->furn( i, j ) == f_rack ) { + if( this->furn( point( i, j ) ) == f_rack ) { place_items( "sewage_plant", 60, point( i, j ), point( i, j ), false, 0 ); } - if( this->ter( i, j ) == t_rock_floor ) { + if( this->ter( point( i, j ) ) == t_rock_floor ) { if( one_in( 250 ) ) { add_item( point( i, j ), item::make_corpse() ); place_items( "science", 70, point( i, j ), point( i, j ), true, 0 ); } place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } - if( this->ter( i, j ) != t_metal_floor ) { + if( this->ter( point( i, j ) ) != t_metal_floor ) { adjust_radiation( i, j, rng( 10, 70 ) ); } - if( this->ter( i, j ) == t_sewage ) { + if( this->ter( point( i, j ) ) == t_sewage ) { if( one_in( 2 ) ) { ter_set( point( i, j ), t_dirtfloor ); } @@ -6170,7 +6170,7 @@ void map::draw_megastore( const oter_id &terrain_type, mapgendata &dat, const ti // Add some spawns for( int i = 0; i < 15; i++ ) { int x = rng( 0, EAST_EDGE ), y = rng( 0, SOUTH_EDGE ); - if( ter( x, y ) == t_floor ) { + if( ter( point( x, y ) ) == t_floor ) { place_spawns( GROUP_PLAIN, 1, point( x, y ), point( x, y ), 1, true ); } } @@ -6605,16 +6605,16 @@ void map::draw_triffid( const oter_id &terrain_type, mapgendata &/*dat*/, int chance_north = 0; int chance_south = 0; for( int dist = 1; dist <= 5; dist++ ) { - if( ter( x - dist, y ) == t_root_wall ) { + if( ter( point( x - dist, y ) ) == t_root_wall ) { chance_west++; } - if( ter( x + dist, y ) == t_root_wall ) { + if( ter( point( x + dist, y ) ) == t_root_wall ) { chance_east++; } - if( ter( x, y - dist ) == t_root_wall ) { + if( ter( point( x, y - dist ) ) == t_root_wall ) { chance_north++; } - if( ter( x, y + dist ) == t_root_wall ) { + if( ter( point( x, y + dist ) ) == t_root_wall ) { chance_south++; } } @@ -6775,8 +6775,8 @@ void map::draw_connections( const oter_id &terrain_type, mapgendata &dat, for( int x = SEEX * 2 - 4; x < SEEX * 2; x++ ) { if( x - y > SEEX * 2 - 4 ) { // TODO: more discriminating conditions - if( ter( x, y ) == t_grass || ter( x, y ) == t_dirt || - ter( x, y ) == t_shrub ) { + if( ter( point( x, y ) ) == t_grass || ter( point( x, y ) ) == t_dirt || + ter( point( x, y ) ) == t_shrub ) { ter_set( point( x, y ), t_sidewalk ); } } @@ -6948,7 +6948,7 @@ std::vector map::place_items( const items_location &loc, int chance, con // Might contain one item or several that belong together like guns & their ammo int tries = 0; auto is_valid_terrain = [this, ongrass]( int x, int y ) { - auto &terrain = ter( x, y ).obj(); + auto &terrain = ter( point( x, y ) ).obj(); return terrain.movecost == 0 && !terrain.has_flag( "PLACE_ITEM" ) && !ongrass && @@ -7762,7 +7762,7 @@ void set_science_room( map *m, int x1, int y1, bool faces_right, const time_poin std::vector itrot[SEEX * 2][SEEY * 2]; for( int i = x1; i <= x2; i++ ) { for( int j = y1; j <= y2; j++ ) { - rotated[i][j] = m->ter( i, j ); + rotated[i][j] = m->ter( point( i, j ) ); auto items = m->i_at( point( i, j ) ); itrot[i][j].reserve( items.size() ); std::copy( items.begin(), items.end(), std::back_inserter( itrot[i][j] ) ); @@ -7812,13 +7812,13 @@ void silo_rooms( map *m ) } } if( !rooms.empty() && // We need at least one room! - ( m->ter( x, y ) != t_rock || m->ter( x + width, y + height ) != t_rock ) ) { + ( m->ter( point( x, y ) ) != t_rock || m->ter( point( x + width, y + height ) ) != t_rock ) ) { okay = false; } else { rooms.emplace_back( point( x, y ), point( width, height ) ); for( int i = x; i <= x + width; i++ ) { for( int j = y; j <= y + height; j++ ) { - if( m->ter( i, j ) == t_rock ) { + if( m->ter( point( i, j ) ) == t_rock ) { m->ter_set( point( i, j ), t_floor ); } } @@ -7892,7 +7892,7 @@ void silo_rooms( map *m ) int y = origin.y + origsize.y; bool x_first = ( abs( origin.x - dest.x ) > abs( origin.y - dest.y ) ); while( x != dest.x || y != dest.y ) { - if( m->ter( x, y ) == t_rock ) { + if( m->ter( point( x, y ) ) == t_rock ) { m->ter_set( point( x, y ), t_floor ); } if( ( x_first && x != dest.x ) || ( !x_first && y == dest.y ) ) { @@ -8103,7 +8103,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_MOVING: for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { - if( furn( i, j ) == f_rubble ) { + if( furn( point( i, j ) ) == f_rubble ) { add_field( {i, j, abs_sub.z}, fd_push_items, 1 ); if( one_in( 3 ) ) { spawn_item( point( i, j ), "rock" ); @@ -8117,7 +8117,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_GLITTERING: for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { - if( furn( i, j ) == f_rubble && one_in( 2 ) ) { + if( furn( point( i, j ) ) == f_rubble && one_in( 2 ) ) { mtrap_set( this, i, j, tr_glow ); } } @@ -8128,7 +8128,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_RATTLING: for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { - if( furn( i, j ) == f_rubble && one_in( 2 ) ) { + if( furn( point( i, j ) ) == f_rubble && one_in( 2 ) ) { mtrap_set( this, i, j, tr_hum ); } } @@ -8139,7 +8139,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_ENGRAVED: for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { - if( furn( i, j ) == f_rubble && one_in( 3 ) ) { + if( furn( point( i, j ) ) == f_rubble && one_in( 3 ) ) { mtrap_set( this, i, j, tr_shadow ); } } @@ -8162,7 +8162,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_DEAD: for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { - if( furn( i, j ) == f_rubble ) { + if( furn( point( i, j ) ) == f_rubble ) { mtrap_set( this, i, j, tr_drain ); } } @@ -8172,8 +8172,8 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_ITCHY: for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { - if( furn( i, j ) == f_rubble ) { - set_radiation( i, j, rng( 0, 10 ) ); + if( furn( point( i, j ) ) == f_rubble ) { + set_radiation( point( i, j ), rng( 0, 10 ) ); } } } @@ -8191,7 +8191,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_WARM: for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { - if( furn( i, j ) == f_rubble ) { + if( furn( point( i, j ) ) == f_rubble ) { add_field( {i, j, abs_sub.z}, fd_fire_vent, 1 + ( rl_dist( cx, cy, i, j ) % 3 ) ); } } @@ -8201,7 +8201,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_SCALED: for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { - if( furn( i, j ) == f_rubble ) { + if( furn( point( i, j ) ) == f_rubble ) { mtrap_set( this, i, j, tr_snake ); } } diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 4820e8d3b732b..2e4271b3b036c 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -343,7 +343,7 @@ void mapgen_null( map *m, oter_id, mapgendata, const time_point &, float ) for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { m->ter_set( point( i, j ), t_null ); - m->set_radiation( i, j, 0 ); + m->set_radiation( point( i, j ), 0 ); } } } @@ -362,10 +362,10 @@ void mapgen_crater( map *m, oter_id, mapgendata dat, const time_point &turn, flo rng( 0, dat.n_fac ) <= j && rng( 0, dat.s_fac ) <= SEEX * 2 - 1 - j ) { m->ter_set( point( i, j ), t_dirt ); m->make_rubble( tripoint( i, j, m->get_abs_sub().z ), f_rubble_rock, true ); - m->set_radiation( i, j, rng( 0, 4 ) * rng( 0, 2 ) ); + m->set_radiation( point( i, j ), rng( 0, 4 ) * rng( 0, 2 ) ); } else { m->ter_set( point( i, j ), dat.groundcover() ); - m->set_radiation( i, j, rng( 0, 2 ) * rng( 0, 2 ) * rng( 0, 2 ) ); + m->set_radiation( point( i, j ), rng( 0, 2 ) * rng( 0, 2 ) * rng( 0, 2 ) ); } } } @@ -635,7 +635,7 @@ void mapgen_spider_pit( map *m, oter_id, mapgendata dat, const time_point &turn, for( int x1 = x - 3; x1 <= x + 3; x1++ ) { for( int y1 = y - 3; y1 <= y + 3; y1++ ) { madd_field( m, x1, y1, fd_web, rng( 2, 3 ) ); - if( m->ter( x1, y1 ) != t_slope_down ) { + if( m->ter( point( x1, y1 ) ) != t_slope_down ) { m->ter_set( point( x1, y1 ), t_dirt ); } } @@ -2072,9 +2072,9 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend m->ter_set( point( i, j ), t_fence ); } else { m->ter_set( point( i, j ), t_grass ); - if( one_in( 35 ) && !m->has_furn( i, j ) ) { + if( one_in( 35 ) && !m->has_furn( point( i, j ) ) ) { m->ter_set( point( i, j ), t_tree_young ); - } else if( one_in( 35 ) && !m->has_furn( i, j ) ) { + } else if( one_in( 35 ) && !m->has_furn( point( i, j ) ) ) { m->ter_set( point( i, j ), t_tree ); } else if( one_in( 25 ) ) { m->ter_set( point( i, j ), t_dirt ); @@ -2088,9 +2088,9 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend for( int i = x1; i <= x2; i++ ) { for( int j = y1; j <= y2; j++ ) { - if( dat.is_groundcover( m->ter( i, j ) ) || + if( dat.is_groundcover( m->ter( point( i, j ) ) ) || //m->ter(i, j) == t_grass || m->ter(i, j) == t_dirt || - m->ter( i, j ) == t_floor ) { + m->ter( point( i, j ) ) == t_floor ) { if( j == y1 || j == y2 ) { m->ter_set( point( i, j ), t_wall ); } else if( i == x1 || i == x2 ) { @@ -2125,12 +2125,12 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend m->furn_set( point( x1 + 2, y2 - 1 ), f_desk ); while( pos_x1 < x2 ) { pos_x1 += 1; - if( m->ter( pos_x1, pos_y1 ) == t_wall ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_wall ) { break; } m->furn_set( point( pos_x1, pos_y1 ), f_bookcase ); pos_x1 += 1; - if( m->ter( pos_x1, pos_y1 ) == t_wall ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_wall ) { break; } m->furn_set( point( pos_x1, pos_y1 ), f_bookcase ); @@ -2143,12 +2143,12 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend m->furn_set( point( x1 + 2, y2 - 1 ), f_desk ); while( pos_x1 > x1 ) { pos_x1 -= 1; - if( m->ter( pos_x1, pos_y1 ) == t_wall ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_wall ) { break; } m->furn_set( point( pos_x1, pos_y1 ), f_bookcase ); pos_x1 -= 1; - if( m->ter( pos_x1, pos_y1 ) == t_wall ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_wall ) { break; } m->furn_set( point( pos_x1, pos_y1 ), f_bookcase ); @@ -2161,12 +2161,12 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend m->furn_set( point( x1 + 2, y2 - 1 ), f_desk ); while( pos_x1 < x2 ) { pos_x1 += 1; - if( m->ter( pos_x1, pos_y1 ) == t_wall ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_wall ) { break; } m->furn_set( point( pos_x1, pos_y1 ), f_bookcase ); pos_x1 += 1; - if( m->ter( pos_x1, pos_y1 ) == t_wall ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_wall ) { break; } m->furn_set( point( pos_x1, pos_y1 ), f_bookcase ); @@ -2179,12 +2179,12 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend m->furn_set( point( x1 + 2, y2 - 1 ), f_desk ); while( pos_x1 > x1 ) { pos_x1 -= 1; - if( m->ter( pos_x1, pos_y1 ) == t_wall ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_wall ) { break; } m->furn_set( point( pos_x1, pos_y1 ), f_bookcase ); pos_x1 -= 1; - if( m->ter( pos_x1, pos_y1 ) == t_wall ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_wall ) { break; } m->furn_set( point( pos_x1, pos_y1 ), f_bookcase ); @@ -2280,9 +2280,10 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend for( int i = 0; i <= 2; i++ ) { pos_x1 = rng( x1 + 2, x2 - 2 ); pos_y1 = rng( y1 + 1, y2 - 1 ); - if( m->ter( pos_x1, pos_y1 ) == t_floor && !( m->furn( pos_x1, pos_y1 ) == f_cupboard || - m->furn( pos_x1, pos_y1 ) == f_oven || m->furn( pos_x1, pos_y1 ) == f_sink || - m->furn( pos_x1, pos_y1 ) == f_fridge ) ) { + if( m->ter( point( pos_x1, pos_y1 ) ) == t_floor && + !( m->furn( point( pos_x1, pos_y1 ) ) == f_cupboard || + m->furn( point( pos_x1, pos_y1 ) ) == f_oven || m->furn( point( pos_x1, pos_y1 ) ) == f_sink || + m->furn( point( pos_x1, pos_y1 ) ) == f_fridge ) ) { m->furn_set( point( pos_x1, pos_y1 ), f_chair ); } } @@ -2371,10 +2372,11 @@ void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgend placed = "softdrugs"; chance = 72; m->furn_set( point( x2 - 1, y2 - 2 ), f_bathtub ); - if( one_in( 3 ) && !( m->ter( x2 - 1, y2 - 3 ) == t_wall ) ) { + if( one_in( 3 ) && !( m->ter( point( x2 - 1, y2 - 3 ) ) == t_wall ) ) { m->furn_set( point( x2 - 1, y2 - 3 ), f_bathtub ); } - if( !( ( m->furn( x1 + 1, y2 - 2 ) == f_toilet ) || ( m->furn( x1 + 1, y2 - 2 ) == f_bathtub ) ) ) { + if( !( ( m->furn( point( x1 + 1, y2 - 2 ) ) == f_toilet ) || + ( m->furn( point( x1 + 1, y2 - 2 ) ) == f_bathtub ) ) ) { m->furn_set( point( x1 + 1, y2 - 2 ), f_sink ); } if( one_in( 4 ) ) { @@ -2732,7 +2734,7 @@ void mapgen_generic_house( map *m, oter_id terrain_type, mapgendata dat, const t if( one_in( 4 ) ) { m->ter_set( point( rng( rw - 2, rw - 1 ), bw ), t_window_domestic ); } else { - m->ter( rw, rng( cw + 1, bw - 1 ) ); + m->ter( point( rw, rng( cw + 1, bw - 1 ) ) ); } } else { //bathroom to the right house_room( m, room_bathroom, lw, cw, lw + 3, bw, dat ); @@ -2763,7 +2765,7 @@ void mapgen_generic_house( map *m, oter_id terrain_type, mapgendata dat, const t if( one_in( 4 ) ) { m->ter_set( point( rng( lw + 1, lw + 2 ), bw ), t_window_domestic ); } else { - m->ter( lw, rng( cw + 1, bw - 1 ) ); + m->ter( point( lw, rng( cw + 1, bw - 1 ) ) ); } } // Doors off the sides of the hallway @@ -2942,7 +2944,7 @@ void mapgen_basement_spiders( map *m, oter_id terrain_type, mapgendata dat, cons } for( int i = 1; i < 22; i++ ) { for( int j = 1; j < 22; j++ ) { - if( m->ter( i, j ).obj().movecost == 0 ) { + if( m->ter( point( i, j ) ).obj().movecost == 0 ) { // Wall, skip continue; } @@ -3608,7 +3610,7 @@ static void mapgen_ants_generic( map *m, oter_id terrain_type, mapgendata dat, do { x = rng( 1 + cw, SEEX * 2 - 2 - cw ); y = rng( 1 + cw, SEEY * 2 - 2 - cw ); - } while( m->ter( x, y ) == t_rock ); + } while( m->ter( point( x, y ) ) == t_rock ); for( int i = x - cw; i <= x + cw; i++ ) { for( int j = y - cw; j <= y + cw; j++ ) { if( trig_dist( x, y, i, j ) <= cw ) { @@ -4527,7 +4529,7 @@ void mapgen_lake_shore( map *m, oter_id, mapgendata dat, const time_point &turn, if( !map_boundaries.contains_inclusive( p ) ) { return false; } - return m->ter( p.x, p.y ) != t_null; + return m->ter( p ) != t_null; }; const auto fill_deep_water = [&]( const point & starting_point ) { diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index 8b2981ff258ab..b171ac52d7378 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -980,7 +980,7 @@ void talk_function::field_plant( npc &p, const std::string &place ) bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); for( int x = 0; x < SEEX * 2 - 1; x++ ) { for( int y = 0; y < SEEY * 2 - 1; y++ ) { - if( bay.ter( x, y ) == t_dirtmound ) { + if( bay.ter( point( x, y ) ) == t_dirtmound ) { empty_plots++; } } @@ -1009,7 +1009,7 @@ void talk_function::field_plant( npc &p, const std::string &place ) //Plant the actual seeds for( int x = 0; x < SEEX * 2 - 1; x++ ) { for( int y = 0; y < SEEY * 2 - 1; y++ ) { - if( bay.ter( x, y ) == t_dirtmound && limiting_number > 0 ) { + if( bay.ter( point( x, y ) ) == t_dirtmound && limiting_number > 0 ) { std::list used_seed; if( item::count_by_charges( seed_id ) ) { used_seed = g->u.use_charges( seed_id, 1 ); @@ -1042,7 +1042,8 @@ void talk_function::field_harvest( npc &p, const std::string &place ) bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); for( int x = 0; x < SEEX * 2 - 1; x++ ) { for( int y = 0; y < SEEY * 2 - 1; y++ ) { - if( bay.furn( x, y ) == furn_str_id( "f_plant_harvest" ) && !bay.i_at( point( x, y ) ).empty() ) { + if( bay.furn( point( x, y ) ) == furn_str_id( "f_plant_harvest" ) && + !bay.i_at( point( x, y ) ).empty() ) { // Can't use item_stack::only_item() since there might be fertilizer map_stack items = bay.i_at( point( x, y ) ); map_stack::iterator seed = std::find_if( items.begin(), items.end(), []( const item & it ) { @@ -1090,7 +1091,7 @@ void talk_function::field_harvest( npc &p, const std::string &place ) for( int x = 0; x < SEEX * 2 - 1; x++ ) { for( int y = 0; y < SEEY * 2 - 1; y++ ) { - if( bay.furn( x, y ) == furn_str_id( "f_plant_harvest" ) ) { + if( bay.furn( point( x, y ) ) == furn_str_id( "f_plant_harvest" ) ) { // Can't use item_stack::only_item() since there might be fertilizer map_stack items = bay.i_at( point( x, y ) ); map_stack::iterator seed = std::find_if( items.begin(), items.end(), []( const item & it ) { @@ -2029,7 +2030,7 @@ void talk_function::loot_building( const tripoint &site ) p.x = x; p.y = y; p.z = site.z; - ter_id t = bay.ter( x, y ); + ter_id t = bay.ter( point( x, y ) ); //Open all the doors, doesn't need to be exhaustive if( t == t_door_c || t == t_door_c_peep || t == t_door_b || t == t_door_boarded || t == t_door_boarded_damaged @@ -2038,7 +2039,7 @@ void talk_function::loot_building( const tripoint &site ) bay.ter_set( point( x, y ), t_door_o ); } else if( t == t_door_locked || t == t_door_locked_peep || t == t_door_locked_alarm ) { - const map_bash_info &bash = bay.ter( x, y ).obj().bash; + const map_bash_info &bash = bay.ter( point( x, y ) ).obj().bash; bay.ter_set( point( x, y ), bash.ter_set ); bay.spawn_items( p, item_group::items_from( bash.drop_group, calendar::turn ) ); } else if( t == t_door_metal_c || t == t_door_metal_locked @@ -2047,7 +2048,7 @@ void talk_function::loot_building( const tripoint &site ) } else if( t == t_door_glass_c ) { bay.ter_set( point( x, y ), t_door_glass_o ); } else if( t == t_wall && one_in( 25 ) ) { - const map_bash_info &bash = bay.ter( x, y ).obj().bash; + const map_bash_info &bash = bay.ter( point( x, y ) ).obj().bash; bay.ter_set( point( x, y ), bash.ter_set ); bay.spawn_items( p, item_group::items_from( bash.drop_group, calendar::turn ) ); bay.collapse_at( p, false ); @@ -2059,16 +2060,16 @@ void talk_function::loot_building( const tripoint &site ) t == t_curtains || t == t_window_alarm || t == t_window_no_curtains || t == t_window_no_curtains_taped ) && one_in( 4 ) ) { - const map_bash_info &bash = bay.ter( x, y ).obj().bash; + const map_bash_info &bash = bay.ter( point( x, y ) ).obj().bash; bay.ter_set( point( x, y ), bash.ter_set ); bay.spawn_items( p, item_group::items_from( bash.drop_group, calendar::turn ) ); } else if( ( t == t_wall_glass || t == t_wall_glass_alarm ) && one_in( 3 ) ) { - const map_bash_info &bash = bay.ter( x, y ).obj().bash; + const map_bash_info &bash = bay.ter( point( x, y ) ).obj().bash; bay.ter_set( point( x, y ), bash.ter_set ); bay.spawn_items( p, item_group::items_from( bash.drop_group, calendar::turn ) ); - } else if( bay.has_furn( x, y ) && bay.furn( x, y ).obj().bash.str_max != -1 && + } else if( bay.has_furn( point( x, y ) ) && bay.furn( point( x, y ) ).obj().bash.str_max != -1 && one_in( 10 ) ) { - const map_bash_info &bash = bay.furn( x, y ).obj().bash; + const map_bash_info &bash = bay.furn( point( x, y ) ).obj().bash; bay.furn_set( point( x, y ), bash.furn_set ); bay.delete_signage( p ); bay.spawn_items( p, item_group::items_from( bash.drop_group, calendar::turn ) ); diff --git a/src/mission_start.cpp b/src/mission_start.cpp index 4bb9d431c4d5b..7b7b7ab7ee3b8 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -144,32 +144,33 @@ static tripoint find_potential_computer_point( const tinymap &compmap, int z ) std::vector last_resort; for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - if( compmap.ter( x, y ) == t_console_broken ) { + if( compmap.ter( point( x, y ) ) == t_console_broken ) { broken.emplace_back( x, y, z ); - } else if( broken.empty() && compmap.ter( x, y ) == t_floor && compmap.furn( x, y ) == f_null ) { + } else if( broken.empty() && compmap.ter( point( x, y ) ) == t_floor && + compmap.furn( point( x, y ) ) == f_null ) { bool okay = false; int wall = 0; for( int x2 = x - 1; x2 <= x + 1 && !okay; x2++ ) { for( int y2 = y - 1; y2 <= y + 1 && !okay; y2++ ) { - if( compmap.furn( x2, y2 ) == f_bed || compmap.furn( x2, y2 ) == f_dresser ) { + if( compmap.furn( point( x2, y2 ) ) == f_bed || compmap.furn( point( x2, y2 ) ) == f_dresser ) { okay = true; potential.emplace_back( x, y, z ); } - if( compmap.has_flag_ter( "WALL", x2, y2 ) ) { + if( compmap.has_flag_ter( "WALL", point( x2, y2 ) ) ) { wall++; } } } if( wall == 5 ) { - if( compmap.is_last_ter_wall( true, x, y, SEEX * 2, SEEY * 2, NORTH ) && - compmap.is_last_ter_wall( true, x, y, SEEX * 2, SEEY * 2, SOUTH ) && - compmap.is_last_ter_wall( true, x, y, SEEX * 2, SEEY * 2, WEST ) && - compmap.is_last_ter_wall( true, x, y, SEEX * 2, SEEY * 2, EAST ) ) { + if( compmap.is_last_ter_wall( true, point( x, y ), SEEX * 2, SEEY * 2, NORTH ) && + compmap.is_last_ter_wall( true, point( x, y ), SEEX * 2, SEEY * 2, SOUTH ) && + compmap.is_last_ter_wall( true, point( x, y ), SEEX * 2, SEEY * 2, WEST ) && + compmap.is_last_ter_wall( true, point( x, y ), SEEX * 2, SEEY * 2, EAST ) ) { potential.emplace_back( x, y, z ); } } } else if( broken.empty() && potential.empty() && x >= rng_x_min && x <= rng_x_max - && y >= rng_y_min && y <= rng_y_max && compmap.ter( x, y ) != t_console ) { + && y >= rng_y_min && y <= rng_y_max && compmap.ter( point( x, y ) ) != t_console ) { last_resort.emplace_back( x, y, z ); } } @@ -248,8 +249,8 @@ void mission_start::place_priest_diary( mission *miss ) std::vector valid; for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - if( compmap.furn( x, y ) == f_bed || compmap.furn( x, y ) == f_dresser || - compmap.furn( x, y ) == f_indoor_plant || compmap.furn( x, y ) == f_cupboard ) { + if( compmap.furn( point( x, y ) ) == f_bed || compmap.furn( point( x, y ) ) == f_dresser || + compmap.furn( point( x, y ) ) == f_indoor_plant || compmap.furn( point( x, y ) ) == f_cupboard ) { valid.push_back( tripoint( x, y, place.z ) ); } } @@ -287,11 +288,11 @@ void mission_start::place_deposit_box( mission *miss ) std::vector valid; for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - if( compmap.ter( x, y ) == t_floor ) { + if( compmap.ter( point( x, y ) ) == t_floor ) { bool okay = false; for( int x2 = x - 1; x2 <= x + 1 && !okay; x2++ ) { for( int y2 = y - 1; y2 <= y + 1 && !okay; y2++ ) { - if( compmap.ter( x2, y2 ) == t_wall_metal ) { + if( compmap.ter( point( x2, y2 ) ) == t_wall_metal ) { okay = true; valid.push_back( tripoint( x, y, site.z ) ); } diff --git a/src/monattack.cpp b/src/monattack.cpp index 5243cb1c7d185..2998fc601c8ba 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -3527,7 +3527,7 @@ void mattack::flame( monster *z, Creature *target ) if( g->m.hit_with_fire( tripoint( i.xy(), z->posz() ) ) ) { if( g->u.sees( i ) ) { add_msg( _( "The tongue of flame hits the %s!" ), - g->m.tername( i.x, i.y ) ); + g->m.tername( i.xy() ) ); } return; } @@ -3550,7 +3550,7 @@ void mattack::flame( monster *z, Creature *target ) if( g->m.hit_with_fire( tripoint( i.xy(), z->posz() ) ) ) { if( g->u.sees( i ) ) { add_msg( _( "The tongue of flame hits the %s!" ), - g->m.tername( i.x, i.y ) ); + g->m.tername( i.xy() ) ); } return; } diff --git a/src/player.cpp b/src/player.cpp index ee4c90751244f..b5aa5519f4ecd 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -11479,10 +11479,10 @@ void player::place_corpse( const tripoint &om_target ) bay.load( tripoint( om_target.x * 2, om_target.y * 2, om_target.z ), false ); int finX = rng( 1, SEEX * 2 - 2 ); int finY = rng( 1, SEEX * 2 - 2 ); - if( bay.furn( finX, finY ) != furn_str_id( "f_null" ) ) { + if( bay.furn( point( finX, finY ) ) != furn_str_id( "f_null" ) ) { for( int x = 0; x < SEEX * 2 - 1; x++ ) { for( int y = 0; y < SEEY * 2 - 1; y++ ) { - if( bay.furn( x, y ) == furn_str_id( "f_null" ) ) { + if( bay.furn( point( x, y ) ) == furn_str_id( "f_null" ) ) { finX = x; finY = y; } diff --git a/src/start_location.cpp b/src/start_location.cpp index 3d25da47dd194..bc9d92d596e15 100644 --- a/src/start_location.cpp +++ b/src/start_location.cpp @@ -130,7 +130,7 @@ static void board_up( map &m, const tripoint &start, const tripoint &end ) for( x = start.x; x < end.x; x++ ) { for( y = start.y; y < end.y; y++ ) { bool must_board_around = false; - const ter_id t = m.ter( x, y ); + const ter_id t = m.ter( point( x, y ) ); if( t == t_window_domestic || t == t_window || t == t_window_no_curtains ) { // Windows are always to the outside and must be boarded must_board_around = true; diff --git a/src/timed_event.cpp b/src/timed_event.cpp index 4115b44e76aa5..25ecd0b3faa57 100644 --- a/src/timed_event.cpp +++ b/src/timed_event.cpp @@ -106,10 +106,10 @@ void timed_event::actualize() bool horizontal = false; for( int x = 0; x < MAPSIZE_X && faultx == -1; x++ ) { for( int y = 0; y < MAPSIZE_Y && faulty == -1; y++ ) { - if( g->m.ter( x, y ) == t_fault ) { + if( g->m.ter( point( x, y ) ) == t_fault ) { faultx = x; faulty = y; - horizontal = g->m.ter( x - 1, y ) == t_fault || g->m.ter( x + 1, y ) == t_fault; + horizontal = g->m.ter( point( x - 1, y ) ) == t_fault || g->m.ter( point( x + 1, y ) ) == t_fault; } } } @@ -121,14 +121,14 @@ void timed_event::actualize() if( horizontal ) { monx = rng( faultx, faultx + 2 * SEEX - 8 ); for( int n = -1; n <= 1; n++ ) { - if( g->m.ter( monx, faulty + n ) == t_rock_floor ) { + if( g->m.ter( point( monx, faulty + n ) ) == t_rock_floor ) { mony = faulty + n; } } } else { // Vertical fault mony = rng( faulty, faulty + 2 * SEEY - 8 ); for( int n = -1; n <= 1; n++ ) { - if( g->m.ter( faultx + n, mony ) == t_rock_floor ) { + if( g->m.ter( point( faultx + n, mony ) ) == t_rock_floor ) { monx = faultx + n; } } @@ -148,7 +148,7 @@ void timed_event::actualize() pgettext( "memorial_female", "Destroyed a triffid grove." ) ); for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.ter( x, y ) == t_root_wall && one_in( 3 ) ) { + if( g->m.ter( point( x, y ) ) == t_root_wall && one_in( 3 ) ) { g->m.ter_set( point( x, y ), t_underbrush ); } } @@ -161,7 +161,7 @@ void timed_event::actualize() bool saw_grate = false; for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.ter( x, y ) == t_grate ) { + if( g->m.ter( point( x, y ) ) == t_grate ) { g->m.ter_set( point( x, y ), t_stairs_down ); if( !saw_grate && g->u.sees( tripoint( x, y, g->get_levz() ) ) ) { saw_grate = true; @@ -181,16 +181,16 @@ void timed_event::actualize() ter_id flood_buf[MAPSIZE_X][MAPSIZE_Y]; for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - flood_buf[x][y] = g->m.ter( x, y ); + flood_buf[x][y] = g->m.ter( point( x, y ) ); } } for( int x = 0; x < MAPSIZE_X; x++ ) { for( int y = 0; y < MAPSIZE_Y; y++ ) { - if( g->m.ter( x, y ) == t_water_sh ) { + if( g->m.ter( point( x, y ) ) == t_water_sh ) { bool deepen = false; for( int wx = x - 1; wx <= x + 1 && !deepen; wx++ ) { for( int wy = y - 1; wy <= y + 1 && !deepen; wy++ ) { - if( g->m.ter( wx, wy ) == t_water_dp ) { + if( g->m.ter( point( wx, wy ) ) == t_water_dp ) { deepen = true; } } @@ -199,11 +199,11 @@ void timed_event::actualize() flood_buf[x][y] = t_water_dp; flooded = true; } - } else if( g->m.ter( x, y ) == t_rock_floor ) { + } else if( g->m.ter( point( x, y ) ) == t_rock_floor ) { bool flood = false; for( int wx = x - 1; wx <= x + 1 && !flood; wx++ ) { for( int wy = y - 1; wy <= y + 1 && !flood; wy++ ) { - if( g->m.ter( wx, wy ) == t_water_dp || g->m.ter( wx, wy ) == t_water_sh ) { + if( g->m.ter( point( wx, wy ) ) == t_water_dp || g->m.ter( point( wx, wy ) ) == t_water_sh ) { flood = true; } } @@ -219,7 +219,7 @@ void timed_event::actualize() return; // We finished flooding the entire chamber! } // Check if we should print a message - if( flood_buf[g->u.posx()][g->u.posy()] != g->m.ter( g->u.posx(), g->u.posy() ) ) { + if( flood_buf[g->u.posx()][g->u.posy()] != g->m.ter( point( g->u.posx(), g->u.posy() ) ) ) { if( flood_buf[g->u.posx()][g->u.posy()] == t_water_sh ) { add_msg( m_warning, _( "Water quickly floods up to your knees." ) ); g->u.add_memorial_log( pgettext( "memorial_male", "Water level reached knees." ), diff --git a/src/tutorial.cpp b/src/tutorial.cpp index f83c2686bbbec..06fbc777050e1 100644 --- a/src/tutorial.cpp +++ b/src/tutorial.cpp @@ -128,22 +128,22 @@ void tutorial_game::per_turn() bool showed_message = false; for( int x = g->u.posx() - 1; x <= g->u.posx() + 1 && !showed_message; x++ ) { for( int y = g->u.posy() - 1; y <= g->u.posy() + 1 && !showed_message; y++ ) { - if( g->m.ter( x, y ) == t_door_o ) { + if( g->m.ter( point( x, y ) ) == t_door_o ) { add_message( LESSON_OPEN ); showed_message = true; - } else if( g->m.ter( x, y ) == t_door_c ) { + } else if( g->m.ter( point( x, y ) ) == t_door_c ) { add_message( LESSON_CLOSE ); showed_message = true; - } else if( g->m.ter( x, y ) == t_window ) { + } else if( g->m.ter( point( x, y ) ) == t_window ) { add_message( LESSON_SMASH ); showed_message = true; - } else if( g->m.furn( x, y ) == f_rack && !g->m.i_at( point( x, y ) ).empty() ) { + } else if( g->m.furn( point( x, y ) ) == f_rack && !g->m.i_at( point( x, y ) ).empty() ) { add_message( LESSON_EXAMINE ); showed_message = true; - } else if( g->m.ter( x, y ) == t_stairs_down ) { + } else if( g->m.ter( point( x, y ) ) == t_stairs_down ) { add_message( LESSON_STAIRS ); showed_message = true; - } else if( g->m.ter( x, y ) == t_water_sh ) { + } else if( g->m.ter( point( x, y ) ) == t_water_sh ) { add_message( LESSON_PICKUP_WATER ); showed_message = true; } diff --git a/src/weather.cpp b/src/weather.cpp index 8a7b622282732..1143b2f3af01a 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -52,7 +52,7 @@ static const trait_id trait_FEATHERS( "FEATHERS" ); static bool is_player_outside() { - return g->m.is_outside( g->u.posx(), g->u.posy() ) && g->get_levz() >= 0; + return g->m.is_outside( point( g->u.posx(), g->u.posy() ) ) && g->get_levz() >= 0; } #define THUNDER_CHANCE 50 From 77a1d7550ee473fdaa570c1282bc0ce291b08789 Mon Sep 17 00:00:00 2001 From: Qrox Date: Sat, 17 Aug 2019 21:20:50 +0800 Subject: [PATCH 029/113] Fix incorrect position of AIM filter text --- src/advanced_inv.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/advanced_inv.cpp b/src/advanced_inv.cpp index 5227387b1c831..5c840c7805444 100644 --- a/src/advanced_inv.cpp +++ b/src/advanced_inv.cpp @@ -1165,7 +1165,7 @@ void advanced_inventory::redraw_pane( side p ) const char *fprefix = _( "[F]ilter" ); const char *fsuffix = _( "[R]eset" ); - if( ! filter_edit ) { + if( !filter_edit ) { if( !pane.filter.empty() ) { mvwprintw( w, point( 2, getmaxy( w ) - 1 ), "< %s: %s >", fprefix, pane.filter ); } else { @@ -1175,10 +1175,10 @@ void advanced_inventory::redraw_pane( side p ) if( active ) { wattroff( w, c_white ); } - if( ! filter_edit && !pane.filter.empty() ) { - mvwprintz( w, point( 6 + std::strlen( fprefix ), getmaxy( w ) - 1 ), c_white, + if( !filter_edit && !pane.filter.empty() ) { + mvwprintz( w, point( 6 + utf8_width( fprefix ), getmaxy( w ) - 1 ), c_white, pane.filter ); - mvwprintz( w, point( getmaxx( w ) - std::strlen( fsuffix ) - 2, getmaxy( w ) - 1 ), c_white, "%s", + mvwprintz( w, point( getmaxx( w ) - utf8_width( fsuffix ) - 2, getmaxy( w ) - 1 ), c_white, "%s", fsuffix ); } wrefresh( w ); From d3bc7109e6e438d5a4b189dd787fb51f02c431b1 Mon Sep 17 00:00:00 2001 From: Qrox Date: Sat, 17 Aug 2019 21:39:42 +0800 Subject: [PATCH 030/113] Fix wrong value saved for npc::previous_attitude --- src/savegame_json.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 1b957393a82f0..926fff66d7b97 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1607,7 +1607,7 @@ void npc::store( JsonOut &json ) const json.member( "my_fac", fac_id.c_str() ); } json.member( "attitude", static_cast( attitude ) ); - json.member( "previous_attitude", static_cast( attitude ) ); + json.member( "previous_attitude", static_cast( previous_attitude ) ); json.member( "op_of_u", op_of_u ); json.member( "chatbin", chatbin ); json.member( "rules", rules ); From b9263cbb534bbcfe69d9d2b9438b7131b0036697 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 17 Aug 2019 11:03:43 -0400 Subject: [PATCH 031/113] Port some map members, overload more --- src/map.cpp | 142 ++++++++++++++++++--------------------- src/map.h | 78 +++++---------------- src/mapgen.cpp | 16 ++--- src/mapgen_functions.cpp | 2 +- 4 files changed, 92 insertions(+), 146 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 1288b2ce6c132..f276b0ccb03ff 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1167,25 +1167,24 @@ bool map::displace_water( const tripoint &p ) // 2D overloads for furniture // To be removed once not needed -void map::set( const int x, const int y, const ter_id &new_terrain, const furn_id &new_furniture ) +void map::set( const point &p, const ter_id &new_terrain, const furn_id &new_furniture ) { - furn_set( point( x, y ), new_furniture ); - ter_set( point( x, y ), new_terrain ); + furn_set( p, new_furniture ); + ter_set( p, new_terrain ); } -std::string map::name( const int x, const int y ) +std::string map::name( const point &p ) { - return name( tripoint( x, y, abs_sub.z ) ); + return name( tripoint( p, abs_sub.z ) ); } -bool map::has_furn( const int x, const int y ) const +bool map::has_furn( const point &p ) const { - return furn( point( x, y ) ) != f_null; + return furn( p ) != f_null; } -furn_id map::furn( const int x, const int y ) const +furn_id map::furn( const point &p ) const { - const point p( x, y ); if( !inbounds( p ) ) { return f_null; } @@ -1196,14 +1195,14 @@ furn_id map::furn( const int x, const int y ) const return current_submap->get_furn( l ); } -void map::furn_set( const int x, const int y, const furn_id &new_furniture ) +void map::furn_set( const point &p, const furn_id &new_furniture ) { - furn_set( tripoint( x, y, abs_sub.z ), new_furniture ); + furn_set( tripoint( p, abs_sub.z ), new_furniture ); } -std::string map::furnname( const int x, const int y ) +std::string map::furnname( const point &p ) { - return furnname( tripoint( x, y, abs_sub.z ) ); + return furnname( tripoint( p, abs_sub.z ) ); } // End of 2D overloads for furniture @@ -1346,9 +1345,8 @@ std::string map::furnname( const tripoint &p ) // 2D overloads for terrain // To be removed once not needed -ter_id map::ter( const int x, const int y ) const +ter_id map::ter( const point &p ) const { - const point p( x, y ); if( !inbounds( p ) ) { return t_null; } @@ -1358,14 +1356,14 @@ ter_id map::ter( const int x, const int y ) const return current_submap->get_ter( l ); } -bool map::ter_set( const int x, const int y, const ter_id &new_terrain ) +bool map::ter_set( const point &p, const ter_id &new_terrain ) { - return ter_set( tripoint( x, y, abs_sub.z ), new_terrain ); + return ter_set( tripoint( p, abs_sub.z ), new_terrain ); } -std::string map::tername( const int x, const int y ) const +std::string map::tername( const point &p ) const { - return tername( tripoint( x, y, abs_sub.z ) ); + return tername( tripoint( p, abs_sub.z ) ); } // End of 2D overloads for terrain @@ -1572,9 +1570,9 @@ std::string map::tername( const tripoint &p ) const return ter( p ).obj().name(); } -std::string map::features( const int x, const int y ) +std::string map::features( const point &p ) { - return features( tripoint( x, y, abs_sub.z ) ); + return features( tripoint( p, abs_sub.z ) ); } std::string map::features( const tripoint &p ) @@ -2182,29 +2180,28 @@ void map::process_falling() // 2D flags -bool map::has_flag( const std::string &flag, const int x, const int y ) const +bool map::has_flag( const std::string &flag, const point &p ) const { - return has_flag( flag, tripoint( x, y, abs_sub.z ) ); + return has_flag( flag, tripoint( p, abs_sub.z ) ); } -bool map::can_put_items_ter_furn( const int x, const int y ) const +bool map::can_put_items_ter_furn( const point &p ) const { - return !has_flag( "NOITEM", point( x, y ) ) && !has_flag( "SEALED", point( x, y ) ); + return !has_flag( "NOITEM", p ) && !has_flag( "SEALED", p ); } -bool map::has_flag_ter( const std::string &flag, const int x, const int y ) const +bool map::has_flag_ter( const std::string &flag, const point &p ) const { - return has_flag_ter( flag, tripoint( x, y, abs_sub.z ) ); + return has_flag_ter( flag, tripoint( p, abs_sub.z ) ); } -bool map::has_flag_furn( const std::string &flag, const int x, const int y ) const +bool map::has_flag_furn( const std::string &flag, const point &p ) const { - return has_flag_furn( flag, tripoint( x, y, abs_sub.z ) ); + return has_flag_furn( flag, tripoint( p, abs_sub.z ) ); } -bool map::has_flag_ter_or_furn( const std::string &flag, const int x, const int y ) const +bool map::has_flag_ter_or_furn( const std::string &flag, const point &p ) const { - const point p( x, y ); if( !inbounds( p ) ) { return false; } @@ -2217,24 +2214,23 @@ bool map::has_flag_ter_or_furn( const std::string &flag, const int x, const int } ///// -bool map::has_flag( const ter_bitflags flag, const int x, const int y ) const +bool map::has_flag( const ter_bitflags flag, const point &p ) const { - return has_flag( flag, tripoint( x, y, abs_sub.z ) ); + return has_flag( flag, tripoint( p, abs_sub.z ) ); } -bool map::has_flag_ter( const ter_bitflags flag, const int x, const int y ) const +bool map::has_flag_ter( const ter_bitflags flag, const point &p ) const { - return has_flag_ter( flag, tripoint( x, y, abs_sub.z ) ); + return has_flag_ter( flag, tripoint( p, abs_sub.z ) ); } -bool map::has_flag_furn( const ter_bitflags flag, const int x, const int y ) const +bool map::has_flag_furn( const ter_bitflags flag, const point &p ) const { - return has_flag_furn( flag, tripoint( x, y, abs_sub.z ) ); + return has_flag_furn( flag, tripoint( p, abs_sub.z ) ); } -bool map::has_flag_ter_or_furn( const ter_bitflags flag, const int x, const int y ) const +bool map::has_flag_ter_or_furn( const ter_bitflags flag, const point &p ) const { - const point p( x, y ); if( !inbounds( p ) ) { return false; } @@ -2367,39 +2363,39 @@ int map::bash_rating_internal( const int str, const furn_t &furniture, // 2D bashable -bool map::is_bashable( const int x, const int y ) const +bool map::is_bashable( const point &p ) const { - return is_bashable( tripoint( x, y, abs_sub.z ) ); + return is_bashable( tripoint( p, abs_sub.z ) ); } -bool map::is_bashable_ter( const int x, const int y ) const +bool map::is_bashable_ter( const point &p ) const { - return is_bashable_ter( tripoint( x, y, abs_sub.z ) ); + return is_bashable_ter( tripoint( p, abs_sub.z ) ); } -bool map::is_bashable_furn( const int x, const int y ) const +bool map::is_bashable_furn( const point &p ) const { - return is_bashable_furn( tripoint( x, y, abs_sub.z ) ); + return is_bashable_furn( tripoint( p, abs_sub.z ) ); } -bool map::is_bashable_ter_furn( const int x, const int y ) const +bool map::is_bashable_ter_furn( const point &p ) const { - return is_bashable_ter_furn( tripoint( x, y, abs_sub.z ) ); + return is_bashable_ter_furn( tripoint( p, abs_sub.z ) ); } -int map::bash_strength( const int x, const int y ) const +int map::bash_strength( const point &p ) const { - return bash_strength( tripoint( x, y, abs_sub.z ) ); + return bash_strength( tripoint( p, abs_sub.z ) ); } -int map::bash_resistance( const int x, const int y ) const +int map::bash_resistance( const point &p ) const { - return bash_resistance( tripoint( x, y, abs_sub.z ) ); + return bash_resistance( tripoint( p, abs_sub.z ) ); } -int map::bash_rating( const int str, const int x, const int y ) const +int map::bash_rating( const int str, const point &p ) const { - return bash_rating( str, tripoint( x, y, abs_sub.z ) ); + return bash_rating( str, tripoint( p, abs_sub.z ) ); } // 3D bashable @@ -2562,14 +2558,14 @@ void map::make_rubble( const tripoint &p, const furn_id &rubble_type, const bool * @param y The y coordinate to look at. * @return true if the terrain can be dived into; false if not. */ -bool map::is_divable( const int x, const int y ) const +bool map::is_divable( const point &p ) const { - return has_flag( "SWIMMABLE", point( x, y ) ) && has_flag( TFLAG_DEEP_WATER, x, y ); + return has_flag( "SWIMMABLE", p ) && has_flag( TFLAG_DEEP_WATER, p ); } -bool map::is_water_shallow_current( const int x, const int y ) const +bool map::is_water_shallow_current( const point &p ) const { - return has_flag( "CURRENT", point( x, y ) ) && !has_flag( TFLAG_DEEP_WATER, x, y ); + return has_flag( "CURRENT", p ) && !has_flag( TFLAG_DEEP_WATER, p ); } bool map::is_water_shallow_current( const tripoint &p ) const @@ -2582,15 +2578,14 @@ bool map::is_divable( const tripoint &p ) const return has_flag( "SWIMMABLE", p ) && has_flag( TFLAG_DEEP_WATER, p ); } -bool map::is_outside( const int x, const int y ) const +bool map::is_outside( const point &p ) const { - const point p( x, y ); if( !inbounds( p ) ) { return true; } const auto &outside_cache = get_cache_ref( abs_sub.z ).outside_cache; - return outside_cache[x][y]; + return outside_cache[p.x][p.y]; } bool map::is_outside( const tripoint &p ) const @@ -2603,7 +2598,7 @@ bool map::is_outside( const tripoint &p ) const return outside_cache[p.x][p.y]; } -bool map::is_last_ter_wall( const bool no_furn, const int x, const int y, +bool map::is_last_ter_wall( const bool no_furn, const point &p, const int xmax, const int ymax, const direction dir ) const { int xmov = 0; @@ -2624,8 +2619,8 @@ bool map::is_last_ter_wall( const bool no_furn, const int x, const int y, default: break; } - int x2 = x; - int y2 = y; + int x2 = p.x; + int y2 = p.y; bool result = true; bool loop = true; while( ( loop ) && ( ( dir == NORTH && y2 >= 0 ) || @@ -3974,9 +3969,9 @@ int map::get_radiation( const tripoint &p ) const return current_submap->get_radiation( l ); } -void map::set_radiation( const int x, const int y, const int value ) +void map::set_radiation( const point &p, const int value ) { - set_radiation( tripoint( x, y, abs_sub.z ), value ); + set_radiation( tripoint( p, abs_sub.z ), value ); } void map::set_radiation( const tripoint &p, const int value ) @@ -7909,14 +7904,9 @@ void map::build_map_cache( const int zlev, bool skip_lightmap ) } } -std::vector closest_points_first( int radius, point p ) -{ - return closest_points_first( radius, p.x, p.y ); -} - //this returns points in a spiral pattern starting at center_x/center_y until it hits the radius. clockwise fashion //credit to Tom J Nowell; http://stackoverflow.com/a/1555236/1269969 -std::vector closest_points_first( int radius, int center_x, int center_y ) +std::vector closest_points_first( int radius, const point ¢er ) { std::vector points; int X = radius * 2 + 1; @@ -7929,7 +7919,7 @@ std::vector closest_points_first( int radius, int center_x, int center_y int maxI = t * t; for( int i = 0; i < maxI; i++ ) { if( -X / 2 <= x && x <= X / 2 && -Y / 2 <= y && y <= Y / 2 ) { - points.push_back( point( x + center_x, y + center_y ) ); + points.push_back( center + point( x, y ) ); } if( x == y || ( x < 0 && x == -y ) || ( x > 0 && x == 1 - y ) ) { t = dx; @@ -7970,9 +7960,9 @@ std::vector closest_tripoints_first( int radius, const tripoint ¢e ////////// ///// coordinate helpers -point map::getabs( const int x, const int y ) const +point map::getabs( const point &p ) const { - return sm_to_ms_copy( abs_sub.xy() ) + point( x, y ); + return sm_to_ms_copy( abs_sub.xy() ) + p; } tripoint map::getabs( const tripoint &p ) const @@ -7980,9 +7970,9 @@ tripoint map::getabs( const tripoint &p ) const return sm_to_ms_copy( abs_sub.xy() ) + p; } -point map::getlocal( const int x, const int y ) const +point map::getlocal( const point &p ) const { - return point( x, y ) - sm_to_ms_copy( abs_sub.xy() ); + return p - sm_to_ms_copy( abs_sub.xy() ); } tripoint map::getlocal( const tripoint &p ) const diff --git a/src/map.h b/src/map.h index 1d77643a0e431..dc0233eb6e8c3 100644 --- a/src/map.h +++ b/src/map.h @@ -589,27 +589,16 @@ class map vehicle *move_vehicle( vehicle &veh, const tripoint &dp, const tileray &facing ); // Furniture: 2D overloads - void set( int x, int y, const ter_id &new_terrain, const furn_id &new_furniture ); - void set( const point &p, const ter_id &new_terrain, const furn_id &new_furniture ) { - set( p.x, p.y, new_terrain, new_furniture ); - } + void set( const point &p, const ter_id &new_terrain, const furn_id &new_furniture ); - std::string name( int x, int y ); std::string name( const point &p ); - bool has_furn( int x, int y ) const; bool has_furn( const point &p ) const; // Furniture at coordinates (x, y); {x|y}=(0, SEE{X|Y}*3] - furn_id furn( int x, int y ) const; furn_id furn( const point &p ) const; - void furn_set( int x, int y, const furn_id &new_furniture ); - - void furn_set( const point &p, const furn_id &new_furniture ) { - furn_set( p.x, p.y, new_furniture ); - } + void furn_set( const point &p, const furn_id &new_furniture ); - std::string furnname( int x, int y ); std::string furnname( const point &p ); // Furniture: 3D void set( const tripoint &p, const ter_id &new_terrain, const furn_id &new_furniture ); @@ -631,16 +620,10 @@ class map bool can_move_furniture( const tripoint &pos, player *p = nullptr ); // Terrain: 2D overloads // Terrain integer id at coordinates (x, y); {x|y}=(0, SEE{X|Y}*3] - ter_id ter( int x, int y ) const; ter_id ter( const point &p ) const; - bool ter_set( int x, int y, const ter_id &new_terrain ); + bool ter_set( const point &p, const ter_id &new_terrain ); - bool ter_set( const point &p, const ter_id &new_terrain ) { - return ter_set( p.x, p.y, new_terrain ); - } - - std::string tername( int x, int y ) const; // Name of terrain at (x, y) std::string tername( const point &p ) const; // Name of terrain at (x, y) // Terrain: 3D ter_id ter( const tripoint &p ) const; @@ -702,35 +685,25 @@ class map // Flags: 2D overloads // Words relevant to terrain (sharp, etc) - std::string features( int x, int y ); std::string features( const point &p ); // checks terrain, furniture and vehicles - bool has_flag( const std::string &flag, int x, int y ) const; bool has_flag( const std::string &flag, const point &p ) const; // True if items can be placed in this tile - bool can_put_items_ter_furn( int x, int y ) const; bool can_put_items_ter_furn( const point &p ) const; // checks terrain - bool has_flag_ter( const std::string &flag, int x, int y ) const; bool has_flag_ter( const std::string &flag, const point &p ) const; // checks furniture - bool has_flag_furn( const std::string &flag, int x, int y ) const; bool has_flag_furn( const std::string &flag, const point &p ) const; // checks terrain or furniture - bool has_flag_ter_or_furn( const std::string &flag, int x, int y ) const; bool has_flag_ter_or_furn( const std::string &flag, const point &p ) const; // fast "oh hai it's update_scent/lightmap/draw/monmove/self/etc again, what about this one" flag checking // checks terrain, furniture and vehicles - bool has_flag( ter_bitflags flag, int x, int y ) const; bool has_flag( ter_bitflags flag, const point &p ) const; // checks terrain - bool has_flag_ter( ter_bitflags flag, int x, int y ) const; bool has_flag_ter( ter_bitflags flag, const point &p ) const; // checks furniture - bool has_flag_furn( ter_bitflags flag, int x, int y ) const; bool has_flag_furn( ter_bitflags flag, const point &p ) const; // checks terrain or furniture - bool has_flag_ter_or_furn( ter_bitflags flag, int x, int y ) const; bool has_flag_ter_or_furn( ter_bitflags flag, const point &p ) const; // Flags: 3D // Words relevant to terrain (sharp, etc) @@ -758,13 +731,6 @@ class map bool has_flag_ter_or_furn( ter_bitflags flag, const tripoint &p ) const; // Bashable: 2D - bool is_bashable( int x, int y ) const; - bool is_bashable_ter( int x, int y ) const; - bool is_bashable_furn( int x, int y ) const; - bool is_bashable_ter_furn( int x, int y ) const; - int bash_strength( int x, int y ) const; - int bash_resistance( int x, int y ) const; - int bash_rating( int str, int x, int y ) const; bool is_bashable( const point &p ) const; bool is_bashable_ter( const point &p ) const; bool is_bashable_furn( const point &p ) const; @@ -796,9 +762,6 @@ class map void make_rubble( const tripoint &p ); void make_rubble( const tripoint &p, const furn_id &rubble_type, bool items ); - bool is_divable( int x, int y ) const; - bool is_water_shallow_current( int x, int y ) const; - bool is_outside( int x, int y ) const; bool is_divable( const point &p ) const; bool is_water_shallow_current( const point &p ) const; bool is_outside( const point &p ) const; @@ -808,17 +771,15 @@ class map /** Check if the last terrain is wall in direction NORTH, SOUTH, WEST or EAST * @param no_furn if true, the function will stop and return false * if it encounters a furniture - * @param x starting x coordinate of check - * @param y starting y coordinate of check - * @param xmax ending x coordinate of check - * @param ymax ending y coordinate of check + * @param p starting coordinates of check + * @param max ending coordinates of check * @param dir Direction of check * @return true if from x to xmax or y to ymax depending on direction * all terrain is floor and the last terrain is a wall */ - bool is_last_ter_wall( bool no_furn, int x, int y, - int xmax, int ymax, direction dir ) const; bool is_last_ter_wall( bool no_furn, const point &p, int xmax, int ymax, direction dir ) const; + bool is_last_ter_wall( bool no_furn, const point &p, + const point &max, direction dir ) const; /** * Checks if there are any tinder flagged items on the tile. @@ -925,7 +886,6 @@ class map int get_radiation( const tripoint &p ) const; // Amount of radiation at (x, y); void set_radiation( const tripoint &p, int value ); // Overload for mapgen - void set_radiation( int x, int y, int value ); void set_radiation( const point &p, int value ); /** Increment the radiation in the given tile by the given delta @@ -934,6 +894,7 @@ class map void adjust_radiation( const tripoint &p, int delta ); // Overload for mapgen void adjust_radiation( int x, int y, int delta ); + void adjust_radiation( const point &p, int delta ); // Temperature // Temperature for submap @@ -942,6 +903,7 @@ class map void set_temperature( const tripoint &p, int temperature ); // 2D overload for mapgen void set_temperature( int x, int y, int temperature ); + void set_temperature( const point &p, int temperature ); // Items void process_active_items(); @@ -1261,10 +1223,7 @@ class map void process_falling(); // mapgen.cpp functions - void generate( int x, int y, int z, const time_point &when ); - void generate( const tripoint &p, const time_point &when ) { - generate( p.x, p.y, p.z, when ); - } + void generate( const tripoint &p, const time_point &when ); void place_spawns( const mongroup_id &group, int chance, const point &p1, const point &p2, float intensity, bool individual = false, bool friendly = false ); @@ -1286,6 +1245,9 @@ class map vehicle *add_vehicle( const vproto_id &type, int x, int y, int dir, int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true ); + vehicle *add_vehicle( const vproto_id &type, const point &p, int dir, + int init_veh_fuel = -1, int init_veh_status = -1, + bool merge_wrecks = true ); void do_vehicle_caching( int z ); // Note: in 3D mode, will actually build caches on ALL z-levels @@ -1335,10 +1297,7 @@ class map * is used by the ter/furn/i_at functions. * Output is in the same scale, but in global system. */ - point getabs( int x, int y ) const; - point getabs( const point &p ) const { - return getabs( p.x, p.y ); - } + point getabs( const point &p ) const; /** * Translates tripoint in local coordinates (near player) to global, * just as the 2D variant of the function. @@ -1348,10 +1307,7 @@ class map /** * Inverse of @ref getabs */ - point getlocal( int x, int y ) const; - point getlocal( const point &p ) const { - return getlocal( p.x, p.y ); - } + point getlocal( const point &p ) const; tripoint getlocal( const tripoint &p ) const; virtual bool inbounds( const tripoint &p ) const; bool inbounds( const point &p ) const { @@ -1537,6 +1493,7 @@ class map * Sets @ref abs_sub, see there. Uses the same coordinate system as @ref abs_sub. */ void set_abs_sub( int x, int y, int z ); + void set_abs_sub( const tripoint &p ); private: field &get_field( const tripoint &p ); @@ -1757,8 +1714,7 @@ class map template void shift_bitset_cache( std::bitset &cache, int sx, int sy ); -std::vector closest_points_first( int radius, point p ); -std::vector closest_points_first( int radius, int x, int y ); +std::vector closest_points_first( int radius, const point ¢er ); // Does not build "piles" - does the same as above functions, except in tripoints std::vector closest_tripoints_first( int radius, const tripoint &p ); bool ter_furn_has_flag( const ter_t &ter, const furn_t &furn, ter_bitflags flag ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 48dfdbd782159..c713543439853 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -102,12 +102,12 @@ void build_mine_room( map *m, room_type type, int x1, int y1, int x2, int y2, ma // (x,y,z) are absolute coordinates of a submap // x%2 and y%2 must be 0! -void map::generate( const int x, const int y, const int z, const time_point &when ) +void map::generate( const tripoint &p, const time_point &when ) { - dbg( D_INFO ) << "map::generate( g[" << g.get() << "], x[" << x << "], " - << "y[" << y << "], z[" << z << "], when[" << to_string( when ) << "] )"; + dbg( D_INFO ) << "map::generate( g[" << g.get() << "], p[" << p << "], " + "when[" << to_string( when ) << "] )"; - set_abs_sub( x, y, z ); + set_abs_sub( p ); // First we have to create new submaps and initialize them to 0 all over // We create all the submaps, even if we're not a tinymap, so that map @@ -122,7 +122,7 @@ void map::generate( const int x, const int y, const int z, const time_point &whe } } // x, and y are submap coordinates, convert to overmap terrain coordinates - tripoint abs_omt = sm_to_omt_copy( tripoint( x, y, z ) ); + tripoint abs_omt = sm_to_omt_copy( p ); const regional_settings *rsettings = &overmap_buffer.get_settings( abs_omt ); oter_id terrain_type = overmap_buffer.ter( abs_omt ); oter_id t_above = overmap_buffer.ter( abs_omt + tripoint_above ); @@ -147,7 +147,7 @@ void map::generate( const int x, const int y, const int z, const time_point &whe density = density / 100; draw_map( terrain_type, t_north, t_east, t_south, t_west, t_neast, t_seast, t_swest, t_nwest, - t_above, t_below, when, density, z, rsettings ); + t_above, t_below, when, density, p.z, rsettings ); // At some point, we should add region information so we can grab the appropriate extras map_extras ex = region_settings_map["default"].region_extras[terrain_type->get_extras()]; @@ -201,9 +201,9 @@ void map::generate( const int x, const int y, const int z, const time_point &whe dbg( D_INFO ) << "map::generate: submap (" << i << "," << j << ")"; if( i <= 1 && j <= 1 ) { - saven( tripoint( i, j, z ) ); + saven( tripoint( i, j, p.z ) ); } else { - delete get_submap_at_grid( { i, j, z } ); + delete get_submap_at_grid( { i, j, p.z } ); } } } diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 2e4271b3b036c..746e580d910ed 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -4484,7 +4484,7 @@ void mapgen_lake_shore( map *m, oter_id, mapgendata dat, const time_point &turn, const auto draw_shallow_water = [&]( const point & from, const point & to ) { std::vector points = line_to( from, to ); for( auto &p : points ) { - std::vector buffered_points = closest_points_first( 1, p.x, p.y ); + std::vector buffered_points = closest_points_first( 1, p ); for( const point &bp : buffered_points ) { if( !map_boundaries.contains_inclusive( bp ) ) { continue; From f5f0f6253387f2cd503422dad572479ab1098d08 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 17 Aug 2019 11:36:45 -0400 Subject: [PATCH 032/113] Refactor calls to map functions --- src/debug_menu.cpp | 2 +- src/iuse.cpp | 2 +- src/iuse_actor.cpp | 2 +- src/map.cpp | 8 +-- src/map_extras.cpp | 32 +++++----- src/mapgen.cpp | 126 +++++++++++++++++++------------------- src/mission_start.cpp | 2 +- tests/vehicle_turrets.cpp | 2 +- 8 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 1026f5050b6e6..f0357a1184150 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1144,7 +1144,7 @@ void debug() //Didn't cancel const vproto_id &selected_opt = veh_strings[veh_menu.ret]; tripoint dest = u.pos(); // TODO: Allow picking this when add_vehicle has 3d argument - vehicle *veh = m.add_vehicle( selected_opt, dest.x, dest.y, -90, 100, 0 ); + vehicle *veh = m.add_vehicle( selected_opt, dest.xy(), -90, 100, 0 ); if( veh != nullptr ) { m.board_vehicle( u.pos(), &u ); } diff --git a/src/iuse.cpp b/src/iuse.cpp index d6fe00cd491ed..010be011349f8 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -5292,7 +5292,7 @@ int iuse::unfold_generic( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; } - vehicle *veh = g->m.add_vehicle( vproto_id( "none" ), p->posx(), p->posy(), 0, 0, 0, false ); + vehicle *veh = g->m.add_vehicle( vproto_id( "none" ), p->pos().xy(), 0, 0, 0, false ); if( veh == nullptr ) { p->add_msg_if_player( m_info, _( "There's no room to unfold the %s." ), it->tname() ); return 0; diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 8734e08a93b99..b92e0b6e6eca5 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -531,7 +531,7 @@ int unfold_vehicle_iuse::use( player &p, item &it, bool /*t*/, const tripoint &/ } } - vehicle *veh = g->m.add_vehicle( vehicle_id, p.posx(), p.posy(), 0, 0, 0, false ); + vehicle *veh = g->m.add_vehicle( vehicle_id, p.pos().xy(), 0, 0, 0, false ); if( veh == nullptr ) { p.add_msg_if_player( m_info, _( "There's no room to unfold the %s." ), it.tname() ); return 0; diff --git a/src/map.cpp b/src/map.cpp index f276b0ccb03ff..0524ef584eee8 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -6461,7 +6461,7 @@ void map::load( const int wx, const int wy, const int wz, const bool update_vehi } field_furn_locs.clear(); submaps_with_active_items.clear(); - set_abs_sub( wx, wy, wz ); + set_abs_sub( tripoint( wx, wy, wz ) ); for( int gridx = 0; gridx < my_MAPSIZE; gridx++ ) { for( int gridy = 0; gridy < my_MAPSIZE; gridy++ ) { loadn( point( gridx, gridy ), update_vehicle ); @@ -6538,7 +6538,7 @@ void map::shift( const int sx, const int sy ) const int absy = get_abs_sub().y; const int wz = get_abs_sub().z; - set_abs_sub( absx + sx, absy + sy, wz ); + set_abs_sub( tripoint( absx + sx, absy + sy, wz ) ); // if player is in vehicle, (s)he must be shifted with vehicle too if( g->u.in_vehicle ) { @@ -6657,7 +6657,7 @@ void map::vertical_shift( const int newz ) } tripoint trp = get_abs_sub(); - set_abs_sub( trp.x, trp.y, newz ); + set_abs_sub( tripoint( trp.xy(), newz ) ); // TODO: Remove the function when it's safe return; @@ -7545,7 +7545,7 @@ bool tinymap::inbounds( const tripoint &p ) const bool tinymap::fake_load( const furn_id &fur_type, const ter_id &ter_type, const trap_id &trap_type ) { bool do_terset = true; - set_abs_sub( 0, 0, 0 ); + set_abs_sub( tripoint_zero ); for( int gridx = 0; gridx < my_MAPSIZE; gridx++ ) { for( int gridy = 0; gridy < my_MAPSIZE; gridy++ ) { const tripoint gridp( gridx, gridy, 0 ); diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 9582a064dfc1f..9ae22763c80a7 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -560,7 +560,7 @@ static void mx_roadblock( map &m, const tripoint &abs_sub ) m.add_spawn( mon_chickenbot, 1, point( 12, 12 ) ); } else if( one_in( 2 ) ) { // TAAANK // The truck's wrecked...with fuel. Explosive barrel? - m.add_vehicle( vproto_id( "military_cargo_truck" ), 12, SEEY * 2 - 8, 0, 70, -1 ); + m.add_vehicle( vproto_id( "military_cargo_truck" ), point( 12, SEEY * 2 - 8 ), 0, 70, -1 ); m.add_spawn( mon_tankbot, 1, point( 12, 12 ) ); } else { // Vehicle & turrets m.add_vehicle( vgroup_id( "military_vehicles" ), tripoint( 12, SEEY * 2 - 10, abs_sub.z ), 0, 70, @@ -615,8 +615,8 @@ static void mx_roadblock( map &m, const tripoint &abs_sub ) m.add_spawn( mon_turret, 1, point( 1, 12 ) ); } - m.add_vehicle( vproto_id( "policecar" ), 8, 6, 20 ); - m.add_vehicle( vproto_id( "policecar" ), 16, SEEY * 2 - 6, 145 ); + m.add_vehicle( vproto_id( "policecar" ), point( 8, 6 ), 20 ); + m.add_vehicle( vproto_id( "policecar" ), point( 16, SEEY * 2 - 6 ), 145 ); int num_bodies = dice( 1, 6 ); for( int i = 0; i < num_bodies; i++ ) { if( const auto p = random_point( m, [&m]( const tripoint & n ) { @@ -917,7 +917,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) //50% chance to spawn a humvee in the left block if( one_in( 2 ) ) { - m.add_vehicle( vproto_id( "humvee" ), 5, 3, 270, 70, -1 ); + m.add_vehicle( vproto_id( "humvee" ), point( 5, 3 ), 270, 70, -1 ); } //Sandbag block at the right edge @@ -1057,8 +1057,8 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) //50% chance to spawn two humvees blocking the road if( one_in( 2 ) ) { - m.add_vehicle( vproto_id( "humvee" ), 7, 19, 0, 70, -1 ); - m.add_vehicle( vproto_id( "humvee" ), 15, 20, 180, 70, -1 ); + m.add_vehicle( vproto_id( "humvee" ), point( 7, 19 ), 0, 70, -1 ); + m.add_vehicle( vproto_id( "humvee" ), point( 15, 20 ), 180, 70, -1 ); } //Spawn 6-20 mines in the upper submap. @@ -1130,7 +1130,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) m.add_field( { 1, 6, abs_sub.z }, fd_gibs_flesh, 1 ); //Add the culprit - m.add_vehicle( vproto_id( "car_fbi" ), 7, 7, 0, 70, 1 ); + m.add_vehicle( vproto_id( "car_fbi" ), point( 7, 7 ), 0, 70, 1 ); //Remove tent parts after drive-through square_furn( &m, f_null, 0, 6, 8, 9 ); @@ -1245,7 +1245,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) if( bridge_at_east && !bridge_at_center && road_at_west ) { //Spawn military cargo truck blocking the entry - m.add_vehicle( vproto_id( "military_cargo_truck" ), 15, 11, 270, 70, 1 ); + m.add_vehicle( vproto_id( "military_cargo_truck" ), point( 15, 11 ), 270, 70, 1 ); //Spawn sandbag and barbed wire fence barricades around the truck line_furn( &m, f_sandbag_half, 14, 2, 14, 8 ); @@ -1387,7 +1387,7 @@ static void mx_crater( map &m, const tripoint &abs_sub ) //Pythagoras to the rescue, x^2 + y^2 = hypotenuse^2 if( !trigdist || ( i - x ) * ( i - x ) + ( j - y ) * ( j - y ) <= size_squared ) { m.destroy( tripoint( i, j, abs_sub.z ), true ); - m.adjust_radiation( i, j, rng( 20, 40 ) ); + m.adjust_radiation( point( i, j ), rng( 20, 40 ) ); } } } @@ -1520,7 +1520,7 @@ static void mx_portal_in( map &m, const tripoint &abs_sub ) if( trig_dist( x, y, i, j ) + rng( 0, 3 ) <= rad ) { const tripoint loc( i, j, abs_sub.z ); dead_vegetation_parser( m, loc ); - m.adjust_radiation( loc.x, loc.y, rng( 20, 40 ) ); + m.adjust_radiation( loc.xy(), rng( 20, 40 ) ); } } } @@ -2306,10 +2306,10 @@ static void mx_roadworks( map &m, const tripoint &abs_sub ) // vehicle placer switch( rng( 1, 6 ) ) { case 1: - m.add_vehicle( vproto_id( "road_roller" ), veh.x, veh.y, rng( 0, 360 ) ); + m.add_vehicle( vproto_id( "road_roller" ), veh, rng( 0, 360 ) ); break; case 2: - m.add_vehicle( vproto_id( "excavator" ), veh.x, veh.y, rng( 0, 360 ) ); + m.add_vehicle( vproto_id( "excavator" ), veh, rng( 0, 360 ) ); break; case 3: case 4: @@ -2331,8 +2331,8 @@ static void mx_mayhem( map &m, const tripoint &abs_sub ) switch( rng( 1, 3 ) ) { //Car accident resulted in a shootout with two victims case 1: { - m.add_vehicle( vproto_id( "car" ), 18, 9, 270 ); - m.add_vehicle( vproto_id( "4x4_car" ), 20, 5, 0 ); + m.add_vehicle( vproto_id( "car" ), point( 18, 9 ), 270 ); + m.add_vehicle( vproto_id( "4x4_car" ), point( 20, 5 ), 0 ); m.spawn_item( { 16, 10, abs_sub.z }, "shot_hull" ); m.add_corpse( { 16, 9, abs_sub.z } ); @@ -2350,7 +2350,7 @@ static void mx_mayhem( map &m, const tripoint &abs_sub ) } //Some cocky moron with friends got dragged out of limo and shooted down by a military case 2: { - m.add_vehicle( vproto_id( "limousine" ), 18, 9, 270 ); + m.add_vehicle( vproto_id( "limousine" ), point( 18, 9 ), 270 ); m.add_corpse( { 16, 9, abs_sub.z } ); m.add_corpse( { 16, 11, abs_sub.z } ); @@ -2367,7 +2367,7 @@ static void mx_mayhem( map &m, const tripoint &abs_sub ) } //Some unfortunate stopped at the roadside to change tire, but was ambushed and killed case 3: { - m.add_vehicle( vproto_id( "car" ), 18, 12, 270 ); + m.add_vehicle( vproto_id( "car" ), point( 18, 12 ), 270 ); m.add_field( { 16, 15, abs_sub.z }, fd_blood, rng( 1, 3 ) ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index c713543439853..de03bb5ad1220 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -2743,7 +2743,7 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, const auto place_office_chairs = [&]() { int num_chairs = rng( 0, 6 ); for( int i = 0; i < num_chairs; i++ ) { - add_vehicle( vproto_id( "swivel_chair" ), rng( 6, 16 ), rng( 6, 16 ), + add_vehicle( vproto_id( "swivel_chair" ), point( rng( 6, 16 ), rng( 6, 16 ) ), 0, -1, -1, false ); } }; @@ -3074,54 +3074,54 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, if( dat.west() == "office_tower_b_entrance" ) { rotate( 1 ); if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "car" ), 17, 7, 180 ); + add_vehicle( vproto_id( "car" ), point( 17, 7 ), 180 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "motorcycle" ), 17, 13, 180 ); + add_vehicle( vproto_id( "motorcycle" ), point( 17, 13 ), 180 ); } if( x_in_y( 1, 5 ) ) { if( one_in( 3 ) ) { - add_vehicle( vproto_id( "fire_truck" ), 6, 13, 0 ); + add_vehicle( vproto_id( "fire_truck" ), point( 6, 13 ), 0 ); } else { - add_vehicle( vproto_id( "pickup" ), 17, 19, 180 ); + add_vehicle( vproto_id( "pickup" ), point( 17, 19 ), 180 ); } } } else if( dat.north() == "office_tower_b_entrance" ) { rotate( 2 ); if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "car" ), 10, 17, 270 ); + add_vehicle( vproto_id( "car" ), point( 10, 17 ), 270 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "motorcycle" ), 4, 18, 270 ); + add_vehicle( vproto_id( "motorcycle" ), point( 4, 18 ), 270 ); } if( x_in_y( 1, 5 ) ) { if( one_in( 3 ) ) { - add_vehicle( vproto_id( "fire_truck" ), 6, 13, 0 ); + add_vehicle( vproto_id( "fire_truck" ), point( 6, 13 ), 0 ); } else { - add_vehicle( vproto_id( "pickup" ), 16, 17, 270 ); + add_vehicle( vproto_id( "pickup" ), point( 16, 17 ), 270 ); } } } else if( dat.east() == "office_tower_b_entrance" ) { rotate( 3 ); if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "car" ), 6, 4, 0 ); + add_vehicle( vproto_id( "car" ), point( 6, 4 ), 0 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "motorcycle" ), 6, 10, 180 ); + add_vehicle( vproto_id( "motorcycle" ), point( 6, 10 ), 180 ); } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "pickup" ), 6, 16, 0 ); + add_vehicle( vproto_id( "pickup" ), point( 6, 16 ), 0 ); } } else { if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "pickup" ), 7, 6, 90 ); + add_vehicle( vproto_id( "pickup" ), point( 7, 6 ), 90 ); } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "car" ), 14, 6, 90 ); + add_vehicle( vproto_id( "car" ), point( 14, 6 ), 90 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "motorcycle" ), 19, 6, 90 ); + add_vehicle( vproto_id( "motorcycle" ), point( 19, 6 ), 90 ); } } } else if( ( dat.west() == "office_tower_b_entrance" && dat.north() == "office_tower_b" ) || @@ -3161,49 +3161,49 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, if( dat.north() == "office_tower_b_entrance" ) { rotate( 1 ); if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "car" ), 8, 15, 0 ); + add_vehicle( vproto_id( "car" ), point( 8, 15 ), 0 ); } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "pickup" ), 7, 10, 180 ); + add_vehicle( vproto_id( "pickup" ), point( 7, 10 ), 180 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "beetle" ), 7, 3, 0 ); + add_vehicle( vproto_id( "beetle" ), point( 7, 3 ), 0 ); } } else if( dat.east() == "office_tower_b_entrance" ) { rotate( 2 ); if( x_in_y( 1, 5 ) ) { if( one_in( 3 ) ) { - add_vehicle( vproto_id( "fire_truck" ), 6, 13, 0 ); + add_vehicle( vproto_id( "fire_truck" ), point( 6, 13 ), 0 ); } else { - add_vehicle( vproto_id( "pickup" ), 7, 7, 270 ); + add_vehicle( vproto_id( "pickup" ), point( 7, 7 ), 270 ); } } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "car" ), 13, 8, 90 ); + add_vehicle( vproto_id( "car" ), point( 13, 8 ), 90 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "beetle" ), 20, 7, 90 ); + add_vehicle( vproto_id( "beetle" ), point( 20, 7 ), 90 ); } } else if( dat.south() == "office_tower_b_entrance" ) { rotate( 3 ); if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "pickup" ), 16, 7, 0 ); + add_vehicle( vproto_id( "pickup" ), point( 16, 7 ), 0 ); } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "car" ), 15, 13, 180 ); + add_vehicle( vproto_id( "car" ), point( 15, 13 ), 180 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "beetle" ), 15, 20, 180 ); + add_vehicle( vproto_id( "beetle" ), point( 15, 20 ), 180 ); } } else { if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "pickup" ), 16, 16, 90 ); + add_vehicle( vproto_id( "pickup" ), point( 16, 16 ), 90 ); } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "car" ), 9, 15, 270 ); + add_vehicle( vproto_id( "car" ), point( 9, 15 ), 270 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "beetle" ), 4, 16, 270 ); + add_vehicle( vproto_id( "beetle" ), point( 4, 16 ), 270 ); } } } else { @@ -3241,56 +3241,56 @@ void map::draw_office_tower( const oter_id &terrain_type, mapgendata &dat, rotate( 1 ); if( x_in_y( 1, 5 ) ) { if( one_in( 3 ) ) { - add_vehicle( vproto_id( "cube_van" ), 17, 4, 180 ); + add_vehicle( vproto_id( "cube_van" ), point( 17, 4 ), 180 ); } else { - add_vehicle( vproto_id( "cube_van_cheap" ), 17, 4, 180 ); + add_vehicle( vproto_id( "cube_van_cheap" ), point( 17, 4 ), 180 ); } } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "pickup" ), 17, 10, 180 ); + add_vehicle( vproto_id( "pickup" ), point( 17, 10 ), 180 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "car" ), 17, 17, 180 ); + add_vehicle( vproto_id( "car" ), point( 17, 17 ), 180 ); } } else if( dat.east() == "office_tower_b" && dat.north() == "office_tower_b" ) { rotate( 2 ); if( x_in_y( 1, 5 ) ) { if( one_in( 3 ) ) { - add_vehicle( vproto_id( "cube_van" ), 6, 17, 270 ); + add_vehicle( vproto_id( "cube_van" ), point( 6, 17 ), 270 ); } else { - add_vehicle( vproto_id( "cube_van_cheap" ), 6, 17, 270 ); + add_vehicle( vproto_id( "cube_van_cheap" ), point( 6, 17 ), 270 ); } } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "pickup" ), 12, 17, 270 ); + add_vehicle( vproto_id( "pickup" ), point( 12, 17 ), 270 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "fire_truck" ), 18, 17, 270 ); + add_vehicle( vproto_id( "fire_truck" ), point( 18, 17 ), 270 ); } } else if( dat.east() == "office_tower_b" && dat.south() == "office_tower_b" ) { rotate( 3 ); if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "cube_van_cheap" ), 6, 6, 0 ); + add_vehicle( vproto_id( "cube_van_cheap" ), point( 6, 6 ), 0 ); } if( x_in_y( 1, 5 ) ) { if( one_in( 3 ) ) { - add_vehicle( vproto_id( "fire_truck" ), 6, 13, 0 ); + add_vehicle( vproto_id( "fire_truck" ), point( 6, 13 ), 0 ); } else { - add_vehicle( vproto_id( "pickup" ), 6, 13, 0 ); + add_vehicle( vproto_id( "pickup" ), point( 6, 13 ), 0 ); } } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "car" ), 5, 19, 180 ); + add_vehicle( vproto_id( "car" ), point( 5, 19 ), 180 ); } } else { if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "flatbed_truck" ), 16, 6, 90 ); + add_vehicle( vproto_id( "flatbed_truck" ), point( 16, 6 ), 90 ); } if( x_in_y( 1, 5 ) ) { - add_vehicle( vproto_id( "cube_van_cheap" ), 10, 6, 90 ); + add_vehicle( vproto_id( "cube_van_cheap" ), point( 10, 6 ), 90 ); } if( x_in_y( 1, 3 ) ) { - add_vehicle( vproto_id( "car" ), 4, 6, 90 ); + add_vehicle( vproto_id( "car" ), point( 4, 6 ), 90 ); } } } @@ -3327,10 +3327,10 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi if( ice_lab ) { int temperature = -20 + 30 * ( dat.zlevel ); - set_temperature( x, y, temperature ); - set_temperature( x + SEEX, y, temperature ); - set_temperature( x, y + SEEY, temperature ); - set_temperature( x + SEEX, y + SEEY, temperature ); + set_temperature( point( x, y ), temperature ); + set_temperature( point( x + SEEX, y ), temperature ); + set_temperature( point( x, y + SEEY ), temperature ); + set_temperature( point( x + SEEX, y + SEEY ), temperature ); } // Check for adjacent sewers; used below @@ -4026,10 +4026,10 @@ void map::draw_lab( const oter_id &terrain_type, mapgendata &dat, const time_poi if( ice_lab ) { int temperature = -20 + 30 * dat.zlevel; - set_temperature( x, y, temperature ); - set_temperature( x + SEEX, y, temperature ); - set_temperature( x, y + SEEY, temperature ); - set_temperature( x + SEEX, y + SEEY, temperature ); + set_temperature( point( x, y ), temperature ); + set_temperature( point( x + SEEX, y ), temperature ); + set_temperature( point( x, y + SEEY ), temperature ); + set_temperature( point( x + SEEX, y + SEEY ), temperature ); } tw = is_ot_match( "lab", dat.north(), ot_match_type::contains ) ? 0 : 2; @@ -5514,7 +5514,7 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, //lazy radiation mapping for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - adjust_radiation( x, y, rng( 10, 30 ) ); + adjust_radiation( point( x, y ), rng( 10, 30 ) ); } } if( match( dat.north(), "haz_sar" ) && match( dat.west(), "haz_sar" ) ) { @@ -5566,26 +5566,26 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, //lazy radiation mapping for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - adjust_radiation( x, y, rng( 10, 30 ) ); + adjust_radiation( point( x, y ), rng( 10, 30 ) ); } } if( match( dat.west(), "haz_sar_entrance" ) ) { rotate( 1 ); if( x_in_y( 1, 4 ) ) { - add_vehicle( vproto_id( "military_cargo_truck" ), 10, 11, 0 ); + add_vehicle( vproto_id( "military_cargo_truck" ), point( 10, 11 ), 0 ); } } else if( match( dat.north(), "haz_sar_entrance" ) ) { rotate( 2 ); if( x_in_y( 1, 4 ) ) { - add_vehicle( vproto_id( "military_cargo_truck" ), 12, 10, 90 ); + add_vehicle( vproto_id( "military_cargo_truck" ), point( 12, 10 ), 90 ); } } else if( match( dat.east(), "haz_sar_entrance" ) ) { rotate( 3 ); if( x_in_y( 1, 4 ) ) { - add_vehicle( vproto_id( "military_cargo_truck" ), 13, 12, 180 ); + add_vehicle( vproto_id( "military_cargo_truck" ), point( 13, 12 ), 180 ); } } else if( x_in_y( 1, 4 ) ) { - add_vehicle( vproto_id( "military_cargo_truck" ), 11, 13, 270 ); + add_vehicle( vproto_id( "military_cargo_truck" ), point( 11, 13 ), 270 ); } } else if( ( match( dat.west(), "haz_sar_entrance" ) && match( dat.north(), "haz_sar" ) ) || @@ -5624,7 +5624,7 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, //lazy radiation mapping for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - adjust_radiation( x, y, rng( 10, 30 ) ); + adjust_radiation( point( x, y ), rng( 10, 30 ) ); } } if( match( dat.north(), "haz_sar_entrance" ) ) { @@ -5671,7 +5671,7 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, //lazy radiation mapping for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - adjust_radiation( x, y, rng( 10, 30 ) ); + adjust_radiation( point( x, y ), rng( 10, 30 ) ); } } tmpcomp = add_computer( tripoint( 2, 23, abs_sub.z ), _( "SRCF Security Terminal" ), 0 ); @@ -5735,7 +5735,7 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } if( this->ter( point( i, j ) ) != t_metal_floor ) { - adjust_radiation( i, j, rng( 10, 70 ) ); + adjust_radiation( point( i, j ), rng( 10, 70 ) ); } if( this->ter( point( i, j ) ) == t_sewage ) { if( one_in( 2 ) ) { @@ -5810,7 +5810,7 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, } } if( this->ter( point( i, j ) ) != t_metal_floor ) { - adjust_radiation( i, j, rng( 10, 70 ) ); + adjust_radiation( point( i, j ), rng( 10, 70 ) ); } if( this->ter( point( i, j ) ) == t_sewage ) { if( one_in( 2 ) ) { @@ -5877,7 +5877,7 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } if( this->ter( point( i, j ) ) != t_metal_floor ) { - adjust_radiation( i, j, rng( 10, 70 ) ); + adjust_radiation( point( i, j ), rng( 10, 70 ) ); } if( this->ter( point( i, j ) ) == t_sewage ) { if( one_in( 2 ) ) { @@ -5953,7 +5953,7 @@ void map::draw_sarcophagus( const oter_id &terrain_type, mapgendata &dat, place_spawns( GROUP_PLAIN, 80, point( i, j ), point( i, j ), 1, true ); } if( this->ter( point( i, j ) ) != t_metal_floor ) { - adjust_radiation( i, j, rng( 10, 70 ) ); + adjust_radiation( point( i, j ), rng( 10, 70 ) ); } if( this->ter( point( i, j ) ) == t_sewage ) { if( one_in( 2 ) ) { diff --git a/src/mission_start.cpp b/src/mission_start.cpp index 7b7b7ab7ee3b8..2faf0eb4721c5 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -557,7 +557,7 @@ void mission_start::ranch_scavenger_2( mission *miss ) tripoint site = mission_util::target_om_ter_random( "ranch_camp_48", 1, miss, false, RANCH_SIZE ); tinymap bay; bay.load( tripoint( site.x * 2, site.y * 2, site.z ), false ); - bay.add_vehicle( vproto_id( "car_chassis" ), 20, 15, 0 ); + bay.add_vehicle( vproto_id( "car_chassis" ), point( 20, 15 ), 0 ); bay.draw_square_ter( t_wall_half, point( 18, 19 ), point( 21, 22 ) ); bay.draw_square_ter( t_dirt, point( 19, 20 ), point( 20, 21 ) ); bay.ter_set( point( 19, 19 ), t_door_frame ); diff --git a/tests/vehicle_turrets.cpp b/tests/vehicle_turrets.cpp index dc3f1fe1aecdc..397a209d31dff 100644 --- a/tests/vehicle_turrets.cpp +++ b/tests/vehicle_turrets.cpp @@ -63,7 +63,7 @@ TEST_CASE( "vehicle_turret", "[vehicle] [gun] [magazine] [.]" ) { for( auto e : turret_types() ) { SECTION( e->name() ) { - vehicle *veh = g->m.add_vehicle( vproto_id( "none" ), 65, 65, 270, 0, 0 ); + vehicle *veh = g->m.add_vehicle( vproto_id( "none" ), point( 65, 65 ), 270, 0, 0 ); REQUIRE( veh ); const int idx = veh->install_part( point_zero, e->get_id(), true ); From e6d8d024ad229cb96cf206fe21ddab4c3bfd7db6 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 17 Aug 2019 11:49:44 -0400 Subject: [PATCH 033/113] Port more map members --- src/map.cpp | 18 +++++++++--------- src/map.h | 8 -------- src/mapgen.cpp | 4 ++-- src/mission_start.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 0524ef584eee8..bfc81092c813a 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2599,7 +2599,7 @@ bool map::is_outside( const tripoint &p ) const } bool map::is_last_ter_wall( const bool no_furn, const point &p, - const int xmax, const int ymax, const direction dir ) const + const point &max, const direction dir ) const { int xmov = 0; int ymov = 0; @@ -2624,9 +2624,9 @@ bool map::is_last_ter_wall( const bool no_furn, const point &p, bool result = true; bool loop = true; while( ( loop ) && ( ( dir == NORTH && y2 >= 0 ) || - ( dir == SOUTH && y2 < ymax ) || + ( dir == SOUTH && y2 < max.y ) || ( dir == WEST && x2 >= 0 ) || - ( dir == EAST && x2 < xmax ) ) ) { + ( dir == EAST && x2 < max.x ) ) ) { if( no_furn && has_furn( point( x2, y2 ) ) ) { loop = false; result = false; @@ -3986,9 +3986,9 @@ void map::set_radiation( const tripoint &p, const int value ) current_submap->set_radiation( l, value ); } -void map::adjust_radiation( const int x, const int y, const int delta ) +void map::adjust_radiation( const point &p, const int delta ) { - adjust_radiation( tripoint( x, y, abs_sub.z ), delta ); + adjust_radiation( tripoint( p, abs_sub.z ), delta ); } void map::adjust_radiation( const tripoint &p, const int delta ) @@ -4022,9 +4022,9 @@ void map::set_temperature( const tripoint &p, int new_temperature ) get_submap_at( p )->set_temperature( new_temperature ); } -void map::set_temperature( const int x, const int y, int new_temperature ) +void map::set_temperature( const point &p, int new_temperature ) { - set_temperature( tripoint( x, y, abs_sub.z ), new_temperature ); + set_temperature( tripoint( p, abs_sub.z ), new_temperature ); } // Items: 2D @@ -7980,9 +7980,9 @@ tripoint map::getlocal( const tripoint &p ) const return p - sm_to_ms_copy( abs_sub.xy() ); } -void map::set_abs_sub( const int x, const int y, const int z ) +void map::set_abs_sub( const tripoint &p ) { - abs_sub = tripoint( x, y, z ); + abs_sub = p; } tripoint map::get_abs_sub() const diff --git a/src/map.h b/src/map.h index dc0233eb6e8c3..81ff1cdc813a8 100644 --- a/src/map.h +++ b/src/map.h @@ -776,8 +776,6 @@ class map * @param dir Direction of check * @return true if from x to xmax or y to ymax depending on direction * all terrain is floor and the last terrain is a wall */ - bool is_last_ter_wall( bool no_furn, const point &p, - int xmax, int ymax, direction dir ) const; bool is_last_ter_wall( bool no_furn, const point &p, const point &max, direction dir ) const; @@ -893,7 +891,6 @@ class map */ void adjust_radiation( const tripoint &p, int delta ); // Overload for mapgen - void adjust_radiation( int x, int y, int delta ); void adjust_radiation( const point &p, int delta ); // Temperature @@ -902,7 +899,6 @@ class map // Set temperature for all four submap quadrants void set_temperature( const tripoint &p, int temperature ); // 2D overload for mapgen - void set_temperature( int x, int y, int temperature ); void set_temperature( const point &p, int temperature ); // Items @@ -1242,9 +1238,6 @@ class map vehicle *add_vehicle( const vgroup_id &type, const point &p, int dir, int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true ); - vehicle *add_vehicle( const vproto_id &type, int x, int y, int dir, - int init_veh_fuel = -1, int init_veh_status = -1, - bool merge_wrecks = true ); vehicle *add_vehicle( const vproto_id &type, const point &p, int dir, int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true ); @@ -1492,7 +1485,6 @@ class map /** * Sets @ref abs_sub, see there. Uses the same coordinate system as @ref abs_sub. */ - void set_abs_sub( int x, int y, int z ); void set_abs_sub( const tripoint &p ); private: diff --git a/src/mapgen.cpp b/src/mapgen.cpp index de03bb5ad1220..3db4ebff11d77 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -7009,10 +7009,10 @@ void map::add_spawn( const mtype_id &type, int count, const point &p, bool frien place_on_submap->spawns.push_back( tmp ); } -vehicle *map::add_vehicle( const vproto_id &type, const int x, const int y, const int dir, +vehicle *map::add_vehicle( const vproto_id &type, const point &p, const int dir, const int veh_fuel, const int veh_status, const bool merge_wrecks ) { - return add_vehicle( type, tripoint( x, y, abs_sub.z ), + return add_vehicle( type, tripoint( p, abs_sub.z ), dir, veh_fuel, veh_status, merge_wrecks ); } diff --git a/src/mission_start.cpp b/src/mission_start.cpp index 2faf0eb4721c5..06352a47daf97 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -162,10 +162,10 @@ static tripoint find_potential_computer_point( const tinymap &compmap, int z ) } } if( wall == 5 ) { - if( compmap.is_last_ter_wall( true, point( x, y ), SEEX * 2, SEEY * 2, NORTH ) && - compmap.is_last_ter_wall( true, point( x, y ), SEEX * 2, SEEY * 2, SOUTH ) && - compmap.is_last_ter_wall( true, point( x, y ), SEEX * 2, SEEY * 2, WEST ) && - compmap.is_last_ter_wall( true, point( x, y ), SEEX * 2, SEEY * 2, EAST ) ) { + if( compmap.is_last_ter_wall( true, point( x, y ), point( SEEX * 2, SEEY * 2 ), NORTH ) && + compmap.is_last_ter_wall( true, point( x, y ), point( SEEX * 2, SEEY * 2 ), SOUTH ) && + compmap.is_last_ter_wall( true, point( x, y ), point( SEEX * 2, SEEY * 2 ), WEST ) && + compmap.is_last_ter_wall( true, point( x, y ), point( SEEX * 2, SEEY * 2 ), EAST ) ) { potential.emplace_back( x, y, z ); } } From 5e847147c6f6db32f792f4f4f5839079131b4f68 Mon Sep 17 00:00:00 2001 From: free-coffee <43655436+free-coffee@users.noreply.github.com> Date: Sat, 17 Aug 2019 21:30:05 +0200 Subject: [PATCH 034/113] fix: added roof (utility light) (#33300) * fix: added roof (utility light) --- data/json/furniture_and_terrain/terrain-floors_indoor.json | 1 + 1 file changed, 1 insertion(+) diff --git a/data/json/furniture_and_terrain/terrain-floors_indoor.json b/data/json/furniture_and_terrain/terrain-floors_indoor.json index ef10c44a37b93..cdf6b83b6a70c 100644 --- a/data/json/furniture_and_terrain/terrain-floors_indoor.json +++ b/data/json/furniture_and_terrain/terrain-floors_indoor.json @@ -321,6 +321,7 @@ "symbol": ".", "color": "white", "move_cost": 2, + "roof": "t_flat_roof", "light_emitted": 240, "flags": [ "TRANSPARENT", "FLAMMABLE_HARD", "SUPPORTS_ROOF", "COLLAPSES", "INDOORS", "FLAT", "ROAD", "MINEABLE" ], "bash": { From d20130865454413e85d75281797044c24b4db6ec Mon Sep 17 00:00:00 2001 From: Tonkatsu Date: Sat, 17 Aug 2019 14:36:54 -0500 Subject: [PATCH 035/113] Fairy Bread and Sprinkles (#33183) * Removed cutting quality from some easy sandwich recipes * Added sprinkles * Added fairy bread --- data/json/itemgroups/food.json | 1 + data/json/itemgroups/food_service.json | 1 + data/json/items/comestibles/sandwich.json | 19 +++++++++++++++ data/json/items/comestibles/spice.json | 13 ++++++++++ data/json/recipes/recipe_food.json | 29 ++++++++++++++--------- 5 files changed, 52 insertions(+), 11 deletions(-) diff --git a/data/json/itemgroups/food.json b/data/json/itemgroups/food.json index c0398444e15c4..263b970e5b2a4 100644 --- a/data/json/itemgroups/food.json +++ b/data/json/itemgroups/food.json @@ -65,6 +65,7 @@ "items": [ [ "yeast", 50 ], [ "sugar", 40 ], + [ "sprinkles", 5 ], [ "salt", 40 ], [ "pepper", 30 ], [ "cinnamon", 15 ], diff --git a/data/json/itemgroups/food_service.json b/data/json/itemgroups/food_service.json index 6f266e92e9010..7bd38c3bee335 100644 --- a/data/json/itemgroups/food_service.json +++ b/data/json/itemgroups/food_service.json @@ -653,6 +653,7 @@ [ "ketchup", 60 ], [ "mustard", 60 ], [ "horseradish", 10 ], + [ "sprinkles", 20 ], [ "honey_bottled", 35 ], [ "honey_glassed", 35 ], [ "peanutbutter", 60 ], diff --git a/data/json/items/comestibles/sandwich.json b/data/json/items/comestibles/sandwich.json index 1190f25b36260..8f5eee090a05b 100644 --- a/data/json/items/comestibles/sandwich.json +++ b/data/json/items/comestibles/sandwich.json @@ -110,6 +110,25 @@ "fun": 15, "vitamins": [ [ "vitC", 6 ], [ "calcium", 7 ], [ "iron", 12 ] ] }, + { + "type": "COMESTIBLE", + "id": "sandwich_fairy", + "name": "fairy bread", + "name_plural": "fairy bread", + "weight": 114, + "color": "brown", + "spoils_in": "3 days", + "container": "wrapper", + "comestible_type": "FOOD", + "symbol": "%", + "calories": 640, + "description": "An 'open-faced sandwich' consisting of sliced white bread, a healthy crust-to-crust slathering of butter, and sprinkles. Supposedly a staple of birthday parties in Australia.", + "price": 85, + "material": [ "junk", "wheat" ], + "primary_material": "wheat", + "volume": "250 ml", + "fun": 10 + }, { "type": "COMESTIBLE", "id": "sandwich_honey", diff --git a/data/json/items/comestibles/spice.json b/data/json/items/comestibles/spice.json index 022596ec5325a..0e38f2e29ee11 100644 --- a/data/json/items/comestibles/spice.json +++ b/data/json/items/comestibles/spice.json @@ -82,6 +82,19 @@ "//": "a tbps is 4.2g of sugar, meaning the volume needed to be adjusted.", "charges": 71 }, + { + "type": "COMESTIBLE", + "id": "sprinkles", + "name": "sprinkles", + "name_plural": "sprinkles", + "weight": 4, + "copy-from": "sugar", + "container": "bottle_plastic_small", + "description": "Known as nonpareils, sprinkles, jimmies, sugar strands or 'hundreds-and-thousands', these colorful balls, rods or flakes of sugar and starch are intended for use decorating soft surfaces of sweets. Like sugar, they are bad for your teeth and surprisingly not very tasty on their own.", + "price": 399, + "calories": 20, + "charges": 66 + }, { "type": "COMESTIBLE", "id": "wild_herbs", diff --git a/data/json/recipes/recipe_food.json b/data/json/recipes/recipe_food.json index a0717b14c7b88..98fbc50f51350 100644 --- a/data/json/recipes/recipe_food.json +++ b/data/json/recipes/recipe_food.json @@ -5694,9 +5694,8 @@ "category": "CC_FOOD", "subcategory": "CSC_FOOD_VEGGI", "skill_used": "cooking", - "time": "4 m", + "time": "1 m", "autolearn": true, - "qualities": [ { "id": "CUT", "level": 1 } ], "components": [ [ [ "flatbread", 2 ], [ "bread", 2 ], [ "cornbread", 2 ], [ "wastebread", 2 ], [ "sourdough_bread", 2 ] ], [ [ "peanutbutter", 1 ], [ "peanutbutter_imitation", 1 ] ] @@ -5708,9 +5707,8 @@ "category": "CC_FOOD", "subcategory": "CSC_FOOD_VEGGI", "skill_used": "cooking", - "time": "4 m", + "time": "1 m", "autolearn": true, - "qualities": [ { "id": "CUT", "level": 1 } ], "components": [ [ [ "flatbread", 2 ], [ "bread", 2 ], [ "cornbread", 2 ], [ "wastebread", 2 ], [ "sourdough_bread", 2 ] ], [ [ "jam_fruit", 1 ] ], @@ -5723,9 +5721,8 @@ "category": "CC_FOOD", "subcategory": "CSC_FOOD_VEGGI", "skill_used": "cooking", - "time": "4 m", + "time": "1 m", "autolearn": true, - "qualities": [ { "id": "CUT", "level": 1 } ], "components": [ [ [ "flatbread", 2 ], [ "bread", 2 ], [ "cornbread", 2 ], [ "wastebread", 2 ], [ "sourdough_bread", 2 ] ], [ [ "honeycomb", 2 ], [ "honey_bottled", 2 ], [ "honey_glassed", 2 ] ], @@ -5738,9 +5735,8 @@ "category": "CC_FOOD", "subcategory": "CSC_FOOD_VEGGI", "skill_used": "cooking", - "time": "4 m", + "time": "1 m", "autolearn": true, - "qualities": [ { "id": "CUT", "level": 1 } ], "components": [ [ [ "flatbread", 2 ], [ "bread", 2 ], [ "cornbread", 2 ], [ "wastebread", 2 ], [ "sourdough_bread", 2 ] ], [ [ "syrup", 1 ] ], @@ -5761,6 +5757,20 @@ [ [ "human_cooked", 1 ], [ "hfleshbologna", 5 ] ] ] }, + { + "type": "recipe", + "result": "sandwich_fairy", + "category": "CC_FOOD", + "subcategory": "CSC_FOOD_VEGGI", + "skill_used": "cooking", + "time": "1 m", + "book_learn": [ [ "mag_glam", 1 ] ], + "components": [ + [ [ "flatbread", 1 ], [ "bread", 1 ], [ "cornbread", 1 ], [ "wastebread", 1 ], [ "sourdough_bread", 1 ] ], + [ [ "butter", 4 ], [ "ghee", 4 ] ], + [ [ "sprinkles", 3 ] ] + ] + }, { "type": "recipe", "result": "toasterpastry", @@ -6821,7 +6831,6 @@ "skill_used": "cooking", "time": "1 m", "autolearn": true, - "qualities": [ { "id": "CUT", "level": 1 } ], "components": [ [ [ "flatbread", 2 ], [ "bread", 2 ], [ "cornbread", 2 ], [ "wastebread", 2 ], [ "sourdough_bread", 2 ] ], [ [ "mayonnaise", 1 ], [ "ketchup", 1 ], [ "sauce_pesto", 1 ], [ "sauce_red", 1 ], [ "mustard", 1 ] ] @@ -6835,7 +6844,6 @@ "skill_used": "cooking", "time": "1 m", "autolearn": true, - "qualities": [ { "id": "CUT", "level": 1 } ], "components": [ [ [ "flatbread", 2 ], [ "bread", 2 ], [ "cornbread", 2 ], [ "wastebread", 2 ], [ "sourdough_bread", 2 ] ], [ [ "jam_fruit", 1 ] ] @@ -6849,7 +6857,6 @@ "skill_used": "cooking", "time": "1 m", "autolearn": true, - "qualities": [ { "id": "CUT", "level": 1 } ], "components": [ [ [ "flatbread", 2 ], [ "bread", 2 ], [ "cornbread", 2 ], [ "wastebread", 2 ], [ "sourdough_bread", 2 ] ], [ [ "honeycomb", 1 ], [ "honey_bottled", 1 ] ] From e22665d0862101f0f30974ccb3cd624ba167caff Mon Sep 17 00:00:00 2001 From: Pete Date: Sat, 17 Aug 2019 15:01:30 -0500 Subject: [PATCH 036/113] Check for completed 'reach refugee center' missions before assigning a new one. --- src/computer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/computer.cpp b/src/computer.cpp index e8c449901626f..6d615401c2d30 100644 --- a/src/computer.cpp +++ b/src/computer.cpp @@ -1689,8 +1689,12 @@ void computer::mark_refugee_center() SEARCHING FOR NEAREST REFUGEE CENTER, PLEASE WAIT ... " ) ); const mission_type_id &mission_type = mission_type_id( "MISSION_REACH_REFUGEE_CENTER" ); - const std::vector missions = g->u.get_active_missions(); tripoint mission_target; + // Check completed missions too, so people can't repeatedly get the mission. + const std::vector completed_missions = g->u.get_completed_missions(); + std::vector missions = g->u.get_active_missions(); + missions.reserve( completed_missions.size() ); + missions.insert( missions.end(), completed_missions.begin(), completed_missions.end() ); const bool has_mission = std::any_of( missions.begin(), missions.end(), [ &mission_type, &mission_target ]( mission * mission ) { From 2748ffe66cb45825cd9d42a0278f4e00a8a15d95 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sat, 17 Aug 2019 23:32:02 +0200 Subject: [PATCH 037/113] Fix iterating in Creature_tracker::kill_marked_for_death Copy the list of monsters before iterating over it so we can change it while doing so. Also changes a few internals: - add assert instead of a silent check for a null pointer (those should not be there at all, if there are any, it's a serious problem). - early continue. --- src/creature_tracker.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/creature_tracker.cpp b/src/creature_tracker.cpp index 9410ad0186ff3..5a39761d8fac6 100644 --- a/src/creature_tracker.cpp +++ b/src/creature_tracker.cpp @@ -252,17 +252,20 @@ bool Creature_tracker::kill_marked_for_death() // Important: `Creature::die` must not be called after creature objects (NPCs, monsters) have // been removed, the dying creature could still have a pointer (the killer) to another creature. bool monster_is_dead = false; - for( const auto &mon_ptr : monsters_list ) { - if( mon_ptr != nullptr ) { - monster &critter = *mon_ptr; - if( critter.is_dead() ) { - dbg( D_INFO ) << string_format( "cleanup_dead: critter %d,%d,%d hp:%d %s", - critter.posx(), critter.posy(), critter.posz(), - critter.get_hp(), critter.name() ); - critter.die( nullptr ); - monster_is_dead = true; - } + // Copy the list so we can iterate the copy safely *and* add new monsters from within monster::die + // This happens for example with blob monsters (they split into two smaller monsters). + const auto copy = monsters_list; + for( const std::shared_ptr &mon_ptr : copy ) { + assert( mon_ptr ); + monster &critter = *mon_ptr; + if( !critter.is_dead() ) { + continue; } + dbg( D_INFO ) << string_format( "cleanup_dead: critter %d,%d,%d hp:%d %s", + critter.posx(), critter.posy(), critter.posz(), + critter.get_hp(), critter.name() ); + critter.die( nullptr ); + monster_is_dead = true; } return monster_is_dead; From c09f8c8c2c401b63738b6a7de118b22c498160f1 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sat, 17 Aug 2019 23:47:08 +0200 Subject: [PATCH 038/113] Clear vehicle groups upon unloading game data --- src/init.cpp | 1 + src/vehicle_group.cpp | 5 +++++ src/vehicle_group.h | 1 + 3 files changed, 7 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 8831ec5f2e12d..5fe5395d28a28 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -514,6 +514,7 @@ void DynamicDataLoader::unload_data() npc_template::reset(); anatomy::reset(); reset_mod_tileset(); + VehicleGroup::reset(); // TODO: // Name::clear(); diff --git a/src/vehicle_group.cpp b/src/vehicle_group.cpp index f656816112623..7cf3915d94138 100644 --- a/src/vehicle_group.cpp +++ b/src/vehicle_group.cpp @@ -72,6 +72,11 @@ void VehicleGroup::load( JsonObject &jo ) } } +void VehicleGroup::reset() +{ + vgroups.clear(); +} + VehicleFacings::VehicleFacings( JsonObject &jo, const std::string &key ) { if( jo.has_array( key ) ) { diff --git a/src/vehicle_group.h b/src/vehicle_group.h index c94e8445b00ba..5b46e0b68aafc 100644 --- a/src/vehicle_group.h +++ b/src/vehicle_group.h @@ -42,6 +42,7 @@ class VehicleGroup } static void load( JsonObject &jo ); + static void reset(); private: weighted_int_list vehicles; From 95122e9cf53ff4621195066bd6953f6a52486358 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sat, 17 Aug 2019 23:47:30 +0200 Subject: [PATCH 039/113] Clear vehicle placements upon unloading game data --- src/init.cpp | 1 + src/vehicle_group.cpp | 5 +++++ src/vehicle_group.h | 1 + 3 files changed, 7 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 5fe5395d28a28..0154ffd3f8116 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -515,6 +515,7 @@ void DynamicDataLoader::unload_data() anatomy::reset(); reset_mod_tileset(); VehicleGroup::reset(); + VehiclePlacement::reset(); // TODO: // Name::clear(); diff --git a/src/vehicle_group.cpp b/src/vehicle_group.cpp index 7cf3915d94138..22b05d7bdc12a 100644 --- a/src/vehicle_group.cpp +++ b/src/vehicle_group.cpp @@ -103,6 +103,11 @@ void VehiclePlacement::load( JsonObject &jo ) } } +void VehiclePlacement::reset() +{ + vplacements.clear(); +} + const VehicleLocation *VehiclePlacement::pick() const { if( const auto chosen = random_entry_opt( locations ) ) { diff --git a/src/vehicle_group.h b/src/vehicle_group.h index 5b46e0b68aafc..753f5a56bb837 100644 --- a/src/vehicle_group.h +++ b/src/vehicle_group.h @@ -88,6 +88,7 @@ struct VehiclePlacement { const VehicleLocation *pick() const; static void load( JsonObject &jo ); + static void reset(); using LocationMap = std::vector; LocationMap locations; From ad3eee8331a69abb0f1e15deb377681979c9f3ae Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sat, 17 Aug 2019 23:47:37 +0200 Subject: [PATCH 040/113] Clear vehicle spawns upon unloading game data --- src/init.cpp | 1 + src/vehicle_group.cpp | 5 +++++ src/vehicle_group.h | 1 + 3 files changed, 7 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 0154ffd3f8116..cda20062c680c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -516,6 +516,7 @@ void DynamicDataLoader::unload_data() reset_mod_tileset(); VehicleGroup::reset(); VehiclePlacement::reset(); + VehicleSpawn::reset(); // TODO: // Name::clear(); diff --git a/src/vehicle_group.cpp b/src/vehicle_group.cpp index 22b05d7bdc12a..244e8a77ea59c 100644 --- a/src/vehicle_group.cpp +++ b/src/vehicle_group.cpp @@ -194,6 +194,11 @@ void VehicleSpawn::load( JsonObject &jo ) } } +void VehicleSpawn::reset() +{ + vspawns.clear(); +} + void VehicleSpawn::apply( map &m, const std::string &terrain_name ) const { const std::shared_ptr *func = types.pick(); diff --git a/src/vehicle_group.h b/src/vehicle_group.h index 753f5a56bb837..7059d72cd3f3f 100644 --- a/src/vehicle_group.h +++ b/src/vehicle_group.h @@ -180,6 +180,7 @@ class VehicleSpawn static void apply( const vspawn_id &id, map &m, const std::string &terrain_name ); static void load( JsonObject &jo ); + static void reset(); private: weighted_float_list> types; From 5a53d0811212f40ec65b9b132fd8f66926970859 Mon Sep 17 00:00:00 2001 From: Pete Date: Sat, 17 Aug 2019 17:14:09 -0500 Subject: [PATCH 041/113] Old Guard Rep now gives more than a single bullet to his new Marshal. --- .../surface_visitors/NPC_old_guard_representative.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/npcs/refugee_center/surface_visitors/NPC_old_guard_representative.json b/data/json/npcs/refugee_center/surface_visitors/NPC_old_guard_representative.json index f6f3c22a78c0f..636c55fbba2c8 100644 --- a/data/json/npcs/refugee_center/surface_visitors/NPC_old_guard_representative.json +++ b/data/json/npcs/refugee_center/surface_visitors/NPC_old_guard_representative.json @@ -203,7 +203,7 @@ "update_mapgen": { "place_npcs": [ { "class": "bandit", "x": 17, "y": 9, "target": true } ] }, "effect": [ { "u_buy_item": "ruger_redhawk" }, - { "u_buy_item": "44magnum" }, + { "u_buy_item": "44magnum", "count": 17 }, { "u_buy_item": "holster" }, { "u_buy_item": "badge_marshal" }, { "u_add_trait": "PROF_FED" } From 28ef9e6599f21aff172ad28152007e645b6761a5 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 18 Aug 2019 01:48:05 +0200 Subject: [PATCH 042/113] pet armor dropped from zombies are filthy --- src/monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monster.cpp b/src/monster.cpp index b322508266b0b..f66a57c12424d 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -2204,7 +2204,7 @@ void monster::drop_items_on_death() if( has_flag( MF_FILTHY ) && get_option( "FILTHY_CLOTHES" ) ) { for( const auto &it : dropped ) { - if( it->is_armor() ) { + if( it->is_armor() || it->is_pet_armor() ) { it->item_tags.insert( "FILTHY" ); } } From eee31b19200ac29f3616cd710820beea7b77af87 Mon Sep 17 00:00:00 2001 From: Pete Date: Sat, 17 Aug 2019 21:07:17 -0500 Subject: [PATCH 043/113] Add descriptions to Old Guard Rep missions. --- .../surface_visitors/NPC_old_guard_representative.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/data/json/npcs/refugee_center/surface_visitors/NPC_old_guard_representative.json b/data/json/npcs/refugee_center/surface_visitors/NPC_old_guard_representative.json index f6f3c22a78c0f..effa34038389a 100644 --- a/data/json/npcs/refugee_center/surface_visitors/NPC_old_guard_representative.json +++ b/data/json/npcs/refugee_center/surface_visitors/NPC_old_guard_representative.json @@ -91,6 +91,7 @@ "id": "MISSION_OLD_GUARD_REP_1", "type": "mission_definition", "name": "Kill Bandits", + "description": "A pair of bandits have been preying on locals, based out of a nearby cabin. Ensure they meet a bitter end along with any associates, but watch out for traps around their hideout.", "goal": "MGOAL_ASSASSINATE", "difficulty": 5, "value": 50000, @@ -124,6 +125,7 @@ "id": "MISSION_OLD_GUARD_REP_2", "type": "mission_definition", "name": "Deal with Informant", + "description": "The Hell's Raiders bandit group may have an informant working inside the Refugee Center. Investigate and bring them to justice without arousing any suspicions.", "goal": "MGOAL_ASSASSINATE", "difficulty": 5, "value": 50000, @@ -158,7 +160,8 @@ { "id": "MISSION_OLD_GUARD_REP_3", "type": "mission_definition", - "name": "Kill ???", + "name": "Secure Trade Route", + "description": "One of the Free Merchants silently disappeared while escorting a trade caravan. Whoever or whatever is responsible must be quick and quiet - investigate the trade route and eliminate the threat.", "goal": "MGOAL_KILL_MONSTER", "difficulty": 5, "value": 100000, @@ -188,7 +191,8 @@ { "id": "MISSION_OLD_GUARD_REP_4", "type": "mission_definition", - "name": "Kill Raider Leader", + "name": "Assassinate Raider Leader", + "description": "The Old Guard have located a Hell's Raiders encampment that is coordinating attacks on the Free Merchants. Pay them a visit and execute the area leadership.", "goal": "MGOAL_ASSASSINATE", "difficulty": 10, "value": 300000, From 58280010a09c2ced16f75e8f947e49616c73369f Mon Sep 17 00:00:00 2001 From: John Candlebury Date: Sat, 17 Aug 2019 21:52:54 -0600 Subject: [PATCH 044/113] Update hub 01 missions with descriptions fix some minor mistakes --- data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json b/data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json index 92b93ddd0d40a..aa5204cb0e126 100644 --- a/data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json +++ b/data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json @@ -42,6 +42,7 @@ "id": "MISSION_ROBOFAC_INTERCOM_1", "type": "mission_definition", "name": "Return Field Data", + "description": "Investigate a nearby field and return with Dr. Prado and the robot prototype she was testing. Failing that, retrieve the I/O recorder stored within the robot. If the robot remains operational, avoid direct confrontation and use EMP grenades to disable it.", "goal": "MGOAL_FIND_ITEM", "difficulty": 5, "item": "robofac_test_data", @@ -106,6 +107,7 @@ "id": "MISSION_ROBOFAC_INTERCOM_2", "type": "mission_definition", "name": "Steal a dead man's mind", + "description": "Find the corpse of a Hub 01's AI researcher and use the mind splicer kit to recover the memories stored inside their memory implant.", "goal": "MGOAL_FIND_ITEM", "difficulty": 5, "item": "mind_scan_robofac", @@ -122,13 +124,14 @@ "om_special": "hub_01", "place_nested": [ { "chunks": [ "robofac_hq_surface_freemerchant_camp" ], "x": 4, "y": 0 } ] } - ] + ], + "effect": [ { "u_buy_item": "RobofacCoin", "count": 2 } ] }, "origins": [ "ORIGIN_SECONDARY" ], "dialogue": { "describe": "...", "offer": "When the portal storms started, the Government issued an evacuation order for critical XEDRA personnel and sent convoys to retrieve them, with our head of AI research among the recalled. We recently discovered that he died when the convoy transferring him was ambushed in the initial chaos, but his corpse and memory bionic might remain intact enough for us to extract valuable knowledge. We want you to travel to the location, make a copy of his Bionic Memory Unit, and return it to us.", - "accepted": "Remember, do extraction /exactly/ as specified, otherwise the bionic will self-destruct.", + "accepted": "Remember, perform the extraction /exactly/ as specified, otherwise the bionic will self-destruct.", "rejected": "Yes, we recognize that our request is exceptional. Return if you change your mind.", "advice": " You do know what a memory unit looks like, right? Matte gray, pill-sized, right in front of the corpus callosum. We suggest a forceps through the eye socket, shaking slightly, then slowly and carefully...", "inquire": "Do you have the scan?", From 9ddf9d3b7a01cb2cea99c7564ec74989b0ebd722 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Sun, 18 Aug 2019 04:03:45 +0000 Subject: [PATCH 045/113] Fix comparator for creature faction tracker --- src/creature_tracker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/creature_tracker.h b/src/creature_tracker.h index 4f69905418d45..9a5fc0d4c5f40 100644 --- a/src/creature_tracker.h +++ b/src/creature_tracker.h @@ -24,7 +24,7 @@ class Creature_tracker { public: bool operator()( const std::weak_ptr &lhs, const std::weak_ptr &rhs ) const { - return lhs.lock().get() == rhs.lock().get(); + return lhs.lock().get() < rhs.lock().get(); } }; From 2a45e46721985894fbb75bac1182fcff236eca27 Mon Sep 17 00:00:00 2001 From: RedShakespeare Date: Sun, 18 Aug 2019 15:02:20 +0800 Subject: [PATCH 046/113] Fix metagenic serum consuming bug metagenic serum now needs syringe to consume again. --- data/json/items/comestibles/mutagen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/comestibles/mutagen.json b/data/json/items/comestibles/mutagen.json index d28fd3a4866ea..da690db84932e 100644 --- a/data/json/items/comestibles/mutagen.json +++ b/data/json/items/comestibles/mutagen.json @@ -38,7 +38,7 @@ "stim": -5, "addiction_potential": 6, "container": "test_tube", - "tools_needed": "syringe", + "tool": "syringe", "flags": [ "NO_INGEST" ] }, { From b88de8803d346681a1d9d4e3b7b9e45f93d063d1 Mon Sep 17 00:00:00 2001 From: RedShakespeare Date: Sun, 18 Aug 2019 15:16:49 +0800 Subject: [PATCH 047/113] Adds new mon flag MECH_DEFENSIVE Add a new optional flag to create fully-protective mechbots. --- doc/JSON_FLAGS.md | 1 + src/creature.cpp | 25 +++++++++++++++++-------- src/monstergenerator.cpp | 1 + src/mtype.h | 1 + 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/doc/JSON_FLAGS.md b/doc/JSON_FLAGS.md index 31e131016b43b..793825579cb15 100644 --- a/doc/JSON_FLAGS.md +++ b/doc/JSON_FLAGS.md @@ -909,6 +909,7 @@ Multiple death functions can be used. Not all combinations make sense. - ```LEATHER``` May produce leather when butchered. - ```LOUDMOVES``` Mkes move noises as if ~2 sizes louder, even if flying. - ```MECH_RECON_VISION``` This mech grants you night-vision and enhanced overmap sight radius when piloted. +- ```MECH_DEFENSIVE``` This mech can protect you thoroughly when piloted. - ```MILITARY_MECH``` Is a military-grade mech. - ```MILKABLE``` Produces milk when milked. - ```NIGHT_INVISIBILITY``` Monster becomes invisible if it's more than one tile away and the lighting on its tile is LL_LOW or less. Visibility is not affected by night vision. diff --git a/src/creature.cpp b/src/creature.cpp index 8cdd92008f948..f27671fa93e6a 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -487,11 +487,15 @@ void Creature::deal_melee_hit( Creature *source, int hit_spread, bool critical_h } // If carrying a rider, there is a chance the hits may hit rider instead. if( has_effect( effect_ridden ) ) { - // big mounts and small player = big shield for player. - if( one_in( std::max( 2, get_size() - g->u.get_size() ) ) ) { - g->u.deal_melee_hit( source, hit_spread, critical_hit, dam, dealt_dam ); - return; + if( !has_flag( MF_MECH_DEFENSIVE ) ) { + // If carrying a rider, there is a chance the hits may hit rider instead. + // big mounts and small player = big shield for player. + if( one_in( std::max( 2, get_size() - g->u.get_size() ) ) ) { + g->u.deal_melee_hit( source, hit_spread, critical_hit, dam, dealt_dam ); + return; + } } + //otherwise it would thoroughly protect the rider(or pilot actually) } damage_instance d = dam; // copy, since we will mutate in block_hit body_part bp_hit = select_body_part( source, hit_spread ); @@ -548,11 +552,16 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack } // If carrying a rider, there is a chance the hits may hit rider instead. if( has_effect( effect_ridden ) ) { - // big mounts and small player = big shield for player. - if( one_in( std::max( 2, get_size() - g->u.get_size() ) ) ) { - g->u.deal_projectile_attack( source, attack, print_messages ); - return; + if( !has_flag( MF_MECH_DEFENSIVE ) ) { + // If carrying a rider, there is a chance the hits may hit rider instead. + // big mounts and small player = big shield for player. + if( one_in( std::max( 2, get_size() - g->u.get_size() ) ) ) { + g->u.deal_projectile_attack( source, attack, print_messages ); + return; + } } + //otherwise it would thoroughly protect the rider(or pilot actually) + } const projectile &proj = attack.proj; dealt_damage_instance &dealt_dam = attack.dealt_dam; diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index 068f344c2e753..d425f22fe9e2c 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -98,6 +98,7 @@ const std::map flag_map = { { "RIDEABLE_MECH", MF_RIDEABLE_MECH }, { "MILITARY_MECH", MF_MILITARY_MECH }, { "MECH_RECON_VISION", MF_MECH_RECON_VISION }, + { "MECH_DEFENSIVE", MF_MECH_DEFENSIVE }, { "HIT_AND_RUN", MF_HIT_AND_RUN }, { "GUILT", MF_GUILT }, { "HUMAN", MF_HUMAN }, diff --git a/src/mtype.h b/src/mtype.h index fa3f43812e197..491b978eefbe9 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -110,6 +110,7 @@ enum m_flag : int { MF_RIDEABLE_MECH, // A rideable mech that is immobile until ridden. MF_MILITARY_MECH, // A rideable mech that was designed for military work. MF_MECH_RECON_VISION, // This mech gives you IR night-vision. + MF_MECH_DEFENSIVE, //This mech gives you thorough protection. MF_HIT_AND_RUN, // Flee for several turns after a melee attack MF_GUILT, // You feel guilty for killing it MF_HUMAN, // It's a live human, as long as it's alive From 4e0e9757baac5a1828e7abbac2a786aefbc017a2 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 18 Aug 2019 09:55:34 +0200 Subject: [PATCH 048/113] ignore weight of included bionic --- src/character.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/character.cpp b/src/character.cpp index 7e589d14e7d0a..15b14be415a3c 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -3380,7 +3380,9 @@ units::mass Character::bionics_weight() const { units::mass bio_weight = 0_gram; for( const auto bio : *my_bionics ) { - bio_weight += item::find_type( bio.id.c_str() )->weight; + if( !bio.info().included ) { + bio_weight += item::find_type( bio.id.c_str() )->weight; + } } return bio_weight; } From 3ff93600cc53f44f14a02cdb1903e7136d6284aa Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 18 Aug 2019 10:06:12 +0200 Subject: [PATCH 049/113] add ingredient to tiny motor --- data/json/recipes/recipe_electronics.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/json/recipes/recipe_electronics.json b/data/json/recipes/recipe_electronics.json index 8c68639dff3f7..9bc10cacb5606 100644 --- a/data/json/recipes/recipe_electronics.json +++ b/data/json/recipes/recipe_electronics.json @@ -1922,9 +1922,9 @@ "reversible": true, "decomp_learn": 2, "book_learn": [ [ "manual_electronics", 2 ], [ "mag_electronics", 2 ], [ "manual_mechanics", 2 ] ], - "using": [ [ "soldering_standard", 5 ] ], + "using": [ [ "soldering_standard", 5 ], [ "steel_standard", 5 ] ], "qualities": [ { "id": "HAMMER", "level": 1 }, { "id": "SCREW_FINE", "level": 1 } ], - "components": [ [ [ "plastic_chunk", 1 ] ], [ [ "scrap", 3 ] ], [ [ "cable", 3 ] ] ] + "components": [ [ [ "plastic_chunk", 1 ] ], [ [ "cable", 3 ] ], [ [ "e_scrap", 5 ] ] ] }, { "type": "recipe", From 7ec35173dd20891761d76f1f7a0964229d540d48 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sun, 18 Aug 2019 05:41:54 -0400 Subject: [PATCH 050/113] Cleanup integer division changes (#33317) * Remove redundant parentheses * Use float division when assigning to float This is a follow-up to changes in #32983 and #33209. --- src/activity_handlers.cpp | 2 +- src/game.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 47a6a094180af..67f70e09d18ce 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -868,7 +868,7 @@ static void butchery_drops_harvest( item *corpse_item, const mtype &mt, player & roll *= roll_drops(); monster_weight_remaining -= roll; roll = ceil( static_cast( roll ) / - to_gram( ( item::find_type( entry.drop ) )->weight ) ); + to_gram( item::find_type( entry.drop )->weight ) ); } else { monster_weight_remaining -= roll * to_gram( ( item::find_type( entry.drop ) )->weight ); } diff --git a/src/game.cpp b/src/game.cpp index 237cb2f8e7a44..0cc82daa4a1d8 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -9051,7 +9051,7 @@ bool game::walk_move( const tripoint &dest_loc ) return false; } const double base_moves = u.run_cost( mcost, diag ) * 100.0 / crit->get_speed(); - const double encumb_moves = u.get_weight() / 4800_gram; + const double encumb_moves = u.get_weight() / 4800.0_gram; u.moves -= static_cast( ceil( base_moves + encumb_moves ) ); if( u.movement_mode_is( PMM_WALK ) ) { crit->use_mech_power( -2 ); From ad6f05f671b2fbb67d2205065ee1e61bef84d69a Mon Sep 17 00:00:00 2001 From: Fris0uman <41293484+Fris0uman@users.noreply.github.com> Date: Sun, 18 Aug 2019 11:42:21 +0200 Subject: [PATCH 051/113] Can't start empty autoclave/dishwasher/washing machine (#33332) * can't start empty autoclave * fix text * can't start empty dishwasher or emty washing machine --- src/map.cpp | 2 +- src/vehicle_use.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/map.cpp b/src/map.cpp index bfc81092c813a..eb0fb09b6960a 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -4516,7 +4516,7 @@ static void process_vehicle_items( vehicle &cur_veh, int part ) } } if( autoclave_finished ) { - add_msg( _( "The autoclave in the %s has finished washing." ), cur_veh.name ); + add_msg( _( "The autoclave in the %s has finished its cycle." ), cur_veh.name ); } } diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 2a0e4644aba79..581ef5a557884 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -1370,6 +1370,9 @@ void vehicle::use_autoclave( int p ) parts[p].enabled = false; add_msg( m_bad, _( "You turn the autoclave off before it's finished the program, and open its door." ) ); + } else if( items.empty() ) { + add_msg( m_bad, + _( "The autoclave is empty, there's no point in starting it." ) ); } else if( fuel_left( "water" ) < 8 && fuel_left( "water_clean" ) < 8 ) { add_msg( m_bad, _( "You need 8 charges of water in tanks of the %s for the autoclave to run." ), name ); @@ -1413,6 +1416,9 @@ void vehicle::use_washing_machine( int p ) parts[p].enabled = false; add_msg( m_bad, _( "You turn the washing machine off before it's finished the program, and open its lid." ) ); + } else if( items.empty() ) { + add_msg( m_bad, + _( "The washing machine is empty, there's no point in starting it." ) ); } else if( fuel_left( "water" ) < 24 && fuel_left( "water_clean" ) < 24 ) { add_msg( m_bad, _( "You need 24 charges of water in tanks of the %s to fill the washing machine." ), name ); @@ -1468,6 +1474,9 @@ void vehicle::use_dishwasher( int p ) parts[p].enabled = false; add_msg( m_bad, _( "You turn the dishwasher off before it's finished the program, and open its lid." ) ); + } else if( items.empty() ) { + add_msg( m_bad, + _( "The dishwasher is empty, there's no point in starting it." ) ); } else if( fuel_left( "water" ) < 24 && fuel_left( "water_clean" ) < 24 ) { add_msg( m_bad, _( "You need 24 charges of water in tanks of the %s to fill the dishwasher." ), name ); From e1c35dec1380540fde9fcc2e065d6a8408b71b67 Mon Sep 17 00:00:00 2001 From: Red Shakespeare <44523519+RedShakespeare@users.noreply.github.com> Date: Sun, 18 Aug 2019 19:31:17 +0800 Subject: [PATCH 052/113] Update src/mtype.h Astyle Co-Authored-By: nshcat --- src/mtype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mtype.h b/src/mtype.h index 491b978eefbe9..002184b4f5c5a 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -110,7 +110,7 @@ enum m_flag : int { MF_RIDEABLE_MECH, // A rideable mech that is immobile until ridden. MF_MILITARY_MECH, // A rideable mech that was designed for military work. MF_MECH_RECON_VISION, // This mech gives you IR night-vision. - MF_MECH_DEFENSIVE, //This mech gives you thorough protection. + MF_MECH_DEFENSIVE, // This mech gives you thorough protection. MF_HIT_AND_RUN, // Flee for several turns after a melee attack MF_GUILT, // You feel guilty for killing it MF_HUMAN, // It's a live human, as long as it's alive From 3e3bd924a5c31b77a658461e6deb473034579cb6 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 13:03:17 +0200 Subject: [PATCH 053/113] Remove include of "auto_pick.h" from "npc.h". --- src/condition.cpp | 1 + src/npc.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/condition.cpp b/src/condition.cpp index fadfebba30598..48a3522453045 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -15,6 +15,7 @@ #include "game.h" #include "item_category.h" #include "item.h" +#include "auto_pickup.h" #include "json.h" #include "map.h" #include "mission.h" diff --git a/src/npc.h b/src/npc.h index 2968a85ca16b4..d82ba77ba51b2 100644 --- a/src/npc.h +++ b/src/npc.h @@ -19,7 +19,6 @@ #include "optional.h" #include "pimpl.h" #include "player.h" -#include "auto_pickup.h" #include "color.h" #include "creature.h" #include "cursesdef.h" @@ -34,6 +33,7 @@ #include "item.h" #include "point.h" +class auto_pickup; struct bionic_data; class JsonObject; class JsonIn; From 281c63910fce69178fc42025d4814211b93a26a9 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sat, 17 Aug 2019 23:54:08 +0200 Subject: [PATCH 054/113] Default constructor of auto_pickup::cRules --- src/auto_pickup.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 289553b978ab3..e9a5d62461afd 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -35,13 +35,10 @@ class auto_pickup { public: std::string sRule; - bool bActive; - bool bExclude; + bool bActive = false; + bool bExclude = false; - cRules() { - this->bActive = false; - this->bExclude = false; - } + cRules() = default; cRules( const std::string &sRuleIn, bool bActiveIn, bool bExcludeIn ) { this->sRule = sRuleIn; From 4bb7913e775dc44f2a4809c89906c8ae015326e9 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 00:03:29 +0200 Subject: [PATCH 055/113] Distribute (de)serialization of auto_pickup rules into several types. --- src/auto_pickup.cpp | 59 ++++++++++++++++++++++++++++----------------- src/auto_pickup.h | 14 +++++++++-- 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 33c6c033f8d51..1e341695e5739 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -717,40 +717,55 @@ void auto_pickup::load( const bool bCharacter ) ready = false; } -void auto_pickup::serialize( JsonOut &json ) const +void auto_pickup::cRules::serialize( JsonOut &jsout ) const { - json.start_array(); - - for( auto &elem : vRules[bChar ? CHARACTER_TAB : GLOBAL_TAB] ) { - json.start_object(); - - json.member( "rule", elem.sRule ); - json.member( "active", elem.bActive ); - json.member( "exclude", elem.bExclude ); + jsout.start_object(); + jsout.member( "rule", sRule ); + jsout.member( "active", bActive ); + jsout.member( "exclude", bExclude ); + jsout.end_object(); +} - json.end_object(); +void auto_pickup::rules_list::serialize( JsonOut &jsout ) const +{ + jsout.start_array(); + for( const cRules &elem : *this ) { + elem.serialize( jsout ); } + jsout.end_array(); +} - json.end_array(); +void auto_pickup::serialize( JsonOut &jsout ) const +{ + vRules[bChar ? CHARACTER_TAB : GLOBAL_TAB].serialize( jsout ); } -void auto_pickup::deserialize( JsonIn &jsin ) +void auto_pickup::cRules::deserialize( JsonIn &jsin ) { - vRules[bChar ? CHARACTER_TAB : GLOBAL_TAB].clear(); - ready = false; + JsonObject jo = jsin.get_object(); + sRule = jo.get_string( "rule" ); + bActive = jo.get_bool( "active" ); + bExclude = jo.get_bool( "exclude" ); +} + +void auto_pickup::rules_list::deserialize( JsonIn &jsin ) +{ + clear(); jsin.start_array(); while( !jsin.end_array() ) { - JsonObject jo = jsin.get_object(); - - const std::string sRule = jo.get_string( "rule" ); - const bool bActive = jo.get_bool( "active" ); - const bool bExclude = jo.get_bool( "exclude" ); - - vRules[bChar ? CHARACTER_TAB : GLOBAL_TAB].push_back( cRules( sRule, bActive, bExclude ) ); + cRules tmp; + tmp.deserialize( jsin ); + push_back( tmp ); } } +void auto_pickup::deserialize( JsonIn &jsin ) +{ + ready = false; + vRules[bChar ? CHARACTER_TAB : GLOBAL_TAB].deserialize( jsin ); +} + bool auto_pickup::load_legacy( const bool bCharacter ) { std::string sFile = FILENAMES["legacy_autopickup2"]; @@ -774,7 +789,7 @@ bool auto_pickup::load_legacy( const bool bCharacter ) return true; } -void auto_pickup::load_legacy_rules( std::vector &rules, std::istream &fin ) +void auto_pickup::load_legacy_rules( rules_list &rules, std::istream &fin ) { rules.clear(); ready = false; diff --git a/src/auto_pickup.h b/src/auto_pickup.h index e9a5d62461afd..1fa30e964324c 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -45,6 +45,16 @@ class auto_pickup this->bActive = bActiveIn; this->bExclude = bExcludeIn; } + + void serialize( JsonOut &json ) const; + void deserialize( JsonIn &jsin ); + }; + + class rules_list : public std::vector + { + public: + void serialize( JsonOut &json ) const; + void deserialize( JsonIn &jsin ); }; mutable bool ready; //< true if map_items has been populated from vRules @@ -61,9 +71,9 @@ class auto_pickup * - vRules[0,1] aka vRules[GLOBAL,CHARACTER]: current rules split into global and * character-specific. Allows the editor to show one or the other. */ - std::array, MAX_TAB> vRules; + std::array vRules; - void load_legacy_rules( std::vector &rules, std::istream &fin ); + void load_legacy_rules( rules_list &rules, std::istream &fin ); void refresh_map_items() const; //< Only modifies mutable state From 9c0108dfc4cfceaeffef776da96ab1e2248e6220 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Wed, 31 Jul 2019 18:48:18 +0200 Subject: [PATCH 056/113] Change mtype::baby_timer and monster::baby_time to optional time classes. `mtype::baby_timer` is the offset between babies (so it's a `time_duration`), and `monster::baby_timer` is the time point when to create a new baby. Changes monster::try_reproduce heavily: Add the check for `type->baby_timer` at the top, so it's only done once and we can ignore the remaining stuff altogether. Remove `current_day` and use `calendar::turn` (current time) instead. Make setting `baby_timer` simpler: just one simple calculation. --- src/monster.cpp | 33 ++++++++++++++------------------- src/monster.h | 2 +- src/monstergenerator.cpp | 11 ++++++++--- src/mtype.cpp | 1 - src/mtype.h | 3 ++- src/savegame_json.cpp | 6 +++++- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index 20607e294ed69..9f1a32ddf2d07 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -208,7 +208,6 @@ monster::monster() upgrades = false; upgrade_time = -1; last_updated = 0; - baby_timer = -1; last_baby = 0; biosig_timer = -1; last_biosig = 0; @@ -400,14 +399,14 @@ void monster::try_reproduce() if( !reproduces ) { return; } + // This can happen if the monster type has changed (from reproducing to non-reproducing monster) + if( !type->baby_timer ) { + return; + } - const int current_day = to_days( calendar::turn - calendar::start_of_cataclysm ); - if( baby_timer < 0 ) { - baby_timer = type->baby_timer; - if( baby_timer < 0 ) { - return; - } - baby_timer += current_day; + if( !baby_timer ) { + // Assume this is a freshly spawned monster (because baby_timer is not set yet), set the point when it reproduce to somewhere in the future. + baby_timer.emplace( calendar::turn + *type->baby_timer ); } bool season_spawn = false; @@ -424,21 +423,17 @@ void monster::try_reproduce() // add a decreasing chance of additional spawns when "catching up" an existing animal int chance = -1; while( true ) { - if( baby_timer > current_day ) { - return; - } - const int next_baby = type->baby_timer; - if( next_baby < 0 ) { + if( *baby_timer > calendar::turn ) { return; } if( season_spawn ) { season_match = false; for( auto &elem : type->baby_flags ) { - if( ( season_of_year( DAYS( baby_timer ) ) == SUMMER && elem == "SUMMER" ) || - ( season_of_year( DAYS( baby_timer ) ) == WINTER && elem == "WINTER" ) || - ( season_of_year( DAYS( baby_timer ) ) == SPRING && elem == "SPRING" ) || - ( season_of_year( DAYS( baby_timer ) ) == AUTUMN && elem == "AUTUMN" ) ) { + if( ( season_of_year( *baby_timer ) == SUMMER && elem == "SUMMER" ) || + ( season_of_year( *baby_timer ) == WINTER && elem == "WINTER" ) || + ( season_of_year( *baby_timer ) == SPRING && elem == "SPRING" ) || + ( season_of_year( *baby_timer ) == AUTUMN && elem == "AUTUMN" ) ) { season_match = true; } } @@ -450,11 +445,11 @@ void monster::try_reproduce() if( type->baby_monster ) { g->m.add_spawn( type->baby_monster, spawn_cnt, pos().xy() ); } else { - g->m.add_item_or_charges( pos(), item( type->baby_egg, DAYS( baby_timer ), spawn_cnt ), true ); + g->m.add_item_or_charges( pos(), item( type->baby_egg, *baby_timer, spawn_cnt ), true ); } } - baby_timer += next_baby; + *baby_timer += *type->baby_timer; } } diff --git a/src/monster.h b/src/monster.h index 597272fc65319..3d1bd4051d9c7 100644 --- a/src/monster.h +++ b/src/monster.h @@ -511,7 +511,7 @@ class monster : public Creature bool upgrades; int upgrade_time; bool reproduces; - int baby_timer; + cata::optional baby_timer; bool biosignatures; int biosig_timer; monster_horde_attraction horde_attraction; diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index 068f344c2e753..ac7a6520dbcc0 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -743,7 +743,12 @@ void mtype::load( JsonObject &jo, const std::string &src ) if( jo.has_member( "reproduction" ) ) { JsonObject repro = jo.get_object( "reproduction" ); optional( repro, was_loaded, "baby_count", baby_count, -1 ); - optional( repro, was_loaded, "baby_timer", baby_timer, -1 ); + if( repro.has_int( "baby_timer" ) ) { + baby_timer = time_duration::from_days( repro.get_int( "baby_timer" ) ); + } else if( repro.has_string( "baby_timer" ) ) { + baby_timer = read_from_json_string( *repro.get_raw( "baby_timer" ), + time_duration::units ); + } optional( repro, was_loaded, "baby_monster", baby_monster, auto_flags_reader {}, mtype_id::NULL_ID() ); optional( repro, was_loaded, "baby_egg", baby_egg, auto_flags_reader {}, @@ -1085,9 +1090,9 @@ void MonsterGenerator::check_monster_definitions() const } if( mon.reproduces ) { - if( mon.baby_timer < 1 ) { + if( !mon.baby_timer || *mon.baby_timer <= 0_seconds ) { debugmsg( "Time between reproductions (%d) is invalid for %s", - mon.baby_timer, mon.id.c_str() ); + mon.baby_timer ? to_turns( *mon.baby_timer ) : -1, mon.id.c_str() ); } if( mon.baby_count < 1 ) { debugmsg( "Number of children (%d) is invalid for %s", diff --git a/src/mtype.cpp b/src/mtype.cpp index bbdfe62beb98d..964a31671e7ce 100644 --- a/src/mtype.cpp +++ b/src/mtype.cpp @@ -34,7 +34,6 @@ mtype::mtype() upgrade_group = mongroup_id::NULL_ID(); reproduces = false; - baby_timer = -1; baby_count = -1; baby_monster = mtype_id::NULL_ID(); baby_egg = "null"; diff --git a/src/mtype.h b/src/mtype.h index fa3f43812e197..38758e157ef25 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -8,6 +8,7 @@ #include #include "color.h" +#include "optional.h" #include "damage.h" #include "enum_bitset.h" #include "enums.h" @@ -292,7 +293,7 @@ struct mtype { mtype_id burn_into; // Monster reproduction variables - int baby_timer; + cata::optional baby_timer; int baby_count; mtype_id baby_monster; itype_id baby_egg; diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 926fff66d7b97..f95bcb7543a9f 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1807,7 +1807,11 @@ void monster::load( JsonObject &data ) upgrade_time = data.get_int( "upgrade_time", -1 ); reproduces = data.get_bool( "reproduces", type->reproduces ); - baby_timer = data.get_int( "baby_timer", -1 ); + baby_timer.reset(); + data.read( "baby_timer", baby_timer ); + if( baby_timer && *baby_timer == calendar::before_time_starts ) { + baby_timer.reset(); + } biosignatures = data.get_bool( "biosignatures", type->biosignatures ); biosig_timer = data.get_int( "biosig_timer", -1 ); From 679d039bbf4f6004fd76afed75b217f4ba470318 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Wed, 31 Jul 2019 18:48:35 +0200 Subject: [PATCH 057/113] Move (de)serialization of cata::optional into json.h --- src/json.h | 22 ++++++++++++++++++++++ src/savegame_json.cpp | 21 --------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/json.h b/src/json.h index 0beb81cd68c73..ab9fca2cff67b 100644 --- a/src/json.h +++ b/src/json.h @@ -14,6 +14,7 @@ #include #include "colony.h" +#include "optional.h" /* Cataclysm-DDA homegrown JSON tools * copyright CC-BY-SA-3.0 2013 CleverRaven @@ -1063,4 +1064,25 @@ class JsonDeserializer std::ostream &operator<<( std::ostream &stream, const JsonError &err ); +template +void serialize( const cata::optional &obj, JsonOut &jsout ) +{ + if( obj ) { + jsout.write( *obj ); + } else { + jsout.write_null(); + } +} + +template +void deserialize( cata::optional &obj, JsonIn &jsin ) +{ + if( jsin.test_null() ) { + obj.reset(); + } else { + obj.emplace(); + jsin.read( *obj ); + } +} + #endif diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index f95bcb7543a9f..3ca5ffa2a6632 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -148,27 +148,6 @@ static void deserialize( std::weak_ptr &obj, JsonIn &jsin ) // } } -template -void serialize( const cata::optional &obj, JsonOut &jsout ) -{ - if( obj ) { - jsout.write( *obj ); - } else { - jsout.write_null(); - } -} - -template -void deserialize( cata::optional &obj, JsonIn &jsin ) -{ - if( jsin.test_null() ) { - obj.reset(); - } else { - obj.emplace(); - jsin.read( *obj ); - } -} - std::vector item::magazine_convert() { std::vector res; From b5402383547c401b26cdac801263ea55ef33e0e5 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 28 Jul 2019 14:36:14 +0200 Subject: [PATCH 058/113] Change mtype::biosig_timer to time_duration --- src/monster.cpp | 22 ++++++++-------------- src/monster.h | 2 +- src/monstergenerator.cpp | 13 ++++++++++--- src/mtype.cpp | 1 - src/mtype.h | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index 9f1a32ddf2d07..cbcc4351849a6 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -458,27 +458,21 @@ void monster::try_biosignature() if( !biosignatures ) { return; } + if( !type->biosig_timer ) { + return; + } - const int current_day = to_days( calendar::turn - calendar::start_of_cataclysm ); - if( biosig_timer < 0 ) { - biosig_timer = type->biosig_timer; - if( biosig_timer < 0 ) { - return; - } - biosig_timer += current_day; + if( !biosig_timer ) { + biosig_timer.emplace( calendar::turn + *type->biosig_timer ); } while( true ) { - if( biosig_timer > current_day ) { + if( *biosig_timer > calendar::turn ) { return; } - g->m.add_item_or_charges( pos(), item( type->biosig_item, DAYS( biosig_timer ), 1 ), true ); - const int next_biosig = type->biosig_timer; - if( next_biosig < 0 ) { - return; - } - biosig_timer += next_biosig; + g->m.add_item_or_charges( pos(), item( type->biosig_item, *biosig_timer, 1 ), true ); + *biosig_timer += *type->biosig_timer; } } diff --git a/src/monster.h b/src/monster.h index 3d1bd4051d9c7..edd78fa557c9d 100644 --- a/src/monster.h +++ b/src/monster.h @@ -513,7 +513,7 @@ class monster : public Creature bool reproduces; cata::optional baby_timer; bool biosignatures; - int biosig_timer; + cata::optional biosig_timer; monster_horde_attraction horde_attraction; /** Found path. Note: Not used by monsters that don't pathfind! **/ std::vector path; diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index ac7a6520dbcc0..363a0f5d7f4d7 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -767,7 +767,14 @@ void mtype::load( JsonObject &jo, const std::string &src ) if( jo.has_member( "biosignature" ) ) { JsonObject biosig = jo.get_object( "biosignature" ); - optional( biosig, was_loaded, "biosig_timer", biosig_timer, -1 ); + if( biosig.has_int( "biosig_timer" ) ) { + biosig_timer = time_duration::from_days( biosig.get_int( "biosig_timer" ) ); + } else if( biosig.has_string( "biosig_timer" ) ) { + biosig_timer = read_from_json_string( *biosig.get_raw( "biosig_timer" ), + time_duration::units ); + } + + optional( biosig, was_loaded, "biosig_item", biosig_item, auto_flags_reader {}, "null" ); biosignatures = true; @@ -1115,9 +1122,9 @@ void MonsterGenerator::check_monster_definitions() const } if( mon.biosignatures ) { - if( mon.biosig_timer < 1 ) { + if( !mon.biosig_timer || *mon.biosig_timer <= 0_seconds ) { debugmsg( "Time between biosignature drops (%d) is invalid for %s", - mon.biosig_timer, mon.id.c_str() ); + mon.biosig_timer ? to_turns( *mon.biosig_timer ) : -1, mon.id.c_str() ); } if( mon.biosig_item == "null" ) { debugmsg( "No biosignature drop defined for monster %s", mon.id.c_str() ); diff --git a/src/mtype.cpp b/src/mtype.cpp index 964a31671e7ce..0047f39b82737 100644 --- a/src/mtype.cpp +++ b/src/mtype.cpp @@ -39,7 +39,6 @@ mtype::mtype() baby_egg = "null"; biosignatures = false; - biosig_timer = -1; biosig_item = "null"; burn_into = mtype_id::NULL_ID(); diff --git a/src/mtype.h b/src/mtype.h index 38758e157ef25..f9fbe6e9da007 100644 --- a/src/mtype.h +++ b/src/mtype.h @@ -300,7 +300,7 @@ struct mtype { std::vector baby_flags; // Monster biosignature variables - int biosig_timer; + cata::optional biosig_timer; itype_id biosig_item; // Monster's ability to destroy terrain and vehicles From d8e47f0eb60edb89e029d7c485476453714d3a64 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Wed, 31 Jul 2019 20:48:43 +0200 Subject: [PATCH 059/113] Change vehicle::power_to_energy_bat to take time_duration --- src/vehicle.cpp | 15 +++++++-------- src/vehicle.h | 2 +- src/vehicle_display.cpp | 2 +- src/vehicle_use.cpp | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 269590dd6b404..56f16901267b7 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -895,10 +895,10 @@ int vehicle::part_epower_w( const int index ) const return e * parts[ index ].health_percent(); } -int vehicle::power_to_energy_bat( const int power_w, const int t_seconds ) const +int vehicle::power_to_energy_bat( const int power_w, const time_duration &d ) const { // Integrate constant epower (watts) over time to get units of battery energy - int energy_j = power_w * t_seconds; + int energy_j = power_w * to_seconds( d ); int energy_bat = energy_j / bat_energy_j; int sign = power_w >= 0 ? 1 : -1; // energy_bat remainder results in chance at additional charge/discharge @@ -4143,7 +4143,7 @@ void vehicle::power_parts() int epower = total_epower_w( engine_epower ); bool reactor_online = false; - int delta_energy_bat = power_to_energy_bat( epower, to_turns( 1_turns ) ); + int delta_energy_bat = power_to_energy_bat( epower, 1_turns ); int storage_deficit_bat = std::max( 0, fuel_capacity( fuel_type_battery ) - fuel_left( fuel_type_battery ) - delta_energy_bat ); if( !reactors.empty() && storage_deficit_bat > 0 ) { @@ -4158,8 +4158,7 @@ void vehicle::power_parts() // Keep track whether or not the vehicle has any reactors activated reactor_online = true; // the amount of energy the reactor generates each turn - const int gen_energy_bat = power_to_energy_bat( part_epower_w( elem ), - to_turns( 1_turns ) ); + const int gen_energy_bat = power_to_energy_bat( part_epower_w( elem ), 1_turns ); if( parts[ elem ].is_unavailable() ) { continue; } else if( parts[ elem ].info().has_flag( "PERPETUAL" ) ) { @@ -5741,7 +5740,7 @@ void vehicle::update_time( const time_point &update_to ) epower_w += part_epower_w( part ); } double intensity = accum_weather.sunlight / DAYLIGHT_LEVEL / to_turns( elapsed ); - int energy_bat = power_to_energy_bat( epower_w * intensity, to_turns( elapsed ) ); + int energy_bat = power_to_energy_bat( epower_w * intensity, elapsed ); if( energy_bat > 0 ) { add_msg( m_debug, "%s got %d kJ energy from solar panels", name, energy_bat ); charge_battery( energy_bat ); @@ -5767,7 +5766,7 @@ void vehicle::update_time( const time_point &update_to ) } epower_w += part_epower_w( part ) * windpower; } - int energy_bat = power_to_energy_bat( epower_w, to_turns( elapsed ) ); + int energy_bat = power_to_energy_bat( epower_w, elapsed ); if( energy_bat > 0 ) { add_msg( m_debug, "%s got %d kJ energy from wind turbines", name, energy_bat ); charge_battery( energy_bat ); @@ -5787,7 +5786,7 @@ void vehicle::update_time( const time_point &update_to ) epower_w += part_epower_w( part ); } // TODO: river current intensity changes power - flat for now. - int energy_bat = power_to_energy_bat( epower_w, to_turns( elapsed ) ); + int energy_bat = power_to_energy_bat( epower_w, elapsed ); if( energy_bat > 0 ) { add_msg( m_debug, "%s got %d kJ energy from water wheels", name, energy_bat ); charge_battery( energy_bat ); diff --git a/src/vehicle.h b/src/vehicle.h index b276a2b34a85f..741699ab90210 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -622,7 +622,7 @@ class vehicle int part_epower_w( int index ) const; // convert watts over time to battery energy - int power_to_energy_bat( int power_w, int t_seconds ) const; + int power_to_energy_bat( int power_w, const time_duration &d ) const; // convert vhp to watts. static int vhp_to_watts( int power ); diff --git a/src/vehicle_display.cpp b/src/vehicle_display.cpp index e74e6ef257ef6..9c5883772370d 100644 --- a/src/vehicle_display.cpp +++ b/src/vehicle_display.cpp @@ -422,7 +422,7 @@ void vehicle::print_fuel_indicator( const catacurses::window &win, int y, int x, units = _( "mL" ); } if( fuel_type == itype_id( "battery" ) ) { - rate += power_to_energy_bat( total_epower_w() + total_reactor_epower_w(), 3600 ); + rate += power_to_energy_bat( total_epower_w() + total_reactor_epower_w(), 1_hours ); units = _( "kJ" ); } if( rate != 0 ) { diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 581ef5a557884..8b6bfae613252 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -882,7 +882,7 @@ bool vehicle::start_engine( const int e ) } const int start_draw_bat = power_to_energy_bat( engine_power * ( 1.0 + dmg / 2 + cold_factor / 5 ) * 10, - TICKS_TO_SECONDS( start_moves ) ); + time_duration::from_seconds( TICKS_TO_SECONDS( start_moves ) ) ); if( discharge_battery( start_draw_bat, true ) != 0 ) { sounds::sound( pos, eng.info().engine_noise_factor(), sounds::sound_t::alarm, string_format( _( "the %s rapidly clicking" ), eng.name() ), true, "vehicle", From 4d1972b50cb28039a1f1fcc6643a3ea9bea93d71 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 28 Jul 2019 14:36:54 +0200 Subject: [PATCH 060/113] Remove DAYS function --- src/calendar.h | 11 ----------- tests/vision_test.cpp | 9 ++++----- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/calendar.h b/src/calendar.h index def656d33ca38..59aab4c5a61ed 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -35,17 +35,6 @@ constexpr int HOURS( int n ) return n * MINUTES( 60 ); } -/** - * Convert days to one-second turns - * - * @param n Time in days - * @returns Time in one-second turns - */ -constexpr int DAYS( int n ) -{ - return n * HOURS( 24 ); -} - /** * Convert ticks to seconds. * diff --git a/tests/vision_test.cpp b/tests/vision_test.cpp index 76bdf493ab9d2..dd479a75355c6 100644 --- a/tests/vision_test.cpp +++ b/tests/vision_test.cpp @@ -460,11 +460,9 @@ TEST_CASE( "vision_wall_can_be_lit_by_player", "[shadowcasting][vision]" ) TEST_CASE( "vision_see_wall_in_moonlight", "[shadowcasting][vision]" ) { - const time_duration till_full_moon = calendar::season_length() / 3; + const time_point full_moon = calendar::turn_zero + calendar::season_length() / 3; // Verify that I've picked the full_moon time correctly. - CHECK( get_moon_phase( calendar::turn_zero + till_full_moon ) == MOON_FULL ); - // Want a night time - const int days_till_full_moon = to_days( till_full_moon ); + CHECK( get_moon_phase( full_moon ) == MOON_FULL ); vision_test_case t { { @@ -481,7 +479,8 @@ TEST_CASE( "vision_see_wall_in_moonlight", "[shadowcasting][vision]" ) "111", "111", }, - DAYS( days_till_full_moon ), + // Want a night time + full_moon - time_past_midnight( full_moon ), true }; From 581534329e6150159913822add74ed86e52a8a06 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 28 Jul 2019 17:25:28 +0200 Subject: [PATCH 061/113] Remove HOURS function --- src/addiction.cpp | 2 +- src/calendar.h | 11 ----------- src/character.cpp | 6 ++++-- src/defense.cpp | 2 +- src/game.cpp | 6 +++--- src/monster.cpp | 4 ++-- src/player.cpp | 6 +++--- src/tutorial.cpp | 2 +- src/weather.cpp | 2 +- tests/crafting_test.cpp | 6 +++--- tests/npc_test.cpp | 2 +- 11 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/addiction.cpp b/src/addiction.cpp index 394ca7efb48e5..b81f35df1e704 100644 --- a/src/addiction.cpp +++ b/src/addiction.cpp @@ -69,7 +69,7 @@ void addict_effect( player &u, addiction &add ) u.mod_per_bonus( -1 ); u.mod_int_bonus( -1 ); - if( x_in_y( in, HOURS( 2 ) ) ) { + if( x_in_y( in, to_turns( 2_hours ) ) ) { u.mod_healthy_mod( -1, -in * 10 ); } if( one_in( 20 ) && rng( 0, 20 ) < in ) { diff --git a/src/calendar.h b/src/calendar.h index 59aab4c5a61ed..3f3b515b97e98 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -24,17 +24,6 @@ constexpr int MINUTES( int n ) return n * 60; } -/** - * Convert hours to one-second turns - * - * @param n Time in hours - * @returns Time in one-second turns - */ -constexpr int HOURS( int n ) -{ - return n * MINUTES( 60 ); -} - /** * Convert ticks to seconds. * diff --git a/src/character.cpp b/src/character.cpp index 15b14be415a3c..2c203ead63a4b 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -3257,7 +3257,8 @@ float Character::healing_rate_medicine( float at_rest_quality, const body_part b const effect &e_disinfected = get_effect( effect_disinfected, bp ); if( !e_bandaged.is_null() ) { - bandaged_rate += static_cast( e_bandaged.get_amount( "HEAL_RATE" ) ) / HOURS( 24 ); + bandaged_rate += static_cast( e_bandaged.get_amount( "HEAL_RATE" ) ) / to_turns + ( 24_hours ); if( bp == bp_head ) { bandaged_rate *= e_bandaged.get_amount( "HEAL_HEAD" ) / 100.0f; } @@ -3267,7 +3268,8 @@ float Character::healing_rate_medicine( float at_rest_quality, const body_part b } if( !e_disinfected.is_null() ) { - disinfected_rate += static_cast( e_disinfected.get_amount( "HEAL_RATE" ) ) / HOURS( 24 ); + disinfected_rate += static_cast( e_disinfected.get_amount( "HEAL_RATE" ) ) / to_turns + ( 24_hours ); if( bp == bp_head ) { disinfected_rate *= e_disinfected.get_amount( "HEAL_HEAD" ) / 100.0f; } diff --git a/src/defense.cpp b/src/defense.cpp index 7278c85a347a8..b6874ca0ac2e1 100644 --- a/src/defense.cpp +++ b/src/defense.cpp @@ -88,7 +88,7 @@ defense_game::defense_game() bool defense_game::init() { - calendar::turn = HOURS( 12 ); // Start at noon + calendar::turn = calendar::turn_zero + 12_hours; // Start at noon g->weather.temperature = 65; if( !g->u.create( PLTYPE_CUSTOM ) ) { return false; diff --git a/src/game.cpp b/src/game.cpp index 0cc82daa4a1d8..d8ae091ce16f4 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -11534,9 +11534,9 @@ void game::start_calendar() scen->has_flag( "SUM_ADV_START" ); if( scen_season ) { - // Configured starting date overridden by scenario, calendar::start_of_cataclysm is left as Spring 1 - calendar::start_of_cataclysm = HOURS( get_option( "INITIAL_TIME" ) ); - calendar::turn = HOURS( get_option( "INITIAL_TIME" ) ); + // Configured starting date overridden by scenario, calendar::start is left as Spring 1 + calendar::start_of_cataclysm = calendar::turn_zero + 1_hours * get_option( "INITIAL_TIME" ); + calendar::turn = calendar::turn_zero + 1_hours * get_option( "INITIAL_TIME" ); if( scen->has_flag( "SPR_START" ) ) { calendar::initial_season = SPRING; } else if( scen->has_flag( "SUM_START" ) ) { diff --git a/src/monster.cpp b/src/monster.cpp index cbcc4351849a6..7801aa7127019 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -2720,10 +2720,10 @@ void monster::on_load() } else if( has_flag( MF_REGENERATES_10 ) ) { regen = 10.0f; } else if( has_flag( MF_REVIVES ) ) { - regen = 1.0f / HOURS( 1 ); + regen = 1.0f / to_turns( 1_hours ); } else if( made_of( material_id( "flesh" ) ) || made_of( material_id( "veggy" ) ) ) { // Most living stuff here - regen = 0.25f / HOURS( 1 ); + regen = 0.25f / to_turns( 1_hours ); } const int heal_amount = roll_remainder( regen * to_turns( dt ) ); diff --git a/src/player.cpp b/src/player.cpp index 42e819a425446..0b0f939402a0e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -5651,7 +5651,7 @@ void player::suffer() // Spread less radiation when sleeping (slower metabolism etc.) // Otherwise it can quickly get to the point where you simply can't sleep at all const bool rad_mut_proc = rad_mut > 0 && - x_in_y( rad_mut, in_sleep_state() ? HOURS( 3 ) : MINUTES( 30 ) ); + x_in_y( rad_mut, to_turns( in_sleep_state() ? 3_hours : 30_minutes ) ); bool has_helmet = false; const bool power_armored = is_wearing_power_armor( &has_helmet ); @@ -6441,7 +6441,7 @@ void player::update_body_wetness( const w_point &weather ) { // Average number of turns to go from completely soaked to fully dry // assuming average temperature and humidity - constexpr int average_drying = HOURS( 2 ); + constexpr time_duration average_drying = 2_hours; // A modifier on drying time double delay = 1.0; @@ -6458,7 +6458,7 @@ void player::update_body_wetness( const w_point &weather ) delay *= 1.5; } - if( !x_in_y( 1, average_drying / 100.0 * delay ) ) { + if( !x_in_y( 1, to_turns( average_drying * delay / 100.0 ) ) ) { // No drying this turn return; } diff --git a/src/tutorial.cpp b/src/tutorial.cpp index 06fbc777050e1..4f45b4328b215 100644 --- a/src/tutorial.cpp +++ b/src/tutorial.cpp @@ -41,7 +41,7 @@ bool tutorial_game::init() { // TODO: clean up old tutorial - calendar::turn = HOURS( 12 ); // Start at noon + calendar::turn = calendar::turn_zero + 12_hours; // Start at noon for( auto &elem : tutorials_seen ) { elem = false; } diff --git a/src/weather.cpp b/src/weather.cpp index 1143b2f3af01a..b963681807fa1 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -268,7 +268,7 @@ double funnel_charges_per_turn( const double surface_area_mm2, const double rain water.charges; const double vol_mm3_per_hour = surface_area_mm2 * rain_depth_mm_per_hour; - const double vol_mm3_per_turn = vol_mm3_per_hour / HOURS( 1 ); + const double vol_mm3_per_turn = vol_mm3_per_hour / to_turns( 1_hours ); const double ml_to_mm3 = 1000; const double charges_per_turn = vol_mm3_per_turn / ( charge_ml * ml_to_mm3 ); diff --git a/tests/crafting_test.cpp b/tests/crafting_test.cpp index 729fc78c7a2ab..a6ebf06ccb916 100644 --- a/tests/crafting_test.cpp +++ b/tests/crafting_test.cpp @@ -280,10 +280,10 @@ static void prep_craft( const recipe_id &rid, const std::vector &tools, CHECK( can_craft == expect_craftable ); } -static constexpr int midnight = HOURS( 0 ); -static constexpr int midday = HOURS( 12 ); +static time_point midnight = calendar::turn_zero + 0_hours; +static time_point midday = calendar::turn_zero + 12_hours; -static void set_time( int time ) +static void set_time( const time_point &time ) { calendar::turn = time; g->reset_light_level(); diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index ec59a3b7b7e4c..7c704ce3c828a 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -429,7 +429,7 @@ TEST_CASE( "npc-movement" ) TEST_CASE( "npc_can_target_player" ) { // Set to daytime for visibiliity - calendar::turn = HOURS( 12 ); + calendar::turn = calendar::turn_zero + 12_hours; g->faction_manager_ptr->create_if_needed(); From 6ed304c1d47f8fd7820b428b273afb382414bd51 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 28 Jul 2019 17:29:32 +0200 Subject: [PATCH 062/113] Remove MINUTES function --- src/calendar.h | 12 ------------ src/player.cpp | 11 ++++++----- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/calendar.h b/src/calendar.h index 3f3b515b97e98..cc81e886a84ac 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -12,18 +12,6 @@ class time_point; class JsonOut; class JsonIn; -/** - * Convert minutes to one-second turns - * - * @param n Time in minutes - * @returns Time in one-second turns - * - */ -constexpr int MINUTES( int n ) -{ - return n * 60; -} - /** * Convert ticks to seconds. * diff --git a/src/player.cpp b/src/player.cpp index 0b0f939402a0e..48a98f222979e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1103,8 +1103,8 @@ void player::update_bodytemp() // Spread the morale bonus in time. if( comfortable_warmth > 0 && // @todo make this simpler and use time_duration/time_point - to_turn( calendar::turn ) % to_turns( 1_minutes ) == ( MINUTES( bp ) / MINUTES( - num_bp ) ) && + to_turn( calendar::turn ) % to_turns( 1_minutes ) == to_turns + ( 1_minutes * bp ) / to_turns( 1_minutes * num_bp ) && get_effect_int( effect_cold, num_bp ) == 0 && get_effect_int( effect_hot, num_bp ) == 0 && temp_cur[bp] > BODYTEMP_COLD && temp_cur[bp] <= BODYTEMP_NORM ) { @@ -3681,7 +3681,8 @@ void player::update_body( const time_point &from, const time_point &to ) update_needs( five_mins ); regen( five_mins ); // Note: mend ticks once per 5 minutes, but wants rate in TURNS, not 5 minute intervals - mend( five_mins * MINUTES( 5 ) ); + //@todo change @ref med to take time_duration + mend( five_mins * to_turns( 5_minutes ) ); } if( ticks_between( from, to, 24_hours ) > 0 ) { enforce_minimum_healing(); @@ -4275,7 +4276,7 @@ void player::regen( int rate_multiplier ) } float rest = rest_quality(); - float heal_rate = healing_rate( rest ) * MINUTES( 5 ); + float heal_rate = healing_rate( rest ) * to_turns( 5_minutes ); if( heal_rate > 0.0f ) { healall( roll_remainder( rate_multiplier * heal_rate ) ); } else if( heal_rate < 0.0f ) { @@ -4289,7 +4290,7 @@ void player::regen( int rate_multiplier ) // include healing effects for( int i = 0; i < num_hp_parts; i++ ) { body_part bp = hp_to_bp( static_cast( i ) ); - float healing = healing_rate_medicine( rest, bp ) * MINUTES( 5 ) ; + float healing = healing_rate_medicine( rest, bp ) * to_turns( 5_minutes ); int healing_apply = roll_remainder( healing ); healed_bp( i, healing_apply ); From 24f6c00d02eacb3ab000e93bcedc5f9a860dfa98 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Wed, 31 Jul 2019 20:50:43 +0200 Subject: [PATCH 063/113] Remove TICKS_TO_SECONDS function --- src/calendar.h | 11 ----------- src/vehicle_use.cpp | 3 ++- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/calendar.h b/src/calendar.h index cc81e886a84ac..b75e724efa797 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -12,17 +12,6 @@ class time_point; class JsonOut; class JsonIn; -/** - * Convert ticks to seconds. - * - * @param ticks number of ticks - * @returns Time in seconds - */ -constexpr int TICKS_TO_SECONDS( int ticks ) -{ - return static_cast( static_cast( ticks ) / 100 ); -} - /** How much light moon provides per lit-up quarter (Full-moon light is four times this value) */ #define MOONLIGHT_PER_QUARTER 2.25 diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 8b6bfae613252..313fcf4fb4124 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -880,9 +880,10 @@ bool vehicle::start_engine( const int e ) "engine_single_click_fail" ); return false; } + // @todo start_moves is in moves, but it's an integer, convert it to some time class const int start_draw_bat = power_to_energy_bat( engine_power * ( 1.0 + dmg / 2 + cold_factor / 5 ) * 10, - time_duration::from_seconds( TICKS_TO_SECONDS( start_moves ) ) ); + 1_turns * start_moves / 100 ); if( discharge_battery( start_draw_bat, true ) != 0 ) { sounds::sound( pos, eng.info().engine_noise_factor(), sounds::sound_t::alarm, string_format( _( "the %s rapidly clicking" ), eng.name() ), true, "vehicle", From ab9b9ec51aa8b59f2a5fca34e3b3944849fb8ddb Mon Sep 17 00:00:00 2001 From: BevapDin Date: Fri, 16 Aug 2019 22:12:44 +0200 Subject: [PATCH 064/113] Convert macro MOONLIGHT_PER_QUARTER into local constant. --- src/calendar.cpp | 5 ++++- src/calendar.h | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calendar.cpp b/src/calendar.cpp index 0c2675c750c1c..e079cfe061fca 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp @@ -10,6 +10,9 @@ #include "string_formatter.h" #include "translations.h" +/** How much light moon provides per lit-up quarter (Full-moon light is four times this value) */ +static constexpr double moonlight_per_quarter = 2.25; + // Divided by 100 to prevent overflowing when converted to moves const int calendar::INDEFINITELY_LONG( std::numeric_limits::max() / 100 ); const time_duration calendar::INDEFINITELY_LONG_DURATION( @@ -164,7 +167,7 @@ float sunlight( const time_point &p ) current_phase = static_cast( MOON_PHASE_MAX ) - current_phase; } - const int moonlight = 1 + static_cast( current_phase * MOONLIGHT_PER_QUARTER ); + const int moonlight = 1 + static_cast( current_phase * moonlight_per_quarter ); if( now > sunset + twilight_duration || now < sunrise ) { // Night return moonlight; diff --git a/src/calendar.h b/src/calendar.h index b75e724efa797..df4f944216cf3 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -12,9 +12,6 @@ class time_point; class JsonOut; class JsonIn; -/** How much light moon provides per lit-up quarter (Full-moon light is four times this value) */ -#define MOONLIGHT_PER_QUARTER 2.25 - /** How much light is provided in full daylight */ #define DAYLIGHT_LEVEL 100 From 67e6a1c97612ecc26d9125ad48db47e6bf901d09 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Fri, 16 Aug 2019 22:18:46 +0200 Subject: [PATCH 065/113] Convert SUNRISE_* and SUNSET_* macros to constants --- src/calendar.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/calendar.cpp b/src/calendar.cpp index e079cfe061fca..f256daeaceebf 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp @@ -31,22 +31,22 @@ season_type calendar::initial_season = SPRING; // Times for sunrise, sunset at equinoxes /** Hour of sunrise at winter solstice */ -#define SUNRISE_WINTER 7 - -/** Hour of sunrise at fall and spring equinox */ -#define SUNRISE_EQUINOX 6 +static constexpr int sunrise_winter = 7; /** Hour of sunrise at summer solstice */ -#define SUNRISE_SUMMER 5 +static constexpr int sunrise_summer = 5; -/** Hour of sunset at winter solstice */ -#define SUNSET_WINTER 17 +/** Hour of sunrise at fall and spring equinox */ +static constexpr int sunrise_equinox = ( sunrise_summer + sunrise_winter ) / 2; -/** Hour of sunset at fall and spring equinox */ -#define SUNSET_EQUINOX 19 +/** Hour of sunset at winter solstice */ +static constexpr int sunset_winter = 17; /** Hour of sunset at summer solstice */ -#define SUNSET_SUMMER 21 +static constexpr int sunset_summer = 21; + +/** Hour of sunset at fall and spring equinox */ +static constexpr int sunset_equinox = ( sunset_summer + sunset_winter ) / 2; // How long, does sunrise/sunset last? static const time_duration twilight_duration = 1_hours; @@ -68,7 +68,7 @@ time_point sunrise( const time_point &p ) static_assert( static_cast( SPRING ) == 0, "Expected spring to be the first season. If not, code below will use wrong index into array" ); - static const std::array start_hours = { { SUNRISE_EQUINOX, SUNRISE_SUMMER, SUNRISE_EQUINOX, SUNRISE_WINTER, } }; + static const std::array start_hours = { { sunrise_equinox, sunrise_summer, sunrise_equinox, sunrise_winter, } }; const size_t season = static_cast( season_of_year( p ) ); assert( season < start_hours.size() ); @@ -88,7 +88,7 @@ time_point sunset( const time_point &p ) static_assert( static_cast( SPRING ) == 0, "Expected spring to be the first season. If not, code below will use wrong index into array" ); - static const std::array start_hours = { { SUNSET_EQUINOX, SUNSET_SUMMER, SUNSET_EQUINOX, SUNSET_WINTER } }; + static const std::array start_hours = { { sunset_equinox, sunset_summer, sunset_equinox, sunset_winter, } }; const size_t season = static_cast( season_of_year( p ) ); assert( season < start_hours.size() ); From 95e81ad2b515a328e521193fb699659ee5693eb1 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Fri, 16 Aug 2019 22:31:22 +0200 Subject: [PATCH 066/113] Remove DAYLIGHT_LEVEL macro: Use the current daylight level instead (where appropriate). And use the same value returned by a new function for the remaining code. --- src/calendar.cpp | 7 ++++++- src/calendar.h | 5 ++--- src/creature.cpp | 2 +- src/editmap.cpp | 3 ++- src/game.cpp | 6 +++--- src/monster.cpp | 5 +++-- src/player.cpp | 5 +++-- src/vehicle.cpp | 2 +- src/weather_data.cpp | 3 ++- 9 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/calendar.cpp b/src/calendar.cpp index f256daeaceebf..b146de76b7ee9 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp @@ -51,6 +51,11 @@ static constexpr int sunset_equinox = ( sunset_summer + sunset_winter ) / 2; // How long, does sunrise/sunset last? static const time_duration twilight_duration = 1_hours; +double default_daylight_level() +{ + return 100.0; +} + moon_phase get_moon_phase( const time_point &p ) { //One full phase every 2 rl months = 2/3 season length @@ -151,7 +156,7 @@ double current_daylight_level( const time_point &p ) break; } - return double( modifier * DAYLIGHT_LEVEL ); + return modifier * default_daylight_level(); } float sunlight( const time_point &p ) diff --git a/src/calendar.h b/src/calendar.h index df4f944216cf3..54f39bfe9cf26 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -12,9 +12,6 @@ class time_point; class JsonOut; class JsonIn; -/** How much light is provided in full daylight */ -#define DAYLIGHT_LEVEL 100 - /** Real world seasons */ enum season_type { SPRING = 0, @@ -540,6 +537,8 @@ bool is_sunset_now( const time_point &p ); bool is_sunrise_now( const time_point &p ); /** Returns the current seasonally-adjusted maximum daylight level */ double current_daylight_level( const time_point &p ); +/** How much light is provided in full daylight */ +double default_daylight_level(); /** Returns the current sunlight or moonlight level through the preceding functions. */ float sunlight( const time_point &p ); diff --git a/src/creature.cpp b/src/creature.cpp index 8cdd92008f948..8371bd127eb75 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -251,7 +251,7 @@ bool Creature::sees( const tripoint &t, bool is_player, int range_mod ) const } const int range_cur = sight_range( g->m.ambient_light_at( t ) ); - const int range_day = sight_range( DAYLIGHT_LEVEL ); + const int range_day = sight_range( current_daylight_level( calendar::turn ) ); const int range_night = sight_range( 0 ); const int range_max = std::max( range_day, range_night ); const int range_min = std::min( range_cur, range_max ); diff --git a/src/editmap.cpp b/src/editmap.cpp index d192e70f8c5d5..05c4770d25692 100644 --- a/src/editmap.cpp +++ b/src/editmap.cpp @@ -604,7 +604,8 @@ void editmap::update_view( bool update_info ) rl_dist( g->u.pos(), target ), static_cast( g->u.sees( target ) ), veh_in, g->scent.get( target ) ); mvwprintw( w_info, point( 1, off++ ), _( "sight_range: %d, daylight_sight_range: %d," ), - g->u.sight_range( g->light_level( g->u.posz() ) ), g->u.sight_range( DAYLIGHT_LEVEL ) ); + g->u.sight_range( g->light_level( g->u.posz() ) ), + g->u.sight_range( current_daylight_level( calendar::turn ) ) ); mvwprintw( w_info, point( 1, off++ ), _( "transparency: %.5f, visibility: %.5f," ), map_cache.transparency_cache[target.x][target.y], map_cache.seen_cache[target.x][target.y] ); diff --git a/src/game.cpp b/src/game.cpp index d8ae091ce16f4..2fbe7ea523041 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3701,7 +3701,7 @@ float game::natural_light_level( const int zlev ) const ret = sunlight( calendar::turn ); } else { // Recent lightning strike has lit the area - ret = DAYLIGHT_LEVEL; + ret = default_daylight_level(); } ret += weather::light_modifier( weather.weather ); @@ -3725,7 +3725,7 @@ float game::natural_light_level( const int zlev ) const } if( timed_events.queued( TIMED_EVENT_ARTIFACT_LIGHT ) ) { // TIMED_EVENT_ARTIFACT_LIGHT causes everywhere to become as bright as day. - mod_ret = std::max( ret, DAYLIGHT_LEVEL ); + mod_ret = std::max( ret, default_daylight_level() ); } // If we had a changed light level due to an artifact event then it overwrites // the natural light level. @@ -7145,7 +7145,7 @@ void game::reset_item_list_state( const catacurses::window &window, int height, void game::list_items_monsters() { - std::vector mons = u.get_visible_creatures( DAYLIGHT_LEVEL ); + std::vector mons = u.get_visible_creatures( current_daylight_level( calendar::turn ) ); ///\EFFECT_PER increases range of interacting with items on the ground from a list const std::vector items = find_nearby_items( 2 * u.per_cur + 12 ); diff --git a/src/monster.cpp b/src/monster.cpp index 7801aa7127019..e603b21f7a191 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -821,8 +821,9 @@ int monster::sight_range( const int light_level ) const return 1; } - int range = light_level * type->vision_day + ( DAYLIGHT_LEVEL - light_level ) * type->vision_night; - range /= DAYLIGHT_LEVEL; + int range = light_level * type->vision_day + ( default_daylight_level() - light_level ) * + type->vision_night; + range /= default_daylight_level(); return range; } diff --git a/src/player.cpp b/src/player.cpp index 48a98f222979e..8c7aa93124a9b 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -11522,10 +11522,11 @@ bool player::sees_with_infrared( const Creature &critter ) const if( is_player() || critter.is_player() ) { // Players should not use map::sees // Likewise, players should not be "looked at" with map::sees, not to break symmetry - return g->m.pl_line_of_sight( critter.pos(), sight_range( DAYLIGHT_LEVEL ) ); + return g->m.pl_line_of_sight( critter.pos(), + sight_range( current_daylight_level( calendar::turn ) ) ); } - return g->m.sees( pos(), critter.pos(), sight_range( DAYLIGHT_LEVEL ) ); + return g->m.sees( pos(), critter.pos(), sight_range( current_daylight_level( calendar::turn ) ) ); } std::vector player::get_overlay_ids() const diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 56f16901267b7..4c27b5fc142a6 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -5739,7 +5739,7 @@ void vehicle::update_time( const time_point &update_to ) epower_w += part_epower_w( part ); } - double intensity = accum_weather.sunlight / DAYLIGHT_LEVEL / to_turns( elapsed ); + double intensity = accum_weather.sunlight / default_daylight_level() / to_turns( elapsed ); int energy_bat = power_to_energy_bat( epower_w * intensity, elapsed ); if( energy_bat > 0 ) { add_msg( m_debug, "%s got %d kJ energy from solar panels", name, energy_bat ); diff --git a/src/weather_data.cpp b/src/weather_data.cpp index 17144fdddba9c..d11afa00843f5 100644 --- a/src/weather_data.cpp +++ b/src/weather_data.cpp @@ -44,8 +44,9 @@ static weather_result weather_data_internal( weather_type const type ) * Weather types data definition. * Name, color in UI, color and glyph on map, ranged penalty, sight penalty, * light modifier, sound attenuation, warn player? - * Note light modifier assumes baseline of DAYLIGHT_LEVEL at 60 + * Note light modifier assumes baseline of default_daylight_level() at 60 */ + // @todo but it actually isn't 60, it's 100. Fix this comment or fix the value static const std::array data {{ weather_datum { "NULL Weather - BUG (weather_data.cpp:weather_data)", c_magenta, c_magenta_red, From 752c548c1c7f7b3d0d09a3f21440a13154dfd9c3 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 00:30:17 +0200 Subject: [PATCH 067/113] Split auto_pickup::vRules into two separate members. --- src/auto_pickup.cpp | 220 +++++++++++++++++++++++--------------------- src/auto_pickup.h | 23 +++-- 2 files changed, 125 insertions(+), 118 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 1e341695e5739..af440a328e2fb 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -41,7 +41,14 @@ void auto_pickup::show() void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) { - auto vRulesOld = vRules; + const auto old_global_rules = global_rules; + const auto old_character_rules = character_rules; + + enum : int { + GLOBAL_TAB, + CHARACTER_TAB, + MAX_TAB + }; const int iHeaderHeight = 4; const int iContentHeight = FULL_SCREEN_HEIGHT - 2 - iHeaderHeight; @@ -138,6 +145,7 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) std::ostringstream sTemp; while( true ) { + rules_list &cur_rules = iTab == GLOBAL_TAB ? global_rules : character_rules; int locx = 17; locx += shortcut_print( w_header, point( locx, 2 ), c_white, iTab == GLOBAL_TAB ? hilite( c_white ) : c_white, _( "[]" ) ) + 1; @@ -166,27 +174,25 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } } - const bool currentPageNonEmpty = !vRules[iTab].empty(); + const bool currentPageNonEmpty = !cur_rules.empty(); if( iTab == CHARACTER_TAB && g->u.name.empty() ) { - vRules[CHARACTER_TAB].clear(); + cur_rules.clear(); mvwprintz( w, point( 15, 8 ), c_white, _( "Please load a character first to use this page!" ) ); } - draw_scrollbar( w_border, iLine, iContentHeight, - vRules[iTab].size(), 5 ); + draw_scrollbar( w_border, iLine, iContentHeight, cur_rules.size(), 5 ); wrefresh( w_border ); - calcStartPos( iStartPos, iLine, iContentHeight, - vRules[iTab].size() ); + calcStartPos( iStartPos, iLine, iContentHeight, cur_rules.size() ); // display auto pickup - for( int i = iStartPos; i < static_cast( vRules[iTab].size() ); i++ ) { + for( int i = iStartPos; i < static_cast( cur_rules.size() ); i++ ) { if( i >= iStartPos && - i < iStartPos + ( iContentHeight > static_cast( vRules[iTab].size() ) ? - static_cast( vRules[iTab].size() ) : iContentHeight ) ) { - nc_color cLineColor = vRules[iTab][i].bActive ? c_white : c_light_gray; + i < iStartPos + ( iContentHeight > static_cast( cur_rules.size() ) ? + static_cast( cur_rules.size() ) : iContentHeight ) ) { + nc_color cLineColor = cur_rules[i].bActive ? c_white : c_light_gray; sTemp.str( "" ); sTemp << i + 1; @@ -200,11 +206,11 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } wprintz( w, iLine == i && iColumn == 1 ? hilite( cLineColor ) : cLineColor, "%s", - vRules[iTab][i].sRule.empty() ? _( "" ) : vRules[iTab][i].sRule ); + cur_rules[i].sRule.empty() ? _( "" ) : cur_rules[i].sRule ); mvwprintz( w, point( 52, i - iStartPos ), iLine == i && iColumn == 2 ? hilite( cLineColor ) : cLineColor, "%s", - vRules[iTab][i].bExclude ? _( "Exclude" ) : _( "Include" ) ); + cur_rules[i].bExclude ? _( "Exclude" ) : _( "Include" ) ); } } @@ -231,19 +237,19 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } else if( action == "DOWN" ) { iLine++; iColumn = 1; - if( iLine >= static_cast( vRules[iTab].size() ) ) { + if( iLine >= static_cast( cur_rules.size() ) ) { iLine = 0; } } else if( action == "UP" ) { iLine--; iColumn = 1; if( iLine < 0 ) { - iLine = vRules[iTab].size() - 1; + iLine = cur_rules.size() - 1; } } else if( action == "REMOVE_RULE" && currentPageNonEmpty ) { bStuffChanged = true; - vRules[iTab].erase( vRules[iTab].begin() + iLine ); - if( iLine > static_cast( vRules[iTab].size() ) - 1 ) { + cur_rules.erase( cur_rules.begin() + iLine ); + if( iLine > static_cast( cur_rules.size() ) - 1 ) { iLine--; } if( iLine < 0 ) { @@ -251,30 +257,25 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } } else if( action == "COPY_RULE" && currentPageNonEmpty ) { bStuffChanged = true; - vRules[iTab].push_back( cRules( - vRules[iTab][iLine].sRule, - vRules[iTab][iLine].bActive, - vRules[iTab][iLine].bExclude ) ); - iLine = vRules[iTab].size() - 1; + cur_rules.push_back( cur_rules[iLine] ); + iLine = cur_rules.size() - 1; } else if( action == "SWAP_RULE_GLOBAL_CHAR" && currentPageNonEmpty ) { if( ( iTab == GLOBAL_TAB && !g->u.name.empty() ) || iTab == CHARACTER_TAB ) { + rules_list &other_rules = iTab == CHARACTER_TAB ? global_rules : character_rules; bStuffChanged = true; //copy over - vRules[iTab == GLOBAL_TAB ? CHARACTER_TAB : GLOBAL_TAB].push_back( cRules( - vRules[iTab][iLine].sRule, - vRules[iTab][iLine].bActive, - vRules[iTab][iLine].bExclude ) ); + other_rules.push_back( cur_rules[iLine] ); //remove old - vRules[iTab].erase( vRules[iTab].begin() + iLine ); - iLine = vRules[iTab == GLOBAL_TAB ? CHARACTER_TAB : GLOBAL_TAB].size() - 1; + cur_rules.erase( cur_rules.begin() + iLine ); + iLine = other_rules.size() - 1; iTab = iTab == GLOBAL_TAB ? CHARACTER_TAB : GLOBAL_TAB; } } else if( action == "ADD_RULE" || ( action == "CONFIRM" && currentPageNonEmpty ) ) { const int old_iLine = iLine; if( action == "ADD_RULE" ) { - vRules[iTab].push_back( cRules( "", true, false ) ); - iLine = vRules[iTab].size() - 1; + cur_rules.push_back( cRules( "", true, false ) ); + iLine = cur_rules.size() - 1; } if( iColumn == 1 || action == "ADD_RULE" ) { @@ -300,28 +301,28 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) const std::string r = string_input_popup() .title( _( "Pickup Rule:" ) ) .width( 30 ) - .text( vRules[iTab][iLine].sRule ) + .text( cur_rules[iLine].sRule ) .query_string(); // If r is empty, then either (1) The player ESC'ed from the window (changed their mind), or // (2) Explicitly entered an empty rule- which isn't allowed since "*" should be used // to include/exclude everything if( !r.empty() ) { - vRules[iTab][iLine].sRule = wildcard_trim_rule( r ); + cur_rules[iLine].sRule = wildcard_trim_rule( r ); bStuffChanged = true; } else if( action == "ADD_RULE" ) { - vRules[iTab].pop_back(); + cur_rules.pop_back(); iLine = old_iLine; } } else if( iColumn == 2 ) { bStuffChanged = true; - vRules[iTab][iLine].bExclude = !vRules[iTab][iLine].bExclude; + cur_rules[iLine].bExclude = !cur_rules[iLine].bExclude; } } else if( action == "ENABLE_RULE" && currentPageNonEmpty ) { bStuffChanged = true; - vRules[iTab][iLine].bActive = true; + cur_rules[iLine].bActive = true; } else if( action == "DISABLE_RULE" && currentPageNonEmpty ) { bStuffChanged = true; - vRules[iTab][iLine].bActive = false; + cur_rules[iLine].bActive = false; } else if( action == "LEFT" ) { iColumn--; if( iColumn < 1 ) { @@ -334,22 +335,20 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } } else if( action == "MOVE_RULE_UP" && currentPageNonEmpty ) { bStuffChanged = true; - if( iLine < static_cast( vRules[iTab].size() ) - 1 ) { - std::swap( vRules[iTab][iLine], - vRules[iTab][iLine + 1] ); + if( iLine < static_cast( cur_rules.size() ) - 1 ) { + std::swap( cur_rules[iLine], cur_rules[iLine + 1] ); iLine++; iColumn = 1; } } else if( action == "MOVE_RULE_DOWN" && currentPageNonEmpty ) { bStuffChanged = true; if( iLine > 0 ) { - std::swap( vRules[iTab][iLine], - vRules[iTab][iLine - 1] ); + std::swap( cur_rules[iLine], cur_rules[iLine - 1] ); iLine--; iColumn = 1; } } else if( action == "TEST_RULE" && currentPageNonEmpty && !g->u.name.empty() ) { - test_pattern( iTab, iLine ); + test_pattern( cur_rules, iLine ); } else if( action == "SWITCH_AUTO_PICKUP_OPTION" ) { // TODO: Now that NPCs use this function, it could be used for them too get_options().get_option( "AUTO_PICKUP" ).setNext(); @@ -374,15 +373,16 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) ready = false; } else { - vRules = vRulesOld; + global_rules = old_global_rules; + character_rules = old_character_rules; } } -void auto_pickup::test_pattern( const int iTab, const int iRow ) +void auto_pickup::test_pattern( const rules_list &rules, const int iRow ) { std::vector vMatchingItems; - if( vRules[iTab][iRow].sRule.empty() ) { + if( rules[iRow].sRule.empty() ) { return; } @@ -390,8 +390,8 @@ void auto_pickup::test_pattern( const int iTab, const int iRow ) //APU now ignores prefixes, bottled items and suffix combinations still not generated for( const itype *e : item_controller->all() ) { const std::string sItemName = e->nname( 1 ); - if( !check_special_rule( e->materials, vRules[iTab][iRow].sRule ) && - !wildcard_match( sItemName, vRules[iTab][iRow].sRule ) ) { + if( !check_special_rule( e->materials, rules[iRow].sRule ) && + !wildcard_match( sItemName, rules[iRow].sRule ) ) { continue; } @@ -416,7 +416,7 @@ void auto_pickup::test_pattern( const int iTab, const int iRow ) int nmatch = vMatchingItems.size(); const std::string buf = string_format( ngettext( "%1$d item matches: %2$s", "%1$d items match: %2$s", - nmatch ), nmatch, vRules[iTab][iRow].sRule ); + nmatch ), nmatch, rules[iRow].sRule ); draw_border( w_test_rule_border, BORDER_COLOR, buf, hilite( c_white ) ); center_print( w_test_rule_border, iContentHeight + 1, red_background( c_white ), _( "Won't display content or suffix matches" ) ); @@ -482,7 +482,7 @@ void auto_pickup::test_pattern( const int iTab, const int iRow ) bool auto_pickup::has_rule( const item *it ) { const std::string &name = it->tname( 1 ); - for( auto &elem : vRules[CHARACTER_TAB] ) { + for( auto &elem : character_rules ) { if( name.length() == elem.sRule.length() && ci_find_substr( name, elem.sRule ) != -1 ) { return true; } @@ -492,7 +492,7 @@ bool auto_pickup::has_rule( const item *it ) void auto_pickup::add_rule( const item *it ) { - vRules[CHARACTER_TAB].push_back( cRules( it->tname( 1, false ), true, false ) ); + character_rules.push_back( cRules( it->tname( 1, false ), true, false ) ); create_rule( it ); if( !get_option( "AUTO_PICKUP" ) && @@ -505,11 +505,11 @@ void auto_pickup::add_rule( const item *it ) void auto_pickup::remove_rule( const item *it ) { const std::string sRule = it->tname( 1, false ); - for( auto it = vRules[CHARACTER_TAB].begin(); - it != vRules[CHARACTER_TAB].end(); ++it ) { + for( auto it = character_rules.begin(); + it != character_rules.end(); ++it ) { if( sRule.length() == it->sRule.length() && ci_find_substr( sRule, it->sRule ) != -1 ) { - vRules[CHARACTER_TAB].erase( it ); + character_rules.erase( it ); ready = false; break; } @@ -518,13 +518,7 @@ void auto_pickup::remove_rule( const item *it ) bool auto_pickup::empty() const { - for( int i = GLOBAL_TAB; i < MAX_TAB; i++ ) { - if( !vRules[i].empty() ) { - return false; - } - } - - return true; + return global_rules.empty() && character_rules.empty(); } bool auto_pickup::check_special_rule( const std::vector &materials, @@ -562,32 +556,41 @@ bool auto_pickup::check_special_rule( const std::vector &materials, //Special case. Required for NPC harvest autopickup. Ignores material rules. void auto_pickup::create_rule( const std::string &to_match ) { - for( int i = GLOBAL_TAB; i < MAX_TAB; i++ ) { - for( auto &elem : vRules[i] ) { - if( !elem.bActive || !wildcard_match( to_match, elem.sRule ) ) { - continue; - } + create_rule( global_rules, to_match ); + create_rule( character_rules, to_match ); +} - map_items[ to_match ] = elem.bExclude ? RULE_BLACKLISTED : RULE_WHITELISTED; +void auto_pickup::create_rule( const rules_list &rules, const std::string &to_match ) +{ + for( const cRules &elem : rules ) { + if( !elem.bActive || !wildcard_match( to_match, elem.sRule ) ) { + continue; } + + map_items[ to_match ] = elem.bExclude ? RULE_BLACKLISTED : RULE_WHITELISTED; } } void auto_pickup::create_rule( const item *it ) { - const std::string to_match = it->tname( 1, false ); - - for( int i = GLOBAL_TAB; i < MAX_TAB; i++ ) { - for( auto &elem : vRules[i] ) { - if( !elem.bActive ) { - continue; - } else if( !check_special_rule( it->made_of(), elem.sRule ) && - !wildcard_match( to_match, elem.sRule ) ) { - continue; - } + // @todo change it to be a reference + create_rule( global_rules, *it ); + create_rule( character_rules, *it ); +} + +void auto_pickup::create_rule( const rules_list &rules, const item &it ) +{ + const std::string to_match = it.tname( 1, false ); - map_items[ to_match ] = elem.bExclude ? RULE_BLACKLISTED : RULE_WHITELISTED; + for( const cRules &elem : rules ) { + if( !elem.bActive ) { + continue; + } else if( !check_special_rule( it.made_of(), elem.sRule ) && + !wildcard_match( to_match, elem.sRule ) ) { + continue; } + + map_items[ to_match ] = elem.bExclude ? RULE_BLACKLISTED : RULE_WHITELISTED; } } @@ -599,40 +602,45 @@ void auto_pickup::refresh_map_items() const //process include/exclude in order of rules, global first, then character specific //if a specific item is being added, all the rules need to be checked now //may have some performance issues since exclusion needs to check all items also - for( int i = GLOBAL_TAB; i < MAX_TAB; i++ ) { - for( auto &elem : vRules[i] ) { - if( elem.sRule.empty() || !elem.bActive ) { - continue; - } + refresh_map_items( global_rules, temp_items ); + refresh_map_items( character_rules, temp_items ); - if( !elem.bExclude ) { - //Check include patterns against all itemfactory items - for( const itype *e : item_controller->all() ) { - const std::string &cur_item = e->nname( 1 ); + ready = true; +} - if( !check_special_rule( e->materials, elem.sRule ) && !wildcard_match( cur_item, elem.sRule ) ) { - continue; - } +void auto_pickup::refresh_map_items( const rules_list &rules, + std::unordered_map &temp_items ) const +{ + for( const cRules &elem : rules ) { + if( elem.sRule.empty() || !elem.bActive ) { + continue; + } - map_items[ cur_item ] = RULE_WHITELISTED; - temp_items[ cur_item ] = e; + if( !elem.bExclude ) { + //Check include patterns against all itemfactory items + for( const itype *e : item_controller->all() ) { + const std::string &cur_item = e->nname( 1 ); + + if( !check_special_rule( e->materials, elem.sRule ) && !wildcard_match( cur_item, elem.sRule ) ) { + continue; } - } else { - //only re-exclude items from the existing mapping for now - //new exclusions will process during pickup attempts - for( auto &map_item : map_items ) { - if( !check_special_rule( temp_items[ map_item.first ]->materials, elem.sRule ) && - !wildcard_match( map_item.first, elem.sRule ) ) { - continue; - } - map_items[ map_item.first ] = RULE_BLACKLISTED; + map_items[ cur_item ] = RULE_WHITELISTED; + temp_items[ cur_item ] = e; + } + } else { + //only re-exclude items from the existing mapping for now + //new exclusions will process during pickup attempts + for( auto &map_item : map_items ) { + if( !check_special_rule( temp_items[ map_item.first ]->materials, elem.sRule ) && + !wildcard_match( map_item.first, elem.sRule ) ) { + continue; } + + map_items[ map_item.first ] = RULE_BLACKLISTED; } } } - - ready = true; } rule_state auto_pickup::check_item( const std::string &sItemName ) const @@ -651,7 +659,7 @@ rule_state auto_pickup::check_item( const std::string &sItemName ) const void auto_pickup::clear_character_rules() { - vRules[CHARACTER_TAB].clear(); + character_rules.clear(); ready = false; } @@ -737,7 +745,7 @@ void auto_pickup::rules_list::serialize( JsonOut &jsout ) const void auto_pickup::serialize( JsonOut &jsout ) const { - vRules[bChar ? CHARACTER_TAB : GLOBAL_TAB].serialize( jsout ); + ( bChar ? character_rules : global_rules ).serialize( jsout ); } void auto_pickup::cRules::deserialize( JsonIn &jsin ) @@ -763,7 +771,7 @@ void auto_pickup::rules_list::deserialize( JsonIn &jsin ) void auto_pickup::deserialize( JsonIn &jsin ) { ready = false; - vRules[bChar ? CHARACTER_TAB : GLOBAL_TAB].deserialize( jsin ); + ( bChar ? character_rules : global_rules ).deserialize( jsin ); } bool auto_pickup::load_legacy( const bool bCharacter ) @@ -774,7 +782,7 @@ bool auto_pickup::load_legacy( const bool bCharacter ) sFile = g->get_player_base_save_path() + ".apu.txt"; } - auto &rules = vRules[bCharacter ? CHARACTER_TAB : GLOBAL_TAB]; + auto &rules = ( bChar ? character_rules : global_rules ); using namespace std::placeholders; const auto &reader = std::bind( &auto_pickup::load_legacy_rules, this, std::ref( rules ), _1 ); diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 1fa30e964324c..486115588b8b5 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -14,23 +14,20 @@ class JsonOut; class JsonIn; class item; +struct itype; class auto_pickup { private: - void test_pattern( int iTab, int iRow ); + class rules_list; + + void test_pattern( const rules_list &rules, int iRow ); void load( bool bCharacter ); bool save( bool bCharacter ); bool load_legacy( bool bCharacter ); bool bChar; - enum TAB : int { - GLOBAL_TAB, - CHARACTER_TAB, - MAX_TAB - }; - class cRules { public: @@ -67,15 +64,17 @@ class auto_pickup */ mutable std::unordered_map map_items; - /** - * - vRules[0,1] aka vRules[GLOBAL,CHARACTER]: current rules split into global and - * character-specific. Allows the editor to show one or the other. - */ - std::array vRules; + rules_list global_rules; + rules_list character_rules; void load_legacy_rules( rules_list &rules, std::istream &fin ); void refresh_map_items() const; //< Only modifies mutable state + void refresh_map_items( const rules_list &rules, + std::unordered_map &temp_items ) const; + + void create_rule( const rules_list &rules, const std::string &to_match ); + void create_rule( const rules_list &rules, const item &it ); public: auto_pickup() : bChar( false ), ready( false ) {} From 826bca2a2b0334fc0b6f6ee3ff87aa5cf49cbc4d Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 00:39:30 +0200 Subject: [PATCH 068/113] Inline code of auto_pickup::serialize --- src/auto_pickup.cpp | 7 +------ src/auto_pickup.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index af440a328e2fb..8f4adfaafe0a0 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -689,7 +689,7 @@ bool auto_pickup::save( const bool bCharacter ) return write_to_file( savefile, [&]( std::ostream & fout ) { JsonOut jout( fout, true ); - serialize( jout ); + ( bChar ? character_rules : global_rules ).serialize( jout ); }, _( "autopickup configuration" ) ); } @@ -743,11 +743,6 @@ void auto_pickup::rules_list::serialize( JsonOut &jsout ) const jsout.end_array(); } -void auto_pickup::serialize( JsonOut &jsout ) const -{ - ( bChar ? character_rules : global_rules ).serialize( jsout ); -} - void auto_pickup::cRules::deserialize( JsonIn &jsin ) { JsonObject jo = jsin.get_object(); diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 486115588b8b5..104fb7db937e7 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -98,7 +98,6 @@ class auto_pickup bool empty() const; - void serialize( JsonOut &json ) const; void deserialize( JsonIn &jsin ); }; From 9ca2a88c0f1ec55b7e8c8464856373eea3c37b62 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 00:40:41 +0200 Subject: [PATCH 069/113] Inline code of auto_pickup::deserialize --- src/auto_pickup.cpp | 8 +------- src/auto_pickup.h | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 8f4adfaafe0a0..525a35b626091 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -713,7 +713,7 @@ void auto_pickup::load( const bool bCharacter ) } if( !read_from_file_optional_json( sFile, [this]( JsonIn & jsin ) { - deserialize( jsin ); + ( bChar ? character_rules : global_rules ).deserialize( jsin ); } ) ) { if( load_legacy( bCharacter ) ) { if( save( bCharacter ) ) { @@ -763,12 +763,6 @@ void auto_pickup::rules_list::deserialize( JsonIn &jsin ) } } -void auto_pickup::deserialize( JsonIn &jsin ) -{ - ready = false; - ( bChar ? character_rules : global_rules ).deserialize( jsin ); -} - bool auto_pickup::load_legacy( const bool bCharacter ) { std::string sFile = FILENAMES["legacy_autopickup2"]; diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 104fb7db937e7..60e421990073e 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -97,8 +97,6 @@ class auto_pickup void load_global(); bool empty() const; - - void deserialize( JsonIn &jsin ); }; auto_pickup &get_auto_pickup(); From 4f222c1e5d3934d1206d4fe54e08f0cc8c0db423 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 00:42:16 +0200 Subject: [PATCH 070/113] Remove auto_pickup::bChar hack --- src/auto_pickup.cpp | 11 ++++------- src/auto_pickup.h | 4 +--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 525a35b626091..ce6e24e68c11f 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -675,7 +675,6 @@ bool auto_pickup::save_global() bool auto_pickup::save( const bool bCharacter ) { - bChar = bCharacter; auto savefile = FILENAMES["autopickup"]; if( bCharacter ) { @@ -689,7 +688,7 @@ bool auto_pickup::save( const bool bCharacter ) return write_to_file( savefile, [&]( std::ostream & fout ) { JsonOut jout( fout, true ); - ( bChar ? character_rules : global_rules ).serialize( jout ); + ( bCharacter ? character_rules : global_rules ).serialize( jout ); }, _( "autopickup configuration" ) ); } @@ -705,15 +704,13 @@ void auto_pickup::load_global() void auto_pickup::load( const bool bCharacter ) { - bChar = bCharacter; - std::string sFile = FILENAMES["autopickup"]; if( bCharacter ) { sFile = g->get_player_base_save_path() + ".apu.json"; } - if( !read_from_file_optional_json( sFile, [this]( JsonIn & jsin ) { - ( bChar ? character_rules : global_rules ).deserialize( jsin ); + if( !read_from_file_optional_json( sFile, [&]( JsonIn & jsin ) { + ( bCharacter ? character_rules : global_rules ).deserialize( jsin ); } ) ) { if( load_legacy( bCharacter ) ) { if( save( bCharacter ) ) { @@ -771,7 +768,7 @@ bool auto_pickup::load_legacy( const bool bCharacter ) sFile = g->get_player_base_save_path() + ".apu.txt"; } - auto &rules = ( bChar ? character_rules : global_rules ); + auto &rules = bCharacter ? character_rules : global_rules; using namespace std::placeholders; const auto &reader = std::bind( &auto_pickup::load_legacy_rules, this, std::ref( rules ), _1 ); diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 60e421990073e..a723a39562a8a 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -26,8 +26,6 @@ class auto_pickup bool save( bool bCharacter ); bool load_legacy( bool bCharacter ); - bool bChar; - class cRules { public: @@ -77,7 +75,7 @@ class auto_pickup void create_rule( const rules_list &rules, const item &it ); public: - auto_pickup() : bChar( false ), ready( false ) {} + auto_pickup() : ready( false ) {} void create_rule( const std::string &to_match ); void create_rule( const item *it ); From 8757614fadc41b4235a8dfb4e6b5be5938b8867e Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 00:48:10 +0200 Subject: [PATCH 071/113] Move classes inside of auto_pickup into global namespace --- src/auto_pickup.cpp | 38 +++++++++++------------ src/auto_pickup.h | 75 ++++++++++++++++++++++++--------------------- 2 files changed, 59 insertions(+), 54 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index ce6e24e68c11f..a0978f4e77ffb 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -145,7 +145,7 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) std::ostringstream sTemp; while( true ) { - rules_list &cur_rules = iTab == GLOBAL_TAB ? global_rules : character_rules; + auto_pickup_rule_list &cur_rules = iTab == GLOBAL_TAB ? global_rules : character_rules; int locx = 17; locx += shortcut_print( w_header, point( locx, 2 ), c_white, iTab == GLOBAL_TAB ? hilite( c_white ) : c_white, _( "[]" ) ) + 1; @@ -261,7 +261,7 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) iLine = cur_rules.size() - 1; } else if( action == "SWAP_RULE_GLOBAL_CHAR" && currentPageNonEmpty ) { if( ( iTab == GLOBAL_TAB && !g->u.name.empty() ) || iTab == CHARACTER_TAB ) { - rules_list &other_rules = iTab == CHARACTER_TAB ? global_rules : character_rules; + auto_pickup_rule_list &other_rules = iTab == CHARACTER_TAB ? global_rules : character_rules; bStuffChanged = true; //copy over other_rules.push_back( cur_rules[iLine] ); @@ -274,7 +274,7 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } else if( action == "ADD_RULE" || ( action == "CONFIRM" && currentPageNonEmpty ) ) { const int old_iLine = iLine; if( action == "ADD_RULE" ) { - cur_rules.push_back( cRules( "", true, false ) ); + cur_rules.push_back( auto_pickup_rule( "", true, false ) ); iLine = cur_rules.size() - 1; } @@ -378,7 +378,7 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } } -void auto_pickup::test_pattern( const rules_list &rules, const int iRow ) +void auto_pickup::test_pattern( const auto_pickup_rule_list &rules, const int iRow ) { std::vector vMatchingItems; @@ -492,7 +492,7 @@ bool auto_pickup::has_rule( const item *it ) void auto_pickup::add_rule( const item *it ) { - character_rules.push_back( cRules( it->tname( 1, false ), true, false ) ); + character_rules.push_back( auto_pickup_rule( it->tname( 1, false ), true, false ) ); create_rule( it ); if( !get_option( "AUTO_PICKUP" ) && @@ -560,9 +560,9 @@ void auto_pickup::create_rule( const std::string &to_match ) create_rule( character_rules, to_match ); } -void auto_pickup::create_rule( const rules_list &rules, const std::string &to_match ) +void auto_pickup::create_rule( const auto_pickup_rule_list &rules, const std::string &to_match ) { - for( const cRules &elem : rules ) { + for( const auto_pickup_rule &elem : rules ) { if( !elem.bActive || !wildcard_match( to_match, elem.sRule ) ) { continue; } @@ -578,11 +578,11 @@ void auto_pickup::create_rule( const item *it ) create_rule( character_rules, *it ); } -void auto_pickup::create_rule( const rules_list &rules, const item &it ) +void auto_pickup::create_rule( const auto_pickup_rule_list &rules, const item &it ) { const std::string to_match = it.tname( 1, false ); - for( const cRules &elem : rules ) { + for( const auto_pickup_rule &elem : rules ) { if( !elem.bActive ) { continue; } else if( !check_special_rule( it.made_of(), elem.sRule ) && @@ -608,10 +608,10 @@ void auto_pickup::refresh_map_items() const ready = true; } -void auto_pickup::refresh_map_items( const rules_list &rules, +void auto_pickup::refresh_map_items( const auto_pickup_rule_list &rules, std::unordered_map &temp_items ) const { - for( const cRules &elem : rules ) { + for( const auto_pickup_rule &elem : rules ) { if( elem.sRule.empty() || !elem.bActive ) { continue; } @@ -722,7 +722,7 @@ void auto_pickup::load( const bool bCharacter ) ready = false; } -void auto_pickup::cRules::serialize( JsonOut &jsout ) const +void auto_pickup_rule::serialize( JsonOut &jsout ) const { jsout.start_object(); jsout.member( "rule", sRule ); @@ -731,16 +731,16 @@ void auto_pickup::cRules::serialize( JsonOut &jsout ) const jsout.end_object(); } -void auto_pickup::rules_list::serialize( JsonOut &jsout ) const +void auto_pickup_rule_list::serialize( JsonOut &jsout ) const { jsout.start_array(); - for( const cRules &elem : *this ) { + for( const auto_pickup_rule &elem : *this ) { elem.serialize( jsout ); } jsout.end_array(); } -void auto_pickup::cRules::deserialize( JsonIn &jsin ) +void auto_pickup_rule::deserialize( JsonIn &jsin ) { JsonObject jo = jsin.get_object(); sRule = jo.get_string( "rule" ); @@ -748,13 +748,13 @@ void auto_pickup::cRules::deserialize( JsonIn &jsin ) bExclude = jo.get_bool( "exclude" ); } -void auto_pickup::rules_list::deserialize( JsonIn &jsin ) +void auto_pickup_rule_list::deserialize( JsonIn &jsin ) { clear(); jsin.start_array(); while( !jsin.end_array() ) { - cRules tmp; + auto_pickup_rule tmp; tmp.deserialize( jsin ); push_back( tmp ); } @@ -783,7 +783,7 @@ bool auto_pickup::load_legacy( const bool bCharacter ) return true; } -void auto_pickup::load_legacy_rules( rules_list &rules, std::istream &fin ) +void auto_pickup::load_legacy_rules( auto_pickup_rule_list &rules, std::istream &fin ) { rules.clear(); ready = false; @@ -827,7 +827,7 @@ void auto_pickup::load_legacy_rules( rules_list &rules, std::istream &fin ) } while( iPos != std::string::npos ); - rules.push_back( cRules( sRule, bActive, bExclude ) ); + rules.push_back( auto_pickup_rule( sRule, bActive, bExclude ) ); } } } diff --git a/src/auto_pickup.h b/src/auto_pickup.h index a723a39562a8a..37e8b7bdc62bc 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -16,41 +16,46 @@ class JsonIn; class item; struct itype; -class auto_pickup +/** + * A single entry in the list of auto pickup entries @ref auto_pickup_rule_list. + * The data contained can be edited by the player and determines what to pick/ignore. + */ +class auto_pickup_rule { - private: - class rules_list; - - void test_pattern( const rules_list &rules, int iRow ); - void load( bool bCharacter ); - bool save( bool bCharacter ); - bool load_legacy( bool bCharacter ); + public: + std::string sRule; + bool bActive = false; + bool bExclude = false; - class cRules - { - public: - std::string sRule; - bool bActive = false; - bool bExclude = false; + auto_pickup_rule() = default; - cRules() = default; + auto_pickup_rule( const std::string &sRuleIn, bool bActiveIn, bool bExcludeIn ) { + this->sRule = sRuleIn; + this->bActive = bActiveIn; + this->bExclude = bExcludeIn; + } - cRules( const std::string &sRuleIn, bool bActiveIn, bool bExcludeIn ) { - this->sRule = sRuleIn; - this->bActive = bActiveIn; - this->bExclude = bExcludeIn; - } + void serialize( JsonOut &json ) const; + void deserialize( JsonIn &jsin ); +}; - void serialize( JsonOut &json ) const; - void deserialize( JsonIn &jsin ); - }; +/** + * A list of rules. This is primarily a container with a few convenient functions (like saving/loading). + */ +class auto_pickup_rule_list : public std::vector +{ + public: + void serialize( JsonOut &json ) const; + void deserialize( JsonIn &jsin ); +}; - class rules_list : public std::vector - { - public: - void serialize( JsonOut &json ) const; - void deserialize( JsonIn &jsin ); - }; +class auto_pickup +{ + private: + void test_pattern( const auto_pickup_rule_list &rules, int iRow ); + void load( bool bCharacter ); + bool save( bool bCharacter ); + bool load_legacy( bool bCharacter ); mutable bool ready; //< true if map_items has been populated from vRules @@ -62,17 +67,17 @@ class auto_pickup */ mutable std::unordered_map map_items; - rules_list global_rules; - rules_list character_rules; + auto_pickup_rule_list global_rules; + auto_pickup_rule_list character_rules; - void load_legacy_rules( rules_list &rules, std::istream &fin ); + void load_legacy_rules( auto_pickup_rule_list &rules, std::istream &fin ); void refresh_map_items() const; //< Only modifies mutable state - void refresh_map_items( const rules_list &rules, + void refresh_map_items( const auto_pickup_rule_list &rules, std::unordered_map &temp_items ) const; - void create_rule( const rules_list &rules, const std::string &to_match ); - void create_rule( const rules_list &rules, const item &it ); + void create_rule( const auto_pickup_rule_list &rules, const std::string &to_match ); + void create_rule( const auto_pickup_rule_list &rules, const item &it ); public: auto_pickup() : ready( false ) {} From 1e47a176ebf4df83d43463e30fb14e9ba2d02a82 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 00:52:15 +0200 Subject: [PATCH 072/113] Move functions into class auto_pickup_rule --- src/auto_pickup.cpp | 62 ++++++++++++++++++++++++--------------------- src/auto_pickup.h | 23 ++++++++++------- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index a0978f4e77ffb..b93725e5069f2 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -348,7 +348,7 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) iColumn = 1; } } else if( action == "TEST_RULE" && currentPageNonEmpty && !g->u.name.empty() ) { - test_pattern( cur_rules, iLine ); + cur_rules[iLine].test_pattern(); } else if( action == "SWITCH_AUTO_PICKUP_OPTION" ) { // TODO: Now that NPCs use this function, it could be used for them too get_options().get_option( "AUTO_PICKUP" ).setNext(); @@ -378,11 +378,11 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } } -void auto_pickup::test_pattern( const auto_pickup_rule_list &rules, const int iRow ) +void auto_pickup_rule::test_pattern() const { std::vector vMatchingItems; - if( rules[iRow].sRule.empty() ) { + if( sRule.empty() ) { return; } @@ -390,8 +390,8 @@ void auto_pickup::test_pattern( const auto_pickup_rule_list &rules, const int iR //APU now ignores prefixes, bottled items and suffix combinations still not generated for( const itype *e : item_controller->all() ) { const std::string sItemName = e->nname( 1 ); - if( !check_special_rule( e->materials, rules[iRow].sRule ) && - !wildcard_match( sItemName, rules[iRow].sRule ) ) { + if( !check_special_rule( e->materials, sRule ) && + !wildcard_match( sItemName, sRule ) ) { continue; } @@ -416,7 +416,7 @@ void auto_pickup::test_pattern( const auto_pickup_rule_list &rules, const int iR int nmatch = vMatchingItems.size(); const std::string buf = string_format( ngettext( "%1$d item matches: %2$s", "%1$d items match: %2$s", - nmatch ), nmatch, rules[iRow].sRule ); + nmatch ), nmatch, sRule ); draw_border( w_test_rule_border, BORDER_COLOR, buf, hilite( c_white ) ); center_print( w_test_rule_border, iContentHeight + 1, red_background( c_white ), _( "Won't display content or suffix matches" ) ); @@ -521,8 +521,8 @@ bool auto_pickup::empty() const return global_rules.empty() && character_rules.empty(); } -bool auto_pickup::check_special_rule( const std::vector &materials, - const std::string &rule ) const +bool auto_pickup_rule::check_special_rule( const std::vector &materials, + const std::string &rule ) { char type = ' '; std::vector filter; @@ -556,13 +556,14 @@ bool auto_pickup::check_special_rule( const std::vector &materials, //Special case. Required for NPC harvest autopickup. Ignores material rules. void auto_pickup::create_rule( const std::string &to_match ) { - create_rule( global_rules, to_match ); - create_rule( character_rules, to_match ); + global_rules.create_rule( map_items, to_match ); + character_rules.create_rule( map_items, to_match ); } -void auto_pickup::create_rule( const auto_pickup_rule_list &rules, const std::string &to_match ) +void auto_pickup_rule_list::create_rule( std::unordered_map &map_items, + const std::string &to_match ) { - for( const auto_pickup_rule &elem : rules ) { + for( const auto_pickup_rule &elem : *this ) { if( !elem.bActive || !wildcard_match( to_match, elem.sRule ) ) { continue; } @@ -574,18 +575,19 @@ void auto_pickup::create_rule( const auto_pickup_rule_list &rules, const std::st void auto_pickup::create_rule( const item *it ) { // @todo change it to be a reference - create_rule( global_rules, *it ); - create_rule( character_rules, *it ); + global_rules.create_rule( map_items, *it ); + character_rules.create_rule( map_items, *it ); } -void auto_pickup::create_rule( const auto_pickup_rule_list &rules, const item &it ) +void auto_pickup_rule_list::create_rule( std::unordered_map &map_items, + const item &it ) { const std::string to_match = it.tname( 1, false ); - for( const auto_pickup_rule &elem : rules ) { + for( const auto_pickup_rule &elem : *this ) { if( !elem.bActive ) { continue; - } else if( !check_special_rule( it.made_of(), elem.sRule ) && + } else if( !auto_pickup_rule::check_special_rule( it.made_of(), elem.sRule ) && !wildcard_match( to_match, elem.sRule ) ) { continue; } @@ -602,16 +604,16 @@ void auto_pickup::refresh_map_items() const //process include/exclude in order of rules, global first, then character specific //if a specific item is being added, all the rules need to be checked now //may have some performance issues since exclusion needs to check all items also - refresh_map_items( global_rules, temp_items ); - refresh_map_items( character_rules, temp_items ); + global_rules.refresh_map_items( map_items, temp_items ); + character_rules.refresh_map_items( map_items, temp_items ); ready = true; } -void auto_pickup::refresh_map_items( const auto_pickup_rule_list &rules, - std::unordered_map &temp_items ) const +void auto_pickup_rule_list::refresh_map_items( std::unordered_map + &map_items, std::unordered_map &temp_items ) const { - for( const auto_pickup_rule &elem : rules ) { + for( const auto_pickup_rule &elem : *this ) { if( elem.sRule.empty() || !elem.bActive ) { continue; } @@ -621,7 +623,8 @@ void auto_pickup::refresh_map_items( const auto_pickup_rule_list &rules, for( const itype *e : item_controller->all() ) { const std::string &cur_item = e->nname( 1 ); - if( !check_special_rule( e->materials, elem.sRule ) && !wildcard_match( cur_item, elem.sRule ) ) { + if( !auto_pickup_rule::check_special_rule( e->materials, elem.sRule ) && + !wildcard_match( cur_item, elem.sRule ) ) { continue; } @@ -632,7 +635,7 @@ void auto_pickup::refresh_map_items( const auto_pickup_rule_list &rules, //only re-exclude items from the existing mapping for now //new exclusions will process during pickup attempts for( auto &map_item : map_items ) { - if( !check_special_rule( temp_items[ map_item.first ]->materials, elem.sRule ) && + if( !auto_pickup_rule::check_special_rule( temp_items[ map_item.first ]->materials, elem.sRule ) && !wildcard_match( map_item.first, elem.sRule ) ) { continue; } @@ -768,10 +771,12 @@ bool auto_pickup::load_legacy( const bool bCharacter ) sFile = g->get_player_base_save_path() + ".apu.txt"; } + ready = false; + auto &rules = bCharacter ? character_rules : global_rules; using namespace std::placeholders; - const auto &reader = std::bind( &auto_pickup::load_legacy_rules, this, std::ref( rules ), _1 ); + const auto &reader = std::bind( &auto_pickup_rule_list::load_legacy_rules, std::ref( rules ), _1 ); if( !read_from_file_optional( sFile, reader ) ) { if( !bCharacter ) { return read_from_file_optional( FILENAMES["legacy_autopickup"], reader ); @@ -783,10 +788,9 @@ bool auto_pickup::load_legacy( const bool bCharacter ) return true; } -void auto_pickup::load_legacy_rules( auto_pickup_rule_list &rules, std::istream &fin ) +void auto_pickup_rule_list::load_legacy_rules( std::istream &fin ) { - rules.clear(); - ready = false; + clear(); std::string sLine; while( !fin.eof() ) { @@ -827,7 +831,7 @@ void auto_pickup::load_legacy_rules( auto_pickup_rule_list &rules, std::istream } while( iPos != std::string::npos ); - rules.push_back( auto_pickup_rule( sRule, bActive, bExclude ) ); + push_back( auto_pickup_rule( sRule, bActive, bExclude ) ); } } } diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 37e8b7bdc62bc..97fef55eb52f3 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -37,6 +37,11 @@ class auto_pickup_rule void serialize( JsonOut &json ) const; void deserialize( JsonIn &jsin ); + + void test_pattern() const; + + static bool check_special_rule( const std::vector &materials, + const std::string &rule ); }; /** @@ -47,12 +52,20 @@ class auto_pickup_rule_list : public std::vector public: void serialize( JsonOut &json ) const; void deserialize( JsonIn &jsin ); + + void load_legacy_rules( std::istream &fin ); + + void refresh_map_items( std::unordered_map &map_items, + std::unordered_map &temp_items ) const; + + void create_rule( std::unordered_map &map_items, + const std::string &to_match ); + void create_rule( std::unordered_map &map_items, const item &it ); }; class auto_pickup { private: - void test_pattern( const auto_pickup_rule_list &rules, int iRow ); void load( bool bCharacter ); bool save( bool bCharacter ); bool load_legacy( bool bCharacter ); @@ -70,14 +83,7 @@ class auto_pickup auto_pickup_rule_list global_rules; auto_pickup_rule_list character_rules; - void load_legacy_rules( auto_pickup_rule_list &rules, std::istream &fin ); - void refresh_map_items() const; //< Only modifies mutable state - void refresh_map_items( const auto_pickup_rule_list &rules, - std::unordered_map &temp_items ) const; - - void create_rule( const auto_pickup_rule_list &rules, const std::string &to_match ); - void create_rule( const auto_pickup_rule_list &rules, const item &it ); public: auto_pickup() : ready( false ) {} @@ -87,7 +93,6 @@ class auto_pickup bool has_rule( const item *it ); void add_rule( const item *it ); void remove_rule( const item *it ); - bool check_special_rule( const std::vector &materials, const std::string &rule ) const; void clear_character_rules(); rule_state check_item( const std::string &sItemName ) const; From 63d4c48aa7ba0a3af126a40e17fbff50e29d1039 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 01:14:27 +0200 Subject: [PATCH 073/113] Add separate class for cached auto pickup entries. The constructor of `auto_pickup` would be empty, so it has been removed. --- src/auto_pickup.cpp | 35 +++++++++++++++++------------------ src/auto_pickup.h | 36 ++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index b93725e5069f2..2e40b144dda26 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -371,7 +371,7 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) } } - ready = false; + map_items.ready = false; } else { global_rules = old_global_rules; character_rules = old_character_rules; @@ -510,7 +510,7 @@ void auto_pickup::remove_rule( const item *it ) if( sRule.length() == it->sRule.length() && ci_find_substr( sRule, it->sRule ) != -1 ) { character_rules.erase( it ); - ready = false; + map_items.ready = false; break; } } @@ -560,8 +560,7 @@ void auto_pickup::create_rule( const std::string &to_match ) character_rules.create_rule( map_items, to_match ); } -void auto_pickup_rule_list::create_rule( std::unordered_map &map_items, - const std::string &to_match ) +void auto_pickup_rule_list::create_rule( auto_pickup_cache &map_items, const std::string &to_match ) { for( const auto_pickup_rule &elem : *this ) { if( !elem.bActive || !wildcard_match( to_match, elem.sRule ) ) { @@ -579,8 +578,7 @@ void auto_pickup::create_rule( const item *it ) character_rules.create_rule( map_items, *it ); } -void auto_pickup_rule_list::create_rule( std::unordered_map &map_items, - const item &it ) +void auto_pickup_rule_list::create_rule( auto_pickup_cache &map_items, const item &it ) { const std::string to_match = it.tname( 1, false ); @@ -599,19 +597,19 @@ void auto_pickup_rule_list::create_rule( std::unordered_map temp_items; + map_items.temp_items.clear(); //process include/exclude in order of rules, global first, then character specific //if a specific item is being added, all the rules need to be checked now //may have some performance issues since exclusion needs to check all items also - global_rules.refresh_map_items( map_items, temp_items ); - character_rules.refresh_map_items( map_items, temp_items ); + global_rules.refresh_map_items( map_items ); + character_rules.refresh_map_items( map_items ); - ready = true; + map_items.ready = true; + map_items.temp_items.clear(); } -void auto_pickup_rule_list::refresh_map_items( std::unordered_map - &map_items, std::unordered_map &temp_items ) const +void auto_pickup_rule_list::refresh_map_items( auto_pickup_cache &map_items ) const { for( const auto_pickup_rule &elem : *this ) { if( elem.sRule.empty() || !elem.bActive ) { @@ -629,13 +627,14 @@ void auto_pickup_rule_list::refresh_map_items( std::unordered_mapmaterials, elem.sRule ) && + if( !auto_pickup_rule::check_special_rule( map_items.temp_items[ map_item.first ]->materials, + elem.sRule ) && !wildcard_match( map_item.first, elem.sRule ) ) { continue; } @@ -648,7 +647,7 @@ void auto_pickup_rule_list::refresh_map_items( std::unordered_mapget_player_base_save_path() + ".apu.txt"; } - ready = false; + map_items.ready = false; auto &rules = bCharacter ? character_rules : global_rules; diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 97fef55eb52f3..205fccf4c9df7 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -16,6 +16,22 @@ class JsonIn; class item; struct itype; +/** + * The currently-active set of auto-pickup rules, in a form that allows quick + * lookup. When this is filled (by @ref auto_pickup::create_rule()), every + * item existing in the game that matches a rule (either white- or blacklist) + * is added as the key, with RULE_WHITELISTED or RULE_BLACKLISTED as the values. + */ +class auto_pickup_cache : public std::unordered_map +{ + public: + /// Defines whether this cache has been filled. + bool ready = false; + + /// Temporary data used while filling the cache. + std::unordered_map temp_items; +}; + /** * A single entry in the list of auto pickup entries @ref auto_pickup_rule_list. * The data contained can be edited by the player and determines what to pick/ignore. @@ -55,12 +71,10 @@ class auto_pickup_rule_list : public std::vector void load_legacy_rules( std::istream &fin ); - void refresh_map_items( std::unordered_map &map_items, - std::unordered_map &temp_items ) const; + void refresh_map_items( auto_pickup_cache &map_items ) const; - void create_rule( std::unordered_map &map_items, - const std::string &to_match ); - void create_rule( std::unordered_map &map_items, const item &it ); + void create_rule( auto_pickup_cache &map_items, const std::string &to_match ); + void create_rule( auto_pickup_cache &map_items, const item &it ); }; class auto_pickup @@ -70,15 +84,7 @@ class auto_pickup bool save( bool bCharacter ); bool load_legacy( bool bCharacter ); - mutable bool ready; //< true if map_items has been populated from vRules - - /** - * The currently-active set of auto-pickup rules, in a form that allows quick - * lookup. When this is filled (by @ref auto_pickup::create_rule()), every - * item existing in the game that matches a rule (either white- or blacklist) - * is added as the key, with RULE_WHITELISTED or RULE_BLACKLISTED as the values. - */ - mutable std::unordered_map map_items; + mutable auto_pickup_cache map_items; auto_pickup_rule_list global_rules; auto_pickup_rule_list character_rules; @@ -86,8 +92,6 @@ class auto_pickup void refresh_map_items() const; //< Only modifies mutable state public: - auto_pickup() : ready( false ) {} - void create_rule( const std::string &to_match ); void create_rule( const item *it ); bool has_rule( const item *it ); From 0e2d27cffa1dd11ea2218c98bf67ebc88f9cb677 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 01:38:04 +0200 Subject: [PATCH 074/113] Make a separate class for displaying auto pickup rules --- src/auto_pickup.cpp | 132 ++++++++++++++++++++++++++------------------ src/auto_pickup.h | 27 +++++++++ 2 files changed, 104 insertions(+), 55 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 2e40b144dda26..634f1f944de4c 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -39,17 +39,8 @@ void auto_pickup::show() show( _( " AUTO PICKUP MANAGER " ), true ); } -void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) +void auto_pickup_ui::show() { - const auto old_global_rules = global_rules; - const auto old_character_rules = character_rules; - - enum : int { - GLOBAL_TAB, - CHARACTER_TAB, - MAX_TAB - }; - const int iHeaderHeight = 4; const int iContentHeight = FULL_SCREEN_HEIGHT - 2 - iHeaderHeight; @@ -75,7 +66,7 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) */ const auto initial_draw = [&]() { // Redraw the border - draw_border( w_border, BORDER_COLOR, custom_name ); + draw_border( w_border, BORDER_COLOR, title ); mvwputch( w_border, point( 0, 3 ), c_light_gray, LINE_XXXO ) ; // |- mvwputch( w_border, point( 79, 3 ), c_light_gray, LINE_XOXX ); // -| mvwputch( w_border, point( 5, FULL_SCREEN_HEIGHT - 1 ), c_light_gray, LINE_XXOX ); // _|_ @@ -116,17 +107,22 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) }; initial_draw(); - int iTab = GLOBAL_TAB; + size_t iTab = 0; + while( !tabs[iTab].available && iTab + 1 < tabs.size() ) { + iTab++; + } int iLine = 0; int iColumn = 1; int iStartPos = 0; - bool bStuffChanged = false; + bStuffChanged = false; input_context ctxt( "AUTO_PICKUP" ); ctxt.register_cardinal(); ctxt.register_action( "CONFIRM" ); ctxt.register_action( "QUIT" ); - ctxt.register_action( "NEXT_TAB" ); - ctxt.register_action( "PREV_TAB" ); + if( tabs.size() > 1 ) { + ctxt.register_action( "NEXT_TAB" ); + ctxt.register_action( "PREV_TAB" ); + } ctxt.register_action( "ADD_RULE" ); ctxt.register_action( "REMOVE_RULE" ); ctxt.register_action( "COPY_RULE" ); @@ -137,20 +133,24 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) ctxt.register_action( "TEST_RULE" ); ctxt.register_action( "HELP_KEYBINDINGS" ); + const bool allow_swapping = tabs.size() == 2 && tabs[0].available && tabs[1].available; + if( allow_swapping ) { + ctxt.register_action( "SWAP_RULE_GLOBAL_CHAR" ); + } + if( is_autopickup ) { ctxt.register_action( "SWITCH_AUTO_PICKUP_OPTION" ); - ctxt.register_action( "SWAP_RULE_GLOBAL_CHAR" ); } std::ostringstream sTemp; while( true ) { - auto_pickup_rule_list &cur_rules = iTab == GLOBAL_TAB ? global_rules : character_rules; + auto_pickup_rule_list &cur_rules = tabs[iTab].new_rules; int locx = 17; - locx += shortcut_print( w_header, point( locx, 2 ), c_white, - iTab == GLOBAL_TAB ? hilite( c_white ) : c_white, _( "[]" ) ) + 1; - shortcut_print( w_header, point( locx, 2 ), c_white, - iTab == CHARACTER_TAB ? hilite( c_white ) : c_white, _( "[]" ) ); + for( size_t i = 0; i < tabs.size(); i++ ) { + const auto color = iTab == i ? hilite( c_white ) : c_white; + locx += shortcut_print( w_header, point( locx, 2 ), c_white, color, tabs[i].title ) + 1; + } locx = 55; mvwprintz( w_header, point( locx, 0 ), c_white, _( "Auto pickup enabled:" ) ); @@ -176,10 +176,9 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) const bool currentPageNonEmpty = !cur_rules.empty(); - if( iTab == CHARACTER_TAB && g->u.name.empty() ) { + if( !tabs[iTab].available ) { cur_rules.clear(); - mvwprintz( w, point( 15, 8 ), c_white, - _( "Please load a character first to use this page!" ) ); + mvwprintz( w, point( 15, 8 ), c_white, "%s", tabs[iTab].unavailable_msg ); } draw_scrollbar( w_border, iLine, iContentHeight, cur_rules.size(), 5 ); @@ -220,20 +219,22 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) if( action == "NEXT_TAB" ) { iTab++; - if( iTab >= MAX_TAB ) { + if( iTab >= tabs.size() ) { iTab = 0; - iLine = 0; } + iLine = 0; } else if( action == "PREV_TAB" ) { - iTab--; - if( iTab < 0 ) { - iTab = MAX_TAB - 1; - iLine = 0; + if( iTab > 0 ) { + iTab--; + } else { + iTab = tabs.size() - 1; } + iLine = 0; } else if( action == "QUIT" ) { break; - } else if( iTab == CHARACTER_TAB && g->u.name.empty() ) { - //Only allow loaded games to use the char sheet + } else if( !tabs[iTab].available ) { + // this effectively disables all the following else branches, which are only useful + // for available tabs. } else if( action == "DOWN" ) { iLine++; iColumn = 1; @@ -259,18 +260,16 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) bStuffChanged = true; cur_rules.push_back( cur_rules[iLine] ); iLine = cur_rules.size() - 1; - } else if( action == "SWAP_RULE_GLOBAL_CHAR" && currentPageNonEmpty ) { - if( ( iTab == GLOBAL_TAB && !g->u.name.empty() ) || iTab == CHARACTER_TAB ) { - auto_pickup_rule_list &other_rules = iTab == CHARACTER_TAB ? global_rules : character_rules; - bStuffChanged = true; - //copy over - other_rules.push_back( cur_rules[iLine] ); - - //remove old - cur_rules.erase( cur_rules.begin() + iLine ); - iLine = other_rules.size() - 1; - iTab = iTab == GLOBAL_TAB ? CHARACTER_TAB : GLOBAL_TAB; - } + } else if( allow_swapping && action == "SWAP_RULE_GLOBAL_CHAR" && currentPageNonEmpty ) { + const size_t other_iTab = ( iTab + 1 ) % 2; + auto_pickup_rule_list &other_rules = tabs[other_iTab].new_rules; + bStuffChanged = true; + //copy over + other_rules.push_back( cur_rules[iLine] ); + //remove old + cur_rules.erase( cur_rules.begin() + iLine ); + iTab = other_iTab; + iLine = other_rules.size() - 1; } else if( action == "ADD_RULE" || ( action == "CONFIRM" && currentPageNonEmpty ) ) { const int old_iLine = iLine; if( action == "ADD_RULE" ) { @@ -362,20 +361,43 @@ void auto_pickup::show( const std::string &custom_name, bool is_autopickup ) return; } - if( query_yn( _( "Save changes?" ) ) ) { - // NPC pickup rules don't need to be saved explicitly - if( is_autopickup ) { - save_global(); - if( !g->u.name.empty() ) { - save_character(); - } - } + if( !query_yn( _( "Save changes?" ) ) ) { + return; + } - map_items.ready = false; + for( tab &t : tabs ) { + t.rules.get() = t.new_rules; + } +} + +void auto_pickup::show( const std::string &custom_name, const bool is_autopickup ) +{ + auto_pickup_ui ui; + + ui.title = custom_name; + ui.tabs.emplace_back( _( "[]" ), global_rules ); + if( g->u.name.empty() ) { + ui.tabs.emplace_back( _( "[]" ), + _( "Please load a character first to use this page!" ) ); } else { - global_rules = old_global_rules; - character_rules = old_character_rules; + ui.tabs.emplace_back( _( "[]" ), character_rules ); + } + ui.is_autopickup = is_autopickup; + + ui.show(); + + if( !ui.bStuffChanged ) { + return; } + + // NPC pickup rules don't need to be saved explicitly + if( is_autopickup ) { + save_global(); + if( !g->u.name.empty() ) { + save_character(); + } + } + map_items.ready = false; } void auto_pickup_rule::test_pattern() const diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 205fccf4c9df7..cb13fb4ad7b34 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -77,6 +77,33 @@ class auto_pickup_rule_list : public std::vector void create_rule( auto_pickup_cache &map_items, const item &it ); }; +class auto_pickup_ui +{ + public: + class tab + { + public: + std::string title; + bool available; + std::string unavailable_msg; + auto_pickup_rule_list new_rules; + std::reference_wrapper rules; + + tab( const std::string &t, auto_pickup_rule_list &r ) : title( t ), available( true ), + new_rules( r ), rules( r ) { } + tab( const std::string &t, const std::string &u ) : title( t ), available( false ), + unavailable_msg( u ), new_rules(), rules( new_rules ) { } + }; + + std::string title; + std::vector tabs; + bool is_autopickup = false; + + void show(); + + bool bStuffChanged = false; +}; + class auto_pickup { private: From 0218e36ce9ac167d1bd51614e701ec5599c21a55 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 13:24:21 +0200 Subject: [PATCH 075/113] auto pickup ui: completely ignore unavailable tabs Don't even tell the UI that there are any unavailable tabs, simply don't add them to the UI. --- src/auto_pickup.cpp | 22 ++++++---------------- src/auto_pickup.h | 7 +------ 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 634f1f944de4c..b9e11687c7bb2 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -41,6 +41,10 @@ void auto_pickup::show() void auto_pickup_ui::show() { + if( tabs.empty() ) { + return; + } + const int iHeaderHeight = 4; const int iContentHeight = FULL_SCREEN_HEIGHT - 2 - iHeaderHeight; @@ -108,9 +112,6 @@ void auto_pickup_ui::show() initial_draw(); size_t iTab = 0; - while( !tabs[iTab].available && iTab + 1 < tabs.size() ) { - iTab++; - } int iLine = 0; int iColumn = 1; int iStartPos = 0; @@ -133,7 +134,7 @@ void auto_pickup_ui::show() ctxt.register_action( "TEST_RULE" ); ctxt.register_action( "HELP_KEYBINDINGS" ); - const bool allow_swapping = tabs.size() == 2 && tabs[0].available && tabs[1].available; + const bool allow_swapping = tabs.size() == 2; if( allow_swapping ) { ctxt.register_action( "SWAP_RULE_GLOBAL_CHAR" ); } @@ -176,11 +177,6 @@ void auto_pickup_ui::show() const bool currentPageNonEmpty = !cur_rules.empty(); - if( !tabs[iTab].available ) { - cur_rules.clear(); - mvwprintz( w, point( 15, 8 ), c_white, "%s", tabs[iTab].unavailable_msg ); - } - draw_scrollbar( w_border, iLine, iContentHeight, cur_rules.size(), 5 ); wrefresh( w_border ); @@ -232,9 +228,6 @@ void auto_pickup_ui::show() iLine = 0; } else if( action == "QUIT" ) { break; - } else if( !tabs[iTab].available ) { - // this effectively disables all the following else branches, which are only useful - // for available tabs. } else if( action == "DOWN" ) { iLine++; iColumn = 1; @@ -376,10 +369,7 @@ void auto_pickup::show( const std::string &custom_name, const bool is_autopickup ui.title = custom_name; ui.tabs.emplace_back( _( "[]" ), global_rules ); - if( g->u.name.empty() ) { - ui.tabs.emplace_back( _( "[]" ), - _( "Please load a character first to use this page!" ) ); - } else { + if( !g->u.name.empty() ) { ui.tabs.emplace_back( _( "[]" ), character_rules ); } ui.is_autopickup = is_autopickup; diff --git a/src/auto_pickup.h b/src/auto_pickup.h index cb13fb4ad7b34..2d7e2fad40e9f 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -84,15 +84,10 @@ class auto_pickup_ui { public: std::string title; - bool available; - std::string unavailable_msg; auto_pickup_rule_list new_rules; std::reference_wrapper rules; - tab( const std::string &t, auto_pickup_rule_list &r ) : title( t ), available( true ), - new_rules( r ), rules( r ) { } - tab( const std::string &t, const std::string &u ) : title( t ), available( false ), - unavailable_msg( u ), new_rules(), rules( new_rules ) { } + tab( const std::string &t, auto_pickup_rule_list &r ) : title( t ), new_rules( r ), rules( r ) { } }; std::string title; From 1ead8fdf7640c8c49f7d828ce2b6bbf80e54837e Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 13:01:55 +0200 Subject: [PATCH 076/113] Split auto_pickup class into several classes: one base class, containing the cache, and one class for the player and for NPCs. Thereby we can move some functions that are only needed by NPCs and some that are only needed for the player into only those classes. --- src/auto_pickup.cpp | 94 +++++++++++++++++++++++++++++-------------- src/auto_pickup.h | 43 ++++++++++++++++---- src/npc.h | 4 +- src/npctalk_funcs.cpp | 3 +- 4 files changed, 102 insertions(+), 42 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index b9e11687c7bb2..6cb35deb0d3a6 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -34,11 +34,6 @@ auto_pickup &get_auto_pickup() return single_instance; } -void auto_pickup::show() -{ - show( _( " AUTO PICKUP MANAGER " ), true ); -} - void auto_pickup_ui::show() { if( tabs.empty() ) { @@ -363,16 +358,16 @@ void auto_pickup_ui::show() } } -void auto_pickup::show( const std::string &custom_name, const bool is_autopickup ) +void auto_pickup::show() { auto_pickup_ui ui; - ui.title = custom_name; + ui.title = _( " AUTO PICKUP MANAGER " ); ui.tabs.emplace_back( _( "[]" ), global_rules ); if( !g->u.name.empty() ) { ui.tabs.emplace_back( _( "[]" ), character_rules ); } - ui.is_autopickup = is_autopickup; + ui.is_autopickup = true; ui.show(); @@ -380,14 +375,11 @@ void auto_pickup::show( const std::string &custom_name, const bool is_autopickup return; } - // NPC pickup rules don't need to be saved explicitly - if( is_autopickup ) { - save_global(); - if( !g->u.name.empty() ) { - save_character(); - } + save_global(); + if( !g->u.name.empty() ) { + save_character(); } - map_items.ready = false; + invalidate(); } void auto_pickup_rule::test_pattern() const @@ -522,7 +514,7 @@ void auto_pickup::remove_rule( const item *it ) if( sRule.length() == it->sRule.length() && ci_find_substr( sRule, it->sRule ) != -1 ) { character_rules.erase( it ); - map_items.ready = false; + invalidate(); break; } } @@ -566,10 +558,9 @@ bool auto_pickup_rule::check_special_rule( const std::vector &mater } //Special case. Required for NPC harvest autopickup. Ignores material rules. -void auto_pickup::create_rule( const std::string &to_match ) +void npc_auto_pickup::create_rule( const std::string &to_match ) { - global_rules.create_rule( map_items, to_match ); - character_rules.create_rule( map_items, to_match ); + rules.create_rule( map_items, to_match ); } void auto_pickup_rule_list::create_rule( auto_pickup_cache &map_items, const std::string &to_match ) @@ -606,19 +597,13 @@ void auto_pickup_rule_list::create_rule( auto_pickup_cache &map_items, const ite } } -void auto_pickup::refresh_map_items() const +void auto_pickup::refresh_map_items( auto_pickup_cache &map_items ) const { - map_items.clear(); - map_items.temp_items.clear(); - //process include/exclude in order of rules, global first, then character specific //if a specific item is being added, all the rules need to be checked now //may have some performance issues since exclusion needs to check all items also global_rules.refresh_map_items( map_items ); character_rules.refresh_map_items( map_items ); - - map_items.ready = true; - map_items.temp_items.clear(); } void auto_pickup_rule_list::refresh_map_items( auto_pickup_cache &map_items ) const @@ -657,10 +642,10 @@ void auto_pickup_rule_list::refresh_map_items( auto_pickup_cache &map_items ) co } } -rule_state auto_pickup::check_item( const std::string &sItemName ) const +rule_state auto_pickup_base::check_item( const std::string &sItemName ) const { if( !map_items.ready ) { - refresh_map_items(); + recreate(); } const auto iter = map_items.find( sItemName ); @@ -674,7 +659,7 @@ rule_state auto_pickup::check_item( const std::string &sItemName ) const void auto_pickup::clear_character_rules() { character_rules.clear(); - map_items.ready = false; + invalidate(); } bool auto_pickup::save_character() @@ -733,7 +718,7 @@ void auto_pickup::load( const bool bCharacter ) } } - map_items.ready = false; + invalidate(); } void auto_pickup_rule::serialize( JsonOut &jsout ) const @@ -782,7 +767,7 @@ bool auto_pickup::load_legacy( const bool bCharacter ) sFile = g->get_player_base_save_path() + ".apu.txt"; } - map_items.ready = false; + invalidate(); auto &rules = bCharacter ? character_rules : global_rules; @@ -847,3 +832,50 @@ void auto_pickup_rule_list::load_legacy_rules( std::istream &fin ) } } } + +void npc_auto_pickup::show( const std::string &name ) +{ + auto_pickup_ui ui; + ui.title = string_format( _( "Pickup rules for %s" ), name ); + ui.tabs.emplace_back( name, rules ); + ui.show(); + // Don't need to save the rules here, it will be save along with the NPC object itself. + if( !ui.bStuffChanged ) { + return; + } + invalidate(); +} + +void npc_auto_pickup::serialize( JsonOut &jsout ) const +{ + rules.serialize( jsout ); +} + +void npc_auto_pickup::deserialize( JsonIn &jsin ) +{ + rules.deserialize( jsin ); +} + +void npc_auto_pickup::refresh_map_items( auto_pickup_cache &map_items ) const +{ + rules.refresh_map_items( map_items ); +} + +bool npc_auto_pickup::empty() const +{ + return rules.empty(); +} + +void auto_pickup_base::recreate() const +{ + map_items.clear(); + map_items.temp_items.clear(); + refresh_map_items( map_items ); + map_items.ready = true; + map_items.temp_items.clear(); +} + +void auto_pickup_base::invalidate() +{ + map_items.ready = false; +} diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 2d7e2fad40e9f..27948a2cde2de 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -99,32 +99,43 @@ class auto_pickup_ui bool bStuffChanged = false; }; -class auto_pickup +class auto_pickup_base +{ + protected: + mutable auto_pickup_cache map_items; + + void invalidate(); + + private: + virtual void refresh_map_items( auto_pickup_cache &map_items ) const = 0; + + void recreate() const; + + public: + rule_state check_item( const std::string &sItemName ) const; +}; + +class auto_pickup : public auto_pickup_base { private: void load( bool bCharacter ); bool save( bool bCharacter ); bool load_legacy( bool bCharacter ); - mutable auto_pickup_cache map_items; - auto_pickup_rule_list global_rules; auto_pickup_rule_list character_rules; - void refresh_map_items() const; //< Only modifies mutable state + void refresh_map_items( auto_pickup_cache &map_items ) const override; public: - void create_rule( const std::string &to_match ); void create_rule( const item *it ); bool has_rule( const item *it ); void add_rule( const item *it ); void remove_rule( const item *it ); void clear_character_rules(); - rule_state check_item( const std::string &sItemName ) const; void show(); - void show( const std::string &custom_name, bool is_autopickup = true ); bool save_character(); bool save_global(); void load_character(); @@ -133,6 +144,24 @@ class auto_pickup bool empty() const; }; +class npc_auto_pickup : public auto_pickup_base +{ + private: + auto_pickup_rule_list rules; + + void refresh_map_items( auto_pickup_cache &map_items ) const override; + + public: + void create_rule( const std::string &to_match ); + + void show( const std::string &name ); + + void serialize( JsonOut &json ) const; + void deserialize( JsonIn &jsin ); + + bool empty() const; +}; + auto_pickup &get_auto_pickup(); #endif diff --git a/src/npc.h b/src/npc.h index d82ba77ba51b2..eb24e616064e1 100644 --- a/src/npc.h +++ b/src/npc.h @@ -33,7 +33,7 @@ #include "item.h" #include "point.h" -class auto_pickup; +class npc_auto_pickup; struct bionic_data; class JsonObject; class JsonIn; @@ -422,7 +422,7 @@ struct npc_follower_rules { ally_rule override_enable; ally_rule overrides; - pimpl pickup_whitelist; + pimpl pickup_whitelist; npc_follower_rules(); diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index 6005a32ab3eb6..0941293a7d125 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -861,8 +861,7 @@ void talk_function::copy_npc_rules( npc &p ) void talk_function::set_npc_pickup( npc &p ) { - const std::string title = string_format( _( "Pickup rules for %s" ), p.name ); - p.rules.pickup_whitelist->show( title, false ); + p.rules.pickup_whitelist->show( p.name ); } void talk_function::npc_die( npc &p ) From 37c7934a80ba64c992cb9b21efb1e71dc74adf4d Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 13:26:23 +0200 Subject: [PATCH 077/113] Simplify the constructor of auto_pickup_rule --- src/auto_pickup.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 27948a2cde2de..38335b62029b8 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -45,10 +45,8 @@ class auto_pickup_rule auto_pickup_rule() = default; - auto_pickup_rule( const std::string &sRuleIn, bool bActiveIn, bool bExcludeIn ) { - this->sRule = sRuleIn; - this->bActive = bActiveIn; - this->bExclude = bExcludeIn; + auto_pickup_rule( const std::string &r, const bool a, const bool e ) : sRule( r ), bActive( a ), + bExclude( e ) { } void serialize( JsonOut &json ) const; From 8eb2e402cc611fa88173bc95a7d577b809c542c2 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 13:39:18 +0200 Subject: [PATCH 078/113] Move auto pickup classes into namespace To make their names shorter. Renamed `auto_pickup` to `player_settings` and renamed `npc_auto_pickup` analog. --- src/auto_pickup.cpp | 112 ++++++++++++++++++++++---------------------- src/auto_pickup.h | 54 +++++++++++---------- src/npc.h | 7 ++- 3 files changed, 91 insertions(+), 82 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 6cb35deb0d3a6..6eb15dec10aa0 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -28,13 +28,15 @@ #include "cursesdef.h" #include "item.h" -auto_pickup &get_auto_pickup() +using namespace auto_pickup; + +auto_pickup::player_settings &get_auto_pickup() { - static auto_pickup single_instance; + static auto_pickup::player_settings single_instance; return single_instance; } -void auto_pickup_ui::show() +void user_interface::show() { if( tabs.empty() ) { return; @@ -141,7 +143,7 @@ void auto_pickup_ui::show() std::ostringstream sTemp; while( true ) { - auto_pickup_rule_list &cur_rules = tabs[iTab].new_rules; + rule_list &cur_rules = tabs[iTab].new_rules; int locx = 17; for( size_t i = 0; i < tabs.size(); i++ ) { const auto color = iTab == i ? hilite( c_white ) : c_white; @@ -250,7 +252,7 @@ void auto_pickup_ui::show() iLine = cur_rules.size() - 1; } else if( allow_swapping && action == "SWAP_RULE_GLOBAL_CHAR" && currentPageNonEmpty ) { const size_t other_iTab = ( iTab + 1 ) % 2; - auto_pickup_rule_list &other_rules = tabs[other_iTab].new_rules; + rule_list &other_rules = tabs[other_iTab].new_rules; bStuffChanged = true; //copy over other_rules.push_back( cur_rules[iLine] ); @@ -261,7 +263,7 @@ void auto_pickup_ui::show() } else if( action == "ADD_RULE" || ( action == "CONFIRM" && currentPageNonEmpty ) ) { const int old_iLine = iLine; if( action == "ADD_RULE" ) { - cur_rules.push_back( auto_pickup_rule( "", true, false ) ); + cur_rules.push_back( rule( "", true, false ) ); iLine = cur_rules.size() - 1; } @@ -358,9 +360,9 @@ void auto_pickup_ui::show() } } -void auto_pickup::show() +void player_settings::show() { - auto_pickup_ui ui; + user_interface ui; ui.title = _( " AUTO PICKUP MANAGER " ); ui.tabs.emplace_back( _( "[]" ), global_rules ); @@ -382,7 +384,7 @@ void auto_pickup::show() invalidate(); } -void auto_pickup_rule::test_pattern() const +void rule::test_pattern() const { std::vector vMatchingItems; @@ -483,7 +485,7 @@ void auto_pickup_rule::test_pattern() const } } -bool auto_pickup::has_rule( const item *it ) +bool player_settings::has_rule( const item *it ) { const std::string &name = it->tname( 1 ); for( auto &elem : character_rules ) { @@ -494,9 +496,9 @@ bool auto_pickup::has_rule( const item *it ) return false; } -void auto_pickup::add_rule( const item *it ) +void player_settings::add_rule( const item *it ) { - character_rules.push_back( auto_pickup_rule( it->tname( 1, false ), true, false ) ); + character_rules.push_back( rule( it->tname( 1, false ), true, false ) ); create_rule( it ); if( !get_option( "AUTO_PICKUP" ) && @@ -506,7 +508,7 @@ void auto_pickup::add_rule( const item *it ) } } -void auto_pickup::remove_rule( const item *it ) +void player_settings::remove_rule( const item *it ) { const std::string sRule = it->tname( 1, false ); for( auto it = character_rules.begin(); @@ -520,13 +522,13 @@ void auto_pickup::remove_rule( const item *it ) } } -bool auto_pickup::empty() const +bool player_settings::empty() const { return global_rules.empty() && character_rules.empty(); } -bool auto_pickup_rule::check_special_rule( const std::vector &materials, - const std::string &rule ) +bool rule::check_special_rule( const std::vector &materials, + const std::string &rule ) { char type = ' '; std::vector filter; @@ -558,14 +560,14 @@ bool auto_pickup_rule::check_special_rule( const std::vector &mater } //Special case. Required for NPC harvest autopickup. Ignores material rules. -void npc_auto_pickup::create_rule( const std::string &to_match ) +void npc_settings::create_rule( const std::string &to_match ) { rules.create_rule( map_items, to_match ); } -void auto_pickup_rule_list::create_rule( auto_pickup_cache &map_items, const std::string &to_match ) +void rule_list::create_rule( cache &map_items, const std::string &to_match ) { - for( const auto_pickup_rule &elem : *this ) { + for( const rule &elem : *this ) { if( !elem.bActive || !wildcard_match( to_match, elem.sRule ) ) { continue; } @@ -574,21 +576,21 @@ void auto_pickup_rule_list::create_rule( auto_pickup_cache &map_items, const std } } -void auto_pickup::create_rule( const item *it ) +void player_settings::create_rule( const item *it ) { // @todo change it to be a reference global_rules.create_rule( map_items, *it ); character_rules.create_rule( map_items, *it ); } -void auto_pickup_rule_list::create_rule( auto_pickup_cache &map_items, const item &it ) +void rule_list::create_rule( cache &map_items, const item &it ) { const std::string to_match = it.tname( 1, false ); - for( const auto_pickup_rule &elem : *this ) { + for( const rule &elem : *this ) { if( !elem.bActive ) { continue; - } else if( !auto_pickup_rule::check_special_rule( it.made_of(), elem.sRule ) && + } else if( !rule::check_special_rule( it.made_of(), elem.sRule ) && !wildcard_match( to_match, elem.sRule ) ) { continue; } @@ -597,7 +599,7 @@ void auto_pickup_rule_list::create_rule( auto_pickup_cache &map_items, const ite } } -void auto_pickup::refresh_map_items( auto_pickup_cache &map_items ) const +void player_settings::refresh_map_items( cache &map_items ) const { //process include/exclude in order of rules, global first, then character specific //if a specific item is being added, all the rules need to be checked now @@ -606,9 +608,9 @@ void auto_pickup::refresh_map_items( auto_pickup_cache &map_items ) const character_rules.refresh_map_items( map_items ); } -void auto_pickup_rule_list::refresh_map_items( auto_pickup_cache &map_items ) const +void rule_list::refresh_map_items( cache &map_items ) const { - for( const auto_pickup_rule &elem : *this ) { + for( const rule &elem : *this ) { if( elem.sRule.empty() || !elem.bActive ) { continue; } @@ -618,7 +620,7 @@ void auto_pickup_rule_list::refresh_map_items( auto_pickup_cache &map_items ) co for( const itype *e : item_controller->all() ) { const std::string &cur_item = e->nname( 1 ); - if( !auto_pickup_rule::check_special_rule( e->materials, elem.sRule ) && + if( !rule::check_special_rule( e->materials, elem.sRule ) && !wildcard_match( cur_item, elem.sRule ) ) { continue; } @@ -630,8 +632,8 @@ void auto_pickup_rule_list::refresh_map_items( auto_pickup_cache &map_items ) co //only re-exclude items from the existing mapping for now //new exclusions will process during pickup attempts for( auto &map_item : map_items ) { - if( !auto_pickup_rule::check_special_rule( map_items.temp_items[ map_item.first ]->materials, - elem.sRule ) && + if( !rule::check_special_rule( map_items.temp_items[ map_item.first ]->materials, + elem.sRule ) && !wildcard_match( map_item.first, elem.sRule ) ) { continue; } @@ -642,7 +644,7 @@ void auto_pickup_rule_list::refresh_map_items( auto_pickup_cache &map_items ) co } } -rule_state auto_pickup_base::check_item( const std::string &sItemName ) const +rule_state base_settings::check_item( const std::string &sItemName ) const { if( !map_items.ready ) { recreate(); @@ -656,23 +658,23 @@ rule_state auto_pickup_base::check_item( const std::string &sItemName ) const return RULE_NONE; } -void auto_pickup::clear_character_rules() +void player_settings::clear_character_rules() { character_rules.clear(); invalidate(); } -bool auto_pickup::save_character() +bool player_settings::save_character() { return save( true ); } -bool auto_pickup::save_global() +bool player_settings::save_global() { return save( false ); } -bool auto_pickup::save( const bool bCharacter ) +bool player_settings::save( const bool bCharacter ) { auto savefile = FILENAMES["autopickup"]; @@ -691,17 +693,17 @@ bool auto_pickup::save( const bool bCharacter ) }, _( "autopickup configuration" ) ); } -void auto_pickup::load_character() +void player_settings::load_character() { load( true ); } -void auto_pickup::load_global() +void player_settings::load_global() { load( false ); } -void auto_pickup::load( const bool bCharacter ) +void player_settings::load( const bool bCharacter ) { std::string sFile = FILENAMES["autopickup"]; if( bCharacter ) { @@ -721,7 +723,7 @@ void auto_pickup::load( const bool bCharacter ) invalidate(); } -void auto_pickup_rule::serialize( JsonOut &jsout ) const +void rule::serialize( JsonOut &jsout ) const { jsout.start_object(); jsout.member( "rule", sRule ); @@ -730,16 +732,16 @@ void auto_pickup_rule::serialize( JsonOut &jsout ) const jsout.end_object(); } -void auto_pickup_rule_list::serialize( JsonOut &jsout ) const +void rule_list::serialize( JsonOut &jsout ) const { jsout.start_array(); - for( const auto_pickup_rule &elem : *this ) { + for( const rule &elem : *this ) { elem.serialize( jsout ); } jsout.end_array(); } -void auto_pickup_rule::deserialize( JsonIn &jsin ) +void rule::deserialize( JsonIn &jsin ) { JsonObject jo = jsin.get_object(); sRule = jo.get_string( "rule" ); @@ -747,19 +749,19 @@ void auto_pickup_rule::deserialize( JsonIn &jsin ) bExclude = jo.get_bool( "exclude" ); } -void auto_pickup_rule_list::deserialize( JsonIn &jsin ) +void rule_list::deserialize( JsonIn &jsin ) { clear(); jsin.start_array(); while( !jsin.end_array() ) { - auto_pickup_rule tmp; + rule tmp; tmp.deserialize( jsin ); push_back( tmp ); } } -bool auto_pickup::load_legacy( const bool bCharacter ) +bool player_settings::load_legacy( const bool bCharacter ) { std::string sFile = FILENAMES["legacy_autopickup2"]; @@ -772,7 +774,7 @@ bool auto_pickup::load_legacy( const bool bCharacter ) auto &rules = bCharacter ? character_rules : global_rules; using namespace std::placeholders; - const auto &reader = std::bind( &auto_pickup_rule_list::load_legacy_rules, std::ref( rules ), _1 ); + const auto &reader = std::bind( &rule_list::load_legacy_rules, std::ref( rules ), _1 ); if( !read_from_file_optional( sFile, reader ) ) { if( !bCharacter ) { return read_from_file_optional( FILENAMES["legacy_autopickup"], reader ); @@ -784,7 +786,7 @@ bool auto_pickup::load_legacy( const bool bCharacter ) return true; } -void auto_pickup_rule_list::load_legacy_rules( std::istream &fin ) +void rule_list::load_legacy_rules( std::istream &fin ) { clear(); @@ -827,15 +829,15 @@ void auto_pickup_rule_list::load_legacy_rules( std::istream &fin ) } while( iPos != std::string::npos ); - push_back( auto_pickup_rule( sRule, bActive, bExclude ) ); + push_back( rule( sRule, bActive, bExclude ) ); } } } } -void npc_auto_pickup::show( const std::string &name ) +void npc_settings::show( const std::string &name ) { - auto_pickup_ui ui; + user_interface ui; ui.title = string_format( _( "Pickup rules for %s" ), name ); ui.tabs.emplace_back( name, rules ); ui.show(); @@ -846,27 +848,27 @@ void npc_auto_pickup::show( const std::string &name ) invalidate(); } -void npc_auto_pickup::serialize( JsonOut &jsout ) const +void npc_settings::serialize( JsonOut &jsout ) const { rules.serialize( jsout ); } -void npc_auto_pickup::deserialize( JsonIn &jsin ) +void npc_settings::deserialize( JsonIn &jsin ) { rules.deserialize( jsin ); } -void npc_auto_pickup::refresh_map_items( auto_pickup_cache &map_items ) const +void npc_settings::refresh_map_items( cache &map_items ) const { rules.refresh_map_items( map_items ); } -bool npc_auto_pickup::empty() const +bool npc_settings::empty() const { return rules.empty(); } -void auto_pickup_base::recreate() const +void base_settings::recreate() const { map_items.clear(); map_items.temp_items.clear(); @@ -875,7 +877,7 @@ void auto_pickup_base::recreate() const map_items.temp_items.clear(); } -void auto_pickup_base::invalidate() +void base_settings::invalidate() { map_items.ready = false; } diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 38335b62029b8..cf15db44aa94d 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -16,13 +16,16 @@ class JsonIn; class item; struct itype; +namespace auto_pickup +{ + /** * The currently-active set of auto-pickup rules, in a form that allows quick * lookup. When this is filled (by @ref auto_pickup::create_rule()), every * item existing in the game that matches a rule (either white- or blacklist) * is added as the key, with RULE_WHITELISTED or RULE_BLACKLISTED as the values. */ -class auto_pickup_cache : public std::unordered_map +class cache : public std::unordered_map { public: /// Defines whether this cache has been filled. @@ -33,20 +36,19 @@ class auto_pickup_cache : public std::unordered_map }; /** - * A single entry in the list of auto pickup entries @ref auto_pickup_rule_list. + * A single entry in the list of auto pickup entries @ref rule_list. * The data contained can be edited by the player and determines what to pick/ignore. */ -class auto_pickup_rule +class rule { public: std::string sRule; bool bActive = false; bool bExclude = false; - auto_pickup_rule() = default; + rule() = default; - auto_pickup_rule( const std::string &r, const bool a, const bool e ) : sRule( r ), bActive( a ), - bExclude( e ) { + rule( const std::string &r, const bool a, const bool e ) : sRule( r ), bActive( a ), bExclude( e ) { } void serialize( JsonOut &json ) const; @@ -61,7 +63,7 @@ class auto_pickup_rule /** * A list of rules. This is primarily a container with a few convenient functions (like saving/loading). */ -class auto_pickup_rule_list : public std::vector +class rule_list : public std::vector { public: void serialize( JsonOut &json ) const; @@ -69,23 +71,23 @@ class auto_pickup_rule_list : public std::vector void load_legacy_rules( std::istream &fin ); - void refresh_map_items( auto_pickup_cache &map_items ) const; + void refresh_map_items( cache &map_items ) const; - void create_rule( auto_pickup_cache &map_items, const std::string &to_match ); - void create_rule( auto_pickup_cache &map_items, const item &it ); + void create_rule( cache &map_items, const std::string &to_match ); + void create_rule( cache &map_items, const item &it ); }; -class auto_pickup_ui +class user_interface { public: class tab { public: std::string title; - auto_pickup_rule_list new_rules; - std::reference_wrapper rules; + rule_list new_rules; + std::reference_wrapper rules; - tab( const std::string &t, auto_pickup_rule_list &r ) : title( t ), new_rules( r ), rules( r ) { } + tab( const std::string &t, rule_list &r ) : title( t ), new_rules( r ), rules( r ) { } }; std::string title; @@ -97,15 +99,15 @@ class auto_pickup_ui bool bStuffChanged = false; }; -class auto_pickup_base +class base_settings { protected: - mutable auto_pickup_cache map_items; + mutable cache map_items; void invalidate(); private: - virtual void refresh_map_items( auto_pickup_cache &map_items ) const = 0; + virtual void refresh_map_items( cache &map_items ) const = 0; void recreate() const; @@ -113,17 +115,17 @@ class auto_pickup_base rule_state check_item( const std::string &sItemName ) const; }; -class auto_pickup : public auto_pickup_base +class player_settings : public base_settings { private: void load( bool bCharacter ); bool save( bool bCharacter ); bool load_legacy( bool bCharacter ); - auto_pickup_rule_list global_rules; - auto_pickup_rule_list character_rules; + rule_list global_rules; + rule_list character_rules; - void refresh_map_items( auto_pickup_cache &map_items ) const override; + void refresh_map_items( cache &map_items ) const override; public: void create_rule( const item *it ); @@ -142,12 +144,12 @@ class auto_pickup : public auto_pickup_base bool empty() const; }; -class npc_auto_pickup : public auto_pickup_base +class npc_settings : public base_settings { private: - auto_pickup_rule_list rules; + rule_list rules; - void refresh_map_items( auto_pickup_cache &map_items ) const override; + void refresh_map_items( cache &map_items ) const override; public: void create_rule( const std::string &to_match ); @@ -160,6 +162,8 @@ class npc_auto_pickup : public auto_pickup_base bool empty() const; }; -auto_pickup &get_auto_pickup(); +} // namespace auto_pickup + +auto_pickup::player_settings &get_auto_pickup(); #endif diff --git a/src/npc.h b/src/npc.h index eb24e616064e1..6591eb5cc49d0 100644 --- a/src/npc.h +++ b/src/npc.h @@ -33,7 +33,10 @@ #include "item.h" #include "point.h" -class npc_auto_pickup; +namespace auto_pickup +{ +class npc_settings; +} // namespace auto_pickup struct bionic_data; class JsonObject; class JsonIn; @@ -422,7 +425,7 @@ struct npc_follower_rules { ally_rule override_enable; ally_rule overrides; - pimpl pickup_whitelist; + pimpl pickup_whitelist; npc_follower_rules(); From 58c1d7c25cd3b3d4e07bca87132ecfb75ff0170f Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 13:41:33 +0200 Subject: [PATCH 079/113] Replace formatting via stringstream with string_format --- src/auto_pickup.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 6eb15dec10aa0..df84837ccfe5a 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -140,8 +139,6 @@ void user_interface::show() ctxt.register_action( "SWITCH_AUTO_PICKUP_OPTION" ); } - std::ostringstream sTemp; - while( true ) { rule_list &cur_rules = tabs[iTab].new_rules; int locx = 17; @@ -186,9 +183,7 @@ void user_interface::show() static_cast( cur_rules.size() ) : iContentHeight ) ) { nc_color cLineColor = cur_rules[i].bActive ? c_white : c_light_gray; - sTemp.str( "" ); - sTemp << i + 1; - mvwprintz( w, point( 1, i - iStartPos ), cLineColor, sTemp.str() ); + mvwprintz( w, point( 1, i - iStartPos ), cLineColor, "%d", i + 1 ); mvwprintz( w, point( 5, i - iStartPos ), cLineColor, "" ); if( iLine == i ) { @@ -411,7 +406,6 @@ void rule::test_pattern() const int iStartPos = 0; const int iContentHeight = FULL_SCREEN_HEIGHT - 8; const int iContentWidth = FULL_SCREEN_WIDTH - 30; - std::ostringstream sTemp; const catacurses::window w_test_rule_border = catacurses::newwin( iContentHeight + 2, iContentWidth, point( iOffsetX, iOffsetY ) ); @@ -451,9 +445,7 @@ void rule::test_pattern() const static_cast( vMatchingItems.size() ) : iContentHeight ) ) { nc_color cLineColor = c_white; - sTemp.str( "" ); - sTemp << i + 1; - mvwprintz( w_test_rule_content, point( 0, i - iStartPos ), cLineColor, sTemp.str() ); + mvwprintz( w_test_rule_content, point( 0, i - iStartPos ), cLineColor, "%d", i + 1 ); mvwprintz( w_test_rule_content, point( 4, i - iStartPos ), cLineColor, "" ); if( iLine == i ) { From e66b6016bde70324e1a1045fa1814f31a2bad83c Mon Sep 17 00:00:00 2001 From: BevapDin Date: Sun, 18 Aug 2019 14:28:10 +0200 Subject: [PATCH 080/113] Move auto_pickup::rule::check_special_rule into anonymous namespace Does not need to be exposed in the header. --- src/auto_pickup.cpp | 17 ++++++++--------- src/auto_pickup.h | 3 --- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index df84837ccfe5a..bd7d4a5d0d81e 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -29,6 +29,9 @@ using namespace auto_pickup; +static bool check_special_rule( const std::vector &materials, + const std::string &rule ); + auto_pickup::player_settings &get_auto_pickup() { static auto_pickup::player_settings single_instance; @@ -391,8 +394,7 @@ void rule::test_pattern() const //APU now ignores prefixes, bottled items and suffix combinations still not generated for( const itype *e : item_controller->all() ) { const std::string sItemName = e->nname( 1 ); - if( !check_special_rule( e->materials, sRule ) && - !wildcard_match( sItemName, sRule ) ) { + if( !check_special_rule( e->materials, sRule ) && !wildcard_match( sItemName, sRule ) ) { continue; } @@ -519,8 +521,7 @@ bool player_settings::empty() const return global_rules.empty() && character_rules.empty(); } -bool rule::check_special_rule( const std::vector &materials, - const std::string &rule ) +bool check_special_rule( const std::vector &materials, const std::string &rule ) { char type = ' '; std::vector filter; @@ -582,7 +583,7 @@ void rule_list::create_rule( cache &map_items, const item &it ) for( const rule &elem : *this ) { if( !elem.bActive ) { continue; - } else if( !rule::check_special_rule( it.made_of(), elem.sRule ) && + } else if( !check_special_rule( it.made_of(), elem.sRule ) && !wildcard_match( to_match, elem.sRule ) ) { continue; } @@ -612,8 +613,7 @@ void rule_list::refresh_map_items( cache &map_items ) const for( const itype *e : item_controller->all() ) { const std::string &cur_item = e->nname( 1 ); - if( !rule::check_special_rule( e->materials, elem.sRule ) && - !wildcard_match( cur_item, elem.sRule ) ) { + if( !check_special_rule( e->materials, elem.sRule ) && !wildcard_match( cur_item, elem.sRule ) ) { continue; } @@ -624,8 +624,7 @@ void rule_list::refresh_map_items( cache &map_items ) const //only re-exclude items from the existing mapping for now //new exclusions will process during pickup attempts for( auto &map_item : map_items ) { - if( !rule::check_special_rule( map_items.temp_items[ map_item.first ]->materials, - elem.sRule ) && + if( !check_special_rule( map_items.temp_items[ map_item.first ]->materials, elem.sRule ) && !wildcard_match( map_item.first, elem.sRule ) ) { continue; } diff --git a/src/auto_pickup.h b/src/auto_pickup.h index cf15db44aa94d..203ecb2729ee9 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -55,9 +55,6 @@ class rule void deserialize( JsonIn &jsin ); void test_pattern() const; - - static bool check_special_rule( const std::vector &materials, - const std::string &rule ); }; /** From d66ba04fce667d9bb84ad6de4196d69eaf3b77c7 Mon Sep 17 00:00:00 2001 From: RedShakespeare Date: Sun, 18 Aug 2019 22:52:40 +0800 Subject: [PATCH 081/113] Fix xl survivor suit and heavy survivor suit's uncraft recipes As above --- data/json/uncraft/armor/suit.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/json/uncraft/armor/suit.json b/data/json/uncraft/armor/suit.json index 050c2d25f1256..52612425dd4e9 100644 --- a/data/json/uncraft/armor/suit.json +++ b/data/json/uncraft/armor/suit.json @@ -6,7 +6,7 @@ "difficulty": 3, "time": "5 m", "qualities": [ { "id": "CUT", "level": 1 } ], - "components": [ [ [ "rag", 33 ] ], [ [ "leather", 35 ] ], [ [ "scrap", 24 ] ], [ [ "kevlar", 48 ] ] ] + "components": [ [ [ "rag", 33 ] ], [ [ "leather", 35 ] ], [ [ "scrap", 24 ] ], [ [ "kevlar_plate", 48 ] ] ] }, { "result": "xlsurvivor_suit", @@ -15,6 +15,6 @@ "difficulty": 3, "time": "150 s", "qualities": [ { "id": "CUT", "level": 1 } ], - "components": [ [ [ "rag", 23 ] ], [ [ "leather", 25 ] ], [ [ "scrap", 12 ] ], [ [ "kevlar", 24 ] ] ] + "components": [ [ [ "rag", 23 ] ], [ [ "leather", 25 ] ], [ [ "scrap", 12 ] ], [ [ "kevlar_plate", 24 ] ] ] } ] From 8686806b02a860629f7261e1ce40c411cdc3f063 Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sun, 28 Jul 2019 01:53:37 +0300 Subject: [PATCH 082/113] Jsonify sewage plant --- data/json/mapgen/sewage_treatment.json | 597 ++++++++++++++++++ .../overmap/overmap_special/specials.json | 38 +- .../overmap_terrain_waste_junk.json | 86 ++- src/mapgen.cpp | 262 -------- src/overmap.cpp | 3 - 5 files changed, 692 insertions(+), 294 deletions(-) create mode 100644 data/json/mapgen/sewage_treatment.json diff --git a/data/json/mapgen/sewage_treatment.json b/data/json/mapgen/sewage_treatment.json new file mode 100644 index 0000000000000..5016eefbe97d5 --- /dev/null +++ b/data/json/mapgen/sewage_treatment.json @@ -0,0 +1,597 @@ +[ + { + "type": "palette", + "id": "sewage_treatment_palette", + "terrain": { + " ": [ "t_dirt", "t_grass" ], + "?": "t_shrub", + ")": "t_water_pool_shallow", + ".": "t_pavement", + "_": "t_sidewalk", + "p": "t_pavement_y", + "|": "t_chainfence", + "C": "t_chaingate_l", + "~": "t_sewage", + "!": "t_metal_railing", + "@": "t_grate", + "w": "t_water_pool", + "A": "t_dirt", + "1": "t_sewage_pipe", + "&": "t_sewage_pump", + "0": "t_manhole_cover", + "O": "t_thconc_floor", + "H": "t_sconc_wall", + "z": "t_concrete", + "-": "t_wall_metal", + "W": "t_window_no_curtains", + "t": "t_thconc_floor", + "m": "t_metal_floor", + "b": "t_door_metal_pickable", + "e": "t_door_metal_locked", + "D": "t_door_glass_c", + "6": "t_console_broken", + "+": "t_door_c", + ",": "t_floor", + "M": "t_metal_floor", + "<": "t_ladder_up", + ">": "t_stairs_down", + "%": "t_machinery_heavy", + "$": "t_machinery_light", + "{": "t_thconc_floor", + "R": "t_thconc_floor", + "J": "t_current_trans", + "U": "t_sai_box", + "G": "t_generator_broken", + "F": "t_potential_trans", + "7": "t_metal_floor", + "4": "t_metal_floor", + "g": "t_metal_floor", + "Y": "t_switchgear_s" + } + }, + { + "type": "palette", + "id": "sewage_treatment_sewer_palette", + "terrain": { + "c": "t_thconc_floor", + "l": "t_thconc_floor", + "L": "t_thconc_floor", + "n": "t_thconc_floor", + "{": "t_thconc_floor", + "f": "t_thconc_floor", + ";": "t_thconc_floor", + "q": "t_thconc_floor", + "r": "t_thconc_floor", + "w": "t_thconc_floor", + "t": "t_thconc_floor", + "0": "t_thconc_floor", + "[": "t_thconc_floor", + "I": "t_thconc_floor", + "h": "t_thconc_floor", + "D": "t_thconc_floor", + "1": "t_thconc_floor", + ">": "t_stairs_up", + "!": "t_bars", + "~": "t_sewage", + "`": "t_sewage", + "%": "t_rock", + ".": "t_thconc_floor", + "^": "t_ladder_up", + "*": "t_door_bar_locked", + "x": "t_bridge", + "#": "t_grate", + "b": "t_door_metal_pickable", + "H": "t_sconc_wall", + "2": "t_sewage_pipe", + "U": "t_sai_box", + "G": "t_generator_broken", + "Y": "t_switchgear_s", + "&": "t_sewage_pump", + "-": "t_wall_glass", + "A": "t_railing_h", + "a": "t_railing_v", + "|": "t_chainfence", + "C": "t_chaingate_l", + "$": "t_machinery_light", + "@": "t_machinery_heavy", + "v": "t_machinery_old", + "+": "t_door_c", + "6": "t_console_broken" + } + }, + { + "id": "treatment_chemicals", + "type": "item_group", + "items": [ + { "item": "bleach", "container-item": "55gal_drum", "charges-min": 10, "charges-max": 126, "chance": 50 }, + { + "item": "chem_sulphuric_acid", + "container-item": "55gal_drum", + "charges-min": 2, + "charges-max": 50, + "chance": 20 + }, + { + "item": "material_quicklime", + "container-item": "55gal_drum", + "charges-min": 2, + "charges-max": 50, + "chance": 20 + }, + { "item": "55gal_drum", "chance": 50 } + ] + }, + { + "id": "sewage_samples", + "type": "item_group", + "items": [ + { "item": "sewage", "container-item": "flask_glass", "charges": 1, "chance": 50 }, + { "item": "water", "container-item": "flask_glass", "charges": 1, "chance": 50 }, + { "item": "water_clean", "container-item": "flask_glass", "charges": 1, "chance": 30 }, + { "item": "slime_scrap", "container-item": "flask_glass", "charges": 1, "chance": 10 } + ] + }, + { + "type": "monstergroup", + "name": "GROUP_SEWAGE_TREATMENT", + "default": "mon_sewer_rat", + "is_animal": true, + "monsters": [ + { "monster": "mon_sewer_fish", "freq": 300, "cost_multiplier": 0, "pack_size": [ 2, 6 ] }, + { "monster": "mon_sewer_snake", "freq": 240, "cost_multiplier": 0 }, + { "monster": "mon_sewer_rat", "freq": 100, "cost_multiplier": 0, "pack_size": [ 3, 6 ] }, + { "monster": "mon_albino_penguin", "freq": 5, "cost_multiplier": 5, "pack_size": [ 3, 9 ] }, + { "monster": "mon_gator", "freq": 40, "cost_multiplier": 2, "pack_size": [ 1, 2 ] } + ] + }, + { + "type": "mapgen", + "method": "json", + "om_terrain": [ [ "sewage_treatment_0_0_0", "sewage_treatment_1_0_0" ], [ "sewage_treatment_0_1_0", "sewage_treatment_1_1_0" ] ], + "weight": 250, + "object": { + "fill_ter": "t_floor", + "rows": [ + "|||_.......pp......._|||||||||||||||||||||||||||", + "| _................_ ? ? ? ??? ? ? |", + "| _.......pp......._ HHWHWHHHWHWWWHWHHHWHH |", + "| _................_ ? H^,6#,H,d,,,,,d,H^d,H |", + "| _.......pp......._____W,,d,,H#6,,#,,6#H,6#W?|", + "| _................_ _D,,,,,D,,,666,,,+,d,H |", + "|___................___ H^[[,^H,,,,,,,,,H,,,W?|", + "|.....................__ HHHH+HHqr*,,,[[qH[[[H |", + "|.....................__?W##,,fHHHHHDHHHHHHHHH |", + "|.....................__ Hdd,,cH,,,,,,,,,8HtH |", + "|......p......p.......__ HH+HH+H,,HH+HH+HbHHHH |", + "|.....................__ Hl,Hl,H,,Hx,Hx,Hm74%H |", + "|......p......p.......__ Hl,Hl,H,,H,,H,,HmmmgH |", + "|.....................__ Hl,Hl,H,,HrTHrTHmmm{H |", + "||||||||||||||||||||||CC|HHHHHHH++HHHHHHH{mm{H |", + "|zzzzzzzzzzzzzzzzzz __ AAA __ H{mm{H |", + "|zwwwwwwwwm)))))))z __ __ ? ? ?H{mm{H |", + "|zwwwwwwwwm)))))))z __ __ H{mm{H |", + "|zzzzzzzzzzzzzzzzzz____________________ HmmMMH |", + "|zwwwwwwwwmwwwwwwwz __________________bmmMMH |", + "|zwwwwwwwwmwwwwwwwz __ HHHHHH |", + "|zzzzzzzzzzzzzzzzzz111111111111 __ |", + "||||||C|||||||||||||1|||||||||||||| __ |", + "| zzzzzzz 1111111111 ______OOO |", + "| zzwwwwwzz 1HHHHHHH1 ? ? HHHHHHHH __ --b--- |", + "|zzwwwwwwwzz1H11&%RH0 HJJFUYYH __ -&m$&- |", + "|zwwwwwwwwwz H1ttttH ? ? WgttttgW __ -%mm%- |", + "|zwwwwwwwwwz H|||C|H H6ttttGH __ W&mm&W |", + "|zwww!!!wwwz _ ? ? |||CC||| __ -Mmm%- |", + "|zwww!@!wwwz OO _ __ __ -Rmm&- |", + "|zwww!@!wwwz OO _ _________________bmmm%W |", + "|zzww!@!wwzz____________________________-&%$&- |", + "| zzw!@!wzz_____________ __ --W--- |", + "| zzzzzzz_________ __ O |", + "| zzzzzzz____zzzzzzz zzzzzzzzzzzzzzzzzz 1 |", + "| zz)))))zz__zzw!@!wzz z~~~~zz~~~~zz~~~~z 1 |", + "|zz)))))))zzzzww!@!wwzz z~~~~zz~~~~zz~~~~z 1 |", + "|z)))))))))zzwww!@!wwwz z~~~~zz~~~~zz~~~~z 11|", + "|z))))!!!!!zzwww!@!wwwz z~~~~zz~~~~zz~~~~z $1|", + "|z))))!@@@@zzwww!!!wwwz z~~~~zz~~~~zz~~~~z111|", + "|z))))!!!!!zzwwwwwwwwwz z~~~~zz~~~~zz~~~~z 1 |", + "|z)))))))))zzwwwwwwwwwz z~~~~zz~~~~zz~~~~z11 |", + "|zz)))))))zzzzwwwwwwwzz z~~~~zz~~~~zz~~~~z 1 |", + "| zz)))))zz zzwwwwwzz z~~~~zz~~~~zz~~~~z11 |", + "| zzzzzzz zzzzzzz zzzzzzzzzzzzzzzzzz |", + "||||||||||||||||||||||||||||||||||||||||||||||||" + ], + "palettes": [ "sewage_treatment_palette" ], + "furniture": { + "#": "f_chair", + "x": "f_sink", + "4": "f_heavy_lathe", + "7": "f_drill_press", + "*": "f_shredder", + "[": "f_glass_cabinet", + "^": "f_indoor_plant", + "A": "f_dumpster", + "c": "f_counter", + "R": "f_rack", + "d": "f_desk", + "f": "f_fridge", + "g": "f_workbench", + "q": "f_indoor_plant_y", + "l": "f_locker", + "r": "f_trashcan", + "{": "f_utility_shelf", + "O": "f_standing_tank" + }, + "place_signs": [ + { "signage": "Authorized personnel only", "x": 21, "y": 1 }, + { "signage": " sewage treatment plant", "x": 2, "y": 1 } + ], + "place_liquids": [ + { "liquid": "sewage", "chance": 1, "amount": [ 2, 3 ], "x": [ 43, 45 ], "y": 25, "repeat": [ 1, 3 ] }, + { "liquid": "water", "chance": 1, "amount": [ 40, 60 ], "x": [ 13, 14 ], "y": [ 31, 32 ], "repeat": [ 2, 4 ] } + ], + "items": { + "g": { "item": "supplies_hardware", "chance": 40 }, + "R": { "item": "tools_plumbing", "chance": 60 }, + "M": { "item": "treatment_chemicals", "chance": 80 }, + "A": { "item": "trash", "chance": 80 }, + "{": [ { "item": "sewage_plant", "chance": 30 }, { "item": "supplies_plumbing", "chance": 20 } ], + "f": { "item": "fridgesnacks", "chance": 70, "repeat": [ 1, 3 ] }, + "c": { "item": "office_breakroom", "chance": 60, "repeat": [ 1, 2 ] }, + "l": { "item": "clothing_work_set", "chance": 40 }, + "d": { "item": "office", "chance": 60 }, + "a": { "item": "trash", "chance": 30, "repeat": [ 1, 3 ] }, + "r": { "item": "trash", "chance": 30 }, + "[": { "item": "office_mess", "chance": 50, "repeat": [ 1, 3 ] } + }, + "computers": { + "8": { + "name": "EnviroCom OS v2.03 - Basement Access", + "security": 1, + "options": [ { "name": "Unlock stairs", "action": "open" } ], + "failures": [ { "action": "shutdown" }, { "action": "alarm" } ] + } + }, + "toilets": { "T": { } }, + "place_vehicles": [ + { "vehicle": "pump_station_vehicles", "x": 5, "y": 13, "rotation": 90, "chance": 40 }, + { "vehicle": "pump_station_vehicles", "x": 11, "y": 13, "rotation": 90, "chance": 40 }, + { "vehicle": "pump_station_vehicles", "x": 19, "y": 13, "rotation": 90, "chance": 40 } + ], + "place_monsters": [ + { "monster": "GROUP_ZOMBIE", "x": [ 33, 40 ], "y": [ 3, 11 ], "density": 0.2 }, + { "monster": "GROUP_ZOMBIE", "x": [ 25, 44 ], "y": [ 32, 36 ], "density": 0.2 } + ] + } + }, + { + "type": "mapgen", + "method": "json", + "om_terrain": [ + [ "sewage_treatment_0_0_roof", "sewage_treatment_1_0_roof" ], + [ "sewage_treatment_0_1_roof", "sewage_treatment_1_1_roof" ] + ], + "object": { + "fill_ter": "t_flat_roof", + "rows": [ + " ", + " ", + " |22222222222222222225 ", + " |...................3 ", + " |................XX.3 ", + " |................XX.3 ", + " |...................3 ", + " |...................3 ", + " |.................### ", + " |.................#># ", + " |.................### ", + " |...................3 ", + " |...................3 ", + " |...................3 ", + " |...................3 ", + " |...................3 ", + " |--------------|....3 ", + " |....3 ", + " |....3 ", + " |....3 ", + " |....3 ", + " |....3 ", + " |----3 ", + " ", + " ", + " ", + " ........ ...... ", + " ....... ........ ...... ", + " ....... ........ ...... ", + " ....... ........ ...... ", + " ....... ........ ...... ", + " ...... ", + " ...... ", + " ...... ", + " ...... ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " + ], + "palettes": [ "roof_palette" ], + "terrain": { ">": "t_ladder_down", "X": "t_radio_tower" }, + "place_nested": [ + { + "chunks": [ [ "null", 20 ], [ "roof_4x4_utility", 50 ], [ "roof_4x4_utility_1", 40 ] ], + "x": [ 29, 36 ], + "y": [ 5, 10 ] + } + ] + } + }, + { + "type": "mapgen", + "method": "json", + "om_terrain": [ + [ "sewage_treatment_0_0_-1", "sewage_treatment_1_0_-1", "sewage_treatment_2_0_-1" ], + [ "sewage_treatment_0_1_-1", "sewage_treatment_1_1_-1", "sewage_treatment_2_1_-1" ] + ], + "weight": 250, + "object": { + "fill_ter": "t_rock_floor", + "rows": [ + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~~~~%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", + "%%%%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%%%%", + "%%%%~###########################~~~~~~~~###########################~%%%%", + "%%%%~#222222222HHHbHHHH%%%%%%%%#%%AAAA%%#%%%%%HHHHbHHH222222222222#~%%%%", + "%%%%~#2%%%%%%%22&....UH%%%%%%%%##xxxxxx##%%%%%HU....&22%%%%%%%%%%2#~%%%%", + "%%%%~#2%%%%%%%%H$&$&@&H%%HHHHHHHHHHHHHHHHHHH%%H&@&$&$H%%%%%%%%%%%2#~%%%%", + "%%%%~#2%%%%%%%%HHHHHHHH%%H0001[.IHD6[[D61.IH%%HHHHHHHH%%%%%%%%%%%2#~%%%%", + "%%%%~#22%%%%%%%%%%%%%%%%%H0c....fH.c...c..fHHHHHLH%%%%%%%%%%%%%%22#~%%%%", + "%%%%`##2%%%%%%%%%%%%%%%%%Hh......+.........+...+.H%%%%%%%%%%%%%%2##`%%%%", + "%%%%!%#2%%%%%%%HHHH%%%%%%H0c....fH.c...c..fHH..HLH%%%%%%%%%%%%%%2#%!%%%%", + "~~~~~~x2~~~~%%%HL.H%%%%%%H0001[.IHD6[[D61.IHH..HHHHHHHHHHH%%~~~~2x~~~~~~", + "~~~~~~x2~~~~~%%HH+HHHHHHHHHHHHHHHHHHHHHHHHHH>..+..&TTT&wwH%~~~~~2x~~~~~~", + "~~~~~~x2~~~~~%%H...............................H........wH%~~~~~2x~~~~~~", + "~~~~~~xx~~~~%%%H...............................H&...8...&H%%~~~~xx~~~~~~", + "%%%%%~#2%%%%%%%HH+HHHH+HHH..HHHHHHHHHHHHHHHHH..H$#######$H%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%Hn..lHn..lH..H%%HIf6666;fH%%%H..H@...@...@H%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%HH+HHHH+HHH..HHHH........HHHHH..H#...#...#H%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%Hq..qHq..qH.....+........+......H$&$&@&$&$H%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%Hq..qHq..qH..HHHHc......cHHHHH..HHHHHHHHHHH%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%HHHHHHHHHHH..H%%H6tttttt6H%%%H..H%%%%%%%%%%%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%%%%%%%%%%%H..H%%H--------H%%%H..H%%%%%%%%%%%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%%%%%%%%%%%H..H%%#vvvvvvvv2%%%H..H%%%%%%%%%%%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%%%%%%%%%%%H..H%%#a~~~~~~~2%%%H..H%%%%%%%%%%%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%%%%%%%%%%%H..H%%#a~~~~~~~2%%%HbbH%%%%%%%%%%%%%%%%2#~%%%%%", + "%%%%%~#2%%%%%%%%HHHHHHHHHH..HHHbH~~~~~~%22222..2%%%%%%%%%%%%%%%%2#~%%%%%", + "%%%%%~#2%%%HHHHHHww.............b##~~~%%%%%%%..22%%%%%%%%%%%%%%%2#~%%%%%", + "%%%%%~#2%%%H{{{{Hw...HHHHHHHHHHHH!*!!!%%%%%%%...22222222222222222#`%%%%%", + "%%%%%`#2%%%H....C...^H%%%%%%%%~~~`````~~~~%%%%...................#!%%%%%", + "%%%%%!#2%%%H{{{{H....H%%%%%%%~~~~~~~~~~~~~~%%%.%%%%%%%%%%%%%%{{%%~~%%%%%", + "%%%%~~##%%%HHHHHHHHbHH%%%%%%~~~~~~~~~~~~~~~~%%b%%%%%%%%%%%%%%%%%~~~~%%%%", + "%%%~~~~############x~~~~~~~~~~~~~~~~~~~~~~~~~~x~~~~~~~~~~~~~~~~~~~~~~%%%", + "%%%~~~~~~~~~~~~~~~~x~~~~~~~~~~~~~~~~~~~~~~~~~~x~~~~~~~~~~~~~~~~~~~~~~%%%", + "%%%%~~~~%%%%%%%%%%HbH%%%%%%%~~~~~~~~~~~~~~~~%HbH%%%%%%%%%%%%%%%%~~~~%%%%", + "%%%%%%%%HHHHHHHHHHH.HHHH%%%%%~~~~~~~~~~~~~~%%H.HHHHHHHHHHHHHHHHH%%%%%%%%", + "%%%%%%%%HGGG.|YYYYY...UH%%%%%%~~~~~~~~~~~~%%%H.HH2$&$&$&$&$&$&$H%%%%%%%%", + "%%%%%%%%HGGG.C........UH%%%%%%%%%%%~~%%%%%%%%H.HH2.............H%%%%%%%%", + "%%%%%%%%HGGG.|........UH%%%%%%%%%%%~~%%%%%%%%H.HH2..@#@..@#@..@H%%%%%%%%", + "%%%%%%%%HHHHHHr.......UHHHHHHHHHHHH~~HHHHHHHHH.HH2..@#@..@#@..@H%%%%%%%%", + "%%%%%%%%%%%%%H2.2.................bxxb.........................H%%%%%%%%", + "%%%%%%%%%%%%%H22222222222222222222H!*H222222222222..@#@..@#@..@H%%%%%%%%", + "%%%%%%%%%%%%%HHHHHHHHHHHHHHHHHHHHHH``HHHHHHHHHHHH2..@#@..@#@..@H%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~~%%%%%%%%%%%H2.............H%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~~%%%%%%%%%%%H2..2#2..2#2..2H%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~~~~%%%%%%%%%%H22222222222222H%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~~~~%%%%%%%%%%HHHHHHHHHHHHHHHH%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%!~~~~~~~~~~~~~~~~~~~~~~~!%%%%%%%%%%%%%%%%%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~~~~%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~~~~%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + ], + "palettes": [ "sewage_treatment_sewer_palette" ], + "furniture": { + "c": "f_chair", + "l": "f_locker", + "L": "f_locker", + "n": "f_sink", + "{": "f_utility_shelf", + "r": "f_rack", + "f": "f_air_filter", + ";": "f_server", + "q": "f_shower", + "w": "f_workbench", + "t": "f_table", + "D": "f_desk", + "T": "f_counter", + "0": "f_lab_bench", + "[": "f_glass_cabinet", + "I": "f_air_conditioner", + "h": "f_fume_hood", + "1": "f_trashcan" + }, + "items": { + "q": { "item": "shower", "chance": 40 }, + "l": [ { "item": "clothing_work_set", "chance": 40 }, { "item": "shower", "chance": 50 } ], + "L": { "item": "cleaning", "chance": 80, "repeat": [ 1, 2 ] }, + "{": [ { "item": "sewage_plant", "chance": 50 }, { "item": "supplies_plumbing", "chance": 30 } ], + "r": { "item": "tools_electronics", "chance": 40, "repeat": [ 1, 3 ] }, + "w": { "item": "supplies_hardware", "chance": 50 }, + "`": [ { "item": "sewer", "chance": 10 }, { "item": "trash_forest", "chance": 10 }, { "item": "trash", "chance": 10 } ], + "0": [ { "item": "tools_science", "chance": 50 }, { "item": "sewage_samples", "chance": 20 } ], + "h": { "item": "chem_home", "chance": 50, "repeat": [ 1, 3 ] }, + "D": { "item": "office_mess", "chance": 40 }, + "t": { "item": "electronics", "chance": 30 }, + "[": [ { "item": "office_mess", "chance": 30 }, { "item": "sewage_samples", "chance": 10 } ], + "1": { "item": "trash", "chance": 50 } + }, + "place_loot": [ + { "group": "sewage_plant", "x": [ 17, 20 ], "y": 4, "chance": 70 }, + { "group": "sewage_plant", "x": [ 48, 51 ], "y": 4, "chance": 70 }, + { "group": "treatment_chemicals", "x": [ 49, 55 ], "y": [ 13, 16 ], "chance": 90, "repeat": [ 1, 3 ] }, + { "group": "treatment_chemicals", "x": [ 50, 61 ], "y": [ 35, 42 ], "chance": 50, "repeat": [ 1, 3 ] }, + { "group": "sewage_plant", "x": [ 50, 61 ], "y": [ 35, 42 ], "chance": 70, "repeat": [ 1, 3 ] } + ], + "computers": { + "8": { + "name": "EnviroCom OS v2.03", + "security": 1, + "options": [ { "name": "Download Sewer Maps", "action": "map_sewer" }, { "name": "Divert sample", "action": "sample" } ], + "failures": [ { "action": "shutdown" }, { "action": "alarm" } ] + } + }, + "place_monsters": [ + { "monster": "GROUP_ZOMBIE", "x": [ 26, 36 ], "y": [ 12, 18 ], "density": 0.35 }, + { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 36, 38 ], "density": 0.35 }, + { "monster": "GROUP_SEWAGE_TREATMENT", "x": 36, "y": 3, "density": 0.2 }, + { "monster": "GROUP_SEWAGE_TREATMENT", "x": [ 30, 32 ], "y": [ 35, 36 ], "density": 0.2 } + ] + } + }, + { + "type": "mapgen", + "method": "json", + "om_terrain": [ "sewage_treatment_0_1_-1" ], + "//": "10% chance of a hidden CHUD lair", + "weight": 25, + "object": { + "fill_ter": "t_rock_floor", + "rows": [ + "%%%%%~#2%%%%%%%%HHHHHHHH", + "%%%%%~#2%%%HHHHHHww.....", + "%%%%%~#2%%%H{{{{Hw...HHH", + "%%%%%~#2%%%H....C...^H%%", + "%%%%%~#2%%%H{{{{H....H%%", + "%%%%~~##%%%HHHHHHHHbHH%%", + "%%%~~~~############x~~~~", + "%%%~~~~~~~~~~~~~~~~x~~~~", + "%%%%~~~~%%%%%%%%%%HbH%%%", + "%%%%%%%%HHHHHHHHHHH.HHHH", + "%%%%%%%%HGGG.|YYYYY...UH", + "%%%%%%%%HGGG.C........UH", + "%%%%%%%%HGGG.|........UH", + "%%%%%%%%HHHHHHr.......UH", + "%%%%%%%%%%%%%H2.2.......", + "%%====%%%%%%%H2222222222", + "%%%======%%%%HHHHHHHHHHH", + "%%%=======%%%%%%%%%%%%%%", + "%%%=======%%%%%%%%%%%%%%", + "%%========%%%%%%%%%%%%%%", + "%%%==%%=%%%%%%%%%%%%%%%%", + "%%%%%%!~~~~~~~~~~~~~~~~~", + "%%%%%%%%%%%%%%%%%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%%" + ], + "palettes": [ "sewage_treatment_sewer_palette" ], + "furniture": { "{": "f_utility_shelf", "r": "f_rack", "w": "f_workbench" }, + "items": { + "{": [ { "item": "sewage_plant", "chance": 30 }, { "item": "supplies_plumbing", "chance": 20 } ], + "w": { "item": "supplies_hardware", "chance": 50 }, + "=": [ { "item": "cannibal_corpse", "chance": 5 }, { "item": "human_remains", "chance": 5 } ], + "r": { "item": "tools_electronics", "chance": 30, "repeat": [ 1, 3 ] } + }, + "fields": { "=": { "field": "fd_blood", "intensity": 1, "age": 990, "chance": 40 } }, + "place_monsters": [ + { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.35 }, + { "monster": "GROUP_CHUD", "x": [ 4, 6 ], "y": [ 16, 18 ], "density": 0.2 } + ] + } + }, + { + "type": "mapgen", + "method": "json", + "om_terrain": [ "sewage_treatment_0_1_-1" ], + "//": "Easter egg - TNMT reference", + "weight": 1, + "object": { + "fill_ter": "t_rock_floor", + "rows": [ + "%%%%%~#2%%%%%%%%HHHHHHHH", + "%%%%%~#2%%%HHHHHHww.....", + "%%%%%~#2%%%H{{{{Hw...HHH", + "%%%%%~#2%%%H....C...^H%%", + "%%%%%~#2%%%H{{{{H....H%%", + "%%%%~~##%%%HHHHHHHHbHH%%", + "%%%~~~~############x~~~~", + "%%%~~~~~~~~~~~~~~~~x~~~~", + "%%%%~~~~%%%%%%%%%%HbH%%%", + "%%%%%%%%HHHHHHHHHHH.HHHH", + "%%%%%%%%HGGG.|YYYYY...UH", + "%.KKK.%%HGGG.C........UH", + "%.KKK.%%HGGG.|........UH", + "%.KKK.%%HHHHHHr.......UH", + "%%%O%%%%%%%%%H2.2.......", + "%t...%Q..B%%%H2222222222", + "%....O.::.%%%HHHHHHHHHHH", + "%ppT.%.::1%%%%%%%%%%%%%%", + "%%%%O%.::.O..P%%%%%%%%%%", + "%fo..%1...%B.P%%%%%%%%%%", + "%.c..%%*%%%%%%%%%%%%%%%%", + "%ctc.%!~~~~~~~~~~~~~~~~~", + "%.c..%%%%%%%%%%%%%%%%%%%", + "%%%%%%%%%%%%%%%%%%%%%%%%" + ], + "palettes": [ "sewage_treatment_sewer_palette" ], + "terrain": { "O": "t_mdoor_lab_frame", ":": "t_carpet_yellow", "Q": "t_privacy_fence" }, + "furniture": { + "{": "f_utility_shelf", + "w": "f_workbench", + "r": "f_rack", + "K": "f_tatami", + "c": "f_chair", + "l": "f_locker", + "n": "f_sink", + "f": "f_fridge", + "t": "f_table", + "V": "f_exercise", + "S": "f_ergometer", + "P": "f_bed", + "p": "f_sofa", + "1": "f_armchair", + "T": "f_floor_lamp", + "o": "f_oven", + "B": "f_bookcase" + }, + "items": { + "{": [ { "item": "sewage_plant", "chance": 30 }, { "item": "supplies_plumbing", "chance": 20 } ], + "w": { "item": "supplies_hardware", "chance": 50 }, + "r": { "item": "tools_electronics", "chance": 30, "repeat": [ 1, 3 ] }, + "B": { "item": "dojo_manuals", "chance": 60, "repeat": [ 1, 2 ] }, + "P": { "item": "bed", "chance": 60 }, + "f": { "item": "fridgesnacks", "chance": 80, "repeat": [ 1, 2 ] } + }, + "place_loot": [ + { "item": "katana", "x": 2, "y": 11, "amount": 2 }, + { "item": "q_staff", "x": 3, "y": 12 }, + { "item": "television", "x": 1, "y": 15 }, + { "item": "judo_belt_orange", "x": 3, "y": 13 }, + { "item": "judo_belt_blue", "x": 4, "y": 13 }, + { "item": "pizza_cheese", "x": 2, "y": 21 } + ], + "place_monsters": [ { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.35 } ] + } + }, + { + "id": "cannibal_corpse", + "type": "item_group", + "subtype": "collection", + "items": [ { "group": "clothing_work_set", "chance": 40 }, { "group": "supplies_plumbing", "chance": 10 }, { "item": "corpse" } ] + }, + { + "id": "human_remains", + "type": "item_group", + "subtype": "collection", + "items": [ + { "item": "human_flesh", "chance": 70, "count-min": 1, "count-max": 10 }, + { "item": "hstomach_large", "chance": 60 }, + { "item": "hstomach", "chance": 60 }, + { "item": "bone_human", "prob": 90, "count-min": 1, "count-max": 5 }, + { "item": "rag_bloody", "prob": 90, "count-min": 1, "count-max": 4 } + ] + } +] \ No newline at end of file diff --git a/data/json/overmap/overmap_special/specials.json b/data/json/overmap/overmap_special/specials.json index e22cc31730153..d7b0cfec87a45 100644 --- a/data/json/overmap/overmap_special/specials.json +++ b/data/json/overmap/overmap_special/specials.json @@ -153,30 +153,32 @@ "id": "Sewage Treatment Plant", "overmaps": [ { "point": [ 0, -1, 0 ], "overmap": "road_end_north" }, - { "point": [ 0, 0, 0 ], "overmap": "s_lot" }, - { "point": [ 0, 1, 0 ], "overmap": "sewage_treatment" }, - { "point": [ 0, 1, -1 ], "overmap": "sewage_treatment_hub" }, - { "point": [ 0, 0, -1 ], "overmap": "sewage_treatment_under" }, - { "point": [ -1, 0, -1 ], "overmap": "sewage_treatment_under" }, - { "point": [ 1, 0, -1 ], "overmap": "sewage_treatment_under" }, - { "point": [ -1, 1, -1 ], "overmap": "sewage_treatment_under" }, - { "point": [ 1, 1, -1 ], "overmap": "sewage_treatment_under" }, - { "point": [ -1, 2, -1 ], "overmap": "sewage_treatment_under" }, - { "point": [ 0, 2, -1 ], "overmap": "sewage_treatment_under" }, - { "point": [ 1, 2, -1 ], "overmap": "sewage_treatment_under" } + { "point": [ 0, 0, 0 ], "overmap": "sewage_treatment_0_0_0_north" }, + { "point": [ 0, 0, 1 ], "overmap": "sewage_treatment_0_0_roof_north" }, + { "point": [ 1, 0, 0 ], "overmap": "sewage_treatment_1_0_0_north" }, + { "point": [ 1, 0, 1 ], "overmap": "sewage_treatment_1_0_roof_north" }, + { "point": [ 0, 1, 0 ], "overmap": "sewage_treatment_0_1_0_north" }, + { "point": [ 0, 1, 1 ], "overmap": "sewage_treatment_0_1_roof_north" }, + { "point": [ 1, 1, 0 ], "overmap": "sewage_treatment_1_1_0_north" }, + { "point": [ 1, 1, 1 ], "overmap": "sewage_treatment_1_1_roof_north" }, + { "point": [ 0, 0, -1 ], "overmap": "sewage_treatment_0_0_-1_north" }, + { "point": [ 1, 0, -1 ], "overmap": "sewage_treatment_1_0_-1_north" }, + { "point": [ 2, 0, -1 ], "overmap": "sewage_treatment_2_0_-1_north" }, + { "point": [ 0, 1, -1 ], "overmap": "sewage_treatment_0_1_-1_north" }, + { "point": [ 1, 1, -1 ], "overmap": "sewage_treatment_1_1_-1_north" }, + { "point": [ 2, 1, -1 ], "overmap": "sewage_treatment_2_1_-1_north" } ], + "locations": [ "land" ], "connections": [ - { "point": [ 0, -1, 0 ] }, - { "point": [ 0, -1, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 0, 0, -1 ] }, - { "point": [ 2, 1, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 1, 1, -1 ] }, - { "point": [ 0, 3, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 0, 2, -1 ] }, - { "point": [ -2, 1, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ -1, 1, -1 ] } + { "point": [ 0, -1, 0 ], "terrain": "road" }, + { "point": [ -1, 0, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 0, 0, -1 ] }, + { "point": [ 1, -1, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 1, 0, -1 ] }, + { "point": [ 3, 0, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 2, 0, -1 ] }, + { "point": [ 1, 2, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 1, 1, -1 ] } ], - "locations": [ "land" ], "city_distance": [ 10, 20 ], "city_sizes": [ 4, 12 ], "occurrences": [ 0, 4 ], - "rotate": false, "flags": [ "CLASSIC" ] }, { diff --git a/data/json/overmap/overmap_terrain/overmap_terrain_waste_junk.json b/data/json/overmap/overmap_terrain/overmap_terrain_waste_junk.json index cf22e7af95310..e6aa754827fdc 100644 --- a/data/json/overmap/overmap_terrain/overmap_terrain_waste_junk.json +++ b/data/json/overmap/overmap_terrain/overmap_terrain_waste_junk.json @@ -1,31 +1,95 @@ [ { "type": "overmap_terrain", - "id": "sewage_treatment", - "name": "sewage treatment", + "id": "sewage_treatment_0_0_0", + "name": "sewage treatment plant", "sym": "P", "color": "red", "see_cost": 5, - "flags": [ "KNOWN_DOWN", "NO_ROTATE" ] + "flags": [ "KNOWN_DOWN" ] + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_0_0_roof", + "name": "open air", + "sym": ".", + "color": "blue", + "see_cost": 5 }, { "type": "overmap_terrain", - "id": "sewage_treatment_hub", - "name": "sewage treatment", + "id": "sewage_treatment_1_0_0", + "copy-from": "sewage_treatment_0_0_0" + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_1_0_roof", + "name": "sewage treatment plant roof", "sym": "P", - "color": "green", + "color": "red", + "see_cost": 5 + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_0_1_0", + "name": "sewage treatment plant", + "sym": "O", + "color": "blue", "see_cost": 5, - "extras": "build", - "flags": [ "KNOWN_UP", "NO_ROTATE" ] + "flags": [ "KNOWN_DOWN" ] + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_0_1_roof", + "name": "sewage treatment plant roof", + "sym": "O", + "color": "blue", + "see_cost": 5 + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_1_1_0", + "copy-from": "sewage_treatment_0_0_0" + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_1_1_roof", + "copy-from": "sewage_treatment_1_0_roof" }, { "type": "overmap_terrain", - "id": "sewage_treatment_under", - "name": "sewage treatment", + "id": "sewage_treatment_0_0_-1", + "name": "sewage treatment plant - underground", "sym": "P", "color": "green", "see_cost": 5, - "flags": [ "NO_ROTATE" ] + "extras": "build", + "flags": [ "KNOWN_UP" ] + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_1_0_-1", + "copy-from": "sewage_treatment_0_0_-1" + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_2_0_-1", + "copy-from": "sewage_treatment_0_0_-1" + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_0_1_-1", + "copy-from": "sewage_treatment_0_0_-1" + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_1_1_-1", + "copy-from": "sewage_treatment_0_0_-1" + }, + { + "type": "overmap_terrain", + "id": "sewage_treatment_2_1_-1", + "copy-from": "sewage_treatment_0_0_-1" }, { "type": "overmap_terrain", diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 3db4ebff11d77..bea2908d97545 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -4662,268 +4662,6 @@ void map::draw_temple( const oter_id &terrain_type, mapgendata &dat, const time_ } } -void map::draw_sewer( const oter_id &terrain_type, mapgendata &dat, const time_point &/*when*/, - const float /*density*/ ) -{ - computer *tmpcomp = nullptr; - - if( terrain_type == "sewage_treatment" ) { - fill_background( this, t_floor ); // Set all to floor - line( this, t_wall, 0, 0, 23, 0 ); // Top wall - line( this, t_window, 1, 0, 6, 0 ); // Its windows - line( this, t_wall, 0, 23, 23, 23 ); // Bottom wall - line( this, t_wall, 1, 5, 6, 5 ); // Interior wall (front office) - line( this, t_wall, 1, 14, 6, 14 ); // Interior wall (equipment) - line( this, t_wall, 1, 20, 7, 20 ); // Interior wall (stairs) - line( this, t_wall, 14, 15, 22, 15 ); // Interior wall (tank) - line( this, t_wall, 0, 1, 0, 22 ); // Left wall - line( this, t_wall, 23, 1, 23, 22 ); // Right wall - line( this, t_wall, 7, 1, 7, 5 ); // Interior wall (front office) - line( this, t_wall, 7, 14, 7, 19 ); // Interior wall (stairs) - line( this, t_wall, 4, 15, 4, 19 ); // Interior wall (mid-stairs) - line( this, t_wall, 14, 15, 14, 20 ); // Interior wall (tank) - line( this, t_wall_glass, 7, 6, 7, 13 ); // Interior glass (equipment) - line( this, t_wall_glass, 8, 20, 13, 20 ); // Interior glass (flow) - line_furn( this, f_counter, 1, 3, 3, 3 ); // Desk (front office); - line_furn( this, f_counter, 1, 6, 1, 13 ); // Counter (equipment); - // Central tanks: - square( this, t_sewage, 10, 3, 13, 6 ); - square( this, t_sewage, 17, 3, 20, 6 ); - square( this, t_sewage, 10, 10, 13, 13 ); - square( this, t_sewage, 17, 10, 20, 13 ); - // Drainage tank - square( this, t_sewage, 16, 16, 21, 18 ); - square( this, t_grate, 18, 16, 19, 17 ); - line( this, t_sewage, 17, 19, 20, 19 ); - line( this, t_sewage, 18, 20, 19, 20 ); - line( this, t_sewage, 2, 21, 19, 21 ); - line( this, t_sewage, 2, 22, 19, 22 ); - // Pipes and pumps - line( this, t_sewage_pipe, 1, 15, 1, 19 ); - line( this, t_sewage_pump, 1, 21, 1, 22 ); - // Stairs down - ter_set( point( 2, 15 ), t_stairs_down ); - // Now place doors - ter_set( point( rng( 2, 5 ), 0 ), t_door_c ); - ter_set( point( rng( 3, 5 ), 5 ), t_door_c ); - ter_set( point( 5, 14 ), t_door_c ); - ter_set( point( 7, rng( 15, 17 ) ), t_door_c ); - ter_set( point( 14, rng( 17, 19 ) ), t_door_c ); - if( one_in( 3 ) ) { // back door - ter_set( point( 23, rng( 19, 22 ) ), t_door_locked ); - } - ter_set( point( 4, 19 ), t_door_metal_locked ); - ter_set( point( 2, 19 ), t_console ); - ter_set( point( 6, 19 ), t_console ); - // Computers to unlock stair room, and items - tmpcomp = add_computer( tripoint( 2, 19, abs_sub.z ), _( "EnviroCom OS v2.03" ), 1 ); - tmpcomp->add_option( _( "Unlock stairs" ), COMPACT_OPEN, 0 ); - tmpcomp->add_failure( COMPFAIL_SHUTDOWN ); - - tmpcomp = add_computer( tripoint( 6, 19, abs_sub.z ), _( "EnviroCom OS v2.03" ), 1 ); - tmpcomp->add_option( _( "Unlock stairs" ), COMPACT_OPEN, 0 ); - tmpcomp->add_failure( COMPFAIL_SHUTDOWN ); - place_items( "sewage_plant", 80, point( 1, 6 ), point( 1, 13 ), false, 0 ); - - } else if( terrain_type == "sewage_treatment_hub" ) { - // Stairs up, center of 3x3 of treatment_below - - fill_background( this, t_rock_floor ); - // Top & left walls; right & bottom are handled by adjacent terrain - line( this, t_wall, 0, 0, 23, 0 ); - line( this, t_wall, 0, 1, 0, 23 ); - // Top-left room - line( this, t_wall, 8, 1, 8, 8 ); - line( this, t_wall, 1, 9, 9, 9 ); - line( this, t_wall_glass, rng( 1, 3 ), 9, rng( 4, 7 ), 9 ); - ter_set( point( 2, 15 ), t_stairs_up ); - ter_set( point( 8, 8 ), t_door_c ); - ter_set( point( 3, 0 ), t_door_c ); - - // Bottom-left room - stairs and equipment - line( this, t_wall, 1, 14, 8, 14 ); - line( this, t_wall_glass, rng( 1, 3 ), 14, rng( 5, 8 ), 14 ); - line( this, t_wall, 9, 14, 9, 23 ); - line( this, t_wall_glass, 9, 16, 9, 19 ); - square_furn( this, f_counter, 5, 16, 6, 20 ); - place_items( "sewage_plant", 80, point( 5, 16 ), point( 6, 20 ), false, 0 ); - ter_set( point( 0, 20 ), t_door_c ); - ter_set( point( 9, 20 ), t_door_c ); - - // Bottom-right room - line( this, t_wall, 14, 19, 14, 23 ); - line( this, t_wall, 14, 18, 19, 18 ); - line( this, t_wall, 21, 14, 23, 14 ); - ter_set( point( 14, 18 ), t_wall ); - ter_set( point( 14, 20 ), t_door_c ); - ter_set( point( 15, 18 ), t_door_c ); - line( this, t_wall, 20, 15, 20, 18 ); - - // Tanks and their content - for( int i = 9; i <= 16; i += 7 ) { - for( int j = 2; j <= 9; j += 7 ) { - square( this, t_rock, i, j, i + 5, j + 5 ); - square( this, t_sewage, i + 1, j + 1, i + 4, j + 4 ); - } - } - square( this, t_rock, 16, 15, 19, 17 ); // Wall around sewage from above - square( this, t_rock, 10, 15, 14, 17 ); // Extra walls for southward flow - // Flow in from north, east, and west always connects to the corresponding tank - square( this, t_sewage, 10, 0, 13, 2 ); // North -> NE tank - square( this, t_sewage, 21, 10, 23, 13 ); // East -> SE tank - square( this, t_sewage, 0, 10, 9, 13 ); // West -> SW tank - // Flow from south may go to SW tank or SE tank - square( this, t_sewage, 10, 16, 13, 23 ); - if( one_in( 2 ) ) { // To SW tank - square( this, t_sewage, 10, 14, 13, 17 ); - // Then, flow from above may be either to flow from south, to SE tank, or both - switch( rng( 1, 5 ) ) { - case 1: - case 2: // To flow from south - square( this, t_sewage, 14, 16, 19, 17 ); - line( this, t_bridge, 15, 16, 15, 17 ); - if( !one_in( 4 ) ) { - line( this, t_wall_glass, 16, 18, 19, 18 ); // Viewing window - } - break; - case 3: - case 4: // To SE tank - square( this, t_sewage, 18, 14, 19, 17 ); - if( !one_in( 4 ) ) { - line( this, t_wall_glass, 20, 15, 20, 17 ); // Viewing window - } - break; - case 5: // Both! - square( this, t_sewage, 14, 16, 19, 17 ); - square( this, t_sewage, 18, 14, 19, 17 ); - line( this, t_bridge, 15, 16, 15, 17 ); - if( !one_in( 4 ) ) { - line( this, t_wall_glass, 16, 18, 19, 18 ); // Viewing window - } - if( !one_in( 4 ) ) { - line( this, t_wall_glass, 20, 15, 20, 17 ); // Viewing window - } - break; - } - } else { // To SE tank, via flow from above - square( this, t_sewage, 14, 16, 19, 17 ); - square( this, t_sewage, 18, 14, 19, 17 ); - line( this, t_bridge, 15, 16, 15, 17 ); - if( !one_in( 4 ) ) { - line( this, t_wall_glass, 16, 18, 19, 18 ); // Viewing window - } - if( !one_in( 4 ) ) { - line( this, t_wall_glass, 20, 15, 20, 17 ); // Viewing window - } - } - - // Next, determine how the tanks interconnect. - int rn = rng( 1, 4 ); // Which of the 4 possible connections is missing? - if( rn != 1 ) { - line( this, t_sewage, 14, 4, 14, 5 ); - line( this, t_bridge, 15, 4, 15, 5 ); - line( this, t_sewage, 16, 4, 16, 5 ); - } - if( rn != 2 ) { - line( this, t_sewage, 18, 7, 19, 7 ); - line( this, t_bridge, 18, 8, 19, 8 ); - line( this, t_sewage, 18, 9, 19, 9 ); - } - if( rn != 3 ) { - line( this, t_sewage, 14, 11, 14, 12 ); - line( this, t_bridge, 15, 11, 15, 12 ); - line( this, t_sewage, 16, 11, 16, 12 ); - } - if( rn != 4 ) { - line( this, t_sewage, 11, 7, 12, 7 ); - line( this, t_bridge, 11, 8, 12, 8 ); - line( this, t_sewage, 11, 9, 12, 9 ); - } - // Bridge connecting bottom two rooms - line( this, t_bridge, 10, 20, 13, 20 ); - // Possibility of extra equipment shelves - if( !one_in( 3 ) ) { - line_furn( this, f_rack, 23, 1, 23, 4 ); - place_items( "sewage_plant", 60, point( 23, 1 ), point( 23, 4 ), false, 0 ); - } - - // Finally, choose what the top-left and bottom-right rooms do. - if( one_in( 2 ) ) { // Upper left is sampling, lower right valuable finds - // Upper left... - line( this, t_wall, 1, 3, 2, 3 ); - line( this, t_wall, 1, 5, 2, 5 ); - line( this, t_wall, 1, 7, 2, 7 ); - ter_set( point( 1, 4 ), t_sewage_pump ); - furn_set( point( 2, 4 ), f_counter ); - ter_set( point( 1, 6 ), t_sewage_pump ); - furn_set( point( 2, 6 ), f_counter ); - ter_set( point( 1, 2 ), t_console ); - tmpcomp = add_computer( tripoint( 1, 2, abs_sub.z ), _( "EnviroCom OS v2.03" ), 0 ); - tmpcomp->add_option( _( "Download Sewer Maps" ), COMPACT_MAP_SEWER, 0 ); - tmpcomp->add_option( _( "Divert sample" ), COMPACT_SAMPLE, 3 ); - tmpcomp->add_failure( COMPFAIL_PUMP_EXPLODE ); - tmpcomp->add_failure( COMPFAIL_PUMP_LEAK ); - // Lower right... - line_furn( this, f_counter, 15, 23, 22, 23 ); - place_items( "sewer", 65, point( 15, 23 ), point( 22, 23 ), false, 0 ); - line_furn( this, f_counter, 23, 15, 23, 19 ); - place_items( "sewer", 65, point( 23, 15 ), point( 23, 19 ), false, 0 ); - } else { // Upper left is valuable finds, lower right is sampling - // Upper left... - line_furn( this, f_counter, 1, 1, 1, 7 ); - place_items( "sewer", 65, point_south_east, point( 1, 7 ), false, 0 ); - line_furn( this, f_counter, 7, 1, 7, 7 ); - place_items( "sewer", 65, point( 7, 1 ), point( 7, 7 ), false, 0 ); - // Lower right... - line( this, t_wall, 17, 22, 17, 23 ); - line( this, t_wall, 19, 22, 19, 23 ); - line( this, t_wall, 21, 22, 21, 23 ); - ter_set( point( 18, 23 ), t_sewage_pump ); - furn_set( point( 18, 22 ), f_counter ); - ter_set( point( 20, 23 ), t_sewage_pump ); - furn_set( point( 20, 22 ), f_counter ); - ter_set( point( 16, 23 ), t_console ); - tmpcomp = add_computer( tripoint( 16, 23, abs_sub.z ), _( "EnviroCom OS v2.03" ), 0 ); - tmpcomp->add_option( _( "Download Sewer Maps" ), COMPACT_MAP_SEWER, 0 ); - tmpcomp->add_option( _( "Divert sample" ), COMPACT_SAMPLE, 3 ); - tmpcomp->add_failure( COMPFAIL_PUMP_EXPLODE ); - tmpcomp->add_failure( COMPFAIL_PUMP_LEAK ); - } - - } else if( terrain_type == "sewage_treatment_under" ) { - fill_background( this, t_floor ); - if( dat.north() == "sewage_treatment_under" || dat.north() == "sewage_treatment_hub" || - ( is_ot_match( "sewer", dat.north(), ot_match_type::type ) && connects_to( dat.north(), 2 ) ) ) { - if( dat.north() == "sewage_treatment_under" || dat.north() == "sewage_treatment_hub" ) { - line( this, t_wall, 0, 0, 23, 0 ); - ter_set( point( 3, 0 ), t_door_c ); - } - dat.n_fac = 1; - square( this, t_sewage, 10, 0, 13, 13 ); - } - if( dat.east() == "sewage_treatment_under" || dat.east() == "sewage_treatment_hub" || - ( is_ot_match( "sewer", dat.east(), ot_match_type::type ) && connects_to( dat.east(), 3 ) ) ) { - dat.e_fac = 1; - square( this, t_sewage, 10, 10, 23, 13 ); - } - if( dat.south() == "sewage_treatment_under" || dat.south() == "sewage_treatment_hub" || - ( is_ot_match( "sewer", dat.south(), ot_match_type::type ) && connects_to( dat.south(), 0 ) ) ) { - dat.s_fac = 1; - square( this, t_sewage, 10, 10, 13, 23 ); - } - if( dat.west() == "sewage_treatment_under" || dat.west() == "sewage_treatment_hub" || - ( is_ot_match( "sewer", dat.west(), ot_match_type::type ) && connects_to( dat.west(), 1 ) ) ) { - if( dat.west() == "sewage_treatment_under" || - dat.west() == "sewage_treatment_hub" ) { - line( this, t_wall, 0, 1, 0, 23 ); - ter_set( point( 0, 20 ), t_door_c ); - } - dat.w_fac = 1; - square( this, t_sewage, 0, 10, 13, 13 ); - } - } -} - void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_point &/*when*/, const float /*density*/ ) { diff --git a/src/overmap.cpp b/src/overmap.cpp index 8b171055c5e05..3d3ffaee23178 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -775,9 +775,6 @@ bool oter_t::is_hardcoded() const "office_tower_1_entrance", "office_tower_b", "office_tower_b_entrance", - "sewage_treatment", - "sewage_treatment_hub", - "sewage_treatment_under", "silo", "silo_finale", "slimepit", From 3bd80bad45d15f245235e9ea2f5314511895c770 Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sun, 28 Jul 2019 12:43:20 +0300 Subject: [PATCH 083/113] Modified road connection --- data/json/overmap/overmap_special/specials.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/overmap/overmap_special/specials.json b/data/json/overmap/overmap_special/specials.json index d7b0cfec87a45..e9bff855f60f5 100644 --- a/data/json/overmap/overmap_special/specials.json +++ b/data/json/overmap/overmap_special/specials.json @@ -170,7 +170,7 @@ ], "locations": [ "land" ], "connections": [ - { "point": [ 0, -1, 0 ], "terrain": "road" }, + { "point": [ 0, -2, 0 ], "terrain": "road", "connection": "local_road", "from": [ 0, -1, 0 ] }, { "point": [ -1, 0, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 0, 0, -1 ] }, { "point": [ 1, -1, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 1, 0, -1 ] }, { "point": [ 3, 0, -1 ], "terrain": "sewer", "connection": "sewer_tunnel", "from": [ 2, 0, -1 ] }, From d3ec12564079e76ac4380f6d1e2a911d2b1b60ba Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sun, 28 Jul 2019 12:43:42 +0300 Subject: [PATCH 084/113] remove draw_sever calls --- src/map.h | 2 -- src/mapgen.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/map.h b/src/map.h index 81ff1cdc813a8..b87d9f8e89894 100644 --- a/src/map.h +++ b/src/map.h @@ -1430,8 +1430,6 @@ class map float density ); void draw_temple( const oter_id &terrain_type, mapgendata &dat, const time_point &when, float density ); - void draw_sewer( const oter_id &terrain_type, mapgendata &dat, const time_point &when, - float density ); void draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_point &when, float density ); void draw_spiral( const oter_id &terrain_type, mapgendata &dat, const time_point &when, diff --git a/src/mapgen.cpp b/src/mapgen.cpp index bea2908d97545..8bee8f2b922ca 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -2700,8 +2700,6 @@ void map::draw_map( const oter_id &terrain_type, const oter_id &t_north, const o draw_triffid( terrain_type, dat, when, density ); } else if( is_ot_match( "office", terrain_type, ot_match_type::prefix ) ) { draw_office_tower( terrain_type, dat, when, density ); - } else if( is_ot_match( "sewage", terrain_type, ot_match_type::prefix ) ) { - draw_sewer( terrain_type, dat, when, density ); } else if( is_ot_match( "spider", terrain_type, ot_match_type::prefix ) ) { draw_spider_pit( terrain_type, dat, when, density ); } else if( is_ot_match( "spiral", terrain_type, ot_match_type::prefix ) ) { From db7b1a8670fcdb406f5e53958f054bd603b2bda4 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Sun, 28 Jul 2019 04:04:42 +0000 Subject: [PATCH 085/113] Style --- data/json/mapgen/sewage_treatment.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/mapgen/sewage_treatment.json b/data/json/mapgen/sewage_treatment.json index 5016eefbe97d5..9658c160e28ac 100644 --- a/data/json/mapgen/sewage_treatment.json +++ b/data/json/mapgen/sewage_treatment.json @@ -594,4 +594,4 @@ { "item": "rag_bloody", "prob": 90, "count-min": 1, "count-max": 4 } ] } -] \ No newline at end of file +] From 577f2a88b6c7b07c0751f15712742c8ad41fa9fb Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sun, 28 Jul 2019 12:50:17 +0300 Subject: [PATCH 086/113] move old plant to obsolete --- data/json/obsolete_terrains.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/json/obsolete_terrains.json b/data/json/obsolete_terrains.json index e16a6b6ecb234..92f7922e98a0b 100644 --- a/data/json/obsolete_terrains.json +++ b/data/json/obsolete_terrains.json @@ -261,6 +261,9 @@ "orchard_tree_apple", "orchard_stall", "orchard_processing", + "sewage_treatment", + "sewage_treatment_hub", + "sewage_treatment_under", "dairy_farm_NW", "dairy_farm_NE", "dairy_farm_SW", From 7ba81987631287ce31b43a06b4c261b73000de2e Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sun, 28 Jul 2019 15:24:51 +0300 Subject: [PATCH 087/113] minor layout tweaks --- data/json/mapgen/sewage_treatment.json | 47 +++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/data/json/mapgen/sewage_treatment.json b/data/json/mapgen/sewage_treatment.json index 9658c160e28ac..e61c92a7ab3af 100644 --- a/data/json/mapgen/sewage_treatment.json +++ b/data/json/mapgen/sewage_treatment.json @@ -70,6 +70,7 @@ "h": "t_thconc_floor", "D": "t_thconc_floor", "1": "t_thconc_floor", + "=": "t_rock_floor", ">": "t_stairs_up", "!": "t_bars", "~": "t_sewage", @@ -372,7 +373,7 @@ "%%%%%~#2%%%%%%%%HHHHHHHHHH..HHHbH~~~~~~%22222..2%%%%%%%%%%%%%%%%2#~%%%%%", "%%%%%~#2%%%HHHHHHww.............b##~~~%%%%%%%..22%%%%%%%%%%%%%%%2#~%%%%%", "%%%%%~#2%%%H{{{{Hw...HHHHHHHHHHHH!*!!!%%%%%%%...22222222222222222#`%%%%%", - "%%%%%`#2%%%H....C...^H%%%%%%%%~~~`````~~~~%%%%...................#!%%%%%", + "%%%%%`#2%%%H....C...^H%%%%%%%%~~~`````~~~~%%%....................#!%%%%%", "%%%%%!#2%%%H{{{{H....H%%%%%%%~~~~~~~~~~~~~~%%%.%%%%%%%%%%%%%%{{%%~~%%%%%", "%%%%~~##%%%HHHHHHHHbHH%%%%%%~~~~~~~~~~~~~~~~%%b%%%%%%%%%%%%%%%%%~~~~%%%%", "%%%~~~~############x~~~~~~~~~~~~~~~~~~~~~~~~~~x~~~~~~~~~~~~~~~~~~~~~~%%%", @@ -422,7 +423,7 @@ "{": [ { "item": "sewage_plant", "chance": 50 }, { "item": "supplies_plumbing", "chance": 30 } ], "r": { "item": "tools_electronics", "chance": 40, "repeat": [ 1, 3 ] }, "w": { "item": "supplies_hardware", "chance": 50 }, - "`": [ { "item": "sewer", "chance": 10 }, { "item": "trash_forest", "chance": 10 }, { "item": "trash", "chance": 10 } ], + "`": [ { "item": "sewer", "chance": 20 }, { "item": "trash_forest", "chance": 10 }, { "item": "trash", "chance": 10 } ], "0": [ { "item": "tools_science", "chance": 50 }, { "item": "sewage_samples", "chance": 20 } ], "h": { "item": "chem_home", "chance": 50, "repeat": [ 1, 3 ] }, "D": { "item": "office_mess", "chance": 40 }, @@ -492,12 +493,12 @@ "items": { "{": [ { "item": "sewage_plant", "chance": 30 }, { "item": "supplies_plumbing", "chance": 20 } ], "w": { "item": "supplies_hardware", "chance": 50 }, - "=": [ { "item": "cannibal_corpse", "chance": 5 }, { "item": "human_remains", "chance": 5 } ], + "=": [ { "item": "cannibal_corpse", "chance": 15 }, { "item": "human_remains", "chance": 15 } ], "r": { "item": "tools_electronics", "chance": 30, "repeat": [ 1, 3 ] } }, "fields": { "=": { "field": "fd_blood", "intensity": 1, "age": 990, "chance": 40 } }, "place_monsters": [ - { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.35 }, + { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.2 }, { "monster": "GROUP_CHUD", "x": [ 4, 6 ], "y": [ 16, 18 ], "density": 0.2 } ] } @@ -506,7 +507,7 @@ "type": "mapgen", "method": "json", "om_terrain": [ "sewage_treatment_0_1_-1" ], - "//": "Easter egg - TNMT reference", + "//": "Easter egg - TMNT reference", "weight": 1, "object": { "fill_ter": "t_rock_floor", @@ -522,15 +523,15 @@ "%%%%~~~~%%%%%%%%%%HbH%%%", "%%%%%%%%HHHHHHHHHHH.HHHH", "%%%%%%%%HGGG.|YYYYY...UH", - "%.KKK.%%HGGG.C........UH", - "%.KKK.%%HGGG.|........UH", - "%.KKK.%%HHHHHHr.......UH", + "%.III.%%HGGG.C........UH", + "%.III.%%HGGG.|........UH", + "%.III.%%HHHHHHr.......UH", "%%%O%%%%%%%%%H2.2.......", - "%t...%Q..B%%%H2222222222", + "%t...%Q..D%%%H2222222222", "%....O.::.%%%HHHHHHHHHHH", - "%ppT.%.::1%%%%%%%%%%%%%%", - "%%%%O%.::.O..P%%%%%%%%%%", - "%fo..%1...%B.P%%%%%%%%%%", + "%LL;.%.::1%%%%%%%%%%%%%%", + "%%%%O%.::.O..[%%%%%%%%%%", + "%f0..%1...%D.[%%%%%%%%%%", "%.c..%%*%%%%%%%%%%%%%%%%", "%ctc.%!~~~~~~~~~~~~~~~~~", "%.c..%%%%%%%%%%%%%%%%%%%", @@ -542,27 +543,25 @@ "{": "f_utility_shelf", "w": "f_workbench", "r": "f_rack", - "K": "f_tatami", + "I": "f_tatami", "c": "f_chair", "l": "f_locker", "n": "f_sink", "f": "f_fridge", "t": "f_table", - "V": "f_exercise", - "S": "f_ergometer", - "P": "f_bed", - "p": "f_sofa", + "[": "f_bed", + "L": "f_sofa", "1": "f_armchair", - "T": "f_floor_lamp", - "o": "f_oven", - "B": "f_bookcase" + ";": "f_floor_lamp", + "0": "f_oven", + "D": "f_bookcase" }, "items": { "{": [ { "item": "sewage_plant", "chance": 30 }, { "item": "supplies_plumbing", "chance": 20 } ], "w": { "item": "supplies_hardware", "chance": 50 }, "r": { "item": "tools_electronics", "chance": 30, "repeat": [ 1, 3 ] }, - "B": { "item": "dojo_manuals", "chance": 60, "repeat": [ 1, 2 ] }, - "P": { "item": "bed", "chance": 60 }, + "D": { "item": "dojo_manuals", "chance": 60, "repeat": [ 1, 2 ] }, + "[": { "item": "bed", "chance": 60 }, "f": { "item": "fridgesnacks", "chance": 80, "repeat": [ 1, 2 ] } }, "place_loot": [ @@ -573,14 +572,14 @@ { "item": "judo_belt_blue", "x": 4, "y": 13 }, { "item": "pizza_cheese", "x": 2, "y": 21 } ], - "place_monsters": [ { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.35 } ] + "place_monsters": [ { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.2 } ] } }, { "id": "cannibal_corpse", "type": "item_group", "subtype": "collection", - "items": [ { "group": "clothing_work_set", "chance": 40 }, { "group": "supplies_plumbing", "chance": 10 }, { "item": "corpse" } ] + "items": [ { "group": "clothing_work_set", "chance": 40 }, { "group": "supplies_plumbing", "chance": 20 }, { "item": "corpse" } ] }, { "id": "human_remains", From 9f7963e67bf65d433c9feedac093902f8fc35df6 Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sun, 28 Jul 2019 15:37:30 +0300 Subject: [PATCH 088/113] lint --- data/json/mapgen/sewage_treatment.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/mapgen/sewage_treatment.json b/data/json/mapgen/sewage_treatment.json index e61c92a7ab3af..e9a6c38f11017 100644 --- a/data/json/mapgen/sewage_treatment.json +++ b/data/json/mapgen/sewage_treatment.json @@ -70,7 +70,7 @@ "h": "t_thconc_floor", "D": "t_thconc_floor", "1": "t_thconc_floor", - "=": "t_rock_floor", + "=": "t_rock_floor", ">": "t_stairs_up", "!": "t_bars", "~": "t_sewage", From ac79d23b1787f9231b25d7c2ff0462adca2d59ad Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sat, 3 Aug 2019 18:47:05 +0300 Subject: [PATCH 089/113] savegame migration --- src/savegame.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/savegame.cpp b/src/savegame.cpp index d19c82272d4e3..ab76d4f5fa81c 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -575,6 +575,23 @@ void overmap::convert_terrain( const std::unordered_map & nearby.push_back( { 0, hospital, -2, hospital_entrance, hospital + "_8_north" } ); nearby.push_back( { 2, hospital, -2, hospital, hospital + "_9_north" } ); } + + } else if( old == "sewage_treatment" ) { + new_id = oter_id( "sewage_treatment_1_1_0_north" ); + } else if( old == "sewage_treatment_under" ) { + const std::string base = "sewage_treatment_under"; + const std::string other = "sewage_treatment_hub"; + nearby.push_back( { 1, other, 0, base, "sewage_treatment_0_0_-1_north" } ); + nearby.push_back( { -1, other, 0, base, "sewage_treatment_0_0_-1_north" } ); + nearby.push_back( { 2, base, -1, other, "sewage_treatment_0_0_-1_north" } ); + nearby.push_back( { 0, other, -1, other, "sewage_treatment_0_0_-1_north" } ); + nearby.push_back( { -2, base, -1, other, "sewage_treatment_0_0_-1_north" } ); + nearby.push_back( { 0, other, 1, other, "sewage_treatment_0_0_-1_north" } ); + nearby.push_back( { 1, other, 1, other, "sewage_treatment_0_0_-1_north" } ); + nearby.push_back( { -1, other, 1, other, "sewage_treatment_0_0_-1_north" } ); + } else if( old == "sewage_treatment_hub" ) { + new_id = oter_id( "sewage_treatment_1_0_-1_north" ); + } else if( old == "cathedral_1_entrance" ) { const std::string base = "cathedral_1_"; const std::string other = "cathedral_1"; From 6261ca8b841080f280ebd7e36d3a0075f9e4551a Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sat, 17 Aug 2019 22:21:00 +0300 Subject: [PATCH 090/113] Update sewage_treatment.json --- data/json/mapgen/sewage_treatment.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/data/json/mapgen/sewage_treatment.json b/data/json/mapgen/sewage_treatment.json index e9a6c38f11017..68422e4d37dab 100644 --- a/data/json/mapgen/sewage_treatment.json +++ b/data/json/mapgen/sewage_treatment.json @@ -22,6 +22,7 @@ "O": "t_thconc_floor", "H": "t_sconc_wall", "z": "t_concrete", + "9": "t_gutter_downspout", "-": "t_wall_metal", "W": "t_window_no_curtains", "t": "t_thconc_floor", @@ -154,7 +155,7 @@ "fill_ter": "t_floor", "rows": [ "|||_.......pp......._|||||||||||||||||||||||||||", - "| _................_ ? ? ? ??? ? ? |", + "| _................_ ? ? ? ??? ? ? 9 |", "| _.......pp......._ HHWHWHHHWHWWWHWHHHWHH |", "| _................_ ? H^,6#,H,d,,,,,d,H^d,H |", "| _.......pp......._____W,,d,,H#6,,#,,6#H,6#W?|", @@ -448,7 +449,7 @@ }, "place_monsters": [ { "monster": "GROUP_ZOMBIE", "x": [ 26, 36 ], "y": [ 12, 18 ], "density": 0.35 }, - { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 36, 38 ], "density": 0.35 }, + { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 36, 38 ], "density": 0.1 }, { "monster": "GROUP_SEWAGE_TREATMENT", "x": 36, "y": 3, "density": 0.2 }, { "monster": "GROUP_SEWAGE_TREATMENT", "x": [ 30, 32 ], "y": [ 35, 36 ], "density": 0.2 } ] @@ -498,7 +499,7 @@ }, "fields": { "=": { "field": "fd_blood", "intensity": 1, "age": 990, "chance": 40 } }, "place_monsters": [ - { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.2 }, + { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.1 }, { "monster": "GROUP_CHUD", "x": [ 4, 6 ], "y": [ 16, 18 ], "density": 0.2 } ] } @@ -572,7 +573,7 @@ { "item": "judo_belt_blue", "x": 4, "y": 13 }, { "item": "pizza_cheese", "x": 2, "y": 21 } ], - "place_monsters": [ { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.2 } ] + "place_monsters": [ { "monster": "GROUP_ZOMBIE", "x": [ 16, 20 ], "y": [ 11, 14 ], "density": 0.1 } ] } }, { From 9d8f857f83b4184b1b2c50bafa4830ec1477b80f Mon Sep 17 00:00:00 2001 From: chaisawlajatang <40278862+chaisawlajatang@users.noreply.github.com> Date: Sat, 17 Aug 2019 22:44:38 +0300 Subject: [PATCH 091/113] Roof update --- data/json/mapgen/sewage_treatment.json | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/data/json/mapgen/sewage_treatment.json b/data/json/mapgen/sewage_treatment.json index 68422e4d37dab..62fb6fb0cc988 100644 --- a/data/json/mapgen/sewage_treatment.json +++ b/data/json/mapgen/sewage_treatment.json @@ -284,9 +284,9 @@ " |................XX.3 ", " |...................3 ", " |...................3 ", - " |.................### ", - " |.................#># ", - " |.................### ", + " |.................HHH ", + " |.................B>H ", + " |.................HHH ", " |...................3 ", " |...................3 ", " |...................3 ", @@ -326,7 +326,12 @@ " " ], "palettes": [ "roof_palette" ], - "terrain": { ">": "t_ladder_down", "X": "t_radio_tower" }, + "terrain": { + ">": "t_ladder_down", + "X": "t_radio_tower", + "H": "t_sconc_wall", + "B": "t_door_metal_pickable" + }, "place_nested": [ { "chunks": [ [ "null", 20 ], [ "roof_4x4_utility", 50 ], [ "roof_4x4_utility_1", 40 ] ], From 3d3d1f6044af6269f8d6425dd344db2de44b96e6 Mon Sep 17 00:00:00 2001 From: Pete Date: Thu, 15 Aug 2019 17:03:03 -0500 Subject: [PATCH 092/113] Let overmap special conversion convert unrelated adjacent tiles to enlarge specials. --- src/savegame.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/savegame.cpp b/src/savegame.cpp index ab76d4f5fa81c..6cbb9d04cf319 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -391,6 +391,7 @@ void overmap::convert_terrain( const std::unordered_map & }; std::vector nearby; + std::vector> convert_unrelated_adjacent_tiles; if( old == "apartments_con_tower_1_entrance" || old == "apartments_mod_tower_1_entrance" ) { @@ -790,6 +791,10 @@ void overmap::convert_terrain( const std::unordered_map & break; } } + + for( const std::pair &conv : convert_unrelated_adjacent_tiles ) { + ter( pos + conv.first ) = oter_id( conv.second ); + } } } From 46b37280ded0bce81319b032e9ff88916418b5bd Mon Sep 17 00:00:00 2001 From: Pete Date: Thu, 15 Aug 2019 17:03:17 -0500 Subject: [PATCH 093/113] Use new conversion to properly convert the sewage plant special! --- src/savegame.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/savegame.cpp b/src/savegame.cpp index 6cbb9d04cf319..5df2c56f9bc37 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -576,23 +576,32 @@ void overmap::convert_terrain( const std::unordered_map & nearby.push_back( { 0, hospital, -2, hospital_entrance, hospital + "_8_north" } ); nearby.push_back( { 2, hospital, -2, hospital, hospital + "_9_north" } ); } - + } else if( old == "sewage_treatment" ) { - new_id = oter_id( "sewage_treatment_1_1_0_north" ); + new_id = oter_id( "sewage_treatment_0_1_0_north" ); + convert_unrelated_adjacent_tiles.push_back( { tripoint_north, "sewage_treatment_0_0_0_north" } ); + convert_unrelated_adjacent_tiles.push_back( { tripoint_east, "sewage_treatment_1_1_0_north" } ); + convert_unrelated_adjacent_tiles.push_back( { tripoint_north_east, "sewage_treatment_1_0_0_north" } ); + convert_unrelated_adjacent_tiles.push_back( { tripoint_above, "sewage_treatment_0_1_roof_north" } ); + convert_unrelated_adjacent_tiles.push_back( { tripoint_north + tripoint_above, "sewage_treatment_0_0_roof_north" } ); + convert_unrelated_adjacent_tiles.push_back( { tripoint_east + tripoint_above, "sewage_treatment_1_1_roof_north" } ); + convert_unrelated_adjacent_tiles.push_back( { tripoint_north_east + tripoint_above, "sewage_treatment_1_0_roof_north" } ); } else if( old == "sewage_treatment_under" ) { const std::string base = "sewage_treatment_under"; - const std::string other = "sewage_treatment_hub"; - nearby.push_back( { 1, other, 0, base, "sewage_treatment_0_0_-1_north" } ); - nearby.push_back( { -1, other, 0, base, "sewage_treatment_0_0_-1_north" } ); - nearby.push_back( { 2, base, -1, other, "sewage_treatment_0_0_-1_north" } ); - nearby.push_back( { 0, other, -1, other, "sewage_treatment_0_0_-1_north" } ); - nearby.push_back( { -2, base, -1, other, "sewage_treatment_0_0_-1_north" } ); - nearby.push_back( { 0, other, 1, other, "sewage_treatment_0_0_-1_north" } ); - nearby.push_back( { 1, other, 1, other, "sewage_treatment_0_0_-1_north" } ); - nearby.push_back( { -1, other, 1, other, "sewage_treatment_0_0_-1_north" } ); + const std::string hub = "sewage_treatment_hub"; + nearby.push_back( { -1, hub, 0, base, "sewage_treatment_1_1_-1_north" } ); + nearby.push_back( { -1, base, 1, hub, "sewage_treatment_0_0_-1_north" } ); + nearby.push_back( { -1, base, 1, base, "sewage_treatment_1_0_-1_north" } ); + // Fill empty space with something other than drivethrus. + nearby.push_back( { 1, hub, 0, base, "empty_rock" } ); + nearby.push_back( { 1, base, 0, base, "empty_rock" } ); + nearby.push_back( { -1, base, -1, base, "empty_rock" } ); + nearby.push_back( { 0, base, -1, base, "empty_rock" } ); + nearby.push_back( { 1, base, -1, base, "empty_rock" } ); } else if( old == "sewage_treatment_hub" ) { - new_id = oter_id( "sewage_treatment_1_0_-1_north" ); - + new_id = oter_id( "sewage_treatment_0_1_-1_north" ); + convert_unrelated_adjacent_tiles.push_back( { tripoint( 2, 0, 0 ), "sewage_treatment_2_1_-1_north" } ); + convert_unrelated_adjacent_tiles.push_back( { tripoint( 2, -1, 0 ), "sewage_treatment_2_0_-1_north" } ); } else if( old == "cathedral_1_entrance" ) { const std::string base = "cathedral_1_"; const std::string other = "cathedral_1"; From 7b33080ede54ebb7d3e0d5bb6cb2b0e544d93155 Mon Sep 17 00:00:00 2001 From: anothersimulacrum Date: Sun, 18 Aug 2019 16:16:41 +0000 Subject: [PATCH 094/113] style --- data/json/mapgen/sewage_treatment.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/data/json/mapgen/sewage_treatment.json b/data/json/mapgen/sewage_treatment.json index 62fb6fb0cc988..1c36bfb05acc7 100644 --- a/data/json/mapgen/sewage_treatment.json +++ b/data/json/mapgen/sewage_treatment.json @@ -326,12 +326,7 @@ " " ], "palettes": [ "roof_palette" ], - "terrain": { - ">": "t_ladder_down", - "X": "t_radio_tower", - "H": "t_sconc_wall", - "B": "t_door_metal_pickable" - }, + "terrain": { ">": "t_ladder_down", "X": "t_radio_tower", "H": "t_sconc_wall", "B": "t_door_metal_pickable" }, "place_nested": [ { "chunks": [ [ "null", 20 ], [ "roof_4x4_utility", 50 ], [ "roof_4x4_utility_1", 40 ] ], From 38466265d9b0706848ee94b673ac851e05c3878a Mon Sep 17 00:00:00 2001 From: Pete Date: Sun, 18 Aug 2019 12:57:44 -0500 Subject: [PATCH 095/113] Remove unnecessary vector::insert call. Thanks jbytheway! --- src/computer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/computer.cpp b/src/computer.cpp index 6d615401c2d30..c7d3adbab967e 100644 --- a/src/computer.cpp +++ b/src/computer.cpp @@ -1693,7 +1693,6 @@ SEARCHING FOR NEAREST REFUGEE CENTER, PLEASE WAIT ... " ) ); // Check completed missions too, so people can't repeatedly get the mission. const std::vector completed_missions = g->u.get_completed_missions(); std::vector missions = g->u.get_active_missions(); - missions.reserve( completed_missions.size() ); missions.insert( missions.end(), completed_missions.begin(), completed_missions.end() ); const bool has_mission = std::any_of( missions.begin(), missions.end(), [ &mission_type, From be821bcd44d53e6eba94c6d7eae4a7c2ce2f916e Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 17 Aug 2019 20:08:57 -0400 Subject: [PATCH 096/113] Add overloads to game, line, map functions --- src/game.h | 5 ++++- src/line.h | 3 +++ src/map.h | 11 +++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/game.h b/src/game.h index d0f4c57e16e70..f36af86f26a58 100644 --- a/src/game.h +++ b/src/game.h @@ -125,6 +125,7 @@ struct w_map { }; bool is_valid_in_w_terrain( int x, int y ); +bool is_valid_in_w_terrain( const point &p ); // There is only one game instance, so losing a few bytes of memory // due to padding is not much of a concern. @@ -640,6 +641,7 @@ class game /** open vehicle interaction screen */ void exam_vehicle( vehicle &veh, int cx = 0, int cy = 0 ); + void exam_vehicle( vehicle &veh, const point &cp ); // Forcefully close a door at p. // The function checks for creatures/items/vehicles at that point and @@ -799,13 +801,14 @@ class game void replace_stair_monsters(); void update_stair_monsters(); /** - * Shift all active monsters, the shift vector (x,y,z) is the number of + * Shift all active monsters, the shift vector is the number of * shifted submaps. Monsters that are outside of the reality bubble after * shifting are despawned. * Note on z-levels: this works with vertical shifts, but currently all * monsters are despawned upon a vertical shift. */ void shift_monsters( int shiftx, int shifty, int shiftz ); + void shift_monsters( const tripoint &shift ); public: /** * Despawn a specific monster, it's stored on the overmap. Also removes diff --git a/src/line.h b/src/line.h index 1e26d48cde12b..94d211e7dd370 100644 --- a/src/line.h +++ b/src/line.h @@ -48,6 +48,7 @@ inline constexpr unsigned make_xyz_unit( const int x, const int y, const int z ) // This more general version of this function gives correct values for larger inputs. unsigned make_xyz( int x, int y, int z ); +unsigned make_xyz( const tripoint & ); enum direction : unsigned { ABOVENORTHWEST = make_xyz_unit( -1, -1, -1 ), @@ -82,6 +83,8 @@ enum direction : unsigned { }; direction direction_from( int x, int y, int z = 0 ) noexcept; +direction direction_from( const point &p ) noexcept; +direction direction_from( const tripoint &p ) noexcept; direction direction_from( int x1, int y1, int x2, int y2 ) noexcept; direction direction_from( const tripoint &p, const tripoint &q ); diff --git a/src/map.h b/src/map.h index 81ff1cdc813a8..ed10f8bd35f52 100644 --- a/src/map.h +++ b/src/map.h @@ -345,16 +345,17 @@ class map * @param update_vehicles If true, add vehicles to the vehicle cache. */ void load( int wx, int wy, int wz, bool update_vehicles ); - void load( const tripoint &p, const bool update_vehicles ) { + void load( const tripoint &p, bool update_vehicles ) { load( p.x, p.y, p.z, update_vehicles ); } /** - * Shift the map along the vector (sx,sy). + * Shift the map along the vector s. * This is like loading the map with coordinates derived from the current * position of the map (@ref abs_sub) plus the shift vector. * Note: the map must have been loaded before this can be called. */ void shift( int sx, int sy ); + void shift( const point &s ); /** * Moves the map vertically to (not by!) newz. * Does not actually shift anything, only forces cache updates. @@ -1052,6 +1053,8 @@ class map bool process_fields(); // See fields.cpp bool process_fields_in_submap( submap *current_submap, int submap_x, int submap_y, int submap_z ); // See fields.cpp + bool process_fields_in_submap( submap *current_submap, + const tripoint &submap_pos ); // See fields.cpp /** * Apply field effects to the creature when it's on a square with fields. */ @@ -1628,6 +1631,8 @@ class map template void function_over( const tripoint &start, const tripoint &end, Functor fun ) const; template + void function_over( int stx, int sty, int stz, const tripoint &end, Functor fun ) const; + template void function_over( int stx, int sty, int stz, int enx, int eny, int enz, Functor fun ) const; /*@}*/ @@ -1705,6 +1710,8 @@ class map template void shift_bitset_cache( std::bitset &cache, int sx, int sy ); +template +void shift_bitset_cache( std::bitset &cache, const point &s ); std::vector closest_points_first( int radius, const point ¢er ); // Does not build "piles" - does the same as above functions, except in tripoints From 63fcc096e75ee84e77273aa0e699e911d20dd9d9 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 17 Aug 2019 20:53:25 -0400 Subject: [PATCH 097/113] Refactor callers --- src/activity_handlers.cpp | 2 +- src/animation.cpp | 2 +- src/game.cpp | 12 +- src/line.cpp | 6 +- src/map.cpp | 4 +- src/map_field.cpp | 2 +- tests/line_test.cpp | 240 +++++++++++++++++++------------------- tests/map_memory.cpp | 16 +-- tests/vehicle_drag.cpp | 4 +- 9 files changed, 144 insertions(+), 144 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 67f70e09d18ce..c0c4221f90c21 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1968,7 +1968,7 @@ void activity_handlers::vehicle_finish( player_activity *act, player *p ) g->refresh_all(); // TODO: Z (and also where the activity is queued) // Or not, because the vehicle coordinates are dropped anyway - g->exam_vehicle( vp->vehicle(), act->values[ 2 ], act->values[ 3 ] ); + g->exam_vehicle( vp->vehicle(), point( act->values[ 2 ], act->values[ 3 ] ) ); return; } else { dbg( D_ERROR ) << "game:process_activity: ACT_VEHICLE: vehicle not found"; diff --git a/src/animation.cpp b/src/animation.cpp index 3f63e4662a8b3..71eebdbe54400 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -708,7 +708,7 @@ void draw_sct_curses( game &g ) const int dy = off.y + text.getPosY(); const int dx = off.x + text.getPosX(); - if( !is_valid_in_w_terrain( dx, dy ) ) { + if( !is_valid_in_w_terrain( point( dx, dy ) ) ) { continue; } diff --git a/src/game.cpp b/src/game.cpp index 0cc82daa4a1d8..0f30389c6b8cf 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3335,7 +3335,7 @@ void game::draw_critter( const Creature &critter, const tripoint ¢er ) { const int my = POSY + ( critter.posy() - center.y ); const int mx = POSX + ( critter.posx() - center.x ); - if( !is_valid_in_w_terrain( mx, my ) ) { + if( !is_valid_in_w_terrain( point( mx, my ) ) ) { return; } if( critter.posz() != center.z && m.has_zlevels() ) { @@ -3897,7 +3897,7 @@ void game::mon_info( const catacurses::window &w, int hor_padding ) const int mx = POSX + ( c->posx() - view.x ); const int my = POSY + ( c->posy() - view.y ); int index = 8; - if( !is_valid_in_w_terrain( mx, my ) ) { + if( !is_valid_in_w_terrain( point( mx, my ) ) ) { // for compatibility with old code, see diagram below, it explains the values for index, // also might need revisiting one z-levels are in. switch( dir_to_mon ) { @@ -10234,7 +10234,7 @@ void game::vertical_move( int movez, bool force ) if( mons != nullptr ) { critter_tracker->remove( *mons ); } - shift_monsters( 0, 0, movez ); + shift_monsters( tripoint( 0, 0, movez ) ); } std::vector> npcs_to_bring; @@ -10514,7 +10514,7 @@ void game::vertical_shift( const int z_after ) m.set_transparency_cache_dirty( z_before ); m.set_outside_cache_dirty( z_before ); m.load( tripoint( get_levx(), get_levy(), z_after ), true ); - shift_monsters( 0, 0, z_after - z_before ); + shift_monsters( tripoint( 0, 0, z_after - z_before ) ); reload_npcs(); } else { // Shift the map itself @@ -10607,10 +10607,10 @@ point game::update_map( int &x, int &y ) } // this handles loading/unloading submaps that have scrolled on or off the viewport - m.shift( shift.x, shift.y ); + m.shift( shift ); // Shift monsters - shift_monsters( shift.x, shift.y, 0 ); + shift_monsters( tripoint( shift, 0 ) ); const point shift_ms = sm_to_ms_copy( shift ); u.shift_destination( -shift_ms ); diff --git a/src/line.cpp b/src/line.cpp index 86b820c643d67..4e310938c3a63 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -396,18 +396,18 @@ std::vector continue_line( const std::vector &line, const in direction direction_from( const int x, const int y, const int z ) noexcept { - return static_cast( make_xyz( x, y, z ) ); + return static_cast( make_xyz( tripoint( x, y, z ) ) ); } direction direction_from( const int x1, const int y1, const int x2, const int y2 ) noexcept { - return direction_from( x2 - x1, y2 - y1 ); + return direction_from( point( x2 - x1, y2 - y1 ) ); } direction direction_from( const tripoint &p, const tripoint &q ) { // Note: Z-coordinate has to be inverted either here or in direction definitions - return direction_from( q.x - p.x, q.y - p.y, -( q.z - p.z ) ); + return direction_from( tripoint( q.x - p.x, q.y - p.y, -( q.z - p.z ) ) ); } point direction_XY( const direction dir ) diff --git a/src/map.cpp b/src/map.cpp index eb0fb09b6960a..f113928e76421 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -6565,8 +6565,8 @@ void map::shift( const int sx, const int sy ) // Clear vehicle list and rebuild after shift clear_vehicle_cache( gridz ); clear_vehicle_list( gridz ); - shift_bitset_cache( get_cache( gridz ).map_memory_seen_cache, sx, sy ); - shift_bitset_cache( get_cache( gridz ).field_cache, sx, sy ); + shift_bitset_cache( get_cache( gridz ).map_memory_seen_cache, point( sx, sy ) ); + shift_bitset_cache( get_cache( gridz ).field_cache, point( sx, sy ) ); if( sx >= 0 ) { for( int gridx = 0; gridx < my_MAPSIZE; gridx++ ) { if( sy >= 0 ) { diff --git a/src/map_field.cpp b/src/map_field.cpp index 9f0847c4b36b5..355c80dc633dd 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -136,7 +136,7 @@ bool map::process_fields() for( int y = 0; y < my_MAPSIZE; y++ ) { if( field_cache[ x + y * MAPSIZE ] ) { submap *const current_submap = get_submap_at_grid( { x, y, z } ); - const bool cur_dirty = process_fields_in_submap( current_submap, x, y, z ); + const bool cur_dirty = process_fields_in_submap( current_submap, tripoint( x, y, z ) ); zlev_dirty |= cur_dirty; } } diff --git a/tests/line_test.cpp b/tests/line_test.cpp index 8f36c1ee822a5..3de4df608c216 100644 --- a/tests/line_test.cpp +++ b/tests/line_test.cpp @@ -124,128 +124,128 @@ TEST_CASE( "Test bounds for mapping x/y/z/ offsets to direction enum" ) // Test the unit square values at distance 1 and 2. // Test the multiples of 30deg at 60 squares. // Test 22 deg to either side of the cardinal directions. - REQUIRE( make_xyz( -1, -1, -1 ) == ABOVENORTHWEST ); - REQUIRE( make_xyz( -2, -2, -2 ) == ABOVENORTHWEST ); - REQUIRE( make_xyz( -30, -60, -1 ) == ABOVENORTHWEST ); - REQUIRE( make_xyz( -60, -60, -1 ) == ABOVENORTHWEST ); - REQUIRE( make_xyz( -60, -30, -1 ) == ABOVENORTHWEST ); - REQUIRE( make_xyz( -1, -1, 0 ) == NORTHWEST ); - REQUIRE( make_xyz( -2, -2, 0 ) == NORTHWEST ); - REQUIRE( make_xyz( -60, -60, 0 ) == NORTHWEST ); - REQUIRE( make_xyz( -1, -1, 1 ) == BELOWNORTHWEST ); - REQUIRE( make_xyz( -2, -2, 2 ) == BELOWNORTHWEST ); - REQUIRE( make_xyz( -30, -60, 1 ) == BELOWNORTHWEST ); - REQUIRE( make_xyz( -60, -60, 1 ) == BELOWNORTHWEST ); - REQUIRE( make_xyz( -60, -30, 1 ) == BELOWNORTHWEST ); - REQUIRE( make_xyz( 0, -1, -1 ) == ABOVENORTH ); - REQUIRE( make_xyz( 0, -2, -2 ) == ABOVENORTH ); - REQUIRE( make_xyz( -22, -60, -1 ) == ABOVENORTH ); - REQUIRE( make_xyz( 0, -60, -1 ) == ABOVENORTH ); - REQUIRE( make_xyz( 22, -60, -1 ) == ABOVENORTH ); - REQUIRE( make_xyz( 0, -1, 0 ) == NORTH ); - REQUIRE( make_xyz( 0, -2, 0 ) == NORTH ); - REQUIRE( make_xyz( -22, -60, 0 ) == NORTH ); - REQUIRE( make_xyz( 0, -60, 0 ) == NORTH ); - REQUIRE( make_xyz( 22, -60, 0 ) == NORTH ); - REQUIRE( make_xyz( 0, -1, 1 ) == BELOWNORTH ); - REQUIRE( make_xyz( 0, -2, 2 ) == BELOWNORTH ); - REQUIRE( make_xyz( -22, -60, 1 ) == BELOWNORTH ); - REQUIRE( make_xyz( 0, -60, 1 ) == BELOWNORTH ); - REQUIRE( make_xyz( 22, -60, 1 ) == BELOWNORTH ); - REQUIRE( make_xyz( 1, -1, -1 ) == ABOVENORTHEAST ); - REQUIRE( make_xyz( 2, -2, -2 ) == ABOVENORTHEAST ); - REQUIRE( make_xyz( 30, -60, -1 ) == ABOVENORTHEAST ); - REQUIRE( make_xyz( 60, -60, -1 ) == ABOVENORTHEAST ); - REQUIRE( make_xyz( 60, -30, -1 ) == ABOVENORTHEAST ); - REQUIRE( make_xyz( 1, -1, 0 ) == NORTHEAST ); - REQUIRE( make_xyz( 2, -2, 0 ) == NORTHEAST ); - REQUIRE( make_xyz( 30, -60, 0 ) == NORTHEAST ); - REQUIRE( make_xyz( 60, -60, 0 ) == NORTHEAST ); - REQUIRE( make_xyz( 60, -30, 0 ) == NORTHEAST ); - REQUIRE( make_xyz( 1, -1, 1 ) == BELOWNORTHEAST ); - REQUIRE( make_xyz( 2, -2, 2 ) == BELOWNORTHEAST ); - REQUIRE( make_xyz( 30, -60, 1 ) == BELOWNORTHEAST ); - REQUIRE( make_xyz( 60, -60, 1 ) == BELOWNORTHEAST ); - REQUIRE( make_xyz( 60, -30, 1 ) == BELOWNORTHEAST ); + REQUIRE( make_xyz( tripoint( -1, -1, -1 ) ) == ABOVENORTHWEST ); + REQUIRE( make_xyz( tripoint( -2, -2, -2 ) ) == ABOVENORTHWEST ); + REQUIRE( make_xyz( tripoint( -30, -60, -1 ) ) == ABOVENORTHWEST ); + REQUIRE( make_xyz( tripoint( -60, -60, -1 ) ) == ABOVENORTHWEST ); + REQUIRE( make_xyz( tripoint( -60, -30, -1 ) ) == ABOVENORTHWEST ); + REQUIRE( make_xyz( tripoint_north_west ) == NORTHWEST ); + REQUIRE( make_xyz( tripoint( -2, -2, 0 ) ) == NORTHWEST ); + REQUIRE( make_xyz( tripoint( -60, -60, 0 ) ) == NORTHWEST ); + REQUIRE( make_xyz( tripoint( -1, -1, 1 ) ) == BELOWNORTHWEST ); + REQUIRE( make_xyz( tripoint( -2, -2, 2 ) ) == BELOWNORTHWEST ); + REQUIRE( make_xyz( tripoint( -30, -60, 1 ) ) == BELOWNORTHWEST ); + REQUIRE( make_xyz( tripoint( -60, -60, 1 ) ) == BELOWNORTHWEST ); + REQUIRE( make_xyz( tripoint( -60, -30, 1 ) ) == BELOWNORTHWEST ); + REQUIRE( make_xyz( tripoint( 0, -1, -1 ) ) == ABOVENORTH ); + REQUIRE( make_xyz( tripoint( 0, -2, -2 ) ) == ABOVENORTH ); + REQUIRE( make_xyz( tripoint( -22, -60, -1 ) ) == ABOVENORTH ); + REQUIRE( make_xyz( tripoint( 0, -60, -1 ) ) == ABOVENORTH ); + REQUIRE( make_xyz( tripoint( 22, -60, -1 ) ) == ABOVENORTH ); + REQUIRE( make_xyz( tripoint_north ) == NORTH ); + REQUIRE( make_xyz( tripoint( 0, -2, 0 ) ) == NORTH ); + REQUIRE( make_xyz( tripoint( -22, -60, 0 ) ) == NORTH ); + REQUIRE( make_xyz( tripoint( 0, -60, 0 ) ) == NORTH ); + REQUIRE( make_xyz( tripoint( 22, -60, 0 ) ) == NORTH ); + REQUIRE( make_xyz( tripoint( 0, -1, 1 ) ) == BELOWNORTH ); + REQUIRE( make_xyz( tripoint( 0, -2, 2 ) ) == BELOWNORTH ); + REQUIRE( make_xyz( tripoint( -22, -60, 1 ) ) == BELOWNORTH ); + REQUIRE( make_xyz( tripoint( 0, -60, 1 ) ) == BELOWNORTH ); + REQUIRE( make_xyz( tripoint( 22, -60, 1 ) ) == BELOWNORTH ); + REQUIRE( make_xyz( tripoint( 1, -1, -1 ) ) == ABOVENORTHEAST ); + REQUIRE( make_xyz( tripoint( 2, -2, -2 ) ) == ABOVENORTHEAST ); + REQUIRE( make_xyz( tripoint( 30, -60, -1 ) ) == ABOVENORTHEAST ); + REQUIRE( make_xyz( tripoint( 60, -60, -1 ) ) == ABOVENORTHEAST ); + REQUIRE( make_xyz( tripoint( 60, -30, -1 ) ) == ABOVENORTHEAST ); + REQUIRE( make_xyz( tripoint_north_east ) == NORTHEAST ); + REQUIRE( make_xyz( tripoint( 2, -2, 0 ) ) == NORTHEAST ); + REQUIRE( make_xyz( tripoint( 30, -60, 0 ) ) == NORTHEAST ); + REQUIRE( make_xyz( tripoint( 60, -60, 0 ) ) == NORTHEAST ); + REQUIRE( make_xyz( tripoint( 60, -30, 0 ) ) == NORTHEAST ); + REQUIRE( make_xyz( tripoint( 1, -1, 1 ) ) == BELOWNORTHEAST ); + REQUIRE( make_xyz( tripoint( 2, -2, 2 ) ) == BELOWNORTHEAST ); + REQUIRE( make_xyz( tripoint( 30, -60, 1 ) ) == BELOWNORTHEAST ); + REQUIRE( make_xyz( tripoint( 60, -60, 1 ) ) == BELOWNORTHEAST ); + REQUIRE( make_xyz( tripoint( 60, -30, 1 ) ) == BELOWNORTHEAST ); - REQUIRE( make_xyz( -1, 0, -1 ) == ABOVEWEST ); - REQUIRE( make_xyz( -2, 0, -2 ) == ABOVEWEST ); - REQUIRE( make_xyz( -60, -22, -1 ) == ABOVEWEST ); - REQUIRE( make_xyz( -60, 0, -1 ) == ABOVEWEST ); - REQUIRE( make_xyz( -60, 22, -1 ) == ABOVEWEST ); - REQUIRE( make_xyz( -1, 0, 0 ) == WEST ); - REQUIRE( make_xyz( -2, 0, 0 ) == WEST ); - REQUIRE( make_xyz( -60, -22, 0 ) == WEST ); - REQUIRE( make_xyz( -60, 0, 0 ) == WEST ); - REQUIRE( make_xyz( -60, 22, 0 ) == WEST ); - REQUIRE( make_xyz( -1, 0, 1 ) == BELOWWEST ); - REQUIRE( make_xyz( -2, 0, 2 ) == BELOWWEST ); - REQUIRE( make_xyz( -60, -22, 1 ) == BELOWWEST ); - REQUIRE( make_xyz( -60, 0, 1 ) == BELOWWEST ); - REQUIRE( make_xyz( -60, 22, 1 ) == BELOWWEST ); - REQUIRE( make_xyz( 0, 0, -1 ) == ABOVECENTER ); - REQUIRE( make_xyz( 0, 0, -2 ) == ABOVECENTER ); - REQUIRE( make_xyz( 0, 0, 0 ) == CENTER ); - REQUIRE( make_xyz( 0, 0, 1 ) == BELOWCENTER ); - REQUIRE( make_xyz( 0, 0, 2 ) == BELOWCENTER ); - REQUIRE( make_xyz( 1, 0, -1 ) == ABOVEEAST ); - REQUIRE( make_xyz( 2, 0, -2 ) == ABOVEEAST ); - REQUIRE( make_xyz( 60, -22, -1 ) == ABOVEEAST ); - REQUIRE( make_xyz( 60, 0, -1 ) == ABOVEEAST ); - REQUIRE( make_xyz( 60, 22, -1 ) == ABOVEEAST ); - REQUIRE( make_xyz( 1, 0, 0 ) == EAST ); - REQUIRE( make_xyz( 2, 0, 0 ) == EAST ); - REQUIRE( make_xyz( 60, -22, 0 ) == EAST ); - REQUIRE( make_xyz( 60, 0, 0 ) == EAST ); - REQUIRE( make_xyz( 60, 22, 0 ) == EAST ); - REQUIRE( make_xyz( 1, 0, 1 ) == BELOWEAST ); - REQUIRE( make_xyz( 2, 0, 2 ) == BELOWEAST ); - REQUIRE( make_xyz( 60, -22, 1 ) == BELOWEAST ); - REQUIRE( make_xyz( 60, 0, 1 ) == BELOWEAST ); - REQUIRE( make_xyz( 60, 22, 1 ) == BELOWEAST ); + REQUIRE( make_xyz( tripoint( -1, 0, -1 ) ) == ABOVEWEST ); + REQUIRE( make_xyz( tripoint( -2, 0, -2 ) ) == ABOVEWEST ); + REQUIRE( make_xyz( tripoint( -60, -22, -1 ) ) == ABOVEWEST ); + REQUIRE( make_xyz( tripoint( -60, 0, -1 ) ) == ABOVEWEST ); + REQUIRE( make_xyz( tripoint( -60, 22, -1 ) ) == ABOVEWEST ); + REQUIRE( make_xyz( tripoint_west ) == WEST ); + REQUIRE( make_xyz( tripoint( -2, 0, 0 ) ) == WEST ); + REQUIRE( make_xyz( tripoint( -60, -22, 0 ) ) == WEST ); + REQUIRE( make_xyz( tripoint( -60, 0, 0 ) ) == WEST ); + REQUIRE( make_xyz( tripoint( -60, 22, 0 ) ) == WEST ); + REQUIRE( make_xyz( tripoint( -1, 0, 1 ) ) == BELOWWEST ); + REQUIRE( make_xyz( tripoint( -2, 0, 2 ) ) == BELOWWEST ); + REQUIRE( make_xyz( tripoint( -60, -22, 1 ) ) == BELOWWEST ); + REQUIRE( make_xyz( tripoint( -60, 0, 1 ) ) == BELOWWEST ); + REQUIRE( make_xyz( tripoint( -60, 22, 1 ) ) == BELOWWEST ); + REQUIRE( make_xyz( tripoint_below ) == ABOVECENTER ); + REQUIRE( make_xyz( tripoint( 0, 0, -2 ) ) == ABOVECENTER ); + REQUIRE( make_xyz( tripoint_zero ) == CENTER ); + REQUIRE( make_xyz( tripoint_above ) == BELOWCENTER ); + REQUIRE( make_xyz( tripoint( 0, 0, 2 ) ) == BELOWCENTER ); + REQUIRE( make_xyz( tripoint( 1, 0, -1 ) ) == ABOVEEAST ); + REQUIRE( make_xyz( tripoint( 2, 0, -2 ) ) == ABOVEEAST ); + REQUIRE( make_xyz( tripoint( 60, -22, -1 ) ) == ABOVEEAST ); + REQUIRE( make_xyz( tripoint( 60, 0, -1 ) ) == ABOVEEAST ); + REQUIRE( make_xyz( tripoint( 60, 22, -1 ) ) == ABOVEEAST ); + REQUIRE( make_xyz( tripoint_east ) == EAST ); + REQUIRE( make_xyz( tripoint( 2, 0, 0 ) ) == EAST ); + REQUIRE( make_xyz( tripoint( 60, -22, 0 ) ) == EAST ); + REQUIRE( make_xyz( tripoint( 60, 0, 0 ) ) == EAST ); + REQUIRE( make_xyz( tripoint( 60, 22, 0 ) ) == EAST ); + REQUIRE( make_xyz( tripoint( 1, 0, 1 ) ) == BELOWEAST ); + REQUIRE( make_xyz( tripoint( 2, 0, 2 ) ) == BELOWEAST ); + REQUIRE( make_xyz( tripoint( 60, -22, 1 ) ) == BELOWEAST ); + REQUIRE( make_xyz( tripoint( 60, 0, 1 ) ) == BELOWEAST ); + REQUIRE( make_xyz( tripoint( 60, 22, 1 ) ) == BELOWEAST ); - REQUIRE( make_xyz( -1, 1, -1 ) == ABOVESOUTHWEST ); - REQUIRE( make_xyz( -2, 2, -2 ) == ABOVESOUTHWEST ); - REQUIRE( make_xyz( -30, 60, -1 ) == ABOVESOUTHWEST ); - REQUIRE( make_xyz( -60, 60, -1 ) == ABOVESOUTHWEST ); - REQUIRE( make_xyz( -60, 30, -1 ) == ABOVESOUTHWEST ); - REQUIRE( make_xyz( -1, 1, 0 ) == SOUTHWEST ); - REQUIRE( make_xyz( -2, 2, 0 ) == SOUTHWEST ); - REQUIRE( make_xyz( -30, 60, 0 ) == SOUTHWEST ); - REQUIRE( make_xyz( -60, 60, 0 ) == SOUTHWEST ); - REQUIRE( make_xyz( -60, 30, 0 ) == SOUTHWEST ); - REQUIRE( make_xyz( -1, 1, 1 ) == BELOWSOUTHWEST ); - REQUIRE( make_xyz( -2, 2, 2 ) == BELOWSOUTHWEST ); - REQUIRE( make_xyz( -30, 60, 1 ) == BELOWSOUTHWEST ); - REQUIRE( make_xyz( -60, 60, 1 ) == BELOWSOUTHWEST ); - REQUIRE( make_xyz( -60, 30, 1 ) == BELOWSOUTHWEST ); - REQUIRE( make_xyz( 0, 1, -1 ) == ABOVESOUTH ); - REQUIRE( make_xyz( 0, 2, -2 ) == ABOVESOUTH ); - REQUIRE( make_xyz( 0, 60, -1 ) == ABOVESOUTH ); - REQUIRE( make_xyz( 0, 1, 0 ) == SOUTH ); - REQUIRE( make_xyz( -22, 60, 0 ) == SOUTH ); - REQUIRE( make_xyz( 0, 60, 0 ) == SOUTH ); - REQUIRE( make_xyz( 22, 60, 0 ) == SOUTH ); - REQUIRE( make_xyz( 0, 1, 1 ) == BELOWSOUTH ); - REQUIRE( make_xyz( 0, 2, 2 ) == BELOWSOUTH ); - REQUIRE( make_xyz( -22, 60, 1 ) == BELOWSOUTH ); - REQUIRE( make_xyz( 0, 60, 1 ) == BELOWSOUTH ); - REQUIRE( make_xyz( 22, 60, 1 ) == BELOWSOUTH ); - REQUIRE( make_xyz( 1, 1, -1 ) == ABOVESOUTHEAST ); - REQUIRE( make_xyz( 2, 2, -2 ) == ABOVESOUTHEAST ); - REQUIRE( make_xyz( 30, 60, -1 ) == ABOVESOUTHEAST ); - REQUIRE( make_xyz( 60, 60, -1 ) == ABOVESOUTHEAST ); - REQUIRE( make_xyz( 60, 30, -1 ) == ABOVESOUTHEAST ); - REQUIRE( make_xyz( 1, 1, 0 ) == SOUTHEAST ); - REQUIRE( make_xyz( 2, 2, 0 ) == SOUTHEAST ); - REQUIRE( make_xyz( 30, 60, 0 ) == SOUTHEAST ); - REQUIRE( make_xyz( 60, 60, 0 ) == SOUTHEAST ); - REQUIRE( make_xyz( 60, 30, 0 ) == SOUTHEAST ); - REQUIRE( make_xyz( 1, 1, 1 ) == BELOWSOUTHEAST ); - REQUIRE( make_xyz( 2, 2, 2 ) == BELOWSOUTHEAST ); - REQUIRE( make_xyz( 30, 60, 1 ) == BELOWSOUTHEAST ); - REQUIRE( make_xyz( 60, 60, 1 ) == BELOWSOUTHEAST ); - REQUIRE( make_xyz( 60, 30, 1 ) == BELOWSOUTHEAST ); + REQUIRE( make_xyz( tripoint( -1, 1, -1 ) ) == ABOVESOUTHWEST ); + REQUIRE( make_xyz( tripoint( -2, 2, -2 ) ) == ABOVESOUTHWEST ); + REQUIRE( make_xyz( tripoint( -30, 60, -1 ) ) == ABOVESOUTHWEST ); + REQUIRE( make_xyz( tripoint( -60, 60, -1 ) ) == ABOVESOUTHWEST ); + REQUIRE( make_xyz( tripoint( -60, 30, -1 ) ) == ABOVESOUTHWEST ); + REQUIRE( make_xyz( tripoint_south_west ) == SOUTHWEST ); + REQUIRE( make_xyz( tripoint( -2, 2, 0 ) ) == SOUTHWEST ); + REQUIRE( make_xyz( tripoint( -30, 60, 0 ) ) == SOUTHWEST ); + REQUIRE( make_xyz( tripoint( -60, 60, 0 ) ) == SOUTHWEST ); + REQUIRE( make_xyz( tripoint( -60, 30, 0 ) ) == SOUTHWEST ); + REQUIRE( make_xyz( tripoint( -1, 1, 1 ) ) == BELOWSOUTHWEST ); + REQUIRE( make_xyz( tripoint( -2, 2, 2 ) ) == BELOWSOUTHWEST ); + REQUIRE( make_xyz( tripoint( -30, 60, 1 ) ) == BELOWSOUTHWEST ); + REQUIRE( make_xyz( tripoint( -60, 60, 1 ) ) == BELOWSOUTHWEST ); + REQUIRE( make_xyz( tripoint( -60, 30, 1 ) ) == BELOWSOUTHWEST ); + REQUIRE( make_xyz( tripoint( 0, 1, -1 ) ) == ABOVESOUTH ); + REQUIRE( make_xyz( tripoint( 0, 2, -2 ) ) == ABOVESOUTH ); + REQUIRE( make_xyz( tripoint( 0, 60, -1 ) ) == ABOVESOUTH ); + REQUIRE( make_xyz( tripoint_south ) == SOUTH ); + REQUIRE( make_xyz( tripoint( -22, 60, 0 ) ) == SOUTH ); + REQUIRE( make_xyz( tripoint( 0, 60, 0 ) ) == SOUTH ); + REQUIRE( make_xyz( tripoint( 22, 60, 0 ) ) == SOUTH ); + REQUIRE( make_xyz( tripoint( 0, 1, 1 ) ) == BELOWSOUTH ); + REQUIRE( make_xyz( tripoint( 0, 2, 2 ) ) == BELOWSOUTH ); + REQUIRE( make_xyz( tripoint( -22, 60, 1 ) ) == BELOWSOUTH ); + REQUIRE( make_xyz( tripoint( 0, 60, 1 ) ) == BELOWSOUTH ); + REQUIRE( make_xyz( tripoint( 22, 60, 1 ) ) == BELOWSOUTH ); + REQUIRE( make_xyz( tripoint( 1, 1, -1 ) ) == ABOVESOUTHEAST ); + REQUIRE( make_xyz( tripoint( 2, 2, -2 ) ) == ABOVESOUTHEAST ); + REQUIRE( make_xyz( tripoint( 30, 60, -1 ) ) == ABOVESOUTHEAST ); + REQUIRE( make_xyz( tripoint( 60, 60, -1 ) ) == ABOVESOUTHEAST ); + REQUIRE( make_xyz( tripoint( 60, 30, -1 ) ) == ABOVESOUTHEAST ); + REQUIRE( make_xyz( tripoint_south_east ) == SOUTHEAST ); + REQUIRE( make_xyz( tripoint( 2, 2, 0 ) ) == SOUTHEAST ); + REQUIRE( make_xyz( tripoint( 30, 60, 0 ) ) == SOUTHEAST ); + REQUIRE( make_xyz( tripoint( 60, 60, 0 ) ) == SOUTHEAST ); + REQUIRE( make_xyz( tripoint( 60, 30, 0 ) ) == SOUTHEAST ); + REQUIRE( make_xyz( tripoint( 1, 1, 1 ) ) == BELOWSOUTHEAST ); + REQUIRE( make_xyz( tripoint( 2, 2, 2 ) ) == BELOWSOUTHEAST ); + REQUIRE( make_xyz( tripoint( 30, 60, 1 ) ) == BELOWSOUTHEAST ); + REQUIRE( make_xyz( tripoint( 60, 60, 1 ) ) == BELOWSOUTHEAST ); + REQUIRE( make_xyz( tripoint( 60, 30, 1 ) ) == BELOWSOUTHEAST ); } TEST_CASE( "squares_closer_to_test" ) diff --git a/tests/map_memory.cpp b/tests/map_memory.cpp index 20f8a7cbaabe5..21f43811b122a 100644 --- a/tests/map_memory.cpp +++ b/tests/map_memory.cpp @@ -168,56 +168,56 @@ TEST_CASE( "shift_map_memory_seen_cache" ) GIVEN( "all bits are set" ) { test_cache.set(); WHEN( "positive x shift" ) { - shift_bitset_cache( test_cache, 1, 0 ); + shift_bitset_cache( test_cache, point_east ); THEN( "last 12 columns are 0, rest are 1" ) { check_quadrants( test_cache, last_twelve, 0, true, false, true, false ); } } WHEN( "negative x shift" ) { - shift_bitset_cache( test_cache, -1, 0 ); + shift_bitset_cache( test_cache, point_west ); THEN( "first 12 columns are 0, rest are 1" ) { check_quadrants( test_cache, first_twelve, 0, false, true, false, true ); } } WHEN( "positive y shift" ) { - shift_bitset_cache( test_cache, 0, 1 ); + shift_bitset_cache( test_cache, point_south ); THEN( "last 12 rows are 0, rest are 1" ) { check_quadrants( test_cache, 0, last_twelve, true, true, false, false ); } } WHEN( "negative y shift" ) { - shift_bitset_cache( test_cache, 0, -1 ); + shift_bitset_cache( test_cache, point_north ); THEN( "first 12 rows are 0, rest are 1" ) { check_quadrants( test_cache, 0, first_twelve, false, false, true, true ); } } WHEN( "positive x, positive y shift" ) { - shift_bitset_cache( test_cache, 1, 1 ); + shift_bitset_cache( test_cache, point_south_east ); THEN( "last 12 columns and rows are 0, rest are 1" ) { check_quadrants( test_cache, last_twelve, last_twelve, true, false, false, false ); } } WHEN( "positive x, negative y shift" ) { - shift_bitset_cache( test_cache, 1, -1 ); + shift_bitset_cache( test_cache, point_north_east ); THEN( "last 12 columns and first 12 rows are 0, rest are 1" ) { check_quadrants( test_cache, last_twelve, first_twelve, false, false, true, false ); } } WHEN( "negative x, positive y shift" ) { - shift_bitset_cache( test_cache, -1, 1 ); + shift_bitset_cache( test_cache, point_south_west ); THEN( "first 12 columns and last 12 rows are 0, rest are 1" ) { check_quadrants( test_cache, first_twelve, last_twelve, false, true, false, false ); } } WHEN( "negative x, negative y shift" ) { - shift_bitset_cache( test_cache, -1, -1 ); + shift_bitset_cache( test_cache, point_north_west ); THEN( "first 12 columns and rows are 0, rest are 1" ) { check_quadrants( test_cache, first_twelve, first_twelve, false, false, false, true ); diff --git a/tests/vehicle_drag.cpp b/tests/vehicle_drag.cpp index bdbe9968da129..cbb083ad5b423 100644 --- a/tests/vehicle_drag.cpp +++ b/tests/vehicle_drag.cpp @@ -54,8 +54,8 @@ static void clear_game_drag( const ter_id &terrain ) g->m.invalidate_map_cache( 0 ); g->m.build_map_cache( 0, true ); // hard force a rebuild of caches - g->m.shift( 0, 1 ); - g->m.shift( 0, -1 ); + g->m.shift( point_south ); + g->m.shift( point_north ); } From 4db80c78d05b31fc13ea84908b3de96d04b5ebbb Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 17 Aug 2019 22:39:37 -0400 Subject: [PATCH 098/113] Port function implementations --- src/game.cpp | 18 ++++----- src/game.h | 5 +-- src/line.cpp | 19 +++++++--- src/line.h | 2 - src/map.cpp | 93 +++++++++++++++++++++-------------------------- src/map.h | 18 +-------- src/map_field.cpp | 16 ++++---- 7 files changed, 75 insertions(+), 96 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 0f30389c6b8cf..a409fc6987b7a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -243,9 +243,9 @@ std::unique_ptr g; //The one and only uistate instance uistatedata uistate; -bool is_valid_in_w_terrain( int x, int y ) +bool is_valid_in_w_terrain( const point &p ) { - return x >= 0 && x < TERRAIN_WINDOW_WIDTH && y >= 0 && y < TERRAIN_WINDOW_HEIGHT; + return p.x >= 0 && p.x < TERRAIN_WINDOW_WIDTH && p.y >= 0 && p.y < TERRAIN_WINDOW_HEIGHT; } // This is the main game set-up process. @@ -5063,9 +5063,9 @@ void game::use_item( int pos ) u.invalidate_crafting_inventory(); } -void game::exam_vehicle( vehicle &veh, int cx, int cy ) +void game::exam_vehicle( vehicle &veh, const point &c ) { - auto act = veh_interact::run( veh, point( cx, cy ) ); + auto act = veh_interact::run( veh, c ); if( act ) { u.moves = 0; u.assign_activity( act ); @@ -10949,18 +10949,18 @@ void game::despawn_monster( monster &critter ) critter.set_hp( 0 ); } -void game::shift_monsters( const int shiftx, const int shifty, const int shiftz ) +void game::shift_monsters( const tripoint &shift ) { // If either shift argument is non-zero, we're shifting. - if( shiftx == 0 && shifty == 0 && shiftz == 0 ) { + if( shift == tripoint_zero ) { return; } for( monster &critter : all_monsters() ) { - if( shiftx != 0 || shifty != 0 ) { - critter.shift( point( shiftx, shifty ) ); + if( shift.xy() != point_zero ) { + critter.shift( shift.xy() ); } - if( m.inbounds( critter.pos() ) && ( shiftz == 0 || m.has_zlevels() ) ) { + if( m.inbounds( critter.pos() ) && ( shift.z == 0 || m.has_zlevels() ) ) { // We're inbounds, so don't despawn after all. // No need to shift Z-coordinates, they are absolute continue; diff --git a/src/game.h b/src/game.h index f36af86f26a58..fbcd343d6ca22 100644 --- a/src/game.h +++ b/src/game.h @@ -124,7 +124,6 @@ struct w_map { catacurses::window win; }; -bool is_valid_in_w_terrain( int x, int y ); bool is_valid_in_w_terrain( const point &p ); // There is only one game instance, so losing a few bytes of memory @@ -640,8 +639,7 @@ class game void set_safe_mode( safe_mode_type mode ); /** open vehicle interaction screen */ - void exam_vehicle( vehicle &veh, int cx = 0, int cy = 0 ); - void exam_vehicle( vehicle &veh, const point &cp ); + void exam_vehicle( vehicle &veh, const point &cp = point_zero ); // Forcefully close a door at p. // The function checks for creatures/items/vehicles at that point and @@ -807,7 +805,6 @@ class game * Note on z-levels: this works with vertical shifts, but currently all * monsters are despawned upon a vertical shift. */ - void shift_monsters( int shiftx, int shifty, int shiftz ); void shift_monsters( const tripoint &shift ); public: /** diff --git a/src/line.cpp b/src/line.cpp index 4e310938c3a63..ecd0605763800 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -310,17 +310,19 @@ double atan2_degrees( const point &p ) } // This more general version of this function gives correct values for larger values. -unsigned make_xyz( const int x, const int y, const int z ) +unsigned make_xyz( const tripoint &p ) { static constexpr double sixteenth_arc = M_PI / 8; - int vertical_position = ( ( z > 0 ) ? 2u : ( z < 0 ) ? 1u : 0u ) * 9u; - if( x == 0 && y == 0 ) { + int vertical_position = ( ( p.z > 0 ) ? 2u : ( p.z < 0 ) ? 1u : 0u ) * 9u; + if( p.xy() == point_zero ) { return vertical_position; } // Get the arctan of the angle and divide by approximately 22.5 deg to get the octant. // the angle is in, then truncate it and map to the right direction. // You can read 'octant' as being "number of 22.5 degree sections away from due south". - int octant = atan2( x, y ) / sixteenth_arc; + // FIXME: atan2 normally takes arguments in ( y, x ) order. This is + // passing ( x, y ). + int octant = atan2( p.x, p.y ) / sixteenth_arc; switch( octant ) { case 0: return SOUTH + vertical_position; @@ -394,9 +396,14 @@ std::vector continue_line( const std::vector &line, const in return line_to( line.back(), move_along_line( line.back(), line, distance ) ); } -direction direction_from( const int x, const int y, const int z ) noexcept +direction direction_from( const point &p ) noexcept { - return static_cast( make_xyz( tripoint( x, y, z ) ) ); + return static_cast( make_xyz( tripoint( p, 0 ) ) ); +} + +direction direction_from( const tripoint &p ) noexcept +{ + return static_cast( make_xyz( p ) ); } direction direction_from( const int x1, const int y1, const int x2, const int y2 ) noexcept diff --git a/src/line.h b/src/line.h index 94d211e7dd370..65b7eeddda445 100644 --- a/src/line.h +++ b/src/line.h @@ -47,7 +47,6 @@ inline constexpr unsigned make_xyz_unit( const int x, const int y, const int z ) } // This more general version of this function gives correct values for larger inputs. -unsigned make_xyz( int x, int y, int z ); unsigned make_xyz( const tripoint & ); enum direction : unsigned { @@ -82,7 +81,6 @@ enum direction : unsigned { BELOWSOUTHEAST = make_xyz_unit( 1, 1, 1 ), }; -direction direction_from( int x, int y, int z = 0 ) noexcept; direction direction_from( const point &p ) noexcept; direction direction_from( const tripoint &p ) noexcept; direction direction_from( int x1, int y1, int x2, int y2 ) noexcept; diff --git a/src/map.cpp b/src/map.cpp index f113928e76421..a1ec34f095197 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -6454,14 +6454,14 @@ void map::save() } } -void map::load( const int wx, const int wy, const int wz, const bool update_vehicle ) +void map::load( const tripoint &w, const bool update_vehicle ) { for( auto &traps : traplocs ) { traps.clear(); } field_furn_locs.clear(); submaps_with_active_items.clear(); - set_abs_sub( tripoint( wx, wy, wz ) ); + set_abs_sub( w ); for( int gridx = 0; gridx < my_MAPSIZE; gridx++ ) { for( int gridy = 0; gridy < my_MAPSIZE; gridy++ ) { loadn( point( gridx, gridy ), update_vehicle ); @@ -6499,10 +6499,10 @@ void map::shift_traps( const tripoint &shift ) } template -void shift_bitset_cache( std::bitset &cache, const int sx, const int sy ) +void shift_bitset_cache( std::bitset &cache, const point &s ) { // sx shifts by MULTIPLIER rows, sy shifts by MULTIPLIER columns. - int shift_amount = sx * MULTIPLIER + sy * SIZE * MULTIPLIER; + int shift_amount = s.x * MULTIPLIER + s.y * SIZE * MULTIPLIER; if( shift_amount > 0 ) { cache >>= static_cast( shift_amount ); } else if( shift_amount < 0 ) { @@ -6510,10 +6510,10 @@ void shift_bitset_cache( std::bitset &cache, const int sx, const int } // Shifting in the y direction shifted in 0 values, no no additional clearing is necessary, but // a shift in the x direction makes values "wrap" to the next row, and they need to be zeroed. - if( sx == 0 ) { + if( s.x == 0 ) { return; } - const size_t x_offset = sx > 0 ? SIZE - MULTIPLIER : 0; + const size_t x_offset = s.x > 0 ? SIZE - MULTIPLIER : 0; for( size_t y = 0; y < SIZE; ++y ) { size_t y_offset = y * SIZE; for( size_t x = 0; x < MULTIPLIER; ++x ) { @@ -6524,34 +6524,32 @@ void shift_bitset_cache( std::bitset &cache, const int sx, const int template void shift_bitset_cache( std::bitset &cache, - const int sx, const int sy ); + const point &s ); template void -shift_bitset_cache( std::bitset &cache, const int sx, const int sy ); +shift_bitset_cache( std::bitset &cache, const point &s ); -void map::shift( const int sx, const int sy ) +void map::shift( const point &sp ) { // Special case of 0-shift; refresh the map - if( sx == 0 && sy == 0 ) { + if( sp == point_zero ) { return; // Skip this? } - const int absx = get_abs_sub().x; - const int absy = get_abs_sub().y; - const int wz = get_abs_sub().z; + const tripoint abs = get_abs_sub(); - set_abs_sub( tripoint( absx + sx, absy + sy, wz ) ); + set_abs_sub( abs + sp ); // if player is in vehicle, (s)he must be shifted with vehicle too if( g->u.in_vehicle ) { - g->u.setx( g->u.posx() - sx * SEEX ); - g->u.sety( g->u.posy() - sy * SEEY ); + g->u.setx( g->u.posx() - sp.x * SEEX ); + g->u.sety( g->u.posy() - sp.y * SEEY ); } - shift_traps( tripoint( sx, sy, 0 ) ); + shift_traps( tripoint( sp, 0 ) ); vehicle *remoteveh = g->remoteveh(); - const int zmin = zlevels ? -OVERMAP_DEPTH : wz; - const int zmax = zlevels ? OVERMAP_HEIGHT : wz; + const int zmin = zlevels ? -OVERMAP_DEPTH : abs.z; + const int zmax = zlevels ? OVERMAP_HEIGHT : abs.z; for( int gridz = zmin; gridz <= zmax; gridz++ ) { for( vehicle *veh : get_cache( gridz ).vehicle_list ) { veh->zones_dirty = true; @@ -6565,18 +6563,18 @@ void map::shift( const int sx, const int sy ) // Clear vehicle list and rebuild after shift clear_vehicle_cache( gridz ); clear_vehicle_list( gridz ); - shift_bitset_cache( get_cache( gridz ).map_memory_seen_cache, point( sx, sy ) ); - shift_bitset_cache( get_cache( gridz ).field_cache, point( sx, sy ) ); - if( sx >= 0 ) { + shift_bitset_cache( get_cache( gridz ).map_memory_seen_cache, sp ); + shift_bitset_cache( get_cache( gridz ).field_cache, sp ); + if( sp.x >= 0 ) { for( int gridx = 0; gridx < my_MAPSIZE; gridx++ ) { - if( sy >= 0 ) { + if( sp.y >= 0 ) { for( int gridy = 0; gridy < my_MAPSIZE; gridy++ ) { if( gridx == 0 || gridy == 0 ) { - submaps_with_active_items.erase( { absx + gridx, absy + gridy, gridz } ); + submaps_with_active_items.erase( { abs.x + gridx, abs.y + gridy, gridz } ); } - if( gridx + sx < my_MAPSIZE && gridy + sy < my_MAPSIZE ) { + if( gridx + sp.x < my_MAPSIZE && gridy + sp.y < my_MAPSIZE ) { copy_grid( tripoint( gridx, gridy, gridz ), - tripoint( gridx + sx, gridy + sy, gridz ) ); + tripoint( gridx + sp.x, gridy + sp.y, gridz ) ); update_vehicle_list( get_submap_at_grid( {gridx, gridy, gridz} ), gridz ); } else { loadn( tripoint( gridx, gridy, gridz ), true ); @@ -6585,11 +6583,11 @@ void map::shift( const int sx, const int sy ) } else { // sy < 0; work through it backwards for( int gridy = my_MAPSIZE - 1; gridy >= 0; gridy-- ) { if( gridx == 0 || gridy == my_MAPSIZE - 1 ) { - submaps_with_active_items.erase( { absx + gridx, absy + gridy, gridz } ); + submaps_with_active_items.erase( { abs.x + gridx, abs.y + gridy, gridz } ); } - if( gridx + sx < my_MAPSIZE && gridy + sy >= 0 ) { + if( gridx + sp.x < my_MAPSIZE && gridy + sp.y >= 0 ) { copy_grid( tripoint( gridx, gridy, gridz ), - tripoint( gridx + sx, gridy + sy, gridz ) ); + tripoint( gridx + sp.x, gridy + sp.y, gridz ) ); update_vehicle_list( get_submap_at_grid( { gridx, gridy, gridz } ), gridz ); } else { loadn( tripoint( gridx, gridy, gridz ), true ); @@ -6599,14 +6597,14 @@ void map::shift( const int sx, const int sy ) } } else { // sx < 0; work through it backwards for( int gridx = my_MAPSIZE - 1; gridx >= 0; gridx-- ) { - if( sy >= 0 ) { + if( sp.y >= 0 ) { for( int gridy = 0; gridy < my_MAPSIZE; gridy++ ) { if( gridx == my_MAPSIZE - 1 || gridy == 0 ) { - submaps_with_active_items.erase( { absx + gridx, absy + gridy, gridz } ); + submaps_with_active_items.erase( { abs.x + gridx, abs.y + gridy, gridz } ); } - if( gridx + sx >= 0 && gridy + sy < my_MAPSIZE ) { + if( gridx + sp.x >= 0 && gridy + sp.y < my_MAPSIZE ) { copy_grid( tripoint( gridx, gridy, gridz ), - tripoint( gridx + sx, gridy + sy, gridz ) ); + tripoint( gridx + sp.x, gridy + sp.y, gridz ) ); update_vehicle_list( get_submap_at_grid( { gridx, gridy, gridz } ), gridz ); } else { loadn( tripoint( gridx, gridy, gridz ), true ); @@ -6615,11 +6613,11 @@ void map::shift( const int sx, const int sy ) } else { // sy < 0; work through it backwards for( int gridy = my_MAPSIZE - 1; gridy >= 0; gridy-- ) { if( gridx == my_MAPSIZE - 1 || gridy == my_MAPSIZE - 1 ) { - submaps_with_active_items.erase( { absx + gridx, absy + gridy, gridz } ); + submaps_with_active_items.erase( { abs.x + gridx, abs.y + gridy, gridz } ); } - if( gridx + sx >= 0 && gridy + sy >= 0 ) { + if( gridx + sp.x >= 0 && gridy + sp.y >= 0 ) { copy_grid( tripoint( gridx, gridy, gridz ), - tripoint( gridx + sx, gridy + sy, gridz ) ); + tripoint( gridx + sp.x, gridy + sp.y, gridz ) ); update_vehicle_list( get_submap_at_grid( { gridx, gridy, gridz } ), gridz ); } else { loadn( tripoint( gridx, gridy, gridz ), true ); @@ -6638,7 +6636,7 @@ void map::shift( const int sx, const int sy ) std::set old_cache = std::move( support_cache_dirty ); support_cache_dirty.clear(); for( const auto &pt : old_cache ) { - support_cache_dirty.insert( pt + point( -sx * SEEX, -sy * SEEY ) ); + support_cache_dirty.insert( pt + point( -sp.x * SEEX, -sp.y * SEEY ) ); } } } @@ -8227,22 +8225,15 @@ void map::creature_on_trap( Creature &c, const bool may_avoid ) template void map::function_over( const tripoint &start, const tripoint &end, Functor fun ) const -{ - function_over( start.x, start.y, start.z, end.x, end.y, end.z, fun ); -} - -template -void map::function_over( const int stx, const int sty, const int stz, - const int enx, const int eny, const int enz, Functor fun ) const { // start and end are just two points, end can be "before" start // Also clip the area to map area - const int minx = std::max( std::min( stx, enx ), 0 ); - const int miny = std::max( std::min( sty, eny ), 0 ); - const int minz = std::max( std::min( stz, enz ), -OVERMAP_DEPTH ); - const int maxx = std::min( std::max( stx, enx ), SEEX * my_MAPSIZE - 1 ); - const int maxy = std::min( std::max( sty, eny ), SEEY * my_MAPSIZE - 1 ); - const int maxz = std::min( std::max( stz, enz ), OVERMAP_HEIGHT ); + const int minx = std::max( std::min( start.x, end.x ), 0 ); + const int miny = std::max( std::min( start.y, end.y ), 0 ); + const int minz = std::max( std::min( start.z, end.z ), -OVERMAP_DEPTH ); + const int maxx = std::min( std::max( start.x, end.x ), SEEX * my_MAPSIZE - 1 ); + const int maxy = std::min( std::max( start.y, end.y ), SEEY * my_MAPSIZE - 1 ); + const int maxz = std::min( std::max( start.z, end.z ), OVERMAP_HEIGHT ); // Submaps that contain the bounding points const int min_smx = minx / SEEX; @@ -8316,7 +8307,7 @@ void map::scent_blockers( std::array, MAPSIZE_Y> &bl return ITER_CONTINUE; }; - function_over( min.x, min.y, abs_sub.z, max.x, max.y, abs_sub.z, fill_values ); + function_over( tripoint( min, abs_sub.z ), tripoint( max, abs_sub.z ), fill_values ); const rectangle local_bounds( min, max ); diff --git a/src/map.h b/src/map.h index ed10f8bd35f52..ca6253c88c4d7 100644 --- a/src/map.h +++ b/src/map.h @@ -338,23 +338,17 @@ class map * the @ref mapbuffer can not deliver the requested submap (as it does * not exist on disc). * This must be called before the map can be used at all! - * @param wx global coordinates of the submap at grid[0]. This + * @param p global coordinates of the submap at grid[0]. This * is in submap coordinates. - * @param wy see wx - * @param wz see wx, this is the z-level * @param update_vehicles If true, add vehicles to the vehicle cache. */ - void load( int wx, int wy, int wz, bool update_vehicles ); - void load( const tripoint &p, bool update_vehicles ) { - load( p.x, p.y, p.z, update_vehicles ); - } + void load( const tripoint &p, bool update_vehicles ); /** * Shift the map along the vector s. * This is like loading the map with coordinates derived from the current * position of the map (@ref abs_sub) plus the shift vector. * Note: the map must have been loaded before this can be called. */ - void shift( int sx, int sy ); void shift( const point &s ); /** * Moves the map vertically to (not by!) newz. @@ -1051,8 +1045,6 @@ class map //Spawns byproducts from items destroyed in fire. void create_burnproducts( const tripoint &p, const item &fuel, const units::mass &burned_mass ); bool process_fields(); // See fields.cpp - bool process_fields_in_submap( submap *current_submap, - int submap_x, int submap_y, int submap_z ); // See fields.cpp bool process_fields_in_submap( submap *current_submap, const tripoint &submap_pos ); // See fields.cpp /** @@ -1630,10 +1622,6 @@ class map /*@{*/ template void function_over( const tripoint &start, const tripoint &end, Functor fun ) const; - template - void function_over( int stx, int sty, int stz, const tripoint &end, Functor fun ) const; - template - void function_over( int stx, int sty, int stz, int enx, int eny, int enz, Functor fun ) const; /*@}*/ /** @@ -1708,8 +1696,6 @@ class map bool need_draw_lower_floor( const tripoint &p ); }; -template -void shift_bitset_cache( std::bitset &cache, int sx, int sy ); template void shift_bitset_cache( std::bitset &cache, const point &s ); diff --git a/src/map_field.cpp b/src/map_field.cpp index 355c80dc633dd..b23dc7bec4eb3 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -365,9 +365,9 @@ This is the general update function for field effects. This should only be calle If you need to insert a new field behavior per unit time add a case statement in the switch below. */ bool map::process_fields_in_submap( submap *const current_submap, - const int submap_x, const int submap_y, const int submap_z ) + const tripoint &submap ) { - scent_block sblk( submap_x, submap_y, submap_z, g->scent ); + scent_block sblk( submap.x, submap.y, submap.z, g->scent ); // This should be true only when the field changes transparency // More correctly: not just when the field is opaque, but when it changes state @@ -378,7 +378,7 @@ bool map::process_fields_in_submap( submap *const current_submap, field_entry *tmpfld = nullptr; tripoint thep; - thep.z = submap_z; + thep.z = submap.z; // Initialize the map tile wrapper maptile map_tile( current_submap, 0, 0 ); @@ -389,8 +389,8 @@ bool map::process_fields_in_submap( submap *const current_submap, for( locy = 0; locy < SEEY; locy++ ) { // This is a translation from local coordinates to submap coordinates. // All submaps are in one long 1d array. - thep.x = locx + submap_x * SEEX; - thep.y = locy + submap_y * SEEY; + thep.x = locx + submap.x * SEEX; + thep.y = locy + submap.y * SEEY; // A const reference to the tripoint above, so that the code below doesn't accidentally change it const tripoint &p = thep; // Get a reference to the field variable from the submap; @@ -1299,10 +1299,10 @@ bool map::process_fields_in_submap( submap *const current_submap, } const int minz = zlevels ? -OVERMAP_DEPTH : abs_sub.z; const int maxz = zlevels ? OVERMAP_HEIGHT : abs_sub.z; - for( int z = std::max( submap_z - 1, minz ); z <= std::min( submap_z + 1, maxz ); ++z ) { + for( int z = std::max( submap.z - 1, minz ); z <= std::min( submap.z + 1, maxz ); ++z ) { auto &field_cache = get_cache( z ).field_cache; - for( int y = std::max( submap_y - 1, 0 ); y <= std::min( submap_y + 1, MAPSIZE - 1 ); ++y ) { - for( int x = std::max( submap_x - 1, 0 ); x <= std::min( submap_x + 1, MAPSIZE - 1 ); ++x ) { + for( int y = std::max( submap.y - 1, 0 ); y <= std::min( submap.y + 1, MAPSIZE - 1 ); ++y ) { + for( int x = std::max( submap.x - 1, 0 ); x <= std::min( submap.x + 1, MAPSIZE - 1 ); ++x ) { if( get_submap_at_grid( { x, y, z } )->field_count > 0 ) { field_cache.set( x + y * MAPSIZE ); } else { From 9dc6451721cbe175addfd4763883594602b302aa Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sun, 18 Aug 2019 16:26:25 -0400 Subject: [PATCH 099/113] Add overloads in line.h --- src/line.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/line.h b/src/line.h index 65b7eeddda445..fab466e1cc6a0 100644 --- a/src/line.h +++ b/src/line.h @@ -84,6 +84,8 @@ enum direction : unsigned { direction direction_from( const point &p ) noexcept; direction direction_from( const tripoint &p ) noexcept; direction direction_from( int x1, int y1, int x2, int y2 ) noexcept; +direction direction_from( const point &p1, int x2, int y2 ) noexcept; +direction direction_from( const point &p1, const point &p2 ) noexcept; direction direction_from( const tripoint &p, const tripoint &q ); point direction_XY( direction dir ); @@ -99,6 +101,10 @@ std::string direction_suffix( const tripoint &p, const tripoint &q ); */ void bresenham( int x1, int y1, int x2, int y2, int t, const std::function &interact ); +void bresenham( const point &p1, int x2, int y2, int t, + const std::function &interact ); +void bresenham( const point &p1, const point &p2, int t, + const std::function &interact ); void bresenham( const tripoint &loc1, const tripoint &loc2, int t, int t2, const std::function &interact ); @@ -106,18 +112,22 @@ tripoint move_along_line( const tripoint &loc, const std::vector &line int distance ); // The "t" value decides WHICH Bresenham line is used. std::vector line_to( int x1, int y1, int x2, int y2, int t = 0 ); +std::vector line_to( const point &p1, int x2, int y2, int t = 0 ); std::vector line_to( const point &p1, const point &p2, int t = 0 ); // t and t2 decide which Bresenham line is used. std::vector line_to( const tripoint &loc1, const tripoint &loc2, int t = 0, int t2 = 0 ); // sqrt(dX^2 + dY^2) float trig_dist( int x1, int y1, int x2, int y2 ); +float trig_dist( const point &p1, int x2, int y2 ); float trig_dist( const point &loc1, const point &loc2 ); float trig_dist( const tripoint &loc1, const tripoint &loc2 ); // Roguelike distance; minimum of dX and dY int square_dist( int x1, int y1, int x2, int y2 ); +int square_dist( const point &p1, int x2, int y2 ); int square_dist( const point &loc1, const point &loc2 ); int square_dist( const tripoint &loc1, const tripoint &loc2 ); int rl_dist( int x1, int y1, int x2, int y2 ); +int rl_dist( const point &p1, int x2, int y2 ); int rl_dist( const tripoint &loc1, const tripoint &loc2 ); int rl_dist( const point &a, const point &b ); // Sum of distance in both axes @@ -131,6 +141,8 @@ double atan2_degrees( const point & ); float get_normalized_angle( const point &start, const point &end ); std::vector continue_line( const std::vector &line, int distance ); std::vector squares_in_direction( int x1, int y1, int x2, int y2 ); +std::vector squares_in_direction( const point &p1, int x2, int y2 ); +std::vector squares_in_direction( const point &p1, const point &p2 ); // Returns a vector of squares adjacent to @from that are closer to @to than @from is. // Currently limited to the same z-level as @from. std::vector squares_closer_to( const tripoint &from, const tripoint &to ); From ee8d5721bffe8e173a713a0c7299b8467e6f0161 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sun, 18 Aug 2019 19:58:15 -0400 Subject: [PATCH 100/113] Refactor callers of line functions --- src/creature.cpp | 5 ++--- src/drawing_primitives.cpp | 4 ++-- src/faction_camp.cpp | 16 ++++++++-------- src/game.cpp | 16 ++++++++-------- src/iuse.cpp | 4 ++-- src/map.cpp | 6 +++--- src/map_extras.cpp | 24 ++++++++++++------------ src/map_field.cpp | 2 +- src/mapgen.cpp | 19 ++++++++++--------- src/mapgen_functions.cpp | 20 ++++++++++---------- src/melee.cpp | 4 ++-- src/mission_util.cpp | 3 +-- src/monattack.cpp | 2 +- src/monmove.cpp | 4 ++-- src/overmap.cpp | 21 +++++++++++---------- src/player.cpp | 4 ++-- src/sounds.cpp | 4 ++-- src/timed_event.cpp | 2 +- src/vehicle.cpp | 6 +++--- tests/line_test.cpp | 11 ++++++----- tests/shadowcasting_test.cpp | 2 +- 21 files changed, 90 insertions(+), 89 deletions(-) diff --git a/src/creature.cpp b/src/creature.cpp index 8cdd92008f948..7b8daee17e97e 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -768,14 +768,13 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack if( source->is_player() ) { //player hits monster ranged SCT.add( posx(), posy(), - direction_from( 0, 0, posx() - source->posx(), posy() - source->posy() ), + direction_from( point_zero, point( posx() - source->posx(), posy() - source->posy() ) ), get_hp_bar( dealt_dam.total_damage(), get_hp_max(), true ).first, m_good, message, gmtSCTcolor ); if( get_hp() > 0 ) { SCT.add( posx(), posy(), - direction_from( 0, 0, posx() - source->posx(), - posy() - source->posy() ), + direction_from( point_zero, point( posx() - source->posx(), posy() - source->posy() ) ), get_hp_bar( get_hp(), get_hp_max(), true ).first, m_good, //~ "hit points", used in scrolling combat text _( "hp" ), m_neutral, "hp" ); diff --git a/src/drawing_primitives.cpp b/src/drawing_primitives.cpp index e379118f3b638..b87e6738883d1 100644 --- a/src/drawing_primitives.cpp +++ b/src/drawing_primitives.cpp @@ -36,7 +36,7 @@ void draw_rough_circle( std::functionset, const point &p, { for( int i = p.x - rad; i <= p.x + rad; i++ ) { for( int j = p.y - rad; j <= p.y + rad; j++ ) { - if( trig_dist( p.x, p.y, i, j ) + rng( 0, 3 ) <= rad ) { + if( trig_dist( p, point( i, j ) ) + rng( 0, 3 ) <= rad ) { set( point( i, j ) ); } } @@ -58,7 +58,7 @@ void draw_circle( std::functionset, const point &p, int r { for( int i = p.x - rad; i <= p.x + rad; i++ ) { for( int j = p.y - rad; j <= p.y + rad; j++ ) { - if( trig_dist( p.x, p.y, i, j ) <= rad ) { + if( trig_dist( p, point( i, j ) ) <= rad ) { set( point( i, j ) ); } } diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index 8095996251070..a743ee394daee 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -1497,7 +1497,7 @@ void basecamp::start_cut_logs() sample_npc.set_fake( true ); int tree_est = om_cutdown_trees_est( forest, 50 ); int tree_young_est = om_harvest_ter_est( sample_npc, forest, ter_id( "t_tree_young" ), 50 ); - int dist = rl_dist( forest.x, forest.y, omt_pos.x, omt_pos.y ); + int dist = rl_dist( forest.xy(), omt_pos.xy() ); //Very roughly what the player does + 6 hours for prep, clean up, breaks time_duration chop_time = 6_hours + 1_hours * tree_est + 7_minutes * tree_young_est; //Generous to believe the NPC can move ~ 2 logs or ~8 heavy sticks (3 per young tree?) @@ -1554,7 +1554,7 @@ void basecamp::start_clearcut() sample_npc.set_fake( true ); int tree_est = om_cutdown_trees_est( forest, 95 ); int tree_young_est = om_harvest_ter_est( sample_npc, forest, ter_id( "t_tree_young" ), 95 ); - int dist = rl_dist( forest.x, forest.y, omt_pos.x, omt_pos.y ); + int dist = rl_dist( forest.xy(), omt_pos.xy() ); //Very roughly what the player does + 6 hours for prep, clean up, breaks time_duration chop_time = 6_hours + 1_hours * tree_est + 7_minutes * tree_young_est; time_duration travel_time = companion_travel_time_calc( forest, omt_pos, 0_minutes, 2 ); @@ -1588,7 +1588,7 @@ void basecamp::start_setup_hide_site() popup( _( "Forests, swamps, and fields are valid hide site locations." ) ); tripoint forest = om_target_tile( omt_pos, 10, 90, hide_locations, true, true, omt_pos, true ); if( forest != tripoint( -999, -999, -999 ) ) { - int dist = rl_dist( forest.x, forest.y, omt_pos.x, omt_pos.y ); + int dist = rl_dist( forest.xy(), omt_pos.xy() ); inventory tgt_inv = g->u.inv; std::vector pos_inv = tgt_inv.items_with( []( const item & itm ) { return !itm.can_revive(); @@ -1627,7 +1627,7 @@ void basecamp::start_relay_hide_site() popup( _( "You must select an existing hide site." ) ); tripoint forest = om_target_tile( omt_pos, 10, 90, hide_locations, true, true, omt_pos, true ); if( forest != tripoint( -999, -999, -999 ) ) { - int dist = rl_dist( forest.x, forest.y, omt_pos.x, omt_pos.y ); + int dist = rl_dist( forest.xy(), omt_pos.xy() ); inventory tgt_inv = g->u.inv; std::vector pos_inv = tgt_inv.items_with( []( const item & itm ) { return !itm.can_revive(); @@ -1743,7 +1743,7 @@ void basecamp::start_fortifications( std::string &bldg_exp, bool by_radio ) } trips += 2; build_time += making.batch_duration(); - dist += rl_dist( fort_om.x, fort_om.y, omt_pos.x, omt_pos.y ); + dist += rl_dist( fort_om.xy(), omt_pos.xy() ); travel_time += companion_travel_time_calc( fort_om, omt_pos, 0_minutes, 2 ); } time_duration total_time = base_camps::to_workdays( travel_time + build_time ); @@ -2474,7 +2474,7 @@ bool basecamp::survey_return() return false; } - int dist = rl_dist( where.x, where.y, omt_pos.x, omt_pos.y ); + int dist = rl_dist( where.xy(), omt_pos.xy() ); if( dist != 1 ) { popup( _( "You must select a tile within %d range of the camp" ), 1 ); return false; @@ -2896,7 +2896,7 @@ tripoint om_target_tile( const tripoint &omt_pos, int min_range, int range, if( where == overmap::invalid_tripoint ) { return tripoint( -999, -999, -999 ); } - int dist = rl_dist( where.x, where.y, omt_pos.x, omt_pos.y ); + int dist = rl_dist( where.xy(), omt_pos.xy() ); if( dist > range || dist < min_range ) { popup( _( "You must select a target between %d and %d range from the base. Range: %d" ), min_range, range, dist ); @@ -3101,7 +3101,7 @@ std::vector om_companion_path( const tripoint &start, int range_start, std::vector note_pts = line_to( last, spt ); scout_points.insert( scout_points.end(), note_pts.begin(), note_pts.end() ); om_line_mark( last, spt ); - range -= rl_dist( spt.x, spt.y, last.x, last.y ); + range -= rl_dist( spt.xy(), last.xy() ); last = spt; oter_id &omt_ref = overmap_buffer.ter( last ); diff --git a/src/game.cpp b/src/game.cpp index a409fc6987b7a..9aff79a300d0b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2501,8 +2501,8 @@ bool game::try_get_right_click_action( action_id &act, const tripoint &mouse_tar return false; } - const bool is_adjacent = square_dist( mouse_target.x, mouse_target.y, u.posx(), u.posy() ) <= 1; - const bool is_self = square_dist( mouse_target.x, mouse_target.y, u.posx(), u.posy() ) <= 0; + const bool is_adjacent = square_dist( mouse_target.xy(), point( u.posx(), u.posy() ) ) <= 1; + const bool is_self = square_dist( mouse_target.xy(), point( u.posx(), u.posy() ) ) <= 0; if( const monster *const mon = critter_at( mouse_target ) ) { if( !u.sees( *mon ) ) { add_msg( _( "Nothing relevant here." ) ); @@ -3194,8 +3194,8 @@ struct npc_dist_to_player { bool operator()( const std::shared_ptr &a, const std::shared_ptr &b ) const { const tripoint apos = a->global_omt_location(); const tripoint bpos = b->global_omt_location(); - return square_dist( ppos.x, ppos.y, apos.x, apos.y ) < - square_dist( ppos.x, ppos.y, bpos.x, bpos.y ); + return square_dist( ppos.xy(), apos.xy() ) < + square_dist( ppos.xy(), bpos.xy() ); } }; @@ -3893,7 +3893,7 @@ void game::mon_info( const catacurses::window &w, int hor_padding ) for( auto &c : u.get_visible_creatures( MAPSIZE_X ) ) { const auto m = dynamic_cast( c ); const auto p = dynamic_cast( c ); - const auto dir_to_mon = direction_from( view.x, view.y, c->posx(), c->posy() ); + const auto dir_to_mon = direction_from( view.xy(), point( c->posx(), c->posy() ) ); const int mx = POSX + ( c->posx() - view.x ); const int my = POSY + ( c->posy() - view.y ); int index = 8; @@ -7507,8 +7507,8 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) const int y = iter->vIG[iThisPage].pos.y; mvwprintz( w_items, point( width - 6 - numw, iNum - iStartPos ), iNum == iActive ? c_light_green : c_light_gray, - "%*d %s", numw, rl_dist( 0, 0, x, y ), - direction_name_short( direction_from( 0, 0, x, y ) ) ); + "%*d %s", numw, rl_dist( point_zero, point( x, y ) ), + direction_name_short( direction_from( point_zero, point( x, y ) ) ) ); ++iter; } } else { @@ -10022,7 +10022,7 @@ static cata::optional point_selection_menu( const std::vectorglobal_sm_location(); - direction angle = direction_from( player_pos.x, player_pos.y, - tref.abs_sm_pos.x, tref.abs_sm_pos.y ); + direction angle = direction_from( player_pos.xy(), + tref.abs_sm_pos ); add_msg( _( "The signal seems strongest to the %s." ), direction_name( angle ) ); return it->type->charges_to_use(); } diff --git a/src/map.cpp b/src/map.cpp index a1ec34f095197..a1a0951c57f52 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -6093,7 +6093,7 @@ bool map::sees( const tripoint &F, const tripoint &T, const int range, int &bres // Ugly `if` for now if( !fov_3d || F.z == T.z ) { - bresenham( F.x, F.y, T.x, T.y, bresenham_slope, + bresenham( F.xy(), T.xy(), bresenham_slope, [this, &visible, &T]( const point & new_point ) { // Exit before checking the last square, it's still visible even if opaque. if( new_point.x == T.x && new_point.y == T.y ) { @@ -6329,12 +6329,12 @@ bool map::clear_path( const tripoint &f, const tripoint &t, const int range, } if( f.z == t.z ) { - if( ( range >= 0 && range < rl_dist( f.x, f.y, t.x, t.y ) ) || + if( ( range >= 0 && range < rl_dist( f.xy(), t.xy() ) ) || !inbounds( t ) ) { return false; // Out of range! } bool is_clear = true; - bresenham( f.x, f.y, t.x, t.y, 0, + bresenham( f.xy(), t.xy(), 0, [this, &is_clear, cost_min, cost_max, &t]( const point & new_point ) { // Exit before checking the last square, it's still reachable even if it is an obstacle. if( new_point.x == t.x && new_point.y == t.y ) { diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 9ae22763c80a7..697452e67cab0 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -941,7 +941,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) } //33% chance to spawn empty magazines used by soldiers - std::vector empty_magazines_locations = line_to( 15, 5, 20, 5 ); + std::vector empty_magazines_locations = line_to( point( 15, 5 ), point( 20, 5 ) ); for( auto &i : empty_magazines_locations ) { if( one_in( 3 ) ) { m.spawn_item( { i, abs_sub.z }, "stanag30" ); @@ -951,7 +951,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) //Horizontal line of barbed wire fence line( &m, t_fence_barbed, 0, 9, SEEX * 2, 9 ); - std::vector barbed_wire = line_to( 0, 9, SEEX * 2, 9 ); + std::vector barbed_wire = line_to( point( 0, 9 ), point( SEEX * 2, 9 ) ); for( auto &i : barbed_wire ) { //10% chance to spawn corpses of bloody people/zombies on every tile of barbed wire fence if( one_in( 10 ) ) { @@ -1008,7 +1008,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) line( &m, t_fence_barbed, 3, 13, 3, 17 ); line( &m, t_fence_barbed, SEEX * 2 - 4, 13, SEEX * 2 - 4, 17 ); - std::vector barbed_wire = line_to( 3, 13, SEEX * 2 - 4, 13 ); + std::vector barbed_wire = line_to( point( 3, 13 ), point( SEEX * 2 - 4, 13 ) ); for( auto &i : barbed_wire ) { //10% chance to spawn corpses of bloody people/zombies on every tile of barbed wire fence if( one_in( 10 ) ) { @@ -1048,7 +1048,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) } //33% chance to spawn empty magazines used by soldiers - std::vector empty_magazines_locations = line_to( 5, 16, 18, 16 ); + std::vector empty_magazines_locations = line_to( point( 5, 16 ), point( 18, 16 ) ); for( auto &i : empty_magazines_locations ) { if( one_in( 3 ) ) { m.spawn_item( { i, abs_sub.z }, "stanag30" ); @@ -1123,7 +1123,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) //33% chance for a crazy maniac ramming the tent with some unfortunate inside if( one_in( 3 ) ) { //Blood and gore - std::vector blood_track = line_to( 1, 6, 8, 6 ); + std::vector blood_track = line_to( point( 1, 6 ), point( 8, 6 ) ); for( auto &i : blood_track ) { m.add_field( { i, abs_sub.z }, fd_blood, 1 ); } @@ -1140,7 +1140,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) line_furn( &m, f_null, 10, 7, 10, 8 ); //Spill sand from damaged sandbags - std::vector sandbag_positions = squares_in_direction( 10, 7, 11, 8 ); + std::vector sandbag_positions = squares_in_direction( point( 10, 7 ), point( 11, 8 ) ); for( auto &i : sandbag_positions ) { m.spawn_item( { i, abs_sub.z }, "bag_canvas", rng( 5, 13 ) ); m.spawn_item( { i, abs_sub.z }, "material_sand", rng( 3, 8 ) ); @@ -1157,7 +1157,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) } //33% chance to spawn empty magazines used by soldiers - std::vector empty_magazines_locations = line_to( 9, 3, 9, 13 ); + std::vector empty_magazines_locations = line_to( point( 9, 3 ), point( 9, 13 ) ); for( auto &i : empty_magazines_locations ) { if( one_in( 3 ) ) { m.spawn_item( { i, abs_sub.z }, "stanag30" ); @@ -1189,14 +1189,14 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) } //33% chance to spawn empty magazines used by soldiers - std::vector empty_magazines_locations = line_to( 9, 16, 9, 20 ); + std::vector empty_magazines_locations = line_to( point( 9, 16 ), point( 9, 20 ) ); for( auto &i : empty_magazines_locations ) { if( one_in( 3 ) ) { m.spawn_item( { i, abs_sub.z }, "stanag30" ); } } - std::vector barbed_wire = line_to( 12, 3, 12, 20 ); + std::vector barbed_wire = line_to( point( 12, 3 ), point( 12, 20 ) ); for( auto &i : barbed_wire ) { //10% chance to spawn corpses of bloody people/zombies on every tile of barbed wire fence if( one_in( 10 ) ) { @@ -1269,7 +1269,7 @@ static void mx_minefield( map &m, const tripoint &abs_sub ) } //33% chance to spawn empty magazines used by soldiers - std::vector empty_magazines_locations = line_to( 15, 2, 15, 8 ); + std::vector empty_magazines_locations = line_to( point( 15, 2 ), point( 15, 8 ) ); for( auto &i : empty_magazines_locations ) { if( one_in( 3 ) ) { m.spawn_item( { i, abs_sub.z }, "stanag30" ); @@ -1398,7 +1398,7 @@ static void place_fumarole( map &m, int x1, int y1, int x2, int y2, std::set ignited; - std::vector fumarole = line_to( x1, y1, x2, y2, 0 ); + std::vector fumarole = line_to( point( x1, y1 ), point( x2, y2 ), 0 ); for( auto &i : fumarole ) { m.ter_set( i, t_lava ); @@ -1517,7 +1517,7 @@ static void mx_portal_in( map &m, const tripoint &abs_sub ) const int rad = 10; for( int i = x - rad; i <= x + rad; i++ ) { for( int j = y - rad; j <= y + rad; j++ ) { - if( trig_dist( x, y, i, j ) + rng( 0, 3 ) <= rad ) { + if( trig_dist( point( x, y ), point( i, j ) ) + rng( 0, 3 ) <= rad ) { const tripoint loc( i, j, abs_sub.z ); dead_vegetation_parser( m, loc ); m.adjust_radiation( loc.xy(), rng( 20, 40 ) ); diff --git a/src/map_field.cpp b/src/map_field.cpp index b23dc7bec4eb3..bf3beefb01282 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1228,7 +1228,7 @@ bool map::process_fields_in_submap( submap *const current_submap, clear_path( p, g->u.pos(), 10, 0, 100 ) ) { std::vector candidate_positions = - squares_in_direction( p.x, p.y, g->u.posx(), g->u.posy() ); + squares_in_direction( p.xy(), point( g->u.posx(), g->u.posy() ) ); for( point &candidate_position : candidate_positions ) { field &target_field = get_field( tripoint( candidate_position, p.z ) ); diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 3db4ebff11d77..26aa4012a3d5c 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -2442,7 +2442,8 @@ bool jmapgen_setmap::apply( const mapgendata &dat, const point &offset, mission } break; case JMAPGEN_SETMAP_LINE_TRAP: { - const std::vector line = line_to( x_get(), y_get(), x2_get(), y2_get(), 0 ); + const std::vector line = line_to( point( x_get(), y_get() ), point( x2_get(), y2_get() ), + 0 ); for( auto &i : line ) { // TODO: the trap_id should be stored separately and not be wrapped in an jmapgen_int mtrap_set( &m, i.x, i.y, trap_id( val.get() ) ); @@ -2450,7 +2451,8 @@ bool jmapgen_setmap::apply( const mapgendata &dat, const point &offset, mission } break; case JMAPGEN_SETMAP_LINE_RADIATION: { - const std::vector line = line_to( x_get(), y_get(), x2_get(), y2_get(), 0 ); + const std::vector line = line_to( point( x_get(), y_get() ), point( x2_get(), y2_get() ), + 0 ); for( auto &i : line ) { m.set_radiation( i, static_cast( val.get() ) ); } @@ -4348,7 +4350,7 @@ void map::draw_silo( const oter_id &terrain_type, mapgendata &dat, const time_po if( dat.zlevel == 0 ) { // We're on ground level for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( trig_dist( i, j, SEEX, SEEY ) <= 6 ) { + if( trig_dist( point( i, j ), point( SEEX, SEEY ) ) <= 6 ) { ter_set( point( i, j ), t_metal_floor ); } else { ter_set( point( i, j ), dat.groundcover() ); @@ -4389,14 +4391,14 @@ void map::draw_silo( const oter_id &terrain_type, mapgendata &dat, const time_po } else { // We are NOT above ground. for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( trig_dist( i, j, SEEX, SEEY ) > 7 ) { + if( trig_dist( point( i, j ), point( SEEX, SEEY ) ) > 7 ) { ter_set( point( i, j ), t_rock ); - } else if( trig_dist( i, j, SEEX, SEEY ) > 5 ) { + } else if( trig_dist( point( i, j ), point( SEEX, SEEY ) ) > 5 ) { ter_set( point( i, j ), t_metal_floor ); if( one_in( 30 ) ) { add_field( {i, j, abs_sub.z}, fd_nuke_gas, 2 ); } - } else if( trig_dist( i, j, SEEX, SEEY ) == 5 ) { + } else if( trig_dist( point( i, j ), point( SEEX, SEEY ) ) == 5 ) { ter_set( point( i, j ), t_hole ); } else { ter_set( point( i, j ), t_missile ); @@ -7877,8 +7879,7 @@ void silo_rooms( map *m ) int best_dist = 999; int closest = 0; for( size_t i = 1; i < rooms.size(); i++ ) { - int dist = trig_dist( first_room_position.x, first_room_position.y, rooms[i].first.x, - rooms[i].first.y ); + int dist = trig_dist( first_room_position, rooms[i].first ); if( dist < best_dist ) { best_dist = dist; closest = i; @@ -8192,7 +8193,7 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo for( int i = cx - 5; i <= cx + 5; i++ ) { for( int j = cy - 5; j <= cy + 5; j++ ) { if( furn( point( i, j ) ) == f_rubble ) { - add_field( {i, j, abs_sub.z}, fd_fire_vent, 1 + ( rl_dist( cx, cy, i, j ) % 3 ) ); + add_field( {i, j, abs_sub.z}, fd_fire_vent, 1 + ( rl_dist( point( cx, cy ), point( i, j ) ) % 3 ) ); } } } diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 746e580d910ed..dd0995957d1bc 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -648,7 +648,7 @@ void mapgen_fungal_bloom( map *m, oter_id, mapgendata dat, const time_point &, f ( void )dat; for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( one_in( rl_dist( i, j, 12, 12 ) * 4 ) ) { + if( one_in( rl_dist( point( i, j ), point( 12, 12 ) ) * 4 ) ) { m->ter_set( point( i, j ), t_marloss ); } else if( one_in( 10 ) ) { if( one_in( 3 ) ) { @@ -698,7 +698,7 @@ void mapgen_fungal_flowers( map *m, oter_id, mapgendata dat, const time_point &, ( void )dat; for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { - if( one_in( rl_dist( i, j, 12, 12 ) * 6 ) ) { + if( one_in( rl_dist( point( i, j ), point( 12, 12 ) ) * 6 ) ) { m->ter_set( point( i, j ), t_fungus ); m->furn_set( point( i, j ), f_flower_marloss ); } else if( one_in( 10 ) ) { @@ -1517,10 +1517,10 @@ void mapgen_sewer_four_way( map *m, oter_id, mapgendata dat, const time_point &t } else { m->ter_set( point( i, j ), t_sewage ); } - if( rn == 0 && ( trig_dist( i, j, SEEX - 1, SEEY - 1 ) <= 6 || - trig_dist( i, j, SEEX - 1, SEEY ) <= 6 || - trig_dist( i, j, SEEX, SEEY - 1 ) <= 6 || - trig_dist( i, j, SEEX, SEEY ) <= 6 ) ) { + if( rn == 0 && ( trig_dist( point( i, j ), point( SEEX - 1, SEEY - 1 ) ) <= 6 || + trig_dist( point( i, j ), point( SEEX - 1, SEEY ) ) <= 6 || + trig_dist( point( i, j ), point( SEEX, SEEY - 1 ) ) <= 6 || + trig_dist( point( i, j ), point( SEEX, SEEY ) ) <= 6 ) ) { m->ter_set( point( i, j ), t_sewage ); } if( rn == 0 && ( i == SEEX - 1 || i == SEEX ) && ( j == SEEY - 1 || j == SEEY ) ) { @@ -3008,7 +3008,7 @@ void mapgen_cave( map *m, oter_id, mapgendata dat, const time_point &turn, float origy = rng( SEEY - 1, SEEY ), hermx = rng( SEEX - 6, SEEX + 5 ), hermy = rng( SEEX - 6, SEEY + 5 ); - std::vector bloodline = line_to( origx, origy, hermx, hermy, 0 ); + std::vector bloodline = line_to( point( origx, origy ), point( hermx, hermy ), 0 ); for( auto &ii : bloodline ) { madd_field( m, ii.x, ii.y, fd_blood, 2 ); } @@ -3052,7 +3052,7 @@ void mapgen_cave( map *m, oter_id, mapgendata dat, const time_point &turn, float pathx = ( one_in( 2 ) ? SEEX - 8 : SEEX + 7 ); pathy = rng( SEEY - 6, SEEY + 5 ); } - std::vector pathline = line_to( pathx, pathy, SEEX - 1, SEEY - 1, 0 ); + std::vector pathline = line_to( point( pathx, pathy ), point( SEEX - 1, SEEY - 1 ), 0 ); for( auto &ii : pathline ) { square( m, t_dirt, ii.x, ii.y, ii.x + 1, ii.y + 1 ); @@ -3109,7 +3109,7 @@ void mapgen_cave_rat( map *m, oter_id, mapgendata dat, const time_point &turn, f // Now draw some extra passages! do { int tox = ( one_in( 2 ) ? 2 : SEEX * 2 - 3 ), toy = rng( 2, SEEY * 2 - 3 ); - std::vector path = line_to( centerx, SEEY - 1, tox, toy, 0 ); + std::vector path = line_to( point( centerx, SEEY - 1 ), point( tox, toy ), 0 ); for( auto &i : path ) { for( int cx = i.x - 1; cx <= i.x + 1; cx++ ) { for( int cy = i.y - 1; cy <= i.y + 1; cy++ ) { @@ -3613,7 +3613,7 @@ static void mapgen_ants_generic( map *m, oter_id terrain_type, mapgendata dat, } while( m->ter( point( x, y ) ) == t_rock ); for( int i = x - cw; i <= x + cw; i++ ) { for( int j = y - cw; j <= y + cw; j++ ) { - if( trig_dist( x, y, i, j ) <= cw ) { + if( trig_dist( point( x, y ), point( i, j ) ) <= cw ) { m->ter_set( point( i, j ), t_rock_floor ); } } diff --git a/src/melee.cpp b/src/melee.cpp index cb403adb72c88..227c299147d2b 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -1960,14 +1960,14 @@ void player_hit_message( player *attacker, const std::string &message, //player hits monster melee SCT.add( t.posx(), t.posy(), - direction_from( 0, 0, t.posx() - attacker->posx(), t.posy() - attacker->posy() ), + direction_from( point_zero, point( t.posx() - attacker->posx(), t.posy() - attacker->posy() ) ), get_hp_bar( dam, t.get_hp_max(), true ).first, m_good, sSCTmod, gmtSCTcolor ); if( t.get_hp() > 0 ) { SCT.add( t.posx(), t.posy(), - direction_from( 0, 0, t.posx() - attacker->posx(), t.posy() - attacker->posy() ), + direction_from( point_zero, point( t.posx() - attacker->posx(), t.posy() - attacker->posy() ) ), get_hp_bar( t.get_hp(), t.get_hp_max(), true ).first, m_good, //~ "hit points", used in scrolling combat text _( "hp" ), m_neutral, diff --git a/src/mission_util.cpp b/src/mission_util.cpp index 7fda72f1deab1..15485ba041745 100644 --- a/src/mission_util.cpp +++ b/src/mission_util.cpp @@ -155,8 +155,7 @@ tripoint mission_util::target_closest_lab_entrance( const tripoint &origin, int underground.z = 0; tripoint closest; - if( square_dist( surface.x, surface.y, origin.x, origin.y ) <= square_dist( underground.x, - underground.y, origin.x, origin.y ) ) { + if( square_dist( surface.xy(), origin.xy() ) <= square_dist( underground.xy(), origin.xy() ) ) { closest = surface; } else { closest = underground; diff --git a/src/monattack.cpp b/src/monattack.cpp index 2998fc601c8ba..210f2b688efa6 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -3452,7 +3452,7 @@ bool mattack::searchlight( monster *z ) } } - if( rl_dist( x, y, zposx, zposy ) > 50 ) { + if( rl_dist( point( x, y ), point( zposx, zposy ) ) > 50 ) { if( x > zposx ) { x--; } diff --git a/src/monmove.cpp b/src/monmove.cpp index e7d0506d1e28d..0f2f5b8c2fe9f 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -1156,7 +1156,7 @@ static std::vector get_bashing_zone( const tripoint &bashee, const tri zone.reserve( 3 * maxdepth ); tripoint previous = bashee; for( const tripoint &p : path ) { - std::vector swath = squares_in_direction( previous.x, previous.y, p.x, p.y ); + std::vector swath = squares_in_direction( previous.xy(), p.xy() ); for( point q : swath ) { zone.push_back( tripoint( q, bashee.z ) ); } @@ -1765,7 +1765,7 @@ bool monster::will_reach( const point &p ) } if( can_hear() && wandf > 0 && rl_dist( wander_pos.xy(), p ) <= 2 && - rl_dist( posx(), posy(), wander_pos.x, wander_pos.y ) <= wandf ) { + rl_dist( point( posx(), posy() ), wander_pos.xy() ) <= wandf ) { return true; } diff --git a/src/overmap.cpp b/src/overmap.cpp index 8b171055c5e05..a1c2a6cb4600e 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -1822,7 +1822,7 @@ void mongroup::wander( const overmap &om ) // Find a nearby city to return to.. for( const city &check_city : om.cities ) { // Check if this is the nearest city so far. - int distance = rl_dist( check_city.pos.x * 2, check_city.pos.y * 2, pos.x, pos.y ); + int distance = rl_dist( point( check_city.pos.x * 2, check_city.pos.y * 2 ), pos.xy() ); if( !target_city || distance < target_distance ) { target_distance = distance; target_city = &check_city; @@ -2100,8 +2100,8 @@ void overmap::place_forest_trails() // center point and use that. point actual_center_point = *std::min_element( forest_points.begin(), forest_points.end(), [¢er_point]( const point & lhs, const point & rhs ) { - return square_dist( lhs.x, lhs.y, center_point.x, center_point.y ) < square_dist( rhs.x, rhs.y, - center_point.x, center_point.y ); + return square_dist( lhs, center_point ) < square_dist( rhs, + center_point ); } ); // Figure out how many random points we'll add to our trail system, based on the forest @@ -2344,7 +2344,7 @@ void overmap::place_lakes() if( !ter( p )->is_river() ) { continue; } - const int distance = square_dist( lake_connection_point.x, lake_connection_point.y, x, y ); + const int distance = square_dist( lake_connection_point, point( x, y ) ); if( distance < closest_distance || closest_distance < 0 ) { closest_point = p.xy(); closest_distance = distance; @@ -2866,8 +2866,7 @@ void overmap::place_building( const tripoint &p, om_direction::type dir, const c const tripoint building_pos = p + om_direction::displace( dir ); const om_direction::type building_dir = om_direction::opposite( dir ); - const int town_dist = ( trig_dist( building_pos.x, building_pos.y, town.pos.x, - town.pos.y ) * 100 ) / std::max( town.size, 1 ); + const int town_dist = ( trig_dist( building_pos.xy(), town.pos ) * 100 ) / std::max( town.size, 1 ); for( size_t retries = 10; retries > 0; --retries ) { const overmap_special_id building_tid = pick_random_building_to_place( town_dist ); @@ -3461,7 +3460,8 @@ void overmap::connect_closest_points( const std::vector &points, int z, int closest = -1; int k = 0; for( size_t j = i + 1; j < points.size(); j++ ) { - const int distance = trig_dist( points[i].x, points[i].y, points[j].x, points[j].y ); + const int distance = trig_dist( point( points[i].x, points[i].y ), point( points[j].x, + points[j].y ) ); if( distance < closest || closest < 0 ) { closest = distance; k = j; @@ -4033,8 +4033,8 @@ void overmap::place_specials( overmap_special_batch &enabled_specials ) // in the 5x5 area surrounding the initial overmap, bounding the amount of work we will do. for( point candidate_addr : closest_points_first( 2, custom_overmap_specials.get_origin() ) ) { if( !overmap_buffer.has( candidate_addr ) ) { - int current_distance = square_dist( pos().x, pos().y, - candidate_addr.x, candidate_addr.y ); + int current_distance = square_dist( pos(), + candidate_addr ); if( nearest_candidates.empty() || current_distance == previous_distance ) { nearest_candidates.push_back( candidate_addr ); previous_distance = current_distance; @@ -4257,7 +4257,8 @@ void overmap::add_mon_group( const mongroup &group ) int xpop = 0; for( int x = -rad; x <= rad; x++ ) { for( int y = -rad; y <= rad; y++ ) { - const int dist = group.diffuse ? square_dist( x, y, 0, 0 ) : trig_dist( x, y, 0, 0 ); + const int dist = group.diffuse ? square_dist( point( x, y ), point_zero ) : trig_dist( point( x, + y ), point_zero ); if( dist > rad ) { continue; } diff --git a/src/player.cpp b/src/player.cpp index 42e819a425446..31eb1571abad3 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -740,7 +740,7 @@ void player::apply_persistent_morale() const int max_dist = 5; for( int dx = -max_dist; dx <= max_dist; dx++ ) { for( int dy = -max_dist; dy <= max_dist; dy++ ) { - const float dist = rl_dist( 0, 0, dx, dy ); + const float dist = rl_dist( point_zero, point( dx, dy ) ); if( dist > max_dist ) { continue; } @@ -2980,7 +2980,7 @@ dealt_damage_instance player::deal_damage( Creature *source, body_part bp, if( is_player() && source ) { //monster hits player melee SCT.add( posx(), posy(), - direction_from( 0, 0, posx() - source->posx(), posy() - source->posy() ), + direction_from( point_zero, point( posx() - source->posx(), posy() - source->posy() ) ), get_hp_bar( dam, get_hp_max( player::bp_to_hp( bp ) ) ).first, m_bad, body_part_name( bp ), m_neutral ); } diff --git a/src/sounds.cpp b/src/sounds.cpp index abd3a9e256a11..6f0a84dbd463e 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -161,7 +161,7 @@ static std::vector cluster_sounds( std::vector( 10 ) ), static_cast( log( recent_sounds.size() ) ) ); const size_t stopping_point = recent_sounds.size() - num_seed_clusters; - const size_t max_map_distance = rl_dist( 0, 0, MAPSIZE_X, MAPSIZE_Y ); + const size_t max_map_distance = rl_dist( point_zero, point( MAPSIZE_X, MAPSIZE_Y ) ); // Randomly choose cluster seeds. for( size_t i = recent_sounds.size(); i > stopping_point; i-- ) { size_t index = rng( 0, i - 1 ); @@ -311,7 +311,7 @@ void sounds::process_sound_markers( player *p ) for( const auto &sound_event_pair : sounds_since_last_turn ) { const tripoint &pos = sound_event_pair.first; const sound_event &sound = sound_event_pair.second; - const int distance_to_sound = rl_dist( p->pos().x, p->pos().y, pos.x, pos.y ) + + const int distance_to_sound = rl_dist( p->pos().xy(), pos.xy() ) + abs( p->pos().z - pos.z ) * 10; const int raw_volume = sound.volume; diff --git a/src/timed_event.cpp b/src/timed_event.cpp index 25ecd0b3faa57..ffb42f3bb576f 100644 --- a/src/timed_event.cpp +++ b/src/timed_event.cpp @@ -256,7 +256,7 @@ void timed_event::actualize() y = rng( g->u.posy() - 5, g->u.posy() + 5 ); tries++; } while( tries < 20 && !g->is_empty( {x, y, g->u.posz()} ) && - rl_dist( x, y, g->u.posx(), g->u.posy() ) <= 2 ); + rl_dist( point( x, y ), point( g->u.posx(), g->u.posy() ) ) <= 2 ); if( tries < 20 ) { g->summon_mon( montype, tripoint( x, y, g->u.posz() ) ); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 269590dd6b404..759b13317e656 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -663,8 +663,8 @@ void vehicle::smash( float hp_percent_loss_min, float hp_percent_loss_max, int roll = dice( 1, 1000 ); int pct_af = ( percent_of_parts_to_affect * 1000.0f ); if( roll < pct_af ) { - float dist = 1.0f - trig_dist( damage_origin.x, damage_origin.y, part.precalc[0].x, - part.precalc[0].y ) / damage_size; + float dist = 1.0f - trig_dist( damage_origin, point( part.precalc[0].x, + part.precalc[0].y ) ) / damage_size; dist = clamp( dist, 0.0f, 1.0f ); if( damage_size == 0 ) { dist = 1.0f; @@ -5263,7 +5263,7 @@ void vehicle::damage_all( int dmg1, int dmg2, damage_type type, const point &imp for( const vpart_reference &vp : get_all_parts() ) { const size_t p = vp.part_index(); - int distance = 1 + square_dist( vp.mount().x, vp.mount().y, impact.x, impact.y ); + int distance = 1 + square_dist( vp.mount(), impact ); if( distance > 1 && part_info( p ).location == part_location_structure && !part_info( p ).has_flag( "PROTRUSION" ) ) { damage_direct( p, rng( dmg1, dmg2 ) / ( distance * distance ), type ); diff --git a/tests/line_test.cpp b/tests/line_test.cpp index 3de4df608c216..f7dc61528ce4e 100644 --- a/tests/line_test.cpp +++ b/tests/line_test.cpp @@ -293,8 +293,8 @@ TEST_CASE( "squares_closer_to_test" ) static void line_to_comparison( const int iterations ) { - REQUIRE( trig_dist( 0, 0, 0, 0 ) == 0 ); - REQUIRE( trig_dist( 0, 0, 1, 0 ) == 1 ); + REQUIRE( trig_dist( point_zero, point_zero ) == 0 ); + REQUIRE( trig_dist( point_zero, point_east ) == 1 ); const int seed = time( nullptr ); std::srand( seed ); @@ -306,7 +306,8 @@ static void line_to_comparison( const int iterations ) const int y2 = rng( -COORDINATE_RANGE, COORDINATE_RANGE ); int t1 = 0; int t2 = 0; - REQUIRE( line_to( x1, y1, x2, y2, t1 ) == canonical_line_to( x1, y1, x2, y2, t2 ) ); + REQUIRE( line_to( point( x1, y1 ), point( x2, y2 ), t1 ) == canonical_line_to( x1, y1, x2, y2, + t2 ) ); } { @@ -319,7 +320,7 @@ static void line_to_comparison( const int iterations ) int count1 = 0; const auto start1 = std::chrono::high_resolution_clock::now(); while( count1 < iterations ) { - line_to( x1, y1, x2, y2, t1 ); + line_to( point( x1, y1 ), point( x2, y2 ), t1 ); count1++; } const auto end1 = std::chrono::high_resolution_clock::now(); @@ -359,7 +360,7 @@ TEST_CASE( "line_to_boundaries" ) const int st( ( ideal_start_offset > 0 ) - ( ideal_start_offset < 0 ) ); const int max_start_offset = std::abs( ideal_start_offset ) * 2 + 1; for( int k = -1; k <= max_start_offset; ++k ) { - auto line = line_to( 0, 0, i, j, k * st ); + auto line = line_to( point_zero, point( i, j ), k * st ); if( line.back() != point( i, j ) ) { WARN( "Expected (" << i << "," << j << ") but got (" << line.back().x << "," << line.back().y << ") with t == " << k ); diff --git a/tests/shadowcasting_test.cpp b/tests/shadowcasting_test.cpp index 970472e00837e..d02473abef254 100644 --- a/tests/shadowcasting_test.cpp +++ b/tests/shadowcasting_test.cpp @@ -88,7 +88,7 @@ static bool bresenham_visibility_check( } bool visible = true; const int junk = 0; - bresenham( x, y, offsetX, offsetY, junk, + bresenham( point( x, y ), point( offsetX, offsetY ), junk, [&transparency_cache, &visible]( const point & new_point ) { if( transparency_cache[new_point.x][new_point.y] <= LIGHT_TRANSPARENCY_SOLID ) { From 4296512e970e1357af81488d3c9e14219d8dd45c Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sun, 18 Aug 2019 20:11:34 -0400 Subject: [PATCH 101/113] Add abs( tripoint ) overload --- src/point.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/point.h b/src/point.h index 2b780c76ab140..5d3ec219df33b 100644 --- a/src/point.h +++ b/src/point.h @@ -300,6 +300,11 @@ inline point abs( const point &p ) return point( abs( p.x ), abs( p.y ) ); } +inline tripoint abs( const tripoint &p ) +{ + return tripoint( abs( p.x ), abs( p.y ), abs( p.z ) ); +} + static constexpr tripoint tripoint_min { INT_MIN, INT_MIN, INT_MIN }; static constexpr tripoint tripoint_max{ INT_MAX, INT_MAX, INT_MAX }; From e85578b7cb95863d6155797b89f737a79bcb2117 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sun, 18 Aug 2019 20:11:59 -0400 Subject: [PATCH 102/113] Port line function implementations --- src/line.cpp | 96 +++++++++++++++++++--------------------------------- src/line.h | 19 ++--------- 2 files changed, 37 insertions(+), 78 deletions(-) diff --git a/src/line.cpp b/src/line.cpp index ecd0605763800..a68ef3011a39a 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -16,49 +16,47 @@ extern bool trigdist; -void bresenham( const int x1, const int y1, const int x2, const int y2, int t, +void bresenham( const point &p1, const point &p2, int t, const std::function &interact ) { // The slope components. - const int dx = x2 - x1; - const int dy = y2 - y1; + const point d = p2 - p1; // Signs of slope values. - const int sx = ( dx == 0 ) ? 0 : sgn( dx ); - const int sy = ( dy == 0 ) ? 0 : sgn( dy ); + const int sx = ( d.x == 0 ) ? 0 : sgn( d.x ); + const int sy = ( d.y == 0 ) ? 0 : sgn( d.y ); // Absolute values of slopes x2 to avoid rounding errors. - const int ax = abs( dx ) * 2; - const int ay = abs( dy ) * 2; + const point a = abs( d ) * 2; - point cur( x1, y1 ); + point cur = p1; - if( ax == ay ) { - while( cur.x != x2 ) { + if( a.x == a.y ) { + while( cur.x != p2.x ) { cur.y += sy; cur.x += sx; if( !interact( cur ) ) { break; } } - } else if( ax > ay ) { - while( cur.x != x2 ) { + } else if( a.x > a.y ) { + while( cur.x != p2.x ) { if( t > 0 ) { cur.y += sy; - t -= ax; + t -= a.x; } cur.x += sx; - t += ay; + t += a.y; if( !interact( cur ) ) { break; } } } else { - while( cur.y != y2 ) { + while( cur.y != p2.y ) { if( t > 0 ) { cur.x += sx; - t -= ay; + t -= a.y; } cur.y += sy; - t += ax; + t += a.x; if( !interact( cur ) ) { break; } @@ -198,16 +196,16 @@ void bresenham( const tripoint &loc1, const tripoint &loc2, int t, int t2, //Trying to pull points out of a tripoint vector is messy and //probably slow, so leaving two full functions for now -std::vector line_to( const int x1, const int y1, const int x2, const int y2, int t ) +std::vector line_to( const point &p1, const point &p2, int t ) { std::vector line; // Preallocate the number of cells we need instead of allocating them piecewise. - const int numCells = square_dist( tripoint( x1, y1, 0 ), tripoint( x2, y2, 0 ) ); + const int numCells = square_dist( p1, p2 ); if( numCells == 0 ) { - line.push_back( {x1, y1} ); + line.push_back( p1 ); } else { line.reserve( numCells ); - bresenham( x1, y1, x2, y2, t, [&line]( const point & new_point ) { + bresenham( p1, p2, t, [&line]( const point & new_point ) { line.push_back( new_point ); return true; } ); @@ -215,11 +213,6 @@ std::vector line_to( const int x1, const int y1, const int x2, const int return line; } -std::vector line_to( const point &p1, const point &p2, const int t ) -{ - return line_to( p1.x, p1.y, p2.x, p2.y, t ); -} - std::vector line_to( const tripoint &loc1, const tripoint &loc2, int t, int t2 ) { std::vector line; @@ -237,11 +230,6 @@ std::vector line_to( const tripoint &loc1, const tripoint &loc2, int return line; } -float trig_dist( const int x1, const int y1, const int x2, const int y2 ) -{ - return trig_dist( tripoint( x1, y1, 0 ), tripoint( x2, y2, 0 ) ); -} - float trig_dist( const point &loc1, const point &loc2 ) { return trig_dist( tripoint( loc1, 0 ), tripoint( loc2, 0 ) ); @@ -254,30 +242,16 @@ float trig_dist( const tripoint &loc1, const tripoint &loc2 ) ( ( loc1.z - loc2.z ) * ( loc1.z - loc2.z ) ) ); } -int square_dist( const int x1, const int y1, const int x2, const int y2 ) -{ - return square_dist( point( x1, y1 ), point( x2, y2 ) ); -} - int square_dist( const point &loc1, const point &loc2 ) { - const int dx = abs( loc1.x - loc2.x ); - const int dy = abs( loc1.y - loc2.y ); - return dx > dy ? dx : dy; + const point d = abs( loc1 - loc2 ); + return std::max( d.x, d.y ); } int square_dist( const tripoint &loc1, const tripoint &loc2 ) { - const int dx = abs( loc1.x - loc2.x ); - const int dy = abs( loc1.y - loc2.y ); - const int dz = abs( loc1.z - loc2.z ); - int maxDxDy = ( dx > dy ? dx : dy ); // Sloppy, but should be quick. - return ( maxDxDy > dz ? maxDxDy : dz ); // Too bad it doesn't scale. -} - -int rl_dist( const int x1, const int y1, const int x2, const int y2 ) -{ - return rl_dist( tripoint( x1, y1, 0 ), tripoint( x2, y2, 0 ) ); + const tripoint d = abs( loc1 - loc2 ); + return std::max( { d.x, d.y, d.z } ); } int rl_dist( const point &a, const point &b ) @@ -406,9 +380,9 @@ direction direction_from( const tripoint &p ) noexcept return static_cast( make_xyz( p ) ); } -direction direction_from( const int x1, const int y1, const int x2, const int y2 ) noexcept +direction direction_from( const point &p1, const point &p2 ) noexcept { - return direction_from( point( x2 - x1, y2 - y1 ) ); + return direction_from( p2 - p1 ); } direction direction_from( const tripoint &p, const tripoint &q ) @@ -557,24 +531,24 @@ std::vector squares_closer_to( const tripoint &from, const tripoint &t // Returns a vector of the adjacent square in the direction of the target, // and the two squares flanking it. -std::vector squares_in_direction( const int x1, const int y1, const int x2, const int y2 ) +std::vector squares_in_direction( const point &p1, const point &p2 ) { int junk = 0; - point center_square = line_to( x1, y1, x2, y2, junk )[0]; + point center_square = line_to( p1, p2, junk )[0]; std::vector adjacent_squares; adjacent_squares.push_back( center_square ); - if( x1 == center_square.x ) { + if( p1.x == center_square.x ) { // Horizontally adjacent. - adjacent_squares.push_back( point( x1 + 1, center_square.y ) ); - adjacent_squares.push_back( point( x1 - 1, center_square.y ) ); - } else if( y1 == center_square.y ) { + adjacent_squares.push_back( point( p1.x + 1, center_square.y ) ); + adjacent_squares.push_back( point( p1.x - 1, center_square.y ) ); + } else if( p1.y == center_square.y ) { // Vertically adjacent. - adjacent_squares.push_back( point( center_square.x, y1 + 1 ) ); - adjacent_squares.push_back( point( center_square.x, y1 - 1 ) ); + adjacent_squares.push_back( point( center_square.x, p1.y + 1 ) ); + adjacent_squares.push_back( point( center_square.x, p1.y - 1 ) ); } else { // Diagonally adjacent. - adjacent_squares.push_back( point( x1, center_square.y ) ); - adjacent_squares.push_back( point( center_square.x, y1 ) ); + adjacent_squares.push_back( point( p1.x, center_square.y ) ); + adjacent_squares.push_back( point( center_square.x, p1.y ) ); } return adjacent_squares; } diff --git a/src/line.h b/src/line.h index fab466e1cc6a0..752bcc35fda3e 100644 --- a/src/line.h +++ b/src/line.h @@ -83,8 +83,6 @@ enum direction : unsigned { direction direction_from( const point &p ) noexcept; direction direction_from( const tripoint &p ) noexcept; -direction direction_from( int x1, int y1, int x2, int y2 ) noexcept; -direction direction_from( const point &p1, int x2, int y2 ) noexcept; direction direction_from( const point &p1, const point &p2 ) noexcept; direction direction_from( const tripoint &p, const tripoint &q ); @@ -99,10 +97,6 @@ std::string direction_suffix( const tripoint &p, const tripoint &q ); * The actual Bresenham algorithm in 2D and 3D, everything else should call these * and pass in an interact functor to iterate across a line between two points. */ -void bresenham( int x1, int y1, int x2, int y2, int t, - const std::function &interact ); -void bresenham( const point &p1, int x2, int y2, int t, - const std::function &interact ); void bresenham( const point &p1, const point &p2, int t, const std::function &interact ); void bresenham( const tripoint &loc1, const tripoint &loc2, int t, int t2, @@ -111,25 +105,18 @@ void bresenham( const tripoint &loc1, const tripoint &loc2, int t, int t2, tripoint move_along_line( const tripoint &loc, const std::vector &line, int distance ); // The "t" value decides WHICH Bresenham line is used. -std::vector line_to( int x1, int y1, int x2, int y2, int t = 0 ); -std::vector line_to( const point &p1, int x2, int y2, int t = 0 ); std::vector line_to( const point &p1, const point &p2, int t = 0 ); // t and t2 decide which Bresenham line is used. std::vector line_to( const tripoint &loc1, const tripoint &loc2, int t = 0, int t2 = 0 ); // sqrt(dX^2 + dY^2) -float trig_dist( int x1, int y1, int x2, int y2 ); -float trig_dist( const point &p1, int x2, int y2 ); float trig_dist( const point &loc1, const point &loc2 ); float trig_dist( const tripoint &loc1, const tripoint &loc2 ); // Roguelike distance; minimum of dX and dY -int square_dist( int x1, int y1, int x2, int y2 ); -int square_dist( const point &p1, int x2, int y2 ); int square_dist( const point &loc1, const point &loc2 ); int square_dist( const tripoint &loc1, const tripoint &loc2 ); -int rl_dist( int x1, int y1, int x2, int y2 ); -int rl_dist( const point &p1, int x2, int y2 ); -int rl_dist( const tripoint &loc1, const tripoint &loc2 ); +// Choose between the above two according to the "circular distances" option int rl_dist( const point &a, const point &b ); +int rl_dist( const tripoint &loc1, const tripoint &loc2 ); // Sum of distance in both axes int manhattan_dist( const point &loc1, const point &loc2 ); @@ -140,8 +127,6 @@ double atan2_degrees( const point & ); // Get the magnitude of the slope ranging from 0.0 to 1.0 float get_normalized_angle( const point &start, const point &end ); std::vector continue_line( const std::vector &line, int distance ); -std::vector squares_in_direction( int x1, int y1, int x2, int y2 ); -std::vector squares_in_direction( const point &p1, int x2, int y2 ); std::vector squares_in_direction( const point &p1, const point &p2 ); // Returns a vector of squares adjacent to @from that are closer to @to than @from is. // Currently limited to the same z-level as @from. From 5755b74fee317a67040898e0f6b3e1de320847f5 Mon Sep 17 00:00:00 2001 From: RedShakespeare Date: Mon, 19 Aug 2019 10:49:00 +0800 Subject: [PATCH 103/113] Fix picking up liquid water bug As above. --- src/pickup.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pickup.cpp b/src/pickup.cpp index 3a4cb4ba3f758..fbaa07b2dc137 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -218,6 +218,8 @@ bool pick_one_up( item_location &loc, int quantity, bool &got_water, bool &offer if( !( got_water = !( u.crush_frozen_liquid( newloc ) ) ) ) { option = STASH; } + } else if( newit.made_of_from_type( LIQUID ) && !newit.is_frozen_liquid() ) { + got_water = true; } else if( !u.can_pickWeight( newit, false ) ) { if( !autopickup ) { const std::string &explain = string_format( _( "The %s is too heavy!" ), From ec26a7eaacc6fb391fb9f341314c4ce1b2b9af8e Mon Sep 17 00:00:00 2001 From: John Candlebury Date: Mon, 19 Aug 2019 00:35:34 -0600 Subject: [PATCH 104/113] Adds the third Hub 01 mission (#33346) * Adds the third Hub 01 mission Find location, clear location, retrieve mcguffin, return. * Update data/json/items/generic.json Co-Authored-By: Anton Burmistrov * Update data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json Co-Authored-By: Anton Burmistrov --- data/json/items/generic.json | 12 ++ .../robofaq_locs/robofac_mission_chunks.json | 103 ++++++++++-------- .../npcs/robofac/NPC_ROBOFAC_INTERCOM.json | 67 ++++++++++++ 3 files changed, 137 insertions(+), 45 deletions(-) diff --git a/data/json/items/generic.json b/data/json/items/generic.json index 4f624aa79ec34..a42ec10e6fa61 100644 --- a/data/json/items/generic.json +++ b/data/json/items/generic.json @@ -1413,6 +1413,18 @@ "to_hit": -1, "flags": [ "NANOFAB_TEMPLATE", "TRADER_AVOID" ] }, + { + "type": "GENERIC", + "id": "template_photonics", + "copy-from": "standard_template_construct", + "color": "yellow", + "name": "nanofabricator template (silicon photonics)", + "description": "A state-of-the-art optical storage system, containing the instruction set required for the fabrication of complex silicon photonic circuitry. The data within was once clearly worth millions, but now, you are not sure if it's anything more than a fancy, high-tech paperweight.", + "price": 200000000, + "//": "actually worth millions", + "price_postapoc": 350, + "flags": [ "TRADER_AVOID" ] + }, { "type": "GENERIC", "id": "antenna", diff --git a/data/json/mapgen/robofaq_locs/robofac_mission_chunks.json b/data/json/mapgen/robofaq_locs/robofac_mission_chunks.json index 1fdb8538b94cb..470c03333ad5a 100644 --- a/data/json/mapgen/robofaq_locs/robofac_mission_chunks.json +++ b/data/json/mapgen/robofaq_locs/robofac_mission_chunks.json @@ -1,46 +1,59 @@ -{ - "type": "mapgen", - "method": "json", - "nested_mapgen_id": "robofac_mi2_convoy_ambush_chunk", - "object": { - "mapgensize": [ 24, 24 ], - "rows": [ - " ", - " ", - " ######### ## ", - " A #### ", - " # # # # ", - " # ## # #### ", - " ####### ### ", - " ### # ", - " # ", - " # ", - " ## # ", - " # ", - " ### ## ", - " ## # # ", - " ## ## ", - " # ### ## # ", - " M ######## ", - " @ #### ", - " #### ", - " ## ##########", - " #### ", - " A ## ", - " ##### ", - " " - ], - "terrain": { "@": "t_pavement", "A": "t_pavement", "M": "t_pavement", "#": "t_pavement" }, - "furniture": { "#": "f_wreckage" }, - "place_vehicles": [ - { "vehicle": "humvee", "x": 18, "y": 15, "fuel": 0, "status": 1, "chance": 100 }, - { "vehicle": "humvee", "x": 16, "y": 4, "fuel": 0, "status": 1, "chance": 100 }, - { "vehicle": "aapc-mg", "x": 10, "y": 10, "fuel": 0, "status": 1, "chance": 100 } - ], - "items": { "@": { "item": "lab_torso", "chance": 100 } }, - "item": { "@": [ { "item": "rmi2_corpse" } ] }, - "place_loot": [ { "item": "223_casing", "charges": [ 1, 1 ], "x": [ 0, 23 ], "y": [ 0, 23 ], "chance": 100, "repeat": [ 20, 60 ] } ], - "monster": { "M": { "monster": "mon_zombie_armored" }, "A": { "monster": "mon_zombie_soldier_acid_1" } }, - "place_monsters": [ { "monster": "GROUP_MIL_STRONG", "x": [ 1, 22 ], "y": [ 1, 22 ], "density": 1.6 } ] +[ + { + "type": "mapgen", + "method": "json", + "nested_mapgen_id": "robofac_mi2_convoy_ambush_chunk", + "object": { + "mapgensize": [ 24, 24 ], + "rows": [ + " ", + " ", + " ######### ## ", + " A #### ", + " # # # # ", + " # ## # #### ", + " ####### ### ", + " ### # ", + " # ", + " # ", + " ## # ", + " # ", + " ### ## ", + " ## # # ", + " ## ## ", + " # ### ## # ", + " M ######## ", + " @ #### ", + " #### ", + " ## ##########", + " #### ", + " A ## ", + " ##### ", + " " + ], + "terrain": { "@": "t_pavement", "A": "t_pavement", "M": "t_pavement", "#": "t_pavement" }, + "furniture": { "#": "f_wreckage" }, + "place_vehicles": [ + { "vehicle": "humvee", "x": 18, "y": 15, "fuel": 0, "status": 1, "chance": 100 }, + { "vehicle": "humvee", "x": 16, "y": 4, "fuel": 0, "status": 1, "chance": 100 }, + { "vehicle": "aapc-mg", "x": 10, "y": 10, "fuel": 0, "status": 1, "chance": 100 } + ], + "items": { "@": { "item": "lab_torso", "chance": 100 } }, + "item": { "@": [ { "item": "rmi2_corpse" } ] }, + "place_loot": [ { "item": "223_casing", "charges": [ 1, 1 ], "x": [ 0, 23 ], "y": [ 0, 23 ], "chance": 100, "repeat": [ 20, 60 ] } ], + "monster": { "M": { "monster": "mon_zombie_armored" }, "A": { "monster": "mon_zombie_soldier_acid_1" } }, + "place_monsters": [ { "monster": "GROUP_MIL_STRONG", "x": [ 1, 22 ], "y": [ 1, 22 ], "density": 1.6 } ] + } + }, + { + "type": "mapgen", + "method": "json", + "nested_mapgen_id": "robofac_mi3_photonics_chunk", + "object": { + "mapgensize": [ 1, 1 ], + "rows": [ "T" ], + "terrain": { "T": "t_metal_floor" }, + "item": { "T": { "item": "template_photonics", "chance": 100 } } + } } -} +] diff --git a/data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json b/data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json index aa5204cb0e126..5895e05190356 100644 --- a/data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json +++ b/data/json/npcs/robofac/NPC_ROBOFAC_INTERCOM.json @@ -128,6 +128,7 @@ "effect": [ { "u_buy_item": "RobofacCoin", "count": 2 } ] }, "origins": [ "ORIGIN_SECONDARY" ], + "followup": "MISSION_ROBOFAC_INTERCOM_3", "dialogue": { "describe": "...", "offer": "When the portal storms started, the Government issued an evacuation order for critical XEDRA personnel and sent convoys to retrieve them, with our head of AI research among the recalled. We recently discovered that he died when the convoy transferring him was ambushed in the initial chaos, but his corpse and memory bionic might remain intact enough for us to extract valuable knowledge. We want you to travel to the location, make a copy of his Bionic Memory Unit, and return it to us.", @@ -140,6 +141,40 @@ "failure": "Simply useless..." } }, + { + "id": "MISSION_ROBOFAC_INTERCOM_3", + "type": "mission_definition", + "name": "Light retrieval", + "description": "Reach the collapsed tower basement, and search the ruins for a photonic circuitry template. The intercom warned you about heavy enemy prescence, and of the existence of a hazardous enviroment.", + "goal": "MGOAL_FIND_ITEM", + "difficulty": 5, + "item": "template_photonics", + "value": 0, + "start": { + "assign_mission_target": { + "om_terrain": "office_tower_collapse_b_a0", + "om_special": "office_tower_collapsed", + "reveal_radius": 1, + "random": true, + "search_range": 180, + "z": -1 + }, + "update_mapgen": [ { "place_nested": [ { "chunks": [ "robofac_mi3_photonics_chunk" ], "x": 10, "y": 22 } ] } ] + }, + "end": { "effect": [ { "u_buy_item": "RobofacCoin", "count": 4 } ] }, + "origins": [ "ORIGIN_SECONDARY" ], + "dialogue": { + "describe": "...", + "offer": "Our facility once sourced advanced photonic circuitry from a nearby robotics manufacturer. Their building suffered major damage during the portal storms, and collapsed almost entirely. However, preliminary scouting reveals that the basement prototyping lab likely remains intact.\n\nthe intercom: We ask you to investigate the ruins, and if possible, retrieve a template for the fabrication of said photonic circuitry.", + "accepted": "We expect your success, mercenary.", + "rejected": "Return if you change your mind.", + "advice": "The scout drone also revealed extensive heat signatures and high concentrations of toxic compounds within the ruins, plan accordingly. We are willing to sell you some protective gear at a discount, if you require it.", + "inquire": "Have you retrieved the blueprints?", + "success": "You have our thanks and payment.", + "success_lie": "What good does this do us?", + "failure": "Simply useless..." + } + }, { "id": "TALK_ROBOFAC_INTERCOM", "type": "talk_topic", @@ -213,6 +248,18 @@ "condition": { "u_has_var": "completed_robofac_intercom_1", "type": "dialogue", "context": "intercom", "value": "yes" }, "topic": "TALK_ROBOFAC_INTERCOM_PROTOTYPE_ASK" }, + { + "text": "So, about that protective gear?", + "condition": { + "and": [ + { "u_has_mission": "MISSION_ROBOFAC_INTERCOM_3" }, + { + "not": { "npc_has_var": "npc_bought_protective_gear", "type": "dialogue", "context": "intercom", "value": "yes" } + } + ] + }, + "topic": "TALK_ROBOFAC_INTERCOM_BUY_PROTECTIVE_GEAR" + }, { "truefalsetext": { "condition": { "npc_has_var": "npc_intercom_trade", "type": "dialogue", "context": "intercom", "value": "yes" }, @@ -249,6 +296,26 @@ "dynamic_line": "It was a modified Wraitheon chassis, with a custom AI. We hoped it would interact with the outside world for us, but you know how well it went... Shame about what happened, with the evisceration and all...", "responses": [ { "text": "...", "topic": "TALK_ROBOFAC_INTERCOM" } ] }, + { + "id": "TALK_ROBOFAC_INTERCOM_BUY_PROTECTIVE_GEAR", + "type": "talk_topic", + "dynamic_line": "Given the current context, we are willing to sell you a set of our protective gear: gas mask, suit and gear, at a considerable discount. We will sell it for two of our coins.\n\nthe intercom: Hmm wait, we might not have your size...", + "responses": [ + { + "text": "[ 2 Hub 01 Gold Coins ] Deal!", + "condition": { "u_has_item": "RobofacCoin" }, + "effect": [ + { "u_sell_item": "RobofacCoin", "count": 2 }, + { "u_buy_item": "mask_gas" }, + { "u_buy_item": "robofac_enviro_suit" }, + { "u_buy_item": "gasfilter_m", "count": 100 }, + { "npc_add_var": "npc_bought_protective_gear", "type": "dialogue", "context": "intercom", "value": "yes" } + ], + "topic": "TALK_ROBOFAC_INTERCOM" + }, + { "text": "I have to give it a thought.", "topic": "TALK_ROBOFAC_INTERCOM" } + ] + }, { "id": "TALK_ROBOFAC_INTERCOM_PLEAD", "type": "talk_topic", From 43a602ba57dbef21fdd08935fd7d54b8232a0915 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Mon, 19 Aug 2019 23:14:33 +0200 Subject: [PATCH 105/113] Add virtual destructors. --- src/auto_pickup.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/auto_pickup.h b/src/auto_pickup.h index 203ecb2729ee9..c31fbfb8b0fa3 100644 --- a/src/auto_pickup.h +++ b/src/auto_pickup.h @@ -109,6 +109,7 @@ class base_settings void recreate() const; public: + virtual ~base_settings() = default; rule_state check_item( const std::string &sItemName ) const; }; @@ -125,6 +126,7 @@ class player_settings : public base_settings void refresh_map_items( cache &map_items ) const override; public: + ~player_settings() override = default; void create_rule( const item *it ); bool has_rule( const item *it ); void add_rule( const item *it ); @@ -149,6 +151,7 @@ class npc_settings : public base_settings void refresh_map_items( cache &map_items ) const override; public: + ~npc_settings() override = default; void create_rule( const std::string &to_match ); void show( const std::string &name ); From 367f3a89607da7144a4697a2e7c2e1993378fb30 Mon Sep 17 00:00:00 2001 From: tenmillimaster Date: Mon, 19 Aug 2019 07:37:32 -0500 Subject: [PATCH 106/113] not 2040 no mo --- data/json/items/ammo/45.json | 2 +- data/json/items/ammo/9mm.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/json/items/ammo/45.json b/data/json/items/ammo/45.json index 82f0746544f55..0f3c891571cbe 100644 --- a/data/json/items/ammo/45.json +++ b/data/json/items/ammo/45.json @@ -4,7 +4,7 @@ "copy-from": "45_jhp", "type": "AMMO", "name": ".45 ACP FMJ", - "description": ".45 ACP ammunition with 230gr FMJ bullets. Noted for its stopping power, the .45 ACP round has been common for almost 150 years.", + "description": ".45 ACP ammunition with 230gr FMJ bullets. Noted for its stopping power, the .45 ACP round has been common for over a century.", "relative": { "damage": -3, "pierce": 6 } }, { diff --git a/data/json/items/ammo/9mm.json b/data/json/items/ammo/9mm.json index 9b865a711f7d4..8edebe2e273ae 100644 --- a/data/json/items/ammo/9mm.json +++ b/data/json/items/ammo/9mm.json @@ -25,7 +25,7 @@ "copy-from": "9mm", "type": "AMMO", "name": "9x19mm FMJ", - "description": "9x19mm ammunition with a brass jacketed 115gr bullet. It is a popular round for military, law enforcement, and civilian use even after almost 150 years.", + "description": "9x19mm ammunition with a brass jacketed 115gr bullet. It has been a popular round for military, law enforcement, and civilian use for over a century.", "relative": { "damage": -2, "pierce": 4 } }, { From 8bb09381596c271605b871dfaf0461cde560a911 Mon Sep 17 00:00:00 2001 From: LaVeyanFiend Date: Mon, 19 Aug 2019 21:48:40 -0400 Subject: [PATCH 107/113] Home Frontier Pack gives compatible battery --- data/json/recipes/recipe_deconstruction.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/recipes/recipe_deconstruction.json b/data/json/recipes/recipe_deconstruction.json index d2ad10c614974..b1926d92b18d4 100644 --- a/data/json/recipes/recipe_deconstruction.json +++ b/data/json/recipes/recipe_deconstruction.json @@ -1647,7 +1647,7 @@ [ [ "l_long_45", 1 ] ], [ [ "l_enforcer_45", 1 ] ], [ [ "small_repairkit", 1 ] ], - [ [ "light_battery_cell", 3 ] ], + [ [ "medium_battery_cell", 1 ] ], [ [ "manual_gun", 1 ] ], [ [ "holster", 1 ] ] ], From 1f7cff41e144c5b468f6c5a586a0a8b7b4115d21 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Mon, 19 Aug 2019 19:39:02 -0700 Subject: [PATCH 108/113] remove rock pot from survivor mess kit recipe --- data/json/recipes/recipe_others.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/recipes/recipe_others.json b/data/json/recipes/recipe_others.json index 2aeead61d168a..8351d54a2c212 100644 --- a/data/json/recipes/recipe_others.json +++ b/data/json/recipes/recipe_others.json @@ -4016,7 +4016,7 @@ "time": "5 m", "reversible": true, "autolearn": true, - "components": [ [ [ "pot", 1 ], [ "pot_copper", 1 ], [ "clay_pot", 1 ], [ "rock_pot", 1 ] ], [ [ "oil_cooker", 1 ] ] ] + "components": [ [ [ "pot", 1 ], [ "pot_copper", 1 ], [ "clay_pot", 1 ] ], [ [ "oil_cooker", 1 ] ] ] }, { "type": "recipe", From 63c7d00550055f0635caa245fac2a1fe949c677b Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Mon, 19 Aug 2019 22:15:35 -0700 Subject: [PATCH 109/113] Install astyle in styling test (#33353) * Install astyle in styling test * Invoke astyle-check in test stage * Bump ubuntu version to bionic * Attempt to fix build failure * Use Clang 7 in initial test build * Change clang command name to clang++ * Switch back to clang 3.8, but add toolchain repo * Use llvm toolchain from precise * Update .travis.yml * Move astyle to more recent stage * Add new astyling directive to build * Remove unecessary astyle invocation. * Remove unecessary astyle environment variable. --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e33957e7e1c1b..f17fc660b5fdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,7 @@ jobs: addons: &clang38 apt: packages: ["clang-3.8", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"] - sources: *apt_sources + sources: [*apt_sources] # Then build different configurations and targets in parallel. - stage: "Main Compilers" @@ -75,11 +75,12 @@ jobs: sources: [*apt_sources] - env: COMPILER=g++-8 CXXFLAGS='-Wno-implicit-fallthrough' TILES=1 SOUND=1 SANITIZE=address - name: "GCC 8 Make build with Tiles, Sound and address sanitization" + name: "GCC 8 Make build with Tiles, Sound, astyle and address sanitization" + dist: bionic compiler: gcc addons: &gcc8 apt: - packages: ["g++-8", "g++-8-multilib", "libc6-dbg", "libc6-dbg:i386", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"] + packages: ["g++-8", "g++-8-multilib", "libc6-dbg", "libc6-dbg:i386", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev", "astyle"] sources: *apt_sources - env: CLANG=clang++-8 SANITIZE=address EXTRA_TEST_OPTS="~[.] ~vehicle_efficiency ~vehicle_drag ~starting_items" From dffa50522445f17696182ef9d8dd94a83119a783 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Tue, 20 Aug 2019 01:17:28 -0400 Subject: [PATCH 110/113] clang-tidy modernize-use-equals-default and -delete (#33360) * Enable modernize-use-equals-default and -delete Enable these clang-tidy checks and fix the related issues. Mostly this means adding '= default' on a bunch of member functions. Also: - Made the Character deleted members public. - Moved the oter_type_id, npc_template, overmap_special_terrain, SkillLevel, and selection_column_preset default constructors out-of-line (for the sake of avoiding the clang warning about const objects without user-provided default constructors). * Try alternate solution to clang warning * Fix unused variable warning --- .clang-tidy | 2 -- src/basecamp.cpp | 4 +--- src/character.h | 4 ++-- src/colony.h | 4 ++-- src/dependency_tree.cpp | 4 +--- src/inventory_ui.cpp | 6 +++--- src/item.cpp | 16 ++-------------- src/json.cpp | 11 +---------- src/json.h | 4 ++-- src/list.h | 12 ++++-------- src/mattack_actors.cpp | 4 +--- src/mattack_actors.h | 4 ++-- src/mattack_common.h | 2 +- src/npc.cpp | 2 +- src/npc.h | 2 +- src/npc_class.cpp | 6 +----- src/omdata.h | 4 ++-- src/overmap.cpp | 4 ++-- src/requirements.h | 6 +++--- src/skill.cpp | 2 +- src/skill.h | 2 +- src/vehicle_group.cpp | 6 +++--- src/vehicle_group.h | 6 +++--- 23 files changed, 40 insertions(+), 77 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 2335e20e2f33b..2f8dd6d7d5138 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -36,8 +36,6 @@ readability-*,\ -modernize-use-auto,\ -modernize-use-default-member-init,\ -modernize-use-emplace,\ --modernize-use-equals-default,\ --modernize-use-equals-delete,\ -modernize-use-transparent-functors,\ -performance-for-range-copy,\ -performance-inefficient-vector-operation,\ diff --git a/src/basecamp.cpp b/src/basecamp.cpp index fa380edf1716d..b88a4850e21d1 100644 --- a/src/basecamp.cpp +++ b/src/basecamp.cpp @@ -79,9 +79,7 @@ int base_camps::max_upgrade_by_type( const std::string &type ) return max_upgrade_cache[type]; } -basecamp::basecamp() -{ -} +basecamp::basecamp() = default; basecamp::basecamp( const std::string &name_, const tripoint &omt_pos_ ): name( name_ ), omt_pos( omt_pos_ ) diff --git a/src/character.h b/src/character.h index b54377867a5ff..16dafb1765f00 100644 --- a/src/character.h +++ b/src/character.h @@ -163,6 +163,8 @@ inline social_modifiers operator+( social_modifiers lhs, const social_modifiers class Character : public Creature, public visitable { public: + Character( const Character & ) = delete; + Character &operator=( const Character & ) = delete; ~Character() override; field_type_id bloodType() const override; @@ -887,9 +889,7 @@ class Character : public Creature, public visitable std::array healed_total; protected: Character(); - Character( const Character & ) = delete; Character( Character && ); - Character &operator=( const Character & ) = delete; Character &operator=( Character && ); struct trait_data { /** Whether the mutation is activated. */ diff --git a/src/colony.h b/src/colony.h index 06f84898e5321..48fae6d637b4d 100644 --- a/src/colony.h +++ b/src/colony.h @@ -550,7 +550,7 @@ class colony : private element_allocator_type return !( rh.it > it ); } - colony_reverse_iterator() noexcept {} + colony_reverse_iterator() noexcept = default; colony_reverse_iterator( const colony_reverse_iterator &source ) noexcept: it( source.it ) {} @@ -3219,7 +3219,7 @@ class colony : private element_allocator_type stored_instance( function_instance ) {} - sort_dereferencer() noexcept {} + sort_dereferencer() noexcept = default; bool operator()( const pointer first, const pointer second ) { return stored_instance( *first, *second ); diff --git a/src/dependency_tree.cpp b/src/dependency_tree.cpp index 506e559b87b16..0b2b8843a5a33 100644 --- a/src/dependency_tree.cpp +++ b/src/dependency_tree.cpp @@ -260,9 +260,7 @@ std::vector dependency_node::get_dependents_as_nodes() return ret; } -dependency_tree::dependency_tree() -{ -} +dependency_tree::dependency_tree() = default; void dependency_tree::init( std::map > key_dependency_map ) { diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 1995f71fa19db..ca19e6b78f3c9 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -81,10 +81,10 @@ bool inventory_entry::operator==( const inventory_entry &other ) const return get_category_ptr() == other.get_category_ptr() && locations == other.locations; } -class selection_column_preset: public inventory_selector_preset +class selection_column_preset : public inventory_selector_preset { public: - selection_column_preset() {} + selection_column_preset() = default; std::string get_caption( const inventory_entry &entry ) const override { std::ostringstream res; @@ -125,7 +125,7 @@ class selection_column_preset: public inventory_selector_preset } }; -static const selection_column_preset selection_preset; +static const selection_column_preset selection_preset{}; int inventory_entry::get_total_charges() const { diff --git a/src/item.cpp b/src/item.cpp index ecd28828c58a0..2accc01677fd4 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -6462,21 +6462,9 @@ bool item::units_sufficient( const Character &ch, int qty ) const return units_remaining( ch, qty ) == qty; } -item::reload_option::reload_option( const reload_option &rhs ) : - who( rhs.who ), target( rhs.target ), ammo( rhs.ammo ), - qty_( rhs.qty_ ), max_qty( rhs.max_qty ), parent( rhs.parent ) {} +item::reload_option::reload_option( const reload_option & ) = default; -item::reload_option &item::reload_option::operator=( const reload_option &rhs ) -{ - who = rhs.who; - target = rhs.target; - ammo = rhs.ammo; - qty_ = rhs.qty_; - max_qty = rhs.max_qty; - parent = rhs.parent; - - return *this; -} +item::reload_option &item::reload_option::operator=( const reload_option & ) = default; item::reload_option::reload_option( const player *who, const item *target, const item *parent, const item_location &ammo ) : diff --git a/src/json.cpp b/src/json.cpp index cdf65e13b1782..a6b929a2f81ca 100644 --- a/src/json.cpp +++ b/src/json.cpp @@ -103,16 +103,7 @@ JsonObject::JsonObject( const JsonObject &jo ) final_separator = jo.final_separator; } -JsonObject &JsonObject::operator=( const JsonObject &jo ) -{ - jsin = jo.jsin; - start = jo.start; - positions = jo.positions; - end = jo.end; - final_separator = jo.final_separator; - - return *this; -} +JsonObject &JsonObject::operator=( const JsonObject &jo ) = default; void JsonObject::finish() { diff --git a/src/json.h b/src/json.h index ab9fca2cff67b..effca6a7c147e 100644 --- a/src/json.h +++ b/src/json.h @@ -1053,9 +1053,9 @@ class JsonSerializer class JsonDeserializer { public: - virtual ~JsonDeserializer() {} + virtual ~JsonDeserializer() = default; virtual void deserialize( JsonIn &jsin ) = 0; - JsonDeserializer() { } + JsonDeserializer() = default; JsonDeserializer( JsonDeserializer && ) = default; JsonDeserializer( const JsonDeserializer & ) = default; JsonDeserializer &operator=( JsonDeserializer && ) = default; diff --git a/src/list.h b/src/list.h index 405ea1b4eec0f..1184108e14649 100644 --- a/src/list.h +++ b/src/list.h @@ -108,8 +108,7 @@ template element, second->element ); @@ -2283,8 +2280,7 @@ template ::obj() const const auto found = npc_templates.find( *this ); if( found == npc_templates.end() ) { debugmsg( "Tried to get invalid npc: %s", c_str() ); - static const npc_template dummy; + static const npc_template dummy{}; return dummy; } return found->second; diff --git a/src/npc.h b/src/npc.h index 2968a85ca16b4..3eb716d46bc79 100644 --- a/src/npc.h +++ b/src/npc.h @@ -1295,7 +1295,7 @@ class standard_npc : public npc class npc_template { public: - npc_template() {} + npc_template() = default; npc guy; diff --git a/src/npc_class.cpp b/src/npc_class.cpp index be636e56ef111..a2ed08cd18da4 100644 --- a/src/npc_class.cpp +++ b/src/npc_class.cpp @@ -462,8 +462,4 @@ distribution distribution::operator*( const distribution &other ) const } ); } -distribution &distribution::operator=( const distribution &other ) -{ - generator_function = other.generator_function; - return *this; -} +distribution &distribution::operator=( const distribution &other ) = default; diff --git a/src/omdata.h b/src/omdata.h index 89ff059153b1d..783b8dd02fb1a 100644 --- a/src/omdata.h +++ b/src/omdata.h @@ -186,7 +186,7 @@ struct oter_type_t { std::string get_symbol() const; - oter_type_t() {} + oter_type_t() = default; oter_id get_first() const; oter_id get_rotated( om_direction::type dir ) const; @@ -359,7 +359,7 @@ struct overmap_special_spawns : public overmap_spawns { }; struct overmap_special_terrain { - overmap_special_terrain() {} + overmap_special_terrain() = default; tripoint p; oter_str_id terrain; std::set flags; diff --git a/src/overmap.cpp b/src/overmap.cpp index a1c2a6cb4600e..cbefb9427bbe0 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -76,7 +76,7 @@ oter_id ot_null, ot_forest_water, ot_river_center; -const oter_type_t oter_type_t::null_type; +const oter_type_t oter_type_t::null_type{}; namespace om_lines { @@ -877,7 +877,7 @@ const overmap_special_terrain &overmap_special::get_terrain_at( const tripoint & return elem.p == p; } ); if( iter == terrains.end() ) { - static const overmap_special_terrain null_terrain; + static const overmap_special_terrain null_terrain{}; return null_terrain; } return *iter; diff --git a/src/requirements.h b/src/requirements.h index 654fdd4c7e2f9..1831e68ceb346 100644 --- a/src/requirements.h +++ b/src/requirements.h @@ -57,7 +57,7 @@ struct component { // If true, it's not actually a component but a requirement (list of components) bool requirement = false; - component() { } + component() = default; component( const itype_id &TYPE, int COUNT ) : type( TYPE ), count( COUNT ) { } component( const itype_id &TYPE, int COUNT, bool RECOVERABLE ) : type( TYPE ), count( COUNT ), recoverable( RECOVERABLE ) { } @@ -71,7 +71,7 @@ struct component { }; struct tool_comp : public component { - tool_comp() { } + tool_comp() = default; tool_comp( const itype_id &TYPE, int COUNT ) : component( TYPE, COUNT ) { } void load( JsonArray &ja ); @@ -87,7 +87,7 @@ struct tool_comp : public component { }; struct item_comp : public component { - item_comp() { } + item_comp() = default; item_comp( const itype_id &TYPE, int COUNT ) : component( TYPE, COUNT ) { } void load( JsonArray &ja ); diff --git a/src/skill.cpp b/src/skill.cpp index e349ec5b9c3aa..eb26133108005 100644 --- a/src/skill.cpp +++ b/src/skill.cpp @@ -225,7 +225,7 @@ bool SkillLevel::can_train() const const SkillLevel &SkillLevelMap::get_skill_level_object( const skill_id &ident ) const { - static const SkillLevel null_skill; + static const SkillLevel null_skill{}; if( ident && ident->is_contextual_skill() ) { debugmsg( "Skill \"%s\" is context-dependent. It cannot be assigned.", ident.str() ); diff --git a/src/skill.h b/src/skill.h index 0df5a2860777a..2dfc5daddcae1 100644 --- a/src/skill.h +++ b/src/skill.h @@ -79,7 +79,7 @@ class SkillLevel int _highestLevel = 0; public: - SkillLevel() {} + SkillLevel() = default; bool isTraining() const { return _isTraining; diff --git a/src/vehicle_group.cpp b/src/vehicle_group.cpp index 244e8a77ea59c..4eb0addf5cda5 100644 --- a/src/vehicle_group.cpp +++ b/src/vehicle_group.cpp @@ -25,7 +25,7 @@ const VehicleGroup &string_id::obj() const const auto iter = vgroups.find( *this ); if( iter == vgroups.end() ) { debugmsg( "invalid vehicle group id %s", c_str() ); - static const VehicleGroup dummy; + static const VehicleGroup dummy{}; return dummy; } return iter->second; @@ -49,7 +49,7 @@ const VehiclePlacement &string_id::obj() const const auto iter = vplacements.find( *this ); if( iter == vplacements.end() ) { debugmsg( "invalid vehicle placement id %s", c_str() ); - static const VehiclePlacement dummy; + static const VehiclePlacement dummy{}; return dummy; } return iter->second; @@ -158,7 +158,7 @@ const VehicleSpawn &string_id::obj() const const auto iter = vspawns.find( *this ); if( iter == vspawns.end() ) { debugmsg( "invalid vehicle spawn id %s", c_str() ); - static const VehicleSpawn dummy; + static const VehicleSpawn dummy{}; return dummy; } return iter->second; diff --git a/src/vehicle_group.h b/src/vehicle_group.h index 7059d72cd3f3f..29808f41732ca 100644 --- a/src/vehicle_group.h +++ b/src/vehicle_group.h @@ -31,7 +31,7 @@ extern std::unordered_map vgroups; class VehicleGroup { public: - VehicleGroup() {} + VehicleGroup() = default; void add_vehicle( const vproto_id &type, const int &probability ) { vehicles.add( type, probability ); @@ -80,7 +80,7 @@ struct VehicleLocation { * A list of vehicle locations which are valid for spawning new vehicles. */ struct VehiclePlacement { - VehiclePlacement() {} + VehiclePlacement() = default; void add( const jmapgen_int &x, const jmapgen_int &y, const VehicleFacings &facings ) { locations.emplace_back( x, y, facings ); @@ -158,7 +158,7 @@ class VehicleFunction_json : public VehicleFunction class VehicleSpawn { public: - VehicleSpawn() {} + VehicleSpawn() = default; void add( const double &weight, const std::shared_ptr &func ) { types.add( func, weight ); From 35de66e25dbc9c4af4b0bd2ef35d63ce2983fe68 Mon Sep 17 00:00:00 2001 From: Fris0uman <41293484+Fris0uman@users.noreply.github.com> Date: Tue, 20 Aug 2019 07:38:48 +0200 Subject: [PATCH 111/113] Allow mattresses as pillow fort material (#33370) * allow mattresses as pillow fort material * need one more matress for the floor --- data/json/construction.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/json/construction.json b/data/json/construction.json index 707fbba385198..8138f462d8832 100644 --- a/data/json/construction.json +++ b/data/json/construction.json @@ -2721,7 +2721,10 @@ "required_skills": [ [ "fabrication", 0 ] ], "time": "15 m", "pre_special": "check_empty", - "components": [ [ [ "pillow", 19 ], [ "down_pillow", 19 ] ], [ [ "down_blanket", 3 ], [ "blanket", 3 ], [ "fur_blanket", 3 ] ] ], + "components": [ + [ [ "pillow", 19 ], [ "down_pillow", 19 ], [ "mattress", 4 ] ], + [ [ "down_blanket", 3 ], [ "blanket", 3 ], [ "fur_blanket", 3 ] ] + ], "pre_terrain": "t_floor", "post_terrain": "f_pillow_fort" }, From 96a567e69ad75b125c54143c5526886937f3593f Mon Sep 17 00:00:00 2001 From: John Candlebury Date: Mon, 19 Aug 2019 23:40:24 -0600 Subject: [PATCH 112/113] Update Radio Tower Mapgen (#33355) * Update Radio Tower * Remove roofs --- .../terrain-floors-outdoors.json | 23 ++ data/json/mapgen/radio_tower.json | 250 +++++++++++++++--- .../overmap/overmap_special/specials.json | 29 +- .../overmap_terrain/overmap_terrain.json | 24 +- 4 files changed, 280 insertions(+), 46 deletions(-) diff --git a/data/json/furniture_and_terrain/terrain-floors-outdoors.json b/data/json/furniture_and_terrain/terrain-floors-outdoors.json index 603391f8a0540..33f7ad11b6d03 100644 --- a/data/json/furniture_and_terrain/terrain-floors-outdoors.json +++ b/data/json/furniture_and_terrain/terrain-floors-outdoors.json @@ -237,6 +237,29 @@ "items": [ { "item": "splinter", "count": [ 2, 8 ] }, { "item": "nail", "charges": [ 5, 10 ] } ] } }, + { + "type": "terrain", + "id": "t_metal_floor_no_roof", + "name": "metal floor", + "looks_like": "t_metal_floor", + "description": "High-quality and tough checkered flooring to reduce risk of slips and falls.", + "symbol": ".", + "color": "light_cyan", + "move_cost": 2, + "flags": [ "TRANSPARENT", "FLAT", "ROAD" ], + "bash": { + "sound": "thump", + "ter_set": "t_null", + "str_min": 200, + "str_max": 500, + "str_min_supported": 200, + "items": [ + { "item": "steel_lump", "count": [ 1, 4 ] }, + { "item": "steel_chunk", "count": [ 3, 12 ] }, + { "item": "scrap", "count": [ 9, 36 ] } + ] + } + }, { "type": "terrain", "id": "t_linoleum_white_no_roof", diff --git a/data/json/mapgen/radio_tower.json b/data/json/mapgen/radio_tower.json index 5d5e44192761d..05b3d8bcc02ac 100644 --- a/data/json/mapgen/radio_tower.json +++ b/data/json/mapgen/radio_tower.json @@ -7,6 +7,18 @@ "object": { "fill_ter": "t_floor", "rows": [ + " ---------------------- ", + " | | ", + " | | ", + " | R____R | ", + " |_______ ______ | ", + " |_______ ______ | ", + " |_______ ______ | ", + " |_______ _<____ | ", + " |_______ R____R | ", + " |_______ 6 | ", + " |_______ | ", + " ------22-------------- ", " ", " ", " ", @@ -18,12 +30,46 @@ " ", " ", " ", - " &&&& ", - " &&&& ", - " &&&& ", - " &&&& ", - " 6 ", - " ", + " " + ], + "terrain": { + " ": [ "t_dirt", "t_dirt", "t_grass" ], + "#": "t_concrete_wall", + "R": "t_radio_tower", + "2": "t_chaingate_c", + "-": "t_chainfence_h", + "|": "t_chainfence_v", + "6": "t_radio_controls", + "_": "t_pavement", + "<": "t_stairs_up" + } + } + }, + { + "type": "mapgen", + "method": "json", + "om_terrain": [ "radio_tower_1" ], + "weight": 250, + "object": { + "fill_ter": "t_floor", + "rows": [ + " -2222222-------------- ", + " |_______ | ", + " |_______ | ", + " |_______ R____R | ", + " |_______ ______ | ", + " |_______ ______ | ", + " |_______ ______ | ", + " |_______ _<____ | ", + " |_______ R____R | ", + " |___________ | ", + " |___________ | ", + " --------##+########--- ", + " #..ll#rrrC#4 ", + " w....+..h6# ", + " ##+#w#...C# ", + " |R wCCCCw ", + " |----##ww## ", " ", " ", " ", @@ -32,32 +78,86 @@ " ", " " ], - "terrain": { " ": [ "t_dirt", "t_dirt", "t_grass" ], "&": "t_radio_tower", "6": "t_radio_controls" } + "terrain": { + " ": [ "t_dirt", "t_dirt", "t_grass" ], + "#": "t_concrete_wall", + "R": "t_radio_tower", + "2": "t_chaingate_c", + "-": "t_chainfence_h", + "|": "t_chainfence_v", + "6": "t_radio_controls", + "_": "t_pavement", + "+": "t_door_c", + "4": "t_gutter_downspout", + "<": "t_stairs_up", + "w": "t_window" + }, + "furniture": { "C": "f_counter", "r": "f_rack", "h": "f_chair", "l": "f_locker" }, + "items": { + "C": { "item": "radio", "chance": 80, "repeat": [ 1, 2 ] }, + "r": { "item": "recycle_electronic", "chance": 80, "repeat": [ 1, 2 ] }, + "l": { "item": "clothing_work_set", "chance": 80 } + } } }, { "type": "mapgen", "method": "json", - "om_terrain": [ "radio_tower_1" ], - "weight": 250, + "om_terrain": "radio_tower_roof_1", "object": { - "fill_ter": "t_floor", + "fill_ter": "t_metal_floor_no_roof", "rows": [ " ", " ", " ", + " R,,,,R ", + " , , ", + " , , ", + " aaaa , ", + " a>": "t_stairs_down" } + } + }, + { + "type": "mapgen", + "method": "json", + "om_terrain": "radio_tower_even", + "object": { + "fill_ter": "t_metal_floor_no_roof", + "rows": [ + " ", + " :: ", + " aaaaaaaa ", + " aR,,,,Ra ", + " :a,,,,,,aX ", + " a,,::,,a ", + " a,,::,,a ", + " :a,<>,,,aX ", + " aR,,,,Ra ", + " aaaaaaaa ", + " : ", + " ", + " ", + " ", + " ", " ", " ", " ", @@ -68,43 +168,68 @@ " ", " " ], - "terrain": { - " ": [ "t_dirt", "t_dirt", "t_grass" ], - "#": "t_wall", - "&": "t_radio_tower", - "+": "t_door_c", - ".": "t_floor", - "6": "t_radio_controls", - "C": "t_floor", - "w": "t_window" - }, - "furniture": { "C": "f_counter" }, - "place_loot": [ { "item": "television", "x": 12, "y": 12, "chance": 100 }, { "item": "stepladder", "x": 10, "y": 12, "chance": 100 } ], - "place_items": [ { "item": "radio", "x": [ 13, 15 ], "y": 12, "chance": 60, "repeat": [ 1, 3 ] } ] + "palettes": [ "roof_palette" ], + "terrain": { "R": "t_radio_tower", "a": "t_railing", ",": "t_metal_floor_no_roof", "<": "t_stairs_up", ">": "t_stairs_down" } } }, { "type": "mapgen", "method": "json", - "om_terrain": "radio_tower_roof_1", + "om_terrain": "radio_tower_odd", "object": { - "fill_ter": "t_tar_flat_roof", + "fill_ter": "t_metal_floor_no_roof", "rows": [ " ", " ", + " ", + " :R,,,,R ", + " , , ", + " , , ", + " Xaaaa , ", + " Xa>": "t_stairs_down" } + } + }, + { + "type": "mapgen", + "method": "json", + "om_terrain": "radio_tower_top", + "object": { + "fill_ter": "t_metal_floor_no_roof", + "rows": [ " ", " ", " ", + " aaaaaa ", + " a,,,,a ", + " a,RR,a ", + " a,RR,a ", + " a>,,,a ", + " aaaaaa ", " ", " ", " ", " ", " ", " ", - " ......... ", - " ..:...... ", - " ......X.. ", - " ......... ", " ", " ", " ", @@ -116,7 +241,64 @@ " " ], "palettes": [ "roof_palette" ], - "terrain": { ".": "t_tar_flat_roof" } + "terrain": { "R": "t_radio_tower", "a": "t_railing", ",": "t_metal_floor_no_roof", ">": "t_stairs_down" }, + "place_nested": [ + { + "chunks": [ [ "null", 40 ], [ "radio_tower_2x2_map", 40 ], [ "radio_tower_2x2_holdout", 10 ], [ "radio_tower_2x2_sniper", 10 ] ], + "x": 10, + "y": 5 + } + ] + } + }, + { + "type": "mapgen", + "method": "json", + "nested_mapgen_id": "radio_tower_2x2_holdout", + "object": { + "mapgensize": [ 2, 2 ], + "place_furniture": [ + { "furn": "f_camp_chair", "x": 1, "y": 0, "chance": 50 }, + { "furn": "f_makeshift_bed", "x": 1, "y": 1, "chance": 50 } + ], + "place_loot": [ + { "group": "camping", "x": 1, "y": [ 0, 1 ], "chance": 50, "repeat": [ 2, 3 ] }, + { "item": "blanket", "x": 1, "y": [ 0, 1 ], "chance": 50, "repeat": [ 1, 2 ] }, + { "item": "can_drink_unsealed", "x": 1, "y": [ 0, 1 ], "chance": 30, "repeat": [ 2, 3 ] }, + { "item": "can_food_unsealed", "x": 1, "y": [ 0, 1 ], "chance": 40, "repeat": [ 2, 3 ] }, + { "item": "can_food_unsealed", "x": 1, "y": [ 0, 1 ], "chance": 40, "repeat": [ 2, 3 ] }, + { "item": "sleeping_bag", "x": 1, "y": 1, "chance": 40 } + ] + } + }, + { + "type": "mapgen", + "method": "json", + "nested_mapgen_id": "radio_tower_2x2_sniper", + "object": { + "mapgensize": [ 2, 2 ], + "place_furniture": [ { "furn": "f_camp_chair", "x": 1, "y": 0, "chance": 50 } ], + "place_loot": [ + { "item": "corpse", "x": 1, "y": 0 }, + { "group": "mon_zombie_soldier_death_drops", "x": 1, "y": 0 }, + { "item": "survivor_scope", "x": 1, "y": 0, "chance": 70 }, + { "item": "can_drink_unsealed", "x": 1, "y": [ 0, 1 ], "chance": 70, "repeat": [ 2, 3 ] }, + { "item": "3006", "x": 1, "y": 0, "chance": 40 }, + { "item": "survivor_special_700", "x": 1, "y": 0, "chance": 80, "ammo": 100 } + ] + } + }, + { + "type": "mapgen", + "method": "json", + "nested_mapgen_id": "radio_tower_2x2_map", + "object": { + "mapgensize": [ 2, 2 ], + "place_loot": [ + { "item": "survivor_scope", "x": 1, "y": 0 }, + { "item": "survivormap", "x": 1, "y": 0 }, + { "item": "3006", "x": 1, "y": 0, "chance": 40 } + ] } } ] diff --git a/data/json/overmap/overmap_special/specials.json b/data/json/overmap/overmap_special/specials.json index e22cc31730153..b4eb9b23362fd 100644 --- a/data/json/overmap/overmap_special/specials.json +++ b/data/json/overmap/overmap_special/specials.json @@ -88,7 +88,13 @@ { "point": [ -1, -4, 0 ], "overmap": "forest_aban1_north" }, { "point": [ 1, -2, 0 ], "overmap": "forest_aban1_north" }, { "point": [ 1, -3, 0 ], "overmap": "forest_aban1_north" }, - { "point": [ 1, -4, 0 ], "overmap": "forest_aban1_north" } + { "point": [ 1, -4, 0 ], "overmap": "forest_aban1_north" }, + { "point": [ -1, -5, 1 ], "overmap": "radio_tower_odd_north" }, + { "point": [ -1, -5, 2 ], "overmap": "radio_tower_even_north" }, + { "point": [ -1, -5, 3 ], "overmap": "radio_tower_odd_north" }, + { "point": [ -1, -5, 4 ], "overmap": "radio_tower_even_north" }, + { "point": [ -1, -5, 5 ], "overmap": "radio_tower_odd_north" }, + { "point": [ -1, -5, 6 ], "overmap": "radio_tower_top_north" } ], "connections": [ { "point": [ -1, -6, 0 ], "terrain": "road" }, { "point": [ 0, -5, 0 ], "terrain": "road" } ], "locations": [ "forest" ], @@ -646,8 +652,16 @@ { "type": "overmap_special", "id": "Radio Tower", - "overmaps": [ { "point": [ 0, 0, 0 ], "overmap": "radio_tower_north" } ], - "connections": [ { "point": [ 0, -1, 0 ], "terrain": "road" } ], + "overmaps": [ + { "point": [ 0, 0, 0 ], "overmap": "radio_tower_north" }, + { "point": [ 0, 0, 1 ], "overmap": "radio_tower_odd_north" }, + { "point": [ 0, 0, 2 ], "overmap": "radio_tower_even_north" }, + { "point": [ 0, 0, 3 ], "overmap": "radio_tower_odd_north" }, + { "point": [ 0, 0, 4 ], "overmap": "radio_tower_even_north" }, + { "point": [ 0, 0, 5 ], "overmap": "radio_tower_odd_north" }, + { "point": [ 0, 0, 6 ], "overmap": "radio_tower_top_north" } + ], + "connections": [ { "point": [ 0, -1, 0 ], "terrain": "road", "connection": "local_road", "from": [ 0, 0, 0 ] } ], "locations": [ "land" ], "city_distance": [ 0, 20 ], "city_sizes": [ 4, 12 ], @@ -659,9 +673,14 @@ "id": "Radio Tower 1", "overmaps": [ { "point": [ 0, 0, 0 ], "overmap": "radio_tower_1_north" }, - { "point": [ 0, 0, 1 ], "overmap": "radio_tower_roof_1_north" } + { "point": [ 0, 0, 1 ], "overmap": "radio_tower_roof_1_north" }, + { "point": [ 0, 0, 2 ], "overmap": "radio_tower_even_north" }, + { "point": [ 0, 0, 3 ], "overmap": "radio_tower_odd_north" }, + { "point": [ 0, 0, 4 ], "overmap": "radio_tower_even_north" }, + { "point": [ 0, 0, 5 ], "overmap": "radio_tower_odd_north" }, + { "point": [ 0, 0, 6 ], "overmap": "radio_tower_top_north" } ], - "connections": [ { "point": [ 0, -1, 0 ], "terrain": "road" } ], + "connections": [ { "point": [ 0, -1, 0 ], "terrain": "road", "connection": "local_road", "from": [ 0, 0, 0 ] } ], "locations": [ "land" ], "city_distance": [ 0, 20 ], "city_sizes": [ 4, 12 ], diff --git a/data/json/overmap/overmap_terrain/overmap_terrain.json b/data/json/overmap/overmap_terrain/overmap_terrain.json index 2d82980447674..c3e0c1387789b 100644 --- a/data/json/overmap/overmap_terrain/overmap_terrain.json +++ b/data/json/overmap/overmap_terrain/overmap_terrain.json @@ -340,21 +340,31 @@ "color": "light_gray", "see_cost": 2 }, + { + "type": "overmap_terrain", + "id": "radio_tower_even", + "copy-from": "radio_tower" + }, + { + "type": "overmap_terrain", + "id": "radio_tower_odd", + "copy-from": "radio_tower" + }, + { + "type": "overmap_terrain", + "id": "radio_tower_top", + "copy-from": "radio_tower" + }, { "type": "overmap_terrain", "id": "radio_tower_1", - "name": "radio tower", - "sym": "X", - "color": "light_gray", - "see_cost": 2 + "copy-from": "radio_tower" }, { "type": "overmap_terrain", "id": "radio_tower_roof_1", "name": "radio tower roof", - "sym": "X", - "color": "light_gray", - "see_cost": 2 + "copy-from": "radio_tower" }, { "type": "overmap_terrain", From 4fc3866d99931208820b33f4ea52cafa10e28e4a Mon Sep 17 00:00:00 2001 From: Rod995 <37703767+Rod995@users.noreply.github.com> Date: Tue, 20 Aug 2019 00:40:52 -0500 Subject: [PATCH 113/113] Adds `gunmod_data` documentation (#33352) --- doc/JSON_INFO.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 33d4c24a11354..abb08bf19474c 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -1114,7 +1114,7 @@ Guns can be defined like this: ``` Alternately, every item (book, tool, armor, even food) can be used as gun if it has gun_data: ```json -"type" : "TOOL", // Or any other item type +"type": "TOOL", // Or any other item type ... // same entries as for the type (e.g. same entries as for any tool), "gun_data" : { // additionally the same gun data like above "skill": ..., @@ -1147,6 +1147,16 @@ Gun mods can be defined like this: "reload_modifier": -10, // Optional field increasing or decreasing base gun reload time in percent "min_str_required_mod": 14, // Optional field increasing or decreasing minimum strength required to use gun ``` +Alternately, every item (book, tool, armor, even food) can be used as a gunmod if it has gunmod_data: +``` +"type": "TOOL", // Or any other item type +... // same entries as for the type (e.g. same entries as for any tool), +"gunmod_data" : { + "location": ..., + "mod_targets": ..., + ... +} +``` ### Batteries ```C++