LunaCON: implement 'definegametype', allow writing userdef.level_number.

Also, allow (implicit) actor index -1 to 'sound' like in C-CON and fix
MULTIMODE gamevar definition (was 0, not 1).

git-svn-id: https://svn.eduke32.com/eduke32@3826 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-05-30 18:10:49 +00:00
parent 593b82692e
commit 640eda2194
5 changed files with 46 additions and 14 deletions

View file

@ -99,13 +99,14 @@ static struct { uint32_t keyw; uint32_t date; } g_keywdate[] =
#endif #endif
char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling
static char g_szCurrentBlockName[256] = "(none)", g_szLastBlockName[256] = "NULL";
int32_t g_totalLines,g_lineNumber; int32_t g_totalLines,g_lineNumber;
static int32_t g_checkingIfElse, g_processingState, g_lastKeyword = -1;
char g_szBuf[1024]; char g_szBuf[1024];
#if !defined LUNATIC #if !defined LUNATIC
static char g_szCurrentBlockName[256] = "(none)", g_szLastBlockName[256] = "NULL";
static int32_t g_checkingIfElse, g_processingState, g_lastKeyword = -1;
// The pointer to the start of the case table in a switch statement. // The pointer to the start of the case table in a switch statement.
// First entry is 'default' code. // First entry is 'default' code.
static intptr_t *g_caseScriptPtr=NULL; static intptr_t *g_caseScriptPtr=NULL;
@ -163,16 +164,18 @@ int32_t g_iPlayerVarID=-1;
int32_t g_iActorVarID=-1; int32_t g_iActorVarID=-1;
intptr_t *apScriptGameEvent[MAXGAMEEVENTS]; intptr_t *apScriptGameEvent[MAXGAMEEVENTS];
static intptr_t *g_parsingEventPtr=NULL;
#if !defined LUNATIC #if !defined LUNATIC
static intptr_t *g_parsingEventPtr=NULL;
gamevar_t aGameVars[MAXGAMEVARS]; gamevar_t aGameVars[MAXGAMEVARS];
gamearray_t aGameArrays[MAXGAMEARRAYS]; gamearray_t aGameArrays[MAXGAMEARRAYS];
int32_t g_gameVarCount=0; int32_t g_gameVarCount=0;
int32_t g_gameArrayCount=0; int32_t g_gameArrayCount=0;
#endif
static char *textptr; static char *textptr;
#endif
int32_t g_numCompilerErrors,g_numCompilerWarnings; int32_t g_numCompilerErrors,g_numCompilerWarnings;
extern int32_t g_maxSoundPos; extern int32_t g_maxSoundPos;
@ -2235,13 +2238,22 @@ void C_DefineLevelName(int32_t vol, int32_t lev, const char *fn,
void C_DefineGameFuncName(int32_t idx, const char *name) void C_DefineGameFuncName(int32_t idx, const char *name)
{ {
assert(idx < NUMGAMEFUNCTIONS); assert((unsigned)idx < NUMGAMEFUNCTIONS);
Bstrncpyz(gamefunctions[idx], name, MAXGAMEFUNCLEN); Bstrncpyz(gamefunctions[idx], name, MAXGAMEFUNCLEN);
Bstrncpyz(keydefaults[3*idx], name, MAXGAMEFUNCLEN); Bstrncpyz(keydefaults[3*idx], name, MAXGAMEFUNCLEN);
hash_add(&h_gamefuncs, gamefunctions[idx], idx, 0); hash_add(&h_gamefuncs, gamefunctions[idx], idx, 0);
} }
void C_DefineGameType(int32_t idx, int32_t flags, const char *name)
{
Bassert((unsigned)idx < MAXGAMETYPES);
GametypeFlags[idx] = flags;
Bstrncpyz(GametypeNames[idx], name, sizeof(GametypeNames[idx]));
g_numGametypes = idx+1;
}
#endif #endif
LUNATIC_EXTERN int32_t C_SetDefName(const char *name) LUNATIC_EXTERN int32_t C_SetDefName(const char *name)

View file

@ -13,6 +13,7 @@ module(...)
MAXVOLUMES = 7 MAXVOLUMES = 7
MAXLEVELS = 64 MAXLEVELS = 64
MAXGAMETYPES = 16
MAXSKILLS = 7 MAXSKILLS = 7
@ -840,7 +841,7 @@ local UserdefLabels = {
fta_on = UD".fta_on", fta_on = UD".fta_on",
god = UDRO".god", god = UDRO".god",
idplayers = UDRO".idplayers", idplayers = UDRO".idplayers",
level_number = UDRO".level_number", level_number = { UD".level_number", UD":set_level_number(%%s)" },
lockout = UDRO".lockout", lockout = UDRO".lockout",
pause_on = UDRO".pause_on", pause_on = UDRO".pause_on",
player_skill = UD".player_skill", player_skill = UD".player_skill",

View file

@ -1588,7 +1588,9 @@ local function S_StopSound(sndidx)
end end
function _soundplaying(aci, sndidx) function _soundplaying(aci, sndidx)
if (aci ~= -1) then
check_sprite_idx(aci) check_sprite_idx(aci)
end
check_sound_idx(sndidx) check_sound_idx(sndidx)
return (ffiC.S_CheckSoundPlaying(aci, sndidx) ~= 0) return (ffiC.S_CheckSoundPlaying(aci, sndidx) ~= 0)
end end
@ -1662,7 +1664,8 @@ function _setaspect(viewingrange, yxaspect)
end end
function _setgamepalette(pli, basepal) function _setgamepalette(pli, basepal)
ffiC.P_SetGamePalette(player[pli], basepal, 2+16) check_player_idx(pli)
ffiC.P_SetGamePalette(ffiC.g_player_ps[pli], basepal, 2+16)
end end
-- Map state persistence. -- Map state persistence.

View file

@ -670,6 +670,7 @@ void C_DefineLevelName(int32_t vol, int32_t lev, const char *fn,
const char *levelname); const char *levelname);
void C_DefineProjectile(int32_t j, int32_t what, int32_t val); void C_DefineProjectile(int32_t j, int32_t what, int32_t val);
void C_DefineGameFuncName(int32_t idx, const char *name); void C_DefineGameFuncName(int32_t idx, const char *name);
void C_DefineGameType(int32_t idx, int32_t flags, const char *name);
int32_t C_SetDefName(const char *name); int32_t C_SetDefName(const char *name);
int32_t SCRIPT_GetNumber(int32_t scripthandle, const char *sectionname, const char *entryname, int32_t *number); int32_t SCRIPT_GetNumber(int32_t scripthandle, const char *sectionname, const char *entryname, int32_t *number);
@ -792,6 +793,7 @@ function actor_static_members.delete(i)
error("Attempt to delete sprite in EVENT_EGS", 2) error("Attempt to delete sprite in EVENT_EGS", 2)
end end
-- TODO_MP
if (ffiC.g_player_ps[0].i == i) then if (ffiC.g_player_ps[0].i == i) then
error("Attempt to delete player 0's APLAYER sprite", 2) error("Attempt to delete player 0's APLAYER sprite", 2)
end end
@ -1173,12 +1175,15 @@ local user_defs_mt = {
end, end,
set_volume_number = function(ud, volume_number) set_volume_number = function(ud, volume_number)
-- XXX: should volume_number==MAXVOLUMES be allowed too? -- NOTE: volume_number==MAXVOLUMES disallowed.
if (volume_number >= con_lang.MAXVOLUMES+0ULL) then bcheck.volume_idx(volume_number)
error("invalid volume number "..volume_number, 2)
end
ud.volume_number = volume_number ud.volume_number = volume_number
end, end,
set_level_number = function(ud, level_number)
bcheck.level_idx(level_number)
ud.level_number = level_number
end,
}, },
} }
ffi.metatype("user_defs", user_defs_mt) ffi.metatype("user_defs", user_defs_mt)

