- fixed maphack loader.

The duplicate 'currentSprite' variable prevented it from doing anything.
Also cleaned up the interface a bit to avoid using a global variable for parameter passing.

Fixes #279
This commit is contained in:
Christoph Oelckers 2021-03-07 09:39:16 +01:00
parent 9104fba3ec
commit ad8654ed06
4 changed files with 11 additions and 10 deletions

View file

@ -173,8 +173,6 @@ struct usermaphack_t
uint8_t md4[16]{};
};
extern usermaphack_t g_loadedMapHack;
EXTERN spriteext_t *spriteext;
EXTERN spritesmooth_t *spritesmooth;
@ -425,7 +423,7 @@ void initspritelists(void);
void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
void loadMapBackup(const char* filename);
void G_LoadMapHack(const char* filename);
void G_LoadMapHack(const char* filename, const unsigned char*);
int32_t qloadkvx(int32_t voxindex, const char *filename);
void vox_undefine(int32_t const);

View file

@ -36,7 +36,6 @@
#include "sc_man.h"
#include "printf.h"
usermaphack_t g_loadedMapHack; // used only for the MD4 part
static TArray<usermaphack_t> usermaphacks;
void AddUserMapHack(usermaphack_t& mhk)
@ -59,7 +58,6 @@ static int32_t LoadMapHack(const char *filename)
while (sc.GetString())
{
FString token = sc.String;
int currentsprite = -1;
auto validateSprite = [&]()
{
if (currentsprite < 0)
@ -201,7 +199,7 @@ static int32_t LoadMapHack(const char *filename)
return 0;
}
void G_LoadMapHack(const char* filename)
void G_LoadMapHack(const char* filename, const unsigned char* md4)
{
FString hack = StripExtension(filename) + ".mhk";
@ -209,7 +207,7 @@ void G_LoadMapHack(const char* filename)
{
for (auto& mhk : usermaphacks)
{
if (!memcmp(g_loadedMapHack.md4, mhk.md4, 16))
if (!memcmp(md4, mhk.md4, 16))
{
LoadMapHack(mhk.mhkfile);
}

View file

@ -439,7 +439,11 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
//Must be last.
updatesector(pos->x, pos->y, cursectnum);
guniqhudid = 0;
G_LoadMapHack(filename);
fr.Seek(0, FileReader::SeekSet);
auto buffer = fr.Read();
unsigned char md4[16];
md4once(buffer.Data(), buffer.Size(), md4);
G_LoadMapHack(filename, md4);
memcpy(wallbackup, wall, sizeof(wallbackup));
memcpy(sectorbackup, sector, sizeof(sectorbackup));

View file

@ -979,8 +979,9 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
fr.Seek(0, FileReader::SeekSet);
auto buffer = fr.Read();
md4once(buffer.Data(), buffer.Size(), g_loadedMapHack.md4);
G_LoadMapHack(mapname);
unsigned char md4[16];
md4once(buffer.Data(), buffer.Size(), md4);
G_LoadMapHack(mapname, md4);
if (CalcCRC32(buffer.Data(), buffer.Size() -4) != nCRC)
{