mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Direct access for the actor structs
git-svn-id: https://svn.eduke32.com/eduke32@7198 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
34c6fcc69f
commit
893bcbd603
5 changed files with 302 additions and 208 deletions
|
@ -859,70 +859,71 @@ const memberlabel_t WallLabels[]=
|
|||
|
||||
const memberlabel_t ActorLabels[]=
|
||||
{
|
||||
{ "x", ACTOR_X, 0, 0, -1 },
|
||||
{ "y", ACTOR_Y, 0, 0, -1 },
|
||||
{ "z", ACTOR_Z, 0, 0, -1 },
|
||||
{ "cstat", ACTOR_CSTAT, 0, 0, -1 },
|
||||
{ "picnum", ACTOR_PICNUM, 0, 0, -1 },
|
||||
{ "shade", ACTOR_SHADE, 0, 0, -1 },
|
||||
{ "pal", ACTOR_PAL, 0, 0, -1 },
|
||||
{ "clipdist", ACTOR_CLIPDIST, 0, 0, -1 },
|
||||
// { "filler", ACTOR_DETAIL, 0, 0, -1 },
|
||||
{ "blend", ACTOR_DETAIL, 0, 0, -1 },
|
||||
{ "xrepeat", ACTOR_XREPEAT, 0, 0, -1 },
|
||||
{ "yrepeat", ACTOR_YREPEAT, 0, 0, -1 },
|
||||
{ "xoffset", ACTOR_XOFFSET, 0, 0, -1 },
|
||||
{ "yoffset", ACTOR_YOFFSET, 0, 0, -1 },
|
||||
{ "sectnum", ACTOR_SECTNUM, 0, 0, -1 },
|
||||
{ "statnum", ACTOR_STATNUM, 0, 0, -1 },
|
||||
{ "ang", ACTOR_ANG, 0, 0, -1 },
|
||||
{ "owner", ACTOR_OWNER, 0, 0, -1 },
|
||||
{ "xvel", ACTOR_XVEL, 0, 0, -1 },
|
||||
{ "yvel", ACTOR_YVEL, 0, 0, -1 },
|
||||
{ "zvel", ACTOR_ZVEL, 0, 0, -1 },
|
||||
{ "lotag", ACTOR_LOTAG, 0, 0, -1 },
|
||||
{ "hitag", ACTOR_HITAG, 0, 0, -1 },
|
||||
{ "extra", ACTOR_EXTRA, 0, 0, -1 },
|
||||
LABEL_SETUP(sprite, x, ACTOR_X),
|
||||
LABEL_SETUP(sprite, y, ACTOR_Y),
|
||||
LABEL_SETUP(sprite, z, ACTOR_Z),
|
||||
LABEL_SETUP(sprite, cstat, ACTOR_CSTAT),
|
||||
LABEL_SETUP(sprite, picnum, ACTOR_PICNUM),
|
||||
LABEL_SETUP(sprite, shade, ACTOR_SHADE),
|
||||
LABEL_SETUP(sprite, pal, ACTOR_PAL),
|
||||
LABEL_SETUP(sprite, clipdist, ACTOR_CLIPDIST),
|
||||
LABEL_SETUP(sprite, blend, ACTOR_DETAIL),
|
||||
LABEL_SETUP(sprite, xrepeat, ACTOR_XREPEAT),
|
||||
LABEL_SETUP(sprite, yrepeat, ACTOR_YREPEAT),
|
||||
LABEL_SETUP(sprite, xoffset, ACTOR_XOFFSET),
|
||||
LABEL_SETUP(sprite, yoffset, ACTOR_YOFFSET),
|
||||
{ "sectnum", ACTOR_SECTNUM, sizeof(sprite[0].sectnum) | LABEL_WRITEFUNC, 0, offsetof(uspritetype, sectnum) },
|
||||
{ "statnum", ACTOR_STATNUM, sizeof(sprite[0].statnum) | LABEL_WRITEFUNC, 0, offsetof(uspritetype, statnum) },
|
||||
LABEL_SETUP(sprite, ang, ACTOR_ANG),
|
||||
LABEL_SETUP(sprite, owner, ACTOR_OWNER),
|
||||
LABEL_SETUP(sprite, xvel, ACTOR_XVEL),
|
||||
LABEL_SETUP(sprite, yvel, ACTOR_YVEL),
|
||||
LABEL_SETUP(sprite, zvel, ACTOR_ZVEL),
|
||||
LABEL_SETUP(sprite, lotag, ACTOR_LOTAG),
|
||||
LABEL_SETUP(sprite, hitag, ACTOR_HITAG),
|
||||
LABEL_SETUP(sprite, extra, ACTOR_EXTRA),
|
||||
|
||||
{ "ulotag", ACTOR_ULOTAG, sizeof(sprite[0].lotag) | LABEL_UNSIGNED, 0, offsetof(uspritetype, lotag) },
|
||||
{ "uhitag", ACTOR_UHITAG, sizeof(sprite[0].hitag) | LABEL_UNSIGNED, 0, offsetof(uspritetype, hitag) },
|
||||
|
||||
// ActorExtra labels...
|
||||
{ "htcgg", ACTOR_HTCGG, 0, 0, -1 },
|
||||
{ "htpicnum", ACTOR_HTPICNUM, 0, 0, -1 },
|
||||
{ "htang", ACTOR_HTANG, 0, 0, -1 },
|
||||
{ "htextra", ACTOR_HTEXTRA, 0, 0, -1 },
|
||||
{ "htowner", ACTOR_HTOWNER, 0, 0, -1 },
|
||||
{ "htmovflag", ACTOR_HTMOVFLAG, 0, 0, -1 },
|
||||
{ "httempang", ACTOR_HTTEMPANG, 0, 0, -1 },
|
||||
{ "htactorstayput", ACTOR_HTSTAYPUT, 0, 0, -1 },
|
||||
{ "htdispicnum", ACTOR_HTDISPICNUM, 0, 0, -1 },
|
||||
{ "httimetosleep", ACTOR_HTTIMETOSLEEP, 0, 0, -1 },
|
||||
{ "htfloorz", ACTOR_HTFLOORZ, 0, 0, -1 },
|
||||
{ "htceilingz", ACTOR_HTCEILINGZ, 0, 0, -1 },
|
||||
{ "htlastvx", ACTOR_HTLASTVX, 0, 0, -1 },
|
||||
{ "htlastvy", ACTOR_HTLASTVY, 0, 0, -1 },
|
||||
{ "htbposx", ACTOR_HTBPOSX, 0, 0, -1 },
|
||||
{ "htbposy", ACTOR_HTBPOSY, 0, 0, -1 },
|
||||
{ "htbposz", ACTOR_HTBPOSZ, 0, 0, -1 },
|
||||
LABEL_SETUP_UNMATCHED(actor, cgg, "htcgg", ACTOR_HTCGG),
|
||||
LABEL_SETUP_UNMATCHED(actor, picnum, "htpicnum", ACTOR_HTPICNUM),
|
||||
LABEL_SETUP_UNMATCHED(actor, ang, "htang", ACTOR_HTANG),
|
||||
LABEL_SETUP_UNMATCHED(actor, extra, "htextra", ACTOR_HTEXTRA),
|
||||
LABEL_SETUP_UNMATCHED(actor, owner, "htowner", ACTOR_HTOWNER),
|
||||
LABEL_SETUP_UNMATCHED(actor, movflag, "htmovflag", ACTOR_HTMOVFLAG),
|
||||
LABEL_SETUP_UNMATCHED(actor, tempang, "httempang", ACTOR_HTTEMPANG),
|
||||
LABEL_SETUP_UNMATCHED(actor, stayput, "htactorstayput", ACTOR_HTSTAYPUT),
|
||||
LABEL_SETUP_UNMATCHED(actor, dispicnum, "htdispicnum", ACTOR_HTDISPICNUM),
|
||||
LABEL_SETUP_UNMATCHED(actor, timetosleep, "httimetosleep", ACTOR_HTTIMETOSLEEP),
|
||||
LABEL_SETUP_UNMATCHED(actor, floorz, "htfloorz", ACTOR_HTFLOORZ),
|
||||
LABEL_SETUP_UNMATCHED(actor, ceilingz, "htceilingz", ACTOR_HTCEILINGZ),
|
||||
LABEL_SETUP_UNMATCHED(actor, lastv.x, "htlastvx", ACTOR_HTLASTVX),
|
||||
LABEL_SETUP_UNMATCHED(actor, lastv.y, "htlastvy", ACTOR_HTLASTVY),
|
||||
LABEL_SETUP_UNMATCHED(actor, bpos.x, "htbposx", ACTOR_HTBPOSX),
|
||||
LABEL_SETUP_UNMATCHED(actor, bpos.y, "htbposy", ACTOR_HTBPOSY),
|
||||
LABEL_SETUP_UNMATCHED(actor, bpos.z, "htbposz", ACTOR_HTBPOSZ),
|
||||
|
||||
{ "htg_t", ACTOR_HTG_T, LABEL_HASPARM2, 10, -1 },
|
||||
LABEL_SETUP_UNMATCHED(actor, flags, "htflags", ACTOR_HTFLAGS),
|
||||
|
||||
// model flags
|
||||
|
||||
{ "angoff", ACTOR_ANGOFF, 0, 0, -1 },
|
||||
{ "pitch", ACTOR_PITCH, 0, 0, -1 },
|
||||
{ "roll", ACTOR_ROLL, 0, 0, -1 },
|
||||
{ "mdxoff", ACTOR_MDXOFF, 0, 0, -1 },
|
||||
{ "mdyoff", ACTOR_MDYOFF, 0, 0, -1 },
|
||||
{ "mdzoff", ACTOR_MDZOFF, 0, 0, -1 },
|
||||
{ "mdflags", ACTOR_MDFLAGS, 0, 0, -1 },
|
||||
{ "xpanning", ACTOR_XPANNING, 0, 0, -1 },
|
||||
{ "ypanning", ACTOR_YPANNING, 0, 0, -1 },
|
||||
LABEL_SETUP(spriteext, angoff, ACTOR_ANGOFF),
|
||||
LABEL_SETUP(spriteext, pitch, ACTOR_PITCH),
|
||||
LABEL_SETUP(spriteext, roll, ACTOR_ROLL),
|
||||
|
||||
{ "htflags", ACTOR_HTFLAGS, 0, 0, -1 },
|
||||
LABEL_SETUP_UNMATCHED(spriteext, offset.x, "mdxoff", ACTOR_MDXOFF),
|
||||
LABEL_SETUP_UNMATCHED(spriteext, offset.y, "mdyoff", ACTOR_MDYOFF),
|
||||
LABEL_SETUP_UNMATCHED(spriteext, offset.z, "mdzoff", ACTOR_MDZOFF),
|
||||
LABEL_SETUP_UNMATCHED(spriteext, flags, "mdflags", ACTOR_MDFLAGS),
|
||||
|
||||
LABEL_SETUP(spriteext, xpanning, ACTOR_XPANNING),
|
||||
LABEL_SETUP(spriteext, ypanning, ACTOR_YPANNING),
|
||||
|
||||
{ "alpha", ACTOR_ALPHA, 0, 0, -1 },
|
||||
|
||||
{ "ulotag", ACTOR_ULOTAG, 0, 0, -1 },
|
||||
{ "uhitag", ACTOR_UHITAG, 0, 0, -1 },
|
||||
|
||||
{ "isvalid", ACTOR_ISVALID, 0, 0, -1 },
|
||||
// aliases:
|
||||
{ "movflags", ACTOR_HITAG, 0, 0, -1 },
|
||||
|
@ -2001,10 +2002,25 @@ static void C_GetNextVarType(int32_t type)
|
|||
switch (id - g_structVarIDs)
|
||||
{
|
||||
case STRUCT_SPRITE:
|
||||
*g_scriptPtr++=ActorLabels[labelNum].lId;
|
||||
{
|
||||
auto const &label = ActorLabels[labelNum];
|
||||
*g_scriptPtr++ = label.lId;
|
||||
|
||||
Bassert((*varptr & (MAXGAMEVARS-1)) == g_structVarIDs + STRUCT_SPRITE);
|
||||
|
||||
if (label.flags & LABEL_HASPARM2)
|
||||
C_GetNextVarType(0);
|
||||
else if (label.offset != -1 && (label.flags & LABEL_READFUNC) == 0)
|
||||
{
|
||||
if (labelNum >= ACTOR_SPRITEEXT_BEGIN)
|
||||
*varptr = (*varptr & ~(MAXGAMEVARS-1)) + g_structVarIDs + STRUCT_SPRITEEXT_INTERNAL__;
|
||||
else if (labelNum >= ACTOR_STRUCT_BEGIN)
|
||||
*varptr = (*varptr & ~(MAXGAMEVARS-1)) + g_structVarIDs + STRUCT_ACTOR_INTERNAL__;
|
||||
else
|
||||
*varptr = (*varptr & ~(MAXGAMEVARS-1)) + g_structVarIDs + STRUCT_SPRITE_INTERNAL__;
|
||||
}
|
||||
}
|
||||
|
||||
if (ActorLabels[labelNum].flags & LABEL_HASPARM2)
|
||||
C_GetNextVarType(0);
|
||||
break;
|
||||
case STRUCT_SECTOR:
|
||||
*g_scriptPtr++=SectorLabels[labelNum].lId;
|
||||
|
@ -4080,20 +4096,66 @@ DO_DEFSTATE:
|
|||
}
|
||||
|
||||
case CON_SETACTOR:
|
||||
case CON_GETACTOR:
|
||||
{
|
||||
int32_t const labelNum = C_GetStructureIndexes(1, &h_actor);
|
||||
intptr_t * const ins = g_scriptPtr-1;
|
||||
int const labelNum = C_GetStructureIndexes(1, &h_actor);
|
||||
|
||||
if (labelNum == -1)
|
||||
continue;
|
||||
|
||||
BITPTR_CLEAR(g_scriptPtr-apScript);
|
||||
*g_scriptPtr++=ActorLabels[labelNum].lId;
|
||||
Bassert((*ins & VM_INSTMASK) == CON_SETACTOR);
|
||||
|
||||
if (ActorLabels[labelNum].flags & LABEL_HASPARM2)
|
||||
auto const &label = ActorLabels[labelNum];
|
||||
|
||||
if (label.offset != -1 && (label.flags & (LABEL_WRITEFUNC|LABEL_HASPARM2)) == 0)
|
||||
{
|
||||
if (labelNum >= ACTOR_SPRITEEXT_BEGIN)
|
||||
*ins = CON_SETSPRITEEXT;
|
||||
else if (labelNum >= ACTOR_STRUCT_BEGIN)
|
||||
*ins = CON_SETACTORSTRUCT;
|
||||
else
|
||||
*ins = CON_SETSPRITESTRUCT;
|
||||
}
|
||||
|
||||
BITPTR_CLEAR(g_scriptPtr-apScript);
|
||||
*g_scriptPtr++=label.lId;
|
||||
|
||||
if (label.flags & LABEL_HASPARM2)
|
||||
C_GetNextVar();
|
||||
|
||||
C_GetNextVarType((tw == CON_GETACTOR) ? GAMEVAR_READONLY : 0);
|
||||
C_GetNextVar();
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_GETACTOR:
|
||||
{
|
||||
intptr_t * const ins = g_scriptPtr-1;
|
||||
int const labelNum = C_GetStructureIndexes(1, &h_actor);
|
||||
|
||||
if (labelNum == -1)
|
||||
continue;
|
||||
|
||||
Bassert((*ins & VM_INSTMASK) == CON_GETACTOR);
|
||||
|
||||
auto const &label = ActorLabels[labelNum];
|
||||
|
||||
if (label.offset != -1 && (label.flags & (LABEL_READFUNC|LABEL_HASPARM2)) == 0)
|
||||
{
|
||||
if (labelNum >= ACTOR_SPRITEEXT_BEGIN)
|
||||
*ins = CON_GETSPRITEEXT;
|
||||
else if (labelNum >= ACTOR_STRUCT_BEGIN)
|
||||
*ins = CON_GETACTORSTRUCT;
|
||||
else
|
||||
*ins = CON_GETSPRITESTRUCT;
|
||||
}
|
||||
|
||||
BITPTR_CLEAR(g_scriptPtr-apScript);
|
||||
*g_scriptPtr++=label.lId;
|
||||
|
||||
if (label.flags & LABEL_HASPARM2)
|
||||
C_GetNextVar();
|
||||
|
||||
C_GetNextVarType(GAMEVAR_READONLY);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -6502,7 +6564,9 @@ void C_InitProjectiles(void)
|
|||
#if !defined LUNATIC
|
||||
static char const * C_ScriptVersionString(int32_t version)
|
||||
{
|
||||
#ifndef EDUKE32_STANDALONE
|
||||
#ifdef EDUKE32_STANDALONE
|
||||
UNREFERENCED_PARAMETER(version);
|
||||
#else
|
||||
switch (version)
|
||||
{
|
||||
case 9:
|
||||
|
|
|
@ -100,6 +100,9 @@ extern int32_t g_zRangeVarID; // var ID of "ZRANGE"
|
|||
enum QuickStructureAccess_t
|
||||
{
|
||||
STRUCT_SPRITE,
|
||||
STRUCT_SPRITE_INTERNAL__,
|
||||
STRUCT_ACTOR_INTERNAL__,
|
||||
STRUCT_SPRITEEXT_INTERNAL__,
|
||||
STRUCT_SECTOR,
|
||||
STRUCT_WALL,
|
||||
STRUCT_PLAYER,
|
||||
|
@ -693,7 +696,10 @@ enum ActorLabel_t
|
|||
ACTOR_LOTAG,
|
||||
ACTOR_HITAG,
|
||||
ACTOR_EXTRA,
|
||||
ACTOR_HTCGG,
|
||||
ACTOR_ULOTAG,
|
||||
ACTOR_UHITAG,
|
||||
ACTOR_STRUCT_BEGIN,
|
||||
ACTOR_HTCGG = ACTOR_STRUCT_BEGIN,
|
||||
ACTOR_HTPICNUM,
|
||||
ACTOR_HTANG,
|
||||
ACTOR_HTEXTRA,
|
||||
|
@ -711,7 +717,9 @@ enum ActorLabel_t
|
|||
ACTOR_HTBPOSY,
|
||||
ACTOR_HTBPOSZ,
|
||||
ACTOR_HTG_T,
|
||||
ACTOR_ANGOFF,
|
||||
ACTOR_HTFLAGS,
|
||||
ACTOR_SPRITEEXT_BEGIN,
|
||||
ACTOR_ANGOFF = ACTOR_SPRITEEXT_BEGIN,
|
||||
ACTOR_PITCH,
|
||||
ACTOR_ROLL,
|
||||
ACTOR_MDXOFF,
|
||||
|
@ -720,10 +728,7 @@ enum ActorLabel_t
|
|||
ACTOR_MDFLAGS,
|
||||
ACTOR_XPANNING,
|
||||
ACTOR_YPANNING,
|
||||
ACTOR_HTFLAGS,
|
||||
ACTOR_ALPHA,
|
||||
ACTOR_ULOTAG,
|
||||
ACTOR_UHITAG,
|
||||
ACTOR_ISVALID,
|
||||
ACTOR_END
|
||||
};
|
||||
|
@ -1254,6 +1259,12 @@ enum ScriptKeywords_t
|
|||
CON_SPAWNWALLSTAINEDGLASS, // 432
|
||||
CON_SPAWNCEILINGGLASS, // 433
|
||||
CON_SWAPARRAYS, // 434
|
||||
CON_GETACTORSTRUCT, // 435
|
||||
CON_SETACTORSTRUCT, // 436
|
||||
CON_GETSPRITEEXT, // 437
|
||||
CON_SETSPRITEEXT, // 438
|
||||
CON_GETSPRITESTRUCT, // 439
|
||||
CON_SETSPRITESTRUCT, // 440
|
||||
CON_END
|
||||
};
|
||||
// KEEPINSYNC with the keyword list in lunatic/con_lang.lua
|
||||
|
|
|
@ -4734,6 +4734,14 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
|
|||
int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum;
|
||||
int const labelNum = *insptr++;
|
||||
int const lParm2 = (ActorLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
|
||||
auto const &actorLabel = ActorLabels[labelNum];
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(((unsigned)spriteNum >= MAXSPRITES)
|
||||
|| (actorLabel.flags & LABEL_HASPARM2 && (unsigned)lParm2 >= (unsigned)actorLabel.maxParm2)))
|
||||
{
|
||||
CON_ERRPRINTF("%s[%d] invalid for sprite %d\n", actorLabel.name, lParm2, spriteNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
VM_SetSprite(spriteNum, labelNum, lParm2, Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
|
@ -4745,11 +4753,120 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
|
|||
int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum;
|
||||
int const labelNum = *insptr++;
|
||||
int const lParm2 = (ActorLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
|
||||
auto const &actorLabel = ActorLabels[labelNum];
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(((unsigned)spriteNum >= MAXSPRITES)
|
||||
|| (actorLabel.flags & LABEL_HASPARM2 && (unsigned)lParm2 >= (unsigned)actorLabel.maxParm2)))
|
||||
{
|
||||
CON_ERRPRINTF("%s[%d] invalid for sprite %d\n", actorLabel.name, lParm2, spriteNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
Gv_SetVarX(*insptr++, VM_GetSprite(spriteNum, labelNum, lParm2));
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_SETACTORSTRUCT:
|
||||
insptr++;
|
||||
{
|
||||
int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum;
|
||||
int const labelNum = *insptr++;
|
||||
auto const &actorLabel = ActorLabels[labelNum];
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
|
||||
{
|
||||
CON_ERRPRINTF("invalid sprite %d\n", spriteNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
VM_SetStruct(actorLabel.flags, (intptr_t *)((char *)&actor[spriteNum] + actorLabel.offset), Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_GETACTORSTRUCT:
|
||||
insptr++;
|
||||
{
|
||||
int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum;
|
||||
int const labelNum = *insptr++;
|
||||
auto const &actorLabel = ActorLabels[labelNum];
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
|
||||
{
|
||||
CON_ERRPRINTF("invalid sprite %d\n", spriteNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
Gv_SetVarX(*insptr++, VM_GetStruct(actorLabel.flags, (intptr_t *)((char *)&actor[spriteNum] + actorLabel.offset)));
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_SETSPRITESTRUCT:
|
||||
insptr++;
|
||||
{
|
||||
int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum;
|
||||
int const labelNum = *insptr++;
|
||||
auto const &spriteLabel = ActorLabels[labelNum];
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
|
||||
{
|
||||
CON_ERRPRINTF("invalid sprite %d\n", spriteNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
VM_SetStruct(spriteLabel.flags, (intptr_t *)((char *)&sprite[spriteNum] + spriteLabel.offset), Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_GETSPRITESTRUCT:
|
||||
insptr++;
|
||||
{
|
||||
int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum;
|
||||
int const labelNum = *insptr++;
|
||||
auto const &spriteLabel = ActorLabels[labelNum];
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
|
||||
{
|
||||
CON_ERRPRINTF("invalid sprite %d\n", spriteNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
Gv_SetVarX(*insptr++, VM_GetStruct(spriteLabel.flags, (intptr_t *)((char *)&sprite[spriteNum] + spriteLabel.offset)));
|
||||
continue;
|
||||
}
|
||||
case CON_SETSPRITEEXT:
|
||||
insptr++;
|
||||
{
|
||||
int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum;
|
||||
int const labelNum = *insptr++;
|
||||
auto const &spriteExtLabel = ActorLabels[labelNum];
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
|
||||
{
|
||||
CON_ERRPRINTF("invalid sprite %d\n", spriteNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
VM_SetStruct(spriteExtLabel.flags, (intptr_t *)((char *)&spriteext[spriteNum] + spriteExtLabel.offset), Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_GETSPRITEEXT:
|
||||
insptr++;
|
||||
{
|
||||
int const spriteNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : vm.spriteNum;
|
||||
int const labelNum = *insptr++;
|
||||
auto const &spriteExtLabel = ActorLabels[labelNum];
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
|
||||
{
|
||||
CON_ERRPRINTF("invalid sprite %d\n", spriteNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
Gv_SetVarX(*insptr++, VM_GetStruct(spriteExtLabel.flags, (intptr_t *)((char *)&spriteext[spriteNum] + spriteExtLabel.offset)));
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_SETTSPR:
|
||||
insptr++;
|
||||
{
|
||||
|
|
|
@ -1095,80 +1095,15 @@ void __fastcall VM_SetSector(int const sectNum, int const labelNum, int32_t newV
|
|||
|
||||
void __fastcall VM_SetSprite(int const spriteNum, int const labelNum, int const lParm2, int32_t const newValue)
|
||||
{
|
||||
if (EDUKE32_PREDICT_FALSE(((unsigned)spriteNum >= MAXSPRITES) ||
|
||||
(ActorLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned)lParm2 >= (unsigned)ActorLabels[labelNum].maxParm2)))
|
||||
{
|
||||
CON_ERRPRINTF("%s[%d] invalid for sprite %d\n", ActorLabels[labelNum].name, lParm2, spriteNum);
|
||||
return;
|
||||
}
|
||||
|
||||
auto &s = sprite[spriteNum];
|
||||
auto &a = actor[spriteNum];
|
||||
auto &ext = spriteext[spriteNum];
|
||||
|
||||
switch (labelNum)
|
||||
{
|
||||
case ACTOR_X: s.x = newValue; break;
|
||||
case ACTOR_Y: s.y = newValue; break;
|
||||
case ACTOR_Z: s.z = newValue; break;
|
||||
case ACTOR_CSTAT: s.cstat = newValue; break;
|
||||
case ACTOR_PICNUM: s.picnum = newValue; break;
|
||||
case ACTOR_SHADE: s.shade = newValue; break;
|
||||
case ACTOR_PAL: s.pal = newValue; break;
|
||||
case ACTOR_CLIPDIST: s.clipdist = newValue; break;
|
||||
case ACTOR_DETAIL: s.blend = newValue; break;
|
||||
case ACTOR_XREPEAT: s.xrepeat = newValue; break;
|
||||
case ACTOR_YREPEAT: s.yrepeat = newValue; break;
|
||||
case ACTOR_XOFFSET: s.xoffset = newValue; break;
|
||||
case ACTOR_YOFFSET: s.yoffset = newValue; break;
|
||||
case ACTOR_ANG: s.ang = newValue; break;
|
||||
case ACTOR_OWNER: s.owner = newValue; break;
|
||||
case ACTOR_XVEL: s.xvel = newValue; break;
|
||||
case ACTOR_YVEL: s.yvel = newValue; break;
|
||||
case ACTOR_ZVEL: s.zvel = newValue; break;
|
||||
case ACTOR_EXTRA: s.extra = newValue; break;
|
||||
|
||||
case ACTOR_LOTAG: s.lotag = (int16_t)newValue; break;
|
||||
case ACTOR_HITAG: s.hitag = (int16_t)newValue; break;
|
||||
case ACTOR_ULOTAG: s.lotag = (uint16_t)newValue; break;
|
||||
case ACTOR_UHITAG: s.hitag = (uint16_t)newValue; break;
|
||||
|
||||
case ACTOR_SECTNUM: changespritesect(spriteNum, newValue); break;
|
||||
case ACTOR_STATNUM: changespritestat(spriteNum, newValue); break;
|
||||
|
||||
case ACTOR_HTCGG: a.cgg = newValue; break;
|
||||
case ACTOR_HTPICNUM: a.picnum = newValue; break;
|
||||
case ACTOR_HTANG: a.ang = newValue; break;
|
||||
case ACTOR_HTEXTRA: a.extra = newValue; break;
|
||||
case ACTOR_HTOWNER: a.owner = newValue; break;
|
||||
case ACTOR_HTMOVFLAG: a.movflag = newValue; break;
|
||||
case ACTOR_HTTEMPANG: a.tempang = newValue; break;
|
||||
case ACTOR_HTSTAYPUT: a.stayput = newValue; break;
|
||||
case ACTOR_HTDISPICNUM: a.dispicnum = newValue; break;
|
||||
case ACTOR_HTTIMETOSLEEP: a.timetosleep = newValue; break;
|
||||
case ACTOR_HTFLOORZ: a.floorz = newValue; break;
|
||||
case ACTOR_HTCEILINGZ: a.ceilingz = newValue; break;
|
||||
case ACTOR_HTLASTVX: a.lastv.x = newValue; break;
|
||||
case ACTOR_HTLASTVY: a.lastv.y = newValue; break;
|
||||
case ACTOR_HTBPOSX: a.bpos.x = newValue; break;
|
||||
case ACTOR_HTBPOSY: a.bpos.y = newValue; break;
|
||||
case ACTOR_HTBPOSZ: a.bpos.z = newValue; break;
|
||||
case ACTOR_HTFLAGS: a.flags = newValue; break;
|
||||
|
||||
case ACTOR_HTG_T: a.t_data[lParm2] = newValue; break;
|
||||
|
||||
case ACTOR_ANGOFF: ext.angoff = newValue; break;
|
||||
case ACTOR_PITCH: ext.pitch = newValue; break;
|
||||
case ACTOR_ROLL: ext.roll = newValue; break;
|
||||
case ACTOR_MDXOFF: ext.offset.x = newValue; break;
|
||||
case ACTOR_MDYOFF: ext.offset.y = newValue; break;
|
||||
case ACTOR_MDZOFF: ext.offset.z = newValue; break;
|
||||
case ACTOR_MDFLAGS: ext.flags = newValue; break;
|
||||
case ACTOR_XPANNING: ext.xpanning = newValue; break;
|
||||
case ACTOR_YPANNING: ext.ypanning = newValue; break;
|
||||
|
||||
case ACTOR_ALPHA: ext.alpha = (float)newValue * (1.f / 255.0f); break;
|
||||
|
||||
default: EDUKE32_UNREACHABLE_SECTION(break);
|
||||
}
|
||||
}
|
||||
|
@ -1176,80 +1111,15 @@ void __fastcall VM_SetSprite(int const spriteNum, int const labelNum, int const
|
|||
|
||||
int32_t __fastcall VM_GetSprite(int const spriteNum, int32_t labelNum, int const lParm2)
|
||||
{
|
||||
if (EDUKE32_PREDICT_FALSE(((unsigned) spriteNum >= MAXSPRITES) ||
|
||||
(ActorLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned) lParm2 >= (unsigned) ActorLabels[labelNum].maxParm2)))
|
||||
{
|
||||
CON_ERRPRINTF("%s[%d] invalid for sprite %d\n", ActorLabels[labelNum].name, lParm2, spriteNum);
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto const &s = sprite[spriteNum];
|
||||
auto const &a = actor[spriteNum];
|
||||
auto const &s = sprite[spriteNum];
|
||||
auto const &ext = spriteext[spriteNum];
|
||||
|
||||
switch (labelNum)
|
||||
{
|
||||
case ACTOR_X: labelNum = s.x; break;
|
||||
case ACTOR_Y: labelNum = s.y; break;
|
||||
case ACTOR_Z: labelNum = s.z; break;
|
||||
case ACTOR_CSTAT: labelNum = s.cstat; break;
|
||||
case ACTOR_PICNUM: labelNum = s.picnum; break;
|
||||
case ACTOR_SHADE: labelNum = s.shade; break;
|
||||
case ACTOR_PAL: labelNum = s.pal; break;
|
||||
case ACTOR_CLIPDIST: labelNum = s.clipdist; break;
|
||||
case ACTOR_DETAIL: labelNum = s.blend; break;
|
||||
case ACTOR_XREPEAT: labelNum = s.xrepeat; break;
|
||||
case ACTOR_YREPEAT: labelNum = s.yrepeat; break;
|
||||
case ACTOR_XOFFSET: labelNum = s.xoffset; break;
|
||||
case ACTOR_YOFFSET: labelNum = s.yoffset; break;
|
||||
case ACTOR_SECTNUM: labelNum = s.sectnum; break;
|
||||
case ACTOR_STATNUM: labelNum = s.statnum; break;
|
||||
case ACTOR_ANG: labelNum = s.ang; break;
|
||||
case ACTOR_OWNER: labelNum = s.owner; break;
|
||||
case ACTOR_XVEL: labelNum = s.xvel; break;
|
||||
case ACTOR_YVEL: labelNum = s.yvel; break;
|
||||
case ACTOR_ZVEL: labelNum = s.zvel; break;
|
||||
case ACTOR_EXTRA: labelNum = s.extra; break;
|
||||
|
||||
case ACTOR_LOTAG: labelNum = (int16_t)s.lotag; break;
|
||||
case ACTOR_HITAG: labelNum = (int16_t)s.hitag; break;
|
||||
case ACTOR_ULOTAG: labelNum = (uint16_t)s.lotag; break;
|
||||
case ACTOR_UHITAG: labelNum = (uint16_t)s.hitag; break;
|
||||
|
||||
case ACTOR_HTCGG: labelNum = a.cgg; break;
|
||||
case ACTOR_HTPICNUM: labelNum = a.picnum; break;
|
||||
case ACTOR_HTANG: labelNum = a.ang; break;
|
||||
case ACTOR_HTEXTRA: labelNum = a.extra; break;
|
||||
case ACTOR_HTOWNER: labelNum = a.owner; break;
|
||||
case ACTOR_HTMOVFLAG: labelNum = a.movflag; break;
|
||||
case ACTOR_HTTEMPANG: labelNum = a.tempang; break;
|
||||
case ACTOR_HTSTAYPUT: labelNum = a.stayput; break;
|
||||
case ACTOR_HTDISPICNUM: labelNum = a.dispicnum; break;
|
||||
case ACTOR_HTTIMETOSLEEP: labelNum = a.timetosleep; break;
|
||||
case ACTOR_HTFLOORZ: labelNum = a.floorz; break;
|
||||
case ACTOR_HTCEILINGZ: labelNum = a.ceilingz; break;
|
||||
case ACTOR_HTLASTVX: labelNum = a.lastv.x; break;
|
||||
case ACTOR_HTLASTVY: labelNum = a.lastv.y; break;
|
||||
case ACTOR_HTBPOSX: labelNum = a.bpos.x; break;
|
||||
case ACTOR_HTBPOSY: labelNum = a.bpos.y; break;
|
||||
case ACTOR_HTBPOSZ: labelNum = a.bpos.z; break;
|
||||
case ACTOR_HTFLAGS: labelNum = a.flags; break;
|
||||
|
||||
case ACTOR_HTG_T: labelNum = a.t_data[lParm2]; break;
|
||||
|
||||
case ACTOR_ANGOFF: labelNum = ext.angoff; break;
|
||||
case ACTOR_PITCH: labelNum = ext.pitch; break;
|
||||
case ACTOR_ROLL: labelNum = ext.roll; break;
|
||||
case ACTOR_MDXOFF: labelNum = ext.offset.x; break;
|
||||
case ACTOR_MDYOFF: labelNum = ext.offset.y; break;
|
||||
case ACTOR_MDZOFF: labelNum = ext.offset.z; break;
|
||||
case ACTOR_MDFLAGS: labelNum = ext.flags; break;
|
||||
case ACTOR_XPANNING: labelNum = ext.xpanning; break;
|
||||
case ACTOR_YPANNING: labelNum = ext.ypanning; break;
|
||||
|
||||
case ACTOR_ALPHA: labelNum = (uint8_t)(ext.alpha * 255.0f); break;
|
||||
case ACTOR_ISVALID: labelNum = (sprite[spriteNum].statnum != MAXSTATUS); break;
|
||||
|
||||
case ACTOR_ISVALID: labelNum = (s.statnum != MAXSTATUS); break;
|
||||
default: EDUKE32_UNREACHABLE_SECTION(labelNum = -1; break);
|
||||
}
|
||||
|
||||
|
|
|
@ -687,12 +687,26 @@ special:
|
|||
switch (gameVar - g_structVarIDs)
|
||||
{
|
||||
case STRUCT_SPRITE:
|
||||
arrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[labelNum].flags & LABEL_HASPARM2)) ?
|
||||
Gv_GetVar(*insptr++, spriteNum, playerNum) : 0;
|
||||
arrayIndexVar = (ActorLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVar(*insptr++, spriteNum, playerNum) : 0;
|
||||
CHECK_INDEX(MAXSPRITES);
|
||||
returnValue = VM_GetSprite(arrayIndex, labelNum, arrayIndexVar);
|
||||
break;
|
||||
|
||||
case STRUCT_SPRITE_INTERNAL__:
|
||||
CHECK_INDEX(MAXSPRITES);
|
||||
returnValue = VM_GetStruct(ActorLabels[labelNum].flags, (intptr_t *)((char *)&sprite[arrayIndex] + ActorLabels[labelNum].offset));
|
||||
break;
|
||||
|
||||
case STRUCT_ACTOR_INTERNAL__:
|
||||
CHECK_INDEX(MAXSPRITES);
|
||||
returnValue = VM_GetStruct(ActorLabels[labelNum].flags, (intptr_t *)((char *)&actor[arrayIndex] + ActorLabels[labelNum].offset));
|
||||
break;
|
||||
|
||||
case STRUCT_SPRITEEXT_INTERNAL__:
|
||||
CHECK_INDEX(MAXSPRITES);
|
||||
returnValue = VM_GetStruct(ActorLabels[labelNum].flags, (intptr_t *)((char *)&spriteext[arrayIndex] + ActorLabels[labelNum].offset));
|
||||
break;
|
||||
|
||||
case STRUCT_TSPR:
|
||||
CHECK_INDEX(MAXSPRITES);
|
||||
returnValue = VM_GetTsprite(arrayIndex, labelNum);
|
||||
|
@ -896,11 +910,26 @@ int __fastcall Gv_GetSpecialVarX(int gameVar)
|
|||
switch (structIndex)
|
||||
{
|
||||
case STRUCT_SPRITE:
|
||||
arrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[labelNum].flags & LABEL_HASPARM2)) ? Gv_GetVarX(*insptr++) : 0;
|
||||
arrayIndexVar = (ActorLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
|
||||
CHECK_INDEX(MAXSPRITES, GVX_BADSPRITE);
|
||||
returnValue = VM_GetSprite(arrayIndex, labelNum, arrayIndexVar);
|
||||
break;
|
||||
|
||||
case STRUCT_SPRITE_INTERNAL__:
|
||||
CHECK_INDEX(MAXSPRITES, GVX_BADSPRITE);
|
||||
returnValue = VM_GetStruct(ActorLabels[labelNum].flags, (intptr_t *)((char *)&sprite[arrayIndex] + ActorLabels[labelNum].offset));
|
||||
break;
|
||||
|
||||
case STRUCT_ACTOR_INTERNAL__:
|
||||
CHECK_INDEX(MAXSPRITES, GVX_BADSPRITE);
|
||||
returnValue = VM_GetStruct(ActorLabels[labelNum].flags, (intptr_t *)((char *)&actor[arrayIndex] + ActorLabels[labelNum].offset));
|
||||
break;
|
||||
|
||||
case STRUCT_SPRITEEXT_INTERNAL__:
|
||||
CHECK_INDEX(MAXSPRITES, GVX_BADSPRITE);
|
||||
returnValue = VM_GetStruct(ActorLabels[labelNum].flags, (intptr_t *)((char *)&spriteext[arrayIndex] + ActorLabels[labelNum].offset));
|
||||
break;
|
||||
|
||||
case STRUCT_TSPR:
|
||||
CHECK_INDEX(MAXSPRITES, GVX_BADSPRITE);
|
||||
returnValue = VM_GetTsprite(arrayIndex, labelNum);
|
||||
|
@ -1081,11 +1110,11 @@ void __fastcall Gv_GetManyVars(int const numVars, int32_t * const outBuf)
|
|||
}
|
||||
|
||||
outBuf[j] = (value ^ -invertResult) + invertResult;
|
||||
continue;
|
||||
|
||||
perr:
|
||||
CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], vm.playerNum);
|
||||
}
|
||||
return;
|
||||
|
||||
perr:
|
||||
CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], vm.playerNum);
|
||||
}
|
||||
|
||||
void __fastcall Gv_SetVarX(int const gameVar, int const newValue)
|
||||
|
@ -1555,6 +1584,9 @@ static void Gv_AddSystemVars(void)
|
|||
// special vars for struct access
|
||||
// KEEPINSYNC gamedef.h: enum QuickStructureAccess_t
|
||||
Gv_NewVar("sprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("__sprite__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("__actor__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("__spriteext__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("sector", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("wall", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("player", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
|
|
Loading…
Reference in a new issue