Lunatic: definesound, more control.lua fixes.

git-svn-id: https://svn.eduke32.com/eduke32@3355 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-01-01 15:24:22 +00:00
parent fd390efe2a
commit 311967f425
7 changed files with 62 additions and 25 deletions

View file

@ -2052,6 +2052,7 @@ static void C_Include(const char *confile)
Bfree(mptr); Bfree(mptr);
} }
#endif // !defined LUNATIC_ONLY
#ifdef _WIN32 #ifdef _WIN32
static void check_filename_case(const char *fn) static void check_filename_case(const char *fn)
@ -2064,8 +2065,6 @@ static void check_filename_case(const char *fn)
static void check_filename_case(const char *fn) { UNREFERENCED_PARAMETER(fn); } static void check_filename_case(const char *fn) { UNREFERENCED_PARAMETER(fn); }
#endif #endif
#endif // !defined LUNATIC_ONLY
void G_DoGameStartup(const int32_t *params) void G_DoGameStartup(const int32_t *params)
{ {
int32_t j = 0; int32_t j = 0;
@ -2107,6 +2106,30 @@ void G_DoGameStartup(const int32_t *params)
} }
} }
#ifdef LUNATIC
void C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5])
{
Bassert((unsigned)sndidx < MAXSOUNDS);
{
sound_t *const snd = &g_sounds[sndidx];
Bfree(snd->filename);
snd->filename = dup_filename(fn);
check_filename_case(snd->filename);
snd->ps = args[0];
snd->pe = args[1];
snd->pr = args[2];
snd->m = args[3];
snd->vo = args[4];
if (sndidx > g_maxSoundPos)
g_maxSoundPos = sndidx;
}
}
#endif
#if !defined LUNATIC_ONLY #if !defined LUNATIC_ONLY
static int32_t C_ParseCommand(int32_t loop) static int32_t C_ParseCommand(int32_t loop)
{ {

View file

@ -105,7 +105,7 @@ int32_t __fastcall Gv_GetVarX(register int32_t id);
void __fastcall Gv_SetVarX(register int32_t id,register int32_t lValue); void __fastcall Gv_SetVarX(register int32_t id,register int32_t lValue);
#ifdef LUNATIC_ONLY #ifdef LUNATIC_ONLY
# define Gv_GetVarByLabel(szGameLabel, lDefault, iActor, iPlayer) (-1) # define Gv_GetVarByLabel(szGameLabel, lDefault, iActor, iPlayer) (lDefault)
#else #else
int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor,int32_t iPlayer); int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor,int32_t iPlayer);
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags); int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);

View file

