Add ability to load blood maps

# Conflicts:
#	platform/Windows/nmapedit.vcxproj
#	platform/Windows/nmapedit.vcxproj.filters
#	source/blood/src/mapedit.cpp
#	source/build/src/build.cpp
#	source/build/src/engine.cpp
This commit is contained in:
nukeykt 2019-06-29 01:03:47 +09:00 committed by Christoph Oelckers
parent 57e9ff2fbc
commit 2867131c86
7 changed files with 81 additions and 33 deletions

View file

@ -539,7 +539,11 @@ void StartLevel(GAMEOPTIONS *gameOptions)
memset(xsprite,0,sizeof(xsprite));
memset(sprite,0,kMaxSprites*sizeof(spritetype));
drawLoadingScreen();
dbLoadMap(gameOptions->zLevelName,(int*)&startpos.x,(int*)&startpos.y,(int*)&startpos.z,&startang,&startsectnum,(unsigned int*)&gameOptions->uMapCRC);
if (dbLoadMap(gameOptions->zLevelName,(int*)&startpos.x,(int*)&startpos.y,(int*)&startpos.z,&startang,&startsectnum,(unsigned int*)&gameOptions->uMapCRC))
{
gQuitGame = true;
return;
}
wsrand(gameOptions->uMapCRC);
gKillMgr.Clear();
gSecretMgr.Clear();
@ -1478,24 +1482,7 @@ int app_main(int argc, char const * const * argv)
gGuiRes.Init("GUI.RFF");
gSoundRes.Init(pUserSoundRFF ? pUserSoundRFF : "SOUNDS.RFF");
{ // Replace
void qinitspritelists();
int32_t qinsertsprite(int16_t nSector, int16_t nStat);
int32_t qdeletesprite(int16_t nSprite);
int32_t qchangespritesect(int16_t nSprite, int16_t nSector);
int32_t qchangespritestat(int16_t nSprite, int16_t nStatus);
animateoffs_replace = qanimateoffs;
paletteLoadFromDisk_replace = qloadpalette;
getpalookup_replace = qgetpalookup;
initspritelists_replace = qinitspritelists;
insertsprite_replace = qinsertsprite;
deletesprite_replace = qdeletesprite;
changespritesect_replace = qchangespritesect;
changespritestat_replace = qchangespritestat;
loadvoxel_replace = qloadvoxel;
bloodhack = true;
}
HookReplaceFunctions();
initprintf("Initializing Build 3D engine\n");
scrInit();

View file

@ -699,7 +699,7 @@ unsigned int dbReadMapCRC(const char *pPath)
int gMapRev, gSongId, gSkyCount;
//char byte_19AE44[128];
void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short *pSector, unsigned int *pCRC)
int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short *pSector, unsigned int *pCRC)
{
int16_t tpskyoff[256];
memset(show2dsector, 0, sizeof(show2dsector));
@ -721,7 +721,15 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
DICTNODE *pNode = gSysRes.Lookup(pPath, "MAP");
if (!pNode)
{
ThrowError("Error opening map file %s", pPath);
char name2[BMAX_PATH];
Bstrncpy(name2, pPath, BMAX_PATH);
ChangeExtension(name2, "");
pNode = gSysRes.Lookup(name2, "MAP");
}
if (!pNode)
{
initprintf("Error opening map file %s", pPath);
return -1;
}
char *pData = (char*)gSysRes.Lock(pNode);
int nSize = pNode->size;
@ -733,7 +741,9 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
#endif
if (memcmp(header.signature, "BLM\x1a", 4))
{
ThrowError("Map file corrupted");
initprintf("Map file corrupted");
gSysRes.Unlock(pNode);
return -1;
}
byte_1A76C8 = 0;
if ((header.version & 0xff00) == 0x600)
@ -745,7 +755,9 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
}
else
{
ThrowError("Map file is wrong version");
initprintf("Map file is wrong version");
gSysRes.Unlock(pNode);
return -1;
}
MAPHEADER mapHeader;
IOBuffer1.Read(&mapHeader,37/* sizeof(mapHeader)*/);
@ -792,12 +804,16 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
}
else
{
ThrowError("Corrupted Map file");
initprintf("Corrupted Map file");
gSysRes.Unlock(pNode);
return -1;
}
}
else if (mapHeader.at16)
{
ThrowError("Corrupted Map file");
initprintf("Corrupted Map file");
gSysRes.Unlock(pNode);
return -1;
}
parallaxtype = mapHeader.at1a;
gMapRev = mapHeader.at1b;
@ -1165,9 +1181,12 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
#endif
if (Bcrc32(pData, nSize-4, 0) != nCRC)
{
ThrowError("Map File does not match CRC");
initprintf("Map File does not match CRC");
gSysRes.Unlock(pNode);
return -1;
}
*pCRC = nCRC;
if (pCRC)
*pCRC = nCRC;
gSysRes.Unlock(pNode);
PropagateMarkerReferences();
if (byte_1A76C8)
@ -1182,12 +1201,16 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
}
else
{
ThrowError("Corrupted Map file");
initprintf("Corrupted Map file");
gSysRes.Unlock(pNode);
return -1;
}
}
else if (gSongId != 0)
{
ThrowError("Corrupted Shareware Map file");
initprintf("Corrupted Map file");
gSysRes.Unlock(pNode);
return -1;
}
#ifdef POLYMER
@ -1246,4 +1269,14 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
#ifdef YAX_ENABLE
yax_update(numyaxbunches > 0 ? 2 : 1);
#endif
g_loadedMapVersion = 7;
return 0;
}
int32_t qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang, int16_t* dacursectnum)
{
// NUKE-TODO: implement flags
return dbLoadMap(filename, &dapos->x, &dapos->y, &dapos->z, (short*)daang, (short*)dacursectnum, NULL);
}

