simplify chest and freestanding item lookups

This commit is contained in:
gymnast86
2026-04-30 19:19:42 -07:00
parent 622920d8c0
commit d4bc2daa89
7 changed files with 334 additions and 342 deletions
+4 -3
View File
@@ -321,12 +321,13 @@ int daItem_c::_daItem_create() {
u32 params = fopAcM_GetParam(this);
u8 flag = daItem_prm::getItemBitNo(this);
u8 stageIdx = getStageID();
const auto& freestandingOverrides = randomizer_GetContext().mFreestandingItemOverrides;
u16 key = (stageIdx << 8) | flag;
auto& freestandingOverrides = randomizer_GetContext().mFreestandingItemOverrides;
// If we found an override for this freestanding item
if (freestandingOverrides.contains(stageIdx) && freestandingOverrides.at(stageIdx).contains(flag)) {
if (freestandingOverrides.contains(key)) {
// Clear the itemId and set it to out new itemId
params &= 0xFFFFFF00;
u8 newItemId = freestandingOverrides.at(stageIdx).at(flag);
u8 newItemId = freestandingOverrides[key];
params |= verifyProgressiveItem(newItemId);
fopAcM_SetParam(this, params);
}
+3 -2
View File
@@ -212,11 +212,12 @@ int daObjLife_c::create() {
} else {
u8 flag = getSaveBitNo();
u8 stageIdx = getStageID();
u16 key = (stageIdx << 8) | flag;
const auto& freestandingOverrides = randomizer_GetContext().mFreestandingItemOverrides;
// If we found an override for this freestanding item
if (freestandingOverrides.contains(stageIdx) && freestandingOverrides.at(stageIdx).contains(flag)) {
if (freestandingOverrides.contains(key)) {
// Clear the itemId and set it to out new itemId
u8 overrideItem = freestandingOverrides.at(stageIdx).at(flag);
u8 overrideItem = freestandingOverrides.at(key);
itemId = verifyProgressiveItem(overrideItem);
}
}
+8 -3
View File
@@ -12,7 +12,10 @@
#include <cmath>
#include <cstring>
#if TARGET_PC
#include "dusk/randomizer/game/tools.h"
#include "dusk/randomizer/game/verify_item_functions.h"
#endif
static const f32 l_cull_size_box[6] = { -150.0f, -10.0f, -150.0f, 150.0f, 300.0f, 100.0f };
@@ -1788,12 +1791,14 @@ cPhs_Step daTbox_c::create1st() {
if (!mParamsInit) {
field_0x980 = home.angle.x;
#if TARGET_PC
// The upper 8 bits of home.angle.z hold the itemId
// The upper 8 bits of home.angle.z hold the itemId. Replace with our randomized
// item in randomizer
if (randomizer_IsActive()) {
home.angle.z &= ~0xFF00;
auto stage = dComIfGp_getStartStageName();
auto stage = getStageID();
auto tboxId = static_cast<u8>(getTboxNo());
u8 itemId = randomizer_GetContext().mTreasureChestOverrides[stage][tboxId];
u16 key = (stage << 8) | tboxId;
u8 itemId = randomizer_GetContext().mTreasureChestOverrides[key];
home.angle.z |= verifyProgressiveItem(itemId) << 8;
}
#endif
+6 -2
View File
@@ -10,7 +10,10 @@
#include "d/actor/d_a_midna.h"
#include <cstring>
#if TARGET_PC
#include "dusk/randomizer/game/tools.h"
#include "dusk/randomizer/game/verify_item_functions.h"
#endif
void daTbox2_c::initBaseMtx() {
mpModel->setBaseScale(scale);
@@ -161,9 +164,10 @@ int daTbox2_c::create1st() {
#if TARGET_PC
if (randomizer_IsActive()) {
// Get the override item for this chest
auto stage = dComIfGp_getStartStageName();
auto stage = getStageID();
u8 tboxId = getTboxNo();
u8 itemId = randomizer_GetContext().mTreasureChestOverrides[stage][tboxId];
u16 key = (stage << 8) | tboxId;
u8 itemId = randomizer_GetContext().mTreasureChestOverrides[key];
// Set the item in the params
u32 params = fopAcM_GetParam(this);
params &= 0xFFFFFF00;