From 3aa0ce5c3ade10f4e9dc63438ddfa90910956922 Mon Sep 17 00:00:00 2001 From: CommonLoon102 <321850+CommonLoon102@users.noreply.github.com> Date: Sun, 22 Sep 2019 07:55:57 +0000 Subject: [PATCH] Maphack support (#186) # Conflicts: # .gitignore --- .gitignore | 4 ++++ source/blood/src/blood.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/.gitignore b/.gitignore index 19c08eeb8..d52256030 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ texturecache *.manifest /*.map +/*.mhk /platform/Windows/*.map *.pdb .vs/ @@ -40,7 +41,10 @@ texturecache /*.grp /*.rts /*.art +/*.ar_ /*.con +/*.SMK +/*.WAV /platform/Windows/*.con *.memmap *.sdf diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 55135db3f..a8c32a294 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -503,6 +503,32 @@ void EndLevel(void) seqKillAll(); } +int G_TryMapHack(const char* mhkfile) +{ + int const failure = engineLoadMHK(mhkfile); + + if (!failure) + initprintf("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); + } +} + PLAYER gPlayerTemp[kMaxPlayers]; int gHealthTemp[kMaxPlayers]; @@ -575,6 +601,8 @@ void StartLevel(GAMEOPTIONS *gameOptions) gQuitGame = true; return; } + char levelName[BMAX_PATH]; + G_LoadMapHack(levelName, gameOptions->zLevelName); wsrand(gameOptions->uMapCRC); gKillMgr.Clear(); gSecretMgr.Clear();