From 1e68829d2f3e68f7230017e5344fab4298e00b91 Mon Sep 17 00:00:00 2001 From: anothersimulacrum Date: Fri, 12 Feb 2021 16:12:20 -0800 Subject: [PATCH] Migrate vehicle ammo spawns These weren't migrated, and some hacks existed to ease this in generic guns. Remove those hacks, and migrate ammo spawns in vehicle turrets. See https://github.com/CleverRaven/Cataclysm-DDA/pull/36839#issuecomment-575954094 for more details on why these hacks existed. --- .../temp_ammo_redefine_hack.json | 26 --- .../temp_magazine_json_load_hack.json | 206 ------------------ src/veh_type.cpp | 15 ++ 3 files changed, 15 insertions(+), 232 deletions(-) delete mode 100644 data/mods/Generic_Guns/vehicles/ammo_redefine_hacks/temp_ammo_redefine_hack.json delete mode 100644 data/mods/Generic_Guns/vehicles/ammo_redefine_hacks/temp_magazine_json_load_hack.json diff --git a/data/mods/Generic_Guns/vehicles/ammo_redefine_hacks/temp_ammo_redefine_hack.json b/data/mods/Generic_Guns/vehicles/ammo_redefine_hacks/temp_ammo_redefine_hack.json deleted file mode 100644 index 11ec18dab5c77..0000000000000 --- a/data/mods/Generic_Guns/vehicles/ammo_redefine_hacks/temp_ammo_redefine_hack.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "id": "308", - "type": "AMMO", - "name": { "str_sp": "rifle ammo, ball" }, - "copy-from": "rifle_ball" - }, - { - "id": "762_51", - "type": "AMMO", - "name": { "str_sp": "rifle ammo, ball" }, - "copy-from": "rifle_ball" - }, - { - "id": "556", - "type": "AMMO", - "name": { "str_sp": "rifle ammo, ball" }, - "copy-from": "rifle_ball" - }, - { - "id": "40x53mm_m430a1", - "type": "AMMO", - "name": { "str": "HEDP grenade cartridge" }, - "copy-from": "grenade_ammo_hedp" - } -] diff --git a/data/mods/Generic_Guns/vehicles/ammo_redefine_hacks/temp_magazine_json_load_hack.json b/data/mods/Generic_Guns/vehicles/ammo_redefine_hacks/temp_magazine_json_load_hack.json deleted file mode 100644 index 1d8ed82cb3ba1..0000000000000 --- a/data/mods/Generic_Guns/vehicles/ammo_redefine_hacks/temp_magazine_json_load_hack.json +++ /dev/null @@ -1,206 +0,0 @@ -[ - { - "id": "belt308", - "copy-from": "belt308", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "7.62x51mm ammo belt" } - }, - { - "id": "falbigmag", - "copy-from": "falbigmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "FN FAL extended magazine" } - }, - { - "id": "falmag", - "copy-from": "falmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "FN FAL magazine" } - }, - { - "id": "fal_makeshiftmag", - "copy-from": "fal_makeshiftmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "FN FAL makeshift magazine" } - }, - { - "id": "g3bigmag", - "copy-from": "g3bigmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "H&K G3 drum magazine" } - }, - { - "id": "g3mag", - "copy-from": "g3mag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "H&K G3 magazine" } - }, - { - "id": "g3_makeshiftmag", - "copy-from": "g3_makeshiftmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "H&K G3 makeshift magazine" } - }, - { - "id": "m14mag", - "copy-from": "m14mag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "M14 magazine" } - }, - { - "id": "m14smallmag", - "copy-from": "m14smallmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "M14 compact magazine" } - }, - { - "id": "m14_makeshiftmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "copy-from": "m14_makeshiftmag", - "name": { "str": "M14 makeshift magazine" } - }, - { - "id": "scarhbigmag", - "copy-from": "scarhbigmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "FN SCAR-H drum magazine" } - }, - { - "id": "scarhmag_30rd", - "copy-from": "scarhmag_30rd", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "FN SCAR-H 30-round magazine" } - }, - { - "id": "scarhmag", - "copy-from": "scarhmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "FN SCAR-H magazine" } - }, - { - "id": "scarh_makeshiftmag", - "copy-from": "scarh_makeshiftmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "FN SCAR-H makeshift magazine" } - }, - { - "id": "hk417mag_20rd", - "copy-from": "hk417mag_20rd", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "HK417 magazine" } - }, - { - "id": "hk417mag_10rd", - "copy-from": "hk417mag_10rd", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "HK417 compact magazine" } - }, - { - "id": "hk417_makeshiftmag", - "copy-from": "hk417_makeshiftmag", - "type": "MAGAZINE", - "name": { "str": "HK417 makeshift magazine" }, - "ammo_type": [ "ammo_rifle", "308" ] - }, - { - "id": "ar10mag_20rd", - "copy-from": "ar10mag_20rd", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "AR-10 magazine" } - }, - { - "id": "ar10_makeshiftmag", - "copy-from": "ar10_makeshiftmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "308" ], - "name": { "str": "AR-10 makeshift magazine" } - }, - { - "id": "223_speedloader5", - "copy-from": "223_speedloader5", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "LW-5 speedloader" }, - "pocket_data": [ { "pocket_type": "MAGAZINE", "ammo_restriction": { "ammo_rifle": 5 } } ] - }, - { - "id": "belt223", - "copy-from": "belt223", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "5.56x45mm ammo belt" } - }, - { - "id": "ruger5", - "copy-from": "ruger5", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "Ruger .223 5-round magazine" } - }, - { - "id": "stanag10", - "copy-from": "stanag10", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "Ruger .223 10-round magazine" } - }, - { - "id": "ruger30", - "copy-from": "ruger30", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "Ruger .223 high-capacity magazine" } - }, - { - "id": "stanag30", - "copy-from": "stanag30", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "STANAG magazine" } - }, - { - "id": "stanag50", - "copy-from": "stanag50", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "STANAG drum magazine" } - }, - { - "id": "survivor223mag", - "copy-from": "survivor223mag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "STANAG makeshift magazine" } - }, - { - "id": "ruger_makeshiftmag", - "copy-from": "ruger_makeshiftmag", - "type": "MAGAZINE", - "ammo_type": [ "ammo_rifle", "223", "300blk" ], - "name": { "str": "Ruger makeshift magazine" } - }, - { - "id": "belt40mm", - "copy-from": "belt40mm", - "type": "MAGAZINE", - "name": { "str": "grenade belt" }, - "ammo_type": [ "ammo_grenade", "40x53mm" ] - } -] diff --git a/src/veh_type.cpp b/src/veh_type.cpp index ab7603f1f8c7b..69d274810163e 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -19,6 +19,7 @@ #include "game_constants.h" #include "init.h" #include "item.h" +#include "item_factory.h" #include "item_group.h" #include "item_pocket.h" #include "itype.h" @@ -1234,6 +1235,20 @@ void vehicle_prototype::finalize() } } + std::vector migrated; + for( auto it = pt.ammo_types.begin(); it != pt.ammo_types.end(); ) { + if( item_controller->migrate_id( *it ) != *it ) { + migrated.push_back( item_controller->migrate_id( *it ) ); + it = pt.ammo_types.erase( it ); + } else { + ++it; + } + } + + for( const itype_id &migrant : migrated ) { + pt.ammo_types.insert( migrant ); + } + if( type_can_contain( *base, pt.fuel ) || base->magazine ) { if( !item::type_is_defined( pt.fuel ) ) { debugmsg( "init_vehicles: tank %s specified invalid fuel in %s",