Add "klabs" keyword to CON, to take a gamevar and set it to its absolute value. The internal "inv" function to invert a gamevar's value has also been exposed externally.

git-svn-id: https://svn.eduke32.com/eduke32@5501 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-01-02 01:56:29 +00:00
parent 01ebee280e
commit 14938ea5fd
3 changed files with 16 additions and 2 deletions

View file

@ -81,7 +81,6 @@ static struct { uint32_t keyw; uint32_t date; } g_keywdate[] =
{ CON_IFVARVAREITHER, 20080907 }, { CON_IFVARVAREITHER, 20080907 },
{ CON_SAVENN, 20080915 }, { CON_SAVENN, 20080915 },
{ CON_COPY, 20090219 }, { CON_COPY, 20090219 },
// { CON_INV, 20090619 },
{ CON_QSTRNCAT, 20090712 }, { CON_QSTRNCAT, 20090712 },
{ CON_STOPACTORSOUND, 20090715 }, { CON_STOPACTORSOUND, 20090715 },
{ CON_IFSERVER, 20100722 }, { CON_IFSERVER, 20100722 },
@ -110,6 +109,8 @@ static struct { uint32_t keyw; uint32_t date; } g_keywdate[] =
{ CON_IFVARVARBOTH, 20160101 }, { CON_IFVARVARBOTH, 20160101 },
{ CON_WHILEVARL, 20160101 }, { CON_WHILEVARL, 20160101 },
{ CON_WHILEVARVARL, 20160101 }, { CON_WHILEVARVARL, 20160101 },
{ CON_KLABS, 20160101 },
{ CON_INV, 20160101 },
}; };
#endif #endif
@ -226,6 +227,7 @@ const tokenmap_t altkeyw [] =
{ "ifboth", CON_IFVARVARBOTH }, { "ifboth", CON_IFVARVARBOTH },
{ "whilen", CON_WHILEVARVARN }, { "whilen", CON_WHILEVARVARN },
{ "whilel", CON_WHILEVARVARL }, { "whilel", CON_WHILEVARVARL },
{ "abs", CON_KLABS },
}; };
const char *keyw[] = const char *keyw[] =
@ -576,7 +578,7 @@ const char *keyw[] =
"getarraysize", // 343 "getarraysize", // 343
"savenn", // 344 "savenn", // 344
"copy", // 345 "copy", // 345
"<null>", // 346 internal inversion function "inv", // 346
"sectorofwall", // 347 "sectorofwall", // 347
"qstrncat", // 348 "qstrncat", // 348
"ifactorsound", // 349 "ifactorsound", // 349
@ -621,6 +623,7 @@ const char *keyw[] =
"ifvarvarboth", // 388 "ifvarvarboth", // 388
"whilevarl", // 389 "whilevarl", // 389
"whilevarvarl", // 390 "whilevarvarl", // 390
"klabs", // 391
"<null>" "<null>"
}; };
#endif #endif
@ -4474,6 +4477,8 @@ DO_DEFSTATE:
case CON_GETTICKS: case CON_GETTICKS:
case CON_GETCURRADDRESS: case CON_GETCURRADDRESS:
case CON_GETMUSICPOSITION: case CON_GETMUSICPOSITION:
case CON_KLABS:
case CON_INV:
C_GetNextVarType(GAMEVAR_READONLY); C_GetNextVarType(GAMEVAR_READONLY);
continue; continue;

View file

@ -1058,6 +1058,7 @@ enum ScriptKeywords_t
CON_IFVARVARBOTH, // 388 CON_IFVARVARBOTH, // 388
CON_WHILEVARL, // 389 CON_WHILEVARL, // 389
CON_WHILEVARVARL, // 390 CON_WHILEVARVARL, // 390
CON_KLABS, // 391
CON_END CON_END
}; };
// KEEPINSYNC with the keyword list in lunatic/con_lang.lua // KEEPINSYNC with the keyword list in lunatic/con_lang.lua

View file

@ -4536,6 +4536,14 @@ finish_qsprintf:
insptr += 2; insptr += 2;
continue; continue;
case CON_KLABS:
if ((aGameVars[*(insptr + 1)].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
aGameVars[*(insptr + 1)].val.lValue = klabs(aGameVars[*(insptr + 1)].val.lValue);
else
Gv_SetVarX(*(insptr + 1), klabs(Gv_GetVarX(*(insptr + 1))));
insptr += 2;
continue;
case CON_SETARRAY: case CON_SETARRAY:
insptr++; insptr++;
{ {