mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 04:20:42 +00:00
- added coreactor.h
This commit is contained in:
parent
e526686d1e
commit
52c80f187a
10 changed files with 167 additions and 42 deletions
|
@ -90,7 +90,6 @@ enum {
|
|||
RS_CENTERORIGIN = (1<<30),
|
||||
};
|
||||
|
||||
|
||||
#include "buildtypes.h"
|
||||
|
||||
using uspriteptr_t = spritetype const *;
|
||||
|
@ -693,18 +692,6 @@ extern int32_t(*animateoffs_replace)(int const tilenum, int fakevar);
|
|||
extern void(*initspritelists_replace)(void);
|
||||
extern int32_t(*changespritesect_replace)(int16_t spritenum, int16_t newsectnum);
|
||||
|
||||
// Masking these into the object index to keep it in 16 bit was probably the single most dumbest and pointless thing Build ever did.
|
||||
// Gonna be fun to globally replace these to finally lift the limit this imposes on map size.
|
||||
// Names taken from DukeGDX
|
||||
enum EHitBits
|
||||
{
|
||||
kHitNone = 0,
|
||||
kHitTypeMask = 0xC000,
|
||||
kHitIndexMask = 0x3FFF,
|
||||
kHitSector = 0x4000,
|
||||
kHitWall = 0x8000,
|
||||
kHitSprite = 0xC000,
|
||||
};
|
||||
|
||||
void updateModelInterpolation();
|
||||
|
||||
|
|
141
source/core/coreactor.h
Normal file
141
source/core/coreactor.h
Normal file
|
@ -0,0 +1,141 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "buildtypes.h"
|
||||
|
||||
class DCoreActor
|
||||
{
|
||||
// common part of the game actors
|
||||
protected:
|
||||
int index;
|
||||
|
||||
public:
|
||||
|
||||
spritetype& s()
|
||||
{
|
||||
return sprite[index];
|
||||
}
|
||||
|
||||
int GetIndex()
|
||||
{
|
||||
// For error printing only! This is only identical with the sprite index for items spawned at map start.
|
||||
return s().time;
|
||||
}
|
||||
|
||||
int GetSpriteIndex()
|
||||
{
|
||||
// this is only here to mark places that need changing later! It will be removed once the sprite array goes.
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sectortype* sector()
|
||||
{
|
||||
return s().sector();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
// holds pointers to the game-side actors.
|
||||
inline DCoreActor* actorArray[16384];
|
||||
extern TArray<sectortype> sector;
|
||||
extern TArray<walltype> wall;
|
||||
|
||||
|
||||
// Masking these into the object index to keep it in 16 bit was probably the single most dumbest and pointless thing Build ever did.
|
||||
// Gonna be fun to globally replace these to finally lift the limit this imposes on map size.
|
||||
// Names taken from DukeGDX
|
||||
enum EHitBits
|
||||
{
|
||||
kHitNone = 0,
|
||||
kHitTypeMask = 0xC000,
|
||||
kHitTypeMaskSW = 0x1C000, // SW has one more relevant bit
|
||||
kHitIndexMask = 0x3FFF,
|
||||
kHitSector = 0x4000,
|
||||
kHitWall = 0x8000,
|
||||
kHitSprite = 0xC000,
|
||||
kHitVoid = 0x10000, // SW only
|
||||
|
||||
|
||||
};
|
||||
|
||||
// This serves as input/output for all functions dealing with collisions, hits, etc.
|
||||
// Not all utilities use all variables.
|
||||
template<class TActor>
|
||||
struct HitInfoBase
|
||||
{
|
||||
static_assert(std::is_convertible_v<TActor*, DCoreActor*>, "Actor class for Collision needs to inherit from DCoreActor");
|
||||
|
||||
int type;
|
||||
vec3_t hitpos;
|
||||
sectortype* hitSector;
|
||||
walltype* hitWall;
|
||||
TActor* hitActor;
|
||||
|
||||
HitInfoBase() = default;
|
||||
explicit HitInfoBase(int legacyval) { setFromEngine(legacyval); }
|
||||
|
||||
void invalidate()
|
||||
{
|
||||
*this = {};
|
||||
type = -1; // something invalid that's not a valid hit type.
|
||||
}
|
||||
|
||||
int setNone()
|
||||
{
|
||||
*this = {};
|
||||
return kHitNone;
|
||||
}
|
||||
|
||||
int setSector(int num)
|
||||
{
|
||||
*this = {};
|
||||
type = kHitSector;
|
||||
hitSector = §or[num];
|
||||
return kHitSector;
|
||||
}
|
||||
|
||||
int setWall(int num)
|
||||
{
|
||||
*this = {};
|
||||
type = kHitWall;
|
||||
hitWall = &wall[num];
|
||||
return kHitWall;
|
||||
}
|
||||
|
||||
int setSprite(int num)
|
||||
{
|
||||
*this = {};
|
||||
type = kHitSprite;
|
||||
hitActor = static_cast<TActor*>(actorArray[num]);
|
||||
return kHitSprite;
|
||||
}
|
||||
|
||||
int setSprite(TActor* num)
|
||||
{
|
||||
*this = {};
|
||||
type = kHitSprite;
|
||||
hitActor = num;
|
||||
return kHitSprite;
|
||||
}
|
||||
|
||||
int setVoid()
|
||||
{
|
||||
*this = {};
|
||||
type = kHitVoid;
|
||||
return kHitVoid;
|
||||
}
|
||||
|
||||
// this hack job needs to go. We still need it for the time being.
|
||||
int setFromEngine(int value)
|
||||
{
|
||||
type = value & kHitTypeMaskSW;
|
||||
if (type == kHitSector) setSector(value & kHitIndexMask);
|
||||
else if (type == kHitWall) setWall(value & kHitIndexMask);
|
||||
else if (type == kHitSprite) setSprite(value & kHitIndexMask);
|
||||
else setNone();
|
||||
return type;
|
||||
}
|
||||
};
|
|
@ -425,6 +425,10 @@ void GameInterface::loadPalette(void)
|
|||
|
||||
void GameInterface::app_init()
|
||||
{
|
||||
for (int i = 0; i < MAXSPRITES; i++)
|
||||
{
|
||||
actorArray[i] = &bloodActors[i];
|
||||
}
|
||||
InitCheats();
|
||||
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
|
||||
gGameOptions.nMonsterSettings = !userConfig.nomonsters;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "coreactor.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
class DBloodActor;
|
||||
|
@ -90,11 +92,8 @@ struct SPRITEHIT
|
|||
Collision hit, ceilhit, florhit;
|
||||
};
|
||||
|
||||
// Due to the messed up array storage of all the game data we cannot do any direct references here yet. We have to access everything via wrapper functions for now.
|
||||
// Note that the indexing is very inconsistent - partially by sprite index, partially by xsprite index.
|
||||
class DBloodActor
|
||||
class DBloodActor : public DCoreActor
|
||||
{
|
||||
int index;
|
||||
DBloodActor* base();
|
||||
|
||||
public:
|
||||
|
@ -116,7 +115,11 @@ public:
|
|||
int cumulDamage;
|
||||
bool interpolated;
|
||||
|
||||
DBloodActor() :index(int(this - base())) {}
|
||||
DBloodActor()
|
||||
{
|
||||
index = (int(this - base()));
|
||||
}
|
||||
|
||||
DBloodActor& operator=(const DBloodActor& other) = default;
|
||||
|
||||
void Clear()
|
||||
|
@ -138,10 +141,7 @@ public:
|
|||
bool hasX() { return hasx; }
|
||||
void addX() { hasx = true; }
|
||||
|
||||
spritetype& s() { return sprite[index]; }
|
||||
XSPRITE& x() { return xsprite; } // calling this does not validate the xsprite!
|
||||
int GetIndex() { return s().time; } // For error printing only! This is only identical with the sprite index for items spawned at map start.
|
||||
int GetSpriteIndex() { return index; } // this is only here to mark places that need changing later!
|
||||
|
||||
void SetOwner(DBloodActor* own)
|
||||
{
|
||||
|
@ -237,11 +237,6 @@ public:
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sectortype* sector()
|
||||
{
|
||||
return s().sector();
|
||||
}
|
||||
};
|
||||
|
||||
extern DBloodActor bloodActors[kMaxSprites];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include "coreactor.h"
|
||||
#include "names.h"
|
||||
#include "packet.h"
|
||||
#include "d_net.h"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "coreactor.h"
|
||||
|
||||
BEGIN_PS_NS
|
||||
|
||||
class DExhumedActor;
|
||||
|
|
|
@ -39,6 +39,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "build.h"
|
||||
#include "d_net.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "coreactor.h"
|
||||
|
||||
#include "mytypes.h"
|
||||
#include "sounds.h"
|
||||
|
|
|
@ -404,7 +404,7 @@ int DoBloodSpray(DSWActor* actor)
|
|||
{
|
||||
switch (u->coll.type)
|
||||
{
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
KillActor(actor);
|
||||
return true;
|
||||
case kHitSprite:
|
||||
|
@ -603,7 +603,7 @@ int DoPhosphorus(DSWActor* actor)
|
|||
{
|
||||
switch (u->coll.type)
|
||||
{
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
KillActor(actor);
|
||||
return true;
|
||||
case kHitSprite:
|
||||
|
@ -818,7 +818,7 @@ int DoChemBomb(DSWActor* actor)
|
|||
{
|
||||
switch (u->coll.type)
|
||||
{
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
KillActor(actor);
|
||||
return true;
|
||||
case kHitSprite:
|
||||
|
@ -1053,7 +1053,7 @@ int DoCaltrops(DSWActor* actor)
|
|||
{
|
||||
switch (u->coll.type)
|
||||
{
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
KillActor(actor);
|
||||
return true;
|
||||
case kHitSprite:
|
||||
|
|
|
@ -145,12 +145,6 @@ public:
|
|||
};
|
||||
|
||||
|
||||
enum EHitBitsSW
|
||||
{
|
||||
kHitTypeMaskSW = 0x1C000,
|
||||
kHitSky = 0x10000, // SW only
|
||||
};
|
||||
|
||||
|
||||
inline int Collision::setNone()
|
||||
{
|
||||
|
@ -186,7 +180,7 @@ inline int Collision::setSprite(DSWActor* num)
|
|||
return kHitSprite;
|
||||
}
|
||||
|
||||
int Collision::setSky() { setNone(); type = kHitSky; return kHitSky; }
|
||||
int Collision::setSky() { setNone(); type = kHitVoid; return kHitVoid; }
|
||||
|
||||
inline int Collision::setFromEngine(int value)
|
||||
{
|
||||
|
|
|
@ -4300,7 +4300,7 @@ bool WeaponMoveHit(DSWActor* actor)
|
|||
default:
|
||||
break;
|
||||
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
SetSuicide(actor);
|
||||
return true;
|
||||
|
||||
|
@ -8474,7 +8474,7 @@ int DoGrenade(DSWActor* actor)
|
|||
{
|
||||
switch (u->coll.type)
|
||||
{
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
KillActor(actor);
|
||||
return true;
|
||||
case kHitSprite:
|
||||
|
@ -8705,7 +8705,7 @@ int DoVulcanBoulder(DSWActor* actor)
|
|||
{
|
||||
switch (u->coll.type)
|
||||
{
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
KillActor(actor);
|
||||
return true;
|
||||
case kHitSprite:
|
||||
|
@ -9090,7 +9090,7 @@ int DoMine(DSWActor* actor)
|
|||
// check to see if you hit a sprite
|
||||
switch (u->coll.type)
|
||||
{
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
KillActor(actor);
|
||||
return 0;
|
||||
case kHitSprite:
|
||||
|
@ -19197,7 +19197,7 @@ int DoShrapVelocity(DSWActor* actor)
|
|||
{
|
||||
switch (u->coll.type)
|
||||
{
|
||||
case kHitSky:
|
||||
case kHitVoid:
|
||||
KillActor(actor);
|
||||
return true;
|
||||
case kHitSprite:
|
||||
|
|
Loading…
Reference in a new issue