mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 04:20:42 +00:00
Revise the userdef code to accept multiple values.
Patch from Fox. git-svn-id: https://svn.eduke32.com/eduke32@6705 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
e26760b6af
commit
9878d0c322
4 changed files with 34 additions and 10 deletions
|
@ -2015,6 +2015,9 @@ static void C_GetNextVarType(int32_t type)
|
|||
break;
|
||||
case STRUCT_USERDEF:
|
||||
*g_scriptPtr++=UserdefsLabels[labelNum].lId;
|
||||
|
||||
if (UserdefsLabels[labelNum].flags & LABEL_HASPARM2)
|
||||
C_GetNextVarType(0);
|
||||
break;
|
||||
case STRUCT_INPUT:
|
||||
*g_scriptPtr++=InputLabels[labelNum].lId;
|
||||
|
@ -3982,6 +3985,9 @@ DO_DEFSTATE:
|
|||
BITPTR_CLEAR(g_scriptPtr-apScript);
|
||||
*g_scriptPtr++=labelNum;
|
||||
|
||||
if (UserdefsLabels[labelNum].flags & LABEL_HASPARM2)
|
||||
C_GetNextVar();
|
||||
|
||||
C_GetNextVarType((tw == CON_GETUSERDEF) ? GAMEVAR_READONLY : 0);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -4213,16 +4213,20 @@ finish_qsprintf:
|
|||
case CON_GETUSERDEF:
|
||||
insptr++;
|
||||
{
|
||||
tw = *insptr++;
|
||||
Gv_SetVarX(*insptr++, VM_GetUserdef(tw));
|
||||
int const labelNum = *insptr++;
|
||||
int const lParm2 = (UserdefsLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
|
||||
|
||||
Gv_SetVarX(*insptr++, VM_GetUserdef(labelNum, lParm2));
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_SETUSERDEF:
|
||||
insptr++;
|
||||
{
|
||||
tw = *insptr++;
|
||||
VM_SetUserdef(tw, Gv_GetVarX(*insptr++));
|
||||
int const labelNum = *insptr++;
|
||||
int const lParm2 = (UserdefsLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
|
||||
|
||||
VM_SetUserdef(labelNum, lParm2, Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
// I got a 3-4 fps gain by inlining these...
|
||||
|
||||
#ifndef gamevars_c_
|
||||
int32_t __fastcall VM_GetUserdef(int32_t labelNum);
|
||||
void __fastcall VM_SetUserdef(int32_t const labelNum, int32_t const iSet);
|
||||
int32_t __fastcall VM_GetUserdef(int32_t labelNum, int32_t const lParm2);
|
||||
void __fastcall VM_SetUserdef(int32_t const labelNum, int32_t const lParm2, int32_t const iSet);
|
||||
int32_t __fastcall VM_GetActiveProjectile(int32_t const spriteNum, int32_t labelNum);
|
||||
void __fastcall VM_SetActiveProjectile(int32_t const spriteNum, int32_t const labelNum, int32_t const iSet);
|
||||
int32_t __fastcall VM_GetPlayer(int32_t const playerNum, int32_t labelNum, int32_t const lParm2);
|
||||
|
@ -45,8 +45,14 @@ void __fastcall VM_SetProjectile(int32_t const tileNum, int32_t const labelNum,
|
|||
int32_t __fastcall VM_GetTileData(int32_t const tileNum, int32_t labelNum);
|
||||
int32_t __fastcall VM_GetPalData(int32_t const palNum, int32_t labelNum);
|
||||
#else
|
||||
int32_t __fastcall VM_GetUserdef(int32_t labelNum)
|
||||
int32_t __fastcall VM_GetUserdef(int32_t labelNum, int32_t const lParm2)
|
||||
{
|
||||
if (EDUKE32_PREDICT_FALSE(UserdefsLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned) lParm2 >= (unsigned) UserdefsLabels[labelNum].maxParm2))
|
||||
{
|
||||
CON_ERRPRINTF("%s[%d] invalid for userdef", UserdefsLabels[labelNum].name, lParm2);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (labelNum)
|
||||
{
|
||||
case USERDEFS_GOD: labelNum = ud.god; break;
|
||||
|
@ -224,8 +230,14 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum)
|
|||
return labelNum;
|
||||
}
|
||||
|
||||
void __fastcall VM_SetUserdef(int32_t const labelNum, int32_t const iSet)
|
||||
void __fastcall VM_SetUserdef(int32_t const labelNum, int32_t const lParm2, int32_t const iSet)
|
||||
{
|
||||
if (EDUKE32_PREDICT_FALSE(UserdefsLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned)lParm2 >= (unsigned)UserdefsLabels[labelNum].maxParm2))
|
||||
{
|
||||
CON_ERRPRINTF("%s[%d] invalid for userdef", UserdefsLabels[labelNum].name, lParm2);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (labelNum)
|
||||
{
|
||||
case USERDEFS_GOD: ud.god = iSet; break;
|
||||
|
|
|
@ -754,7 +754,8 @@ special:
|
|||
break;
|
||||
|
||||
case STRUCT_USERDEF:
|
||||
returnValue = VM_GetUserdef(labelNum);
|
||||
arrayIndexVar = (EDUKE32_PREDICT_FALSE(UserdefsLabels[labelNum].flags & LABEL_HASPARM2)) ? Gv_GetVarX(*insptr++) : 0;
|
||||
returnValue = VM_GetUserdef(labelNum, arrayIndexVar);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -952,7 +953,8 @@ int __fastcall Gv_GetSpecialVarX(int gameVar)
|
|||
break;
|
||||
|
||||
case STRUCT_USERDEF:
|
||||
returnValue = VM_GetUserdef(labelNum);
|
||||
arrayIndexVar = (EDUKE32_PREDICT_FALSE(UserdefsLabels[labelNum].flags & LABEL_HASPARM2)) ? Gv_GetVarX(*insptr++) : 0;
|
||||
returnValue = VM_GetUserdef(labelNum, arrayIndexVar);
|
||||
break;
|
||||
|
||||
default: EDUKE32_UNREACHABLE_SECTION(return -1);
|
||||
|
|
Loading…
Reference in a new issue