diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e1129dfa8..634172e1a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -791,6 +791,7 @@ set (PCH_SOURCES core/gamecvars.cpp core/gamecontrol.cpp core/inputstate.cpp + core/mapinfo.cpp core/searchpaths.cpp core/screenjob.cpp core/initfs.cpp diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 399268d1c..25fc79991 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -420,32 +420,6 @@ void EndLevel(void) seqKillAll(); } -int G_TryMapHack(const char* mhkfile) -{ - int const failure = engineLoadMHK(mhkfile); - - if (!failure) - Printf("Loaded map hack file \"%s\"\n", mhkfile); - - return failure; -} - -void G_LoadMapHack(char* outbuf, const char* filename) -{ - if (filename != NULL) - Bstrcpy(outbuf, filename); - - append_ext_UNSAFE(outbuf, ".mhk"); - - if (G_TryMapHack(outbuf) && usermaphacks != NULL) - { - auto pMapInfo = (usermaphack_t*)bsearch(&g_loadedMapHack, usermaphacks, num_usermaphacks, - sizeof(usermaphack_t), compare_usermaphacks); - if (pMapInfo) - G_TryMapHack(pMapInfo->mhkfile); - } -} - #ifdef POLYMER void G_RefreshLights(void) { @@ -541,11 +515,10 @@ void StartLevel(GAMEOPTIONS *gameOptions) gQuitGame = true; return; } - char levelName[BMAX_PATH]; currentLevel = &mapList[gGameOptions.nEpisode * kMaxLevels + gGameOptions.nLevel]; SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); STAT_NewLevel(currentLevel->fileName); - G_LoadMapHack(levelName, gameOptions->zLevelName); + G_LoadMapHack(gameOptions->zLevelName); wsrand(gameOptions->uMapCRC); gKillMgr.Clear(); gSecretMgr.Clear(); diff --git a/source/build/include/build.h b/source/build/include/build.h index 3a3ca43b5..2234d977a 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -818,6 +818,7 @@ void initspritelists(void); int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum); int32_t engineLoadMHK(const char *filename); +void G_LoadMapHack(const char* filename); void engineClearLightsFromMHK(); #ifdef HAVE_CLIPSHAPE_FEATURE int32_t engineLoadClipMaps(void); diff --git a/source/build/src/mhk.cpp b/source/build/src/mhk.cpp index d12e0db35..d90f74919 100644 --- a/source/build/src/mhk.cpp +++ b/source/build/src/mhk.cpp @@ -417,3 +417,28 @@ int32_t engineLoadMHK(const char *filename) scriptfile_close(script); return 0; } + +// taken out of the game modules - this code was repeated in all of them. +static int G_TryMapHack(const char* mhkfile) +{ + int const failure = engineLoadMHK(mhkfile); + + if (!failure) + Printf("Loaded map hack file \"%s\"\n", mhkfile); + + return failure; +} + +void G_LoadMapHack(const char* filename) +{ + FString hack = StripExtension(filename) + ".mhk"; + + if (G_TryMapHack(hack) && usermaphacks != NULL) + { + auto pMapInfo = (usermaphack_t*)bsearch(&g_loadedMapHack, usermaphacks, num_usermaphacks, + sizeof(usermaphack_t), compare_usermaphacks); + if (pMapInfo) + G_TryMapHack(pMapInfo->mhkfile); + } +} + diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 89e5caf15..118bd98b0 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -97,12 +97,6 @@ auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need glcycle_t thinktime, actortime, gameupdatetime, drawtime; - -MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts. -MapRecord *currentLevel; // level that is currently played. (The real level, not what script hacks modfifying the current level index can pretend.) -MapRecord* lastLevel; // Same here, for the last level. -MapRecord userMapRecord; // stand-in for the user map. - gamestate_t gamestate = GS_STARTUP; FILE* hashfile; diff --git a/source/core/mapinfo.cpp b/source/core/mapinfo.cpp new file mode 100644 index 000000000..1c4918731 --- /dev/null +++ b/source/core/mapinfo.cpp @@ -0,0 +1,145 @@ +/* +** mapinfo.cpp +** +** Map record management +** +**--------------------------------------------------------------------------- +** Copyright 2020 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "mapinfo.h" + +MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts. +MapRecord *currentLevel; // level that is currently played. (The real level, not what script hacks modfifying the current level index can pretend.) +MapRecord* lastLevel; // Same here, for the last level. +unsigned int numUsedSlots; + + +MapRecord *FindMapByName(const char *nm) +{ + for (unsigned i = 0; i < numUsedSlots; i++) + { + auto &map = mapList[i]; + if (map.labelName.CompareNoCase(nm) == 0) + { + return ↦ + } + } + return nullptr; +} + + +MapRecord *FindMapByLevelNum(int num) +{ + for (unsigned i = 0; i < numUsedSlots; i++) + { + auto &map = mapList[i]; + if (map.levelNumber == num) + { + return ↦ + } + } + return nullptr; +} + +MapRecord *FindNextMap(MapRecord *thismap) +{ + if (thismap->nextLevel != -1) return mapList[thismap->nextlevel]; + return FindMapByLevelNum(thismap->levelNumber+1); +} + +bool SetMusicForMap(const char* mapname, const char* music, bool namehack = false) +{ + static const char* specials[] = { "intro", "briefing", "loading" }; + for (int i = 0; i < 3; i++) + { + if (!stricmp(mapname, specials[i])) + { + // todo: store this properly. + return true; + } + } + + int index = FindMapByName(mapname); + + // This is for the DEFS parser's MUSIC command which never bothered to check for the real map name. + if (index < 0 && namehack) + { + int lev, ep; + signed char b1, b2; + + int numMatches = sscanf(mapname, "%c%d%c%d", &b1, &ep, &b2, &lev); + + if (numMatches != 4 || toupper(b1) != 'E' || toupper(b2) != 'L') + return false; + + index = FindMapByLevelNum(ep*100 + lev); + + } + if (index >= 0) + { + mapList[index].music = music; + return true; + } + return false; +} + +MapRecord *AlloocateMap() +{ + return &mapList[numUsedSlots++]; +} + + +MapRecord* SetupUserMap(const char* boardfilename) +{ + for (unsigned i = 0; i < numUsedSlots; i++) + { + auto &map = mapList[i]; + if (map.fileName.CompareNoCase(boardfilename) == 0) + { + return ↦ + } + } + auto map = AllocateMap() + map->name = ""; + map->SetFileName(boardfilename); + map->flags = MI_USERMAP|MI_FORCEEOG; + map->music = G_SetupFilenameBasedMusic(boardfilename, !isRR() ? "dethtoll.mid" : nullptr); + return map; +} + + + +void InitRREndMap() +{ + // RR defines its end map ad-hoc so give it a proper entry to reference (the last one in episode 2 because it needs to be in Ep. 2.) + mapList[127].SetName("$TXT_CLOSEENCOUNTERS"); + mapList[127].SetFileName("endgame.map"); + mapList[127].levelNumber = 163; // last one in Ep. 2. +} diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index cbeab6f73..053748f6f 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -18,6 +18,7 @@ inline void MakeStringLocalizable(FString "e) enum { MI_FORCEEOG = 1, + MI_USERMAP = 2, }; struct MapRecord @@ -39,7 +40,12 @@ struct MapRecord FString author; int8_t fog = -1, weather = -1; // Blood defines these but they aren't used. - const char *DisplayName() + const char* LabelName() const + { + if (flags & MI_USERMAP) return GStrings("TXT_USERMAP"); + return labelName; + } + const char *DisplayName() const { if (name.IsEmpty()) return labelName; return GStrings.localize(name); @@ -64,54 +70,14 @@ struct MapRecord extern MapRecord mapList[512]; -extern MapRecord userMapRecord; extern MapRecord *currentLevel; -extern MapRecord* lastLevel; -inline bool SetMusicForMap(const char* mapname, const char* music, bool namehack = false) -{ - static const char* specials[] = { "intro", "briefing", "loading" }; - for (int i = 0; i < 3; i++) - { - if (!stricmp(mapname, specials[i])) - { - // todo: store this properly. - return true; - } - } +bool SetMusicForMap(const char* mapname, const char* music, bool namehack = false); +void InitRREndMap(); - int index = -1; // = FindMap(mapname); - - // This is for the DEFS parser's MUSIC command which never bothered to check for the real map name. - if (index < 0 && namehack) - { - int lev, ep; - signed char b1, b2; - - int numMatches = sscanf(mapname, "%c%d%c%d", &b1, &ep, &b2, &lev); - - if (numMatches != 4 || toupper(b1) != 'E' || toupper(b2) != 'L') - return false; - - index = -1; // = FindMapByIndex(ep, lev); - - } - if (index >= 0) - { - mapList[index].music = music; - return true; - } - return false; -} - - -inline void InitRREndMap() -{ - // RR defines its end map ad-hoc so give it a proper entry to reference (the last one in episode 2 because it needs to be in Ep. 2.) - mapList[127].SetName("$TXT_CLOSEENCOUNTERS"); - mapList[127].SetFileName("endgame.map"); - mapList[127].levelNumber = 163; // last one in Ep. 2. -} +MapRecord *FindMapByName(const char *nm); +MapRecord *FindMapByLevelNum(int num); +MapRecord *FindNextMap(MapRecord *thismap); enum { diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index be961cbf7..905b9f194 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -40,6 +40,7 @@ BEGIN_EDUKE_NS static uint8_t precachehightile[2][(MAXTILES+7)>>3]; static int32_t g_precacheCount; +MapRecord userMapRecord; static int32_t NET_75_CHECK = 0; @@ -1653,32 +1654,6 @@ static void G_FadeLoad(int32_t r, int32_t g, int32_t b, int32_t start, int32_t e } #endif -static int G_TryMapHack(const char *mhkfile) -{ - int const failure = engineLoadMHK(mhkfile); - - if (!failure) - Printf("Loaded map hack file \"%s\"\n", mhkfile); - - return failure; -} - -static void G_LoadMapHack(char *outbuf, const char *filename) -{ - if (filename != NULL) - Bstrcpy(outbuf, filename); - - append_ext_UNSAFE(outbuf, ".mhk"); - - if (G_TryMapHack(outbuf) && usermaphacks != NULL) - { - auto pMapInfo = (usermaphack_t *)bsearch(&g_loadedMapHack, usermaphacks, num_usermaphacks, - sizeof(usermaphack_t), compare_usermaphacks); - if (pMapInfo) - G_TryMapHack(pMapInfo->mhkfile); - } -} - static void G_CheckIfStateless() { for (bssize_t i = 0; i < (MAXVOLUMES * MAXLEVELS); i++) @@ -1785,7 +1760,7 @@ int G_EnterLevel(int gameMode) currentLevel = &userMapRecord; SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); STAT_NewLevel(boardfilename); - G_LoadMapHack(levelName, boardfilename); + G_LoadMapHack(boardfilename); userMapRecord.music = G_SetupFilenameBasedMusic(boardfilename, mapList[MUS_USERMAP].music.IsNotEmpty()? mapList[MUS_USERMAP].music.GetChars() :(!FURY? mapList[7].music.GetChars() : nullptr)); } @@ -1799,7 +1774,7 @@ int G_EnterLevel(int gameMode) currentLevel = &mm; SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); STAT_NewLevel(mm.fileName); - G_LoadMapHack(levelName, mm.fileName); + G_LoadMapHack(mm.fileName); } p0.q16ang = fix16_from_int(playerAngle); diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index fb59ec0d9..84d22cbff 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -38,6 +38,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "screenjob.h" #include "texturemanager.h" #include "buildtiles.h" +#include "mapinfo.h" BEGIN_DUKE_NS @@ -781,17 +782,7 @@ public: DDukeLevelSummaryScreen() : DScreenJob(fadein | fadeout) { gfx_offset = BONUSSCREEN + ((ud.volume_number == 1) ? 5 : 0); - - if (ud.volume_number == 0 && ud.last_level == 8 && boardfilename[0]) // todo: get rid of this awful hack. - { - lastmapname = strrchr(boardfilename, '\\'); - if (!lastmapname) lastmapname = strrchr(boardfilename, '/'); - if (!lastmapname) lastmapname = boardfilename; - } - else - { - lastmapname = currentLevel->DisplayName(); - } + lastmapname = currentLevel->DisplayName(); PlayBonusMusic(); } @@ -1043,26 +1034,18 @@ void e4intro(CompletionFunc completion) class DDukeLoadScreen : public DScreenJob { std::function callback; + MapRecord* rec; public: - DDukeLoadScreen(const char *mapname_, std::function callback_) : DScreenJob(fadein|fadeout), callback(callback_) {} + DDukeLoadScreen(MapRecord *maprec, std::function callback_) : DScreenJob(fadein|fadeout), callback(callback_), rec(maprec) {} int Frame(uint64_t clock, bool skiprequest) { DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); - // fixme: The level management needs a total overhaul! - if (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0) - { - BigText(160, 90, GStrings("TXT_LOADUM")); - GameText(160, 100, boardfilename, 14, 0); - } - else - { - BigText(160, 90, GStrings("TXT_LOADING")); - BigText(160, 114, mapList[(ud.volume_number * MAXLEVELS) + ud.level_number].DisplayName()); - } - + BigText(160, 90, (rec->flags & MI_USERMAP)? GStrings("TXT_LOADUM") : GStrings("TXT_LOADING")); + BigText(160, 114, rec->DisplayName()); + // Initiate the level load once the page has been faded in completely. if (callback && GetFadeState() == visible) { diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index 8f427caaa..cb6acac04 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -50,74 +50,74 @@ BEGIN_DUKE_NS void InitFonts_r() { - GlyphSet fontdata; + GlyphSet fontdata; - // Small font - for (int i = 0; i < 95; i++) - { - auto tile = tileGetTexture(STARTALPHANUM + i); - if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0) - { - fontdata.Insert('!' + i, tile); - tile->SetOffsetsNotForFont(); - } - } - SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 10, false, false, false, &fontdata); - SmallFont->SetKerning(2); - fontdata.Clear(); + // Small font + for (int i = 0; i < 95; i++) + { + auto tile = tileGetTexture(STARTALPHANUM + i); + if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0) + { + fontdata.Insert('!' + i, tile); + tile->SetOffsetsNotForFont(); + } + } + SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 10, false, false, false, &fontdata); + SmallFont->SetKerning(2); + fontdata.Clear(); - // Big font + // Big font - // This font is VERY messy... - fontdata.Insert('_', tileGetTexture(BIGALPHANUM - 11)); - fontdata.Insert('-', tileGetTexture(BIGALPHANUM - 11)); - for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(BIGALPHANUM - 10 + i)); - for (int i = 0; i < 26; i++) fontdata.Insert('A' + i, tileGetTexture(BIGALPHANUM + i)); - fontdata.Insert('.', tileGetTexture(BIGPERIOD)); - fontdata.Insert(',', tileGetTexture(BIGCOMMA)); - fontdata.Insert('!', tileGetTexture(BIGX)); - fontdata.Insert('?', tileGetTexture(BIGQ)); - fontdata.Insert(';', tileGetTexture(BIGSEMI)); - fontdata.Insert(':', tileGetTexture(BIGCOLIN)); - fontdata.Insert('\\', tileGetTexture(BIGALPHANUM + 68)); - fontdata.Insert('/', tileGetTexture(BIGALPHANUM + 68)); - fontdata.Insert('%', tileGetTexture(BIGALPHANUM + 69)); - fontdata.Insert('`', tileGetTexture(BIGAPPOS)); - fontdata.Insert('"', tileGetTexture(BIGAPPOS)); - fontdata.Insert('\'', tileGetTexture(BIGAPPOS)); - GlyphSet::Iterator it(fontdata); - GlyphSet::Pair* pair; - while (it.NextPair(pair)) pair->Value->SetOffsetsNotForFont(); - BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, 10, false, false, false, &fontdata); - BigFont->SetKerning(6); - fontdata.Clear(); + // This font is VERY messy... + fontdata.Insert('_', tileGetTexture(BIGALPHANUM - 11)); + fontdata.Insert('-', tileGetTexture(BIGALPHANUM - 11)); + for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(BIGALPHANUM - 10 + i)); + for (int i = 0; i < 26; i++) fontdata.Insert('A' + i, tileGetTexture(BIGALPHANUM + i)); + fontdata.Insert('.', tileGetTexture(BIGPERIOD)); + fontdata.Insert(',', tileGetTexture(BIGCOMMA)); + fontdata.Insert('!', tileGetTexture(BIGX)); + fontdata.Insert('?', tileGetTexture(BIGQ)); + fontdata.Insert(';', tileGetTexture(BIGSEMI)); + fontdata.Insert(':', tileGetTexture(BIGCOLIN)); + fontdata.Insert('\\', tileGetTexture(BIGALPHANUM + 68)); + fontdata.Insert('/', tileGetTexture(BIGALPHANUM + 68)); + fontdata.Insert('%', tileGetTexture(BIGALPHANUM + 69)); + fontdata.Insert('`', tileGetTexture(BIGAPPOS)); + fontdata.Insert('"', tileGetTexture(BIGAPPOS)); + fontdata.Insert('\'', tileGetTexture(BIGAPPOS)); + GlyphSet::Iterator it(fontdata); + GlyphSet::Pair* pair; + while (it.NextPair(pair)) pair->Value->SetOffsetsNotForFont(); + BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, 10, false, false, false, &fontdata); + BigFont->SetKerning(6); + fontdata.Clear(); - // Tiny font - for (int i = 0; i < 95; i++) - { - auto tile = tileGetTexture(MINIFONT + i); - if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0) - fontdata.Insert('!' + i, tile); - } - fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. - SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, 6, false, false, false, &fontdata); - SmallFont2->SetKerning(2); - fontdata.Clear(); + // Tiny font + for (int i = 0; i < 95; i++) + { + auto tile = tileGetTexture(MINIFONT + i); + if (tile && tile->isValid() && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0) + fontdata.Insert('!' + i, tile); + } + fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. + SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, 6, false, false, false, &fontdata); + SmallFont2->SetKerning(2); + fontdata.Clear(); - // SBAR index font - for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE + i)); - fontdata.Insert(':', tileGetTexture(THREEBYFIVE + 10)); - fontdata.Insert('/', tileGetTexture(THREEBYFIVE + 11)); - fontdata.Insert('%', tileGetTexture(MINIFONT + '%' - '!')); - fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. - IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); + // SBAR index font + for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE + i)); + fontdata.Insert(':', tileGetTexture(THREEBYFIVE + 10)); + fontdata.Insert('/', tileGetTexture(THREEBYFIVE + 11)); + fontdata.Insert('%', tileGetTexture(MINIFONT + '%' - '!')); + fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. + IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); - fontdata.Clear(); + fontdata.Clear(); - // digital font - for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(DIGITALNUM + i)); - fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. - DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); + // digital font + for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(DIGITALNUM + i)); + fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. + DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); } @@ -130,31 +130,31 @@ void InitFonts_r() static void BigText(double x, double y, const char* text, int align, double alpha = 1.) { - //x *= 2.2; y *= 2.64; - if (align != -1) - x -= BigFont->StringWidth(text) * (align == 0 ? 0.2 : 0.4); - auto width = BigFont->StringWidth(text); - DrawText(twod, BigFont, CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.4, DTA_ScaleY, 0.4, DTA_Alpha, alpha, TAG_DONE); + //x *= 2.2; y *= 2.64; + if (align != -1) + x -= BigFont->StringWidth(text) * (align == 0 ? 0.2 : 0.4); + auto width = BigFont->StringWidth(text); + DrawText(twod, BigFont, CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.4, DTA_ScaleY, 0.4, DTA_Alpha, alpha, TAG_DONE); } static void GameText(double x, double y, const char* t, int shade, int align = -1, int trans = 0) { - x *= 2; y *= 2; - if (align != -1) - x -= SmallFont->StringWidth(t) * (align == 0 ? 0.5 : 1); - int light = Scale(numshades - shade, 255, numshades); - PalEntry pe(255, light, light, light); - DrawText(twod, SmallFont, CR_UNDEFINED, x, y + 2, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, pe, TAG_DONE); + x *= 2; y *= 2; + if (align != -1) + x -= SmallFont->StringWidth(t) * (align == 0 ? 0.5 : 1); + int light = Scale(numshades - shade, 255, numshades); + PalEntry pe(255, light, light, light); + DrawText(twod, SmallFont, CR_UNDEFINED, x, y + 2, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, pe, TAG_DONE); } static void MiniText(double x, double y, const char* t, int shade, int align = -1, int trans = 0) { - x *= 2; y *= 2; - if (align != -1) - x -= SmallFont2->StringWidth(t) * (align == 0 ? 0.5 : 1); - int light = Scale(numshades - shade, 255, numshades); - PalEntry pe(255, light, light, light); - DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, pe, TAG_DONE); + x *= 2; y *= 2; + if (align != -1) + x -= SmallFont2->StringWidth(t) * (align == 0 ? 0.5 : 1); + int light = Scale(numshades - shade, 255, numshades); + PalEntry pe(255, light, light, light); + DrawText(twod, SmallFont2, CR_UNDEFINED, x, y, t, DTA_FullscreenScale, 3, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400, DTA_TranslationIndex, TRANSLATION(Translation_Remap, trans), DTA_Color, pe, TAG_DONE); } //--------------------------------------------------------------------------- @@ -165,43 +165,43 @@ static void MiniText(double x, double y, const char* t, int shade, int align = - void Logo_r(CompletionFunc completion) { - Mus_Stop(); - FX_StopAllSounds(); // JBF 20031228 + Mus_Stop(); + FX_StopAllSounds(); // JBF 20031228 - static const AnimSound introsound[] = - { - { 1, 29+1 }, - { -1, -1 } - }; + static const AnimSound introsound[] = + { + { 1, 29+1 }, + { -1, -1 } + }; - static const AnimSound rednecksound[] = - { - { 1, 478+1 }, - { -1, -1 } - }; + static const AnimSound rednecksound[] = + { + { 1, 478+1 }, + { -1, -1 } + }; - static const AnimSound xatrixsound[] = - { - { 1, 479+1 }, - { -1, -1 } - }; + static const AnimSound xatrixsound[] = + { + { 1, 479+1 }, + { -1, -1 } + }; - static const int framespeed[] = { 9, 9, 9 }; // same for all 3 anims + static const int framespeed[] = { 9, 9, 9 }; // same for all 3 anims - JobDesc jobs[3]; - int job = 0; + JobDesc jobs[3]; + int job = 0; - if (!isRRRA()) - { - jobs[job++] = { PlayVideo("rr_intro.anm", introsound, framespeed), nullptr }; - jobs[job++] = { PlayVideo("redneck.anm", rednecksound, framespeed), nullptr }; - jobs[job++] = { PlayVideo("xatlogo.anm", xatrixsound, framespeed), nullptr }; - } - else - { - jobs[job++] = { PlayVideo("redint.mve"), nullptr }; - } - RunScreenJob(jobs, job, completion); + if (!isRRRA()) + { + jobs[job++] = { PlayVideo("rr_intro.anm", introsound, framespeed), nullptr }; + jobs[job++] = { PlayVideo("redneck.anm", rednecksound, framespeed), nullptr }; + jobs[job++] = { PlayVideo("xatlogo.anm", xatrixsound, framespeed), nullptr }; + } + else + { + jobs[job++] = { PlayVideo("redint.mve"), nullptr }; + } + RunScreenJob(jobs, job, completion); } //--------------------------------------------------------------------------- @@ -212,38 +212,38 @@ void Logo_r(CompletionFunc completion) static void bonussequence_r(int num, JobDesc* jobs, int& job) { - static const AnimSound turdmov[] = - { - { 1, 82 + 1 }, - { -1, -1 } - }; + static const AnimSound turdmov[] = + { + { 1, 82 + 1 }, + { -1, -1 } + }; - static const AnimSound rr_outro[] = - { - { 1, 35 + 1 }, - { -1, -1 } - }; + static const AnimSound rr_outro[] = + { + { 1, 35 + 1 }, + { -1, -1 } + }; - static const int framespeed[] = { 9, 9, 9 }; // same for all 3 anims + static const int framespeed[] = { 9, 9, 9 }; // same for all 3 anims - Mus_Stop(); - FX_StopAllSounds(); + Mus_Stop(); + FX_StopAllSounds(); - switch (num) - { - case 0: - jobs[job++] = { PlayVideo("turdmov.anm", turdmov, framespeed), nullptr }; - jobs[job++] = { Create(TENSCREEN), nullptr }; - break; + switch (num) + { + case 0: + jobs[job++] = { PlayVideo("turdmov.anm", turdmov, framespeed), nullptr }; + jobs[job++] = { Create(TENSCREEN), nullptr }; + break; - case 1: - jobs[job++] = { PlayVideo("rr_outro.anm", rr_outro, framespeed), nullptr }; - jobs[job++] = { Create(TENSCREEN), nullptr }; - break; + case 1: + jobs[job++] = { PlayVideo("rr_outro.anm", rr_outro, framespeed), nullptr }; + jobs[job++] = { Create(TENSCREEN), nullptr }; + break; - default: - break; - } + default: + break; + } } //--------------------------------------------------------------------------- @@ -254,94 +254,94 @@ static void bonussequence_r(int num, JobDesc* jobs, int& job) class DRRMultiplayerBonusScreen : public DScreenJob { - int playerswhenstarted; + int playerswhenstarted; public: - DRRMultiplayerBonusScreen(int pws) : DScreenJob(fadein | fadeout) - { - playerswhenstarted = pws; - PlayBonusMusic(); - } + DRRMultiplayerBonusScreen(int pws) : DScreenJob(fadein | fadeout) + { + playerswhenstarted = pws; + PlayBonusMusic(); + } - int Frame(uint64_t clock, bool skiprequest) - { - char tempbuf[32]; - twod->ClearScreen(); - DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); - double scale = 0.36; - DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_CenterOffset, true, DTA_ScaleX, scale, DTA_ScaleY, 0.36, TAG_DONE); + int Frame(uint64_t clock, bool skiprequest) + { + char tempbuf[32]; + twod->ClearScreen(); + DrawTexture(twod, tileGetTexture(MENUSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_Color, 0xff808080, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + double scale = 0.36; + DrawTexture(twod, tileGetTexture(INGAMEDUKETHREEDEE, true), 160, 34, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DTA_CenterOffset, true, DTA_ScaleX, scale, DTA_ScaleY, 0.36, TAG_DONE); - GameText(160, 58, GStrings("Multiplayer Totals"), 0, 0); - GameText(160, 58 + 10, currentLevel->DisplayName(), 0, 0); - GameText(160, 165, GStrings("Presskey"), 0, 0); + GameText(160, 58, GStrings("Multiplayer Totals"), 0, 0); + GameText(160, 58 + 10, currentLevel->DisplayName(), 0, 0); + GameText(160, 165, GStrings("Presskey"), 0, 0); - int t = 0; + int t = 0; - MiniText(38, 80, GStrings("Name"), 0); - MiniText(269 + 20, 80, GStrings("Kills"), 0, 1); + MiniText(38, 80, GStrings("Name"), 0); + MiniText(269 + 20, 80, GStrings("Kills"), 0, 1); - for (int i = 0; i < playerswhenstarted; i++) - { - mysnprintf(tempbuf, 32, "%-4ld", i + 1); - MiniText(92 + (i * 23), 80, tempbuf, 0); - } + for (int i = 0; i < playerswhenstarted; i++) + { + mysnprintf(tempbuf, 32, "%-4ld", i + 1); + MiniText(92 + (i * 23), 80, tempbuf, 0); + } - for (int i = 0; i < playerswhenstarted; i++) - { - int xfragtotal = 0; - mysnprintf(tempbuf, 32, "%ld", i + 1); + for (int i = 0; i < playerswhenstarted; i++) + { + int xfragtotal = 0; + mysnprintf(tempbuf, 32, "%ld", i + 1); - MiniText(30, 90 + t, tempbuf, 0); - MiniText(38, 90 + t, g_player[i].user_name, 0, -1, ps[i].palookup); + MiniText(30, 90 + t, tempbuf, 0); + MiniText(38, 90 + t, g_player[i].user_name, 0, -1, ps[i].palookup); - for (int y = 0; y < playerswhenstarted; y++) - { - int frag = g_player[i].frags[y];// frags[i][y]); - if (i == y) - { - mysnprintf(tempbuf, 32, "%-4ld", ps[y].fraggedself); - MiniText(92 + (y * 23), 90 + t, tempbuf, 0); - xfragtotal -= ps[y].fraggedself; - } - else - { - mysnprintf(tempbuf, 32, "%-4ld", frag); - MiniText(92 + (y * 23), 90 + t, tempbuf, 0); - xfragtotal += frag; - } - /* - if (myconnectindex == connecthead) - { - mysnprintf(tempbuf, 32, "stats %ld killed %ld %ld\n", i + 1, y + 1, frag); - sendscore(tempbuf); - } - */ - } + for (int y = 0; y < playerswhenstarted; y++) + { + int frag = g_player[i].frags[y];// frags[i][y]); + if (i == y) + { + mysnprintf(tempbuf, 32, "%-4ld", ps[y].fraggedself); + MiniText(92 + (y * 23), 90 + t, tempbuf, 0); + xfragtotal -= ps[y].fraggedself; + } + else + { + mysnprintf(tempbuf, 32, "%-4ld", frag); + MiniText(92 + (y * 23), 90 + t, tempbuf, 0); + xfragtotal += frag; + } + /* + if (myconnectindex == connecthead) + { + mysnprintf(tempbuf, 32, "stats %ld killed %ld %ld\n", i + 1, y + 1, frag); + sendscore(tempbuf); + } + */ + } - mysnprintf(tempbuf, 32, "%-4ld", xfragtotal); - MiniText(101 + (8 * 23), 90 + t, tempbuf, 0); + mysnprintf(tempbuf, 32, "%-4ld", xfragtotal); + MiniText(101 + (8 * 23), 90 + t, tempbuf, 0); - t += 7; - } + t += 7; + } - for (int y = 0; y < playerswhenstarted; y++) - { - int yfragtotal = 0; - for (int i = 0; i < playerswhenstarted; i++) - { - if (i == y) - yfragtotal += ps[i].fraggedself; - int frag = g_player[i].frags[y];// frags[i][y]); - yfragtotal += frag; - } - mysnprintf(tempbuf, 32, "%-4ld", yfragtotal); - MiniText(92 + (y * 23), 96 + (8 * 7), tempbuf, 0); - } + for (int y = 0; y < playerswhenstarted; y++) + { + int yfragtotal = 0; + for (int i = 0; i < playerswhenstarted; i++) + { + if (i == y) + yfragtotal += ps[i].fraggedself; + int frag = g_player[i].frags[y];// frags[i][y]); + yfragtotal += frag; + } + mysnprintf(tempbuf, 32, "%-4ld", yfragtotal); + MiniText(92 + (y * 23), 96 + (8 * 7), tempbuf, 0); + } - MiniText(45, 96 + (8 * 7), GStrings("Deaths"), 0); - return skiprequest ? -1 : 1; - } + MiniText(45, 96 + (8 * 7), GStrings("Deaths"), 0); + return skiprequest ? -1 : 1; + } }; //--------------------------------------------------------------------------- @@ -352,182 +352,173 @@ public: class DRRLevelSummaryScreen : public DScreenJob { - const char* lastmapname; - int gfx_offset; - int bonuscnt = 0; + const char* lastmapname; + int gfx_offset; + int bonuscnt = 0; - void SetTotalClock(int tc) - { - SetClock(tc * (uint64_t)1'000'000'000 / 120); - } + void SetTotalClock(int tc) + { + SetClock(tc * (uint64_t)1'000'000'000 / 120); + } public: - DRRLevelSummaryScreen(bool dofadeout = true) : DScreenJob(dofadeout? (fadein | fadeout) : fadein) - { - PlayBonusMusic(); - if (boardfilename[0]) - gfx_offset = RRTILE403; - else if (!isRRRA()) - gfx_offset = RRTILE403 + clamp((currentLevel->levelNumber / 100) * 7 + (currentLevel->levelNumber % 100), 0, 13); - else - gfx_offset = LEVELMAP + clamp((currentLevel->levelNumber / 100) * 7 + (currentLevel->levelNumber % 100), 0, 13); - + DRRLevelSummaryScreen(bool dofadeout = true) : DScreenJob(dofadeout? (fadein | fadeout) : fadein) + { + PlayBonusMusic(); + if (currentLevel->flags & MI_USERMAP) + gfx_offset = RRTILE403; + else if (!isRRRA()) + gfx_offset = RRTILE403 + clamp((currentLevel->levelNumber / 100) * 7 + (currentLevel->levelNumber % 100), 0, 13); + else + gfx_offset = LEVELMAP + clamp((currentLevel->levelNumber / 100) * 7 + (currentLevel->levelNumber % 100), 0, 13); + - if (ud.volume_number == 0 && ud.last_level == 8 && boardfilename[0]) // todo: get rid of this awful hack. - { - lastmapname = strrchr(boardfilename, '\\'); - if (!lastmapname) lastmapname = strrchr(boardfilename, '/'); - if (!lastmapname) lastmapname = boardfilename; - } - else - { - lastmapname = currentLevel->DisplayName(); - } - } + lastmapname = currentLevel->DisplayName(); + } - void FormatTime(int time, char* tempbuf) - { - mysnprintf(tempbuf, 32, "%02ld:%02ld", (time / (26 * 60)) % 60, (time / 26) % 60); - } + void FormatTime(int time, char* tempbuf) + { + mysnprintf(tempbuf, 32, "%02ld:%02ld", (time / (26 * 60)) % 60, (time / 26) % 60); + } - void PrintTime(int totalclock) - { - char tempbuf[32]; - BigText(30, 48, GStrings("TXT_YerTime"), -1); - BigText(30, 64, GStrings("TXT_ParTime"), -1); - BigText(30, 80, GStrings("TXT_XTRTIME"), -1); + void PrintTime(int totalclock) + { + char tempbuf[32]; + BigText(30, 48, GStrings("TXT_YerTime"), -1); + BigText(30, 64, GStrings("TXT_ParTime"), -1); + BigText(30, 80, GStrings("TXT_XTRTIME"), -1); - if (bonuscnt == 0) - bonuscnt++; + if (bonuscnt == 0) + bonuscnt++; - if (totalclock > (60 * 4)) - { - if (bonuscnt == 1) - { - bonuscnt++; - S_PlaySound(404, CHAN_AUTO, CHANF_UI); - } - FormatTime(ps[myconnectindex].player_par, tempbuf); - BigText(191, 48, tempbuf, -1); + if (totalclock > (60 * 4)) + { + if (bonuscnt == 1) + { + bonuscnt++; + S_PlaySound(404, CHAN_AUTO, CHANF_UI); + } + FormatTime(ps[myconnectindex].player_par, tempbuf); + BigText(191, 48, tempbuf, -1); - FormatTime(currentLevel->parTime, tempbuf); - BigText(191, 64, tempbuf, -1); + FormatTime(currentLevel->parTime, tempbuf); + BigText(191, 64, tempbuf, -1); - if (!isNamWW2GI()) - { - FormatTime(currentLevel->designerTime, tempbuf); - BigText(191, 80, tempbuf, -1); - } - } - } + if (!isNamWW2GI()) + { + FormatTime(currentLevel->designerTime, tempbuf); + BigText(191, 80, tempbuf, -1); + } + } + } - void PrintKills(int totalclock) - { - BigText(30, 112, GStrings("TXT_VarmintsKilled"), -1); - BigText(30, 128, GStrings("TXT_VarmintsLeft"), -1); + void PrintKills(int totalclock) + { + BigText(30, 112, GStrings("TXT_VarmintsKilled"), -1); + BigText(30, 128, GStrings("TXT_VarmintsLeft"), -1); - if (bonuscnt == 2) - bonuscnt++; + if (bonuscnt == 2) + bonuscnt++; - if (totalclock > (60 * 7)) - { - if (bonuscnt == 3) - { - bonuscnt++; - S_PlaySound(442, CHAN_AUTO, CHANF_UI); - } - mysnprintf(tempbuf, 32, "%-3ld", ps[myconnectindex].actors_killed); - BigText(231, 112, tempbuf, -1); - if (ud.player_skill > 3) - { - mysnprintf(tempbuf, 32, GStrings("TXT_N_A")); - BigText(231, 128, tempbuf, -1); - } - else - { - if ((ps[myconnectindex].max_actors_killed - ps[myconnectindex].actors_killed) < 0) - mysnprintf(tempbuf, 32, "%-3ld", 0); - else mysnprintf(tempbuf, 32, "%-3ld", ps[myconnectindex].max_actors_killed - ps[myconnectindex].actors_killed); - BigText(231, 128, tempbuf, -1); - } - } - } + if (totalclock > (60 * 7)) + { + if (bonuscnt == 3) + { + bonuscnt++; + S_PlaySound(442, CHAN_AUTO, CHANF_UI); + } + mysnprintf(tempbuf, 32, "%-3ld", ps[myconnectindex].actors_killed); + BigText(231, 112, tempbuf, -1); + if (ud.player_skill > 3) + { + mysnprintf(tempbuf, 32, GStrings("TXT_N_A")); + BigText(231, 128, tempbuf, -1); + } + else + { + if ((ps[myconnectindex].max_actors_killed - ps[myconnectindex].actors_killed) < 0) + mysnprintf(tempbuf, 32, "%-3ld", 0); + else mysnprintf(tempbuf, 32, "%-3ld", ps[myconnectindex].max_actors_killed - ps[myconnectindex].actors_killed); + BigText(231, 128, tempbuf, -1); + } + } + } - void PrintSecrets(int totalclock) - { - BigText(30, 144, GStrings("TXT_SECFND"), -1); - BigText(30, 160, GStrings("TXT_SECMISS"), -1); - if (bonuscnt == 4) bonuscnt++; + void PrintSecrets(int totalclock) + { + BigText(30, 144, GStrings("TXT_SECFND"), -1); + BigText(30, 160, GStrings("TXT_SECMISS"), -1); + if (bonuscnt == 4) bonuscnt++; - if (totalclock > (60 * 10)) - { - if (bonuscnt == 5) - { - bonuscnt++; - S_PlaySound(404, CHAN_AUTO, CHANF_UI); - } - mysnprintf(tempbuf, 32, "%-3d", ps[myconnectindex].secret_rooms); - BigText(231, 144, tempbuf, -1); - if (ps[myconnectindex].secret_rooms > 0) - sprintf(tempbuf, "%-3d", (100 * ps[myconnectindex].secret_rooms / ps[myconnectindex].max_secret_rooms)); - mysnprintf(tempbuf, 32, "%-3d", ps[myconnectindex].max_secret_rooms - ps[myconnectindex].secret_rooms); - BigText(231, 160, tempbuf, -1); - } - } + if (totalclock > (60 * 10)) + { + if (bonuscnt == 5) + { + bonuscnt++; + S_PlaySound(404, CHAN_AUTO, CHANF_UI); + } + mysnprintf(tempbuf, 32, "%-3d", ps[myconnectindex].secret_rooms); + BigText(231, 144, tempbuf, -1); + if (ps[myconnectindex].secret_rooms > 0) + sprintf(tempbuf, "%-3d", (100 * ps[myconnectindex].secret_rooms / ps[myconnectindex].max_secret_rooms)); + mysnprintf(tempbuf, 32, "%-3d", ps[myconnectindex].max_secret_rooms - ps[myconnectindex].secret_rooms); + BigText(231, 160, tempbuf, -1); + } + } - int Frame(uint64_t clock, bool skiprequest) - { - twod->ClearScreen(); - int totalclock = int(clock * 120 / 1'000'000'000); - DrawTexture(twod, tileGetTexture(gfx_offset, true), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); + int Frame(uint64_t clock, bool skiprequest) + { + twod->ClearScreen(); + int totalclock = int(clock * 120 / 1'000'000'000); + DrawTexture(twod, tileGetTexture(gfx_offset, true), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); - if (lastmapname) BigText(80, 16, lastmapname, -1); - BigText(15, 192, GStrings("PRESSKEY"), -1); + if (lastmapname) BigText(80, 16, lastmapname, -1); + BigText(15, 192, GStrings("PRESSKEY"), -1); - if (totalclock > (60 * 3)) - { - PrintTime(totalclock); - } - if (totalclock > (60 * 6)) - { - PrintKills(totalclock); - } - if (totalclock > (60 * 9)) - { - PrintSecrets(totalclock); - } + if (totalclock > (60 * 3)) + { + PrintTime(totalclock); + } + if (totalclock > (60 * 6)) + { + PrintKills(totalclock); + } + if (totalclock > (60 * 9)) + { + PrintSecrets(totalclock); + } - if (totalclock > (1000000000L) && totalclock < (1000000320L)) - { - int val = (totalclock >> 4) % 15; - if (val == 0) - { - if (bonuscnt == 6) - { - bonuscnt++; - S_PlaySound(425, CHAN_AUTO, CHANF_UI); - S_PlaySound(BONUS_SPEECH1 + (rand() & 3), CHAN_AUTO, CHANF_UI); - } - } - } - else if (totalclock > (10240 + 120L)) return 0; + if (totalclock > (1000000000L) && totalclock < (1000000320L)) + { + int val = (totalclock >> 4) % 15; + if (val == 0) + { + if (bonuscnt == 6) + { + bonuscnt++; + S_PlaySound(425, CHAN_AUTO, CHANF_UI); + S_PlaySound(BONUS_SPEECH1 + (rand() & 3), CHAN_AUTO, CHANF_UI); + } + } + } + else if (totalclock > (10240 + 120L)) return 0; - if (totalclock > 10240 && totalclock < 10240 + 10240) - SetTotalClock(1024); + if (totalclock > 10240 && totalclock < 10240 + 10240) + SetTotalClock(1024); - if (skiprequest && totalclock > (60 * 2)) - { - skiprequest = false; - if (totalclock < (60 * 13)) - { - SetTotalClock(60 * 13); - } - else if (totalclock < (1000000000)) - SetTotalClock(1000000000); - } + if (skiprequest && totalclock > (60 * 2)) + { + skiprequest = false; + if (totalclock < (60 * 13)) + { + SetTotalClock(60 * 13); + } + else if (totalclock < (1000000000)) + SetTotalClock(1000000000); + } - return 1; - } + return 1; + } }; @@ -535,23 +526,23 @@ public: class DRRRAEndOfGame : public DScreenJob { public: - DRRRAEndOfGame() : DScreenJob(fadein|fadeout) - { - S_PlaySound(35, CHAN_AUTO, CHANF_UI); - } - int Frame(uint64_t clock, bool skiprequest) - { - int totalclock = int(clock * 120 / 1'000'000'000); - auto tex = tileGetTexture(RRTILE8677 + ((totalclock >> 4) & 1)); - DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, TAG_DONE); - if (!S_CheckSoundPlaying(-1, 35) && totalclock > 15*120) return 0; // make sure it stays, even if sound is off. - if (skiprequest) - { - S_StopSound(35); - return -1; - } - return 1; - } + DRRRAEndOfGame() : DScreenJob(fadein|fadeout) + { + S_PlaySound(35, CHAN_AUTO, CHANF_UI); + } + int Frame(uint64_t clock, bool skiprequest) + { + int totalclock = int(clock * 120 / 1'000'000'000); + auto tex = tileGetTexture(RRTILE8677 + ((totalclock >> 4) & 1)); + DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, TAG_DONE); + if (!S_CheckSoundPlaying(-1, 35) && totalclock > 15*120) return 0; // make sure it stays, even if sound is off. + if (skiprequest) + { + S_StopSound(35); + return -1; + } + return 1; + } }; //--------------------------------------------------------------------------- @@ -562,41 +553,41 @@ public: void dobonus_r(bool bonusonly, CompletionFunc completion) { - JobDesc jobs[20]; - int job = 0; + JobDesc jobs[20]; + int job = 0; - FX_StopAllSounds(); - Mus_Stop(); + FX_StopAllSounds(); + Mus_Stop(); - if (!bonusonly && !isRRRA() && numplayers < 2 && ud.eog && ud.from_bonus == 0) - { - bonussequence_r(ud.volume_number, jobs, job); - } + if (!bonusonly && !isRRRA() && numplayers < 2 && ud.eog && ud.from_bonus == 0) + { + bonussequence_r(ud.volume_number, jobs, job); + } - if (playerswhenstarted > 1 && ud.coop != 1) - { - jobs[job++] = { Create(playerswhenstarted) }; - } - else if (!bonusonly && ud.multimode <= 1) - { - if (isRRRA() && !boardfilename[0] && currentLevel->levelNumber < 106) // fixme: The logic here is awful. Shift more control to the map records. - { - jobs[job++] = { Create(true) }; - int levnum = clamp((currentLevel->levelNumber / 100) * 7 + (currentLevel->levelNumber % 100), 0, 13); - char fn[20]; - mysnprintf(fn, 20, "lvl%d.anm", levnum + 1); - static const int framespeed[] = { 20, 20, 7200 }; // wait for one minute on the final frame so that the video doesn't appear before the user notices. - jobs[job++] = { PlayVideo(fn, nullptr, framespeed) }; - if (ud.eog && currentLevel->levelNumber > 100) - { - jobs[job++] = { Create() }; - } - } - else jobs[job++] = { Create(false) }; - } - if (job) - RunScreenJob(jobs, job, completion); - else if (completion) completion(false); + if (playerswhenstarted > 1 && ud.coop != 1) + { + jobs[job++] = { Create(playerswhenstarted) }; + } + else if (!bonusonly && ud.multimode <= 1) + { + if (isRRRA() && !boardfilename[0] && currentLevel->levelNumber < 106) // fixme: The logic here is awful. Shift more control to the map records. + { + jobs[job++] = { Create(true) }; + int levnum = clamp((currentLevel->levelNumber / 100) * 7 + (currentLevel->levelNumber % 100), 0, 13); + char fn[20]; + mysnprintf(fn, 20, "lvl%d.anm", levnum + 1); + static const int framespeed[] = { 20, 20, 7200 }; // wait for one minute on the final frame so that the video doesn't appear before the user notices. + jobs[job++] = { PlayVideo(fn, nullptr, framespeed) }; + if (ud.eog && currentLevel->levelNumber > 100) + { + jobs[job++] = { Create() }; + } + } + else jobs[job++] = { Create(false) }; + } + if (job) + RunScreenJob(jobs, job, completion); + else if (completion) completion(false); } @@ -609,27 +600,19 @@ void dobonus_r(bool bonusonly, CompletionFunc completion) class DRRLoadScreen : public DScreenJob { std::function callback; - + std::function callback; + MapRecord* rec; + public: - DRRLoadScreen(const char *mapname_, std::function callback_) : DScreenJob(fadein|fadeout), callback(callback_) {} + DRRLoadScreen(MapRecord* maprec, std::function callback_) : DScreenJob(fadein | fadeout), callback(callback_), rec(maprec) {} int Frame(uint64_t clock, bool skiprequest) { DrawTexture(twod, tileGetTexture(LOADSCREEN), 0, 0, DTA_FullscreenEx, 3, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); int y = isRRRA()? 140 : 90; - // fixme: The level management needs a total overhaul! - if (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0) - { - BigText(160, y, GStrings("TXT_ENTRUM"), 0); - BigText(160, y+20, boardfilename, 0); - } - else - { - BigText(160, y, GStrings("TXT_ENTERIN"), 0); - // Fixme: This last level hack needs to go away!!! - BigText(160, y+24, mapList[g_lastLevel? 127 : (ud.volume_number * MAXLEVELS) + ud.level_number].DisplayName(), 0); - } + BigText(160, y, (rec->flags & MI_USERMAP) ? GStrings("TXT_ENTRUM") : GStrings("TXT_ENTERIN"), 0); + BigText(160, y+24, rec->DisplayName(), 0); // Initiate the level load once the page has been faded in completely. if (callback && GetFadeState() == visible) @@ -644,55 +627,55 @@ public: void PrintPaused_r() { - BigText(160, 100, GStrings("Game Paused"), 0); + BigText(160, 100, GStrings("Game Paused"), 0); } void PrintLevelName_r(double alpha) { - BigText(160, 114, currentLevel->DisplayName(), 0, alpha); + BigText(160, 114, currentLevel->DisplayName(), 0, alpha); } // Utility for testing the above screens CCMD(testrscreen) { - JobDesc jobs[10]; - int job = 0; - C_HideConsole(); - FX_StopAllSounds(); - Mus_Stop(); - if (argv.argc() > 1) - { - int screen = strtol(argv[1], nullptr, 0); - switch (screen) - { - case 0: - case 1: - if (!isRRRA()) - { - bonussequence_r(screen, jobs, job); - RunScreenJob(jobs, job, nullptr); - } - break; + JobDesc jobs[10]; + int job = 0; + C_HideConsole(); + FX_StopAllSounds(); + Mus_Stop(); + if (argv.argc() > 1) + { + int screen = strtol(argv[1], nullptr, 0); + switch (screen) + { + case 0: + case 1: + if (!isRRRA()) + { + bonussequence_r(screen, jobs, job); + RunScreenJob(jobs, job, nullptr); + } + break; - case 2: - jobs[job++] = { Create(6) }; - RunScreenJob(jobs, job, nullptr); - break; + case 2: + jobs[job++] = { Create(6) }; + RunScreenJob(jobs, job, nullptr); + break; - case 3: - jobs[job++] = { Create() }; - RunScreenJob(jobs, job, nullptr); - break; + case 3: + jobs[job++] = { Create() }; + RunScreenJob(jobs, job, nullptr); + break; - case 4: - jobs[job++] = { Create() }; - RunScreenJob(jobs, job, nullptr); - break; + case 4: + jobs[job++] = { Create() }; + RunScreenJob(jobs, job, nullptr); + break; - default: - break; - } - } + default: + break; + } + } } diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index dcf666206..54528fab6 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -192,6 +192,8 @@ void resetprestat(int snum, int g); void clearfifo(void); void setmapfog(int fogtype); void prelevel_common(int g); +void cacheit_d(); +void cacheit_r(); void FTA(int q, struct player_struct* p); void OnMotorcycle(player_struct *pl, int snum); @@ -211,5 +213,6 @@ void displayrest(int32_t smoothratio); void drawbackground(void); void displayrooms(int32_t playerNum, int32_t smoothratio); void setgamepalette(int palid); +void resetmys(); END_DUKE_NS diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index 19f28f934..94f0a4ac1 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -47,18 +47,6 @@ extern int rtsplaying; extern char boardfilename[BMAX_PATH]; #define USERMAPMUSICFAKEVOLUME MAXVOLUMES #define USERMAPMUSICFAKELEVEL (MAXLEVELS-1) -#define USERMAPMUSICFAKESLOT ((USERMAPMUSICFAKEVOLUME * MAXLEVELS) + USERMAPMUSICFAKELEVEL) - -// Need to do this differently, set to false to allow transitioning away from the current mess. -static inline int G_HaveUserMap(void) -{ - return false; // (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0); -} - -static inline int Menu_HaveUserMap(void) -{ - return false;// (boardfilename[0] != 0 && m_level_number == 7 && ud.m_volume_number == 0); -} extern int32_t g_Shareware; extern int32_t cameraclock; diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index a15c295a0..4c5af6838 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -772,9 +772,9 @@ void drawoverheadmap(int cposx, int cposy, int czoom, int cang) { double scale = isRR() ? 0.5 : 1.; int top = isRR() ? 0 : ((ud.screen_size > 0) ? 147 : 179); - if (!G_HaveUserMap()) - DrawText(twod, SmallFont2, CR_UNDEFINED, 5, top+6, GStrings.localize(gVolumeNames[ud.volume_number]), - DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); + if (!(currentLevel->flags & MI_USERMAP)) + DrawText(twod, SmallFont2, CR_UNDEFINED, 5, top+6, GStrings.localize(gVolumeNames[ud.volume_number]), + DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); DrawText(twod, SmallFont2, CR_UNDEFINED, 5, top + 12, currentLevel->DisplayName(), DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); } diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 10500b8f3..67c06b5e0 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -157,6 +157,11 @@ inline void SetPlayerPal(player_struct* p, PalEntry pe) p->pals = pe; } +constexpr inline int levelnum(int vol, int map) +{ + return vol * 1000 + map; +} + //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index fef1bba6e..038174df1 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -742,5 +742,180 @@ void prelevel_common(int g) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void resettimevars(void) +{ + totalclock = 0; + cloudtotalclock = 0; + ototalclock = 0; + lockclock = 0; + ready2send = 1; + if (camsprite >= 0) + hittype[camsprite].temp_data[0] = 0; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode) +{ + int16_t lbang; + if (VOLUMEONE && (mi->flags & MI_USERMAP)) + { + Printf(TEXTCOLOR_RED "Cannot load user maps with shareware version!\n"); + return 1; + } + + if (engineLoadBoard(mi->fileName, VOLUMEONE, &p->pos, &lbang, &p->cursectnum) < 0) + { + Printf(TEXTCOLOR_RED "Map \"%s\" not found or invalid map version!\n", mi->fileName.GetChars()); + return 1; + } + currentLevel = mi; + SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); + STAT_NewLevel(mi->fileName); + G_LoadMapHack(mi->fileName); + + if (isRR() && !isRRRA() && mi->levelNumber == levelnum(1, 1)) + { + for (int i = PISTOL_WEAPON; i < MAX_WEAPONS; i++) + ps[0].ammo_amount[i] = 0; + ps[0].gotweapon.Clear(KNEE_WEAPON); + } + p->setang(lbang); + + memset(gotpic, 0, sizeof(gotpic)); + + if (isRR()) prelevel_r(gamemode); + else prelevel_d(gamemode); + + G_InitRRRASkies(); + + if (isRRRA() && mi->levelNumber == levelnum(2, 0)) + { + for (int i = PISTOL_WEAPON; i < MAX_WEAPONS; i++) + ps[0].ammo_amount[i] = 0; + ps[0].gotweapon.Clear(KNEE_WEAPON); + ps[0].gotweapon.Set(SLINGBLADE_WEAPON); + ps[0].ammo_amount[SLINGBLADE_WEAPON] = 1; + ps[0].curr_weapon = SLINGBLADE_WEAPON; + } + + allignwarpelevators(); + resetpspritevars(gamemode); + + if (isRR()) cacheit_r(); else cacheit_d(); + return 0; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int enterlevel(MapRecord *mi, int gamemode) +{ +// flushpackets(); +// waitforeverybody(); + + ud.respawn_monsters = ud.m_respawn_monsters; + ud.respawn_items = ud.m_respawn_items; + ud.respawn_inventory = ud.m_respawn_inventory; + ud.monsters_off = ud.m_monsters_off; + ud.coop = ud.m_coop; + ud.marker = ud.m_marker; + ud.ffire = ud.m_ffire; + + if ((gamemode & MODE_DEMO) == 0 && ud.recstat == 2) + ud.recstat = 0; + + OnEvent(EVENT_ENTERLEVEL); + + // Stop all sounds + S_PauseSounds(false); + FX_StopAllSounds(); + FX_SetReverb(0); + + struct player_struct *const p = g_player[0].ps; + + + /* + G_DoLoadScreen(msg, -1); // this should be done outside of this function later. + */ + int res = LoadTheMap(mi, p, gamemode); + if (res != 0) return res; + + // Try this first so that it can disable the CD player if no tracks are found. + if (isRR() && !(gamemode & MODE_DEMO)) + S_PlayRRMusic(); + + if (ud.recstat != 2) + { + S_PlayLevelMusic(mi); + } + + if (gamemode & (MODE_GAME|MODE_EOL)) + { + ps[myconnectindex].gm = MODE_GAME; + } + else if (gamemode & MODE_RESTART) + { + if (ud.recstat == 2) + ps[myconnectindex].gm = MODE_DEMO; + else ps[myconnectindex].gm = MODE_GAME; + } + + if (VOLUMEONE && mi->levelNumber == 0 && ud.recstat != 2) FTA(QUOTE_F1HELP, &ps[myconnectindex]); + + for (int i = connecthead; i >= 0; i = connectpoint2[i]) + { + int pn = sector[sprite[ps[i].i].sectnum].floorpicnum; + if (pn == TILE_HURTRAIL || pn == TILE_FLOORSLIME || pn == TILE_FLOORPLASMA) + { + resetweapons(i); + resetinventory(i); + ps[i].gotweapon.Clear(PISTOL_WEAPON); + ps[i].ammo_amount[PISTOL_WEAPON] = 0; + ps[i].curr_weapon = KNEE_WEAPON; + ps[i].kickback_pic = 0; + } + } + resetmys(); + setpal(&ps[myconnectindex]); + + everyothertime = 0; + global_random = 0; + + ud.last_level = ud.level_number+1; + clearfifo(); + for (int i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; + ps[myconnectindex].over_shoulder_on = 0; + clearfrags(); + resettimevars(); // Here we go + Printf(TEXTCOLOR_GOLD "%s: %s\n", mi->LabelName(), mi->DisplayName()); + return 0; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void setmapfog(int fogtype) +{ + GLInterface.SetMapFog(fogtype != 0); +} + + END_DUKE_NS \ No newline at end of file diff --git a/source/games/duke/src/premap.h b/source/games/duke/src/premap.h index d53788918..7b9bb5947 100644 --- a/source/games/duke/src/premap.h +++ b/source/games/duke/src/premap.h @@ -23,11 +23,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef premap_h_ #define premap_h_ +struct MapRecord; + BEGIN_DUKE_NS extern int16_t ambientlotag[64]; extern int16_t ambienthitag[64]; -int G_EnterLevel(int gameMode); +int G_EnterLevel(MapRecord *mi, int gameMode); int G_FindLevelByFile(const char *fileName); void G_NewGame(int volumeNum, int levelNum, int skillNum); void G_ResetTimers(uint8_t keepgtics); diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index c09760b1b..c6e54ff8d 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -507,184 +507,4 @@ void prelevel_d(int g) } } - -#if 0 - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void enterlevel(char g) -{ - short i,j; - long l; - char levname[256]; - - if( (g&MODE_DEMO) != MODE_DEMO ) ud.recstat = ud.m_recstat; - ud.respawn_monsters = ud.m_respawn_monsters; - ud.respawn_items = ud.m_respawn_items; - ud.respawn_inventory = ud.m_respawn_inventory; - ud.monsters_off = ud.m_monsters_off; - ud.coop = ud.m_coop; - ud.marker = ud.m_marker; - ud.ffire = ud.m_ffire; - -#ifdef WW2 -//sprintf(g_szBuf,"ENTERLEVEL L=%d V=%d",ud.level_number, ud.volume_number); -//AddLog(g_szBuf); - // variables are set by pointer... - OnEvent(EVENT_ENTERLEVEL, -1, -1, -1); -#endif - if( (g&MODE_DEMO) == 0 && ud.recstat == 2) - ud.recstat = 0; - - FX_StopAllSounds(); - clearsoundlocks(); - FX_SetReverb(0); - - dofrontscreens(); - vscrn(); - -#ifndef VOLUMEONE - - if( boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0 ) - { - if ( loadboard( boardfilename,&ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang,&ps[0].cursectnum ) == -1 ) - { - initprintf("Map %s not found!\n",boardfilename); - //gameexit(tempbuf); - return 1; - } else { - char *p; - strcpy(levname, boardfilename); - p = Bstrrchr(levname,'.'); - if (!p) strcat(levname,".mhk"); - else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } - if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); - } - } - else if ( loadboard( level_file_names[ (ud.volume_number*11)+ud.level_number],&ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang,&ps[0].cursectnum ) == -1) - { - initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]); - //gameexit(tempbuf); - return 1; - } else { - char *p; - strcpy(levname, level_file_names[ (ud.volume_number*11)+ud.level_number]); - p = Bstrrchr(levname,'.'); - if (!p) strcat(levname,".mhk"); - else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } - if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); - } - -#else - - l = strlen(level_file_names[ (ud.volume_number*11)+ud.level_number]); - copybufbyte( level_file_names[ (ud.volume_number*11)+ud.level_number],&levname[0],l); - levname[l] = 255; - levname[l+1] = 0; - - if ( loadboard( levname,&ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang,&ps[0].cursectnum ) == -1) - { - initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]); - //gameexit(tempbuf); - return 1; - } else { - char *p; - p = Bstrrchr(levname,'.'); - if (!p) strcat(levname,".mhk"); - else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } - if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); - } -#endif - - clearbufbyte(gotpic,sizeof(gotpic),0L); - - prelevel(g); - - allignwarpelevators(); - resetpspritevars(g); - - cachedebug = 0; - automapping = 0; - - if(ud.recstat != 2) MUSIC_StopSong(); - - cacheit(); - - if(ud.recstat != 2) - { - music_select = (ud.volume_number*11) + ud.level_number; - playmusic(&music_fn[0][music_select][0]); - } - - if( (g&MODE_GAME) || (g&MODE_EOL) ) - ps[myconnectindex].gm = MODE_GAME; - else if(g&MODE_RESTART) - { - if(ud.recstat == 2) - ps[myconnectindex].gm = MODE_DEMO; - else ps[myconnectindex].gm = MODE_GAME; - } - - if( (ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART ) - opendemowrite(); - -#ifdef VOLUMEONE - if(ud.level_number == 0 && ud.recstat != 2) FTA(40,&ps[myconnectindex]); -#endif - - for(i=connecthead;i>=0;i=connectpoint2[i]) - switch(sector[sprite[ps[i].i].sectnum].floorpicnum) - { - case HURTRAIL: - case FLOORSLIME: - case FLOORPLASMA: - resetweapons(i); - resetinventory(i); - ps[i].gotweapon[PISTOL_WEAPON] = 0; - ps[i].ammo_amount[PISTOL_WEAPON] = 0; - ps[i].curr_weapon = KNEE_WEAPON; - ps[i].kickback_pic = 0; - break; - } - - //PREMAP.C - replace near the my's at the end of the file - - resetmys(); - - ps[myconnectindex].palette = palette; - palto(0,0,0,0); - - setpal(&ps[myconnectindex]); - flushperms(); - - everyothertime = 0; - global_random = 0; - - ud.last_level = ud.level_number+1; - - clearfifo(); - - for(i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; - - flushpackets(); - waitforeverybody(); - - palto(0,0,0,0); - vscrn(); - clearview(0L); - displayrooms(myconnectindex,65536); - displayrest(screenpeek); - - ps[myconnectindex].over_shoulder_on = 0; - - clearfrags(); - - resettimevars(); // Here we go -} -#endif - END_DUKE_NS \ No newline at end of file diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 0b51ee283..ab7c9cc2a 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -812,191 +812,4 @@ void prelevel_r(int g) } - - -#if 0 - - - -#if 0 -void enterlevel(char g) -{ - short i, j; - long l; - char levname[256]; - - if ((g & MODE_DEMO) != MODE_DEMO) ud.recstat = ud.m_recstat; - ud.respawn_monsters = ud.m_respawn_monsters; - ud.respawn_items = ud.m_respawn_items; - ud.respawn_inventory = ud.m_respawn_inventory; - ud.monsters_off = ud.m_monsters_off; - ud.coop = ud.m_coop; - ud.marker = ud.m_marker; - ud.ffire = ud.m_ffire; - - if ((g & MODE_DEMO) == 0 && ud.recstat == 2) - ud.recstat = 0; - - dofrontscreens(); - vscrn(); - - if (lastlevel) - { - if (loadboard("endgame.map", &ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang, &ps[0].cursectnum) == -1) - { - sprintf(tempbuf, "Map %s not found!", boardfilename); - gameexit(tempbuf); - } - } - else - { - if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) - { - if (loadboard(boardfilename, &ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang, &ps[0].cursectnum) == -1) - { - sprintf(tempbuf, "Map %s not found!", boardfilename); - gameexit(tempbuf); - } - } - else if (loadboard(level_file_names[(ud.volume_number * 7) + ud.level_number], &ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang, &ps[0].cursectnum) == -1) - { - sprintf(tempbuf, "Map %s not found!", level_file_names[(ud.volume_number * 8) + ud.level_number]); - gameexit(tempbuf); - } - } - -} -#endif - - -void loadlevel(const char *filename) - - -#ifndef RRRA - if (ud.volume_number == 1 && ud.level_number == 1) - { - short ii; - for (ii = PISTOL_WEAPON; ii < MAX_WEAPONS; ii++) - ps[0].gotweapon[ii] = 0; - for (ii = PISTOL_WEAPON; ii < MAX_WEAPONS; ii++) - ps[0].ammo_amount[ii] = 0; - } -#endif - - clearbufbyte(gotpic,sizeof(gotpic),0L); - - prelevel(g); - -#ifdef RRRA - if (ud.level_number == 2 && ud.volume_number == 0) - { - short ii; - for (ii = PISTOL_WEAPON; ii < MAX_WEAPONS; ii++) - ps[0].gotweapon[ii] = 0; - for (ii = PISTOL_WEAPON; ii < MAX_WEAPONS; ii++) - ps[0].ammo_amount[ii] = 0; - ps[0].gotweapon[RA15_WEAPON] = 1; - ps[0].ammo_amount[RA15_WEAPON] = 1; - ps[0].curr_weapon = RA15_WEAPON; - } -#endif - - allignwarpelevators(); - resetpspritevars(g); - - cachedebug = 0; - automapping = 0; - - cacheit(); - docacheit(); - - if (globalskillsound >= 0) - { - while (Sound[globalskillsound].lock >= 200); - } - globalskillsound = -1; - - FX_StopAllSounds(); - clearsoundlocks(); - FX_SetReverb(0); - - if( (g&MODE_GAME) || (g&MODE_EOL) ) - ps[myconnectindex].gm = MODE_GAME; - else if(g&MODE_RESTART) - { - if(ud.recstat == 2) - ps[myconnectindex].gm = MODE_DEMO; - else ps[myconnectindex].gm = MODE_GAME; - } - - if( (ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART ) - opendemowrite(); - - for(i=connecthead;i>=0;i=connectpoint2[i]) - switch(sector[sprite[ps[i].i].sectnum].floorpicnum) - { - case HURTRAIL: - case FLOORSLIME: - case FLOORPLASMA: - resetweapons(i); - resetinventory(i); - ps[i].gotweapon[PISTOL_WEAPON] = 0; - ps[i].ammo_amount[PISTOL_WEAPON] = 0; - ps[i].curr_weapon = KNEE_WEAPON; - ps[i].kickback_pic = 0; - break; - } - - //PREMAP.C - replace near the my's at the end of the file - myx = omyx = ps[myconnectindex].posx; - myy = omyy = ps[myconnectindex].posy; - myz = omyz = ps[myconnectindex].posz; - myxvel = myyvel = myzvel = 0; - myang = omyang = ps[myconnectindex].ang; - myhoriz = omyhoriz = ps[myconnectindex].horiz; - myhorizoff = omyhorizoff = ps[myconnectindex].horizoff; - mycursectnum = ps[myconnectindex].cursectnum; - myjumpingcounter = ps[myconnectindex].jumping_counter; - myjumpingtoggle = ps[myconnectindex].jumping_toggle; - myonground = ps[myconnectindex].on_ground; - myhardlanding = ps[myconnectindex].hard_landing; - myreturntocenter = ps[myconnectindex].return_to_center; - - ps[myconnectindex].palette = palette; - palto(0,0,0,0); - - setpal(&ps[myconnectindex]); - flushperms(); - - everyothertime = 0; - global_random = 0; - - ud.last_level = ud.level_number+1; - - clearfifo(); - - for(i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; - - flushpackets(); - waitforeverybody(); - - palto(0,0,0,0); - vscrn(); - clearview(0L); - displayrooms(screenpeek,65536); - displayrest(screenpeek); - nextpage(); - - if (waitabort == 1) - gameexit(" "); - ps[myconnectindex].over_shoulder_on = 0; - - clearfrags(); - - resettimevars(); // Here we go -} -#endif - - - END_DUKE_NS diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 909971e65..b954deda2 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -579,11 +579,10 @@ void S_MenuSound(void) static bool cd_disabled = false; // This is in case mus_redbook is enabled but no tracks found so that the regular music system can be switched on. -void S_PlayLevelMusic(unsigned int m) +void S_PlayLevelMusic(MapRecord *mi) { - auto& mr = m == USERMAPMUSICFAKESLOT ? userMapRecord : mapList[m]; - if (isRR() && mr.music.IsEmpty() && mus_redbook && !cd_disabled) return; - Mus_Play(mr.labelName, mr.music, true); + if (isRR() && mi->music.IsEmpty() && mus_redbook && !cd_disabled) return; + Mus_Play(mi->labelName, mi->music, true); } void S_PlaySpecialMusic(unsigned int m) diff --git a/source/games/duke/src/sounds.h b/source/games/duke/src/sounds.h index d438ead33..2fed8c7ec 100644 --- a/source/games/duke/src/sounds.h +++ b/source/games/duke/src/sounds.h @@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "raze_sound.h" #include "raze_music.h" +struct MapRecord; BEGIN_DUKE_NS @@ -69,7 +70,7 @@ void cacheAllSounds(void); void S_MenuSound(void); void S_PauseMusic(bool paused); void S_PauseSounds(bool paused); -void S_PlayLevelMusic(unsigned int); +void S_PlayLevelMusic(MapRecord* mi); void S_PlaySpecialMusic(unsigned int); void S_ContinueLevelMusic(void); int S_PlaySound(int num, int channel = CHAN_AUTO, EChanFlags flags = 0); diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 91f52a61a..4d6775f40 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -66,7 +66,7 @@ struct user_defs int m_respawn_items, m_respawn_monsters, m_respawn_inventory, m_recstat, m_monsters_off, detail; int m_ffire, ffire, m_player_skill, /*m_level_number, m_volume_number,*/ multimode; int player_skill, level_number, volume_number, m_marker, marker, mouseflip; - int statusbarmode, noexits, althud, ShowOpponentWeapons; + int statusbarmode, althud, ShowOpponentWeapons; }; diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index 4f352fcab..c6333d4e3 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -34,18 +34,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS -extern int which_palookup; - -static int32_t g_precacheCount; -int32_t g_skillSoundVoice = -1; - - void G_InitRRRASkies(void) { if (!isRRRA()) return; - for (bssize_t i = 0; i < MAXSECTORS; i++) + for (int i = 0; i < MAXSECTORS; i++) { if (sector[i].ceilingpicnum != TILE_LA && sector[i].ceilingpicnum != TILE_MOONSKY1 && sector[i].ceilingpicnum != TILE_BIGORBIT1) { @@ -79,8 +73,6 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum) handleevents(); - g_skillSoundVoice = -1; - ready2send = 0; #if 0 @@ -104,7 +96,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum) ud.last_level = -1; - int const UserMap = Menu_HaveUserMap(); + int const UserMap = false;// Menu_HaveUserMap(); // we don't want the intro to play after the multiplayer setup screen if (!isRR() && (!g_netServer && ud.multimode < 2) && UserMap == 0 && @@ -127,7 +119,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum) if (m_coop != 1) { - for (bssize_t weaponNum = 0; weaponNum < 12/*MAX_WEAPONS*/; weaponNum++) + for (int weaponNum = 0; weaponNum < 12/*MAX_WEAPONS*/; weaponNum++) { auto const worksLike = isWW2GI() ? PWEAPON(0, weaponNum, WorksLike) : weaponNum; if (worksLike == PISTOL_WEAPON) @@ -153,7 +145,7 @@ void resetpspritevars(int gameMode); static inline void clearfrags(void) { - for (bssize_t i = 0; i < ud.multimode; i++) + for (int i = 0; i < ud.multimode; i++) { playerdata_t *const pPlayerData = &g_player[i]; pPlayerData->ps->frag = pPlayerData->ps->fraggedself = 0; @@ -161,301 +153,5 @@ static inline void clearfrags(void) } } -void G_ResetTimers(uint8_t keepgtics) -{ - totalclock = cloudtotalclock = ototalclock = lockclock = 0; - ready2send = 1; - levelTextTime = 85; - - if (!keepgtics) - g_moveThingsCount = 0; - - if (camsprite >= 0) - hittype[camsprite].temp_data[0] = 0; -} - -int G_FindLevelByFile(const char *fileName) -{ - for (bssize_t volumeNum = 0; volumeNum < MAXVOLUMES; volumeNum++) - { - int const volOffset = volumeNum * MAXLEVELS; - - for (bssize_t levelNum = 0; levelNum < MAXLEVELS; levelNum++) - { - if (!mapList[volOffset + levelNum].fileName.CompareNoCase(fileName)) - return volOffset + levelNum; - } - } - - return MAXLEVELS * MAXVOLUMES; -} - -static int G_TryMapHack(const char *mhkfile) -{ - int32_t failure = engineLoadMHK(mhkfile); - - if (!failure) - Printf("Loaded map hack file \"%s\"\n", mhkfile); - - return failure; -} - -static void G_LoadMapHack(char *outbuf, const char *filename) -{ - if (filename != NULL) - Bstrcpy(outbuf, filename); - - append_ext_UNSAFE(outbuf, ".mhk"); - - if (G_TryMapHack(outbuf) && usermaphacks != NULL) - { - usermaphack_t *pMapInfo = (usermaphack_t*)bsearch( - &g_loadedMapHack, usermaphacks, num_usermaphacks, sizeof(usermaphack_t), - compare_usermaphacks); - - if (pMapInfo) - G_TryMapHack(pMapInfo->mhkfile); - } -} - -void cacheit_d(); -void cacheit_r(); - -static int LoadTheMap(MapRecord &mi, struct player_struct *pPlayer, int gameMode) -{ - char levelName[BMAX_PATH]; - int16_t lbang; - if (!VOLUMEONE && Menu_HaveUserMap()) - { - if (engineLoadBoard(boardfilename, 0, &pPlayer->pos, &lbang, &pPlayer->cursectnum) < 0) - { - Printf(TEXTCOLOR_RED "Map \"%s\" not found or invalid map version!\n", boardfilename); - return 1; - } - userMapRecord.name = ""; - userMapRecord.SetFileName(boardfilename); - currentLevel = &userMapRecord; - SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); - STAT_NewLevel(boardfilename); - G_LoadMapHack(levelName, boardfilename); - userMapRecord.music = G_SetupFilenameBasedMusic(boardfilename, !isRR() ? "dethtoll.mid" : nullptr); - } - else if (engineLoadBoard(mi.fileName, VOLUMEONE, &pPlayer->pos, &lbang, &pPlayer->cursectnum) < 0) - { - Printf(TEXTCOLOR_RED "Map \"%s\" not found or invalid map version!\n", mi.fileName.GetChars()); - return 1; - } - else - { - currentLevel = &mi; - SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); - STAT_NewLevel(mi.fileName); - G_LoadMapHack(levelName, mi.fileName); - } - - if (isRR() && !isRRRA() && ud.volume_number == 1 && ud.level_number == 1) - { - for (bssize_t i = PISTOL_WEAPON; i < MAX_WEAPONS; i++) - g_player[0].ps->ammo_amount[i] = 0; - g_player[0].ps->gotweapon.Clear(KNEE_WEAPON); - } - - pPlayer->q16ang = fix16_from_int(lbang); - - g_precacheCount = 0; - Bmemset(gotpic, 0, sizeof(gotpic)); - - if (isRR()) prelevel_r(gameMode); - else prelevel_d(gameMode); - - G_InitRRRASkies(); - - if (isRRRA() && ud.level_number == 2 && ud.volume_number == 0) - { - for (bssize_t i = PISTOL_WEAPON; i < MAX_WEAPONS; i++) - g_player[0].ps->ammo_amount[i] = 0; - g_player[0].ps->gotweapon.Clear(KNEE_WEAPON); - g_player[0].ps->gotweapon.Set(SLINGBLADE_WEAPON); - g_player[0].ps->ammo_amount[SLINGBLADE_WEAPON] = 1; - g_player[0].ps->curr_weapon = SLINGBLADE_WEAPON; - } - - allignwarpelevators(); - resetpspritevars(gameMode); - - if (isRR()) cacheit_r(); else cacheit_d(); - return 0; -} - -int G_EnterLevel(int gameMode) -{ - int32_t i, mii; - -// flushpackets(); -// waitforeverybody(); - - ud.respawn_monsters = ud.m_respawn_monsters; - ud.respawn_items = ud.m_respawn_items; - ud.respawn_inventory = ud.m_respawn_inventory; - ud.monsters_off = ud.m_monsters_off; - ud.coop = m_coop; - ud.marker = m_marker; - ud.ffire = m_ffire; - ud.noexits = m_noexits; - - if ((gameMode & MODE_DEMO) != MODE_DEMO) - ud.recstat = m_recstat; - if ((gameMode & MODE_DEMO) == 0 && ud.recstat == 2) - ud.recstat = 0; - - if (IsGameEvent(EVENT_ENTERLEVEL)) - { - SetGameVarID(g_iReturnVarID, -1, -1, -1); - OnEvent(EVENT_ENTERLEVEL); - } - - //if (g_networkMode != NET_DEDICATED_SERVER) - { - S_PauseSounds(false); - FX_StopAllSounds(); - FX_SetReverb(0); - } - - if (Menu_HaveUserMap()) - { - int levelNum = G_FindLevelByFile(boardfilename); - - if (levelNum != MAXLEVELS*MAXVOLUMES) - { - int volumeNum = levelNum; - - levelNum &= MAXLEVELS-1; - volumeNum = (volumeNum - levelNum) / MAXLEVELS; - - ud.level_number = levelNum; - ud.volume_number = volumeNum; - - boardfilename[0] = 0; - } - } - - // Redirect the final isRR() level to a valid map record so that currentLevel can point to something. - mii = (isRR() && g_lastLevel)? 127 : (ud.volume_number*MAXLEVELS)+ud.level_number; - auto& mi = mapList[mii]; - - if (mi.fileName.IsEmpty() && !Menu_HaveUserMap()) - { - Printf(TEXTCOLOR_RED "Map E%dL%d not defined!\n", ud.volume_number+1, ud.level_number+1); - return 1; - } - - FStringf msg("%s . . .", GStrings("TXT_LOADMAP")); - struct player_struct *const pPlayer = g_player[0].ps; - - - /* - G_DoLoadScreen(msg, -1); - */ - int res = LoadTheMap(mi, pPlayer, gameMode); - if (res != 0) return res; - - // Try this first so that it can disable the CD player if no tracks are found. - if (isRR() && !(gameMode & MODE_DEMO)) - S_PlayRRMusic(); - - if (ud.recstat != 2) - { - if (Menu_HaveUserMap()) - { - S_PlayLevelMusic(USERMAPMUSICFAKESLOT); - } - else S_PlayLevelMusic(mii); - } - - if (gameMode & (MODE_GAME|MODE_EOL)) - { - for (TRAVERSE_CONNECT(i)) - { - g_player[i].ps->gm = MODE_GAME; - } - } - else if (gameMode & MODE_RESTART) - { - if (ud.recstat == 2) - g_player[myconnectindex].ps->gm = MODE_DEMO; - else g_player[myconnectindex].ps->gm = MODE_GAME; - } - -#ifndef EDUKE32_TOUCH_DEVICES - if (VOLUMEONE && ud.level_number == 0 && ud.recstat != 2) - FTA(QUOTE_F1HELP,g_player[myconnectindex].ps); -#endif - - for (TRAVERSE_CONNECT(i)) - { - int pn = sector[sprite[g_player[i].ps->i].sectnum].floorpicnum; - if (pn == TILE_HURTRAIL || pn == TILE_FLOORSLIME || pn == TILE_FLOORPLASMA) - { - resetweapons(i); - resetinventory(i); - - g_player[i].ps->gotweapon.Clear(PISTOL_WEAPON); - g_player[i].ps->ammo_amount[PISTOL_WEAPON] = 0; - - g_player[i].ps->curr_weapon = KNEE_WEAPON; - g_player[i].ps->kickback_pic = 0; - } - } - - //PREMAP.C - replace near the my's at the end of the file - - Net_NotifyNewGame(); - Net_ResetPrediction(); - - //g_player[myconnectindex].ps->palette = palette; - setpal(g_player[myconnectindex].ps); - renderFlushPerms(); - - everyothertime = 0; - g_globalRandom = 0; - - ud.last_level = ud.level_number+1; - - clearfifo(); - - for (i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; - - g_player[myconnectindex].ps->over_shoulder_on = 0; - - clearfrags(); - - G_ResetTimers(0); // Here we go - - //Bsprintf(g_szBuf,"G_EnterLevel L=%d V=%d",ud.level_number, ud.volume_number); - //AddLog(g_szBuf); - // variables are set by pointer... - - - if (G_HaveUserMap()) - { - Printf(TEXTCOLOR_GOLD "%s: %s\n", GStrings("TXT_USERMAP"), boardfilename); - } - else - { - Printf(TEXTCOLOR_GOLD "%s: %s\n", mapList[mii].labelName.GetChars(), mapList[mii].DisplayName()); - } - - videoClearViewableArea(0L); - displayrooms(myconnectindex,65536); - displayrest(65536); - - Net_WaitForEverybody(); - return 0; -} - -void setmapfog(int fogtype) -{ - GLInterface.SetMapFog(fogtype != 0); -} END_DUKE_NS diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index ff20163b7..2a7408247 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -783,11 +783,10 @@ static const dataspec_t svgm_udnetw[] = { DS_NOCHK, &ud.coop, sizeof(ud.coop), 1 }, { DS_NOCHK, &ud.marker, sizeof(ud.marker), 1 }, { DS_NOCHK, &ud.ffire, sizeof(ud.ffire), 1 }, - { DS_NOCHK, &ud.noexits, sizeof(ud.noexits), 1 }, { 0, &ud.pause_on, sizeof(ud.pause_on), 1 }, { 0, connectpoint2, sizeof(connectpoint2), 1 }, { 0, &randomseed, sizeof(randomseed), 1 }, - { 0, &g_globalRandom, sizeof(g_globalRandom), 1 }, + { 0, &global_random, sizeof(global_random), 1 }, // { 0, &lockclock_dummy, sizeof(lockclock), 1 }, { DS_END, 0, 0, 0 } }; @@ -1204,7 +1203,6 @@ static void sv_postudload() m_coop = ud.coop; m_marker = ud.marker; m_ffire = ud.ffire; - m_noexits = ud.noexits; #endif } //static int32_t lockclock_dummy; @@ -1432,7 +1430,7 @@ static void postloadplayer(int32_t savegamep) //8 // if (savegamep) ? - G_ResetTimers(0); + resettimevars(); #ifdef USE_STRUCT_TRACKERS Bmemset(sectorchanged, 0, sizeof(sectorchanged)); diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index aba82bde9..cbc9bca91 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -42,6 +42,7 @@ static int32_t g_whichPalForPlayer = 9; static uint8_t precachehightile[2][MAXTILES>>3]; static int32_t g_precacheCount; int32_t g_skillSoundVoice = -1; +MapRecord userMapRecord; static void flag_precache(int32_t tile, int32_t type) @@ -2237,34 +2238,6 @@ static void G_FadeLoad(int32_t r, int32_t g, int32_t b, int32_t start, int32_t e } #endif -static int G_TryMapHack(const char *mhkfile) -{ - int32_t failure = engineLoadMHK(mhkfile); - - if (!failure) - Printf("Loaded map hack file \"%s\"\n", mhkfile); - - return failure; -} - -static void G_LoadMapHack(char *outbuf, const char *filename) -{ - if (filename != NULL) - Bstrcpy(outbuf, filename); - - append_ext_UNSAFE(outbuf, ".mhk"); - - if (G_TryMapHack(outbuf) && usermaphacks != NULL) - { - usermaphack_t *pMapInfo = (usermaphack_t*)bsearch( - &g_loadedMapHack, usermaphacks, num_usermaphacks, sizeof(usermaphack_t), - compare_usermaphacks); - - if (pMapInfo) - G_TryMapHack(pMapInfo->mhkfile); - } -} - int G_EnterLevel(int gameMode) { int32_t i, mii; @@ -2350,7 +2323,7 @@ int G_EnterLevel(int gameMode) currentLevel = &userMapRecord; SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); STAT_NewLevel(boardfilename); - G_LoadMapHack(levelName, boardfilename); + G_LoadMapHack(boardfilename); userMapRecord.music = G_SetupFilenameBasedMusic(boardfilename, !RR? "dethtoll.mid" : nullptr); } else if (engineLoadBoard(mi.fileName, VOLUMEONE, &pPlayer->pos, &lbang, &pPlayer->cursectnum) < 0) @@ -2363,7 +2336,7 @@ int G_EnterLevel(int gameMode) currentLevel = &mi; SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); STAT_NewLevel(mi.fileName); - G_LoadMapHack(levelName, mi.fileName); + G_LoadMapHack(mi.fileName); } if (RR && !RRRA && ud.volume_number == 1 && ud.level_number == 1)