diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 80c9bbbb8..69c365407 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -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; diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index 4b0c59729..aaf2cabd3 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -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 diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 35af21d38..86763f3c9 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -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++));