Use sizeof(type) instead of sizeof(variableName) when (de)serializing data (#1505)

* Use sizeof(type) instead of sizeof(variableName) when (de)serializing data

* Less usage of sizeof(variableName) while (de)serializing
This commit is contained in:
Anonymous Maarten
2025-05-18 22:56:28 +02:00
committed by GitHub
parent c9b41e2db8
commit 2915aa014f
27 changed files with 227 additions and 234 deletions

View File

@@ -19,13 +19,13 @@ LegoPaletteEntry::LegoPaletteEntry()
LegoResult LegoPaletteEntry::Read(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Read(&m_red, sizeof(m_red))) != SUCCESS) {
if ((result = p_storage->Read(&m_red, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_green, sizeof(m_green))) != SUCCESS) {
if ((result = p_storage->Read(&m_green, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_blue, sizeof(m_blue))) != SUCCESS) {
if ((result = p_storage->Read(&m_blue, sizeof(LegoU8))) != SUCCESS) {
return result;
}
return SUCCESS;
@@ -35,13 +35,13 @@ LegoResult LegoPaletteEntry::Read(LegoStorage* p_storage)
LegoResult LegoPaletteEntry::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Write(&m_red, sizeof(m_red))) != SUCCESS) {
if ((result = p_storage->Write(&m_red, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_green, sizeof(m_green))) != SUCCESS) {
if ((result = p_storage->Write(&m_green, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_blue, sizeof(m_blue))) != SUCCESS) {
if ((result = p_storage->Write(&m_blue, sizeof(LegoU8))) != SUCCESS) {
return result;
}
return SUCCESS;
@@ -77,13 +77,13 @@ LegoImage::~LegoImage()
LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square)
{
LegoResult result;
if ((result = p_storage->Read(&m_width, sizeof(m_width))) != SUCCESS) {
if ((result = p_storage->Read(&m_width, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_height, sizeof(m_height))) != SUCCESS) {
if ((result = p_storage->Read(&m_height, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_count, sizeof(m_height))) != SUCCESS) {
if ((result = p_storage->Read(&m_count, sizeof(LegoU32))) != SUCCESS) {
return result;
}
for (LegoU32 i = 0; i < m_count; i++) {
@@ -153,13 +153,13 @@ LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square)
LegoResult LegoImage::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Write(&m_width, sizeof(m_width))) != SUCCESS) {
if ((result = p_storage->Write(&m_width, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_height, sizeof(m_height))) != SUCCESS) {
if ((result = p_storage->Write(&m_height, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_count, sizeof(m_height))) != SUCCESS) {
if ((result = p_storage->Write(&m_count, sizeof(LegoU32))) != SUCCESS) {
return result;
}
for (LegoU32 i = 0; i < m_count; i++) {

View File

@@ -45,21 +45,21 @@ public:
// FUNCTION: BETA10 0x1004b0d0
LegoStorage* WriteU8(LegoU8 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(LegoU8));
return this;
}
// FUNCTION: BETA10 0x10017ce0
LegoStorage* WriteS16(LegoS16 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(LegoS16));
return this;
}
// FUNCTION: BETA10 0x1004b110
LegoStorage* WriteU16(LegoU16 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(LegoU16));
return this;
}
@@ -67,7 +67,7 @@ public:
// FUNCTION: BETA10 0x10088540
LegoStorage* WriteS32(MxS32 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(MxS32));
return this;
}
@@ -75,14 +75,14 @@ public:
// FUNCTION: BETA10 0x1004b150
LegoStorage* WriteU32(MxU32 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(MxU32));
return this;
}
// FUNCTION: BETA10 0x10073610
LegoStorage* WriteFloat(LegoFloat p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(LegoFloat));
return this;
}
@@ -116,21 +116,21 @@ public:
// FUNCTION: BETA10 0x1004b190
LegoStorage* ReadU8(LegoU8& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(LegoU8));
return this;
}
// FUNCTION: BETA10 0x10024680
LegoStorage* ReadS16(LegoS16& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(LegoS16));
return this;
}
// FUNCTION: BETA10 0x1004b1d0
LegoStorage* ReadU16(LegoU16& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(LegoU16));
return this;
}
@@ -138,7 +138,7 @@ public:
// FUNCTION: BETA10 0x10088580
LegoStorage* ReadS32(MxS32& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(MxS32));
return this;
}
@@ -146,14 +146,14 @@ public:
// FUNCTION: BETA10 0x1004b210
LegoStorage* ReadU32(MxU32& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(MxU32));
return this;
}
// FUNCTION: BETA10 0x10073650
LegoStorage* ReadFloat(LegoFloat& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(LegoFloat));
return this;
}

View File

@@ -64,7 +64,7 @@ LegoResult LegoTree::Read(LegoStorage* p_storage, LegoTreeNode*& p_node)
return result;
}
LegoU32 numChildren;
if ((result = p_storage->Read(&numChildren, sizeof(numChildren))) != SUCCESS) {
if ((result = p_storage->Read(&numChildren, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if (numChildren) {
@@ -91,7 +91,7 @@ LegoResult LegoTree::Write(LegoStorage* p_storage, LegoTreeNode* p_node)
}
}
LegoU32 numChildren = p_node->GetNumChildren();
if ((result = p_storage->Write(&numChildren, sizeof(numChildren))) != SUCCESS) {
if ((result = p_storage->Write(&numChildren, sizeof(LegoU32))) != SUCCESS) {
return result;
}
for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) {