Various bug fixes

This commit is contained in:
Jack Andersen 2017-11-25 17:04:25 -10:00
parent 80f98e1218
commit 11d17d0fe5
34 changed files with 481 additions and 80 deletions

View File

@ -16,7 +16,7 @@ struct IElement : BigYAML
virtual const char* ClassID() const=0;
};
struct IRealElement : IElement {Delete _d;};
struct IRealElement : IElement {Delete _d2;};
struct RealElementFactory : BigYAML
{
Delete _d;
@ -30,7 +30,7 @@ struct RealElementFactory : BigYAML
void write(athena::io::IStreamWriter& w) const;
};
struct IIntElement : IElement {Delete _d;};
struct IIntElement : IElement {Delete _d2;};
struct IntElementFactory : BigYAML
{
Delete _d;
@ -44,7 +44,7 @@ struct IntElementFactory : BigYAML
void write(athena::io::IStreamWriter& w) const;
};
struct IVectorElement : IElement {Delete _d;};
struct IVectorElement : IElement {Delete _d2;};
struct VectorElementFactory : BigYAML
{
Delete _d;
@ -58,7 +58,7 @@ struct VectorElementFactory : BigYAML
void write(athena::io::IStreamWriter& w) const;
};
struct IColorElement : IElement {Delete _d;};
struct IColorElement : IElement {Delete _d2;};
struct ColorElementFactory : BigYAML
{
Delete _d;
@ -72,7 +72,7 @@ struct ColorElementFactory : BigYAML
void write(athena::io::IStreamWriter& w) const;
};
struct IModVectorElement : IElement {Delete _d;};
struct IModVectorElement : IElement {Delete _d2;};
struct ModVectorElementFactory : BigYAML
{
Delete _d;
@ -86,7 +86,7 @@ struct ModVectorElementFactory : BigYAML
void write(athena::io::IStreamWriter& w) const;
};
struct IEmitterElement : IElement {Delete _d;};
struct IEmitterElement : IElement {Delete _d2;};
struct EmitterElementFactory : BigYAML
{
Delete _d;
@ -102,13 +102,13 @@ struct EmitterElementFactory : BigYAML
struct IUVElement : IElement
{
Delete _d;
Delete _d2;
virtual void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const=0;
};
struct BoolHelper : IElement
{
Delete _d;
Delete _d2;
bool value = false;
operator bool() const {return value;}
BoolHelper& operator=(bool val) {value = val; return *this;}
@ -151,7 +151,7 @@ struct RELifetimeTween : IRealElement
struct REConstant : IRealElement
{
Delete _d;
Delete _d3;
Value<float> val;
void read(athena::io::YAMLDocReader& r)
@ -464,7 +464,7 @@ struct IEAdd : IIntElement
struct IEConstant : IIntElement
{
Delete _d;
Delete _d3;
Value<atUint32> val;
void read(athena::io::YAMLDocReader& r)
@ -625,7 +625,7 @@ struct VECircleCluster : IVectorElement
struct VEConstant : IVectorElement
{
Delete _d;
Delete _d3;
RealElementFactory comps[3];
void read(athena::io::YAMLDocReader& r)
@ -772,7 +772,7 @@ struct CEKeyframeEmitter : IColorElement
struct CEConstant : IColorElement
{
Delete _d;
Delete _d3;
RealElementFactory comps[4];
void read(athena::io::YAMLDocReader& r)
@ -895,7 +895,7 @@ struct MVEBounce : IModVectorElement
struct MVEConstant : IModVectorElement
{
Delete _d;
Delete _d3;
RealElementFactory comps[3];
void read(athena::io::YAMLDocReader& r)
@ -1026,7 +1026,7 @@ struct VEAngleSphere : IEmitterElement
struct EESimpleEmitterTR : EESimpleEmitter
{
Delete _d;
Delete _d3;
void read(athena::io::YAMLDocReader& r)
{
@ -1078,7 +1078,7 @@ struct EESimpleEmitterTR : EESimpleEmitter
template <class IDType>
struct UVEConstant : IUVElement
{
Delete _d;
Delete _d3;
IDType tex;
void read(athena::io::YAMLDocReader& r)
{
@ -1119,7 +1119,7 @@ struct UVEConstant : IUVElement
template <class IDType>
struct UVEAnimTexture : IUVElement
{
Delete _d;
Delete _d3;
IDType tex;
IntElementFactory tileW;
IntElementFactory tileH;

View File

@ -183,7 +183,7 @@ struct ANCS : BigYAML
};
struct MetaAnimPrimitive : IMetaAnim
{
Delete expl;
Delete expl2;
MetaAnimPrimitive() : IMetaAnim(Type::Primitive, "Primitive") {}

View File

@ -64,7 +64,7 @@ struct EVNT : BigYAML
{
DECL_YAML
Value<atUint32> duration;
DNAFourCC type;
DNAFourCC ptype;
UniqueID32 id;
String<-1> locator;
Value<float> scale;

View File

@ -56,13 +56,13 @@ struct FRME : BigDNA
struct BWIGInfo : IWidgetInfo
{
Delete _d;
Delete _d2;
FourCC fourcc() const { return FOURCC('BWIG'); }
};
struct HWIGInfo : IWidgetInfo
{
Delete _d;
Delete _d2;
FourCC fourcc() const { return FOURCC('HWIG'); }
};

View File

@ -14,7 +14,7 @@ struct CameraBlurKeyframe : IScriptObject
DECL_YAML
String<-1> name;
Value<bool> active;
Value<atUint32> type;
Value<atUint32> btype;
Value<float> amount;
Value<atUint32> unk;
Value<float> timeIn;

View File

@ -14,7 +14,7 @@ struct CameraFilterKeyframe : IScriptObject
DECL_YAML
String<-1> name;
Value<bool> active;
Value<atUint32> type;
Value<atUint32> ftype;
Value<atUint32> shape;
Value<atUint32> filterIdx;
Value<atUint32> unk;

View File

@ -114,9 +114,9 @@ struct CHAR : BigYAML
Delete expl;
UniqueID64 caudId;
Value<atUint32> unk1;
Value<atUint32> unk2;
Value<atUint32> unk3;
Value<atUint32> unk1_;
Value<atUint32> unk2_;
Value<atUint32> unk3_;
std::vector<float> unk3Vals;
Value<atUint32> extraType;
Value<float> extraFloat;

View File

@ -546,10 +546,9 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da
hecl::ProjectPath outPath(m_project.getProjectWorkingPath(),
_S("out/") + components[0] + _S("/") + components[1] + _S(".upak"));
outPath.makeDirChain(false);
hecl::SystemString tmpPath = hecl::SystemString(outPath.getAbsolutePath()) + _S("~");
/* Output file */
athena::io::FileWriter pakOut(tmpPath);
athena::io::FileWriter pakOut(outPath.getAbsolutePath());
std::vector<urde::SObjectTag> buildList;
atUint64 resTableOffset = 0;
@ -656,9 +655,6 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da
/* Write file index */
writePakFileIndex(pakOut, buildList, fileIndex, resTableOffset);
pakOut.close();
/* Atomic rename */
hecl::Rename(tmpPath.c_str(), outPath.getAbsolutePath().data());
}
hecl::ProjectPath SpecBase::getCookedPath(const hecl::ProjectPath& working, bool pcTarget) const

View File

@ -1036,6 +1036,10 @@ void CStateManager::SendScriptMsg(CEntity* dest, TUniqueId src, EScriptObjectMes
{
if (dest && !dest->x30_26_scriptingBlocked)
{
#ifndef NDEBUG
LogModule.report(logvisor::Info, "Sending '%s' to '%s'",
ScriptObjectMessageToStr(msg).data(), dest->GetName().data());
#endif
dest->AcceptScriptMsg(msg, src, *this);
}
}
@ -1050,7 +1054,13 @@ void CStateManager::SendScriptMsgAlways(TUniqueId dest, TUniqueId src, EScriptOb
{
CEntity* dst = ObjectById(dest);
if (dst)
{
#ifndef NDEBUG
LogModule.report(logvisor::Info, "Sending '%s' to '%s'",
ScriptObjectMessageToStr(msg).data(), dst->GetName().data());
#endif
dst->AcceptScriptMsg(msg, src, *this);
}
}
void CStateManager::SendScriptMsg(TUniqueId src, TEditorId dest, EScriptObjectMessage msg, EScriptObjectState state)
@ -1110,6 +1120,10 @@ void CStateManager::FreeScriptObject(TUniqueId id)
x874_sortedListManager->Remove(act.GetPtr());
act->SetUseInSortedLists(false);
}
#ifndef NDEBUG
LogModule.report(logvisor::Info, "Removed '%s'", ent->GetName().data());
#endif
}
std::pair<const SScriptObjectStream*, TEditorId> CStateManager::GetBuildForScript(TEditorId id) const
@ -2083,7 +2097,7 @@ void CStateManager::CrossTouchActors()
ent2->Touch(actor, *this);
}
visits[ent2->GetUniqueId().Value()] = true;
visits[actor.GetUniqueId().Value()] = true;
}
}
}
@ -2383,14 +2397,14 @@ void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOu
void CStateManager::UpdateActorInSortedLists(CActor& act)
{
if (!act.GetUseInSortedLists() || !act.xe4_27_)
if (!act.GetUseInSortedLists() || !act.xe4_27_notInSortedLists)
return;
std::experimental::optional<zeus::CAABox> aabb = CalculateObjectBounds(act);
bool actorInLists = x874_sortedListManager->ActorInLists(&act);
if (actorInLists || aabb)
{
act.xe4_27_ = false;
act.xe4_27_notInSortedLists = false;
if (actorInLists)
{
if (!act.GetActive() || !aabb)
@ -2469,6 +2483,10 @@ void CStateManager::AddObject(CEntity& ent)
if (area->IsValidated())
SendScriptMsg(&ent, kInvalidUniqueId, EScriptObjectMessage::InitializedInArea);
}
#ifndef NDEBUG
LogModule.report(logvisor::Info, "Added '%s'", ent.GetName().data());
#endif
}
void CStateManager::AddObject(CEntity* ent)

View File

@ -746,7 +746,9 @@ bool CCameraManager::HasBallCameraInitialPositionHint(CStateManager& mgr) const
void CCameraManager::RemoveCinemaCamera(TUniqueId uid, CStateManager& mgr)
{
x4_cineCameras.erase(std::remove(x4_cineCameras.begin(), x4_cineCameras.end(), uid));
auto search = std::find(x4_cineCameras.begin(), x4_cineCameras.end(), uid);
if (search != x4_cineCameras.end())
x4_cineCameras.erase(search);
}
void CCameraManager::DeleteCameraHint(TUniqueId id, CStateManager& mgr)

View File

@ -652,7 +652,7 @@ CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Context& ctx,
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment };
size_t ubufOffs[] = {0, 0, 768};
size_t ubufSizes[] = {768, 768, 256};
size_t ubufSizes[] = {768, 768, sizeof(CModelShaders::LightingUniform)};
size_t texCount = 0;
boo::ObjToken<boo::ITexture> texs[7];
if (m_patternTex1)
@ -682,7 +682,7 @@ CFluidPlaneShader::BuildBinding(boo::VulkanDataFactory::Context& ctx,
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment };
size_t ubufOffs[] = {0, 0, 768};
size_t ubufSizes[] = {768, 768, 256};
size_t ubufSizes[] = {768, 768, sizeof(CModelShaders::LightingUniform)};
size_t texCount = 0;
boo::ObjToken<boo::ITexture> texs[7] = {};
if (m_patternTex1)

View File

@ -566,7 +566,7 @@ CFluidPlaneShader::BuildBinding(boo::ID3DDataFactory::Context& ctx,
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment };
size_t ubufOffs[] = {0, 0, 768};
size_t ubufSizes[] = {768, 768, 256};
size_t ubufSizes[] = {768, 768, sizeof(CModelShaders::LightingUniform)};
size_t texCount = 0;
boo::ObjToken<boo::ITexture> texs[7] = {};
if (m_patternTex1)

View File

@ -595,7 +595,7 @@ boo::ObjToken<boo::IShaderDataBinding> CFluidPlaneShader::BuildBinding(boo::Meta
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment };
size_t ubufOffs[] = {0, 0, 768};
size_t ubufSizes[] = {768, 768, 256};
size_t ubufSizes[] = {768, 768, sizeof(CModelShaders::LightingUniform)};
size_t texCount = 0;
boo::ObjToken<boo::ITexture> texs[7];
if (m_patternTex1)

View File

@ -32,7 +32,7 @@ CENTITY_TYPES = (
('CAi', 'World/CAi.hpp'),
('CPatterned', 'World/CPatterned.hpp'),
('CPhysicsActor', 'World/CPhysicsActor.hpp'),
('CPlayer', 'World/CPhysicsActor.hpp'),
('CPlayer', 'World/CPlayer.hpp'),
('CRepulsor', 'World/CRepulsor.hpp'),
('CScriptActor', 'World/CScriptActor.hpp'),
('CScriptActorKeyframe', 'World/CScriptActorKeyframe.hpp'),
@ -188,6 +188,8 @@ for tp in CENTITY_TYPES:
sourcef.write('''template <class T>
void TCastToPtr<T>::Visit(%s* p)
{
static_assert(sizeof(T) > 0, "TCastToPtr can not cast to incomplete type");
static_assert(!std::is_void<T>::value, "TCastToPtr can not cast to incomplete type");
ptr = reinterpret_cast<T*>(std::is_convertible<%s*, T*>::value ? p : nullptr);
}

View File

@ -22,9 +22,10 @@ static CMaterialList MakeActorMaterialList(const CMaterialList& materialList, co
return ret;
}
CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& info, const zeus::CTransform&,
CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CMaterialList& list, const CActorParameters& params, TUniqueId otherUid)
: CEntity(uid, info, active, name)
, x34_transform(xf)
, x68_material(MakeActorMaterialList(list, params))
, x70_materialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {0ull}))
, xc6_nextDrawNode(otherUid)
@ -34,7 +35,7 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI
x64_modelData = std::make_unique<CModelData>(std::move(mData));
xd0_ = params.x64_;
xd8_nonLoopingSfxHandles.resize(2);
xe4_27_ = true;
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_29_actorLightsDirty = true;
xe4_31_lightsDirty = true;
@ -315,7 +316,7 @@ void CActor::SetSoundEventPitchBend(s32 val)
void CActor::SetRotation(const zeus::CQuaternion &q)
{
x34_transform = q.toTransform(x34_transform.origin);
xe4_27_ = true;
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_29_actorLightsDirty = true;
}
@ -323,7 +324,7 @@ void CActor::SetRotation(const zeus::CQuaternion &q)
void CActor::SetTranslation(const zeus::CVector3f& tr)
{
x34_transform.origin = tr;
xe4_27_ = true;
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_29_actorLightsDirty = true;
}
@ -331,7 +332,7 @@ void CActor::SetTranslation(const zeus::CVector3f& tr)
void CActor::SetTransform(const zeus::CTransform& tr)
{
x34_transform = tr;
xe4_27_ = true;
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_29_actorLightsDirty = true;
}

View File

@ -53,7 +53,7 @@ protected:
struct
{
u8 xe4_24_nextNonLoopingSfxHandle : 3;
bool xe4_27_ : 1;
bool xe4_27_notInSortedLists : 1;
bool xe4_28_ : 1;
bool xe4_29_actorLightsDirty : 1;
bool xe4_30_outOfFrustum : 1;
@ -103,7 +103,7 @@ public:
virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
virtual void SetActive(bool active)
{
xe4_27_ = true;
xe4_27_notInSortedLists = true;
xe4_28_ = true;
xe4_29_actorLightsDirty = true;
xe7_29_actorActive = active;

View File

@ -68,6 +68,8 @@ public:
const std::vector<SConnection>& GetConnectionList() const { return x20_conns; }
std::vector<SConnection>& ConnectionList() { return x20_conns; }
std::string_view GetName() const { return x10_name; }
};
}

View File

@ -0,0 +1,20 @@
#include "CFishCloud.hpp"
#include "CActorParameters.hpp"
namespace urde
{
CFishCloud::CFishCloud(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& info,
const zeus::CVector3f& scale, const zeus::CTransform& xf, CModelData&& mData,
const CAnimRes& aRes, u32 w1, float f1, float f2, float f3, float f4, float f5, float f6,
float f7, float f8, float f9, float f10, float f11, float f12, float f13, u32 w2,
const zeus::CColor& color, bool b1, float f14, CAssetId part1, u32 w3, CAssetId part2, u32 w4,
CAssetId part3, u32 w5, CAssetId part4, u32 w6, u32 w7, bool b2, bool b3)
: CActor(uid, active, name, info, xf, std::move(mData), {EMaterialTypes::Unknown},
CActorParameters::None(), kInvalidUniqueId)
{
}
}

View File

@ -0,0 +1,22 @@
#ifndef __URDE_CFISHCLOUD_HPP__
#define __URDE_CFISHCLOUD_HPP__
#include "CActor.hpp"
namespace urde
{
class CFishCloud : public CActor
{
public:
CFishCloud(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& info,
const zeus::CVector3f& scale, const zeus::CTransform& xf, CModelData&& mData,
const CAnimRes& aRes, u32 w1, float f1, float f2, float f3, float f4, float f5, float f6,
float f7, float f8, float f9, float f10, float f11, float f12, float f13, u32 w2,
const zeus::CColor& color, bool b1, float f14, CAssetId part1, u32 w3, CAssetId part2, u32 w4,
CAssetId part3, u32 w5, CAssetId part4, u32 w6, u32 w7, bool b2, bool b3);
};
}
#endif // __URDE_CFISHCLOUD_HPP__

View File

@ -11,6 +11,7 @@ CPhysicsActor::CPhysicsActor(TUniqueId uid, bool active, std::string_view name,
, xe8_mass(moverData.x30_mass)
, xec_massRecip(moverData.x30_mass <= 0.f ? 1.f : 1.f / moverData.x30_mass)
, x150_momentum(moverData.x18_momentum)
, x1a4_baseBoundingBox(box)
, x1c0_collisionPrimitive(box, matList)
, x1f4_lastNonCollidingState(xf.origin, xf.buildMatrix3f())
, x23c_stepUpHeight(stepUp)

View File

@ -0,0 +1,14 @@
#include "CScriptDebugCameraWaypoint.hpp"
#include "CActorParameters.hpp"
namespace urde
{
CScriptDebugCameraWaypoint::CScriptDebugCameraWaypoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, u32 w1)
: CActor(uid, true, name, info, xf, CModelData::CModelDataNull(), {EMaterialTypes::Unknown},
CActorParameters::None(), kInvalidUniqueId), xe8_w1(w1)
{
}
}

View File

@ -0,0 +1,19 @@
#ifndef __URDE_CSCRIPTDEBUGCAMERAWAYPOINT_HPP__
#define __URDE_CSCRIPTDEBUGCAMERAWAYPOINT_HPP__
#include "CActor.hpp"
namespace urde
{
class CScriptDebugCameraWaypoint : public CActor
{
u32 xe8_w1;
public:
CScriptDebugCameraWaypoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, u32 w1);
};
}
#endif // __URDE_CSCRIPTDEBUGCAMERAWAYPOINT_HPP__

View File

@ -0,0 +1,21 @@
#include "CScriptGunTurret.hpp"
namespace urde
{
static const CMaterialList skGunMaterialList = { EMaterialTypes::Solid, EMaterialTypes::Character,
EMaterialTypes::Orbit, EMaterialTypes::Target };
static const CMaterialList skTurretMaterialList = { EMaterialTypes::Character };
CScriptGunTurret::CScriptGunTurret(TUniqueId uid, std::string_view name, ETurretComponent comp, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const zeus::CAABox& aabb,
const CHealthInfo& hInfo, const CDamageVulnerability& dVuln,
const CActorParameters& aParms, const CScriptGunTurretData& turretData)
: CPhysicsActor(uid, true, name, info, xf, std::move(mData),
comp == ETurretComponent::Turret ? skTurretMaterialList : skGunMaterialList,
aabb, SMoverData(1000.f), aParms, 0.3f, 0.1f)
{
}
}

View File

@ -0,0 +1,32 @@
#ifndef __URDE_CSCRIPTGUNTURRET_HPP__
#define __URDE_CSCRIPTGUNTURRET_HPP__
#include "CPhysicsActor.hpp"
namespace urde
{
class CScriptGunTurretData
{
};
class CScriptGunTurret : public CPhysicsActor
{
public:
enum class ETurretComponent
{
Turret,
Gun
};
private:
public:
CScriptGunTurret(TUniqueId uid, std::string_view name, ETurretComponent comp, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const zeus::CAABox& aabb,
const CHealthInfo& hInfo, const CDamageVulnerability& dVuln,
const CActorParameters& aParms, const CScriptGunTurretData& turretData);
};
}
#endif // __URDE_CSCRIPTGUNTURRET_HPP__

View File

@ -24,39 +24,39 @@ void CScriptRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CS
}
else if (msg == EScriptObjectMessage::SetToZero)
{
if (x30_24_active)
if (!x30_24_active)
return;
x38_refCount++;
x38_sendCount++;
TUniqueId tmp = stateMgr.GetLastRelayId();
while (tmp != kInvalidUniqueId)
while (tmp != GetUniqueId() && tmp != kInvalidUniqueId)
{
const CEntity* obj = stateMgr.GetObjectById(tmp);
const CScriptRelay* obj = static_cast<const CScriptRelay*>(stateMgr.GetObjectById(tmp));
if (!obj)
{
tmp = x34_nextRelay;
continue;
tmp = kInvalidUniqueId;
break;
}
if (obj->GetUniqueId() == tmp)
break;
tmp = obj->x34_nextRelay;
}
if (tmp == kInvalidUniqueId)
return;
x34_nextRelay = stateMgr.GetLastRelayId();
stateMgr.SetLastRelayId(GetUniqueId());
{
x34_nextRelay = stateMgr.GetLastRelayId();
stateMgr.SetLastRelayId(GetUniqueId());
}
}
}
void CScriptRelay::Think(float, CStateManager& stateMgr)
{
if (x38_refCount == 0)
if (x38_sendCount == 0)
return;
while (x38_refCount != 0)
while (x38_sendCount != 0)
{
x38_refCount--;
x38_sendCount--;
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
}
UpdateObjectRef(stateMgr);
@ -65,14 +65,14 @@ void CScriptRelay::Think(float, CStateManager& stateMgr)
void CScriptRelay::UpdateObjectRef(CStateManager& stateMgr)
{
TUniqueId* tmp = stateMgr.GetLastRelayIdPtr();
while (*tmp != kInvalidUniqueId && tmp != nullptr)
while (tmp != nullptr && *tmp != kInvalidUniqueId)
{
if (*tmp == GetUniqueId())
{
*tmp = x34_nextRelay;
return;
}
CScriptRelay* obj = dynamic_cast<CScriptRelay*>(stateMgr.ObjectById(*tmp));
CScriptRelay* obj = static_cast<CScriptRelay*>(stateMgr.ObjectById(*tmp));
if (obj == nullptr)
return;
tmp = &obj->x34_nextRelay;

View File

@ -8,7 +8,7 @@ namespace urde
class CScriptRelay : public CEntity
{
TUniqueId x34_nextRelay = kInvalidUniqueId;
u32 x38_refCount = 0;
u32 x38_sendCount = 0;
public:
CScriptRelay(TUniqueId, std::string_view, const CEntityInfo&, bool);

View File

@ -11,8 +11,8 @@ namespace urde
CScriptTrigger::CScriptTrigger(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CVector3f& pos, const zeus::CAABox& bounds, const CDamageInfo& dInfo,
const zeus::CVector3f& forceField, ETriggerFlags triggerFlags, bool active, bool deactivateOnEntered,
bool deactivateOnExited)
const zeus::CVector3f& forceField, ETriggerFlags triggerFlags, bool active,
bool deactivateOnEntered, bool deactivateOnExited)
: CActor(uid, active, name, info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(),
CMaterialList(EMaterialTypes::Trigger), CActorParameters::None(), kInvalidUniqueId)
, x100_damageInfo(dInfo)
@ -44,9 +44,9 @@ void CScriptTrigger::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CS
x148_25_camSubmerged = false;
}
if (x148_28_playerDamage)
if (x148_28_playerTriggerProc)
{
x148_28_playerDamage = false;
x148_28_playerTriggerProc = false;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();
@ -97,9 +97,9 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr)
{
xe8_inhabitants.erase(it);
sendExited = true;
if (x148_28_playerDamage)
if (x148_28_playerTriggerProc)
{
x148_28_playerDamage = false;
x148_28_playerTriggerProc = false;
if (x148_29_didPhazonDamage)
{
mgr.GetPlayer().DecrementPhazon();
@ -150,9 +150,9 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr)
{
xe8_inhabitants.erase(it);
sendExited = true;
if (mgr.GetPlayer().GetUniqueId() == it->GetObjectId() && x148_28_playerDamage)
if (mgr.GetPlayer().GetUniqueId() == it->GetObjectId() && x148_28_playerTriggerProc)
{
x148_28_playerDamage = false;
x148_28_playerTriggerProc = false;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();
@ -169,9 +169,9 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr)
else
{
xe8_inhabitants.erase(it);
if (mgr.GetPlayer().GetUniqueId() == it->GetObjectId() && x148_28_playerDamage)
if (mgr.GetPlayer().GetUniqueId() == it->GetObjectId() && x148_28_playerTriggerProc)
{
x148_28_playerDamage = false;
x148_28_playerTriggerProc = false;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();
@ -259,7 +259,6 @@ void CScriptTrigger::Touch(CActor& act, CStateManager& mgr)
TCastToPtr<CPlayer> pl(act);
if (pl)
{
if (x128_forceMagnitude > 0.f && (x12c_flags & ETriggerFlags::DetectPlayer) != ETriggerFlags::None &&
mgr.GetLastTriggerId() == kInvalidUniqueId)
mgr.SetLastTriggerId(x8_uid);
@ -297,9 +296,9 @@ void CScriptTrigger::Touch(CActor& act, CStateManager& mgr)
if (pl)
{
if (!x148_28_playerDamage)
if (!x148_28_playerTriggerProc)
{
x148_28_playerDamage = true;
x148_28_playerTriggerProc = true;
if (x148_29_didPhazonDamage)
{
mgr.Player()->DecrementPhazon();

View File

@ -61,7 +61,7 @@ protected:
bool x148_25_camSubmerged : 1;
bool x148_26_deactivateOnEntered : 1;
bool x148_27_deactivateOnExited : 1;
bool x148_28_playerDamage : 1;
bool x148_28_playerTriggerProc : 1;
bool x148_29_didPhazonDamage : 1;
};
u8 dummy = 0;

View File

@ -1033,7 +1033,7 @@ CEntity* ScriptLoader::LoadCameraFilterKeyframe(CStateManager& mgr, CInputStream
return nullptr;
std::string name = mgr.HashInstanceName(in);
bool active = in.readBool();
EFilterType type = EFilterType(in.readUint32Big());
EFilterType ftype = EFilterType(in.readUint32Big());
EFilterShape shape = EFilterShape(in.readUint32Big());
u32 filterIdx = in.readUint32Big();
u32 unk = in.readUint32Big();
@ -1043,7 +1043,7 @@ CEntity* ScriptLoader::LoadCameraFilterKeyframe(CStateManager& mgr, CInputStream
float timeOut = in.readFloatBig();
CAssetId txtr = in.readUint32Big();
return new CScriptCameraFilterKeyframe(mgr.AllocateUniqueId(), name, info, type, shape, filterIdx, unk, color,
return new CScriptCameraFilterKeyframe(mgr.AllocateUniqueId(), name, info, ftype, shape, filterIdx, unk, color,
timeIn, timeOut, txtr, active);
}

View File

@ -0,0 +1,243 @@
#include "ScriptObjectSupport.hpp"
using namespace std::literals;
namespace urde
{
#ifndef NDEBUG
std::string_view ScriptObjectTypeToStr(EScriptObjectType type)
{
switch (type)
{
case EScriptObjectType::Actor: return "Actor"sv;
case EScriptObjectType::Waypoint: return "Waypoint"sv;
case EScriptObjectType::Door: return "Door"sv;
case EScriptObjectType::Trigger: return "Trigger"sv;
case EScriptObjectType::Timer: return "Timer"sv;
case EScriptObjectType::Counter: return "Counter"sv;
case EScriptObjectType::Effect: return "Effect"sv;
case EScriptObjectType::Platform: return "Platform"sv;
case EScriptObjectType::Sound: return "Sound"sv;
case EScriptObjectType::Generator: return "Generator"sv;
case EScriptObjectType::Dock: return "Dock"sv;
case EScriptObjectType::Camera: return "Camera"sv;
case EScriptObjectType::CameraWaypoint: return "CameraWaypoint"sv;
case EScriptObjectType::NewIntroBoss: return "NewIntroBoss"sv;
case EScriptObjectType::SpawnPoint: return "SpawnPoint"sv;
case EScriptObjectType::CameraHint: return "CameraHint"sv;
case EScriptObjectType::Pickup: return "Pickup"sv;
case EScriptObjectType::MemoryRelay: return "MemoryRelay"sv;
case EScriptObjectType::RandomRelay: return "RandomRelay"sv;
case EScriptObjectType::Relay: return "Relay"sv;
case EScriptObjectType::Beetle: return "Beetle"sv;
case EScriptObjectType::HUDMemo: return "HUDMemo"sv;
case EScriptObjectType::CameraFilterKeyframe: return "CameraFilterKeyframe"sv;
case EScriptObjectType::CameraBlurKeyframe: return "CameraBlurKeyframe"sv;
case EScriptObjectType::DamageableTrigger: return "DamageableTrigger"sv;
case EScriptObjectType::Debris: return "Debris"sv;
case EScriptObjectType::CameraShaker: return "CameraShaker"sv;
case EScriptObjectType::ActorKeyframe: return "ActorKeyframe"sv;
case EScriptObjectType::Water: return "Water"sv;
case EScriptObjectType::Warwasp: return "Warwasp"sv;
case EScriptObjectType::SpacePirate: return "SpacePirate"sv;
case EScriptObjectType::FlyingPirate: return "FlyingPirate"sv;
case EScriptObjectType::ElitePirate: return "ElitePirate"sv;
case EScriptObjectType::MetroidBeta: return "MetroidBeta"sv;
case EScriptObjectType::ChozoGhost: return "ChozoGhost"sv;
case EScriptObjectType::CoverPoint: return "CoverPoint"sv;
case EScriptObjectType::SpiderBallWaypoint: return "SpiderBallWaypoint"sv;
case EScriptObjectType::BloodFlower: return "BloodFlower"sv;
case EScriptObjectType::FlickerBat: return "FlickerBat"sv;
case EScriptObjectType::PathCamera: return "PathCamera"sv;
case EScriptObjectType::GrapplePoint: return "GrapplePoint"sv;
case EScriptObjectType::PuddleSpore: return "PuddleSpore"sv;
case EScriptObjectType::DebugCameraWaypoint: return "DebugCameraWaypoint"sv;
case EScriptObjectType::SpiderBallAttractionSurface: return "SpiderBallAttractionSurface"sv;
case EScriptObjectType::PuddleToadGamma: return "PuddleToadGamma"sv;
case EScriptObjectType::DistanceFog: return "DistanceFog"sv;
case EScriptObjectType::FireFlea: return "FireFlea"sv;
case EScriptObjectType::MetareeAlpha: return "MetareeAlpha"sv;
case EScriptObjectType::DockAreaChange: return "DockAreaChange"sv;
case EScriptObjectType::ActorRotate: return "ActorRotate"sv;
case EScriptObjectType::SpecialFunction: return "SpecialFunction"sv;
case EScriptObjectType::SpankWeed: return "SpankWeed"sv;
case EScriptObjectType::Parasite: return "Parasite"sv;
case EScriptObjectType::PlayerHint: return "PlayerHint"sv;
case EScriptObjectType::Ripper: return "Ripper"sv;
case EScriptObjectType::PickupGenerator: return "PickupGenerator"sv;
case EScriptObjectType::AIKeyframe: return "AIKeyframe"sv;
case EScriptObjectType::PointOfInterest: return "PointOfInterest"sv;
case EScriptObjectType::Drone: return "Drone"sv;
case EScriptObjectType::MetroidAlpha: return "MetroidAlpha"sv;
case EScriptObjectType::DebrisExtended: return "DebrisExtended"sv;
case EScriptObjectType::Steam: return "Steam"sv;
case EScriptObjectType::Ripple: return "Ripple"sv;
case EScriptObjectType::BallTrigger: return "BallTrigger"sv;
case EScriptObjectType::TargetingPoint: return "TargetingPoint"sv;
case EScriptObjectType::EMPulse: return "EMPulse"sv;
case EScriptObjectType::IceSheegoth: return "IceSheegoth"sv;
case EScriptObjectType::PlayerActor: return "PlayerActor"sv;
case EScriptObjectType::Flaahgra: return "Flaahgra"sv;
case EScriptObjectType::AreaAttributes: return "AreaAttributes"sv;
case EScriptObjectType::FishCloud: return "FishCloud"sv;
case EScriptObjectType::FishCloudModifier: return "FishCloudModifier"sv;
case EScriptObjectType::VisorFlare: return "VisorFlare"sv;
case EScriptObjectType::WorldTeleporter: return "WorldTeleporter"sv;
case EScriptObjectType::VisorGoo: return "VisorGoo"sv;
case EScriptObjectType::JellyZap: return "JellyZap"sv;
case EScriptObjectType::ControllerAction: return "ControllerAction"sv;
case EScriptObjectType::Switch: return "Switch"sv;
case EScriptObjectType::PlayerStateChange: return "PlayerStateChange"sv;
case EScriptObjectType::Thardus: return "Thardus"sv;
case EScriptObjectType::WallCrawlerSwarm: return "WallCrawlerSwarm"sv;
case EScriptObjectType::AIJumpPoint: return "AIJumpPoint"sv;
case EScriptObjectType::FlaahgraTentacle: return "FlaahgraTentacle"sv;
case EScriptObjectType::RoomAcoustics: return "RoomAcoustics"sv;
case EScriptObjectType::ColorModulate: return "ColorModulate"sv;
case EScriptObjectType::ThardusRockProjectile: return "ThardusRockProjectile"sv;
case EScriptObjectType::Midi: return "Midi"sv;
case EScriptObjectType::StreamedAudio: return "StreamedAudio"sv;
case EScriptObjectType::WorldTeleporterToo: return "WorldTeleporterToo"sv;
case EScriptObjectType::Repulsor: return "Repulsor"sv;
case EScriptObjectType::GunTurret: return "GunTurret"sv;
case EScriptObjectType::FogVolume: return "FogVolume"sv;
case EScriptObjectType::Babygoth: return "Babygoth"sv;
case EScriptObjectType::Eyeball: return "Eyeball"sv;
case EScriptObjectType::RadialDamage: return "RadialDamage"sv;
case EScriptObjectType::CameraPitchVolume: return "CameraPitchVolume"sv;
case EScriptObjectType::EnvFxDensityController: return "EnvFxDensityController"sv;
case EScriptObjectType::Magdolite: return "Magdolite"sv;
case EScriptObjectType::TeamAIMgr: return "TeamAIMgr"sv;
case EScriptObjectType::SnakeWeedSwarm: return "SnakeWeedSwarm"sv;
case EScriptObjectType::ActorContraption: return "ActorContraption"sv;
case EScriptObjectType::Oculus: return "Oculus"sv;
case EScriptObjectType::Geemer: return "Geemer"sv;
case EScriptObjectType::SpindleCamera: return "SpindleCamera"sv;
case EScriptObjectType::AtomicAlpha: return "AtomicAlpha"sv;
case EScriptObjectType::CameraHintTrigger: return "CameraHintTrigger"sv;
case EScriptObjectType::RumbleEffect: return "RumbleEffect"sv;
case EScriptObjectType::AmbientAI: return "AmbientAI"sv;
case EScriptObjectType::AtomicBeta: return "AtomicBeta"sv;
case EScriptObjectType::IceZoomer: return "IceZoomer"sv;
case EScriptObjectType::Puffer: return "Puffer"sv;
case EScriptObjectType::Tryclops: return "Tryclops"sv;
case EScriptObjectType::Ridley: return "Ridley"sv;
case EScriptObjectType::Seedling: return "Seedling"sv;
case EScriptObjectType::ThermalHeatFader: return "ThermalHeatFader"sv;
case EScriptObjectType::Burrower: return "Burrower"sv;
case EScriptObjectType::ScriptBeam: return "ScriptBeam"sv;
case EScriptObjectType::WorldLightFader: return "WorldLightFader"sv;
case EScriptObjectType::MetroidPrimeStage2: return "MetroidPrimeStage2"sv;
case EScriptObjectType::MetroidPrimeStage1: return "MetroidPrimeStage1"sv;
case EScriptObjectType::MazeNode: return "MazeNode"sv;
case EScriptObjectType::OmegaPirate: return "OmegaPirate"sv;
case EScriptObjectType::PhazonPool: return "PhazonPool"sv;
case EScriptObjectType::PhazonHealingNodule: return "PhazonHealingNodule"sv;
case EScriptObjectType::NewCameraShaker: return "NewCameraShaker"sv;
case EScriptObjectType::ShadowProjector: return "ShadowProjector"sv;
case EScriptObjectType::EnergyBall: return "EnergyBall"sv;
default: return "..."sv;
}
}
std::string_view ScriptObjectStateToStr(EScriptObjectState state)
{
switch (state)
{
case EScriptObjectState::Active: return "Active"sv;
case EScriptObjectState::Arrived: return "Arrived"sv;
case EScriptObjectState::Closed: return "Closed"sv;
case EScriptObjectState::Entered: return "Entered"sv;
case EScriptObjectState::Exited: return "Exited"sv;
case EScriptObjectState::Inactive: return "Inactive"sv;
case EScriptObjectState::Inside: return "Inside"sv;
case EScriptObjectState::MaxReached: return "MaxReached"sv;
case EScriptObjectState::Open: return "Open"sv;
case EScriptObjectState::Zero: return "Zero"sv;
case EScriptObjectState::Attack: return "Attack"sv;
case EScriptObjectState::UNKS1: return "UNKS1"sv;
case EScriptObjectState::Retreat: return "Retreat"sv;
case EScriptObjectState::Patrol: return "Patrol"sv;
case EScriptObjectState::Dead: return "Dead"sv;
case EScriptObjectState::CameraPath: return "CameraPath"sv;
case EScriptObjectState::CameraTarget: return "CameraTarget"sv;
case EScriptObjectState::UNKS2: return "UNKS2"sv;
case EScriptObjectState::Play: return "Play"sv;
case EScriptObjectState::UNKS3: return "UNKS3"sv;
case EScriptObjectState::DeathRattle: return "DeathRattle"sv;
case EScriptObjectState::UNKS4: return "UNKS4"sv;
case EScriptObjectState::Damage: return "Damage"sv;
case EScriptObjectState::InvulnDamage: return "InvulnDamage"sv;
case EScriptObjectState::UNKS5: return "UNKS5"sv;
case EScriptObjectState::Modify: return "Modify"sv;
case EScriptObjectState::ScanStart: return "ScanStart"sv;
case EScriptObjectState::ScanProcessing: return "ScanProcessing"sv;
case EScriptObjectState::ScanDone: return "ScanDone"sv;
case EScriptObjectState::UnFrozen: return "UnFrozen"sv;
case EScriptObjectState::Default: return "Default"sv;
case EScriptObjectState::ReflectedDamage: return "ReflectedDamage"sv;
case EScriptObjectState::InheritBounds: return "InheritBounds"sv;
default: return "..."sv;
}
}
std::string_view ScriptObjectMessageToStr(EScriptObjectMessage message)
{
switch (message)
{
case EScriptObjectMessage::UNKM0: return "UNKM0"sv;
case EScriptObjectMessage::Activate: return "Activate"sv;
case EScriptObjectMessage::Arrived: return "Arrived"sv;
case EScriptObjectMessage::Close: return "Close"sv;
case EScriptObjectMessage::Deactivate: return "Deactivate"sv;
case EScriptObjectMessage::Decrement: return "Decrement"sv;
case EScriptObjectMessage::Follow: return "Follow"sv;
case EScriptObjectMessage::Increment: return "Increment"sv;
case EScriptObjectMessage::Next: return "Next"sv;
case EScriptObjectMessage::Open: return "Open"sv;
case EScriptObjectMessage::Reset: return "Reset"sv;
case EScriptObjectMessage::ResetAndStart: return "ResetAndStart"sv;
case EScriptObjectMessage::SetToMax: return "SetToMax"sv;
case EScriptObjectMessage::SetToZero: return "SetToZero"sv;
case EScriptObjectMessage::Start: return "Start"sv;
case EScriptObjectMessage::Stop: return "Stop"sv;
case EScriptObjectMessage::StopAndReset: return "StopAndReset"sv;
case EScriptObjectMessage::ToggleActive: return "ToggleActive"sv;
case EScriptObjectMessage::UNKM18: return "UNKM18"sv;
case EScriptObjectMessage::Action: return "Action"sv;
case EScriptObjectMessage::Play: return "Play"sv;
case EScriptObjectMessage::Alert: return "Alert"sv;
case EScriptObjectMessage::InternalMessage00: return "InternalMessage00"sv;
case EScriptObjectMessage::OnFloor: return "OnFloor"sv;
case EScriptObjectMessage::InternalMessage02: return "InternalMessage02"sv;
case EScriptObjectMessage::InternalMessage03: return "InternalMessage03"sv;
case EScriptObjectMessage::Falling: return "Falling"sv;
case EScriptObjectMessage::OnIceSurface: return "OnIceSurface"sv;
case EScriptObjectMessage::OnMudSlowSurface: return "OnMudSlowSurface"sv;
case EScriptObjectMessage::OnNormalSurface: return "OnNormalSurface"sv;
case EScriptObjectMessage::InternalMessage08: return "InternalMessage08"sv;
case EScriptObjectMessage::AddPlatformRider: return "AddPlatformRider"sv;
case EScriptObjectMessage::LandOnNotFloor: return "LandOnNotFloor"sv;
case EScriptObjectMessage::Registered: return "Registered"sv;
case EScriptObjectMessage::Deleted: return "Deleted"sv;
case EScriptObjectMessage::InitializedInArea: return "InitializedInArea"sv;
case EScriptObjectMessage::InternalMessage14: return "InternalMessage14"sv;
case EScriptObjectMessage::AddSplashInhabitant: return "AddSplashInhabitant"sv;
case EScriptObjectMessage::UpdateSplashInhabitant: return "UpdateSplashInhabitant"sv;
case EScriptObjectMessage::RemoveSplashInhabitant: return "RemoveSplashInhabitant"sv;
case EScriptObjectMessage::InternalMessage18: return "InternalMessage18"sv;
case EScriptObjectMessage::Damage: return "Damage"sv;
case EScriptObjectMessage::InvulnDamage: return "InvulnDamage"sv;
case EScriptObjectMessage::ProjectileCollide: return "ProjectileCollide"sv;
case EScriptObjectMessage::InSnakeWeed: return "InSnakeWeed"sv;
case EScriptObjectMessage::AddPhazonPoolInhabitant: return "AddPhazonPoolInhabitant"sv;
case EScriptObjectMessage::UpdatePhazonPoolInhabitant: return "UpdatePhazonPoolInhabitant"sv;
case EScriptObjectMessage::RemovePhazonPoolInhabitant: return "RemovePhazonPoolInhabitant"sv;
case EScriptObjectMessage::InternalMessage26: return "InternalMessage26"sv;
default: return "..."sv;
}
}
#endif
}

View File

@ -1,6 +1,8 @@
#ifndef __SCRIPT_OBJECT_SUPPORT_HPP__
#define __SCRIPT_OBJECT_SUPPORT_HPP__
#include <string_view>
namespace urde
{
@ -227,6 +229,13 @@ enum class EScriptObjectMessage
RemovePhazonPoolInhabitant = 47,
InternalMessage26 = 48
};
#ifndef NDEBUG
std::string_view ScriptObjectTypeToStr(EScriptObjectType type);
std::string_view ScriptObjectStateToStr(EScriptObjectState state);
std::string_view ScriptObjectMessageToStr(EScriptObjectMessage message);
#endif
}
#endif // __SCRIPT_OBJECT_SUPPORT_HPP__

2
hecl

@ -1 +1 @@
Subproject commit 6c480c70f1f46f35658576d91241b529d19c7a61
Subproject commit e90ad748993e4662f39a723a54b75bdc2e364bd8