View file

@ -580,7 +580,7 @@ local function reset_labels()
CLIPMASK1 = (256*65536)+64, -- hittable CLIPMASK1 = (256*65536)+64, -- hittable
-- TODO_MP -- TODO_MP
COOP = 0, COOP = 0,
MULTIMODE = 0, MULTIMODE = 1,
numplayers = 1, numplayers = 1,
myconnectindex = 0, myconnectindex = 0,
} }
@ -953,6 +953,17 @@ function Cmd.definegamefuncname(idx, name)
end end
end end
function Cmd.definegametype(idx, flags, name)
if (not (idx >= 0 and idx < conl.MAXGAMETYPES)) then
errprintf("gametype number exceeds maximum gametype count.")
return
end
if (ffi) then
ffiC.C_DefineGameType(idx, flags, name)
end
end
-- strip whitespace from front and back -- strip whitespace from front and back
local function stripws(str) local function stripws(str)
return str:match("^%s*(.*)%s*$") return str:match("^%s*(.*)%s*$")
@ -1382,7 +1393,7 @@ local Couter = {
definegamefuncname = sp1 * tok.define * newline_term_string -- XXX: TS? definegamefuncname = sp1 * tok.define * newline_term_string -- XXX: TS?
/ Cmd.definegamefuncname, / Cmd.definegamefuncname,
definegametype = n_defines(2) * newline_term_string definegametype = n_defines(2) * newline_term_string
/ Cmd.NYI("`definegametype'"), -- TODO_MP / Cmd.definegametype,
definelevelname = n_defines(2) * sp1 * tok.filename * sp1 * tok.time * sp1 * tok.time * definelevelname = n_defines(2) * sp1 * tok.filename * sp1 * tok.time * sp1 * tok.time *
newline_term_string newline_term_string
/ Cmd.definelevelname, / Cmd.definelevelname,