- actSpawnSprite, ZONE, startsectnum and dbLoadMap

This commit is contained in:
Christoph Oelckers 2021-11-24 00:55:57 +01:00
parent b187f3c028
commit 443cfc991c
12 changed files with 39 additions and 39 deletions

View file

@ -524,7 +524,7 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
} }
void qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang, int* dacursectnum); void qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang);
// loads a map into the backup buffer. // loads a map into the backup buffer.
@ -536,7 +536,7 @@ void loadMapBackup(const char* filename)
if (isBlood()) if (isBlood())
{ {
qloadboard(filename, 0, &pos, &scratch, &scratch2); qloadboard(filename, 0, &pos, &scratch);
} }
else else
{ {

View file

@ -2761,12 +2761,12 @@ static void actNapalmMove(DBloodActor* actor)
static DBloodActor* actSpawnFloor(DBloodActor* actor) static DBloodActor* actSpawnFloor(DBloodActor* actor)
{ {
auto pSprite = &actor->s(); auto pSprite = &actor->s();
int sector = pSprite->sectnum; auto pSector = pSprite->sector();
int x = pSprite->x; int x = pSprite->x;
int y = pSprite->y; int y = pSprite->y;
updatesector(x, y, &sector); updatesector(x, y, &pSector);
int zFloor = getflorzofslope(sector, x, y); int zFloor = getflorzofslopeptr(pSector, x, y);
auto spawned = actSpawnSprite(sector, x, y, zFloor, 3, 0); auto spawned = actSpawnSprite(pSector, x, y, zFloor, 3, 0);
if (spawned) spawned->s().cstat &= ~257; if (spawned) spawned->s().cstat &= ~257;
return spawned; return spawned;
} }
@ -5517,7 +5517,7 @@ void actExplodeSprite(DBloodActor* actor)
case kThingTNTBarrel: case kThingTNTBarrel:
{ {
auto spawned = actSpawnSprite(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0, 1); auto spawned = actSpawnSprite(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 0, 1);
spawned->SetOwner(actor->GetOwner()); spawned->SetOwner(actor->GetOwner());
if (actCheckRespawn(actor)) if (actCheckRespawn(actor))
{ {
@ -5892,7 +5892,6 @@ static void actCheckExplosion()
int x = pSprite->x; int x = pSprite->x;
int y = pSprite->y; int y = pSprite->y;
int z = pSprite->z; int z = pSprite->z;
int nSector = pSprite->sectnum;
auto pSector = pSprite->sector(); auto pSector = pSprite->sector();
int radius = pExplodeInfo->radius; int radius = pExplodeInfo->radius;
@ -6319,9 +6318,9 @@ void actProcessSprites(void)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool setextra) DBloodActor* actSpawnSprite(sectortype* pSector, int x, int y, int z, int nStat, bool setextra)
{ {
DBloodActor* actor = InsertSprite(nSector, nStat); DBloodActor* actor = InsertSprite(pSector, nStat);
vec3_t pos = { x, y, z }; vec3_t pos = { x, y, z };
setActorPos(actor, &pos); setActorPos(actor, &pos);
@ -6346,7 +6345,7 @@ DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool se
DBloodActor* actSpawnSprite(DBloodActor* source, int nStat) DBloodActor* actSpawnSprite(DBloodActor* source, int nStat)
{ {
auto pSource = &source->s(); auto pSource = &source->s();
DBloodActor* actor = InsertSprite(pSource->sectnum, nStat); DBloodActor* actor = InsertSprite(pSource->sector(), nStat);
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
pSprite->x = pSource->x; pSprite->x = pSource->x;
@ -6447,7 +6446,7 @@ DBloodActor* actSpawnDude(DBloodActor* source, int nType, int a3, int a4)
DBloodActor* actSpawnThing(int nSector, int x, int y, int z, int nThingType) DBloodActor* actSpawnThing(int nSector, int x, int y, int z, int nThingType)
{ {
assert(nThingType >= kThingBase && nThingType < kThingMax); assert(nThingType >= kThingBase && nThingType < kThingMax);
auto actor = actSpawnSprite(nSector, x, y, z, 4, 1); auto actor = actSpawnSprite(&sector[nSector], x, y, z, 4, 1);
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
int nType = nThingType - kThingBase; int nType = nThingType - kThingBase;
pSprite->type = nThingType; pSprite->type = nThingType;
@ -6678,7 +6677,7 @@ DBloodActor* actFireMissile(DBloodActor* actor, int a2, int a3, int a4, int a5,
y = gHitInfo.hity - MulScale(pMissileInfo->clipDist << 1, Sin(pSprite->ang), 28); y = gHitInfo.hity - MulScale(pMissileInfo->clipDist << 1, Sin(pSprite->ang), 28);
} }
} }
auto spawned = actSpawnSprite(pSprite->sectnum, x, y, z, 5, 1); auto spawned = actSpawnSprite(pSprite->sector(), x, y, z, 5, 1);
spritetype* pMissile = &spawned->s(); spritetype* pMissile = &spawned->s();
pMissile->cstat2 |= CSTAT2_SPRITE_MAPPED; pMissile->cstat2 |= CSTAT2_SPRITE_MAPPED;
pMissile->type = nType; pMissile->type = nType;

View file

@ -224,7 +224,7 @@ void actAirDrag(DBloodActor *pSprite, int a2);
void actExplodeSprite(DBloodActor *pSprite); void actExplodeSprite(DBloodActor *pSprite);
void actActivateGibObject(DBloodActor *actor); void actActivateGibObject(DBloodActor *actor);
void actProcessSprites(void); void actProcessSprites(void);
DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool a6); DBloodActor* actSpawnSprite(sectortype* pSector, int x, int y, int z, int nStat, bool a6);
DBloodActor* actSpawnDude(DBloodActor* pSource, int nType, int a3, int a4); DBloodActor* actSpawnDude(DBloodActor* pSource, int nType, int a3, int a4);
DBloodActor * actSpawnSprite(DBloodActor *pSource, int nStat); DBloodActor * actSpawnSprite(DBloodActor *pSource, int nStat);
DBloodActor * actSpawnThing(int nSector, int x, int y, int z, int nThingType); DBloodActor * actSpawnThing(int nSector, int x, int y, int z, int nThingType);

View file

@ -1887,7 +1887,7 @@ bool doExplosion(DBloodActor* actor, int nType)
{ {
auto const pSprite = &actor->s(); auto const pSprite = &actor->s();
auto actExplosion = actSpawnSprite(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, kStatExplosion, true); auto actExplosion = actSpawnSprite(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, kStatExplosion, true);
auto const pExplosion = &actExplosion->s(); auto const pExplosion = &actExplosion->s();
auto const pXExplosion = &actExplosion->x(); auto const pXExplosion = &actExplosion->x();
if (!actExplosion->hasX()) if (!actExplosion->hasX())

View file

@ -61,7 +61,7 @@ PLAYER gPlayerTemp[kMaxPlayers];
int gHealthTemp[kMaxPlayers]; int gHealthTemp[kMaxPlayers];
vec3_t startpos; vec3_t startpos;
int16_t startang; int16_t startang;
int startsectnum; sectortype* startsector;
void QuitGame(void) void QuitGame(void)
@ -111,7 +111,7 @@ void StartLevel(MapRecord* level, bool newgame)
} }
} }
//drawLoadingScreen(); //drawLoadingScreen();
dbLoadMap(currentLevel->fileName, (int*)&startpos.x, (int*)&startpos.y, (int*)&startpos.z, &startang, &startsectnum, nullptr); dbLoadMap(currentLevel->fileName, (int*)&startpos.x, (int*)&startpos.y, (int*)&startpos.z, &startang, &startsector, nullptr);
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
STAT_NewLevel(currentLevel->fileName); STAT_NewLevel(currentLevel->fileName);
wsrand(dbReadMapCRC(currentLevel->LabelName())); wsrand(dbReadMapCRC(currentLevel->LabelName()));
@ -149,12 +149,12 @@ void StartLevel(MapRecord* level, bool newgame)
Printf(PRINT_NONOTIFY, "> Modern types erased: %d.\n", modernTypesErased); Printf(PRINT_NONOTIFY, "> Modern types erased: %d.\n", modernTypesErased);
#endif #endif
startpos.z = getflorzofslope(startsectnum, startpos.x, startpos.y); startpos.z = getflorzofslopeptr(startsector, startpos.x, startpos.y);
for (int i = 0; i < kMaxPlayers; i++) { for (int i = 0; i < kMaxPlayers; i++) {
gStartZone[i].x = startpos.x; gStartZone[i].x = startpos.x;
gStartZone[i].y = startpos.y; gStartZone[i].y = startpos.y;
gStartZone[i].z = startpos.z; gStartZone[i].z = startpos.z;
gStartZone[i].sectnum = startsectnum; gStartZone[i].sector = startsector;
gStartZone[i].ang = startang; gStartZone[i].ang = startang;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
@ -163,13 +163,13 @@ void StartLevel(MapRecord* level, bool newgame)
gStartZoneTeam1[i].x = startpos.x; gStartZoneTeam1[i].x = startpos.x;
gStartZoneTeam1[i].y = startpos.y; gStartZoneTeam1[i].y = startpos.y;
gStartZoneTeam1[i].z = startpos.z; gStartZoneTeam1[i].z = startpos.z;
gStartZoneTeam1[i].sectnum = startsectnum; gStartZoneTeam1[i].sector = startsector;
gStartZoneTeam1[i].ang = startang; gStartZoneTeam1[i].ang = startang;
gStartZoneTeam2[i].x = startpos.x; gStartZoneTeam2[i].x = startpos.x;
gStartZoneTeam2[i].y = startpos.y; gStartZoneTeam2[i].y = startpos.y;
gStartZoneTeam2[i].z = startpos.z; gStartZoneTeam2[i].z = startpos.z;
gStartZoneTeam2[i].sectnum = startsectnum; gStartZoneTeam2[i].sector = startsector;
gStartZoneTeam2[i].ang = startang; gStartZoneTeam2[i].ang = startang;
} }
#endif #endif

View file

@ -162,7 +162,7 @@ void qinitspritelists(void) // Replace
Numsprites = 0; Numsprites = 0;
} }
DBloodActor* InsertSprite(int nSector, int nStat) DBloodActor* InsertSprite(sectortype* pSector, int nStat)
{ {
int nSprite = headspritestat[kMaxStatus]; int nSprite = headspritestat[kMaxStatus];
assert(nSprite < kMaxSprites); assert(nSprite < kMaxSprites);
@ -177,7 +177,7 @@ DBloodActor* InsertSprite(int nSector, int nStat)
spritetype *pSprite = &actor->s(); spritetype *pSprite = &actor->s();
memset(pSprite, 0, sizeof(spritetype)); memset(pSprite, 0, sizeof(spritetype));
InsertSpriteStat(nSprite, nStat); InsertSpriteStat(nSprite, nStat);
InsertSpriteSect(nSprite, nSector); InsertSpriteSect(nSprite, sectnum(pSector));
pSprite->cstat = 128; pSprite->cstat = 128;
pSprite->clipdist = 32; pSprite->clipdist = 32;
pSprite->xrepeat = pSprite->yrepeat = 64; pSprite->xrepeat = pSprite->yrepeat = 64;
@ -393,7 +393,7 @@ struct walltypedisk
#pragma pack(pop) #pragma pack(pop)
void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int* pSector, unsigned int* pCRC) void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sectortype** pSector, unsigned int* pCRC)
{ {
int16_t tpskyoff[256]; int16_t tpskyoff[256];
ClearAutomap(); ClearAutomap();
@ -463,7 +463,6 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
*pY = mapHeader.y; *pY = mapHeader.y;
*pZ = mapHeader.z; *pZ = mapHeader.z;
*pAngle = mapHeader.ang; *pAngle = mapHeader.ang;
*pSector = mapHeader.sect;
gVisibility = g_visibility = mapHeader.visibility; gVisibility = g_visibility = mapHeader.visibility;
gMattId = mapHeader.mattid; gMattId = mapHeader.mattid;
if (encrypted) if (encrypted)
@ -493,6 +492,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
#if 1 // bad, bad hack, just for making Polymost happy... #if 1 // bad, bad hack, just for making Polymost happy...
PolymostAllocFakeSector(); PolymostAllocFakeSector();
#endif #endif
* pSector = &sector[mapHeader.sect];
dbInit(); dbInit();
if (encrypted) if (encrypted)
@ -970,9 +970,10 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
END_BLD_NS END_BLD_NS
// only used by the backup loader. // only used by the backup loader.
void qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang, int* dacursectnum) void qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang)
{ {
Blood::dbLoadMap(filename, &dapos->x, &dapos->y, &dapos->z, daang, dacursectnum, NULL); sectortype* sp;
Blood::dbLoadMap(filename, &dapos->x, &dapos->y, &dapos->z, daang, &sp, NULL);
Blood::dbInit(); // clean up immediately. Blood::dbInit(); // clean up immediately.
} }

View file

@ -117,7 +117,7 @@ void RemoveSpriteSect(int nSprite);
void InsertSpriteStat(int nSprite, int nStat); void InsertSpriteStat(int nSprite, int nStat);
void RemoveSpriteStat(int nSprite); void RemoveSpriteStat(int nSprite);
void qinitspritelists(void); void qinitspritelists(void);
DBloodActor* InsertSprite(int nSector, int nStat); DBloodActor* InsertSprite(sectortype* pSector, int nStat);
int DeleteSprite(int nSprite); int DeleteSprite(int nSprite);
int ChangeSpriteSect(int nSprite, int nSector); int ChangeSpriteSect(int nSprite, int nSector);
int qchangespritesect(short nSprite, short nSector); int qchangespritesect(short nSprite, short nSector);
@ -126,7 +126,7 @@ void InitFreeList(unsigned short *pList, int nCount);
void dbInit(void); void dbInit(void);
void PropagateMarkerReferences(void); void PropagateMarkerReferences(void);
unsigned int dbReadMapCRC(const char *pPath); unsigned int dbReadMapCRC(const char *pPath);
void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int* pSector, unsigned int* pCRC); void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sectortype** pSector, unsigned int* pCRC);
END_BLD_NS END_BLD_NS

View file

@ -161,7 +161,7 @@ DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsi
return nullptr; return nullptr;
destroy(iactor); destroy(iactor);
} }
auto actor = actSpawnSprite(nSector, x, y, z, 1, 0); auto actor = actSpawnSprite(&sector[nSector], x, y, z, 1, 0);
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
pSprite->type = nFx; pSprite->type = nFx;
pSprite->picnum = pFX->picnum; pSprite->picnum = pFX->picnum;

