This commit is contained in:
Jack Andersen 2016-06-30 16:33:34 -10:00
commit 8e43027b1d
7 changed files with 51 additions and 12 deletions

View File

@ -41,7 +41,7 @@ target_link_libraries(urde
DNACommon specter specter-fonts freetype ${DATA_SPEC_LIBS}
hecl-database hecl-runtime hecl-backend hecl-frontend hecl-hmdl hecl-blender hecl-common
athena-core nod logvisor athena-libyaml amuse boo ${PNG_LIB} libjpeg-turbo squish xxhash zeus
${ZLIB_LIBRARIES} ${LZO_LIB}
kabufuda ${ZLIB_LIBRARIES} ${LZO_LIB}
${BOO_SYS_LIBS})
set_target_properties(urde PROPERTIES

View File

@ -6,8 +6,23 @@ namespace urde
{
CGameState::CGameState(CBitStreamReader& stream)
: m_stateFlag(stream.readUint32Big()), m_playerState(stream), m_gameTime(stream.readFloatBig())
{}
{
for (u32 i = 0; i < 128; i++)
stream.ReadEncoded(8);
u32 tmp = stream.ReadEncoded(32);
double val1 = *(reinterpret_cast<float*>(&tmp));
bool val2 = stream.ReadEncoded(1);
stream.ReadEncoded(1);
tmp = stream.ReadEncoded(32);
double val3 = *(reinterpret_cast<float*>(&tmp));
tmp = stream.ReadEncoded(32);
double val4 = *(reinterpret_cast<float*>(&tmp));
tmp = stream.ReadEncoded(32);
double val5 = *(reinterpret_cast<float*>(&tmp));
CPlayerState tmpPlayer(stream);
float currentHealth = tmpPlayer.GetHealthInfo().GetHP();
}
void CGameState::SetCurrentWorldId(unsigned int id, const std::string& name)
{

View File

@ -13,7 +13,7 @@ namespace urde
class CGameState
{
int m_stateFlag = -1;
CPlayerState m_playerState;
CPlayerState x98_playerState;
CWorldTransManager x9c_transManager;
float m_gameTime = 0.0;
CGameOptions m_gameOpts;

View File

@ -59,7 +59,7 @@ CPlayerState::CPlayerState(CBitStreamReader& stream)
{
x4_ = stream.ReadEncoded(0x20);
u32 tmp = stream.ReadEncoded(0x20);
xc_currentHealth = *reinterpret_cast<float*>(&tmp);
xc_health.SetHP(*reinterpret_cast<float*>(&tmp));
x8_currentBeam = EBeamId(stream.ReadEncoded(CBitStreamReader::GetBitCount(5)));
x20_currentSuit = EPlayerSuit(stream.ReadEncoded(CBitStreamReader::GetBitCount(4)));
x24_powerups.resize(41);
@ -90,8 +90,8 @@ CPlayerState::CPlayerState(CBitStreamReader& stream)
void CPlayerState::PutTo(CBitStreamWriter &stream)
{
stream.WriteEncoded(x4_, 32);
u32 tmp = *reinterpret_cast<int*>(&xc_currentHealth);
stream.WriteEncoded(tmp, 32);
float hp = xc_health.GetHP();
stream.WriteEncoded(*reinterpret_cast<int*>(&hp), 32);
stream.WriteEncoded((u32)x8_currentBeam, CBitStreamWriter::GetBitCount(5));
stream.WriteEncoded((u32)x20_currentSuit, CBitStreamWriter::GetBitCount(4));
for (u32 i = 0; i < x24_powerups.size(); ++i)
@ -175,6 +175,16 @@ u32 CPlayerState::CalculateItemCollectionRate() const
return total + GetItemCapacity(EItemType::Wavebuster);
}
CHealthInfo& CPlayerState::HealthInfo()
{
return xc_health;
}
CHealthInfo CPlayerState::GetHealthInfo() const
{
return xc_health;
}
CPlayerState::EPlayerSuit CPlayerState::GetCurrentSuit() const
{
if (GetFusion())
@ -335,7 +345,7 @@ void CPlayerState::IncrPickup(EItemType type, s32 amount)
case EItemType::HealthRefill:
{
float health = CalculateHealth(amount);
xc_currentHealth = std::min(health, xc_currentHealth + amount);
xc_health.SetHP(std::min(health, xc_health.GetHP() + amount));
}
default:
break;

View File

@ -6,6 +6,7 @@
#include "CStaticInterference.hpp"
#include "IOStreams.hpp"
#include "rstl.hpp"
#include "World/CHealthInfo.hpp"
namespace urde
{
@ -111,8 +112,7 @@ private:
u32 x4_ = 0;
EBeamId x8_currentBeam = EBeamId::Power;
float xc_currentHealth = 99.f;
float x10_ = 50.f;
CHealthInfo xc_health = {99.f, 50.f};
EPlayerVisor x14_currentVisor = EPlayerVisor::Combat;
EPlayerVisor x18_transitioningVisor = x14_currentVisor;
float x1c_visorTransitionFactor = 0.2f;
@ -128,6 +128,8 @@ public:
u32 GetMissileCostForAltAttack() const;
u32 CalculateItemCollectionRate() const;
CHealthInfo& HealthInfo();
CHealthInfo GetHealthInfo() const;
u32 GetPickupTotal() { return 99; }
void SetFusion(bool val) { x0_26_fusion = val; }
bool GetFusion() const { return x0_26_fusion; }

View File

@ -11,8 +11,20 @@ class CHealthInfo
float x0_health;
float x4_knockbackResistance;
public:
CHealthInfo(float hp)
: x0_health(hp),
x4_knockbackResistance(0.f)
{
}
CHealthInfo(float hp, float resist)
: x0_health(hp),
x4_knockbackResistance(resist)
{}
CHealthInfo(CInputStream& in);
float GetHealth() const {return x0_health;}
void SetHP(float hp) { x0_health = hp; }
float GetHP() const {return x0_health;}
float GetKnockbackResistance() const {return x4_knockbackResistance;}
};

View File

@ -35,7 +35,7 @@ int main(int argc, char* argv[])
if (in.length() != 8256)
{
printf("File too small expected 8,256 bytes got %llu", in.length());
printf("File too small expected 8,256 bytes got %" PRIu64, in.length());
return 1;
}