From cbb18f5c70a36df88586fff6f5a5745e874a673a Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 1 Aug 2017 09:48:59 +0000 Subject: [PATCH] CON: Add starttrackslot Clobbering ud.volume_number is a hack no one should need to use any more. Only this command supports specifying -1 for volume to access the main menu, briefing, etc themes. git-svn-id: https://svn.eduke32.com/eduke32@6414 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/gamedef.cpp | 2 ++ source/duke3d/src/gamedef.h | 1 + source/duke3d/src/gameexec.cpp | 37 ++++++++++++++++++++++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 5a326839b..6fc6589b7 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -599,6 +599,7 @@ const char *keyw[] = { "getclosestcol", // 403 "drawline256", // 404 "drawlinergb", // 405 + "starttrackslot", // 406 NULL }; #endif @@ -4120,6 +4121,7 @@ DO_DEFSTATE: case CON_QSTRCPY: case CON_QGETSYSSTR: case CON_STOPACTORSOUND: + case CON_STARTTRACKSLOT: C_GetManyVars(2); continue; diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index 66a59f7e3..3c10ab81c 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -1141,6 +1141,7 @@ enum ScriptKeywords_t CON_GETCLOSESTCOL, // 403 CON_DRAWLINE256, // 404 CON_DRAWLINERGB, // 405 + CON_STARTTRACKSLOT, // 406 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 b1d71f401..146dc46f7 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -1140,11 +1140,11 @@ void G_GetTimeDate(int32_t * const pValues) pValues[7] = pTime->tm_yday; } -int G_StartTrack(int const levelNum) +static int G_StartTrackSlot(int const volumeNum, int const levelNum) { - if ((unsigned)levelNum < MAXLEVELS) + if ((unsigned)volumeNum <= MAXVOLUMES && (unsigned)levelNum < MAXLEVELS) { - int trackNum = MAXLEVELS*ud.volume_number + levelNum; + int trackNum = MAXLEVELS*volumeNum + levelNum; if (g_mapInfo[trackNum].musicfn != NULL) { @@ -1159,6 +1159,20 @@ int G_StartTrack(int const levelNum) return 1; } +static void 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); +} + +#ifdef LUNATIC +int G_StartTrack(int const levelNum) +{ + return G_StartTrackSlot(ud.volume_number, levelNum); +} +#endif + LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp) { @@ -4920,14 +4934,21 @@ finish_qsprintf: continue; case CON_STARTTRACK: + insptr++; + G_StartTrackSlotWrap(ud.volume_number, *(insptr++)); + continue; + case CON_STARTTRACKVAR: insptr++; - { - int const levelNum = (tw == CON_STARTTRACK) ? *(insptr++) : Gv_GetVarX(*(insptr++)); + G_StartTrackSlotWrap(ud.volume_number, Gv_GetVarX(*(insptr++))); + continue; - if (EDUKE32_PREDICT_FALSE(G_StartTrack(levelNum))) - CON_ERRPRINTF("invalid level %d or null music for volume %d level %d\n", - levelNum, ud.volume_number, levelNum); + case CON_STARTTRACKSLOT: + insptr++; + { + int const volumeNum = Gv_GetVarX(*(insptr++)); + int const levelNum = Gv_GetVarX(*(insptr++)); + G_StartTrackSlotWrap(volumeNum == -1 ? MAXVOLUMES : volumeNum, levelNum); } continue;