Skip to content

Commit

Permalink
Merge pull request CleverRaven#30212 from Night-Pryanik/on-roof-flag
Browse files Browse the repository at this point in the history
Added ON_ROOF flag
  • Loading branch information
kevingranade authored May 4, 2019
2 parents 2e4aa2a + 2a9d757 commit 22854db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/mods/Aftershock/vehicles/afs_vehicle_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"name": "roof-mounted external tank (200L)",
"item": "55gal_drum",
"location": "on_roof",
"flags": [ "ON_ROOF" ],
"size": 200000
},
{
Expand Down
4 changes: 3 additions & 1 deletion doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 15 additions & 1 deletion src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) ) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 22854db

Please sign in to comment.