From 3db594912fff9c47e74b4be1aa1b74cbb0a84a9a Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 14 Dec 2014 20:48:05 +0000 Subject: [PATCH] Lunatic: for '(display)rand*', use math.floor(); correct create_additive_trans() help. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4816 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/control.lua | 10 ++++++---- polymer/eduke32/source/lunatic/test/shadexfog.lua | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index f57d2ef57..64ac203a7 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -24,6 +24,8 @@ local band, bor = bit.band, bit.bor local rshift = bit.rshift local tobit = bit.tobit +local floor = math.floor + local assert = assert local error = error local ipairs = ipairs @@ -460,11 +462,11 @@ end --- Legacy operators --- function _rand(x) - return tobit((ffiC.krand()*(x+1))/65536) + return floor((ffiC.krand()*(x+1))/65536) end function _displayrand(x) - return tobit((math.random(0, 32767)*(x+1))/32768) + return floor((math.random(0, 32767)*(x+1))/32768) end do @@ -2100,7 +2102,7 @@ local function gamearray_file_common(qnum, writep) end end - return f, math.floor(fsize/4), isnewgar, fn + return f, floor(fsize/4), isnewgar, fn end local function check_gamearray_idx(gar, idx, addstr) @@ -2137,7 +2139,7 @@ local gamearray_methods = { error("invalid new array size "..newsize, 2) end - local MAXELTS = math.floor(0x7fffffff/4) + local MAXELTS = floor(0x7fffffff/4) if (newsize > MAXELTS) then -- mainly for some sanity with kread() (which we don't use, but still) error("new array size "..newsize.." too large (max="..MAXELTS.." elements)", 2) diff --git a/polymer/eduke32/source/lunatic/test/shadexfog.lua b/polymer/eduke32/source/lunatic/test/shadexfog.lua index a72887d05..be8ba4794 100644 --- a/polymer/eduke32/source/lunatic/test/shadexfog.lua +++ b/polymer/eduke32/source/lunatic/test/shadexfog.lua @@ -570,7 +570,7 @@ formatHelp <____________________________________________________________________> Creates blending tables of smooth alpha translucency, -starting with the blending number , with fractions +starting with the blending number , with values of alpha 1/(2\255), 2/(2\255) ... /(2\255). @@ -596,9 +596,10 @@ formatHelp <____________________________________________________________________> Creates blending tables of smooth additive translucency, -starting with the blending number , with fractions +starting with the blending number , with factors for the +background color - 1/(2\255), 2/(2\255) ... /(2\255). + 1/, 2/ ... /. must be a power of two in [1 .. 128].