Skip to content
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

C++11 patchset 9: move hardcoded init parameters to class definitions (part 1) #5984

Merged
merged 3 commits into from Jun 16, 2017

Conversation

nerzhul
Copy link
Member

@nerzhul nerzhul commented Jun 14, 2017

C++11 introduced the possibility to define the default values directly in class definitions, do it on current code

This patchset cleanup src/{a*,b*,c*-> constants.h} files

@nerzhul nerzhul added the Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements label Jun 14, 2017
@nerzhul nerzhul added this to Todo in Minetest C++11 Jun 14, 2017
@@ -388,7 +364,7 @@ class RemoteClient
Block is removed when GOTBLOCKS is received.
Value is time from sending. (not used at the moment)
*/
std::map<v3s16, float> m_blocks_sending;
std::map<v3s16, float> m_blocks_sending = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't sets/maps defined to be empty when initialized?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i forgot to remove that my bad :)

src/collision.h Outdated
v3s16 node_p = v3s16(-32768,-32768,-32768); // COLLISION_NODE
bool bouncy = false;
v3f old_speed = v3f(0.0f, 0.0f, 0.0f);
v3f new_speed = v3f(0.0f, 0.0f, 0.0f);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then i will remove all standard v3f v3s16 :)

src/clouds.h Outdated
v2f m_speed;
v3s16 m_camera_offset;
video::SColorf m_color;
v3s16 m_camera_offset = v3s16(0, 0, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also set to 0 when initialized.

C++11 introduced the possibility to define the default values directly in class definitions, do it on current code

Also remove some unused attributes

* CollisionInfo::bouncy
* collisionMoveResult::collides_xy
* collisionMoveResult::standing_on_unloaded
* Clouds::speed
@nerzhul
Copy link
Member Author

nerzhul commented Jun 14, 2017

All points fixed

@@ -499,7 +498,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
info.type = COLLISION_NODE;

info.node_p = nearest_info.position;
info.bouncy = bouncy;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are affected but never used since 2012 it's why i removed them from code

@nerzhul nerzhul added this to Ready to merge in Minetest 5.0.0 blockers Jun 14, 2017
* remove only write guiFormSpecMenu::m_old_tooltip
* move header included inside defintions in genericobject.h
* remove some unused since years exception classes
* remove unused & empty debug_stacks_init
* remove unused & empty content_nodemeta_serialize_legacy
* remove forgotten useless bool (bouncy) in collision.cpp code
@nerzhul
Copy link
Member Author

nerzhul commented Jun 14, 2017

I added a second commit to this PR to make things advance (it's boring task but should be done)

bool m_physics_override_sneak = true;
bool m_physics_override_sneak_glitch = false;
bool m_physics_override_new_move = true;
bool m_physics_override_sent = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please line up these values for better readability?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean ?


// font
gui::IGUIFont* m_font;
gui::IGUIFont* m_font = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong pointer position

src/guiEngine.h Outdated
@@ -272,7 +272,7 @@ class GUIEngine {
void setTopleftText(const std::string &text);

/** pointer to gui element shown at topleft corner */
irr::gui::IGUIStaticText* m_irr_toplefttext;
irr::gui::IGUIStaticText* m_irr_toplefttext = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointer style wrong here too

@Zeno-
Copy link
Contributor

Zeno- commented Jun 16, 2017

👍

bool bouncy;
CollisionInfo() {}
CollisionType type = COLLISION_NODE;
v3s16 node_p = v3s16(-32768,-32768,-32768); // COLLISION_NODE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to use -32768?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value fits in the container, i don't really know it's the original behaviour, i think we can keep this as is as it's not a PR which should trigger regression by changing values :)

@nerzhul nerzhul merged commit 76be103 into minetest:master Jun 16, 2017
@ShadowNinja ShadowNinja removed this from Ready to merge in Minetest 5.0.0 blockers Jun 17, 2017
@nerzhul nerzhul moved this from Todo to Done in Minetest C++11 Jun 17, 2017
@nerzhul nerzhul deleted the cpp11_initializers_1 branch June 19, 2017 13:15
osjc pushed a commit to osjc/minetest that referenced this pull request Jan 11, 2019
… (part 1) (minetest#5984)

* C++11 patchset 9: move hardcoded init parameters to class definitions

C++11 introduced the possibility to define the default values directly in class definitions, do it on current code

Also remove some unused attributes

* CollisionInfo::bouncy
* collisionMoveResult::collides_xy
* collisionMoveResult::standing_on_unloaded
* Clouds::speed

* More constructor cleanups + some variables removal

* remove only write guiFormSpecMenu::m_old_tooltip
* move header included inside defintions in genericobject.h
* remove some unused since years exception classes
* remove unused & empty debug_stacks_init
* remove unused & empty content_nodemeta_serialize_legacy
* remove forgotten useless bool (bouncy) in collision.cpp code
osjc pushed a commit to osjc/minetest that referenced this pull request Jan 23, 2019
… (part 1) (minetest#5984)

* C++11 patchset 9: move hardcoded init parameters to class definitions

C++11 introduced the possibility to define the default values directly in class definitions, do it on current code

Also remove some unused attributes

* CollisionInfo::bouncy
* collisionMoveResult::collides_xy
* collisionMoveResult::standing_on_unloaded
* Clouds::speed

* More constructor cleanups + some variables removal

* remove only write guiFormSpecMenu::m_old_tooltip
* move header included inside defintions in genericobject.h
* remove some unused since years exception classes
* remove unused & empty debug_stacks_init
* remove unused & empty content_nodemeta_serialize_legacy
* remove forgotten useless bool (bouncy) in collision.cpp code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements One approval ✅ ◻️
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants