Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
None
Purpose of change
Cleans various unused, rarely used, stubs and duplicate functions from vehicle class
Describe the solution
num_parts/num_true_parts/part_count needed special treatment;
parts.size()
and is a duplicate ofnum_parts()
except it uses fake_parts.size()parts.size() - fake_parts.size()
The problem is num_true_parts is used generic_vehicle_part_range which is in turn used inside vehicle::refresh() while fake_parts is being filled. Trying to use the actual real part count in the range class results in bike rack test failures, so to keep status quo and keep tests happy these were refactored to 3 functions:
int part_count() const;
- returns parts.size()int part_count_real() const;
- uses std::count_if to iterate and count parts with with is_fake falseint part_count_real_cached() const;
- returnsparts.size() - fake_parts.size()
and used in the range classI'm 90% sure generic_vehicle_part_range shouldn't be using fake_parts as it's being filled and it can cause issues, but it'll require a separate patch to figure out what's getting broken there
Unused:
int break_off( int p, int dmg )
void remove_owner()
turret_data turret_query( const vehicle_part &pt ) const;
- used once as a DIY const_cast hack, not actually neededturret_data turret_query( const tripoint &pos ) const;
const vehicle_part &cpart( int part_num ) const;
- no uses, no implementation, part() has const overloadvoid force_erase_part( int part_num );
bool valid_part( int part_num ) const;
- no implementationbool has_any_parts() const;
- unusedint removed_part_count = 0; // NOLINT(cata-serialize)
- unused variable, only written toUseless:
tripoint get_abs_diff( const tripoint &one, const tripoint &two ) const;
- same as(one-two).abs()
with extra stepsRarely used:
int num_fake_parts() const;
- only used in tests, moved to the testint num_active_fake_parts() const;
- only used in tests, moved to the testint num_true_parts() const;
- renamed topart_count_real()
to matchpart_count()
void refresh_mass() const;
- stub immediately callingcalc_mass_center( true );
Duplicates:
int num_parts() const;
- duplicate ofpart_count()
, replaced withpart_count
as that one had more usersRemoved overloads:
int part_count( bool no_fake = false ) const;
only had 1 user with no_fake == true, split to no-parameterpart_count()
andpart_count_real()
(deduplicated and renamed fromnum_true_parts()
)std::vector<vehicle_part *> lights( bool active = false );
- all users had set active = true, removed the parameter, only returns enabled lightsMisc:
bool real_or_active_fake_part( int part_num ) const;
- was moved to vehicle_part, a few checks that actually checked this but didn't use the function weer made to use the function insteadCAPTURE(...)
s instead of std::cout printsDescribe alternatives you've considered
Testing
Compiler and tests should hopefully catch me
Additional context