Skip to content

Commit

Permalink
Merge pull request #78277 from Procyonae/ForceInitVehStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
Maleclypse authored Dec 4, 2024
2 parents 73a8a40 + e2fec0c commit b0f3322
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3157,7 +3157,7 @@ static void debug_menu_spawn_vehicle()
if( veh_cond_menu.ret >= 0 && veh_cond_menu.ret < 4 ) {
// TODO: Allow picking this when add_vehicle has 3d argument
vehicle *veh = here.add_vehicle(
selected_opt, dest, -90_degrees, 100, veh_cond_menu.ret - 1 );
selected_opt, dest, -90_degrees, 100, veh_cond_menu.ret - 1, true, true );
if( veh != nullptr ) {
here.board_vehicle( dest, &player_character );
}
Expand Down
2 changes: 1 addition & 1 deletion src/magic_spell_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ void spell_effect::spawn_summoned_vehicle( const spell &sp, Creature &caster,
return;
}
if( vehicle *veh = here.add_vehicle( sp.summon_vehicle_id(), target, -90_degrees,
100, 0, false ) ) {
100, 2, false, true ) ) {
veh->unlock();
veh->magic = true;
if( !sp.has_flag( spell_flag::PERMANENT ) ) {
Expand Down
11 changes: 7 additions & 4 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -2038,9 +2038,11 @@ class map
// if false and vehicle will overlap aborts and returns nullptr
// TODO: Get rid of untyped overload
vehicle *add_vehicle( const vproto_id &type, const tripoint &p, const units::angle &dir,
int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true );
int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true,
bool force_status = false );
vehicle *add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, const units::angle &dir,
int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true );
int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true,
bool force_status = false );

// Light/transparency
float light_transparency( const tripoint_bub_ms &p ) const;
Expand Down Expand Up @@ -2839,9 +2841,10 @@ class tinymap : private map
return map::veh_at( rebase_bub( p ) );
}
vehicle *add_vehicle( const vproto_id &type, const tripoint_omt_ms &p, const units::angle &dir,
int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true ) {
int init_veh_fuel = -1, int init_veh_status = -1, bool merge_wrecks = true,
bool force_status = false ) {
return map::add_vehicle( type, rebase_bub( p ), dir, init_veh_fuel, init_veh_status,
merge_wrecks );
merge_wrecks, force_status );
}
void add_splatter_trail( const field_type_id &type, const tripoint_omt_ms &from,
const tripoint_omt_ms &to ) {
Expand Down
11 changes: 7 additions & 4 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6808,13 +6808,16 @@ void map::add_spawn(
}

vehicle *map::add_vehicle( const vproto_id &type, const tripoint &p, const units::angle &dir,
const int veh_fuel, const int veh_status, const bool merge_wrecks )
const int veh_fuel, const int veh_status, const bool merge_wrecks,
const bool force_status/* = false*/ )
{
return map::add_vehicle( type, tripoint_bub_ms( p ), dir, veh_fuel, veh_status, merge_wrecks );
return map::add_vehicle( type, tripoint_bub_ms( p ), dir, veh_fuel, veh_status, merge_wrecks,
force_status );
}

vehicle *map::add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, const units::angle &dir,
const int veh_fuel, const int veh_status, const bool merge_wrecks )
const int veh_fuel, const int veh_status, const bool merge_wrecks,
const bool force_status/* = false*/ )
{
if( !type.is_valid() ) {
debugmsg( "Nonexistent vehicle type: \"%s\"", type.c_str() );
Expand All @@ -6833,7 +6836,7 @@ vehicle *map::add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, cons
std::tie( quotient, remainder ) = coords::project_remain<coords::sm>( p_ms );
veh->sm_pos = quotient.raw();
veh->pos = remainder;
veh->init_state( *this, veh_fuel, veh_status );
veh->init_state( *this, veh_fuel, veh_status, force_status );
veh->place_spawn_items();
veh->face.init( dir );
veh->turn_dir = dir;
Expand Down
7 changes: 5 additions & 2 deletions src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ bool vehicle::remote_controlled( const Character &p ) const
return false;
}

void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status )
void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status,
const bool force_status/* = false*/ )
{
// vehicle parts excluding engines in non-owned vehicles are by default turned off
for( vehicle_part &pt : parts ) {
Expand All @@ -333,7 +334,9 @@ void vehicle::init_state( map &placed_on, int init_veh_fuel, int init_veh_status
last_update = calendar::turn_zero;

if( get_option<bool>( "OVERRIDE_VEHICLE_INIT_STATE" ) ) {
init_veh_status = get_option<int>( "VEHICLE_STATUS_AT_SPAWN" );
if( !force_status ) {
init_veh_status = get_option<int>( "VEHICLE_STATUS_AT_SPAWN" );
}
init_veh_fuel = get_option<int>( "VEHICLE_FUEL_AT_SPAWN" );
}

Expand Down
3 changes: 2 additions & 1 deletion src/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ class vehicle
bool remote_controlled( const Character &p ) const;

// initializes parts and fuel state for randomly generated vehicle and calls refresh()
void init_state( map &placed_on, int init_veh_fuel, int init_veh_status );
void init_state( map &placed_on, int init_veh_fuel, int init_veh_status,
const bool force_status = false );

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (src)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

Check failure on line 943 in src/vehicle.h

View workflow job for this annotation

GitHub Actions / build (other)

parameter 'force_status' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls,-warnings-as-errors]

// damages all parts of a vehicle by a random amount
void smash( map &m, float hp_percent_loss_min = 0.1f, float hp_percent_loss_max = 1.2f,
Expand Down

0 comments on commit b0f3322

Please sign in to comment.