@ -21,6 +21,7 @@ local inside = dc.inside
local sector, wall, sprite = dc.sector, dc.wall, dc.sprite local sector, wall, sprite = dc.sector, dc.wall, dc.sprite
local spritesofsect = dc.spritesofsect local spritesofsect = dc.spritesofsect
module(...) module(...)
@ -161,12 +162,12 @@ function insertsprite(tab_or_tilenum, ...)
tilenum, pos, sectnum = unpack(tab, 1, 3) tilenum, pos, sectnum = unpack(tab, 1, 3)
owner = tab[4] or tab.owner or -1 owner = tab[4] or tab.owner or -1
statnum = tab[5] or tab.statnum or 0 statnum = tab[5] or tab.statnum or 0
shade = shade and tab.shade shade = tab.shade or shade
xrepeat = xrepeat and tab.xrepeat xrepeat = tab.xrepeat or xrepeat
yrepeat = yrepeat and tab.yrepeat yrepeat = tab.yrepeat or yrepeat
ang = ang and (tab.ang % 2048) ang = tab.ang or ang
xvel = xvel and tab.xvel xvel = tab.xvel or xvel
zvel = zvel and tab.zvel zvel = tab.zvel or zvel
else else
tilenum = tab_or_tilenum tilenum = tab_or_tilenum
local args = {...} local args = {...}
@ -311,7 +312,7 @@ function _A_DoGuts(i, gutstile, n)
local smallguts = spr.xrepeat < 16 and spr:isenemy() local smallguts = spr.xrepeat < 16 and spr:isenemy()
local xsz = smallguts and 8 or 32 local xsz = smallguts and 8 or 32
local ysz = xsz local ysz = xsz
local z = math.min(spr, sector[spr.sectnum]:floorzat(spr)) - 8*256 local z = math.min(spr.z, sector[spr.sectnum]:floorzat(spr)) - 8*256
if (spr.picnum == D.COMMANDER) then if (spr.picnum == D.COMMANDER) then
z = z - (24*256) z = z - (24*256)
@ -346,7 +347,7 @@ function _debris(i, dtile, n)
shade=spr.shade, xrepeat=32+krandand(15), yrepeat=32+krandand(15), shade=spr.shade, xrepeat=32+krandand(15), yrepeat=32+krandand(15),
ang=krandand(2047), xvel=32+krandand(127), zvel=-krandand(2047) } ang=krandand(2047), xvel=32+krandand(127), zvel=-krandand(2047) }
-- NOTE: BlimpSpawnSprites[14] (its array size if 15) will never be chosen -- NOTE: BlimpSpawnSprites[14] (its array size if 15) will never be chosen
sprite[jj].yvel = isblimpscrap and ffiC.BlimpSpawnSprites[math.mod(jj, 14)] or -1 sprite[jj]:set_yvel(isblimpscrap and ffiC.BlimpSpawnSprites[math.mod(jj, 14)] or -1)
sprite[jj].pal = spr.pal sprite[jj].pal = spr.pal
end end
end end
@ -498,7 +499,7 @@ function _testkey(pli, synckey)
if (synckey >= 32ULL) then if (synckey >= 32ULL) then
error("Invalid argument #2 to _testkey: must be in [0..31]", 2) error("Invalid argument #2 to _testkey: must be in [0..31]", 2)
end end
local bits = ffiC.player[pli].sync.bits local bits = ffiC.g_player[pli].sync.bits
return (bit.band(bits, bit.lshift(1,synckey)) ~= 0) return (bit.band(bits, bit.lshift(1,synckey)) ~= 0)
end end
@ -568,7 +569,7 @@ local BANG2RAD = math.pi/1024
local function cossinb(bang) local function cossinb(bang)
-- XXX: better use the precalc'd arrays instead? -- XXX: better use the precalc'd arrays instead?
local ang = BANG2RAD*(bang) local ang = BANG2RAD*bang
return 16384*math.cos(ang), 16384*math.sin(ang) return 16384*math.cos(ang), 16384*math.sin(ang)
end end
@ -681,7 +682,7 @@ function _canshoottarget(dist, aci)
for i=1,3 do for i=1,3 do
if (i > 1) then if (i > 1) then
hitspr, hitdist = A_CheckHitSprite(aci, angdifs[i]) hitspr, hitdist = A_CheckHitSprite(spr, angdifs[i])
end end
if (hitspr >= 0 and sprite[hitspr].picnum == spr.picnum) then if (hitspr >= 0 and sprite[hitspr].picnum == spr.picnum) then

View file

@ -484,6 +484,7 @@ int32_t kread(int32_t handle, void *buffer, int32_t leng);
const char *G_ConFile(void); const char *G_ConFile(void);
void G_DoGameStartup(const int32_t *params); void G_DoGameStartup(const int32_t *params);
int32_t C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5]);
]] ]]

View file

