Fix "setvarvar: Gv_GetVarX(): invalid player ID -1" message for certain userdef accesses

git-svn-id: https://svn.eduke32.com/eduke32@6717 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-03-03 08:22:55 +00:00
parent 478165f00c
commit ab3c4366e4

View file

@ -876,10 +876,11 @@ int __fastcall Gv_GetSpecialVarX(int gameVar)
else if (gameVar & (MAXGAMEVARS << 3)) // struct shortcut vars
{
int arrayIndexVar = *insptr++;
int arrayIndex = Gv_GetVarX(arrayIndexVar);
auto const structIndex = (gameVar & (MAXGAMEVARS - 1)) - g_structVarIDs;
int arrayIndex = structIndex != STRUCT_USERDEF ? Gv_GetVarX(arrayIndexVar) : -1;
int const labelNum = *insptr++;
switch ((gameVar & (MAXGAMEVARS - 1)) - g_structVarIDs)
switch (structIndex)
{
case STRUCT_SPRITE:
arrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[labelNum].flags & LABEL_HASPARM2)) ? Gv_GetVarX(*insptr++) : 0;