From 7205bbe1b78269f683a6817b496d054590ef8f99 Mon Sep 17 00:00:00 2001 From: Coolthulhu Date: Tue, 24 May 2022 20:03:40 +0200 Subject: [PATCH] Fix "bow" location not working at all Also add warning in strict json mode --- data/json/items/gunmod/accessories.json | 8 ++++---- data/json/items/gunmod/grip.json | 2 +- data/json/items/gunmod/mount.json | 2 +- data/json/items/gunmod/sights.json | 6 +++--- data/json/items/gunmod/underbarrel.json | 2 +- data/mods/Magiclysm/items/enchanted_gunmods.json | 2 +- src/item.cpp | 8 +++++--- src/item_factory.cpp | 4 ++++ 8 files changed, 20 insertions(+), 14 deletions(-) diff --git a/data/json/items/gunmod/accessories.json b/data/json/items/gunmod/accessories.json index 77b3794e9632..06f6bd74dbdb 100644 --- a/data/json/items/gunmod/accessories.json +++ b/data/json/items/gunmod/accessories.json @@ -13,7 +13,7 @@ "symbol": ":", "color": "dark_gray", "location": "accessories", - "mod_targets": [ "bow" ], + "mod_targets": [ "archery" ], "dispersion_modifier": -100 }, { @@ -29,7 +29,7 @@ "symbol": ":", "color": "brown", "location": "stabilizer", - "mod_targets": [ "bow" ], + "mod_targets": [ "archery" ], "dispersion_modifier": -100 }, { @@ -45,7 +45,7 @@ "symbol": ":", "color": "brown", "location": "stabilizer", - "mod_targets": [ "bow" ], + "mod_targets": [ "archery" ], "dispersion_modifier": -150, "flags": [ "NEEDS_UNFOLD" ] }, @@ -62,7 +62,7 @@ "symbol": ":", "color": "brown", "location": "dampening", - "mod_targets": [ "bow", "crossbow" ], + "mod_targets": [ "archery", "crossbow" ], "dispersion_modifier": -50, "loudness_modifier": -8 }, diff --git a/data/json/items/gunmod/grip.json b/data/json/items/gunmod/grip.json index f7dd942a3e1d..126ac0bdb83b 100644 --- a/data/json/items/gunmod/grip.json +++ b/data/json/items/gunmod/grip.json @@ -33,7 +33,7 @@ "symbol": ":", "color": "dark_gray", "location": "grip", - "mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "launcher", "bow" ], + "mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "launcher", "archery" ], "handling_modifier": 4 }, { diff --git a/data/json/items/gunmod/mount.json b/data/json/items/gunmod/mount.json index 136dcaa7cac5..33fad0685426 100644 --- a/data/json/items/gunmod/mount.json +++ b/data/json/items/gunmod/mount.json @@ -122,7 +122,7 @@ "symbol": ":", "color": "light_gray", "location": "underbarrel mount", - "mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "launcher", "bow" ], + "mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "launcher", "archery" ], "install_time": "5 m", "add_mod": [ [ "underbarrel", 1 ] ], "flags": [ "INSTALL_DIFFICULT", "IRREMOVABLE" ] diff --git a/data/json/items/gunmod/sights.json b/data/json/items/gunmod/sights.json index fb29bc7da9dd..930f48aaa854 100644 --- a/data/json/items/gunmod/sights.json +++ b/data/json/items/gunmod/sights.json @@ -13,7 +13,7 @@ "symbol": ":", "color": "dark_gray", "location": "sights", - "mod_targets": [ "bow" ], + "mod_targets": [ "archery" ], "sight_dispersion": 10, "aim_speed": 5 }, @@ -31,7 +31,7 @@ "symbol": ":", "color": "dark_gray", "location": "sights", - "mod_targets": [ "bow" ], + "mod_targets": [ "archery" ], "sight_dispersion": 25, "aim_speed": 8 }, @@ -49,7 +49,7 @@ "symbol": ":", "color": "dark_gray", "location": "sights", - "mod_targets": [ "bow" ], + "mod_targets": [ "archery" ], "sight_dispersion": 5, "aim_speed": 2, "flags": [ "ZOOM" ] diff --git a/data/json/items/gunmod/underbarrel.json b/data/json/items/gunmod/underbarrel.json index 072dda84d2cc..1f4eb2402e8f 100644 --- a/data/json/items/gunmod/underbarrel.json +++ b/data/json/items/gunmod/underbarrel.json @@ -225,7 +225,7 @@ "symbol": ":", "color": "dark_gray", "location": "underbarrel", - "mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "bow", "launcher" ], + "mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "archery", "launcher" ], "sight_dispersion": 30, "aim_speed": 9, "flags": [ "PUMP_RAIL_COMPATIBLE" ] diff --git a/data/mods/Magiclysm/items/enchanted_gunmods.json b/data/mods/Magiclysm/items/enchanted_gunmods.json index 3ac8615b79ec..cfa48a852d2d 100644 --- a/data/mods/Magiclysm/items/enchanted_gunmods.json +++ b/data/mods/Magiclysm/items/enchanted_gunmods.json @@ -54,7 +54,7 @@ "symbol": ":", "color": "dark_gray", "location": "underbarrel", - "mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "bow", "launcher" ], + "mod_targets": [ "smg", "rifle", "pistol", "shotgun", "crossbow", "archery", "launcher" ], "sight_dispersion": 27, "aim_speed": 9, "min_skills": [ [ "weapon", 2 ], [ "gun", 2 ] ], diff --git a/src/item.cpp b/src/item.cpp index a0ff61bb5a0d..d1b8a7d8042c 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -6926,8 +6926,6 @@ skill_id item::gun_skill() const gun_type_type item::gun_type() const { - static skill_id skill_archery( "archery" ); - if( !is_gun() ) { return gun_type_type( std::string() ); } @@ -7503,6 +7501,8 @@ ret_val item::is_gunmod_compatible( const item &mod ) const return ret_val::make_failure(); } static const gun_type_type pistol_gun_type( translate_marker_context( "gun_type_type", "pistol" ) ); + static const skill_id skill_archery( "archery" ); + static const std::string bow_hack_str( "bow" ); if( !is_gun() ) { return ret_val::make_failure( _( "isn't a weapon" ) ); @@ -7520,8 +7520,10 @@ ret_val item::is_gunmod_compatible( const item &mod ) const return ret_val::make_failure( _( "doesn't have enough room for another %s mod" ), mod.type->gunmod->location.name() ); + // TODO: Get rid of the "archery"->"bow" hack } else if( !mod.type->gunmod->usable.count( gun_type() ) && - !mod.type->gunmod->usable.count( typeId().str() ) ) { + !mod.type->gunmod->usable.count( typeId().str() ) && + !( gun_skill() == skill_archery && mod.type->gunmod->usable.count( bow_hack_str ) > 0 ) ) { return ret_val::make_failure( _( "cannot have a %s" ), mod.tname() ); } else if( typeId() == itype_hand_crossbow && diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 118a7fd0f2f8..e6e1111c0fe4 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -1321,6 +1321,10 @@ void Item_factory::check_definitions() const continue; } + if( json_report_strict && t.name_ == "bow" ) { + msg += string_format( "\"bow\" location is deprecated, use \"archery\" instead" ); + } + // We need to check is_skill because something can be both an item and a skill if( !is_skill && is_item ) { const itype *target = &*item_type;