@ -256,11 +256,11 @@ ivec3_ = ffi.metatype("vec3_t", ivec3_mt)
local sectortype_mt = { local sectortype_mt = {
__index = { __index = {
ceilingzat = function(s, pos) ceilingzat = function(s, pos)
return ffiC.getceilzofslope(s, pos.x, pos.y) return ffiC.getceilzofslopeptr(s, pos.x, pos.y)
end, end,
floorzat = function(s, pos) floorzat = function(s, pos)
return ffiC.getflorzofslope(s, pos.x, pos.y) return ffiC.getflorzofslopeptr(s, pos.x, pos.y)
end, end,
} }
} }
@ -300,7 +300,12 @@ spritetype_mt = {
error("attempt to set invalid picnum "..tilenum, 2) error("attempt to set invalid picnum "..tilenum, 2)
end end
ffi.cast(spritetype_ptr_ct, s).picnum = tilenum ffi.cast(spritetype_ptr_ct, s).picnum = tilenum
end end,
set_yvel = function(s, yvel)
-- XXX: for now, no checking
ffi.cast(spritetype_ptr_ct, s).yvel = yvel
end,
}, },
} }
-- The user of this module can insert additional "spritetype" metamethods and -- The user of this module can insert additional "spritetype" metamethods and

View file

@ -65,6 +65,7 @@ kread;
G_ConFile; G_ConFile;
G_DoGameStartup; G_DoGameStartup;
C_DefineSound;
actor; actor;
ud; ud;

View file

@ -24,9 +24,13 @@ local unpack = unpack
-- non-nil if running from EDuke32 -- non-nil if running from EDuke32
-- (read_into_string~=nil iff string.dump==nil) -- (read_into_string~=nil iff string.dump==nil)
local read_into_string = read_into_string local read_into_string = read_into_string
local ffi, ffiC
if (string.dump) then if (string.dump) then
require("strict") require("strict")
else
ffi = require("ffi")
ffiC = ffi.C
end end
@ -511,12 +515,9 @@ local function cmd_gamestartup(...)
return return
end end
if (string.dump == nil) then if (ffi) then
-- running from EDuke32 -- running from EDuke32
local ffi = require("ffi") if (#args == 30) then
local ffiC = ffi.C
if (args == 30) then
ffiC.g_scriptVersion = 14 ffiC.g_scriptVersion = 14
end end
local params = ffi.new("int32_t [30]", args) local params = ffi.new("int32_t [30]", args)
@ -527,12 +528,17 @@ local function cmd_gamestartup(...)
end end
local function cmd_definesound(sndnum, fn, ...) local function cmd_definesound(sndnum, fn, ...)
if (sndnum < 0 or sndnum >= conl.MAXSOUNDS) then if (sndnum >= conl.MAXSOUNDS+0ULL) then
errprintf("sound number is or exceeds sound limit of %d", conl.MAXSOUNDS) errprintf("sound number is or exceeds sound limit of %d", conl.MAXSOUNDS)
return return
end end
local params = {...} -- TODO: sanity-check them local params = {...} -- TODO: sanity-check them
if (ffi) then
local cparams = ffi.new("int32_t [5]", params)
assert(type(fn)=="string")
ffiC.C_DefineSound(sndnum, fn, cparams)
end
g_data.sound[sndnum] = { fn=fn, params=params } g_data.sound[sndnum] = { fn=fn, params=params }
end end
@ -880,7 +886,7 @@ local Ci = {
spritepal = cmd(D), spritepal = cmd(D),
hitradius = cmd(D,D,D,D,D) hitradius = cmd(D,D,D,D,D)
/ "_con._A_RadiusDamage(%1,%2,%3,%4,%5)", / "_con._A_RadiusDamage(_aci,%1,%2,%3,%4,%5)",
hitradiusvar = cmd(R,R,R,R,R), hitradiusvar = cmd(R,R,R,R,R),
-- some commands taking read vars -- some commands taking read vars
@ -1230,7 +1236,7 @@ local Cif = {
ifinouterspace = cmd() ifinouterspace = cmd()
/ format("_con._checkspace(%s,true)", SPS".sectnum"), / format("_con._checkspace(%s,true)", SPS".sectnum"),
ifhitweapon = cmd() ifhitweapon = cmd()
/ "_con._A_IncurDamage(_aci)", / "_con._A_IncurDamage(_aci)>=0",
ifhitspace = cmd() ifhitspace = cmd()
/ "_con._testkey(_pli,29)", -- XXX / "_con._testkey(_pli,29)", -- XXX
ifdead = cmd() ifdead = cmd()