From 7196fd8b7e5e6a9e7ebd08becb1489d81485df85 Mon Sep 17 00:00:00 2001 From: Night-Pryanik Date: Fri, 3 May 2019 17:50:23 +0400 Subject: [PATCH 1/3] Added check for installing parts with ON_ROOF flag --- src/vehicle.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 653b1b38c46a1..bfe9c6d0f26b8 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1015,7 +1015,7 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } } - //Turret mounts must NOT be installed on other (moded) turret mounts + //Turret mounts must NOT be installed on other (modded) turret mounts if( part.has_flag( "TURRET_MOUNT" ) ) { for( const auto &elem : parts_in_square ) { if( part_info( elem ).has_flag( "TURRET_MOUNT" ) ) { @@ -1024,6 +1024,20 @@ bool vehicle::can_mount( const point &dp, const vpart_id &id ) const } } + //Roof-mounted parts must be installed on a roofs + if( part.has_flag( "ON_ROOF" ) ) { + bool anchor_found = false; + for( const auto &elem : parts_in_square ) { + if( part_info( elem ).has_flag( "ROOF" ) ) { + anchor_found = true; + break; + } + } + if( !anchor_found ) { + return false; + } + } + //Anything not explicitly denied is permitted return true; } From dc26c2427a9a482578ce93ae32dd22e12110cd91 Mon Sep 17 00:00:00 2001 From: Night-Pryanik Date: Fri, 3 May 2019 17:50:55 +0400 Subject: [PATCH 2/3] Added ON_ROOF flag to Aftershock's roof-mounted external 200L tank --- data/mods/Aftershock/vehicles/afs_vehicle_parts.json | 1 + 1 file changed, 1 insertion(+) diff --git a/data/mods/Aftershock/vehicles/afs_vehicle_parts.json b/data/mods/Aftershock/vehicles/afs_vehicle_parts.json index 210d8d1f64a3e..2f5897061e3cf 100644 --- a/data/mods/Aftershock/vehicles/afs_vehicle_parts.json +++ b/data/mods/Aftershock/vehicles/afs_vehicle_parts.json @@ -239,6 +239,7 @@ "name": "roof-mounted external tank (200L)", "item": "55gal_drum", "location": "on_roof", + "flags": [ "ON_ROOF" ], "size": 200000 }, { From 2a9d757e0e943118a66adca67c42071d054ec211 Mon Sep 17 00:00:00 2001 From: Night-Pryanik Date: Fri, 3 May 2019 17:51:47 +0400 Subject: [PATCH 3/3] Updated documentation for vehicle flags --- doc/JSON_FLAGS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/JSON_FLAGS.md b/doc/JSON_FLAGS.md index f53ca374dbe74..af4d8d797593d 100644 --- a/doc/JSON_FLAGS.md +++ b/doc/JSON_FLAGS.md @@ -537,6 +537,7 @@ These branches are also the valid entries for the categories of `dreams` in `dre - ```OBSTACLE``` Cannot walk through part, unless the part is also ```OPENABLE```. - ```ODDTURN``` Only on during odd turns. - ```ON_CONTROLS``` +- ```ON_ROOF``` - Parts with this flag could only be installed on a roof (parts with ```ROOF``` flag). - ```OPAQUE``` Cannot be seen through. - ```OPENABLE``` Can be opened or closed. - ```OPENCLOSE_INSIDE``` Can be opened or closed, but only from inside the vehicle. @@ -568,7 +569,8 @@ These branches are also the valid entries for the categories of `dreams` in `dre - ```TOOL_WRENCH``` Attached with bolts, can be removed/installed with a wrench - ```TRACK``` Allows the vehicle installed on, to be marked and tracked on map. - ```TRACKED``` Contributes to steering effectiveness but doesn't count as a steering axle for install difficulty and still contributes to drag for the center of steering calculation. -- ```TURRET``` Is a weapon turret. +- ```TURRET``` Is a weapon turret. Can only be installed on a part with ```TURRET_MOUNT``` flag. +- ```TURRET_MOUNT``` Parts with this flag are suitable for installing turrets. - ```UNMOUNT_ON_DAMAGE``` Part breaks off the vehicle when destroyed by damage. - ```UNMOUNT_ON_MOVE``` Dismount this part when the vehicle moves. Doesn't drop the part, unless you give it special handling. - ```VARIABLE_SIZE``` Has 'bigness' for power, wheel radius, etc.