View file

@ -320,4 +320,4 @@ void dbXSectorClean(void);
void dbInit(void);
void PropagateMarkerReferences(void);
unsigned int dbReadMapCRC(const char *pPath);
void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short *pSector, unsigned int *pCRC);
int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short *pSector, unsigned int *pCRC);

View file

@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "crc32.h"
#include "globals.h"
#include "tile.h"
#include "screen.h"
int qanimateoffs(int a1, int a2)
@ -70,4 +71,25 @@ int32_t qgetpalookup(int32_t a1, int32_t a2)
return ClipHigh(a1 >> 8, 15) * 16 + ClipRange(a2, 0, 15);
else
return ClipRange((a1 >> 8) + a2, 0, 63);
}
}
void HookReplaceFunctions(void)
{
void qinitspritelists();
int32_t qinsertsprite(int16_t nSector, int16_t nStat);
int32_t qdeletesprite(int16_t nSprite);
int32_t qchangespritesect(int16_t nSprite, int16_t nSector);
int32_t qchangespritestat(int16_t nSprite, int16_t nStatus);
int32_t qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang, int16_t* dacursectnum);
animateoffs_replace = qanimateoffs;
paletteLoadFromDisk_replace = qloadpalette;
getpalookup_replace = qgetpalookup;
initspritelists_replace = qinitspritelists;
insertsprite_replace = qinsertsprite;
deletesprite_replace = qdeletesprite;
changespritesect_replace = qchangespritesect;
changespritestat_replace = qchangespritestat;
loadvoxel_replace = qloadvoxel;
loadboard_replace = qloadboard;
bloodhack = true;
}

View file

@ -25,4 +25,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
int qanimateoffs(int a1, int a2);
void qloadpalette();
int32_t qgetpalookup(int32_t a1, int32_t a2);
int32_t qgetpalookup(int32_t a1, int32_t a2);
void HookReplaceFunctions();

View file

@ -1599,6 +1599,7 @@ extern int32_t(*deletesprite_replace)(int16_t spritenum);
extern int32_t(*changespritesect_replace)(int16_t spritenum, int16_t newsectnum);
extern int32_t(*changespritestat_replace)(int16_t spritenum, int16_t newstatnum);
extern void(*loadvoxel_replace)(int32_t voxel);
extern int32_t(*loadboard_replace)(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
#ifdef USE_OPENGL
extern void(*PolymostProcessVoxels_Callback)(void);
#endif

View file

@ -9665,6 +9665,8 @@ LUNATIC_CB int32_t (*loadboard_maptext)(buildvfs_kfd fil, vec3_t *dapos, int16_t
#include "md4.h"
int32_t(*loadboard_replace)(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum) = NULL;
// flags: 1, 2: former parameter "fromwhere"
// 4: don't call polymer_loadboard
// 8: don't autoexec <mapname>.cfg
@ -9675,7 +9677,9 @@ LUNATIC_CB int32_t (*loadboard_maptext)(buildvfs_kfd fil, vec3_t *dapos, int16_t
// <= -4: map-text error
int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum)
{
int32_t i;
if (loadboard_replace)
return loadboard_replace(filename, flags, dapos, daang, dacursectnum);
int32_t fil, i;
int16_t numsprites;
const char myflags = flags&(~3);