Lua: added helper.round function
This commit is contained in:
parent
8418f05e8c
commit
6bfaa5ef88
2 changed files with 13 additions and 0 deletions
|
@ -82,6 +82,7 @@ Version 1.11.0-svn:
|
|||
* Changed: Extended support for toggle_button.
|
||||
* Fixed: wesnoth.find_reach does no longer replace a passed private lua
|
||||
proxy unit with the on-map unit at the same location
|
||||
* new: helper.round function
|
||||
* Multiplayer:
|
||||
* Fix an accidental terrain type change in Isar's Cross
|
||||
* Fix attacker side being human in 6p_Team_Survival (bug #19400)
|
||||
|
|
|
@ -368,4 +368,16 @@ function helper.deprecate(msg, f)
|
|||
end
|
||||
end
|
||||
|
||||
function helper.round( number )
|
||||
-- code converted from util.hpp, round_portable function
|
||||
-- round half away from zero method
|
||||
if number >= 0 then
|
||||
number = math.floor( number + 0.5 )
|
||||
else
|
||||
number = math.ceil ( number - 0.5 )
|
||||
end
|
||||
|
||||
return number
|
||||
end
|
||||
|
||||
return helper
|
||||
|
|
Loading…
Add table
Reference in a new issue