First pass at CPlayerState::PutTo

Former-commit-id: 4fcad1ada2
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-04 21:50:29 +03:00
parent 08efa3fd4f
commit e56a45c6c4
2 changed files with 23 additions and 14 deletions

View File

@ -0,0 +1,11 @@
#ifndef _COUTPUTSTREAM_HPP
#define _COUTPUTSTREAM_HPP
#include "types.h"
class COutputStream {
public:
void WriteBits(int val, int bitCount);
};
#endif // _COUTPUTSTREAM_HPP

View File

@ -9,6 +9,7 @@
#include "Kyoto/Math/CMath.hpp"
#include "Kyoto/Streams/CInputStream.hpp"
#include "Kyoto/Streams/COutputStream.hpp"
#include "rstl/math.hpp"
@ -114,32 +115,29 @@ CPlayerState::CPlayerState(CInputStream& stream)
}
void CPlayerState::PutTo(COutputStream& stream) {
/*
stream.WriteBits(x4_enabledItems, 32);
const float realHP = xc_health.GetHP();
u32 integralHP;
std::memcpy(&integralHP, &realHP, sizeof(u32));
stream.WriteBits(integralHP, 32);
stream.WriteBits(u32(x8_currentBeam), COutputStream::GetBitCount(5));
stream.WriteBits(u32(x20_currentSuit), COutputStream::GetBitCount(4));
stream.WriteBits(*(int*)(&realHP), 32);
stream.WriteBits(int(x8_currentBeam), GetBitCount(5));
stream.WriteBits(int(x20_currentSuit), GetBitCount(4));
for (size_t i = 0; i < x24_powerups.size(); ++i) {
const CPowerUp& pup = x24_powerups[i];
stream.WriteBits(pup.x0_amount, COutputStream::GetBitCount(PowerUpMaxValues[i]));
stream.WriteBits(pup.x4_capacity, COutputStream::GetBitCount(PowerUpMaxValues[i]));
stream.WriteBits(pup.x0_amount, GetBitCount(kPowerUpMax[i]));
stream.WriteBits(pup.x4_capacity, GetBitCount(kPowerUpMax[i]));
}
for (const auto& scanTime : x170_scanTimes) {
if (scanTime.second >= 1.f)
for (rstl::vector< rstl::pair< CAssetId, float > >::iterator it = x170_scanTimes.begin();
it != x170_scanTimes.end(); ++it) {
if (it->second >= 1.f)
stream.WriteBits(true, 1);
else
stream.WriteBits(false, 1);
}
stream.WriteBits(x180_scanCompletionRate.first, COutputStream::GetBitCount(0x100));
stream.WriteBits(x180_scanCompletionRate.second, COutputStream::GetBitCount(0x100));
*/
stream.WriteBits(x180_scanCompletionRateFirst, GetBitCount(0x100));
stream.WriteBits(x184_scanCompletionRateSecond, GetBitCount(0x100));
}
void CPlayerState::ReInitializePowerUp(CPlayerState::EItemType type, int capacity) {