* Dowsing.

* d_t_dowsing

* d_t_holy_water OK
This commit is contained in:
robojumper
2024-09-12 22:23:11 +02:00
committed by GitHub
parent 9aa30ee499
commit e2c4bb7be7
40 changed files with 1041 additions and 160 deletions
+71
View File
@@ -0,0 +1,71 @@
#ifndef DOWSING_TARGET_H
#define DOWSING_TARGET_H
#include <d/a/d_a_base.h>
#include <f/f_list_nd.h>
#include <m/m_vec.h>
class DowsingTarget {
public:
TListNode mLink; // 0x00
private:
dAcBase_c *mpActor; // 0x08
u8 mDowsingSlot; // 0x0C
u16 field_0x0E; // 0x0E
mVec3_c mOffset; // 0x10
public:
enum DowsingSlot {
SLOT_STORY_EVENT = 0,
SLOT_RUPEE = 1,
SLOT_QUEST = 2,
SLOT_CRYSTAL = 3,
SLOT_HEART = 4,
SLOT_GODDESS_CUBE = 5,
SLOT_LOOK = 6,
SLOT_TREASURE = 7,
SLOT_NONE = 8,
};
DowsingTarget(dAcBase_c *ac, u8 dowsingSlot) : mpActor(ac), mDowsingSlot(dowsingSlot) {}
// vt offset 0x1C
virtual ~DowsingTarget(); // 0x08
virtual void getPosition(mVec3_c &); // 0x0C
bool doRegister();
bool doUnregister();
void initialize(DowsingSlot type, u16 unk, const mVec3_c *offset, f32 f);
void reinitialize(DowsingSlot type);
inline DowsingSlot getSlot() {
return (DowsingSlot)mDowsingSlot;
}
static bool hasZeldaDowsing();
static bool hasKikwiDowsing();
static bool hasKeyPieceDowsing();
static bool hasDesertNodeDowsing();
static bool hasAnyTrialDowsing();
static bool hasSacredWaterDowsing();
static bool hasSandshipDowsing();
static bool hasTadtoneDowsing();
static bool hasPropellerDowsing();
static bool hasWaterBasinDowsing();
static bool hasCrystalBallDowsing();
static bool hasPumpkinDowsing();
static bool hasNewPlantSpeciesDowsing();
static bool hasPartyWheelDowsing();
static bool hasDowsingInSlot(int slot);
static DowsingTarget *getDowsingInfo(const mVec3_c &playerPosition, const mVec3_c &dowsingDirection, f32 *, f32 *,
f32 *intensity, int slot);
static void init();
static void execute();
static u8 getTopDowsingIcon();
static u8 getLeftDowsingIcon();
};
#endif
@@ -0,0 +1,46 @@
#ifndef ITEM_STORY_FLAG_MANAGER_H
#define ITEM_STORY_FLAG_MANAGER_H
#include <toBeSorted/flag_space.h>
#include <toBeSorted/unk_flag_stuff.h>
// TODO These classes have an interesting relation and there are like 5 vtables, so
// the stuff in this header should not be relied upon for actually implementing these,
// but we need the interface
class ItemStoryManagerBase {
public:
ItemStoryManagerBase();
/** 0x08 */ virtual ~ItemStoryManagerBase();
/** 0x0C */ virtual void setFlagszptr();
/** 0x10 */ virtual void onDirty();
/** 0x14 */ virtual void copyFlagsFromSave() = 0;
/** 0x18 */ virtual void setupUnkFlagsStuff() = 0;
/** 0x1C */ virtual bool doCommit() = 0;
/** 0x20 */ virtual void setFlag(u16 flag);
/** 0x24 */ virtual void unsetFlag(u16 flag);
/** 0x28 */ virtual void setFlagOrCounterToValue(u16 flag, u16 value);
/** 0x2C */ virtual u16 getCounterOrFlag(u16 flag) const;
/** 0x30 */ virtual u16 getUncommittedValue(u16 flag);
/** 0x34 */ virtual void unk3();
/** 0x38 */ virtual u16 *getSaveFlagSpace() = 0;
u16 getFlag(u16 flag) const;
};
class StoryFlagManager : public ItemStoryManagerBase {
FlagSpace storyFlags;
public:
static StoryFlagManager *sInstance;
};
class ItemFlagManager : public ItemStoryManagerBase {
FlagSpace itemFlags;
public:
static ItemFlagManager *sInstance;
};
#endif
+3 -3
View File
@@ -21,7 +21,7 @@ class dRoomCollision {
char todo[352];
};
class dRoom : dBase_c {
class dRoom : public dBase_c {
public:
mAllocator_c allocator;
nw4r::g3d::ResFile *roomRes;
@@ -94,8 +94,8 @@ public:
/* 80575760 */ static RoomManager *m_Instance;
public:
dRoom *GetRoomByIndex(int roomid);
/* 801b42b0 */ static dBase_c *getRoom(int roomid);
/* 801b3970 */ dRoom *GetRoomByIndex(int roomid);
/* 801b42b0 */ static dRoom *getRoom(int roomid);
/* 801b42d0 */ static void bindStageResToFile(nw4r::g3d::ResFile *);
/* 801b4320 */ static void bindSkyCmnToResFile(nw4r::g3d::ResFile *);
/* 801b4380 */ static bool getMA0AnmTexSrt(nw4r::g3d::ResAnmTexSrt *, char *);
+5
View File
@@ -58,6 +58,11 @@ public:
void unsetSceneflagGlobal(u16 sceneIdx, u16 flag);
void unsetTempOrSceneflag(u16 flag);
s32 doCommit();
bool checkBoolFlag(u16 roomid, u16 flag) {
return checkFlag(roomid, flag);
}
};
#endif
+4
View File
@@ -13,6 +13,10 @@ struct SpawnInfo {
/* 0x26 */ s8 trial;
/* 0x27 */ s8 transitionType;
/* 0x28 */ s32 unk;
bool isNight() {
return night == 1;
}
};
class ScGame {
+130
View File
@@ -0,0 +1,130 @@
#ifndef T_LIST_H
#define T_LIST_H
// A templated list, similar to nw4r::ut::LinkList.
// Notable differences are:
// * No dtor
// * Entirely in headers
// * Swapped node and count members
// Used in DowsingTarget, maybe also in dAcBase_c.soundStuff
// It's not immediately clear whether this stores pointers to nodes
// or pointers to objects. DowsingTarget's node offset is 0, so there's
// no observable difference, but the SoundSource stuff makes it
// look like it stores object pointers
class TListNode {
public:
TListNode() : mpPrev(nullptr), mpNext(nullptr) {}
void *GetNext() const {
return mpNext;
}
void *GetPrev() const {
return mpPrev;
}
void *mpPrev;
void *mpNext;
};
template <typename T, int offset>
class TList {
public:
class Iterator {
public:
Iterator() : mNode(NULL) {}
Iterator(TListNode *node) : mNode(node) {}
Iterator &operator++() {
mNode = GetNodeFromPointer(mNode->GetNext());
return *this;
}
Iterator &operator--() {
mNode = mNode->GetPrev();
return *this;
}
T *operator->() const {
return GetPointerFromNode(mNode);
}
T &operator*() {
return *this->operator->();
}
friend bool operator==(Iterator lhs, Iterator rhs) {
return lhs.mNode == rhs.mNode;
}
friend bool operator!=(Iterator lhs, Iterator rhs) {
return !(lhs.mNode == rhs.mNode);
}
private:
TListNode *mNode; // at 0x0
};
TList() {
this->mNode.mpNext = GetPointerFromNode(&mNode);
this->mNode.mpPrev = GetPointerFromNode(&mNode);
mCount = 0;
}
Iterator GetBeginIter() {
return GetNodeFromPointer(&mNode) != mNode.GetNext() ? Iterator(GetNodeFromPointer(mNode.GetNext())) :
Iterator(&mNode);
}
Iterator GetEndIter() {
return Iterator(&mNode);
}
static TListNode *GetNodeFromPointer(void *p) {
return reinterpret_cast<TListNode *>(reinterpret_cast<char *>(p) + offset);
}
static T *GetPointerFromNode(TListNode *node) {
return reinterpret_cast<T *>(reinterpret_cast<char *>(node) - offset);
}
void insert(T *value) {
TListNode *node = GetNodeFromPointer(value);
if (GetPointerFromNode(&mNode) == this->mNode.mpNext) {
node->mpNext = GetPointerFromNode(&mNode);
node->mpPrev = GetPointerFromNode(&mNode);
this->mNode.mpNext = value;
this->mNode.mpPrev = value;
mCount++;
} else {
node->mpPrev = this->mNode.mpPrev;
node->mpNext = GetPointerFromNode(&mNode);
GetNodeFromPointer(this->mNode.mpPrev)->mpNext = value;
this->mNode.mpPrev = value;
mCount++;
}
}
void remove(T *value) {
TListNode *node = GetNodeFromPointer(value);
T *next = reinterpret_cast<T *>(node->mpNext);
if (GetPointerFromNode(&mNode) == node->mpPrev) {
this->mNode.mpNext = next;
} else {
GetNodeFromPointer(node->mpPrev)->mpNext = next;
}
if (GetPointerFromNode(&mNode) == node->mpNext) {
this->mNode.mpPrev = node->mpPrev;
} else {
GetNodeFromPointer(node->mpNext)->mpPrev = node->mpPrev;
}
node->mpPrev = nullptr;
node->mpNext = nullptr;
mCount--;
}
TListNode mNode;
s32 mCount;
};
#endif