View file

@ -58,7 +58,7 @@ void WeaponPrecache();
struct ZONE { struct ZONE {
int x, y, z; int x, y, z;
int sectnum; sectortype* sector;
short ang; short ang;
}; };
extern ZONE gStartZone[8]; extern ZONE gStartZone[8];

View file

@ -3590,7 +3590,7 @@ void useSeqSpawnerGen(DBloodActor* sourceactor, int objType, sectortype* pSector
{ {
if (pXSource->data3 > 0) if (pXSource->data3 > 0)
{ {
auto spawned = InsertSprite(pSprite->sectnum, kStatDecoration); auto spawned = InsertSprite(pSprite->sector(), kStatDecoration);
auto pSpawned = &spawned->s(); auto pSpawned = &spawned->s();
int top, bottom; GetActorExtents(spawned, &top, &bottom); int top, bottom; GetActorExtents(spawned, &top, &bottom);
pSpawned->x = pSprite->x; pSpawned->x = pSprite->x;

View file

@ -637,7 +637,7 @@ void playerStart(int nPlayer, int bNewLevel)
if (maxRetries != 0) { if (maxRetries != 0) {
// check if there is no spawned player in selected zone // check if there is no spawned player in selected zone
BloodSectIterator it(pStartZone->sectnum); BloodSectIterator it(pStartZone->sector);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
spritetype* pSprite = &act->s(); spritetype* pSprite = &act->s();
@ -658,7 +658,7 @@ void playerStart(int nPlayer, int bNewLevel)
pStartZone = &gStartZone[Random(8)]; pStartZone = &gStartZone[Random(8)];
} }
auto actor = actSpawnSprite(pStartZone->sectnum, pStartZone->x, pStartZone->y, pStartZone->z, 6, 1); auto actor = actSpawnSprite(pStartZone->sector, pStartZone->x, pStartZone->y, pStartZone->z, 6, 1);
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
assert(actor->hasX()); assert(actor->hasX());
XSPRITE *pXSprite = &actor->x(); XSPRITE *pXSprite = &actor->x();

View file

@ -73,7 +73,7 @@ void warpInit(void)
pZone->x = pSprite->x; pZone->x = pSprite->x;
pZone->y = pSprite->y; pZone->y = pSprite->y;
pZone->z = pSprite->z; pZone->z = pSprite->z;
pZone->sectnum = pSprite->sectnum; pZone->sector = pSprite->sector();
pZone->ang = pSprite->ang; pZone->ang = pSprite->ang;
} }
DeleteSprite(actor); DeleteSprite(actor);
@ -86,7 +86,7 @@ void warpInit(void)
pZone->x = pSprite->x; pZone->x = pSprite->x;
pZone->y = pSprite->y; pZone->y = pSprite->y;
pZone->z = pSprite->z; pZone->z = pSprite->z;
pZone->sectnum = pSprite->sectnum; pZone->sector = pSprite->sector();
pZone->ang = pSprite->ang; pZone->ang = pSprite->ang;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
@ -97,7 +97,7 @@ void warpInit(void)
pZone->x = pSprite->x; pZone->x = pSprite->x;
pZone->y = pSprite->y; pZone->y = pSprite->y;
pZone->z = pSprite->z; pZone->z = pSprite->z;
pZone->sectnum = pSprite->sectnum; pZone->sector = pSprite->sector();
pZone->ang = pSprite->ang; pZone->ang = pSprite->ang;
team1++; team1++;
@ -106,7 +106,7 @@ void warpInit(void)
pZone->x = pSprite->x; pZone->x = pSprite->x;
pZone->y = pSprite->y; pZone->y = pSprite->y;
pZone->z = pSprite->z; pZone->z = pSprite->z;
pZone->sectnum = pSprite->sectnum; pZone->sector = pSprite->sector();
pZone->ang = pSprite->ang; pZone->ang = pSprite->ang;
team2++; team2++;
} }
@ -320,7 +320,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, ZONE& w, ZONE* def
arc("x", w.x) arc("x", w.x)
("y", w.y) ("y", w.y)
("z", w.z) ("z", w.z)
("sector", w.sectnum) ("sector", w.sector)
("angle", w.ang) ("angle", w.ang)
.EndObject(); .EndObject();
} }