CWorld fixes, CActor fixes

This commit is contained in:
Phillip Stephens
2026-01-20 13:41:07 -08:00
parent 4295781058
commit 8e8594c8a7
11 changed files with 110 additions and 105 deletions
+1 -1
View File
@@ -1352,7 +1352,7 @@ fn_80056FE8 = .text:0x80056FE8; // type:function size:0x8C
fn_80057074 = .text:0x80057074; // type:function size:0x50
fn_800570C4 = .text:0x800570C4; // type:function size:0x24
fn_800570E8 = .text:0x800570E8; // type:function size:0xF0
LoadRelays__FR12CInputStreamRQ24rstl44vector<Q26SRelay,Q24rstl17rmemory_allocator> = .text:0x800571D8; // type:function size:0xF8 scope:global
__ct__Q24rstl42vector<6CRelay,Q24rstl17rmemory_allocator>FR12CInputStreamRCQ24rstl17rmemory_allocator = .text:0x800571D8; // type:function size:0xF8 scope:global
__dt__11CDummyWorldFv = .text:0x800572D0; // type:function size:0xDC scope:global
fn_800573AC = .text:0x800573AC; // type:function size:0xD0
__ct__11CDummyWorldFUi = .text:0x8005747C; // type:function size:0x138 scope:global
+1 -1
View File
@@ -1352,7 +1352,7 @@ fn_80056FE8 = .text:0x80057064; // type:function size:0x8C scope:global
fn_80057074 = .text:0x800570F0; // type:function size:0x50 scope:global
fn_800570C4 = .text:0x80057140; // type:function size:0x24 scope:global
fn_800570E8 = .text:0x80057164; // type:function size:0xF0 scope:global
LoadRelays__FR12CInputStreamRQ24rstl44vector<Q26SRelay,Q24rstl17rmemory_allocator> = .text:0x80057254; // type:function size:0xF8 scope:global
__ct__Q24rstl42vector<6CRelay,Q24rstl17rmemory_allocator>FR12CInputStreamRCQ24rstl17rmemory_allocator = .text:0x80057254; // type:function size:0xF8 scope:global
__dt__11CDummyWorldFv = .text:0x8005734C; // type:function size:0xDC scope:global
fn_800573AC = .text:0x80057428; // type:function size:0xD0 scope:global
__ct__11CDummyWorldFUi = .text:0x800574F8; // type:function size:0x138 scope:global
+1 -1
View File
@@ -40,7 +40,7 @@ public:
CModelFlags(const ETrans blendMode, const uchar shadIdx, const EFlags flags, const CColor& col)
: x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {}
CModelFlags(const CModelFlags& flags, uint otherFlags)
CModelFlags(const CModelFlags& flags, const uint otherFlags)
: x0_blendMode(flags.x0_blendMode)
, x1_matSetIdx(flags.x1_matSetIdx)
, x2_flags(otherFlags)
+1 -1
View File
@@ -34,7 +34,7 @@ public:
void Get(void* dest, unsigned long len);
template < typename T >
inline T Get(const TType< T >& type = TType< T >()) {
T Get(const TType< T >& type = TType< T >()) {
return cinput_stream_helper(TType< T >(), *this);
}
+2 -2
View File
@@ -53,9 +53,9 @@ public:
const TLockedToken< CSkinnedModel >& GetModelData() const { return xd8_modelData; }
void SetIsAnimating(bool v) { x220_24_animating = v; }
void SetParticleEffectState(const rstl::string& name, const bool active, CStateManager& mgr); /* {
void SetParticleEffectState(const rstl::string& name, const bool active, CStateManager& mgr) {
x120_particleDB.SetParticleEffectState(name, active, mgr);
}*/
}
int GetCharacterIndex() const { return x204_charIdx; }
float GetAverageVelocity(int idx) const;
+1 -1
View File
@@ -302,7 +302,7 @@ class CDummyGameArea final : public IGameArea {
friend class CDummyWorld;
public:
CDummyGameArea(CInputStream& in, int idx, int mlvlVersion);
CDummyGameArea(CInputStream& in, int idx, uint mlvlVersion);
rstl::pair< rstl::auto_ptr< uchar >, int > IGetScriptingMemoryAlways() const override;
int IGetAreaSaveId() const override;
CAssetId IGetAreaAssetId() const override;
-1
View File
@@ -151,7 +151,6 @@ public:
bool IsMapAreaInBFSInfoVector(const CMapAreaData* area,
const rstl::vector< CMapAreaBFSInfo >& vec) const;
void SetWhichMapAreasLoaded(const IWorld& wld, int start, int count);
bool IsMapAreasStreaming();
void MoveMapAreaToList(CMapAreaData* data, EMapAreaList list);
int GetCurrentMapAreaDepth(const IWorld& wld, TAreaId aid);
rstl::vector< int > GetVisibleAreas(const IWorld& wld, const CMapWorldInfo& mwInfo) const;
+4 -1
View File
@@ -123,7 +123,9 @@ public:
const CGameArea& GetAreaAlways(const TAreaId id) const { return *x18_areas[id.Value()]; }
CGameArea* Area(const TAreaId id) { return &*x18_areas[id.Value()]; }
const CGameArea* GetArea(const TAreaId id) const { return &*x18_areas[id.Value()]; }
bool IsAreaValid(const TAreaId id) const { return x18_areas[id.Value()]->IsLoaded(); }
bool IsAreaValid(const TAreaId id) const {
return x18_areas[id.Value()]->IsLoaded();
}
CAssetId GetWorldAssetId() const { return x8_mlvlId; }
TAreaId GetCurrentAreaId() const { return x68_curAreaId; }
TAreaId GetAreaIdForSaveId(int saveId) const;
@@ -149,6 +151,7 @@ public:
void SetAreaAttributes(const TAreaId aid, CScriptAreaAttributes* attr) {
Area(aid)->SetAreaAttributes(attr);
}
private:
enum Phase {
+91 -90
View File
@@ -36,9 +36,10 @@ static CMaterialList MakeActorMaterialList(const CMaterialList& in,
return ret;
}
CActor::CActor(TUniqueId uid, bool active, const rstl::string& name, const CEntityInfo& info,
const CTransform4f& xf, const CModelData& mData, const CMaterialList& list,
const CActorParameters& params, TUniqueId nextDrawNode)
CActor::CActor(const TUniqueId uid, const bool active, const rstl::string& name,
const CEntityInfo& info, const CTransform4f& xf, const CModelData& mData,
const CMaterialList& list, const CActorParameters& params,
const TUniqueId nextDrawNode)
: CEntity(uid, info, active, name)
, x34_transform(xf)
, x64_modelData(mData.IsNull() ? nullptr : rs_new CModelData(mData))
@@ -232,27 +233,23 @@ void CActor::PreRender(CStateManager& mgr, const CFrustumPlanes& planes) {
}
if (GetCalculateLighting()) {
CAABox bounds = GetModelData()->GetBounds(GetTransform());
const CAABox bounds = GetModelData()->GetBounds(GetTransform());
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::kPV_Thermal) {
ActorLights()->BuildConstantAmbientLighting();
} else {
if (lightsDirty == true) {
if (GetCurrentAreaId() != kInvalidAreaId) {
TAreaId aid = GetCurrentAreaId();
if (mgr.GetWorld()->IsAreaValid(aid)) {
const CGameArea* area = mgr.GetWorld()->GetArea(aid);
if (ActorLights()->BuildAreaLightList(mgr, *area, bounds)) {
xe7_28_worldLightingDirty = false;
}
}
}
if (lightsDirty == true && GetCurrentAreaId() != kInvalidAreaId &&
mgr.GetWorld()->IsAreaValid(GetCurrentAreaId()) &&
ActorLights()->BuildAreaLightList(mgr, *mgr.GetWorld()->GetArea(GetCurrentAreaId()),
bounds)) {
xe7_28_worldLightingDirty = false;
}
ActorLights()->BuildDynamicLightList(mgr, bounds);
}
}
CModelData* mData = ModelData();
if (GetModelData()->HasAnimation()) {
AnimationData()->PreRender();
mData->AnimationData()->PreRender();
}
} else {
if (GetPreRenderHasMoved()) {
@@ -700,81 +697,86 @@ void CActor::SetInFluid(bool in, TUniqueId uid) {
}
// TODO nonmatching
void CActor::ProcessSoundEvent(int sfxId, float weight, int flags, float fallOff, float maxDist,
uchar minVol, uchar maxVol, const CVector3f& toListener,
const CVector3f& position, int aid, CStateManager& mgr,
bool translateId) {
if (toListener.MagSquared() >= maxDist * maxDist) {
return;
}
ushort id = translateId ? CSfxManager::TranslateSFXID(static_cast< ushort >(sfxId))
: static_cast< ushort >(sfxId);
uint musyxFlags = 0x1; // Continuous parameter update
if (flags & 0x8) {
musyxFlags |= 0x8; // Doppler FX
}
// TODO ctor?
CAudioSys::C3DEmitterParmData parms(maxDist, fallOff, musyxFlags, maxVol, minVol);
parms.x0_pos = position;
parms.xc_dir = CVector3f::Zero();
parms.x24_sfxId = id;
bool useAcoustics = (flags & 0x80) == 0;
bool looping = (sfxId & 0x80000000) != 0;
bool nonEmitter = (sfxId & 0x40000000) != 0;
if (mgr.Random()->Float() > weight) {
return;
}
if (looping) {
ushort curId = x88_sfxId;
if (!x8c_loopingSfxHandle) {
CSfxHandle handle;
if (nonEmitter) {
handle = CSfxManager::SfxStart(id, 1.f, 0.f, true, CSfxManager::kMedPriority, true, aid);
} else {
handle = CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid);
}
if (handle) {
x88_sfxId = id;
x8c_loopingSfxHandle = handle;
if (xe6_30_enablePitchBend) {
CSfxManager::PitchBend(handle, xc0_pitchBend);
}
}
} else if (curId == id) {
CSfxManager::UpdateEmitter(x8c_loopingSfxHandle, parms.x0_pos, parms.xc_dir, maxVol);
} else if (flags & 0x4) {
CSfxManager::RemoveEmitter(x8c_loopingSfxHandle);
CSfxHandle handle =
CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid);
if (handle) {
x88_sfxId = id;
x8c_loopingSfxHandle = handle;
if (xe6_30_enablePitchBend) {
CSfxManager::PitchBend(handle, xc0_pitchBend);
}
}
}
} else {
CSfxHandle handle;
if (nonEmitter) {
handle =
CSfxManager::SfxStart(id, 1.f, 0.f, useAcoustics, CSfxManager::kMedPriority, false, aid);
void CActor::ProcessSoundEvent(const int sfxId, const float weight, const int flags,
const float fallOff, const float maxDist, const uchar minVol,
const uchar maxVol, const CVector3f& toListener,
const CVector3f& position, const int aid, CStateManager& mgr,
const bool translateId) {
if (toListener.MagSquared() < maxDist * maxDist) {
ushort id;
if (translateId) {
id = CSfxManager::TranslateSFXID(sfxId);
} else {
handle = CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, false, aid);
}
if ((sfxId & 0x20000000) != 0 /* continuous update */) {
xd8_nonLoopingSfxHandles[xe4_24_nextNonLoopingSfxHandle] = handle;
xe4_24_nextNonLoopingSfxHandle =
(xe4_24_nextNonLoopingSfxHandle + 1) % xd8_nonLoopingSfxHandles.size();
id = static_cast<ushort>(sfxId);
}
if (xe6_30_enablePitchBend) {
CSfxManager::PitchBend(handle, xc0_pitchBend);
uint musyxFlags = 0x1; // Continuous parameter update
if (flags & 0x8) {
musyxFlags |= 0x8; // Doppler FX
}
// TODO ctor?
CAudioSys::C3DEmitterParmData parms(maxDist, fallOff, musyxFlags, maxVol, minVol);
parms.x0_pos = position;
parms.xc_dir = CVector3f::Zero();
parms.x24_sfxId = id;
bool useAcoustics = (flags & 0x80) == 0;
bool looping = (sfxId & 0x80000000) != 0;
bool nonEmitter = (sfxId & 0x40000000) != 0;
if (mgr.Random()->Float() <= weight) {
if (looping) {
ushort curId = x88_sfxId;
if (!x8c_loopingSfxHandle) {
CSfxHandle handle;
if (nonEmitter) {
handle =
CSfxManager::SfxStart(id, 1.f, 0.f, true, CSfxManager::kMedPriority, true, aid);
} else {
handle =
CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid);
}
if (handle) {
x88_sfxId = id;
x8c_loopingSfxHandle = handle;
if (xe6_30_enablePitchBend) {
CSfxManager::PitchBend(handle, xc0_pitchBend);
}
}
} else if (curId == id) {
CSfxManager::UpdateEmitter(x8c_loopingSfxHandle, parms.x0_pos, parms.xc_dir, maxVol);
} else if (flags & 0x4) {
CSfxManager::RemoveEmitter(x8c_loopingSfxHandle);
CSfxHandle handle =
CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid);
if (handle) {
x88_sfxId = id;
x8c_loopingSfxHandle = handle;
if (xe6_30_enablePitchBend) {
CSfxManager::PitchBend(handle, xc0_pitchBend);
}
}
}
} else {
CSfxHandle handle;
if (nonEmitter) {
handle = CSfxManager::SfxStart(id, 1.f, 0.f, useAcoustics, CSfxManager::kMedPriority,
false, aid);
} else {
handle =
CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, false, aid);
}
if ((sfxId & 0x20000000) != 0 /* continuous update */) {
xd8_nonLoopingSfxHandles[xe4_24_nextNonLoopingSfxHandle] = handle;
xe4_24_nextNonLoopingSfxHandle =
(xe4_24_nextNonLoopingSfxHandle + 1) % xd8_nonLoopingSfxHandles.size();
}
if (xe6_30_enablePitchBend) {
CSfxManager::PitchBend(handle, xc0_pitchBend);
}
}
}
}
}
@@ -814,10 +816,9 @@ void CActor::SetDrawShadow(bool enabled) {
xe5_24_shadowEnabled = enabled;
}
// TODO nonmatching
bool CActor::CanDrawStatic() const {
if (!GetActive() || !HasModelData() || xb4_drawFlags.GetTrans() > 4) {
return false;
if (!GetActive() || !HasModelData() || static_cast< char >(xb4_drawFlags.GetBlendMode()) > 4) {
return false;
}
if (GetModelData()->IsNull() || GetModelData()->HasAnimation()) {
return false;
+1
View File
@@ -7,6 +7,7 @@
#define ROUND_UP_32(val) (((val) + 31) & ~31)
rstl::pair< rstl::auto_ptr< uchar >, int > GetScriptingMemoryAlways(const IGameArea& area) {
SObjectTag tag('MREA', area.IGetAreaAssetId());
+7 -6
View File
@@ -269,13 +269,13 @@ CDummyWorld::CDummyWorld(CAssetId mlvlId, bool loadMap)
class CMemoryRelays {
public:
CMemoryRelays(CInputStream& in /*, const int& unk*/);
CMemoryRelays(CInputStream& in, const int& unk);
private:
rstl::vector< CRelay > x0_relayList;
};
CMemoryRelays::CMemoryRelays(CInputStream& in /*, const int& unk*/) {
CMemoryRelays::CMemoryRelays(CInputStream& in, const int&) {
int count = in.Get< int >();
x0_relayList.reserve(count);
for (int i = 0; i < count; ++i) {
@@ -283,8 +283,10 @@ CMemoryRelays::CMemoryRelays(CInputStream& in /*, const int& unk*/) {
}
}
void LoadRelays(CInputStream& in, rstl::vector< CRelay >& relays) {}
CDummyWorld::~CDummyWorld() {}
#pragma inline_max_size(250)
// TOOD nonmatching
bool CDummyWorld::ICheckWorldComplete() {
switch (x8_phase) {
@@ -305,10 +307,7 @@ bool CDummyWorld::ICheckWorldComplete() {
r.ReadLong();
}
if (version >= 17) {
// TOOD: this class takes some stack argument in r5
// but I can't figure out what it is
// int unk;
CMemoryRelays relays(r /*, unk*/);
rstl::vector< CRelay > relay(r);
}
int areaCount = r.Get< int >();
@@ -406,3 +405,5 @@ TAreaId CDummyWorld::IGetAreaId(CAssetId id) const {
return TAreaId(-1);
#endif
}
rstl::string CDummyWorld::IGetDefaultAudioTrack() const { return rstl::string_l(""); }