From 8be39579f62ece80fd77dba4cf9714bea1f1d2b4 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Thu, 15 Oct 2026 14:29:12 -0400 Subject: [PATCH] dArea_c + various cleanups in passing --- .../rels/d_t_time_door_beamNP/symbols.txt | 2 +- config/SOUE01/splits.txt | 3 +- config/SOUE01/symbols.txt | 14 ++--- configure.py | 2 +- include/d/d_area.h | 18 +++++++ include/d/t/d_t_action.h | 6 +-- include/d/t/d_t_alldie.h | 3 +- include/d/t/d_t_beetle.h | 4 +- include/d/t/d_t_event.h | 4 +- include/d/t/d_t_event_f.h | 17 +++--- include/d/t/d_t_gate_to_ground.h | 16 +++--- include/d/t/d_t_heat_resist.h | 4 +- include/d/t/d_t_restart_time_stone.h | 4 +- include/d/t/d_t_scene_change.h | 6 +-- include/d/t/d_t_stream.h | 4 +- include/d/t/d_t_sw_area.h | 36 +++---------- include/d/t/d_t_time_door_beam.h | 7 +-- include/d/t/d_t_touch.h | 4 +- include/d/t/d_t_view_clip.h | 4 +- include/toBeSorted/area_math.h | 12 ----- src/REL/d/t/d_t_action.cpp | 17 +++--- src/REL/d/t/d_t_beetle.cpp | 17 +++--- src/REL/d/t/d_t_gate_to_ground.cpp | 31 +++++------ src/REL/d/t/d_t_heat_resist.cpp | 11 ++-- src/REL/d/t/d_t_restart_time_stone.cpp | 5 +- src/REL/d/t/d_t_scene_change.cpp | 9 ++-- src/REL/d/t/d_t_stream.cpp | 3 +- src/REL/d/t/d_t_sw_area.cpp | 53 +++++++++---------- src/REL/d/t/d_t_time_door_beam.cpp | 9 ++-- src/REL/d/t/d_t_touch.cpp | 6 +-- src/d/d_area.cpp | 33 ++++++++++++ src/d/tg/d_t_alldie.cpp | 6 +-- src/d/tg/d_t_event.cpp | 5 +- src/d/tg/d_t_event_f.cpp | 25 +++++---- src/d/tg/d_t_view_clip.cpp | 5 +- 35 files changed, 203 insertions(+), 202 deletions(-) create mode 100644 include/d/d_area.h delete mode 100644 include/toBeSorted/area_math.h create mode 100644 src/d/d_area.cpp diff --git a/config/SOUE01/rels/d_t_time_door_beamNP/symbols.txt b/config/SOUE01/rels/d_t_time_door_beamNP/symbols.txt index d014a1db..83bea2d0 100644 --- a/config/SOUE01/rels/d_t_time_door_beamNP/symbols.txt +++ b/config/SOUE01/rels/d_t_time_door_beamNP/symbols.txt @@ -6,7 +6,7 @@ create__17dTgTimeDoorBeam_cFv = .text:0x000000C0; // type:function size:0x48 doDelete__17dTgTimeDoorBeam_cFv = .text:0x00000110; // type:function size:0x8 actorExecute__17dTgTimeDoorBeam_cFv = .text:0x00000120; // type:function size:0x8 draw__17dTgTimeDoorBeam_cFv = .text:0x00000130; // type:function size:0x8 -checkPlayerPosInMtx__17dTgTimeDoorBeam_cFv = .text:0x00000140; // type:function size:0x28 +isPlayerInArea__17dTgTimeDoorBeam_cFv = .text:0x00000140; // type:function size:0x28 __dt__17dTgTimeDoorBeam_cFv = .text:0x00000170; // type:function size:0x5C _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 6f5aaef3..894eb239 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -366,8 +366,9 @@ toBeSorted/string_util.cpp: toBeSorted/cx_util.cpp: .text start:0x80066FB0 end:0x80067014 align:16 -toBeSorted/area_math.cpp: +d/d_area.cpp: .text start:0x80067020 end:0x80067274 align:16 + .sdata2 start:0x80577998 end:0x805779A8 toBeSorted/deg_angle_util.cpp: .text start:0x80067280 end:0x80067B14 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 9938ead6..3f0e935f 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2899,9 +2899,9 @@ stop__12dRumbleIdx_cFv = .text:0x80066E00; // type:function size:0x44 __sinit_\d_rumble_cpp = .text:0x80066E50; // type:function size:0x108 scope:local fn_80066F60 = .text:0x80066F60; // type:function size:0x50 lzSafeDecompress__FPCvUlPv = .text:0x80066FB0; // type:function size:0x64 -matrixCreateFromPosRotYScale__FR6mMtx_cRC7mVec3_c4mAngRC7mVec3_cP6mMtx_cf = .text:0x80067020; // type:function size:0x138 -checkAreaBox__FRC6mMtx_cRC7mVec3_c = .text:0x80067160; // type:function size:0x88 -checkAreaCyl__FRC6mMtx_cRC7mVec3_c = .text:0x800671F0; // type:function size:0x84 +set__7dArea_cFRC7mVec3_c4mAngRC7mVec3_cP6mMtx_cf = .text:0x80067020; // type:function size:0x138 +checkAreaBox__7dArea_cFRC7mVec3_c = .text:0x80067160; // type:function size:0x88 +checkAreaCyl__7dArea_cFRC7mVec3_c = .text:0x800671F0; // type:function size:0x84 __ct__7mVec2_cFv = .text:0x80067280; // type:function size:0x4 fn_80067290 = .text:0x80067290; // type:function size:0xA8 fn_80067340 = .text:0x80067340; // type:function size:0xC0 @@ -14627,10 +14627,10 @@ __dt__10dTgEvent_cFv = .text:0x8027A6D0; // type:function size:0x70 scope:weak dTgEventF_c_classInit__Fv = .text:0x8027A740; // type:function size:0x5C create__11dTgEventF_cFv = .text:0x8027A7A0; // type:function size:0x9C doDelete__11dTgEventF_cFv = .text:0x8027A840; // type:function size:0x8 -checkStoryflagValid__11dTgEventF_cFUl = .text:0x8027A850; // type:function size:0x14 -checkUncommitedStoryFlagValue__11dTgEventF_cFUl = .text:0x8027A870; // type:function size:0x48 -setStoryFlag__11dTgEventF_cF12StoryFlags_e = .text:0x8027A8C0; // type:function size:0x1C -unsetStoryFlag__11dTgEventF_cF12StoryFlags_e = .text:0x8027A8E0; // type:function size:0x1C +checkStoryflagValid__11dTgEventF_cFl = .text:0x8027A850; // type:function size:0x14 +checkUncommitedStoryFlagValue__11dTgEventF_cFl = .text:0x8027A870; // type:function size:0x48 +setStoryFlag__11dTgEventF_cFl = .text:0x8027A8C0; // type:function size:0x1C +unsetStoryFlag__11dTgEventF_cFl = .text:0x8027A8E0; // type:function size:0x1C actorExecute__11dTgEventF_cFv = .text:0x8027A900; // type:function size:0xFC actorExecuteInEvent__11dTgEventF_cFv = .text:0x8027AA00; // type:function size:0xB0 draw__11dTgEventF_cFv = .text:0x8027AAB0; // type:function size:0x8 diff --git a/configure.py b/configure.py index 29d4fbce..5c26d5ba 100644 --- a/configure.py +++ b/configure.py @@ -475,7 +475,7 @@ config.libs = [ Object(Matching, "d/d_rumble.cpp"), Object(NonMatching, "toBeSorted/string_util.cpp"), Object(NonMatching, "toBeSorted/cx_util.cpp"), - Object(NonMatching, "toBeSorted/area_math.cpp"), + Object(Matching, "d/d_area.cpp"), Object(NonMatching, "toBeSorted/deg_angle_util.cpp"), Object(Matching, "d/d_reset.cpp"), Object(Matching, "toBeSorted/arc_managers/current_stage_arc_manager.cpp"), diff --git a/include/d/d_area.h b/include/d/d_area.h new file mode 100644 index 00000000..2c91d1a1 --- /dev/null +++ b/include/d/d_area.h @@ -0,0 +1,18 @@ +#ifndef D_AREA_H +#define D_AREA_H + +#include "m/m_angle.h" +#include "m/m_mtx.h" +#include "m/m_vec.h" + +class dArea_c { +public: + void set(const mVec3_c &, const mAng, const mVec3_c &, mMtx_c *, f32); + bool checkAreaBox(const mVec3_c &); + bool checkAreaCyl(const mVec3_c &); + +private: + mMtx_c mArea; +}; + +#endif diff --git a/include/d/t/d_t_action.h b/include/d/t/d_t_action.h index bf0cbe63..893b8601 100644 --- a/include/d/t/d_t_action.h +++ b/include/d/t/d_t_action.h @@ -1,10 +1,10 @@ #ifndef D_T_ACTION_H #define D_T_ACTION_H +#include "d/d_area.h" #include "d/flag/sceneflag_manager.h" #include "d/t/d_tg.h" #include "m/m_angle.h" -#include "m/m_mtx.h" class dTgAction_c : public dTg_c { public: @@ -32,11 +32,11 @@ public: return SceneflagManager::sInstance->checkBoolFlag(mRoomID, mEnableFlag1); } bool checkActive2() const { - return (!(mEnableFlag2 < 0xFF) || SceneflagManager::sInstance->checkBoolFlag(mRoomID, mEnableFlag2)); + return !(mEnableFlag2 < 0xFF) || SceneflagManager::sInstance->checkBoolFlag(mRoomID, mEnableFlag2); } private: - /* 0x0FC */ mMtx_c mActiveMtx; + /* 0x0FC */ dArea_c mArea; /* 0x12C */ f32 mScaleIncrease; /* 0x130 */ u8 mEnableFlag1; /* 0x131 */ u8 mEnableFlag2; diff --git a/include/d/t/d_t_alldie.h b/include/d/t/d_t_alldie.h index 3fe18e82..8f4a596c 100644 --- a/include/d/t/d_t_alldie.h +++ b/include/d/t/d_t_alldie.h @@ -1,6 +1,7 @@ #ifndef D_T_ALL_DIE_H #define D_T_ALL_DIE_H +#include "d/d_area.h" #include "d/t/d_tg.h" #include "m/m_mtx.h" #include "toBeSorted/time_area_mgr.h" @@ -18,7 +19,7 @@ public: static dTgAllDie_c *getNearestToPlayer(s32 roomId); private: - /* 0x0FC */ mMtx_c mArea; + /* 0x0FC */ dArea_c mArea; /* 0x12C */ TimeAreaStruct mTimeArea; /* 0x138 */ s32 mNumEnemiesInArea; /* 0x13C */ u16 mTimer0x13C; diff --git a/include/d/t/d_t_beetle.h b/include/d/t/d_t_beetle.h index 554288c8..a093f912 100644 --- a/include/d/t/d_t_beetle.h +++ b/include/d/t/d_t_beetle.h @@ -2,8 +2,8 @@ #define D_T_BEETLE_H #include "d/a/obj/d_a_obj_boomerang.h" +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" // This is a tag actor for controlling where the beetle can fly // BtlTgC is leaves (beetle plays leaf animation as it passes through) @@ -40,7 +40,7 @@ public: }; private: - /* 0xFC */ mMtx_c mMatrix1; + /* 0xFC */ dArea_c mArea; /* 0x12C*/ u8 mZoneType; // defines what this object does /* 0x12D*/ u8 mZoneShape; // the shape created inside the object that it checks /* 0x12E*/ u8 mUnknown; // unused diff --git a/include/d/t/d_t_event.h b/include/d/t/d_t_event.h index 1fcf9ae4..6818a401 100644 --- a/include/d/t/d_t_event.h +++ b/include/d/t/d_t_event.h @@ -1,8 +1,8 @@ #ifndef D_T_EVENT_H #define D_T_EVENT_H +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" #include "toBeSorted/actor_event.h" class dTgEvent_c : public dTg_c { @@ -21,7 +21,7 @@ public: private: /* 0x0FC */ ActorEventRelated mActorEvent; - /* 0x14C */ mMtx_c mMatrix; + /* 0x14C */ dArea_c mArea; /* 0x17C */ u32 mEventId; /* 0x180 */ u32 mSetSceneflag; /* 0x184 */ u32 mTrigSceneflag; diff --git a/include/d/t/d_t_event_f.h b/include/d/t/d_t_event_f.h index 024b29be..7ba7b069 100644 --- a/include/d/t/d_t_event_f.h +++ b/include/d/t/d_t_event_f.h @@ -2,9 +2,8 @@ #define D_T_EVENT_F_H #include "common.h" -#include "d/flag/storyflag_manager.h" +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" #include "toBeSorted/actor_event.h" class dTgEventF_c : public dTg_c { @@ -14,20 +13,20 @@ public: virtual int create() override; virtual int doDelete() override; - static int checkStoryflagValid(u32); - static bool checkUncommitedStoryFlagValue(u32); - static void setStoryFlag(StoryFlags_e); - static void unsetStoryFlag(StoryFlags_e); + static int checkStoryflagValid(s32); + static bool checkUncommitedStoryFlagValue(s32); + static void setStoryFlag(s32); + static void unsetStoryFlag(s32); virtual int actorExecute() override; virtual int actorExecuteInEvent() override; virtual int draw() override; private: /* 0x0FC */ ActorEventRelated mActorEvent; - /* 0x14C */ mMtx_c mMatrix; + /* 0x14C */ dArea_c mArea; /* 0x17C */ u32 mEventId; - /* 0x180 */ u32 mSetStoryflag; - /* 0x184 */ u32 mTrigStoryflag; + /* 0x180 */ s32 mSetStoryflag; + /* 0x184 */ s32 mTrigStoryflag; /* 0x188 */ u32 mSubtype; }; #endif diff --git a/include/d/t/d_t_gate_to_ground.h b/include/d/t/d_t_gate_to_ground.h index 880417ea..5c13bccf 100644 --- a/include/d/t/d_t_gate_to_ground.h +++ b/include/d/t/d_t_gate_to_ground.h @@ -2,8 +2,8 @@ #define D_T_GATE_TO_GROUND_H #include "common.h" +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" #include "toBeSorted/actor_event.h" class dTgGateToGround_c : public dTg_c { @@ -12,18 +12,18 @@ public: virtual ~dTgGateToGround_c() {} virtual int create() override; - virtual int doDelete() override; // fn_205_150 + virtual int doDelete() override; virtual int actorExecute() override; virtual int actorExecuteInEvent() override; - virtual int draw() override; // fn_205_2F0 + virtual int draw() override; private: /* 0xfc */ ActorEventRelated mEventRelated; - /* 0x14c */ mMtx_c matrix; - /* 0x17c */ s32 delayFrames; - /* 0x180 */ s16 params_FF_FF_00_00; - /* 0x182 */ s8 params_00_00_FF_00; - /* 0x183 */ s8 params_00_00_00_FF; + /* 0x14c */ dArea_c mArea; + /* 0x17c */ s32 mDelayFrameCount; + /* 0x180 */ s16 mStoryflag; + /* 0x182 */ s8 field_0x182; + /* 0x183 */ s8 mCameraID; }; #endif diff --git a/include/d/t/d_t_heat_resist.h b/include/d/t/d_t_heat_resist.h index e350f0ac..d1becbdd 100644 --- a/include/d/t/d_t_heat_resist.h +++ b/include/d/t/d_t_heat_resist.h @@ -2,8 +2,8 @@ #define D_T_HEAT_RESIST_H #include "common.h" +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" class dTgHeatResist_c : public dTg_c { public: @@ -16,7 +16,7 @@ public: virtual int actorExecute() override; private: - /* 0x0FC */ mMtx_c matrix; + /* 0x0FC */ dArea_c mArea; /* 0x12C */ u8 mInverted; }; diff --git a/include/d/t/d_t_restart_time_stone.h b/include/d/t/d_t_restart_time_stone.h index 33b2c9eb..a5383f9f 100644 --- a/include/d/t/d_t_restart_time_stone.h +++ b/include/d/t/d_t_restart_time_stone.h @@ -1,8 +1,8 @@ #ifndef D_T_RESTART_TIME_STONE_H #define D_T_RESTART_TIME_STONE_H +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" #include "m/m_vec.h" class dTgRestartTimeStone_c : public dTg_c { @@ -16,7 +16,7 @@ public: virtual int actorExecute() override; private: - /* 0x0FC */ mMtx_c mMtx; + /* 0x0FC */ dArea_c mArea; /* 0x12C */ mVec3_c mPathStartPos; }; diff --git a/include/d/t/d_t_scene_change.h b/include/d/t/d_t_scene_change.h index 017c8d58..4224cbac 100644 --- a/include/d/t/d_t_scene_change.h +++ b/include/d/t/d_t_scene_change.h @@ -1,8 +1,8 @@ #ifndef D_T_SCENE_CHANGE_H #define D_T_SCENE_CHANGE_H +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" #include "m/m_vec.h" class dTgSceneChange_c : public dTg_c { @@ -38,14 +38,14 @@ private: void savePlayerPosition(); private: - /* 0x0FC */ mMtx_c mArea; + /* 0x0FC */ dArea_c mArea; /* 0x12C */ u8 mSceneLink; /* 0x12D */ u8 mSceneType; /* 0x12E */ u8 mPathId; /* 0x12F */ u8 mEnableSceneflag; /* 0x130 */ u16 mEnableStoryflag; /* 0x132 */ u16 mDisableStoryflag; - /* 0x134 */ bool field_0x134; + /* 0x134 */ bool mbAreaCyl; /* 0x135 */ bool field_0x135; /* 0x136 */ bool field_0x136; /* 0x138 */ mVec3_c field_0x138; // Player position on Scrapper Stop diff --git a/include/d/t/d_t_stream.h b/include/d/t/d_t_stream.h index 9a52f1d9..a850bf82 100644 --- a/include/d/t/d_t_stream.h +++ b/include/d/t/d_t_stream.h @@ -1,10 +1,10 @@ #ifndef D_T_STREAM_H #define D_T_STREAM_H +#include "d/d_area.h" #include "d/t/d_tg.h" #include "f/f_list_mg.h" #include "f/f_list_nd.h" -#include "m/m_mtx.h" #include "m/m_vec.h" class dTgStream_c : public dTg_c { @@ -31,7 +31,7 @@ private: /* 0x0FF */ u8 mOrder; /* 0x100 */ u8 mIsSand; /* 0x101 */ u8 field_0x101; - /* 0x104 */ mMtx_c mArea; + /* 0x104 */ dArea_c mArea; /* 0x134 */ fLiNdBa_c mStreamNode; }; diff --git a/include/d/t/d_t_sw_area.h b/include/d/t/d_t_sw_area.h index 196f02c1..063ee60a 100644 --- a/include/d/t/d_t_sw_area.h +++ b/include/d/t/d_t_sw_area.h @@ -1,8 +1,8 @@ #ifndef D_T_SW_AREA_H #define D_T_SW_AREA_H +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" class dTgSwArea_c : public dTg_c { public: @@ -13,33 +13,13 @@ public: virtual int actorExecute() override; private: - u8 getSetSceneflag() { - return mParams; - } - - u8 getUnsetSceneflag() { - return mParams >> 0x8; - } - - u8 getIsPersistent() { - return mParams >> 0x10 & 1; - } - - mAng getSetStoryflag() { - return mRotation.x & 0x7FF; - } - - mAng getUnsetStoryflag() { - return mRotation.z & 0x7FF; - } - - mMtx_c area; - u8 setSceneflag; - u8 unsetSceneflag; - bool isTemporary; - f32 scale; - u16 setStoryflag; - u16 unsetStoryflag; + dArea_c mArea; + u8 mSetSceneflag; + u8 mUnsetSceneflag; + bool mbTemporary; + f32 mScaleModify; + u16 mSetStoryflag; + u16 mUnsetStoryflag; }; #endif diff --git a/include/d/t/d_t_time_door_beam.h b/include/d/t/d_t_time_door_beam.h index d03600e4..5b134375 100644 --- a/include/d/t/d_t_time_door_beam.h +++ b/include/d/t/d_t_time_door_beam.h @@ -1,8 +1,8 @@ #ifndef D_T_TIME_DOOR_BEAM_H #define D_T_TIME_DOOR_BEAM_H +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" class dTgTimeDoorBeam_c : public dTg_c { public: @@ -14,9 +14,10 @@ public: virtual int actorExecute() override; virtual int draw() override; + bool isPlayerInArea(); + private: - bool checkPlayerPosInMtx(); - mMtx_c matrix; + dArea_c mArea; }; #endif diff --git a/include/d/t/d_t_touch.h b/include/d/t/d_t_touch.h index bf0413bc..2a38b3d9 100644 --- a/include/d/t/d_t_touch.h +++ b/include/d/t/d_t_touch.h @@ -1,8 +1,8 @@ #ifndef D_T_TOUCH_H #define D_T_TOUCH_H +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" #include "s/s_State.hpp" class dTgTouchTag : public dTg_c { @@ -30,7 +30,7 @@ private: } STATE_MGR_DECLARE(dTgTouchTag); - mMtx_c mAreaOfEffect; + dArea_c mAreaOfEffect; u16 mFlagTimer; u8 mActivatorIndex; u8 mZoneFlag; diff --git a/include/d/t/d_t_view_clip.h b/include/d/t/d_t_view_clip.h index 0b81b35c..e3c2024a 100644 --- a/include/d/t/d_t_view_clip.h +++ b/include/d/t/d_t_view_clip.h @@ -1,8 +1,8 @@ #ifndef D_T_VIEW_CLIP_H #define D_T_VIEW_CLIP_H +#include "d/d_area.h" #include "d/t/d_tg.h" -#include "m/m_mtx.h" class dTgViewClip_c : public dTg_c { public: @@ -38,7 +38,7 @@ public: static void setViewClip(s32 idx, u8 value); private: - /* 0x0DC */ mMtx_c mArea; + /* 0x0DC */ dArea_c mArea; /* 0x12C */ u8 mIndex; /* 0x12D */ u8 mType; /* 0x12E */ u8 mAreaIndex; diff --git a/include/toBeSorted/area_math.h b/include/toBeSorted/area_math.h deleted file mode 100644 index f4f52600..00000000 --- a/include/toBeSorted/area_math.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef D_AREA_MATH_H -#define D_AREA_MATH_H - -#include "m/m_angle.h" -#include "m/m_mtx.h" -#include "m/m_vec.h" - -void matrixCreateFromPosRotYScale(mMtx_c &, const mVec3_c &, const mAng, const mVec3_c &, mMtx_c *, f32); -bool checkAreaBox(const mMtx_c &, const mVec3_c &); -bool checkAreaCyl(const mMtx_c &, const mVec3_c &); - -#endif diff --git a/src/REL/d/t/d_t_action.cpp b/src/REL/d/t/d_t_action.cpp index 5ea4bf52..a3abb492 100644 --- a/src/REL/d/t/d_t_action.cpp +++ b/src/REL/d/t/d_t_action.cpp @@ -7,15 +7,14 @@ #include "f/f_base.h" #include "f/f_profile_name.h" #include "m/m_angle.h" -#include "toBeSorted/area_math.h" SPECIAL_ACTOR_PROFILE(ACTION_TAG, dTgAction_c, fProfile::ACTION_TAG, 0x20, 0, 0); int dTgAction_c::create() { - mEnableFlag1 = (mParams >> 6) & 0xFF; - mEnableFlag2 = (mParams >> 14) & 0xFF; - mType = (mParams >> 0) & 0x3F; - matrixCreateFromPosRotYScale(mActiveMtx, mPosition, mRotation.y, mScale, nullptr, 0.f); + mEnableFlag1 = getFromParams(6, 0xFF); + mEnableFlag2 = getFromParams(14, 0xFF); + mType = getFromParams(0, 0x3F); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.f); return SUCCEEDED; } @@ -26,14 +25,14 @@ int dTgAction_c::doDelete() { void dTgAction_c::setActiveArea(f32 scale) { if (mScaleIncrease < 0.1f) { mScaleIncrease = scale; - matrixCreateFromPosRotYScale(mActiveMtx, mPosition, mRotation.y, mScale, nullptr, mScaleIncrease); + mArea.set(mPosition, mRotation.y, mScale, nullptr, mScaleIncrease); } } void dTgAction_c::resetActiveArea() { if (mScaleIncrease > 0.f) { mScaleIncrease = 0.f; - matrixCreateFromPosRotYScale(mActiveMtx, mPosition, mRotation.y, mScale, nullptr, 0.f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.f); field_0x134 = 0; } } @@ -51,7 +50,7 @@ int dTgAction_c::actorExecute() { break; } if (pObj->mProfileName == fProfile::BOMB) { - if (checkAreaBox(mActiveMtx, pObj->getPosition())) { + if (mArea.checkAreaBox(pObj->getPosition())) { reinterpret_cast(pObj)->setFlag(dAcBomb_c::FLAG_0x20000000); } } @@ -59,7 +58,7 @@ int dTgAction_c::actorExecute() { } // Check For Player Within Area - if (enabled && checkAreaBox(mActiveMtx, player->getPosition())) { + if (enabled && mArea.checkAreaBox(player->getPosition())) { if (mType == FORCE_FADE_RESTART) { player->onFlags_0x358(0x10000000); setActiveArea(50.f); diff --git a/src/REL/d/t/d_t_beetle.cpp b/src/REL/d/t/d_t_beetle.cpp index 9ba5b33d..0e49a08f 100644 --- a/src/REL/d/t/d_t_beetle.cpp +++ b/src/REL/d/t/d_t_beetle.cpp @@ -5,7 +5,6 @@ #include "d/a/obj/d_a_obj_boomerang.h" #include "d/d_sc_game.h" #include "d/flag/sceneflag_manager.h" -#include "toBeSorted/area_math.h" #include "toBeSorted/time_area_mgr.h" SPECIAL_ACTOR_PROFILE(BEETLE_TAG, dTgBeetle_c, fProfile::BEETLE_TAG, 0x297, 0, 0); @@ -14,7 +13,7 @@ extern const f32 unused_ = 0.0f; int dTgBeetle_c::create() { if (dScGame_c::currentSpawnInfo.stageName == "F103") { // flooded faron woods - if (mActorSubtype) { + if (mActorSubtype != 0) { mScale *= 0.01f; } // Haven't verfied but I think CO_TEST is an invisible sphere created around leaves @@ -23,7 +22,7 @@ int dTgBeetle_c::create() { return FAILED; } else { - if (!mActorSubtype) { // BtlTg + if (mActorSubtype == 0) { // BtlTg mZoneType = getFromParams(0, 0xF); mZoneShape = getFromParams(4, 0x3); mUnknown = getFromParams(6, 0xFF); @@ -39,7 +38,7 @@ int dTgBeetle_c::create() { mZoneShape = SphereShape; } } - matrixCreateFromPosRotYScale(mMatrix1, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); return SUCCEEDED; } } @@ -56,20 +55,18 @@ int dTgBeetle_c::actorExecute() { } if (!SceneflagManager::sInstance->checkBoolFlag(mRoomID, mBeetleFlag) || mActorSubtype) { - dAcBoomerang_c *beetlePtr = - (dAcBoomerang_c *)dAcPy_c::GetLink() - ->getBeetleInFlight(); // boomerang pointer cast required because function currently returns void* + dAcBoomerang_c *beetlePtr = static_cast(dAcPy_c::GetLink()->getBeetleInFlight()); if (mZoneShape == RectangularPrismShape) { // rectangular prism - if (beetlePtr && checkAreaBox(mMatrix1, beetlePtr->mPosition)) { + if (beetlePtr && mArea.checkAreaBox(beetlePtr->mPosition)) { updateBeetle(*beetlePtr); } } else if (mZoneShape == CylinderShape) { // cylinder - if (beetlePtr && isWithinCylinder((beetlePtr->mPosition))) { + if (beetlePtr && isWithinCylinder(beetlePtr->mPosition)) { updateBeetle(*beetlePtr); } } else if (mZoneShape == SphereShape) { // sphere - if (beetlePtr && isWithinSphere((beetlePtr->mPosition))) { + if (beetlePtr && isWithinSphere(beetlePtr->mPosition)) { updateBeetle(*beetlePtr); } } diff --git a/src/REL/d/t/d_t_gate_to_ground.cpp b/src/REL/d/t/d_t_gate_to_ground.cpp index 4f0b47e1..26d679ea 100644 --- a/src/REL/d/t/d_t_gate_to_ground.cpp +++ b/src/REL/d/t/d_t_gate_to_ground.cpp @@ -7,15 +7,14 @@ #include "d/flag/storyflag_manager.h" #include "f/f_base.h" #include "toBeSorted/actor_event.h" -#include "toBeSorted/area_math.h" #include "toBeSorted/event.h" SPECIAL_ACTOR_PROFILE(GATE2GND_TAG, dTgGateToGround_c, fProfile::GATE2GND_TAG, 0x22, 0, 0); int dTgGateToGround_c::create() { - matrixCreateFromPosRotYScale(matrix, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); - delayFrames = 0; + mDelayFrameCount = 0; union { u32 val; @@ -26,9 +25,9 @@ int dTgGateToGround_c::create() { }; } v; v.val = mParams; - params_FF_FF_00_00 = v.a; - params_00_00_FF_00 = v.b; - params_00_00_00_FF = v.c; + mStoryflag = v.a; + field_0x182 = v.b; + mCameraID = v.c; return SUCCEEDED; } @@ -38,31 +37,29 @@ int dTgGateToGround_c::doDelete() { } int dTgGateToGround_c::actorExecute() { - dAcPy_c *player; - - if (params_FF_FF_00_00 != -1 && StoryflagManager::sInstance->getCounterOrFlag(params_FF_FF_00_00) == 0) { + if (mStoryflag != -1 && StoryflagManager::sInstance->getCounterOrFlag(mStoryflag) == 0) { return SUCCEEDED; } - player = dAcPy_c::LINK; + dAcPy_c *player = dAcPy_c::GetLinkM(); - if (checkAreaBox(matrix, player->mPosition)) { + if (mArea.checkAreaBox(player->mPosition)) { if (player->getRidingActorType() != dAcPy_c::RIDING_LOFTWING) { - if (delayFrames > 15) { + if (mDelayFrameCount > 15) { Event e("CloudHole", 100, 0, nullptr, nullptr); mEventRelated.scheduleEvent(e, 0); } else { - delayFrames++; + mDelayFrameCount++; } } else { - if (params_00_00_00_FF != -1) { + if (mCameraID != -1) { // TODO Cast is maybe fake but I can't get overrideCam to match otherwise - dScGame_c::getCamera(0)->getGameCam1()->overrideCam(params_00_00_00_FF, 0, (u16)mRoomID, false); + dScGame_c::getCamera(0)->getGameCam1()->overrideCam(mCameraID, 0, (u16)mRoomID, false); } - delayFrames = 0; + mDelayFrameCount = 0; } } else { - delayFrames = 0; + mDelayFrameCount = 0; } return SUCCEEDED; diff --git a/src/REL/d/t/d_t_heat_resist.cpp b/src/REL/d/t/d_t_heat_resist.cpp index 045cce17..2bdc802d 100644 --- a/src/REL/d/t/d_t_heat_resist.cpp +++ b/src/REL/d/t/d_t_heat_resist.cpp @@ -2,14 +2,13 @@ #include "d/a/d_a_player.h" #include "f/f_base.h" -#include "toBeSorted/area_math.h" SPECIAL_ACTOR_PROFILE(TAG_HEAT_RESIST, dTgHeatResist_c, fProfile::TAG_HEAT_RESIST, 0x223, 0, 4); int dTgHeatResist_c::create() { - mInverted = static_cast(mParams & 0x3); + mInverted = getFromParams(0, 0x3); - matrixCreateFromPosRotYScale(matrix, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); return SUCCEEDED; } @@ -18,14 +17,14 @@ int dTgHeatResist_c::doDelete() { } int dTgHeatResist_c::actorExecute() { - dAcPy_c *player = dAcPy_c::LINK; + dAcPy_c *player = dAcPy_c::GetLinkM(); if (mInverted == 1) { - if (!checkAreaBox(matrix, player->mPosition)) { + if (!mArea.checkAreaBox(player->mPosition)) { player->onForceOrPreventActionFlags(0x8000000); } } else { - if (checkAreaBox(matrix, player->mPosition)) { + if (mArea.checkAreaBox(player->mPosition)) { player->onForceOrPreventActionFlags(0x8000000); } } diff --git a/src/REL/d/t/d_t_restart_time_stone.cpp b/src/REL/d/t/d_t_restart_time_stone.cpp index 118f4986..94e1c1f4 100644 --- a/src/REL/d/t/d_t_restart_time_stone.cpp +++ b/src/REL/d/t/d_t_restart_time_stone.cpp @@ -1,16 +1,15 @@ #include "d/t/d_t_restart_time_stone.h" #include "f/f_base.h" -#include "toBeSorted/area_math.h" #include "toBeSorted/d_path.h" SPECIAL_ACTOR_PROFILE(TAG_RESTART_TIME_STONE, dTgRestartTimeStone_c, fProfile::TAG_RESTART_TIME_STONE, 0x29A, 0, 0); int dTgRestartTimeStone_c::create() { - matrixCreateFromPosRotYScale(mMtx, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); ActorOnRail3 rail; - u8 pathIdx = mParams & 0xFF; + u8 pathIdx = getFromParams(0, 0xFF); if (pathIdx != 0xFF) { rail.init(pathIdx, mRoomID, 0, 0, false); mPathStartPos.copyFrom(rail.getPath().getPoint(0)); diff --git a/src/REL/d/t/d_t_scene_change.cpp b/src/REL/d/t/d_t_scene_change.cpp index 972d2406..35c05fa4 100644 --- a/src/REL/d/t/d_t_scene_change.cpp +++ b/src/REL/d/t/d_t_scene_change.cpp @@ -10,7 +10,6 @@ #include "f/f_profile_name.h" #include "m/m_angle.h" #include "m/m_vec.h" -#include "toBeSorted/area_math.h" #include "toBeSorted/d_path.h" #include "toBeSorted/event.h" #include "toBeSorted/event_manager.h" @@ -31,7 +30,7 @@ int dTgSceneChange_c::create() { mEnableSceneflag = getFromParams(24, 0xFF); mEnableStoryflag = (mRotation.x >> 0) & 0x7FF; - field_0x134 = ((mRotation.x >> 11) & 0x3) == 1; + mbAreaCyl = ((mRotation.x >> 11) & 0x3) == 1; mRotation.x = 0; mDisableStoryflag = mRotation.z & 0x7FF; @@ -39,7 +38,7 @@ int dTgSceneChange_c::create() { mRotation.z = 0; - matrixCreateFromPosRotYScale(mArea, mPosition, mRotation.y, mScale, nullptr, 0.f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.f); return SUCCEEDED; } @@ -71,8 +70,8 @@ int dTgSceneChange_c::actorExecute() { } dAcPy_c *pPlayer = dAcPy_c::GetLinkM(); - if ((field_0x134 && checkAreaCyl(mArea, pPlayer->mPosition)) || - (!field_0x134 && checkAreaBox(mArea, pPlayer->mPosition))) { + if ((mbAreaCyl && mArea.checkAreaCyl(pPlayer->mPosition)) || + (!mbAreaCyl && mArea.checkAreaBox(pPlayer->mPosition))) { if (!(field_0x136 && checkScrapper())) { pPlayer->triggerExitRelated(mSceneLink, mPathId, mSceneType); } diff --git a/src/REL/d/t/d_t_stream.cpp b/src/REL/d/t/d_t_stream.cpp index 80990f61..5d4d0e92 100644 --- a/src/REL/d/t/d_t_stream.cpp +++ b/src/REL/d/t/d_t_stream.cpp @@ -3,7 +3,6 @@ #include "d/a/d_a_base.h" #include "f/f_base.h" #include "f/f_list_mg.h" -#include "toBeSorted/area_math.h" SPECIAL_ACTOR_PROFILE(TAG_STREAM, dTgStream_c, fProfile::TAG_STREAM, 0x29D, 0, 0); @@ -47,7 +46,7 @@ int dTgStream_c::create() { addToList(sStreamList); } - matrixCreateFromPosRotYScale(mArea, mPosition, mRotation.y, mScale, nullptr, 0.f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.f); return SUCCEEDED; } diff --git a/src/REL/d/t/d_t_sw_area.cpp b/src/REL/d/t/d_t_sw_area.cpp index cc9cbee1..da503d9f 100644 --- a/src/REL/d/t/d_t_sw_area.cpp +++ b/src/REL/d/t/d_t_sw_area.cpp @@ -3,21 +3,20 @@ #include "d/a/d_a_player.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" -#include "toBeSorted/area_math.h" SPECIAL_ACTOR_PROFILE(SW_AREA_TAG, dTgSwArea_c, fProfile::SW_AREA_TAG, 0x292, 0, 0); int dTgSwArea_c::create() { - setSceneflag = getSetSceneflag(); - unsetSceneflag = getUnsetSceneflag(); - isTemporary = !getIsPersistent(); + mSetSceneflag = getFromParams(0, 0xFF); + mUnsetSceneflag = getFromParams(8, 0xFF); + mbTemporary = !getFromParams(16, 0x1); - setStoryflag = getSetStoryflag(); - unsetStoryflag = getUnsetStoryflag(); + mSetStoryflag = mRotation.x & 0x7FF; + mUnsetStoryflag = mRotation.z & 0x7FF; mRotation.x = 0; mRotation.z = 0; - matrixCreateFromPosRotYScale(area, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); return SUCCEEDED; } @@ -32,38 +31,38 @@ bool isValidStoryFlag(u16 storyflag) { } int dTgSwArea_c::actorExecute() { - if (checkAreaBox(area, dAcPy_c::LINK->mPosition)) { - SceneflagManager::sInstance->setFlag(mRoomID, setSceneflag); - SceneflagManager::sInstance->unsetFlag(mRoomID, unsetSceneflag); + if (mArea.checkAreaBox(dAcPy_c::GetLink()->mPosition)) { + SceneflagManager::sInstance->setFlag(mRoomID, mSetSceneflag); + SceneflagManager::sInstance->unsetFlag(mRoomID, mUnsetSceneflag); - if (isValidStoryFlag(setStoryflag)) { - StoryflagManager::sInstance->setFlag(setStoryflag); + if (isValidStoryFlag(mSetStoryflag)) { + StoryflagManager::sInstance->setFlag(mSetStoryflag); } - if (isValidStoryFlag(unsetStoryflag)) { - StoryflagManager::sInstance->unsetFlag(unsetStoryflag); + if (isValidStoryFlag(mUnsetStoryflag)) { + StoryflagManager::sInstance->unsetFlag(mUnsetStoryflag); } - if (scale < 1.0f) { - scale = 50.0f; - matrixCreateFromPosRotYScale(area, mPosition, mRotation.y, mScale, nullptr, scale); + if (mScaleModify < 1.0f) { + mScaleModify = 50.0f; + mArea.set(mPosition, mRotation.y, mScale, nullptr, mScaleModify); } } else { - if (scale > 1.0f) { - scale = 0.0f; - matrixCreateFromPosRotYScale(area, mPosition, mRotation.y, mScale, nullptr, scale); + if (mScaleModify > 1.0f) { + mScaleModify = 0.0f; + mArea.set(mPosition, mRotation.y, mScale, nullptr, mScaleModify); } - if (isTemporary) { - SceneflagManager::sInstance->unsetFlag(mRoomID, setSceneflag); - SceneflagManager::sInstance->setFlag(mRoomID, unsetSceneflag); + if (mbTemporary) { + SceneflagManager::sInstance->unsetFlag(mRoomID, mSetSceneflag); + SceneflagManager::sInstance->setFlag(mRoomID, mUnsetSceneflag); - if (isValidStoryFlag(setStoryflag)) { - StoryflagManager::sInstance->unsetFlag(setStoryflag); + if (isValidStoryFlag(mSetStoryflag)) { + StoryflagManager::sInstance->unsetFlag(mSetStoryflag); } - if (isValidStoryFlag(unsetStoryflag)) { - StoryflagManager::sInstance->setFlag(unsetStoryflag); + if (isValidStoryFlag(mUnsetStoryflag)) { + StoryflagManager::sInstance->setFlag(mUnsetStoryflag); } } } diff --git a/src/REL/d/t/d_t_time_door_beam.cpp b/src/REL/d/t/d_t_time_door_beam.cpp index bc9b2aa6..a33aa523 100644 --- a/src/REL/d/t/d_t_time_door_beam.cpp +++ b/src/REL/d/t/d_t_time_door_beam.cpp @@ -1,12 +1,11 @@ #include "d/t/d_t_time_door_beam.h" #include "d/a/d_a_player.h" -#include "toBeSorted/area_math.h" SPECIAL_ACTOR_PROFILE(TAG_TIME_DOOR_BEAM, dTgTimeDoorBeam_c, fProfile::TAG_TIME_DOOR_BEAM, 0x252, 0, 0); int dTgTimeDoorBeam_c::create() { - matrixCreateFromPosRotYScale(matrix, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); return SUCCEEDED; } @@ -22,10 +21,10 @@ int dTgTimeDoorBeam_c::draw() { return SUCCEEDED; } -bool dTgTimeDoorBeam_c::checkPlayerPosInMtx() { - if (dAcPy_c::LINK == nullptr) { +bool dTgTimeDoorBeam_c::isPlayerInArea() { + if (dAcPy_c::GetLink() == nullptr) { return false; } - return checkAreaBox(matrix, dAcPy_c::LINK->mPosition); + return mArea.checkAreaBox(dAcPy_c::GetLink()->mPosition); } diff --git a/src/REL/d/t/d_t_touch.cpp b/src/REL/d/t/d_t_touch.cpp index 99b46ad2..208564fc 100644 --- a/src/REL/d/t/d_t_touch.cpp +++ b/src/REL/d/t/d_t_touch.cpp @@ -1,9 +1,7 @@ #include "d/t/d_t_touch.h" -#include "c/c_math.h" #include "d/flag/sceneflag_manager.h" #include "s/s_Math.h" -#include "toBeSorted/area_math.h" SPECIAL_ACTOR_PROFILE(TOUCH_TAG, dTgTouchTag, fProfile::TOUCH_TAG, 0x028E, 0, 0); @@ -18,7 +16,7 @@ int dTgTouchTag::create() { mActivatorIndex = !(getActivatorIndex() == 0xF) ? getActivatorIndex() : 0; mZoneFlag = getZoneFlag(); mChkFlag = getChkFlag(); - matrixCreateFromPosRotYScale(mAreaOfEffect, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mAreaOfEffect.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); mStateMgr.changeState(StateID_Wait); return SUCCEEDED; } @@ -48,7 +46,7 @@ void dTgTouchTag::executeState_Wait() { dAcBase_c *actor = static_cast(fManager_c::searchBaseByProfName(ACTIVATORS[mActivatorIndex], nullptr)); while (actor != nullptr) { - if (actor->mRoomID == mRoomID && checkAreaBox(mAreaOfEffect, actor->mPosition)) { + if (actor->mRoomID == mRoomID && mAreaOfEffect.checkAreaBox(actor->mPosition)) { mFlagTimer = 5; if (mZoneFlag != 0xFF) { SceneflagManager::sInstance->setFlag(mRoomID, mZoneFlag); diff --git a/src/d/d_area.cpp b/src/d/d_area.cpp new file mode 100644 index 00000000..6e9929fa --- /dev/null +++ b/src/d/d_area.cpp @@ -0,0 +1,33 @@ +#include "d/d_area.h" + +#include "common.h" +#include "m/m_mtx.h" +#include "m/m_vec.h" +#include "rvl/MTX/mtx.h" + +void dArea_c::set(const mVec3_c &position, const mAng rotY, const mVec3_c &scale, mMtx_c *pSrc, f32 scaleTerm) { + mMtx_c src; + if (pSrc == nullptr) { + pSrc = &src; + } + pSrc->transS(position.x, position.y + scale.y * 0.5f, position.z); + pSrc->YrotM(rotY); + pSrc->scaleM(scale.x + scaleTerm, scale.y + scaleTerm, scale.z + scaleTerm); + mArea.copyFrom(*pSrc); + MTXInverse(mArea, mArea); +} + +bool dArea_c::checkAreaBox(const mVec3_c &position) { + mVec3_c pos; + mArea.multVec(position, pos); + return (-0.5f <= pos.x && pos.x <= 0.5f) && // + (-0.5f <= pos.y && pos.y <= 0.5f) && // + (-0.5f <= pos.z && pos.z <= 0.5f); +} + +bool dArea_c::checkAreaCyl(const mVec3_c &position) { + mVec3_c pos; + mArea.multVec(position, pos); + return (-0.5f <= pos.y && pos.y <= 0.5f) && // + pos.squareMagXZ() <= 1.0f; +} diff --git a/src/d/tg/d_t_alldie.cpp b/src/d/tg/d_t_alldie.cpp index a205ce09..f3bb8610 100644 --- a/src/d/tg/d_t_alldie.cpp +++ b/src/d/tg/d_t_alldie.cpp @@ -3,14 +3,12 @@ #include "common.h" #include "d/a/d_a_player.h" #include "d/a/e/d_a_en_base.h" -#include "d/a/obj/d_a_obj_base.h" #include "d/d_stage.h" #include "d/flag/sceneflag_manager.h" #include "f/f_base.h" #include "f/f_manager.h" #include "f/f_profile_name.h" #include "s/s_Math.h" -#include "toBeSorted/area_math.h" #include "toBeSorted/event_manager.h" SPECIAL_ACTOR_PROFILE(ALLDIE_TAG, dTgAllDie_c, fProfile::ALLDIE_TAG, 0x23, 0, 4); @@ -22,7 +20,7 @@ int dTgAllDie_c::create() { field_0x148 = 0; field_0x144 = getFromParams(30, 0xFF); mRotation.x.set(0); - matrixCreateFromPosRotYScale(mArea, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); return SUCCEEDED; } @@ -55,7 +53,7 @@ int dTgAllDie_c::actorExecute() { while ((pEnemy = dAcEnBase_c::GetNextEnemy(pEnemy))) { if (pEnemy->mRoomID == mRoomID && !pEnemy->checkInteractionFlags(0x2)) { if (pEnemy->checkProcControl(DISABLE_EXECUTE) == 0 && pEnemy->mLifecycleState != TO_BE_DELETED) { - if (checkAreaBox(mArea, pEnemy->mPosition)) { + if (mArea.checkAreaBox(pEnemy->mPosition)) { mNumEnemiesInArea++; } } diff --git a/src/d/tg/d_t_event.cpp b/src/d/tg/d_t_event.cpp index add4cac5..41091907 100644 --- a/src/d/tg/d_t_event.cpp +++ b/src/d/tg/d_t_event.cpp @@ -3,13 +3,12 @@ #include "d/a/d_a_player.h" #include "d/flag/sceneflag_manager.h" #include "f/f_base.h" -#include "toBeSorted/area_math.h" #include "toBeSorted/event.h" SPECIAL_ACTOR_PROFILE(EVENT_TAG, dTgEvent_c, fProfile::EVENT_TAG, 0X13, 0, 0); int dTgEvent_c::create() { - matrixCreateFromPosRotYScale(mMatrix, mPosition, mRotation.y, mScale, 0x0, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, 0x0, 0.0f); mEventId = getFromParams(0, 0xFF); mSetSceneflag = getFromParams(8, 0xFF); mTrigSceneflag = getFromParams(16, 0xFF); @@ -42,7 +41,7 @@ int dTgEvent_c::actorExecute() { if (!isValidFlag(mTrigSceneflag) || checkUncommittedFlag(mTrigSceneflag)) { if ((mSubtype != 0 && !(isValidFlag(mSetSceneflag) && checkUncommittedFlag(mSetSceneflag))) || (mSubtype == 0 && (isValidFlag(mSetSceneflag) && checkUncommittedFlag(mSetSceneflag)))) { - if (checkAreaBox(mMatrix, dAcPy_c::LINK->mPosition)) { + if (mArea.checkAreaBox(dAcPy_c::GetLink()->mPosition)) { Event EStack_48 = Event(mEventId, mRoomID, fun(mUnkParamFlag, 0x1), 0, 0); mActorEvent.scheduleEvent(EStack_48, 0); } diff --git a/src/d/tg/d_t_event_f.cpp b/src/d/tg/d_t_event_f.cpp index 3300eda0..17457f87 100644 --- a/src/d/tg/d_t_event_f.cpp +++ b/src/d/tg/d_t_event_f.cpp @@ -3,20 +3,19 @@ #include "d/a/d_a_player.h" #include "d/flag/storyflag_manager.h" #include "f/f_base.h" -#include "toBeSorted/area_math.h" SPECIAL_ACTOR_PROFILE(EVENTF_TAG, dTgEventF_c, fProfile::EVENTF_TAG, 0x14, 0, 0); int dTgEventF_c::create() { - matrixCreateFromPosRotYScale(mMatrix, mPosition, mRotation.y, mScale, 0x0, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, 0x0, 0.0f); mEventId = getFromParams(0, 0xFF); mSetStoryflag = getFromParams(8, 0x7FF); - if ((s32)mSetStoryflag == 0x3FF) { - mSetStoryflag = 0xFFFFFFFF; + if (mSetStoryflag == 0x3FF) { + mSetStoryflag = -1; } mTrigStoryflag = getFromParams(19, 0x7FF); - if ((s32)mTrigStoryflag == 0x3FF) { - mTrigStoryflag = 0xFFFFFFFF; + if (mTrigStoryflag == 0x3FF) { + mTrigStoryflag = -1; } mSubtype = getFromParams(30, 0x3); return SUCCEEDED; @@ -26,19 +25,19 @@ int dTgEventF_c::doDelete() { return SUCCEEDED; } -int dTgEventF_c::checkStoryflagValid(u32 counterIdx) { +int dTgEventF_c::checkStoryflagValid(s32 counterIdx) { return StoryflagManager::sInstance->checkFlagValid(counterIdx); } -bool dTgEventF_c::checkUncommitedStoryFlagValue(u32 flag) { +bool dTgEventF_c::checkUncommitedStoryFlagValue(s32 flag) { return StoryflagManager::sInstance->getUncommittedValue(flag); } -void dTgEventF_c::setStoryFlag(StoryFlags_e flag) { +void dTgEventF_c::setStoryFlag(s32 flag) { StoryflagManager::sInstance->setFlag(flag); } -void dTgEventF_c::unsetStoryFlag(StoryFlags_e flag) { +void dTgEventF_c::unsetStoryFlag(s32 flag) { StoryflagManager::sInstance->unsetFlag(flag); } @@ -46,7 +45,7 @@ int dTgEventF_c::actorExecute() { if ((!checkStoryflagValid(mTrigStoryflag) || checkUncommitedStoryFlagValue(mTrigStoryflag))) { if ((mSubtype != 0 && !(checkStoryflagValid(mSetStoryflag) && checkUncommitedStoryFlagValue(mSetStoryflag))) || (mSubtype == 0 && checkStoryflagValid(mSetStoryflag) && checkUncommitedStoryFlagValue(mSetStoryflag))) { - if (checkAreaBox(mMatrix, dAcPy_c::LINK->mPosition)) { + if (mArea.checkAreaBox(dAcPy_c::GetLink()->mPosition)) { Event EStack_48 = Event(mEventId, (int)mRoomID, 0x100001, 0, 0); mActorEvent.scheduleEvent(EStack_48, 0); } @@ -58,10 +57,10 @@ int dTgEventF_c::actorExecuteInEvent() { if (mActorEvent.isThisActorInEvent()) { mActorEvent.advanceNext(); if (!(mSubtype == 0 || !checkStoryflagValid(mSetStoryflag) || checkUncommitedStoryFlagValue(mSetStoryflag))) { - setStoryFlag((StoryFlags_e)mSetStoryflag); + setStoryFlag(mSetStoryflag); } else if ((mSubtype == 0 && checkStoryflagValid(mSetStoryflag)) && checkUncommitedStoryFlagValue(mSetStoryflag)) { - unsetStoryFlag((StoryFlags_e)mSetStoryflag); + unsetStoryFlag(mSetStoryflag); } } return SUCCEEDED; diff --git a/src/d/tg/d_t_view_clip.cpp b/src/d/tg/d_t_view_clip.cpp index 30ef9cba..c88f80b1 100644 --- a/src/d/tg/d_t_view_clip.cpp +++ b/src/d/tg/d_t_view_clip.cpp @@ -4,7 +4,6 @@ #include "d/d_camera.h" #include "d/d_sc_game.h" #include "f/f_base.h" -#include "toBeSorted/area_math.h" #include "toBeSorted/area_utils.h" SPECIAL_ACTOR_PROFILE(VIEW_CLIP_TAG, dTgViewClip_c, fProfile::VIEW_CLIP_TAG, 0xB, 0, 0); @@ -19,7 +18,7 @@ int dTgViewClip_c::create() { } mAreaIndex = getFromParams(12, 0xFF); - matrixCreateFromPosRotYScale(mArea, mPosition, mRotation.y, mScale, nullptr, 0.0f); + mArea.set(mPosition, mRotation.y, mScale, nullptr, 0.0f); return SUCCEEDED; } @@ -34,7 +33,7 @@ int dTgViewClip_c::actorExecute() { int dTgViewClip_c::draw() { dCamera_c *pCamera = dScGame_c::getCamera(); - if (!checkAreaBox(mArea, pCamera->getPosition())) { + if (!mArea.checkAreaBox(pCamera->getPosition())) { if (mAreaIndex == 0xFF) { return SUCCEEDED; }