diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index a3fa19bbe..91948caa3 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -4123,8 +4123,8 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) PLAYER *pPlayer = NULL; if (IsPlayerSprite(pSprite)) pPlayer = &gPlayer[pSprite->type-kDudePlayer1]; - int nHitSprite = pSpriteHit->ceilhit & 0x1fff; - switch (pSpriteHit->ceilhit&0xe000) + int nHitSprite = pSpriteHit->ceilhit & 0x3fff; + switch (pSpriteHit->ceilhit&0xc000) { case 0x8000: break; @@ -4214,8 +4214,8 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) } break; } - nHitSprite = pSpriteHit->hit & 0x1fff; - switch (pSpriteHit->hit&0xe000) + nHitSprite = pSpriteHit->hit & 0x3fff; + switch (pSpriteHit->hit&0xc000) { case 0x8000: break; @@ -4287,8 +4287,8 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) } break; } - nHitSprite = pSpriteHit->florhit & 0x1fff; - switch (pSpriteHit->florhit&0xe000) + nHitSprite = pSpriteHit->florhit & 0x3fff; + switch (pSpriteHit->florhit&0xc000) { case 0x8000: break; @@ -4468,9 +4468,9 @@ int MoveThing(spritetype *pSprite) dassert(nSector >= 0 && nSector < kMaxSectors); ChangeSpriteSect(nSprite, nSector); } - if ((gSpriteHit[nXSprite].hit&0xe000) == 0x8000) + if ((gSpriteHit[nXSprite].hit&0xc000) == 0x8000) { - int nHitWall = gSpriteHit[nXSprite].hit&0x1fff; + int nHitWall = gSpriteHit[nXSprite].hit&0x3fff; actWallBounceVector((int*)&xvel[nSprite], (int*)&yvel[nSprite], nHitWall, pThingInfo->at7); switch (pSprite->type) { @@ -4600,9 +4600,9 @@ int MoveThing(spritetype *pSprite) { int nVel = approxDist(xvel[nSprite], yvel[nSprite]); int nVelClipped = ClipHigh(nVel, 0x11111); - if ((floorHit & 0xe000) == 0xc000) + if ((floorHit & 0xc000) == 0xc000) { - int nHitSprite = floorHit & 0x1fff; + int nHitSprite = floorHit & 0x3fff; if ((sprite[nHitSprite].cstat & 0x30) == 0) { xvel[nSprite] += mulscale(4, pSprite->x - sprite[nHitSprite].x, 2); @@ -4670,11 +4670,11 @@ void MoveDude(spritetype *pSprite) dassert(nSector >= 0); pSprite->cstat = bakCstat; } - switch (gSpriteHit[nXSprite].hit&0xe000) + switch (gSpriteHit[nXSprite].hit&0xc000) { case 0xc000: { - int nHitSprite = gSpriteHit[nXSprite].hit&0x1fff; + int nHitSprite = gSpriteHit[nXSprite].hit&0x3fff; spritetype *pHitSprite = &sprite[nHitSprite]; XSPRITE *pHitXSprite = NULL; // Should be pHitSprite here @@ -4698,7 +4698,7 @@ void MoveDude(spritetype *pSprite) } case 0x8000: { - int nHitWall = gSpriteHit[nXSprite].hit&0x1fff; + int nHitWall = gSpriteHit[nXSprite].hit&0x3fff; walltype *pHitWall = &wall[nHitWall]; XWALL *pHitXWall = NULL; if (pHitWall->extra > 0) @@ -5108,9 +5108,9 @@ void MoveDude(spritetype *pSprite) pXSprite->height = ClipLow(floorZ-bottom, 0)>>8; if (xvel[nSprite] || yvel[nSprite]) { - if ((floorHit & 0xe000) == 0xc000) + if ((floorHit & 0xc000) == 0xc000) { - int nHitSprite = floorHit & 0x1fff; + int nHitSprite = floorHit & 0x3fff; if ((sprite[nHitSprite].cstat & 0x30) == 0) { xvel[nSprite] += mulscale(4, pSprite->x - sprite[nHitSprite].x, 2); @@ -5210,13 +5210,13 @@ int MoveMissile(spritetype *pSprite) } if (vdx) { - int nHitSprite = vdx & 0x1fff; - if ((vdx&0xe000) == 0xc000) + int nHitSprite = vdx & 0x3fff; + if ((vdx&0xc000) == 0xc000) { gHitInfo.hitsprite = nHitSprite; vdi = 3; } - else if ((vdx & 0xe000) == 0x8000) + else if ((vdx & 0xc000) == 0x8000) { gHitInfo.hitwall = nHitSprite; if (wall[nHitSprite].nextsector == -1) @@ -5615,7 +5615,7 @@ void actProcessSprites(void) } } actAirDrag(pSprite, 128); - if ((pSprite->index>>8) == (gFrame&15) && (pSprite->hitag&2)) + if (((pSprite->index>>8)&15) == (gFrame&15) && (pSprite->hitag&2)) pSprite->hitag |= 4; if ((pSprite->hitag&4) || xvel[nSprite] || yvel[nSprite] || zvel[nSprite] || velFloor[pSprite->sectnum] || velCeil[pSprite->sectnum]) @@ -5637,11 +5637,11 @@ void actProcessSprites(void) break; case kGDXThingThrowableRock: seqSpawn(24, 3, nXSprite, -1); - if ((hit & 0xe000) == 0xc000) + if ((hit & 0xc000) == 0xc000) { pSprite->xrepeat = 32; pSprite->yrepeat = 32; - int nObject = hit & 0x1fff; + int nObject = hit & 0x3fff; dassert(nObject >= 0 && nObject < kMaxSprites); spritetype * pObject = &sprite[nObject]; actDamageSprite(actSpriteOwnerToSpriteId(pSprite), pObject, DAMAGE_TYPE_0, pXSprite->data1); @@ -5649,24 +5649,24 @@ void actProcessSprites(void) break; case 421: seqSpawn(24, 3, nXSprite, -1); - if ((hit&0xe000) == 0xc000) + if ((hit&0xc000) == 0xc000) { - int nObject = hit & 0x1fff; + int nObject = hit & 0x3fff; dassert(nObject >= 0 && nObject < kMaxSprites); spritetype *pObject = &sprite[nObject]; actDamageSprite(actSpriteOwnerToSpriteId(pSprite), pObject, DAMAGE_TYPE_0, 12); } break; case 430: - if ((hit&0xe000) == 0x4000) + if ((hit&0xc000) == 0x4000) { sub_2A620(actSpriteOwnerToSpriteId(pSprite), pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 200, 1, 20, DAMAGE_TYPE_3, 6, 0, 0, 0); evPost(pSprite->index, 3, 0, CALLBACK_ID_19); } else { - int nObject = hit & 0x1fff; - if ((hit&0xe000) != 0xc000 && (nObject < 0 || nObject >= 4096)) + int nObject = hit & 0x3fff; + if ((hit&0xc000) != 0xc000 && (nObject < 0 || nObject >= 4096)) break; dassert(nObject >= 0 && nObject < kMaxSprites); spritetype *pObject = &sprite[nObject]; @@ -5676,8 +5676,8 @@ void actProcessSprites(void) break; case 429: { - int nObject = hit & 0x1fff; - if ((hit&0xe000) != 0xc000 && (nObject < 0 || nObject >= 4096)) + int nObject = hit & 0x3fff; + if ((hit&0xc000) != 0xc000 && (nObject < 0 || nObject >= 4096)) break; dassert(nObject >= 0 && nObject < kMaxSprites); int UNUSED(nOwner) = actSpriteOwnerToSpriteId(pSprite); diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index f87f945f6..d1c424d94 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -79,8 +79,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. const char* AppProperName = APPNAME; const char* AppTechnicalName = APPBASENAME; -char qsprite_filler[kMaxSprites], qsector_filler[kMaxSectors]; - char SetupFilename[BMAX_PATH] = SETUPFILENAME; int32_t gNoSetup = 0, gCommandSetup = 0; @@ -170,43 +168,6 @@ void M32RunScript(const char *s) UNREFERENCED_PARAMETER(s); } -static const char *_module; -static int _line; - -void _SetErrorLoc(const char *pzFile, int nLine) -{ - _module = pzFile; - _line = nLine; -} - -void _ThrowError(const char *pzFormat, ...) -{ - char buffer[256]; - va_list args; - va_start(args, pzFormat); - vsprintf(buffer, pzFormat, args); - initprintf("%s(%i): %s\n", _module, _line, buffer); - - char titlebuf[256]; - Bsprintf(titlebuf, APPNAME " %s", s_buildRev); - wm_msgbox(titlebuf, "%s(%i): %s\n", _module, _line, buffer); - - Bfflush(NULL); - QuitGame(); -} - -void __dassert(const char * pzExpr, const char * pzFile, int nLine) -{ - initprintf("Assertion failed: %s in file %s at line %i\n", pzExpr, pzFile, nLine); - - char titlebuf[256]; - Bsprintf(titlebuf, APPNAME " %s", s_buildRev); - wm_msgbox(titlebuf, "Assertion failed: %s in file %s at line %i\n", pzExpr, pzFile, nLine); - - Bfflush(NULL); - exit(0); -} - void ShutDown(void) { if (!in3dmode()) diff --git a/source/blood/src/common_game.h b/source/blood/src/common_game.h index 16d30ae39..5d99a6a66 100644 --- a/source/blood/src/common_game.h +++ b/source/blood/src/common_game.h @@ -45,6 +45,7 @@ extern int g_useCwd; void _SetErrorLoc(const char *pzFile, int nLine); void _ThrowError(const char *pzFormat, ...); void __dassert(const char *pzExpr, const char *pzFile, int nLine); +void QuitGame(void); #define ThrowError(...) \ { \ @@ -54,9 +55,9 @@ void __dassert(const char *pzExpr, const char *pzFile, int nLine); #define dassert(x) if (!(x)) __dassert(#x,__FILE__,__LINE__) -#define kMaxSectors 1024 -#define kMaxWalls 8192 -#define kMaxSprites 4096 +#define kMaxSectors MAXSECTORS +#define kMaxWalls MAXWALLS +#define kMaxSprites MAXSPRITES #define kMaxTiles MAXTILES #define kMaxStatus MAXSTATUS @@ -358,8 +359,6 @@ struct Aim { #pragma pack(pop) -extern char qsprite_filler[], qsector_filler[]; - inline int ksgnf(float f) { if (f < 0) diff --git a/source/blood/src/db.cpp b/source/blood/src/db.cpp index 9dd51df1f..e9d16af09 100644 --- a/source/blood/src/db.cpp +++ b/source/blood/src/db.cpp @@ -43,6 +43,8 @@ SPRITEHIT gSpriteHit[kMaxXSprites]; int xvel[kMaxSprites], yvel[kMaxSprites], zvel[kMaxSprites]; +char qsprite_filler[kMaxSprites], qsector_filler[kMaxSectors]; + int gVisibility; const char *gItemText[] = { @@ -246,7 +248,8 @@ void qinitspritelists(void) // Replace { headspritestat[i] = -1; } - for (short i = 0; i < kMaxSprites; i++) + int const nMaxSprites = bVanilla ? 4096 : kMaxSprites; + for (short i = 0; i < nMaxSprites; i++) { sprite[i].sectnum = -1; sprite[i].index = -1; diff --git a/source/blood/src/db.h b/source/blood/src/db.h index 76fb85ebc..902212f8e 100644 --- a/source/blood/src/db.h +++ b/source/blood/src/db.h @@ -263,6 +263,8 @@ extern XWALL xwall[kMaxXWalls]; extern SPRITEHIT gSpriteHit[kMaxXSprites]; +extern char qsprite_filler[kMaxSprites], qsector_filler[kMaxSectors]; + extern int xvel[kMaxSprites], yvel[kMaxSprites], zvel[kMaxSprites]; extern int gVisibility; diff --git a/source/blood/src/gameutil.cpp b/source/blood/src/gameutil.cpp index 2c9a50067..534788e9c 100644 --- a/source/blood/src/gameutil.cpp +++ b/source/blood/src/gameutil.cpp @@ -682,9 +682,9 @@ void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int * int32_t nTemp1, nTemp2; pSprite->cstat &= ~257; getzrange_old(pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, (int32_t*)ceilZ, (int32_t*)ceilHit, (int32_t*)floorZ, (int32_t*)floorHit, nDist, nMask); - if (((*floorHit) & 0xe000) == 0x4000) + if (((*floorHit) & 0xc000) == 0x4000) { - int nSector = (*floorHit) & 0x1fff; + int nSector = (*floorHit) & 0x3fff; if ((nMask & 0x2000) == 0 && (sector[nSector].floorstat & 1)) *floorZ = 0x7fffffff; if (sector[nSector].extra > 0) @@ -702,9 +702,9 @@ void GetZRange(spritetype *pSprite, int *ceilZ, int *ceilHit, int *floorZ, int * *floorZ -= sprite[nLink].z - sprite[nSprite].z; } } - if (((*ceilHit) & 0xe000) == 0x4000) + if (((*ceilHit) & 0xc000) == 0x4000) { - int nSector = (*ceilHit) & 0x1fff; + int nSector = (*ceilHit) & 0x3fff; if ((nMask & 0x1000) == 0 && (sector[nSector].ceilingstat & 1)) *ceilZ = 0x80000000; if (gLowerLink[nSector] >= 0) @@ -724,9 +724,9 @@ void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, int *ceilHit, { int32_t nTemp1, nTemp2; getzrange_old(x, y, z, nSector, (int32_t*)ceilZ, (int32_t*)ceilHit, (int32_t*)floorZ, (int32_t*)floorHit, nDist, nMask); - if (((*floorHit) & 0xe000) == 0x4000) + if (((*floorHit) & 0xc000) == 0x4000) { - int nSector = (*floorHit) & 0x1fff; + int nSector = (*floorHit) & 0x3fff; if ((nMask & 0x2000) == 0 && (sector[nSector].floorstat & 1)) *floorZ = 0x7fffffff; if (sector[nSector].extra > 0) @@ -744,9 +744,9 @@ void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, int *ceilHit, *floorZ -= sprite[nLink].z - sprite[nSprite].z; } } - if (((*ceilHit) & 0xe000) == 0x4000) + if (((*ceilHit) & 0xc000) == 0x4000) { - int nSector = (*ceilHit) & 0x1fff; + int nSector = (*ceilHit) & 0x3fff; if ((nMask & 0x1000) == 0 && (sector[nSector].ceilingstat & 1)) *ceilZ = 0x80000000; if (gLowerLink[nSector] >= 0) diff --git a/source/blood/src/globals.cpp b/source/blood/src/globals.cpp index 4c78ffa70..e780df458 100644 --- a/source/blood/src/globals.cpp +++ b/source/blood/src/globals.cpp @@ -42,6 +42,43 @@ char gVersionStringBuf[16]; Resource gSysRes; +static const char *_module; +static int _line; + +void _SetErrorLoc(const char *pzFile, int nLine) +{ + _module = pzFile; + _line = nLine; +} + +void _ThrowError(const char *pzFormat, ...) +{ + char buffer[256]; + va_list args; + va_start(args, pzFormat); + vsprintf(buffer, pzFormat, args); + initprintf("%s(%i): %s\n", _module, _line, buffer); + + char titlebuf[256]; + Bsprintf(titlebuf, APPNAME " %s", s_buildRev); + wm_msgbox(titlebuf, "%s(%i): %s\n", _module, _line, buffer); + + Bfflush(NULL); + QuitGame(); +} + +void __dassert(const char * pzExpr, const char * pzFile, int nLine) +{ + initprintf("Assertion failed: %s in file %s at line %i\n", pzExpr, pzFile, nLine); + + char titlebuf[256]; + Bsprintf(titlebuf, APPNAME " %s", s_buildRev); + wm_msgbox(titlebuf, "Assertion failed: %s in file %s at line %i\n", pzExpr, pzFile, nLine); + + Bfflush(NULL); + exit(0); +} + const char *GetVersionString(void) { if (!gVersionString) diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 4acb99d74..99cdf1ba7 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1775,7 +1775,7 @@ void ProcessInput(PLAYER *pPlayer) pPlayer->q16horiz = fix16_from_float(100.f*tanf(fix16_to_float(pPlayer->q16look)*fPI/1024.f)); } int nSector = pSprite->sectnum; - int florhit = gSpriteHit[pSprite->extra].florhit & 0xe000; + int florhit = gSpriteHit[pSprite->extra].florhit & 0xc000; char va; if (pXSprite->height < 16 && (florhit == 0x4000 || florhit == 0)) va = 1; diff --git a/source/blood/src/tile.cpp b/source/blood/src/tile.cpp index 2d545af1c..aef8037b1 100644 --- a/source/blood/src/tile.cpp +++ b/source/blood/src/tile.cpp @@ -263,8 +263,8 @@ void tilePrecacheTile(int nTile, int nType) char tileGetSurfType(int hit) { - int n = hit &0x1fff; - switch (hit&0xe000) + int n = hit & 0x3fff; + switch (hit&0xc000) { case 0x4000: return surfType[sector[n].floorpicnum]; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 0614b693f..2d9c73476 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -447,7 +447,7 @@ void fakeProcessInput(PLAYER *pPlayer, GINPUT *pInput) predict.at24 = fix16_from_float(100.f*tanf(fix16_to_float(predict.at20)*fPI/1024.f)); int nSector = predict.at68; - int florhit = predict.at75.florhit & 0xe000; + int florhit = predict.at75.florhit & 0xc000; char va; if (predict.at6a < 16 && (florhit == 0x4000 || florhit == 0)) va = 1; @@ -614,11 +614,11 @@ void fakeMoveDude(spritetype *pSprite) pSprite->cstat = bakCstat; } - switch (predict.at75.hit&0xe000) + switch (predict.at75.hit&0xc000) { case 0x8000: { - int nHitWall = predict.at75.hit&0x1fff; + int nHitWall = predict.at75.hit&0x3fff; walltype *pHitWall = &wall[nHitWall]; if (pHitWall->nextsector != -1) { @@ -756,9 +756,9 @@ void fakeMoveDude(spritetype *pSprite) predict.at6a = ClipLow(floorZ-bottom, 0)>>8; if (predict.at5c || predict.at60) { - if ((floorHit & 0xe000) == 0xc000) + if ((floorHit & 0xc000) == 0xc000) { - int nHitSprite = floorHit & 0x1fff; + int nHitSprite = floorHit & 0x3fff; if ((sprite[nHitSprite].cstat & 0x30) == 0) { predict.at5c += mulscale(4, predict.at50 - sprite[nHitSprite].x, 2); @@ -3327,7 +3327,7 @@ RORHACK: GetZRange(gView->pSprite, &vf4, &vf0, &vec, &ve8, nClipDist, 0); #if 0 int tmpSect = nSectnum; - if ((vf0 & 0xe000) == 0x4000) + if ((vf0 & 0xc000) == 0x4000) { tmpSect = vf0 & (kMaxWalls-1); }