mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 17:32:13 +00:00
Lunatic rotatesprite: disallow FULL16 coordinates since Lua numbers are FP.
git-svn-id: https://svn.eduke32.com/eduke32@3770 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
6cc4cfbf8a
commit
3092fb20e7
2 changed files with 24 additions and 10 deletions
|
@ -279,29 +279,43 @@ function isenemytile(tilenum)
|
||||||
return (bit.band(ffiC.g_tile[tilenum].flags, BADGUY_MASK)~=0)
|
return (bit.band(ffiC.g_tile[tilenum].flags, BADGUY_MASK)~=0)
|
||||||
end
|
end
|
||||||
|
|
||||||
function rotatesprite(x, y, zoom, ang, tilenum, shade, pal, orientation,
|
-- The 'rotatesprite' wrapper used by the CON commands.
|
||||||
|
function _rotspr(x, y, zoom, ang, tilenum, shade, pal, orientation,
|
||||||
alpha, cx1, cy1, cx2, cy2)
|
alpha, cx1, cy1, cx2, cy2)
|
||||||
check_tile_idx(tilenum)
|
check_tile_idx(tilenum)
|
||||||
orientation = bit.band(orientation, 4095) -- ROTATESPRITE_MAX-1
|
orientation = bit.band(orientation, 4095) -- ROTATESPRITE_MAX-1
|
||||||
|
|
||||||
if (bit.band(orientation, 2048) ~= 2048) then -- ROTATESPRITE_FULL16
|
if (bit.band(orientation, 2048) == 0) then -- ROTATESPRITE_FULL16
|
||||||
x = 65536*x
|
x = 65536*x
|
||||||
y = 65536*y
|
y = 65536*y
|
||||||
end
|
end
|
||||||
|
|
||||||
-- XXX: This is the same as the check in gameexec.c, but ideally we'd want
|
-- XXX: This is the same as the check in gameexec.c, but ideally we'd want
|
||||||
-- rotatesprite to accept all coordinates and simply draw nothing if they
|
-- rotatesprite to accept all coordinates and simply draw nothing if the
|
||||||
-- denote an area beyond the screen.
|
-- tile's bounding rectange is beyond the screen.
|
||||||
|
-- XXX: Currently, classic rotatesprite() is not correct with some large
|
||||||
|
-- zoom values.
|
||||||
if (not (x >= -320*65536 and x < 640*65536) or not (y >= -200*65536 and y < 400*65536)) then
|
if (not (x >= -320*65536 and x < 640*65536) or not (y >= -200*65536 and y < 400*65536)) then
|
||||||
error(format("invalid coordinates (%.03f, %.03f)", x, y), 2)
|
error(format("invalid coordinates (%.03f, %.03f)", x, y), 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: check that it works correctly with all coordinates, also if one
|
|
||||||
-- border is outside the screen etc...
|
|
||||||
ffiC.rotatesprite_(x, y, zoom, ang, tilenum, shade, pal, bit.bor(2,orientation),
|
ffiC.rotatesprite_(x, y, zoom, ang, tilenum, shade, pal, bit.bor(2,orientation),
|
||||||
alpha, cx1, cy1, cx2, cy2)
|
alpha, cx1, cy1, cx2, cy2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- The external legacy tile drawing function for Lunatic.
|
||||||
|
function rotatesprite(x, y, zoom, ang, tilenum, shade, pal, orientation,
|
||||||
|
alpha, cx1, cy1, cx2, cy2)
|
||||||
|
-- Disallow <<16 coordinates from Lunatic. They only unnecessarily increase
|
||||||
|
-- complexity; you already have more precision in the FP number fraction.
|
||||||
|
if (bit.band(orientation, 2048) ~= 0) then
|
||||||
|
error('left-shift-by-16 coordinates forbidden', 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
return _rotspr(x, y, zoom, ang, tilenum, shade, pal, orientation,
|
||||||
|
alpha, cx1, cy1, cx2, cy2)
|
||||||
|
end
|
||||||
|
|
||||||
function _myos(x, y, zoom, tilenum, shade, orientation, pal)
|
function _myos(x, y, zoom, tilenum, shade, orientation, pal)
|
||||||
if (pal==nil) then
|
if (pal==nil) then
|
||||||
local sect = player[ffiC.screenpeek].cursectnum
|
local sect = player[ffiC.screenpeek].cursectnum
|
||||||
|
|
|
@ -1745,15 +1745,15 @@ local handle =
|
||||||
end,
|
end,
|
||||||
|
|
||||||
rotatesprite = function(...)
|
rotatesprite = function(...)
|
||||||
return format("_con.rotatesprite(%s,%s,%s,%s,%s,%s,%s,%s,0,%s,%s,%s,%s)", ...)
|
return format("_con._rotspr(%s,%s,%s,%s,%s,%s,%s,%s,0,%s,%s,%s,%s)", ...)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
rotatesprite16 = function(...) -- (orientation|ROTATESPRITE_FULL16)
|
rotatesprite16 = function(...) -- (orientation|ROTATESPRITE_FULL16)
|
||||||
return format("_con.rotatesprite(%s,%s,%s,%s,%s,%s,%s,_bor(%s,2048),0,%s,%s,%s,%s)", ...)
|
return format("_con._rotspr(%s,%s,%s,%s,%s,%s,%s,_bor(%s,2048),0,%s,%s,%s,%s)", ...)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
rotatespritea = function(...)
|
rotatespritea = function(...)
|
||||||
return format("_con.rotatesprite(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", ...)
|
return format("_con._rotspr(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", ...)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- readgamevar or savegamevar
|
-- readgamevar or savegamevar
|
||||||
|
|
Loading…
Reference in a new issue