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

Enhance point api refactoring #33082

Merged

Conversation

jbytheway
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

The cata-use-point-apis check I added in #32963 turned out to have some limitations.

  • It didn't work for calls to function tremplates.
  • It didn't work if the parameter types were const int rather than int.

Describe the solution

Fix both those limitations.

Re-run the refactoring pass across the codebase again, capturing these new cases.

Additional context

Working gradually towards #32017.

The cata-use-point-apis check tries to convert calls to overloads to
which a point can be pased instead of separate coordinates.

This wasn't working when the call was to a function template
specialization.  Make that work.
The cata-use-point-apis check wasn't refactoring calls to functions
whose arguments were 'const int'.  Fix that.
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Code: Build Issues regarding different builds and build environments labels Aug 9, 2019
@@ -704,7 +704,7 @@ namespace
{
void draw_sct_curses( game &g )
{
const tripoint off = relative_view_pos( g.u, 0, 0, 0 );
const tripoint off = relative_view_pos( g.u, tripoint( 0, 0, 0 ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const tripoint off = relative_view_pos( g.u, tripoint( 0, 0, 0 ) );
const tripoint off = relative_view_pos( g.u, tripoint_zero );

@@ -37,7 +37,7 @@ TEST_CASE( "map_bounds_checking" )
// inelegant solution.
clear_map();
map m;
m.load( 0, 0, 0, false );
m.load( tripoint( 0, 0, 0 ), false );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
m.load( tripoint( 0, 0, 0 ), false );
m.load( tripoint_zero, false );

@@ -62,7 +62,7 @@ TEST_CASE( "tinymap_bounds_checking" )
// inelegant solution.
clear_map();
tinymap m;
m.load( 0, 0, 0, false );
m.load( tripoint( 0, 0, 0 ), false );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
m.load( tripoint( 0, 0, 0 ), false );
m.load( tripoint_zero, false );

@@ -155,7 +155,7 @@ static void init_global_game_state( const std::vector<mod_id> &mods,
overmap_special_batch empty_specials( { 0, 0 } );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
overmap_special_batch empty_specials( { 0, 0 } );
overmap_special_batch empty_specials( point_zero );

@jbytheway
Copy link
Contributor Author

I'm planning to automate those changes to put point_zero etc. later, so I was being lazy and not doing it by hand :).

@ZhilkinSerg ZhilkinSerg merged commit aee7ee1 into CleverRaven:master Aug 9, 2019
@jbytheway jbytheway deleted the enhance_point_api_refactoring branch August 10, 2019 10:13
dunstad pushed a commit to dunstad/Cataclysm-DDA that referenced this pull request Aug 11, 2019
* Support porting calls to function templates

The cata-use-point-apis check tries to convert calls to overloads to
which a point can be pased instead of separate coordinates.

This wasn't working when the call was to a function template
specialization.  Make that work.

* Test variadic function template also

* Handle const-qualified int arguments

The cata-use-point-apis check wasn't refactoring calls to functions
whose arguments were 'const int'.  Fix that.

* Apply refactoring pass using new features

* Follow-on tidying up of refactored code

* Add some point_zero, tripoint_zero
misterprimus pushed a commit to misterprimus/Cataclysm-DDA that referenced this pull request Sep 21, 2019
* Support porting calls to function templates

The cata-use-point-apis check tries to convert calls to overloads to
which a point can be pased instead of separate coordinates.

This wasn't working when the call was to a function template
specialization.  Make that work.

* Test variadic function template also

* Handle const-qualified int arguments

The cata-use-point-apis check wasn't refactoring calls to functions
whose arguments were 'const int'.  Fix that.

* Apply refactoring pass using new features

* Follow-on tidying up of refactored code

* Add some point_zero, tripoint_zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants