widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #14631
Re: [Merge] lp:~widelands-dev/widelands/soldier-capacity-ctrl into lp:widelands
I comment with an idea.
Diff comments:
> === modified file 'src/wui/soldiercapacitycontrol.cc'
> --- src/wui/soldiercapacitycontrol.cc 2018-04-27 06:11:05 +0000
> +++ src/wui/soldiercapacitycontrol.cc 2018-09-16 09:39:05 +0000
> @@ -112,11 +112,12 @@
> }
>
> void SoldierCapacityControl::click_decrease() {
> - change_soldier_capacity(-1);
> + // using int16_t because int32_t could cause over-/underflows
How about reading the current capacity and calculating it exactly it from there? That way, no need to worry bout over- or underflows.
> + change_soldier_capacity((SDL_GetModState() & KMOD_CTRL) ? std::numeric_limits<int16_t>::min() : -1);
> }
>
> void SoldierCapacityControl::click_increase() {
> - change_soldier_capacity(1);
> + change_soldier_capacity((SDL_GetModState() & KMOD_CTRL) ? std::numeric_limits<int16_t>::max() : 1);
> }
>
> UI::Panel* create_soldier_capacity_control(UI::Panel& parent,
--
https://code.launchpad.net/~widelands-dev/widelands/soldier-capacity-ctrl/+merge/355002
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/soldier-capacity-ctrl into lp:widelands.
References