Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlayerInfo stuff that doesn't require PlayerBase #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/data_symbols.csv
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
0x00000071024D8D58,_ZTVN4ksys3act2ai10ActionBaseE
0x00000071025129E0,_ZTVN4ksys3act2ai6ActionE
0x0000007102513268,_ZTVN4ksys3act2ai2AiE
0x00000071025CDB60,_ZN4ksys3act10PlayerInfo9sInstanceE
0x00000071025F75B0,pfnc_nvnDeviceBuilderSetDefaults
0x00000071025F75B8,pfnc_nvnDeviceBuilderSetFlags
0x00000071025F75C0,pfnc_nvnDeviceInitialize
Expand Down
124 changes: 62 additions & 62 deletions data/uking_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -51629,7 +51629,7 @@ Address,Quality,Size,Name
0x000000710084b62c,U,000084,Player::setItemVel
0x000000710084b680,U,000084,Player::setItemSwimVel
0x000000710084b6d4,U,000084,
0x000000710084b728,U,000080,Player::addExtraLife
0x000000710084b728,U,000080,Player::setExtraLife
0x000000710084b778,U,000072,Player::addExtraStamina
0x000000710084b7c0,U,000080,
0x000000710084b810,U,000080,
Expand Down Expand Up @@ -52122,32 +52122,32 @@ Address,Quality,Size,Name
0x00000071008525f8,U,000092,
0x0000007100852654,U,000072,
0x000000710085269c,U,000372,
0x0000007100852810,U,000048,PlayerInfo::S1::ctor
0x0000007100852840,U,000004,j_nullsub_2594
0x0000007100852844,U,000036,
0x0000007100852868,U,000020,PlayerInfo::S0::ctor
0x000000710085287c,U,000004,nullsub_2594
0x0000007100852880,U,000004,j__ZdlPv_369
0x0000007100852884,U,000048,PlayerInfo::S2::ctor
0x00000071008528b4,U,000004,j_nullsub_2594_0
0x00000071008528b8,U,000036,
0x0000007100852810,O,000048,_ZN4ksys3act10PlayerInfo5Info1C1Ev
0x0000007100852840,O,000004,_ZN4ksys3act10PlayerInfo5Info1D2Ev
0x0000007100852844,O,000036,_ZN4ksys3act10PlayerInfo5Info1D0Ev
0x0000007100852868,O,000020,_ZN4ksys3act14PlayerInfoBaseC1Ev
0x000000710085287c,O,000004,_ZN4ksys3act14PlayerInfoBaseD2Ev
0x0000007100852880,O,000004,_ZN4ksys3act14PlayerInfoBaseD0Ev
0x0000007100852884,O,000048,_ZN4ksys3act10PlayerInfo5Info2C1Ev
0x00000071008528b4,O,000004,_ZN4ksys3act10PlayerInfo5Info2D2Ev
0x00000071008528b8,O,000036,_ZN4ksys3act10PlayerInfo5Info2D0Ev
0x00000071008528dc,U,000004,nullsub_2595
0x00000071008528e0,U,000048,PlayerInfo::S3::ctor
0x0000007100852910,U,000004,j_nullsub_2594_1
0x0000007100852914,U,000036,
0x0000007100852938,U,000048,PlayerInfo::S4::ctor
0x0000007100852968,U,000004,j_nullsub_2594_2
0x000000710085296c,U,000036,
0x0000007100852990,U,000048,PlayerInfo::S5::ctor
0x00000071008529c0,U,000004,j_nullsub_2594_3
0x00000071008529c4,U,000036,
0x00000071008528e0,O,000048,_ZN4ksys3act10PlayerInfo5Info3C1Ev
0x0000007100852910,O,000004,_ZN4ksys3act10PlayerInfo5Info3D2Ev
0x0000007100852914,O,000036,_ZN4ksys3act10PlayerInfo5Info3D0Ev
0x0000007100852938,O,000048,_ZN4ksys3act10PlayerInfo5Info4C1Ev
0x0000007100852968,O,000004,_ZN4ksys3act10PlayerInfo5Info4D2Ev
0x000000710085296c,O,000036,_ZN4ksys3act10PlayerInfo5Info4D0Ev
0x0000007100852990,O,000048,_ZN4ksys3act10PlayerInfo5Info5C1Ev
0x00000071008529c0,O,000004,_ZN4ksys3act10PlayerInfo5Info5D2Ev
0x00000071008529c4,O,000036,_ZN4ksys3act10PlayerInfo5Info5D0Ev
0x00000071008529e8,U,000008,return1_0
0x00000071008529f0,U,000048,PlayerInfo::S6::ctor
0x0000007100852a20,U,000004,j_nullsub_2594_4
0x0000007100852a24,U,000036,
0x0000007100852a48,U,000048,PlayerInfo::S7::ctor
0x0000007100852a78,U,000004,j_nullsub_2594_5
0x0000007100852a7c,U,000036,
0x00000071008529f0,O,000048,_ZN4ksys3act10PlayerInfo5Info6C1Ev
0x0000007100852a20,O,000004,_ZN4ksys3act10PlayerInfo5Info6D2Ev
0x0000007100852a24,O,000036,_ZN4ksys3act10PlayerInfo5Info6D0Ev
0x0000007100852a48,O,000048,_ZN4ksys3act10PlayerInfo5Info7C1Ev
0x0000007100852a78,O,000004,_ZN4ksys3act10PlayerInfo5Info7D2Ev
0x0000007100852a7c,O,000036,_ZN4ksys3act10PlayerInfo5Info7D0Ev
0x0000007100852aa0,U,000240,Player::RideInfo::ctor
0x0000007100852b90,U,000152,Player::RideInfo::init
0x0000007100852c28,U,000044,Player::RideInfo::x_0
Expand All @@ -52164,46 +52164,46 @@ Address,Quality,Size,Name
0x0000007100854028,U,000036,
0x000000710085404c,U,000288,
0x000000710085416c,U,000092,
0x00000071008541c8,U,000100,
0x000000710085422c,U,000108,
0x0000007100854298,U,000136,PlayerInfo::createInstance
0x0000007100854320,U,000192,PlayerInfo::ctor
0x00000071008543e0,U,000124,PlayerInfo::dtor
0x000000710085445c,U,000132,PlayerInfo::dtorDelete
0x00000071008544e0,U,000008,PlayerInfo::init
0x00000071008541c8,O,000100,_ZN4ksys3act10PlayerInfo18SingletonDisposer_D1Ev
0x000000710085422c,O,000108,_ZN4ksys3act10PlayerInfo18SingletonDisposer_D0Ev
0x0000007100854298,O,000136,_ZN4ksys3act10PlayerInfo14createInstanceEPN4sead4HeapE
0x0000007100854320,O,000192,_ZN4ksys3act10PlayerInfoC1Ev
0x00000071008543e0,O,000124,_ZN4ksys3act10PlayerInfoD1Ev
0x000000710085445c,O,000132,_ZN4ksys3act10PlayerInfoD0Ev
0x00000071008544e0,O,000008,_ZN4ksys3act10PlayerInfo4initEv
0x00000071008544e8,U,000084,PlayerInfo::setPlayerActor
0x000000710085453c,U,000028,PlayerInfo::resetActor
0x0000007100854558,U,000012,
0x0000007100854564,U,000008,PlayerInfo::__auto2
0x000000710085456c,U,000068,PlayerInfo::getActor
0x00000071008545b0,U,000068,PlayerInfo::getActor_0
0x000000710085453c,O,000028,_ZN4ksys3act10PlayerInfo11resetPlayerEPNS0_10PlayerBaseE
0x0000007100854558,O,000012,_ZN4ksys3act10PlayerInfo12acquireHorseEPNS0_8BaseProcE
0x0000007100854564,O,000008,_ZN4ksys3act10PlayerInfo12setHorseLinkERKNS0_12BaseProcLinkE
0x000000710085456c,O,000068,_ZNK4ksys3act10PlayerInfo9getPlayerEv
0x00000071008545b0,O,000068,_ZNK4ksys3act10PlayerInfo10getPlayer_Ev
0x00000071008545f4,U,000212,PlayerInfo::getRiddenHorse
0x00000071008546c8,U,000016,PlayerInfo::setPlayerActorMaxHeartValue
0x00000071008546d8,U,000024,PlayerInfo::getMaxLife
0x00000071008546f0,U,000052,PlayerInfo::setMaxHeartValue
0x0000007100854724,U,000012,PlayerInfo::getMaxHeartValue
0x0000007100854730,U,000044,PlayerInfo::updateMaxHeartValue
0x000000710085475c,U,000052,PlayerInfo::setLife
0x0000007100854790,U,000052,PlayerInfo::getLife
0x00000071008547c4,U,000164,PlayerInfo::updateCurrentHartFlagFromPlayer
0x00000071008546c8,U,000016,PlayerInfo::setMaxLifeForPlayerActor
0x00000071008546d8,O,000024,_ZNK4ksys3act10PlayerInfo25getMaxLifeFromPlayerActorEv
0x00000071008546f0,O,000052,_ZN4ksys3act10PlayerInfo16setMaxHeartValueEi
0x0000007100854724,O,000012,_ZNK4ksys3act10PlayerInfo16getMaxHeartValueEv
0x0000007100854730,O,000044,_ZN4ksys3act10PlayerInfo31updateMaxHeartValueFromGameDataEv
0x000000710085475c,O,000052,_ZN4ksys3act10PlayerInfo21setLifeForPlayerActorEi
0x0000007100854790,O,000052,_ZNK4ksys3act10PlayerInfo22getLifeFromPlayerActorEv
0x00000071008547c4,U,000164,PlayerInfo::updateCurrentHartFlagFromPlayerActor
0x0000007100854868,U,000100,PlayerInfo::updateLifeAfterGameOver
0x00000071008548cc,U,000168,PlayerInfo::resetPlayerPullSwordStartLife
0x0000007100854974,U,000096,PlayerInfo::saveLifeInfoForPlayerPullSword
0x00000071008549d4,U,000076,
0x0000007100854a20,U,000052,PlayerInfo::setStamina
0x0000007100854a54,U,000008,PlayerInfo::getStaminaCurrentMax_0
0x0000007100854a5c,U,000040,PlayerInfo::updateStaminaCurrentMax
0x0000007100854a84,U,000052,PlayerInfo::setStaminaMax
0x0000007100854ab8,U,000008,PlayerInfo::getStaminaMax
0x0000007100854ac0,U,000040,PlayerInfo::updateStaminaMax
0x0000007100854ae8,U,000016,PlayerInfo::x_1
0x0000007100854af8,U,000024,PlayerInfo::getMaxStamina
0x0000007100854b10,U,000072,PlayerInfo::recoverEnergy
0x0000007100854b58,U,000072,PlayerInfo::recoverPlayerCondition
0x0000007100854ba0,U,000008,PlayerInfo::getActorWithoutAnyChecks
0x0000007100854ba8,U,000120,PlayerInfo::getPlayerPos
0x0000007100854c20,U,000120,PlayerInfo::getPlayerPosForPostCalc
0x0000007100854c98,U,000048,
0x00000071008548cc,U,000168,PlayerInfo::resetLifeToBeforeSwordPull
0x0000007100854974,U,000096,PlayerInfo::saveLifeInfoForSwordPull
0x00000071008549d4,O,000076,_ZN4ksys3act10PlayerInfo11recoverLifeEv
0x0000007100854a20,O,000052,_ZN4ksys3act10PlayerInfo20setStaminaCurrentMaxEf
0x0000007100854a54,O,000008,_ZNK4ksys3act10PlayerInfo20getStaminaCurrentMaxEv
0x0000007100854a5c,O,000040,_ZN4ksys3act10PlayerInfo35updateStaminaCurrentMaxFromGameDataEv
0x0000007100854a84,O,000052,_ZN4ksys3act10PlayerInfo13setStaminaMaxEf
0x0000007100854ab8,O,000008,_ZNK4ksys3act10PlayerInfo13getStaminaMaxEv
0x0000007100854ac0,O,000040,_ZN4ksys3act10PlayerInfo28updateStaminaMaxFromGameDataEv
0x0000007100854ae8,U,000016,PlayerInfo::setStaminaMax
0x0000007100854af8,U,000024,PlayerInfo::getStaminaMax
0x0000007100854b10,U,000072,PlayerInfo::recoverStamina
0x0000007100854b58,U,000072,PlayerInfo::recoverCondition
0x0000007100854ba0,O,000008,_ZN4ksys3act10PlayerInfo18getPlayerUncheckedEv
0x0000007100854ba8,O,000120,_ZN4ksys3act10PlayerInfo12getPlayerPosEv
0x0000007100854c20,O,000120,_ZN4ksys3act10PlayerInfo23getPlayerPosForPostCalcEv
0x0000007100854c98,U,000048,PlayerInfo::getPlayerM265
0x0000007100854cc8,U,001052,Player::x_43
0x00000071008550e4,U,000280,
0x00000071008551fc,U,000292,Player::x_25
Expand Down
2 changes: 1 addition & 1 deletion src/Game/AI/Query/queryComparePlayerHeart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int ComparePlayerHeart::doQuery() {
if (pi == nullptr)
return 0;

return pi->getLife() >= *mThreshold;
return pi->getLifeFromPlayerActor() >= *mThreshold;
}

