mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-02-04 12:50:57 +00:00
Lunatic: implement passing string label to 'spawn' OSD command.
Unlike in C-CON, it only tries an exact match with the given and uppercased label, not "full" case-insensitive search. git-svn-id: https://svn.eduke32.com/eduke32@4370 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
69d906c4f7
commit
55d6b9c5c7
3 changed files with 36 additions and 12 deletions
|
@ -614,6 +614,7 @@ char *g_elSavecode;
|
||||||
void El_FreeSaveCode(void);
|
void El_FreeSaveCode(void);
|
||||||
const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum);
|
const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum);
|
||||||
int32_t (*El_RestoreGamevars)(const char *savecode);
|
int32_t (*El_RestoreGamevars)(const char *savecode);
|
||||||
|
int32_t (*El_GetLabelValue)(const char *label);
|
||||||
|
|
||||||
const char *s_buildRev;
|
const char *s_buildRev;
|
||||||
const char *g_sizes_of_what[];
|
const char *g_sizes_of_what[];
|
||||||
|
@ -2517,7 +2518,7 @@ ffiC.El_RestoreGamevars = function(savecode)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Run the CON code translated into Lua.
|
-- Run the CON code translated into Lua.
|
||||||
if (concode) then
|
if (assert(concode ~= nil)) then
|
||||||
local confunc, conerrmsg = loadstring(concode, "CON")
|
local confunc, conerrmsg = loadstring(concode, "CON")
|
||||||
if (confunc == nil) then
|
if (confunc == nil) then
|
||||||
error("Failure loading translated CON code: "..conerrmsg, 0)
|
error("Failure loading translated CON code: "..conerrmsg, 0)
|
||||||
|
@ -2547,6 +2548,12 @@ if (concode) then
|
||||||
|
|
||||||
-- Propagate potentially remapped defines to the control module.
|
-- Propagate potentially remapped defines to the control module.
|
||||||
con._setuplabels(conlabels)
|
con._setuplabels(conlabels)
|
||||||
|
|
||||||
|
ffiC.El_GetLabelValue = function(label)
|
||||||
|
local str = ffi.string(label)
|
||||||
|
local val = conlabels[str] or conlabels[string.upper(str)]
|
||||||
|
return type(val)=="number" and val or bit.tobit(0x80000000)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- When starting a map, load Lua modules given on the command line.
|
-- When starting a map, load Lua modules given on the command line.
|
||||||
|
|
|
@ -114,6 +114,7 @@ g_elSavecode;
|
||||||
El_FreeSaveCode;
|
El_FreeSaveCode;
|
||||||
El_SerializeGamevars;
|
El_SerializeGamevars;
|
||||||
El_RestoreGamevars;
|
El_RestoreGamevars;
|
||||||
|
El_GetLabelValue;
|
||||||
|
|
||||||
s_buildRev;
|
s_buildRev;
|
||||||
g_sizes_of_what;
|
g_sizes_of_what;
|
||||||
|
|
|
@ -451,9 +451,15 @@ static int32_t osdcmd_vidmode(const osdfuncparm_t *parm)
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LUNATIC
|
||||||
|
// Returns: INT32_MIN if no such CON label, its value else.
|
||||||
|
LUNATIC_CB int32_t (*El_GetLabelValue)(const char *label);
|
||||||
|
#endif
|
||||||
|
|
||||||
static int32_t osdcmd_spawn(const osdfuncparm_t *parm)
|
static int32_t osdcmd_spawn(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
uint16_t cstat=0,picnum=0;
|
int32_t picnum = 0;
|
||||||
|
uint16_t cstat=0;
|
||||||
char pal=0;
|
char pal=0;
|
||||||
int16_t ang=0;
|
int16_t ang=0;
|
||||||
int16_t set=0, idx;
|
int16_t set=0, idx;
|
||||||
|
@ -484,26 +490,35 @@ static int32_t osdcmd_spawn(const osdfuncparm_t *parm)
|
||||||
case 1: // tile number
|
case 1: // tile number
|
||||||
if (isdigit(parm->parms[0][0]))
|
if (isdigit(parm->parms[0][0]))
|
||||||
{
|
{
|
||||||
picnum = (uint16_t)Batol(parm->parms[0]);
|
picnum = Batol(parm->parms[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int32_t i,j;
|
int32_t i;
|
||||||
|
#ifdef LUNATIC
|
||||||
|
i = g_numLabels;
|
||||||
|
picnum = El_GetLabelValue(parm->parms[0]);
|
||||||
|
if (picnum != INT32_MIN)
|
||||||
|
i = !i;
|
||||||
|
#else
|
||||||
|
int32_t j;
|
||||||
|
|
||||||
for (j=0; j<2; j++)
|
for (j=0; j<2; j++)
|
||||||
{
|
{
|
||||||
for (i=0; i<g_numLabels; i++)
|
for (i=0; i<g_numLabels; i++)
|
||||||
{
|
{
|
||||||
if (
|
if ((j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) ||
|
||||||
(j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) ||
|
(j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0])))
|
||||||
(j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
picnum = (uint16_t)labelcode[i];
|
picnum = labelcode[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i<g_numLabels) break;
|
|
||||||
|
if (i < g_numLabels)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (i==g_numLabels)
|
if (i==g_numLabels)
|
||||||
{
|
{
|
||||||
OSD_Printf("spawn: Invalid tile label given\n");
|
OSD_Printf("spawn: Invalid tile label given\n");
|
||||||
|
@ -511,17 +526,18 @@ static int32_t osdcmd_spawn(const osdfuncparm_t *parm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (picnum >= MAXTILES)
|
if ((uint32_t)picnum >= MAXUSERTILES)
|
||||||
{
|
{
|
||||||
OSD_Printf("spawn: Invalid tile number\n");
|
OSD_Printf("spawn: Invalid tile number\n");
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return OSDCMD_SHOWHELP;
|
return OSDCMD_SHOWHELP;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = A_Spawn(g_player[myconnectindex].ps->i, (int16_t)picnum);
|
idx = A_Spawn(g_player[myconnectindex].ps->i, picnum);
|
||||||
if (set & 1) sprite[idx].pal = (uint8_t)pal;
|
if (set & 1) sprite[idx].pal = (uint8_t)pal;
|
||||||
if (set & 2) sprite[idx].cstat = (int16_t)cstat;
|
if (set & 2) sprite[idx].cstat = (int16_t)cstat;
|
||||||
if (set & 4) sprite[idx].ang = ang;
|
if (set & 4) sprite[idx].ang = ang;
|
||||||
|
|
Loading…
Reference in a new issue