chore(datastore): clean up getter for uint8_t

This commit is contained in:
fallenoak 2023-01-08 13:55:26 -06:00
parent 30c34ca015
commit 42f36f2888
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D

View file

@ -45,12 +45,14 @@ void CDataStore::Finalize() {
CDataStore& CDataStore::Get(uint8_t& val) { CDataStore& CDataStore::Get(uint8_t& val) {
STORM_ASSERT(this->IsFinal()); STORM_ASSERT(this->IsFinal());
if (this->FetchRead(this->m_read, 1)) { auto bytes = sizeof(val);
if (this->FetchRead(this->m_read, bytes)) {
auto ofs = this->m_read - this->m_base; auto ofs = this->m_read - this->m_base;
auto ptr = &this->m_data[ofs]; auto ptr = &this->m_data[ofs];
val = *reinterpret_cast<uint8_t*>(ptr); val = *reinterpret_cast<uint8_t*>(ptr);
this->m_read += sizeof(val); this->m_read += bytes;
} }
return *this; return *this;