CON: Add commands "swaptrackslot" and "preloadtrackslotforswap"

git-svn-id: https://svn.eduke32.com/eduke32@6623 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-01-29 11:14:04 +00:00
parent 0d1137be5d
commit d41a013a57
3 changed files with 35 additions and 1 deletions

View file

@ -380,6 +380,7 @@ static tokenmap_t const vm_keywords[] =
{ "precache", CON_PRECACHE },
{ "prevspritesect", CON_PREVSPRITESECT },
{ "prevspritestat", CON_PREVSPRITESTAT },
{ "preloadtrackslotforswap", CON_PRELOADTRACKSLOTFORSWAP },
{ "pstomp", CON_PSTOMP },
{ "qgetsysstr", CON_QGETSYSSTR },
{ "qspawnvar", CON_QSPAWNVAR },
@ -492,6 +493,7 @@ static tokenmap_t const vm_keywords[] =
{ "subvar", CON_SUBVAR },
{ "subvarvar", CON_SUBVARVAR },
{ "switch", CON_SWITCH },
{ "swaptrackslot", CON_SWAPTRACKSLOT },
{ "time", CON_TIME },
{ "tip", CON_TIP },
{ "tossweapon", CON_TOSSWEAPON },
@ -4205,6 +4207,8 @@ DO_DEFSTATE:
case CON_ACTORSOUND:
case CON_STOPACTORSOUND:
case CON_STARTTRACKSLOT:
case CON_SWAPTRACKSLOT:
case CON_PRELOADTRACKSLOTFORSWAP:
C_GetManyVars(2);
continue;

View file

@ -1208,6 +1208,8 @@ enum ScriptKeywords_t
CON_QSTRCMP, // 411
CON_DIVR, // 412
CON_DIVRU, // 413
CON_SWAPTRACKSLOT, // 414
CON_PRELOADTRACKSLOTFORSWAP, // 415
CON_END
};
// KEEPINSYNC with the keyword list in lunatic/con_lang.lua

View file

@ -1146,11 +1146,16 @@ static int G_StartTrackSlot(int const volumeNum, int const levelNum)
}
#ifndef LUNATIC
static void G_StartTrackSlotWrap(int const volumeNum, int const levelNum)
static int G_StartTrackSlotWrap(int const volumeNum, int const levelNum)
{
if (EDUKE32_PREDICT_FALSE(G_StartTrackSlot(volumeNum, levelNum)))
{
CON_ERRPRINTF("invalid level %d or null music for volume %d level %d\n",
levelNum, volumeNum, levelNum);
return 1;
}
return 0;
}
#else
int G_StartTrack(int const levelNum)
@ -5054,6 +5059,29 @@ finish_qsprintf:
}
continue;
case CON_SWAPTRACKSLOT:
insptr++;
{
int const volumeNum = Gv_GetVarX(*(insptr++));
int const levelNum = Gv_GetVarX(*(insptr++));
if (volumeNum == ud.music_episode && levelNum == ud.music_level)
continue;
// This is the best ASS can do right now. Better implementation pending.
int32_t position = S_GetMusicPosition();
if (!G_StartTrackSlotWrap(volumeNum == -1 ? MAXVOLUMES : volumeNum, levelNum))
S_SetMusicPosition(position);
}
continue;
case CON_PRELOADTRACKSLOTFORSWAP:
// ASS can't even handle this command right now.
insptr++;
Gv_GetVarX(*(insptr++));
Gv_GetVarX(*(insptr++));
continue;
case CON_SETMUSICPOSITION:
insptr++;
Gv_GetVarX(*(insptr++));