Link dowsing_target, eggException, d_lyt_meter_drink (#128)

* Link dowsing_target, eggException

* d_lyt_meter_drink OK (thanks Zeldex!)

* More sensible DowsingTarget flag code

* Attempt explaining TList inline
This commit is contained in:
robojumper
2025-03-14 03:13:15 +01:00
committed by GitHub
parent 01b964c831
commit 32cbf96184
8 changed files with 53 additions and 43 deletions
+18 -18
View File
@@ -406,6 +406,15 @@ bool dLytMeterDrink_c::build(d2d::ResAccIf_c *resAcc) {
return true;
}
bool dLytMeterDrink_c::remove() {
for (int i = 0; i < 20; i++) {
mAnmGroups[i].unbind();
mAnmGroups[i].afterUnbind();
}
return true;
}
bool dLytMeterDrink_c::execute() {
mStateMgr.executeState();
@@ -420,29 +429,11 @@ bool dLytMeterDrink_c::execute() {
return true;
}
bool dLytMeterDrink_c::remove() {
for (int i = 0; i < 20; i++) {
mAnmGroups[i].unbind();
mAnmGroups[i].afterUnbind();
}
return true;
}
bool dLytMeterDrink_c::draw() {
mLyt.addToDrawList();
return true;
}
int dLytMeterDrink_c::getPartForDrinkType(dLytMeterDrinkParts_c::DrinkType_e ty) const {
for (int i = 0; i < 3; i++) {
if (ty == mParts[i].mDrinkType) {
return i;
}
}
return 3;
}
bool dLytMeterDrink_c::fn_800E5C40(int i) {
if ((i == 0 || i == 3) && (FileManager::GetInstance()->getStaminaPotionTimer() != 0 ||
FileManager::GetInstance()->getStaminaPotionPlusTimer() != 0)) {
@@ -462,6 +453,15 @@ bool dLytMeterDrink_c::fn_800E5C40(int i) {
return false;
}
int dLytMeterDrink_c::getPartForDrinkType(dLytMeterDrinkParts_c::DrinkType_e ty) const {
for (int i = 0; i < 3; i++) {
if (ty == mParts[i].mDrinkType) {
return i;
}
}
return 3;
}
void dLytMeterDrink_c::executeInternal() {
bool bHasNotSoonExpiringDrink = false;
bool bHasSoonExpiringDrink = false;
+6 -5
View File
@@ -13,7 +13,7 @@
namespace EGG {
Exception *Exception::sException;
volatile nw4r::db::ConsoleHandle Exception::sConsoleHandle;
nw4r::db::ConsoleHandle Exception::sConsoleHandle;
void *Exception::sMapFileWorks;
u32 Exception::sMapFileNumMax;
u32 Exception::sCurrentMapFileNum;
@@ -179,16 +179,17 @@ Exception::Exception(u16 width, u16 height, u16 attr, EGG::Heap *heap, int mapFi
return;
}
GXRenderModeObj *o = EGG::BaseSystem::getVideo()->getCurrentOrFallbackRenderModeObj();
nw4r::db::Exception_SetConsole(sConsoleHandle, o);
const GXRenderModeObj *o = EGG::BaseSystem::getVideo()->getCurrentOrFallbackRenderModeObj();
// Fakematch? Everything before Exception_SetConsole matches if it's volatile, but things after
// it break
nw4r::db::Exception_SetConsole(*(nw4r::db::ConsoleHandle *volatile)&sConsoleHandle, o);
nw4r::db::Console_SetPosition(sConsoleHandle, 0, 30);
nw4r::db::Console_SetVisible(sConsoleHandle, false);
sMapFileNumMax = mapFileNum;
size_t size = mapFileNum * 0x14;
sCurrentMapFileNum = 0;
sMapFileWorks = Heap::alloc(size, 4, heap);
sMapFileWorks = Heap::alloc(mapFileNum * 0x14, 4, heap);
SetCallbackArgs(nullptr);
}
+8 -14
View File
@@ -136,9 +136,12 @@ bool DowsingTarget::hasDowsingInSlot(int slot) {
} else if (slot == 2) {
return hasCrystalBallDowsing() || hasPumpkinDowsing() || hasNewPlantSpeciesDowsing() || hasKikwiDowsing() ||
hasKeyPieceDowsing() || hasDesertNodeDowsing() || hasPartyWheelDowsing();
} else if (StoryflagManager::sInstance->getCounterOrFlag(DOWSING_TARGET_STORY_FLAGS[slot])) {
// TODO small instruction shuffle
return true;
} else {
u16 flag = DOWSING_TARGET_STORY_FLAGS[slot];
flag = StoryflagManager::sInstance->getCounterOrFlag(flag);
if (flag != 0) {
return true;
}
}
return false;
@@ -199,22 +202,13 @@ void DowsingTarget::init() {}
void DowsingTarget::execute() {}
// Not sure what this is
inline static TListNode<DowsingTarget> *getNode(u8 slot, DowsingTarget *t) {
if (t->mLink.mpNext == nullptr || t->mLink.mpPrev == nullptr) {
return &DOWSING_LISTS[slot].mStartEnd;
} else {
return &t->mLink;
}
}
static bool insertDowsingTarget(DowsingTarget *target) {
u8 slot = target->getSlot();
if (slot == DowsingTarget::SLOT_NONE) {
return false;
}
if (getNode(slot, target) != &DOWSING_LISTS[slot].mStartEnd) {
if (DOWSING_LISTS[slot].GetPosition(target) != DOWSING_LISTS[slot].GetEndIter()) {
return false;
}
DOWSING_LISTS[slot].insert(target);
@@ -227,7 +221,7 @@ static bool removeDowsingTarget(DowsingTarget *target) {
return false;
}
if (getNode(slot, target) != &DOWSING_LISTS[slot].mStartEnd) {
if (DOWSING_LISTS[slot].GetPosition(target) != DOWSING_LISTS[slot].GetEndIter()) {
DOWSING_LISTS[slot].remove(target);
return true;
}