diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 9146270ae..5c93f1e12 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -382,6 +382,7 @@ static tokenmap_t const vm_keywords[] = { "qspawnvar", CON_QSPAWNVAR }, { "qsprintf", CON_QSPRINTF }, { "qstrcat", CON_QSTRCAT }, + { "qstrcmp", CON_QSTRCMP }, { "qstrcpy", CON_QSTRCPY }, { "qstrdim", CON_QSTRDIM }, { "qstrlen", CON_QSTRLEN }, @@ -4778,6 +4779,7 @@ DO_DEFSTATE: case CON_CANSEESPR: case CON_UPDATESECTOR: + case CON_QSTRCMP: C_GetManyVars(2); C_GetNextVarType(GAMEVAR_READONLY); continue; diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index fe3765999..669b4d84b 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -1168,6 +1168,7 @@ enum ScriptKeywords_t CON_ACTORSOUND, // 408 CON_STARTSCREEN, // 409 CON_SCREENPAL, // 410 + CON_QSTRCMP, // 411 CON_END }; // KEEPINSYNC with the keyword list in lunatic/con_lang.lua diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index afd154f25..730567ad5 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -2245,6 +2245,24 @@ skip_check: continue; } + case CON_QSTRCMP: + insptr++; + { + int const quote1 = Gv_GetVarX(*insptr++); + int const quote2 = Gv_GetVarX(*insptr++); + int const gameVar = *insptr++; + + if (EDUKE32_PREDICT_FALSE(apStrings[quote1] == NULL || apStrings[quote2] == NULL)) + { + CON_ERRPRINTF("null quote %d\n", apStrings[quote1] ? quote2 : quote1); + Gv_SetVarX(gameVar, -2); + continue; + } + + Gv_SetVarX(gameVar, strcmp(apStrings[quote1], apStrings[quote2])); + continue; + } + case CON_GETPNAME: case CON_QSTRNCAT: case CON_QSTRCAT: