Fix CPASAnimState::FindBestAnimation derp

This commit is contained in:
Phillip Stephens 2016-08-22 17:52:51 -07:00
parent bf049843e1
commit 09bd30846f
4 changed files with 20 additions and 10 deletions

View File

@ -33,7 +33,7 @@ CGameState::CGameState(CBitStreamReader& stream)
float currentHealth = tmpPlayer.GetHealthInfo().GetHP(); float currentHealth = tmpPlayer.GetHealthInfo().GetHP();
} }
void CGameState::SetCurrentWorldId(unsigned int id, const std::string& name) void CGameState::SetCurrentWorldId(unsigned int id)
{ {
} }

View File

@ -5,8 +5,9 @@
#include "CBasics.hpp" #include "CBasics.hpp"
#include "CPlayerState.hpp" #include "CPlayerState.hpp"
#include "CGameOptions.hpp" #include "CGameOptions.hpp"
#include "CRelayTracker.hpp"
#include "World/CWorldTransManager.hpp" #include "World/CWorldTransManager.hpp"
#include "AutoMapper/CMapWorldInfo.hpp"
namespace urde namespace urde
{ {
@ -14,10 +15,16 @@ class CWorldState
{ {
ResId x0_mlvlId; ResId x0_mlvlId;
TAreaId x4_areaId; TAreaId x4_areaId;
std::shared_ptr<CRelayTracker> x8_relayTracker;
std::shared_ptr<CMapWorldInfo> xc_mapWorldInfo;
/* std::shared_ptr<> x14_ */
public: public:
CWorldState(ResId id) : x0_mlvlId(id) {} CWorldState(ResId id) : x0_mlvlId(id) {}
ResId GetWorldAssetId() const {return x0_mlvlId;} ResId GetWorldAssetId() const {return x0_mlvlId;}
void SetAreaId(TAreaId aid) { x4_areaId = aid; } void SetAreaId(TAreaId aid) { x4_areaId = aid; }
const TAreaId& GetCurrentAreaId() const { return x4_areaId; }
std::shared_ptr<CRelayTracker> RelayTracker() { return x8_relayTracker; }
std::shared_ptr<CMapWorldInfo> MapWorldInfo() { return xc_mapWorldInfo; }
}; };
class CGameState class CGameState
@ -25,14 +32,16 @@ class CGameState
friend class CStateManager; friend class CStateManager;
bool x0_[128] = {}; bool x0_[128] = {};
int m_stateFlag = -1;
ResId x84_mlvlId = -1; ResId x84_mlvlId = -1;
std::vector<CWorldState> x88_worldStates; std::vector<CWorldState> x88_worldStates;
std::shared_ptr<CPlayerState> x98_playerState; std::shared_ptr<CPlayerState> x98_playerState;
std::shared_ptr<CWorldTransManager> x9c_transManager; std::shared_ptr<CWorldTransManager> x9c_transManager;
float m_gameTime = 0.0;
CGameOptions m_gameOpts; CGameOptions m_gameOpts;
double xa0_playTime; double xa0_playTime;
u32 xa4_;
/* x17c_ */
/* x1f8_ */
union union
{ {
@ -46,7 +55,7 @@ class CGameState
public: public:
CGameState(); CGameState();
CGameState(CBitStreamReader& stream); CGameState(CBitStreamReader& stream);
void SetCurrentWorldId(unsigned int id, const std::string& name); void SetCurrentWorldId(unsigned int id);
std::shared_ptr<CPlayerState> GetPlayerState() {return x98_playerState;} std::shared_ptr<CPlayerState> GetPlayerState() {return x98_playerState;}
std::shared_ptr<CWorldTransManager> GetWorldTransitionManager() {return x9c_transManager;} std::shared_ptr<CWorldTransManager> GetWorldTransitionManager() {return x9c_transManager;}
void SetTotalPlayTime(float time); void SetTotalPlayTime(float time);

View File

@ -99,7 +99,7 @@ std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vect
if (x4_parms.size() > 0) if (x4_parms.size() > 0)
calcWeight = 0.f; calcWeight = 0.f;
u32 r23 = 0 ; u32 unweightedCount = 0 ;
u32 i = 0; u32 i = 0;
for (; i<x4_parms.size() ; ++i) for (; i<x4_parms.size() ; ++i)
@ -115,13 +115,13 @@ std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vect
computedWeight = ComputeExactMatchWeight(i, parms[i], val); computedWeight = ComputeExactMatchWeight(i, parms[i], val);
else if (parmInfo.GetWeightFunction() == CPASParmInfo::EWeightFunction::PercentError) else if (parmInfo.GetWeightFunction() == CPASParmInfo::EWeightFunction::PercentError)
computedWeight = ComputePercentErrorWeight(i, parms[i], val); computedWeight = ComputePercentErrorWeight(i, parms[i], val);
else if (parmInfo.GetWeightFunction() == CPASParmInfo::EWeightFunction::Three) else if (parmInfo.GetWeightFunction() == CPASParmInfo::EWeightFunction::NoWeight)
r23++; unweightedCount++;
calcWeight = parmWeight * calcWeight + computedWeight; calcWeight = parmWeight * calcWeight + computedWeight;
} }
if (r23 == x4_parms.size()) if (unweightedCount == x4_parms.size())
calcWeight = 1.0f; calcWeight = 1.0f;
if (calcWeight < weight) if (calcWeight < weight)
@ -132,6 +132,7 @@ std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vect
if (search == x24_selectionCache.cend()) if (search == x24_selectionCache.cend())
const_cast<std::vector<s32>*>(&x24_selectionCache)->push_back(info.GetAnimId()); const_cast<std::vector<s32>*>(&x24_selectionCache)->push_back(info.GetAnimId());
weight = calcWeight;
} }
} }
return {weight, PickRandomAnimation(rand)}; return {weight, PickRandomAnimation(rand)};

View File

@ -15,7 +15,7 @@ public:
ExactMatch, ExactMatch,
PercentError, PercentError,
AngularPercent, AngularPercent,
Three NoWeight
}; };
CPASAnimParm::EParmType x0_type; CPASAnimParm::EParmType x0_type;