mirror of
https://github.com/zeldaret/botw
synced 2026-10-10 14:00:58 -04:00
PauseMenuDataMgr createPlayerEquipment
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <limits>
|
||||
#include <math/seadMathCalcCommon.h>
|
||||
#include <prim/seadScopedLock.h>
|
||||
#include "Game/Actor/actCreatePlayerEquipActorMgr.h"
|
||||
#include "Game/Actor/actWeapon.h"
|
||||
#include "Game/Cooking/cookManager.h"
|
||||
#include "Game/DLC/aocManager.h"
|
||||
@@ -1269,6 +1270,71 @@ int PauseMenuDataMgr::getItemCount(const sead::SafeString& name, bool count_equi
|
||||
return count;
|
||||
}
|
||||
|
||||
void PauseMenuDataMgr::createPlayerEquipment() {
|
||||
constexpr const char* Caller = "PauseMenuDataMgr_FromSaveData";
|
||||
const auto lock = sead::makeScopedLock(mCritSection);
|
||||
|
||||
auto* create_mgr = act::CreatePlayerEquipActorMgr::instance();
|
||||
if (!create_mgr) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::array<PouchItem*, (u64)act::CreateEquipmentSlot::Length> equipment_items{};
|
||||
|
||||
const auto& items = getItems();
|
||||
PouchItem* item = items.isEmpty() ? nullptr : items.nth(0);
|
||||
|
||||
bool need_head_b = false;
|
||||
if (item) {
|
||||
for (; item; item = items.next(item)) {
|
||||
auto type = item->getType();
|
||||
if (type > PouchItemType::Material) {
|
||||
break;
|
||||
}
|
||||
if (item->isInInventory() && item->isEquipped()) {
|
||||
u64 slot = (u64)act::getCreateEquipmentSlot(type);
|
||||
if (slot < equipment_items.size()) {
|
||||
equipment_items[slot] = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
const auto* head = equipment_items[(u64)act::CreateEquipmentSlot::ArmorHead];
|
||||
if (head && equipment_items[(u64)act::CreateEquipmentSlot::ArmorUpper]) {
|
||||
need_head_b = act::needsArmorHeadB(
|
||||
head->getName(),
|
||||
equipment_items[(u64)act::CreateEquipmentSlot::ArmorUpper]->getName());
|
||||
}
|
||||
}
|
||||
|
||||
auto* player = ksys::act::PlayerInfo::instance()->getPlayer();
|
||||
|
||||
s32 slot = 0; // <- this is required to match
|
||||
for (u64 i = 0; i != equipment_items.size(); slot = s32(++i)) {
|
||||
if (equipment_items[i]) {
|
||||
if (!need_head_b || i != (u64)act::CreateEquipmentSlot::ArmorHead) {
|
||||
act::createEquipmentFromItem(equipment_items[i], Caller);
|
||||
} else {
|
||||
create_mgr->requestCreateArmorHeadB(equipment_items[i]->getName(),
|
||||
equipment_items[i]->getValue(), Caller);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (i > (u64)act::CreateEquipmentSlot::WeaponBow) {
|
||||
create_mgr->requestCreateDefaultArmor(slot, Caller);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player) {
|
||||
auto equipment_slot = getEquipmentSlot((act::CreateEquipmentSlot)i);
|
||||
player->switchEquipment(getDefaultEquipment(equipment_slot), 30);
|
||||
}
|
||||
|
||||
#ifdef MATCHING_HACK_NX_CLANG
|
||||
asm(""); // force no unroll
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void PauseMenuDataMgr::setEquippedWeaponItemValue(s32 value, PouchItemType type) {
|
||||
if (isPouchItemNotWeapon(type))
|
||||
return;
|
||||
@@ -1294,7 +1360,7 @@ void PauseMenuDataMgr::setEquippedWeaponItemValue(s32 value, PouchItemType type)
|
||||
const sead::SafeString& PauseMenuDataMgr::getDefaultEquipment(EquipmentSlot idx) const {
|
||||
if (idx != EquipmentSlot::WeaponArrow &&
|
||||
u32(idx) < u32(sValues.default_equipment_names.size())) {
|
||||
return sValues.default_equipment_names(u32(idx));
|
||||
return sValues.default_equipment_names(s32(idx));
|
||||
}
|
||||
return sead::SafeString::cEmptyString;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user