From 6dd94d36263c1aed0e56e6be4ad5612e1a92f935 Mon Sep 17 00:00:00 2001 From: MS Date: Fri, 22 Sep 2023 17:42:23 -0400 Subject: [PATCH] PresenterNameDispatch (#137) * PresenterNameDispatch * Use reference for PresenterNameDispatch param - fix or add const markers so we can use a const reference --- LEGO1/mxdsaction.h | 3 +++ LEGO1/mxdsmediaaction.h | 2 ++ LEGO1/mxdsobject.h | 5 ++-- LEGO1/mxpresenter.cpp | 59 +++++++++++++++++++++++++++++++++++++++++ LEGO1/mxpresenter.h | 2 ++ 5 files changed, 69 insertions(+), 2 deletions(-) diff --git a/LEGO1/mxdsaction.h b/LEGO1/mxdsaction.h index 3028a43d..265f0a6f 100644 --- a/LEGO1/mxdsaction.h +++ b/LEGO1/mxdsaction.h @@ -12,6 +12,7 @@ class MxDSAction : public MxDSObject public: enum { + Flag_Looping = 0x01, Flag_Enabled = 0x20, Flag_Parsed = 0x80, }; @@ -55,6 +56,8 @@ class MxDSAction : public MxDSObject inline const MxVector3Data &GetLocation() const { return m_location; } inline void SetOmni(MxOmni *p_omni) { m_omni = p_omni; } + inline MxBool IsLooping() const { return this->m_flags & Flag_Looping; } + private: MxU32 m_sizeOnDisk; MxU32 m_flags; diff --git a/LEGO1/mxdsmediaaction.h b/LEGO1/mxdsmediaaction.h index 1ebbfdd2..f3c03839 100644 --- a/LEGO1/mxdsmediaaction.h +++ b/LEGO1/mxdsmediaaction.h @@ -32,6 +32,8 @@ class MxDSMediaAction : public MxDSAction virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c; void CopyMediaSrcPath(const char *p_mediaSrcPath); + + inline MxS32 GetMediaFormat() const { return this->m_mediaFormat; } private: MxU32 m_sizeOnDisk; char *m_mediaSrcPath; diff --git a/LEGO1/mxdsobject.h b/LEGO1/mxdsobject.h index 0b247a6a..1ca3d98a 100644 --- a/LEGO1/mxdsobject.h +++ b/LEGO1/mxdsobject.h @@ -40,9 +40,10 @@ class MxDSObject : public MxCore inline void SetObjectId(MxU32 p_objectId) { this->m_objectId = p_objectId; } inline void SetUnknown24(MxS16 p_unk24) { this->m_unk24 = p_unk24; } -protected: + inline char *GetSourceName() const { return this->m_sourceName; } + inline void SetType(MxDSType p_type) { this->m_type = p_type; } - inline MxDSType GetType() { return (MxDSType) this->m_type; } + inline MxDSType GetType() const { return (MxDSType) this->m_type; } private: MxU32 m_sizeOnDisk; diff --git a/LEGO1/mxpresenter.cpp b/LEGO1/mxpresenter.cpp index 838b0af3..940248a0 100644 --- a/LEGO1/mxpresenter.cpp +++ b/LEGO1/mxpresenter.cpp @@ -2,6 +2,8 @@ #include "mxautolocker.h" #include "mxparam.h" #include "legoomni.h" +#include "mxdsanim.h" +#include "mxdssound.h" #include #include "decomp.h" @@ -155,6 +157,63 @@ void MxPresenter::Enable(MxBool p_enable) } } +// OFFSET: LEGO1 0x100b5310 +char *PresenterNameDispatch(const MxDSAction &p_action) +{ + char *name = p_action.GetSourceName(); + MxS32 format; + + if (!name || strlen(name) == 0) { + switch (p_action.GetType()) { + case MxDSType_Anim: + format = ((MxDSAnim&)p_action).GetMediaFormat(); + switch (format) { + case FOURCC(' ', 'F', 'L', 'C'): + name = !p_action.IsLooping() ? + "MxFlcPresenter" : + "MxLoopingFlcPresenter"; + break; + case FOURCC(' ', 'S', 'M', 'K'): + name = !p_action.IsLooping() ? + "MxSmkPresenter" : + "MxLoopingSmkPresenter"; + break; + } + break; + + case MxDSType_Sound: + format = ((MxDSSound&)p_action).GetMediaFormat(); + switch(format) { + case FOURCC(' ', 'M', 'I', 'D'): + name = !p_action.IsLooping() ? + "MxMIDIPresenter" : + "MxLoopingMIDIPresenter"; + break; + case FOURCC(' ', 'W', 'A', 'V'): + name = "MxWavePresenter"; + break; + } + break; + + case MxDSType_SerialAction: + case MxDSType_ParallelAction: + case MxDSType_SelectAction: + name = "MxCompositePresenter"; + break; + + case MxDSType_Event: + name = "MxEventPresenter"; + break; + + case MxDSType_Still: + name = "MxStillPresenter"; + break; + } + } + + return name; +} + // OFFSET: LEGO1 0x100b54c0 MxBool MxPresenter::IsEnabled() { diff --git a/LEGO1/mxpresenter.h b/LEGO1/mxpresenter.h index 86b078a6..1537d2d3 100644 --- a/LEGO1/mxpresenter.h +++ b/LEGO1/mxpresenter.h @@ -84,4 +84,6 @@ class MxPresenter : public MxCore MxPresenter *m_unkPresenter; // 0x3c }; +char *PresenterNameDispatch(const MxDSAction &); + #endif // MXPRESENTER_H