void ComparePlayerHeart::loadParams(const evfl::QueryArg& arg) {
Expand Down
2 changes: 1 addition & 1 deletion src/Game/AI/Query/queryComparePlayerMaxHeart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int ComparePlayerMaxHeart::doQuery() {
if (pi == nullptr)
return 0;

s32 full_hearts = pi->getMaxHearts() / 4;
s32 full_hearts = pi->getMaxHeartValue() / 4;
return full_hearts >= *mThreshold;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Game/AI/Query/queryComparePlayerMaxStamina.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int ComparePlayerMaxStamina::doQuery() {
if (pi == nullptr)
return 0;

s32 stamina = pi->getMaxStamina();
s32 stamina = pi->getStaminaMax();
if (stamina % 200 <= 0)
return stamina / 200 >= *mThreshold;
else
Expand Down
4 changes: 2 additions & 2 deletions src/Game/AI/Query/queryComparePlayerOriginalHeart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ int ComparePlayerOriginalHeart::doQuery() {
if (PlayerInfo::instance() == nullptr)
return 0;

s32 life = PlayerInfo::instance()->getLife();
s32 hearts = PlayerInfo::instance()->getMaxHearts();
s32 life = PlayerInfo::instance()->getLifeFromPlayerActor();
s32 hearts = PlayerInfo::instance()->getMaxHeartValue();
s32 compare;
if (life <= hearts)
compare = life;
Expand Down
2 changes: 2 additions & 0 deletions src/KingSystem/ActorSystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ target_sources(uking PRIVATE
actPhysicsUserTag.h
actPlayerInfo.cpp
actPlayerInfo.h
actPlayerInfoBase.cpp
actPlayerInfoStub.cpp
actTag.h

actionDummyAction.cpp
Expand Down
6 changes: 5 additions & 1 deletion src/KingSystem/ActorSystem/Profiles/actPlayerBase.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#pragma once

#include <prim/seadSafeString.h>
#include "KingSystem/ActorSystem/actActor.h"

namespace ksys::act {

// TODO
class PlayerBase {
class PlayerBase : public Actor {
public:
// FIXME: name for x and name+type for y
void switchEquipment(const sead::SafeString& slot, int frames, int x = -1,
const uintptr_t& y = {});

// FIXME: name for x
void setExtraLife(s32 extra_life, f32 x);
};

} // namespace ksys::act
133 changes: 133 additions & 0 deletions src/KingSystem/ActorSystem/actPlayerInfo.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,134 @@
#include "KingSystem/ActorSystem/actPlayerInfo.h"
#include "KingSystem/ActorSystem/Profiles/actPlayerBase.h"
#include "KingSystem/ActorSystem/actActorConstDataAccess.h"
#include "KingSystem/ActorSystem/actActorLinkConstDataAccess.h"
#include "KingSystem/ActorSystem/actBaseProc.h"
#include "KingSystem/ActorSystem/actBaseProcMgr.h"
#include "KingSystem/GameData/gdtCommonFlagsUtils.h"
#include "KingSystem/ksys.h"

namespace ksys::act {

SEAD_SINGLETON_DISPOSER_IMPL(PlayerInfo)

PlayerInfo::PlayerInfo() = default;
PlayerInfo::~PlayerInfo() = default;

bool PlayerInfo::init() {
return true;
}

void PlayerInfo::resetPlayer(PlayerBase* player) {
if (mPlayerActor == player) {
mPlayerActor = nullptr;
ksys::setPlayerLink(nullptr);
}
}

bool PlayerInfo::acquireHorse(BaseProc* horse) {
return mHorseLink.acquire(horse, false);
}

void PlayerInfo::setHorseLink(const BaseProcLink& horse_link) {
mHorseLink = horse_link;
}

PlayerBase* PlayerInfo::getPlayer() const {
if (!mPlayerActor) {
return nullptr;
}
BaseProcMgr::instance()->isAccessingProcSafe(mPlayerActor, nullptr);
return mPlayerActor;
}

PlayerBase* PlayerInfo::getPlayer_() const {
if (!mPlayerActor) {
return nullptr;
}
BaseProcMgr::instance()->isAccessingProcSafe(mPlayerActor, nullptr);
return mPlayerActor;
}

s32 PlayerInfo::getMaxLifeFromPlayerActor() const {
return mPlayerActor ? mPlayerActor->getMaxLife() : 0;
}

void PlayerInfo::setMaxHeartValue(s32 quarter_hearts) {
gdt::setFlag_MaxHartValue(quarter_hearts);
mMaxHeartValue = static_cast<f32>(quarter_hearts);
}

u32 PlayerInfo::getMaxHeartValue() const {
// Return type is unsigned, but the conversion is signed
return static_cast<s32>(mMaxHeartValue);
}

void PlayerInfo::updateMaxHeartValueFromGameData() {
mMaxHeartValue = static_cast<f32>(gdt::getFlag_MaxHartValue());
}

void PlayerInfo::setLifeForPlayerActor(s32 life) {
if (mPlayerActor) {
*mPlayerActor->getLife() = life;
}
}

s32 PlayerInfo::getLifeFromPlayerActor() const {
if (!mPlayerActor) {
return 0;
}
auto* life = mPlayerActor->getLife();
return life ? *life : 1;
}

void PlayerInfo::recoverLife() {
setLifeForPlayerActor(getMaxLifeFromPlayerActor());
}

void PlayerInfo::setStaminaCurrentMax(f32 max_stamina) {
gdt::setFlag_StaminaCurrentMax(max_stamina);
mStaminaCurrentMax = max_stamina;
}

f32 PlayerInfo::getStaminaCurrentMax() const {
return mStaminaCurrentMax;
}

void PlayerInfo::updateStaminaCurrentMaxFromGameData() {
mStaminaCurrentMax = gdt::getFlag_StaminaCurrentMax();
}

void PlayerInfo::setStaminaMax(f32 max_stamina) {
gdt::setFlag_StaminaMax(max_stamina);
mStaminaMax = max_stamina;
}

f32 PlayerInfo::getStaminaMax() const {
return mStaminaMax;
}

void PlayerInfo::updateStaminaMaxFromGameData() {
mStaminaMax = gdt::getFlag_StaminaMax();
}

PlayerBase* PlayerInfo::getPlayerUnchecked() {
return mPlayerActor;
}

sead::Vector3f& PlayerInfo::getPlayerPos() {
ActorConstDataAccess accessor;

acquireActor(&mPlayerLink, &accessor);
accessor.debugLog(1, "getPlayerPos");
return mPlayerPos;
}

sead::Vector3f& PlayerInfo::getPlayerPosForPostCalc() {
ActorConstDataAccess accessor;

acquireActor(&mPlayerLink, &accessor);
accessor.debugLog(0, "getPlayerPosForPostCalc");
return mPlayerPosForPostCalc;
}

} // namespace ksys::act
Loading
Loading