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

getDigParams: Fix selecting the lowest digging time #5558

Closed
wants to merge 3 commits into from

Conversation

HybridDog
Copy link
Contributor

@HybridDog HybridDog commented Apr 10, 2017

  • Tidy up code
  • Fix selecting the best fitting time: time was compared with result_time before dividing it by the level difference
  • Remove dead code (time from last punch)

src/tool.cpp Outdated
}

u16 wear_i = 65535.*result_wear;
u16 wear_i = 0xffff * result_wear;
Copy link
Member

Choose a reason for hiding this comment

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

U16_MAX

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

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

Otherwise 👍

src/tool.cpp Outdated
result_wear = 0;
result_main_group = name;
}
bool time_exists = cap.getTime(itemgroup_get(groups, groupname), &time);
Copy link
Member

Choose a reason for hiding this comment

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

no need to create variable, just call this into condition

Copy link
Member

Choose a reason for hiding this comment

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

It's not entirely clear what getTime returns, thus it's better to keep it this way. Makes it easier to understand and the compiler would optimize this anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@paramat paramat added the Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements label Apr 10, 2017
SmallJoker
SmallJoker previously approved these changes Apr 11, 2017
Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

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

LGTM, however, you quite misunderstood what nerzhul and me actually meant. Your previous commit was good too.

src/tool.cpp Outdated
//infostream<<"f="<<f<<std::endl;
result_time /= f;
result_wear /= f;
if (f > 1.0) {
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong. It can't be > 1 since last_punch < punch_interval

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Anyway, l just noticed ($ ag -r -A2 getDigParams) that it's unused code.
l'll remove it in a separate commit.

@SmallJoker SmallJoker dismissed their stale review April 11, 2017 14:28

Found issue.

@HybridDog HybridDog changed the title tool.cpp: 3 changes in getDigParams 3 changes in getDigParams Apr 11, 2017
@@ -219,18 +219,14 @@ int ModApiUtil::l_write_json(lua_State *L)
return 1;
}

// get_dig_params(groups, tool_capabilities[, time_from_last_punch])
// get_dig_params(groups, tool_capabilities)
int ModApiUtil::l_get_dig_params(lua_State *L)
Copy link
Member

Choose a reason for hiding this comment

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

Mind documenting get_hit_params and get_dig_params in the Lua API or does that rather belong into a new pull/issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lt belongs to another PR.

@nerzhul nerzhul added the Rebase needed The PR needs to be rebased by its author label Apr 19, 2017
@paramat
Copy link
Contributor

paramat commented Apr 19, 2017

l put the first two in one commit because the code is changed in the same place.

Code cleanup should still be a separate commit even if it is acting on the same code, mixiing cleanups with other changes makes review harder and creates a more confusing history.

@HybridDog HybridDog force-pushed the toolfix branch 2 times, most recently from 3409f33 to 8874520 Compare April 19, 2017 19:01
@HybridDog
Copy link
Contributor Author

HybridDog commented Apr 19, 2017

paramat, you're right. l added an extra commit which shows a simple (and inefficient) fix.

@HybridDog HybridDog changed the title 3 changes in getDigParams getDigParams: Fix selecting the lowest digging time Apr 19, 2017
@sfan5 sfan5 removed the Rebase needed The PR needs to be rebased by its author label Apr 20, 2017
@paramat
Copy link
Contributor

paramat commented Apr 21, 2017

Thanks, perhaps the last 2 can be squashed? (this could be done on merge).

@sfan5
Copy link
Member

sfan5 commented Apr 29, 2017

Only thing that failed is an unimportant unittest on OS X

@SmallJoker SmallJoker added the Rebase needed The PR needs to be rebased by its author label Aug 29, 2017
time was compared with result_time before dividing it by the level difference
@sfan5 sfan5 removed the Rebase needed The PR needs to be rebased by its author label Oct 14, 2017
Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

lgtm

@paramat
Copy link
Contributor

paramat commented Dec 26, 2017

@SmallJoker still +1? If so this can be merged.

@SmallJoker
Copy link
Member

@paramat Yes.

@paramat
Copy link
Contributor

paramat commented Jan 3, 2018

d7c1f6c
345e104

@paramat paramat closed this Jan 3, 2018
@paramat
Copy link
Contributor

paramat commented Jan 3, 2018

Is there a corresponding issue to close?

@HybridDog
Copy link
Contributor Author

AfaIk, there isn't.

@HybridDog HybridDog deleted the toolfix branch January 3, 2018 09:11
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 >= Two approvals ✅ ✅
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants