-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply clang-tidy fixes #384
base: master
Are you sure you want to change the base?
Conversation
40ea622
to
ef99aac
Compare
662a0ca
to
edf1990
Compare
min_fleets {}, | ||
max_fleets {}, | ||
time_before_disband {} {} | ||
AIDefines::AIDefines() : fleet_size {}, min_fleets {}, max_fleets {} {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use size_t PROPERTY(var_name, 0)
to initialise these in the header and replace the constructor with AIDefines() = default;
(or remove it altogether)? Same for other defines structs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed these on running clang-tidy.
= default
is deceptive because if all the members are trivially constructible and aren't set, the type becomes trivially constructible which while great for performance, in most scenarios also introduces UB if you forget to initialize the value much like an uninitialized int. As a result I'm a bit undecided if we should use = default
for cases where we wouldn't benefit from trivial constructibility already.
src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
Outdated
Show resolved
Hide resolved
Actor::Actor() : model_file {}, scale { 1 }, idle_animation {}, move_animation {}, attack_animation {} {} | ||
Actor::Actor() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this (and other similar constructors in this file and maybe others) be removed, either replace with = default;
in the header or just gone altogether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't change anything (as of now) to be default here, and while it can't really happen as is, we don't want Actor to be trivial constructible which = default
can do wherever possible. This PR is not intended to change the calling semantics, just cleanup things according to clang-tidy.
ModifierEffectCache::building_type_effects_t::building_type_effects_t() {} | ||
ModifierEffectCache::good_effects_t::good_effects_t() {} | ||
ModifierEffectCache::unit_type_effects_t::unit_type_effects_t() {} | ||
ModifierEffectCache::regiment_type_effects_t::regiment_type_effects_t() {} | ||
ModifierEffectCache::ship_type_effects_t::ship_type_effects_t() {} | ||
ModifierEffectCache::unit_terrain_effects_t::unit_terrain_effects_t() {} | ||
ModifierEffectCache::strata_effects_t::strata_effects_t() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be moved to the header as default
or just removed altogether?
navy_base_effects {}, | ||
ship_type_effects { nullptr }, | ||
unit_terrain_effects { nullptr }, | ||
ship_type_effects { nullptr }, unit_terrain_effects { nullptr }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting here seems inconsistent, why are these on the same line? Also I've tried to avoid "tab + 2 spaces" formatting for constructor lists, instead adding 2 spaces before the :
so that all the later lines only need a tab
@@ -28,7 +29,7 @@ namespace OpenVic { | |||
struct ConditionalWeight { | |||
|
|||
private: | |||
fixed_point_t PROPERTY(base); | |||
fixed_point_t PROPERTY(base, fixed_point_t::_0()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Across many files in this PR, fixed_point_t
s are unnecessarily initialised to 0. It's not the end of the world, but it would be cleaner to avoid it where possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed_point_t always initialized to 0 because someone set the default constructor to always initialize the value to 0, fixed points are thus always default initialized when declared, truthfully this specific case is pointless but its just mimicking the behavior that was in the source file
|
||
protected: | ||
virtual bool _parse_script(ast::NodeCPtr root, _Context... context) = 0; | ||
|
||
public: | ||
Script() : _root { nullptr } {} | ||
Script() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not = default
?
5174916558532155392 | ||
5174916558532153344 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that this changed, I guess we've found an example of why we don't use floats and platform specific implementations of stuff like exp
. Not that big a deal here tho as this is by far the least likely value to be used in any exponential calculations we do, but still worth bearing in mind for any future re-generations of this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to get a consistent value we can use for this that won't change on each run of the script, I have literally no idea how we'd achieve that with python tho.
f2d1150
to
2cd5a1b
Compare
edf1990
to
33b06dc
Compare
2cd5a1b
to
5751583
Compare
39e2fcf
to
b2fee04
Compare
b2fee04
to
68eabd1
Compare
Move fixed point LUT generator scripts to misc/scripts
68eabd1
to
56c1951
Compare
Move fixed point LUT generator scripts to misc/scripts