mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-01-14 07:28:15 -05:00
Cleanup, bugfixes, removing the - 1
s from z_player.c
This commit is contained in:
parent
2077636c92
commit
69086f58c2
@ -2196,6 +2196,65 @@ bool Randomizer::IsItemVanilla(RandomizerGet randoGet) {
|
|||||||
case RG_PROGRESSIVE_GORONSWORD:
|
case RG_PROGRESSIVE_GORONSWORD:
|
||||||
case RG_EMPTY_BOTTLE:
|
case RG_EMPTY_BOTTLE:
|
||||||
case RG_BOTTLE_WITH_MILK:
|
case RG_BOTTLE_WITH_MILK:
|
||||||
|
case RG_RECOVERY_HEART:
|
||||||
|
case RG_GREEN_RUPEE:
|
||||||
|
case RG_BLUE_RUPEE:
|
||||||
|
case RG_RED_RUPEE:
|
||||||
|
case RG_PURPLE_RUPEE:
|
||||||
|
case RG_HUGE_RUPEE:
|
||||||
|
case RG_PIECE_OF_HEART:
|
||||||
|
case RG_HEART_CONTAINER:
|
||||||
|
case RG_MILK:
|
||||||
|
case RG_BOMBS_5:
|
||||||
|
case RG_BOMBS_10:
|
||||||
|
case RG_BOMBS_20:
|
||||||
|
case RG_BOMBCHU_5:
|
||||||
|
case RG_BOMBCHU_10:
|
||||||
|
case RG_BOMBCHU_20:
|
||||||
|
case RG_BOMBCHU_DROP:
|
||||||
|
case RG_ARROWS_5:
|
||||||
|
case RG_ARROWS_10:
|
||||||
|
case RG_ARROWS_30:
|
||||||
|
case RG_DEKU_NUTS_5:
|
||||||
|
case RG_DEKU_NUTS_10:
|
||||||
|
case RG_DEKU_SEEDS_30:
|
||||||
|
case RG_DEKU_STICK_1:
|
||||||
|
case RG_RED_POTION_REFILL:
|
||||||
|
case RG_GREEN_POTION_REFILL:
|
||||||
|
case RG_BLUE_POTION_REFILL:
|
||||||
|
case RG_TREASURE_GAME_HEART:
|
||||||
|
case RG_TREASURE_GAME_GREEN_RUPEE:
|
||||||
|
case RG_BUY_DEKU_NUT_5:
|
||||||
|
case RG_BUY_ARROWS_30:
|
||||||
|
case RG_BUY_ARROWS_50:
|
||||||
|
case RG_BUY_BOMBS_525:
|
||||||
|
case RG_BUY_DEKU_NUT_10:
|
||||||
|
case RG_BUY_DEKU_STICK_1:
|
||||||
|
case RG_BUY_BOMBS_10:
|
||||||
|
case RG_BUY_FISH:
|
||||||
|
case RG_BUY_RED_POTION_30:
|
||||||
|
case RG_BUY_GREEN_POTION:
|
||||||
|
case RG_BUY_BLUE_POTION:
|
||||||
|
case RG_BUY_HYLIAN_SHIELD:
|
||||||
|
case RG_BUY_DEKU_SHIELD:
|
||||||
|
case RG_BUY_GORON_TUNIC:
|
||||||
|
case RG_BUY_ZORA_TUNIC:
|
||||||
|
case RG_BUY_HEART:
|
||||||
|
case RG_BUY_BOMBCHU_10:
|
||||||
|
case RG_BUY_BOMBCHU_20:
|
||||||
|
case RG_BUY_BOMBCHU_5:
|
||||||
|
case RG_BUY_DEKU_SEEDS_30:
|
||||||
|
case RG_SOLD_OUT:
|
||||||
|
case RG_BUY_BLUE_FIRE:
|
||||||
|
case RG_BUY_BOTTLE_BUG:
|
||||||
|
case RG_BUY_POE:
|
||||||
|
case RG_BUY_FAIRYS_SPIRIT:
|
||||||
|
case RG_BUY_ARROWS_10:
|
||||||
|
case RG_BUY_BOMBS_20:
|
||||||
|
case RG_BUY_BOMBS_30:
|
||||||
|
case RG_BUY_BOMBS_535:
|
||||||
|
case RG_BUY_RED_POTION_40:
|
||||||
|
case RG_BUY_RED_POTION_50:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -4641,7 +4700,7 @@ void InitRandoItemTable() {
|
|||||||
// These do not have ItemIDs or GetItemIDs from vanilla, so I'm using their
|
// These do not have ItemIDs or GetItemIDs from vanilla, so I'm using their
|
||||||
// RandomizerGet enum values for both.
|
// RandomizerGet enum values for both.
|
||||||
GetItemEntry randoGetItemTable[] = {
|
GetItemEntry randoGetItemTable[] = {
|
||||||
GET_ITEM(RG_ICE_TRAP, OBJECT_GI_RUPY, GID_RUPEE_GOLD, 0, 0, CHEST_ANIM_SHORT),
|
GET_ITEM(RG_ICE_TRAP, OBJECT_GI_RUPY, GID_RUPEE_GOLD, 0, 0x80, CHEST_ANIM_SHORT),
|
||||||
GET_ITEM(RG_MAGIC_SINGLE, OBJECT_GI_MAGICPOT, GID_MAGIC_SMALL, 0xE4, 0x80, CHEST_ANIM_LONG),
|
GET_ITEM(RG_MAGIC_SINGLE, OBJECT_GI_MAGICPOT, GID_MAGIC_SMALL, 0xE4, 0x80, CHEST_ANIM_LONG),
|
||||||
GET_ITEM(RG_MAGIC_DOUBLE, OBJECT_GI_MAGICPOT, GID_MAGIC_LARGE, 0xE8, 0x80, CHEST_ANIM_LONG),
|
GET_ITEM(RG_MAGIC_DOUBLE, OBJECT_GI_MAGICPOT, GID_MAGIC_LARGE, 0xE8, 0x80, CHEST_ANIM_LONG),
|
||||||
GET_ITEM(RG_DOUBLE_DEFENSE, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xE9, 0x80, CHEST_ANIM_LONG),
|
GET_ITEM(RG_DOUBLE_DEFENSE, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xE9, 0x80, CHEST_ANIM_LONG),
|
||||||
|
@ -954,7 +954,8 @@ typedef enum {
|
|||||||
RG_BUY_RED_POTION_40,
|
RG_BUY_RED_POTION_40,
|
||||||
RG_BUY_RED_POTION_50,
|
RG_BUY_RED_POTION_50,
|
||||||
RG_TRIFORCE,
|
RG_TRIFORCE,
|
||||||
RG_HINT
|
RG_HINT,
|
||||||
|
RG_MAX
|
||||||
} RandomizerGet;
|
} RandomizerGet;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -288,7 +288,12 @@ extern "C" void VanillaItemTable_Init() {
|
|||||||
ItemTableManager::Instance->AddItemTable(MOD_NONE);
|
ItemTableManager::Instance->AddItemTable(MOD_NONE);
|
||||||
for (uint8_t i = 0; i < ARRAY_COUNT(getItemTable); i++) {
|
for (uint8_t i = 0; i < ARRAY_COUNT(getItemTable); i++) {
|
||||||
getItemTable[i].modIndex = MOD_NONE;
|
getItemTable[i].modIndex = MOD_NONE;
|
||||||
ItemTableManager::Instance->AddItemEntry(MOD_NONE, i, getItemTable[i]);
|
// The vanilla item table array started with ITEM_BOMBS_5,
|
||||||
|
// but the GetItemID enum started with GI_NONE. Then everywhere
|
||||||
|
// that table was accessed used `GetItemID - 1`. This allows the
|
||||||
|
// "first" item of the new map to start at 1, syncing it up with
|
||||||
|
// the GetItemID values and removing the need for the `- 1`
|
||||||
|
ItemTableManager::Instance->AddItemEntry(MOD_NONE, i+1, getItemTable[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1606,25 +1611,18 @@ extern "C" CustomMessageEntry Randomizer_GetHintFromCheck(RandomizerCheck check)
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" GetItemEntry ItemTable_Retrieve(int16_t getItemID) {
|
extern "C" GetItemEntry ItemTable_Retrieve(int16_t getItemID) {
|
||||||
if (OTRGlobals::Instance->getItemModIndex != MOD_NONE) {
|
|
||||||
getItemID++; // counteracts the - 1 offset used for vanilla table
|
|
||||||
}
|
|
||||||
|
|
||||||
return ItemTableManager::Instance->RetrieveItemEntry(OTRGlobals::Instance->getItemModIndex, getItemID);
|
return ItemTableManager::Instance->RetrieveItemEntry(OTRGlobals::Instance->getItemModIndex, getItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 tableID, s16 getItemID) {
|
extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 tableID, s16 getItemID) {
|
||||||
if (tableID == MOD_NONE) {
|
|
||||||
getItemID--; // counteracts the - 1 offset used for vanilla table
|
|
||||||
}
|
|
||||||
return ItemTableManager::Instance->RetrieveItemEntry(tableID, getItemID);
|
return ItemTableManager::Instance->RetrieveItemEntry(tableID, getItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" s32 Randomizer_GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum) {
|
extern "C" s32 Randomizer_GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum) {
|
||||||
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams))) {
|
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams))) {
|
||||||
OTRGlobals::Instance->getItemModIndex = MOD_RANDOMIZER;
|
|
||||||
} else {
|
|
||||||
OTRGlobals::Instance->getItemModIndex = MOD_NONE;
|
OTRGlobals::Instance->getItemModIndex = MOD_NONE;
|
||||||
|
} else {
|
||||||
|
OTRGlobals::Instance->getItemModIndex = MOD_RANDOMIZER;
|
||||||
}
|
}
|
||||||
return OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId, actorParams, sceneNum);
|
return OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId, actorParams, sceneNum);
|
||||||
}
|
}
|
||||||
@ -1633,9 +1631,9 @@ extern "C" GetItemEntry Randomizer_GetRandomizedItem(GetItemID ogId, s16 actorId
|
|||||||
s16 getItemModIndex;
|
s16 getItemModIndex;
|
||||||
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(
|
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(
|
||||||
OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams))) {
|
OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams))) {
|
||||||
getItemModIndex = MOD_RANDOMIZER;
|
|
||||||
} else {
|
|
||||||
getItemModIndex = MOD_NONE;
|
getItemModIndex = MOD_NONE;
|
||||||
|
} else {
|
||||||
|
getItemModIndex = MOD_RANDOMIZER;
|
||||||
}
|
}
|
||||||
s16 itemID = OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId, actorParams, sceneNum);
|
s16 itemID = OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId, actorParams, sceneNum);
|
||||||
return ItemTable_RetrieveEntry(getItemModIndex, itemID);
|
return ItemTable_RetrieveEntry(getItemModIndex, itemID);
|
||||||
@ -1643,9 +1641,9 @@ extern "C" GetItemEntry Randomizer_GetRandomizedItem(GetItemID ogId, s16 actorId
|
|||||||
|
|
||||||
extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId) {
|
extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId) {
|
||||||
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(randomizerCheck)) {
|
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(randomizerCheck)) {
|
||||||
OTRGlobals::Instance->getItemModIndex = MOD_RANDOMIZER;
|
|
||||||
} else {
|
|
||||||
OTRGlobals::Instance->getItemModIndex = MOD_NONE;
|
OTRGlobals::Instance->getItemModIndex = MOD_NONE;
|
||||||
|
} else {
|
||||||
|
OTRGlobals::Instance->getItemModIndex = MOD_RANDOMIZER;
|
||||||
}
|
}
|
||||||
return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId);
|
return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId);
|
||||||
}
|
}
|
||||||
@ -1653,9 +1651,9 @@ extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerChec
|
|||||||
extern "C" GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId) {
|
extern "C" GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId) {
|
||||||
s16 getItemModIndex;
|
s16 getItemModIndex;
|
||||||
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(randomizerCheck)) {
|
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(randomizerCheck)) {
|
||||||
getItemModIndex = MOD_RANDOMIZER;
|
|
||||||
} else {
|
|
||||||
getItemModIndex = MOD_NONE;
|
getItemModIndex = MOD_NONE;
|
||||||
|
} else {
|
||||||
|
getItemModIndex = MOD_RANDOMIZER;
|
||||||
}
|
}
|
||||||
s16 itemID = OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId);
|
s16 itemID = OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId);
|
||||||
return ItemTable_RetrieveEntry(getItemModIndex, itemID);
|
return ItemTable_RetrieveEntry(getItemModIndex, itemID);
|
||||||
|
@ -1977,8 +1977,8 @@ s32 func_8002F434(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzR
|
|||||||
Player* player = GET_PLAYER(globalCtx);
|
Player* player = GET_PLAYER(globalCtx);
|
||||||
|
|
||||||
if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) {
|
if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) {
|
||||||
if ((((player->heldActor != NULL) || (actor == player->targetActor)) && (getItemId > GI_NONE) &&
|
if ((((player->heldActor != NULL) || (actor == player->targetActor)) &&
|
||||||
(getItemId < GI_MAX)) ||
|
((!gSaveContext.n64ddFlag && ((getItemId > GI_NONE) && (getItemId < GI_MAX))) || (gSaveContext.n64ddFlag && ((getItemId > RG_NONE) && (getItemId < RG_MAX))))) ||
|
||||||
(!(player->stateFlags1 & 0x20000800))) {
|
(!(player->stateFlags1 & 0x20000800))) {
|
||||||
if ((actor->xzDistToPlayer < xzRange) && (fabsf(actor->yDistToPlayer) < yRange)) {
|
if ((actor->xzDistToPlayer < xzRange) && (fabsf(actor->yDistToPlayer) < yRange)) {
|
||||||
s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y;
|
s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y;
|
||||||
|
@ -1410,7 +1410,7 @@ s32 func_808332E4(Player* this) {
|
|||||||
void func_808332F4(Player* this, GlobalContext* globalCtx) {
|
void func_808332F4(Player* this, GlobalContext* globalCtx) {
|
||||||
GetItemEntry giEntry;
|
GetItemEntry giEntry;
|
||||||
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
||||||
giEntry = ItemTable_Retrieve(this->getItemId - 1);
|
giEntry = ItemTable_Retrieve(this->getItemId);
|
||||||
} else {
|
} else {
|
||||||
giEntry = this->getItemEntry;
|
giEntry = this->getItemEntry;
|
||||||
}
|
}
|
||||||
@ -4862,7 +4862,7 @@ s32 func_8083B040(Player* this, GlobalContext* globalCtx) {
|
|||||||
|
|
||||||
if (sp2C >= 0) {
|
if (sp2C >= 0) {
|
||||||
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
||||||
giEntry = ItemTable_Retrieve(D_80854528[sp2C] - 1);
|
giEntry = ItemTable_Retrieve(D_80854528[sp2C]);
|
||||||
} else {
|
} else {
|
||||||
giEntry = this->getItemEntry;
|
giEntry = this->getItemEntry;
|
||||||
}
|
}
|
||||||
@ -6100,10 +6100,10 @@ s32 func_8083E5A8(Player* this, GlobalContext* globalCtx) {
|
|||||||
this->getItemId = iREG(68);
|
this->getItemId = iREG(68);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->getItemId < GI_MAX) {
|
if (this->getItemId < GI_MAX || (gSaveContext.n64ddFlag && this->getItemId < RG_MAX)) {
|
||||||
GetItemEntry giEntry;
|
GetItemEntry giEntry;
|
||||||
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
||||||
giEntry = ItemTable_Retrieve(this->getItemId - 1);
|
giEntry = ItemTable_Retrieve(this->getItemId);
|
||||||
} else {
|
} else {
|
||||||
giEntry = this->getItemEntry;
|
giEntry = this->getItemEntry;
|
||||||
}
|
}
|
||||||
@ -6160,7 +6160,7 @@ s32 func_8083E5A8(Player* this, GlobalContext* globalCtx) {
|
|||||||
if (this->getItemId != GI_NONE) {
|
if (this->getItemId != GI_NONE) {
|
||||||
GetItemEntry giEntry;
|
GetItemEntry giEntry;
|
||||||
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
||||||
giEntry = ItemTable_Retrieve(-this->getItemId - 1);
|
giEntry = ItemTable_Retrieve(-this->getItemId);
|
||||||
} else {
|
} else {
|
||||||
giEntry = this->getItemEntry;
|
giEntry = this->getItemEntry;
|
||||||
}
|
}
|
||||||
@ -6173,7 +6173,7 @@ s32 func_8083E5A8(Player* this, GlobalContext* globalCtx) {
|
|||||||
if (((Item_CheckObtainability(giEntry.itemId) == ITEM_NONE) && (giEntry.field & 0x40)) ||
|
if (((Item_CheckObtainability(giEntry.itemId) == ITEM_NONE) && (giEntry.field & 0x40)) ||
|
||||||
((Item_CheckObtainability(giEntry.itemId) != ITEM_NONE) && (giEntry.field & 0x20))) {
|
((Item_CheckObtainability(giEntry.itemId) != ITEM_NONE) && (giEntry.field & 0x20))) {
|
||||||
this->getItemId = -GI_RUPEE_BLUE;
|
this->getItemId = -GI_RUPEE_BLUE;
|
||||||
giEntry = ItemTable_Retrieve(GI_RUPEE_BLUE - 1);
|
giEntry = ItemTable_Retrieve(GI_RUPEE_BLUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12546,7 +12546,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) {
|
|||||||
|
|
||||||
if (this->unk_84F == 0) {
|
if (this->unk_84F == 0) {
|
||||||
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
if (this->getItemEntry.objectId == OBJECT_INVALID) {
|
||||||
giEntry = ItemTable_Retrieve(this->getItemId - 1);
|
giEntry = ItemTable_Retrieve(this->getItemId);
|
||||||
} else {
|
} else {
|
||||||
giEntry = this->getItemEntry;
|
giEntry = this->getItemEntry;
|
||||||
}
|
}
|
||||||
@ -13192,7 +13192,7 @@ void func_8084F104(Player* this, GlobalContext* globalCtx) {
|
|||||||
func_80853148(globalCtx, targetActor);
|
func_80853148(globalCtx, targetActor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GetItemEntry giEntry = ItemTable_Retrieve(D_80854528[this->exchangeItemId - 1] - 1);
|
GetItemEntry giEntry = ItemTable_Retrieve(D_80854528[this->exchangeItemId - 1]);
|
||||||
|
|
||||||
if (this->itemActionParam >= PLAYER_AP_LETTER_ZELDA) {
|
if (this->itemActionParam >= PLAYER_AP_LETTER_ZELDA) {
|
||||||
if (giEntry.gi >= 0) {
|
if (giEntry.gi >= 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user