Add CON_CLAMP

git-svn-id: https://svn.eduke32.com/eduke32@5728 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-05-13 22:15:37 +00:00
parent ce86532949
commit 584b748897
3 changed files with 16 additions and 0 deletions

View file

@ -572,6 +572,7 @@ const char *keyw[] =
"movesector", // 395
"for", // 396
"nextsectorneighborz", // 397
"clamp", // 398
"<null>"
};
#endif
@ -4062,6 +4063,11 @@ DO_DEFSTATE:
C_GetNextVarType(GAMEVAR_READONLY);
continue;
case CON_CLAMP:
C_GetNextVarType(GAMEVAR_READONLY);
C_GetManyVars(2);
continue;
case CON_ENHANCED:
g_scriptPtr--;
C_GetNextValue(LABEL_DEFINE);

View file

@ -1106,6 +1106,7 @@ enum ScriptKeywords_t
CON_MOVESECTOR, // 395
CON_FOR, // 396
CON_NEXTSECTORNEIGHBORZ,// 397
CON_CLAMP, // 398
CON_END
};
// KEEPINSYNC with the keyword list in lunatic/con_lang.lua

View file

@ -4769,6 +4769,15 @@ finish_qsprintf:
insptr += 2;
continue;
case CON_CLAMP:
insptr++;
{
tw = *insptr++;
int const min = Gv_GetVarX(*insptr++);
Gv_SetVarX(tw, clamp2(Gv_GetVarX(tw), min, Gv_GetVarX(*insptr++)));
}
continue;
case CON_INV:
if ((aGameVars[*(insptr + 1)].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
aGameVars[*(insptr + 1)].val.lValue = -aGameVars[*(insptr + 1)].val.lValue;