diff --git a/LEGO1/lego/legoomni/include/infocenterstate.h b/LEGO1/lego/legoomni/include/infocenterstate.h index 05b0ed83..b1c418f1 100644 --- a/LEGO1/lego/legoomni/include/infocenterstate.h +++ b/LEGO1/lego/legoomni/include/infocenterstate.h @@ -30,7 +30,7 @@ public: // FUNCTION: LEGO1 0x10071830 MxBool IsSerializable() override { return FALSE; } // vtable+0x14 - inline MxS16 GetMaxNameLength() { return _countof(m_letters); } + inline MxS16 GetMaxNameLength() { return sizeOfArray(m_letters); } inline MxStillPresenter* GetNameLetter(MxS32 p_index) { return m_letters[p_index]; } inline void SetNameLetter(MxS32 p_index, MxStillPresenter* p_letter) { m_letters[p_index] = p_letter; } inline MxBool HasRegistered() { return m_letters[0] != NULL; } diff --git a/LEGO1/lego/legoomni/src/act1/act1state.cpp b/LEGO1/lego/legoomni/src/act1/act1state.cpp index 98c167fe..013347d3 100644 --- a/LEGO1/lego/legoomni/src/act1/act1state.cpp +++ b/LEGO1/lego/legoomni/src/act1/act1state.cpp @@ -34,7 +34,7 @@ Act1State::Act1State() : m_unk0x00c(0), m_unk0x00e(0), m_unk0x008(NULL), m_unk0x m_unk0x1b0 = NULL; m_unk0x021 = 1; m_elevFloor = Act1State::c_floor1; - m_unk0x00c = _countof(g_unk0x100f37f0); + m_unk0x00c = sizeOfArray(g_unk0x100f37f0); m_unk0x1b4 = NULL; m_unk0x1b8 = NULL; m_unk0x208 = NULL; diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index 2dc88f9a..5d2c1259 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -244,7 +244,7 @@ LegoBuildingManager::~LegoBuildingManager() // FUNCTION: LEGO1 0x1002f9d0 void LegoBuildingManager::Init() { - for (MxS32 i = 0; i < _countof(g_buildingInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) { g_buildingInfo[i] = g_buildingInfoInit[i]; } @@ -262,7 +262,7 @@ void LegoBuildingManager::FUN_1002fa00() MxS32 i; LegoWorld* world = CurrentWorld(); - for (i = 0; i < _countof(g_buildingInfo); i++) { + for (i = 0; i < sizeOfArray(g_buildingInfo); i++) { UpdatePosition(i, world); } @@ -274,7 +274,7 @@ void LegoBuildingManager::FUN_1002fa00() } } else { - for (i = 0; i < _countof(g_buildingInfoHausName); i++) { + for (i = 0; i < sizeOfArray(g_buildingInfoHausName); i++) { LegoEntity* entity = (LegoEntity*) world->Find("MxEntity", g_buildingInfoHausName[i]); if (entity) { entity->GetROI()->SetVisibility(m_nextVariant == i); @@ -308,7 +308,7 @@ void LegoBuildingManager::FUN_1002fb30() { MxU32 i; - for (i = 0; i < _countof(g_buildingInfo); i++) { + for (i = 0; i < sizeOfArray(g_buildingInfo); i++) { g_buildingInfo[i].m_entity = NULL; } @@ -327,7 +327,7 @@ MxResult LegoBuildingManager::Write(LegoStorage* p_storage) { MxResult result = FAILURE; - for (MxS32 i = 0; i < _countof(g_buildingInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) { LegoBuildingInfo* info = &g_buildingInfo[i]; if (p_storage->Write(&info->m_cycle1, sizeof(info->m_cycle1)) != SUCCESS) { @@ -360,7 +360,7 @@ MxResult LegoBuildingManager::Read(LegoStorage* p_storage) { MxResult result = FAILURE; - for (MxS32 i = 0; i < _countof(g_buildingInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) { LegoBuildingInfo* info = &g_buildingInfo[i]; if (p_storage->Read(&info->m_cycle1, sizeof(info->m_cycle1)) != SUCCESS) { @@ -426,13 +426,13 @@ LegoBuildingInfo* LegoBuildingManager::GetInfo(LegoEntity* p_entity) { MxS32 i; - for (i = 0; i < _countof(g_buildingInfo); i++) { + for (i = 0; i < sizeOfArray(g_buildingInfo); i++) { if (g_buildingInfo[i].m_entity == p_entity) { break; } } - if (i < _countof(g_buildingInfo)) { + if (i < sizeOfArray(g_buildingInfo)) { return &g_buildingInfo[i]; } @@ -451,7 +451,7 @@ MxBool LegoBuildingManager::IncrementVariant(LegoEntity* p_entity) if (info != NULL && info->m_flags & LegoBuildingInfo::c_bit1 && info->m_unk0x11 == -1) { LegoROI* roi = p_entity->GetROI(); - if (++m_nextVariant >= _countof(g_buildingInfoHausName)) { + if (++m_nextVariant >= sizeOfArray(g_buildingInfoHausName)) { m_nextVariant = 0; } @@ -603,7 +603,7 @@ MxBool LegoBuildingManager::FUN_10030030(MxS32 p_index) // FUNCTION: LEGO1 0x10030110 MxBool LegoBuildingManager::FUN_10030110(LegoBuildingInfo* p_data) { - for (MxS32 i = 0; i < _countof(g_buildingInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) { if (&g_buildingInfo[i] == p_data) { return FUN_10030030(i); } @@ -665,7 +665,7 @@ MxResult LegoBuildingManager::Tickle() // FUNCTION: BETA10 0x1006474c void LegoBuildingManager::FUN_10030590() { - for (MxS32 i = 0; i < _countof(g_buildingInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) { g_buildingInfo[i].m_unk0x11 = -1; g_buildingInfo[i].m_initialUnk0x11 = -1; AdjustHeight(i); @@ -693,7 +693,7 @@ LegoBuildingInfo* LegoBuildingManager::GetInfoArray(MxS32& p_length) FUN_10030630(); } - p_length = _countof(g_buildingInfo); + p_length = sizeOfArray(g_buildingInfo); return g_buildingInfo; } @@ -719,7 +719,7 @@ void LegoBuildingManager::FUN_100307b0(LegoEntity* p_entity, MxS32 p_adjust) // FUNCTION: LEGO1 0x10030800 void LegoBuildingManager::FUN_10030800() { - for (MxS32 i = 0; i < _countof(g_buildingInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) { g_buildingInfo[i].m_initialUnk0x11 = g_buildingInfo[i].m_unk0x11; } } diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 912e9d3d..812d9d93 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -144,7 +144,7 @@ LegoAnimationManager::~LegoAnimationManager() FUN_10061010(FALSE); - for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { + for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { LegoROI* roi = m_extras[i].m_roi; if (roi != NULL) { @@ -230,7 +230,7 @@ void LegoAnimationManager::Suspend() FUN_10061010(FALSE); MxS32 i; - for (i = 0; i < (MxS32) _countof(m_extras); i++) { + for (i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { LegoROI* roi = m_extras[i].m_roi; if (roi != NULL) { @@ -270,7 +270,7 @@ void LegoAnimationManager::Suspend() m_unk0x414 = 0; m_unk0x401 = FALSE; - for (i = 0; i < (MxS32) _countof(g_characters); i++) { + for (i = 0; i < (MxS32) sizeOfArray(g_characters); i++) { g_characters[i].m_unk0x04 = FALSE; } } @@ -305,12 +305,12 @@ void LegoAnimationManager::Init() m_unk0x41c = g_legoAnimationManagerConfig <= 1 ? 10 : 20; MxS32 i; - for (i = 0; i < (MxS32) _countof(m_unk0x28); i++) { + for (i = 0; i < (MxS32) sizeOfArray(m_unk0x28); i++) { m_unk0x28[i] = NULL; m_unk0x30[i] = 0; } - for (i = 0; i < (MxS32) _countof(m_extras); i++) { + for (i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { m_extras[i].m_roi = NULL; m_extras[i].m_characterId = -1; m_extras[i].m_unk0x10 = -1.0f; @@ -333,12 +333,12 @@ void LegoAnimationManager::Init() m_unk0x408 = m_unk0x40c = m_unk0x404 = Timer()->GetTime(); m_unk0x410 = 5000; - for (i = 0; i < (MxS32) _countof(g_characters); i++) { + for (i = 0; i < (MxS32) sizeOfArray(g_characters); i++) { g_characters[i].m_active = FALSE; g_characters[i].m_unk0x04 = FALSE; } - for (i = 0; i < (MxS32) _countof(g_vehicles); i++) { + for (i = 0; i < (MxS32) sizeOfArray(g_vehicles); i++) { g_vehicles[i].m_unk0x04 = FALSE; g_vehicles[i].m_unk0x05 = FALSE; } @@ -396,7 +396,7 @@ MxResult LegoAnimationManager::LoadScriptInfo(MxS32 p_scriptIndex) m_tranInfoList2 = NULL; } - for (i = 0; i < (MxS32) _countof(m_unk0x28); i++) { + for (i = 0; i < (MxS32) sizeOfArray(m_unk0x28); i++) { m_unk0x28[i] = NULL; m_unk0x30[i] = 0; } @@ -406,7 +406,7 @@ MxResult LegoAnimationManager::LoadScriptInfo(MxS32 p_scriptIndex) m_unk0x430 = FALSE; m_unk0x42c = NULL; - for (j = 0; j < (MxS32) _countof(g_characters); j++) { + for (j = 0; j < (MxS32) sizeOfArray(g_characters); j++) { g_characters[j].m_active = FALSE; } @@ -543,7 +543,7 @@ done: // FUNCTION: LEGO1 0x10060140 MxBool LegoAnimationManager::FindVehicle(const char* p_name, MxU32& p_index) { - for (MxS32 i = 0; i < _countof(g_vehicles); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_vehicles); i++) { if (!strcmpi(p_name, g_vehicles[i].m_name)) { p_index = i; return TRUE; @@ -590,7 +590,7 @@ MxResult LegoAnimationManager::ReadAnimInfo(LegoFile* p_file, AnimInfo* p_info) goto done; } - for (i = 0; i < (MxS32) _countof(p_info->m_unk0x10); i++) { + for (i = 0; i < (MxS32) sizeOfArray(p_info->m_unk0x10); i++) { if (p_file->Read(&p_info->m_unk0x10[i], sizeof(*p_info->m_unk0x10)) != SUCCESS) { goto done; } @@ -865,7 +865,7 @@ MxResult LegoAnimationManager::StartEntityAction(MxDSAction& p_dsAction, LegoEnt controller->RemoveActor(actor); actor->SetController(NULL); - for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { + for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { if (m_extras[i].m_roi == roi) { MxS32 characterId = m_extras[i].m_characterId; g_characters[characterId].m_unk0x07 = TRUE; @@ -1134,7 +1134,7 @@ MxLong LegoAnimationManager::Notify(MxParam& p_param) cursor.Detach(); delete tranInfo; - for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { + for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { LegoROI* roi = m_extras[i].m_roi; if (roi != NULL) { @@ -1184,7 +1184,7 @@ MxResult LegoAnimationManager::Tickle() } if (m_unk0x401) { - for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { + for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { LegoROI* roi = m_extras[i].m_roi; if (roi != NULL && m_extras[i].m_unk0x0d) { @@ -1241,7 +1241,7 @@ MxResult LegoAnimationManager::Tickle() unk0x0c = g_unk0x100d8b28[actorId]; } - for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { + for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { LegoROI* roi = m_extras[i].m_roi; if (roi != NULL) { @@ -1318,7 +1318,7 @@ MxU16 LegoAnimationManager::FUN_10062110( float len = position.LenSquared(); float min, max; - for (MxU32 i = 0; i < _countof(g_unk0x100f74b0); i++) { + for (MxU32 i = 0; i < sizeOfArray(g_unk0x100f74b0); i++) { if (g_unk0x100f74b0[i][0] < p_speed) { max = g_unk0x100f74b0[i][1]; min = g_unk0x100f74b0[i][2]; @@ -1335,7 +1335,7 @@ MxU16 LegoAnimationManager::FUN_10062110( if (vehicleId >= 0) { MxBool found = FALSE; - for (MxS32 j = 0; j < (MxS32) _countof(m_anims[i].m_unk0x2a); j++) { + for (MxS32 j = 0; j < (MxS32) sizeOfArray(m_anims[i].m_unk0x2a); j++) { if (m_anims[i].m_unk0x2a[j] == vehicleId) { found = TRUE; break; @@ -1375,7 +1375,7 @@ MxS8 LegoAnimationManager::GetCharacterIndex(const char* p_name) { MxS8 i; - for (i = 0; i < _countof(g_characters); i++) { + for (i = 0; i < sizeOfArray(g_characters); i++) { if (!strnicmp(p_name, g_characters[i].m_name, 2)) { return i; } @@ -1454,7 +1454,7 @@ void LegoAnimationManager::FUN_10062580(AnimInfo& p_info) controller->RemoveActor(actor); actor->SetController(NULL); - for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { + for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { if (m_extras[i].m_roi == actor->GetROI()) { MxS32 characterId = m_extras[i].m_characterId; g_characters[characterId].m_unk0x07 = TRUE; @@ -1544,7 +1544,7 @@ void LegoAnimationManager::PurgeExtra(MxBool p_und) if (p_und || viewManager != NULL) { MxLong time = Timer()->GetTime(); - for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { + for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { LegoROI* roi = m_extras[i].m_roi; if (roi != NULL) { @@ -1655,7 +1655,7 @@ void LegoAnimationManager::AddExtra(MxS32 p_location, MxBool p_und) if (m_extras[i].m_roi == NULL) { m_lastExtraCharacterId++; - if (m_lastExtraCharacterId >= _countof(g_characters)) { + if (m_lastExtraCharacterId >= sizeOfArray(g_characters)) { m_lastExtraCharacterId = 0; } @@ -1755,7 +1755,7 @@ void LegoAnimationManager::AddExtra(MxS32 p_location, MxBool p_und) m_lastExtraCharacterId++; - if (m_lastExtraCharacterId >= _countof(g_characters)) { + if (m_lastExtraCharacterId >= sizeOfArray(g_characters)) { m_lastExtraCharacterId = 0; } diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 7b0c3995..891a6471 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -75,7 +75,7 @@ LegoCharacterManager::~LegoCharacterManager() // FUNCTION: LEGO1 0x10083270 void LegoCharacterManager::Init() { - for (MxS32 i = 0; i < _countof(g_characterInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_characterInfo); i++) { g_characterInfo[i] = g_characterInfoInit[i]; } } @@ -83,7 +83,7 @@ void LegoCharacterManager::Init() // FUNCTION: LEGO1 0x100832a0 void LegoCharacterManager::FUN_100832a0() { - for (MxS32 i = 0; i < _countof(g_characterInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_characterInfo); i++) { LegoCharacterInfo* info = GetInfo(g_characterInfo[i].m_name); if (info != NULL) { @@ -107,7 +107,7 @@ MxResult LegoCharacterManager::Write(LegoStorage* p_storage) { MxResult result = FAILURE; - for (MxS32 i = 0; i < _countof(g_characterInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_characterInfo); i++) { LegoCharacterInfo* info = &g_characterInfo[i]; if (p_storage->Write(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) { @@ -162,7 +162,7 @@ MxResult LegoCharacterManager::Read(LegoStorage* p_storage) { MxResult result = FAILURE; - for (MxS32 i = 0; i < _countof(g_characterInfo); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_characterInfo); i++) { LegoCharacterInfo* info = &g_characterInfo[i]; if (p_storage->Read(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) { @@ -451,7 +451,7 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) info->m_unk0x10 = pepper->m_unk0x10; info->m_unk0x14 = pepper->m_unk0x14; - for (i = 0; i < _countof(info->m_parts); i++) { + for (i = 0; i < sizeOfArray(info->m_parts); i++) { info->m_parts[i] = pepper->m_parts[i]; } } @@ -476,7 +476,7 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) comp = new CompoundObject(); roi->SetComp(comp); - for (i = 0; i < _countof(g_characterLODs) - 1; i++) { + for (i = 0; i < sizeOfArray(g_characterLODs) - 1; i++) { char lodName[256]; LegoCharacterInfo::Part& part = info->m_parts[i]; @@ -622,7 +622,7 @@ MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_tex // FUNCTION: LEGO1 0x10084c00 MxBool LegoCharacterManager::Exists(const char* p_key) { - for (MxU32 i = 0; i < _countof(g_characterInfo); i++) { + for (MxU32 i = 0; i < sizeOfArray(g_characterInfo); i++) { if (!strcmpi(g_characterInfo[i].m_name, p_key)) { return TRUE; } @@ -648,13 +648,13 @@ LegoCharacterInfo* LegoCharacterManager::GetInfo(const char* p_key) { MxU32 i; - for (i = 0; i < _countof(g_characterInfo); i++) { + for (i = 0; i < sizeOfArray(g_characterInfo); i++) { if (!strcmpi(g_characterInfo[i].m_name, p_key)) { break; } } - if (i < _countof(g_characterInfo)) { + if (i < sizeOfArray(g_characterInfo)) { return &g_characterInfo[i]; } @@ -666,13 +666,13 @@ LegoCharacterInfo* LegoCharacterManager::GetInfo(LegoROI* p_roi) { MxU32 i; - for (i = 0; i < _countof(g_characterInfo); i++) { + for (i = 0; i < sizeOfArray(g_characterInfo); i++) { if (g_characterInfo[i].m_roi == p_roi) { break; } } - if (i < _countof(g_characterInfo)) { + if (i < sizeOfArray(g_characterInfo)) { return &g_characterInfo[i]; } diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index c07a1871..101a3e6a 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -251,7 +251,7 @@ MxResult LegoGameState::Save(MxULong p_slot) Write(&fileStorage, (MxU16) m_currentAct); Write(&fileStorage, m_actorId); - for (i = 0; i < _countof(g_colorSaveData); i++) { + for (i = 0; i < sizeOfArray(g_colorSaveData); i++) { if (WriteVariable(&fileStorage, variableTable, g_colorSaveData[i].m_targetName) == FAILURE) { goto done; } @@ -997,7 +997,7 @@ void LegoGameState::SetColors() { MxVariableTable* variableTable = VariableTable(); - for (MxS32 i = 0; i < _countof(g_colorSaveData); i++) { + for (MxS32 i = 0; i < sizeOfArray(g_colorSaveData); i++) { variableTable->SetVariable(g_colorSaveData[i].m_targetName, g_colorSaveData[i].m_colorName); } } diff --git a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp index 520a0070..51775a03 100644 --- a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp +++ b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp @@ -104,7 +104,7 @@ LegoTextureInfo* LegoTextureInfo::Create(const char* p_name, LegoTexture* p_text PALETTEENTRY entries[256]; memset(entries, 0, sizeof(entries)); - for (i = 0; i < _countof(entries); i++) { + for (i = 0; i < sizeOfArray(entries); i++) { if (i < image->GetCount()) { entries[i].peFlags = 0; entries[i].peRed = image->GetPaletteEntry(i).GetRed(); diff --git a/LEGO1/lego/legoomni/src/entity/legoactor.cpp b/LEGO1/lego/legoomni/src/entity/legoactor.cpp index 58df76c4..6c455909 100644 --- a/LEGO1/lego/legoomni/src/entity/legoactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoactor.cpp @@ -127,7 +127,7 @@ void LegoActor::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2) if (p_roi) { const char* name = p_roi->GetName(); - for (MxU32 i = 1; i <= _countof(g_actorNames) - 1; i++) { + for (MxU32 i = 1; i <= sizeOfArray(g_actorNames) - 1; i++) { if (!strcmpi(name, g_actorNames[i])) { m_type = e_character; m_actorId = i; diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 2ecdff71..d3d940d3 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -407,7 +407,7 @@ MxResult LegoNavController::UpdateLocation(const char* p_location) { MxResult result = FAILURE; - for (MxS32 i = 0; i < (MxS32) _countof(g_locations); i++) { + for (MxS32 i = 0; i < (MxS32) sizeOfArray(g_locations); i++) { if (!strcmpi(p_location, g_locations[i].m_name)) { MxMatrix mat; LegoROI* viewROI = VideoManager()->GetViewROI(); @@ -440,7 +440,7 @@ MxResult LegoNavController::UpdateLocation(MxU32 p_location) { MxResult result = FAILURE; - if (p_location < _countof(g_locations)) { + if (p_location < sizeOfArray(g_locations)) { MxMatrix mat; LegoROI* viewROI = VideoManager()->GetViewROI(); @@ -475,7 +475,7 @@ MxResult LegoNavController::UpdateLocation(MxU32 p_location) // FUNCTION: BETA10 0x1009c259 LegoLocation* LegoNavController::GetLocation(MxU32 p_location) { - if (p_location < _countof(g_locations)) { + if (p_location < sizeOfArray(g_locations)) { return &g_locations[p_location]; } diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp index a6159d62..0fd99839 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp @@ -93,28 +93,28 @@ InfomainScript::Script g_bricksterDialogue[2] = { // FUNCTION: LEGO1 0x10071600 InfocenterState::InfocenterState() { - m_exitDialogueAct1 = LegoState::Playlist((MxU32*) g_exitDialogueAct1, _countof(g_exitDialogueAct1)); - m_exitDialogueAct23 = LegoState::Playlist((MxU32*) g_exitDialogueAct23, _countof(g_exitDialogueAct23) - 1); + m_exitDialogueAct1 = LegoState::Playlist((MxU32*) g_exitDialogueAct1, sizeOfArray(g_exitDialogueAct1)); + m_exitDialogueAct23 = LegoState::Playlist((MxU32*) g_exitDialogueAct23, sizeOfArray(g_exitDialogueAct23) - 1); m_returnDialogue[LegoGameState::e_act1] = - LegoState::Playlist((MxU32*) g_returnDialogueAct1, _countof(g_returnDialogueAct1) - 1); + LegoState::Playlist((MxU32*) g_returnDialogueAct1, sizeOfArray(g_returnDialogueAct1) - 1); m_returnDialogue[LegoGameState::e_act2] = - LegoState::Playlist((MxU32*) g_returnDialogueAct2, _countof(g_returnDialogueAct2) - 1); + LegoState::Playlist((MxU32*) g_returnDialogueAct2, sizeOfArray(g_returnDialogueAct2) - 1); m_returnDialogue[LegoGameState::e_act3] = - LegoState::Playlist((MxU32*) g_returnDialogueAct3, _countof(g_returnDialogueAct3)); + LegoState::Playlist((MxU32*) g_returnDialogueAct3, sizeOfArray(g_returnDialogueAct3)); m_leaveDialogue[LegoGameState::e_act1] = - LegoState::Playlist((MxU32*) g_leaveDialogueAct1, _countof(g_leaveDialogueAct1)); + LegoState::Playlist((MxU32*) g_leaveDialogueAct1, sizeOfArray(g_leaveDialogueAct1)); m_leaveDialogue[LegoGameState::e_act2] = - LegoState::Playlist((MxU32*) g_leaveDialogueAct2, _countof(g_leaveDialogueAct2)); + LegoState::Playlist((MxU32*) g_leaveDialogueAct2, sizeOfArray(g_leaveDialogueAct2)); m_leaveDialogue[LegoGameState::e_act3] = - LegoState::Playlist((MxU32*) g_leaveDialogueAct3, _countof(g_leaveDialogueAct3) - 1); + LegoState::Playlist((MxU32*) g_leaveDialogueAct3, sizeOfArray(g_leaveDialogueAct3) - 1); - m_bricksterDialogue = LegoState::Playlist((MxU32*) g_bricksterDialogue, _countof(g_bricksterDialogue)); + m_bricksterDialogue = LegoState::Playlist((MxU32*) g_bricksterDialogue, sizeOfArray(g_bricksterDialogue)); memset(m_letters, 0, sizeof(m_letters)); } diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 3d683dea..9149835d 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -147,11 +147,11 @@ void LegoInputManager::FUN_1005c0f0() m_unk0x94 = FALSE; if (m_directInputDevice) { - HRESULT hr = m_directInputDevice->GetDeviceState(_countof(m_unk0x95), &m_unk0x95); + HRESULT hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_unk0x95), &m_unk0x95); if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) { if (m_directInputDevice->Acquire() == S_OK) { - hr = m_directInputDevice->GetDeviceState(_countof(m_unk0x95), &m_unk0x95); + hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_unk0x95), &m_unk0x95); } } diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 2f8eefe8..a5f1797d 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -100,7 +100,7 @@ MxResult LegoPathController::Create(MxU8* p_data, const Vector3& p_location, con LegoPathBoundary& boundary = m_boundaries[i]; MxS32 j; - for (j = 0; j < _countof(g_unk0x100f42f0); j++) { + for (j = 0; j < sizeOfArray(g_unk0x100f42f0); j++) { if (!strcmpi(g_unk0x100f42f0[j], boundary.GetName())) { g_ctrlBoundariesA[j].m_controller = this; g_ctrlBoundariesA[j].m_boundary = &boundary; @@ -111,7 +111,7 @@ MxResult LegoPathController::Create(MxU8* p_data, const Vector3& p_location, con } } - for (j = 0; j < _countof(g_unk0x100f4330); j++) { + for (j = 0; j < sizeOfArray(g_unk0x100f4330); j++) { if (!strcmpi(g_unk0x100f4330[j], boundary.GetName())) { g_ctrlBoundariesB[j].m_controller = this; g_ctrlBoundariesB[j].m_boundary = &boundary; @@ -162,7 +162,7 @@ void LegoPathController::Destroy() m_numE = 0; MxS32 j; - for (j = 0; j < _countof(g_unk0x100f42f0); j++) { + for (j = 0; j < sizeOfArray(g_unk0x100f42f0); j++) { if (g_ctrlBoundariesA[j].m_controller == this) { g_ctrlBoundariesA[j].m_controller = NULL; g_ctrlBoundariesA[j].m_boundary = NULL; @@ -174,7 +174,7 @@ void LegoPathController::Destroy() } } - for (j = 0; j < _countof(g_unk0x100f4330); j++) { + for (j = 0; j < sizeOfArray(g_unk0x100f4330); j++) { if (g_ctrlBoundariesB[j].m_controller == this) { g_ctrlBoundariesB[j].m_controller = NULL; g_ctrlBoundariesB[j].m_boundary = NULL; @@ -421,10 +421,10 @@ MxResult LegoPathController::Init() return FAILURE; } - g_ctrlBoundariesA = new CtrlBoundary[_countof(g_unk0x100f42f0)]; - g_ctrlEdgesA = new CtrlEdge[_countof(g_unk0x100f42f0)]; - g_ctrlBoundariesB = new CtrlBoundary[_countof(g_unk0x100f4330)]; - g_ctrlEdgesB = new CtrlEdge[_countof(g_unk0x100f4330)]; + g_ctrlBoundariesA = new CtrlBoundary[sizeOfArray(g_unk0x100f42f0)]; + g_ctrlEdgesA = new CtrlEdge[sizeOfArray(g_unk0x100f42f0)]; + g_ctrlBoundariesB = new CtrlBoundary[sizeOfArray(g_unk0x100f4330)]; + g_ctrlEdgesB = new CtrlEdge[sizeOfArray(g_unk0x100f4330)]; return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp index c5da3ffe..a5302e47 100644 --- a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp @@ -80,7 +80,7 @@ void LegoLocomotionAnimPresenter::PutFrame() // FUNCTION: LEGO1 0x1006d5d0 void LegoLocomotionAnimPresenter::ReadyTickle() { - LegoAnimPresenter::ReadyTickle(); + LegoLoopingAnimPresenter::ReadyTickle(); if (m_currentWorld != NULL && m_currentTickleState == e_starting) { m_currentWorld->Add(this); diff --git a/LEGO1/lego/legoomni/src/worlds/historybook.cpp b/LEGO1/lego/legoomni/src/worlds/historybook.cpp index 7534623a..56e09bed 100644 --- a/LEGO1/lego/legoomni/src/worlds/historybook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/historybook.cpp @@ -127,7 +127,7 @@ void HistoryBook::ReadyWorld() (*scorebox)->SetTickleState(MxPresenter::e_repeating); (*scorebox)->SetPosition(scoreX + 0xa1, scoreY); - for (MxS16 letterIndex = 0; letterIndex < (MxS16) _countof(m_names[0]);) { + for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_names[0]);) { MxS16 letter = score->m_name.m_letters[letterIndex]; if (letter == -1) { diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index df5b09f3..21d95cac 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -492,7 +492,7 @@ void Isle::Enable(MxBool p_enable) for (MxU32 i = 0; i < 5; i++) { MxS32 r = rand() % 5; - for (MxU32 j = 0; j < _countof(locations); j++) { + for (MxU32 j = 0; j < sizeOfArray(locations); j++) { if (locations[j] != 0 && r-- == 0) { AnimationManager()->AddExtra(locations[j], TRUE); locations[j] = 0; diff --git a/LEGO1/lego/sources/misc/legounknown.cpp b/LEGO1/lego/sources/misc/legounknown.cpp index e9210dc7..14178e44 100644 --- a/LEGO1/lego/sources/misc/legounknown.cpp +++ b/LEGO1/lego/sources/misc/legounknown.cpp @@ -5,7 +5,7 @@ DECOMP_SIZE_ASSERT(LegoUnknown, 0x50) // FUNCTION: LEGO1 0x1009a0f0 LegoUnknown::LegoUnknown() { - for (LegoS32 i = 0; i < _countof(m_unk0x00); i++) { + for (LegoS32 i = 0; i < sizeOfArray(m_unk0x00); i++) { m_unk0x00[i].Clear(); } } diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index e9997907..2170c101 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -108,21 +108,21 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text } if (numVerts > 0) { - vertices = new float[numVerts][_countof(*vertices)]; + vertices = new float[numVerts][sizeOfArray(*vertices)]; if (p_storage->Read(vertices, numVerts * sizeof(*vertices)) != SUCCESS) { goto done; } } if (numNormals > 0) { - normals = new float[numNormals][_countof(*normals)]; + normals = new float[numNormals][sizeOfArray(*normals)]; if (p_storage->Read(normals, numNormals * sizeof(*normals)) != SUCCESS) { goto done; } } if (numTextureVertices > 0) { - textureVertices = new float[numTextureVertices][_countof(*textureVertices)]; + textureVertices = new float[numTextureVertices][sizeOfArray(*textureVertices)]; if (p_storage->Read(textureVertices, numTextureVertices * sizeof(*textureVertices)) != SUCCESS) { goto done; } @@ -143,7 +143,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text goto done; } - polyIndices = new LegoU32[numPolys & MAXWORD][_countof(*polyIndices)]; + polyIndices = new LegoU32[numPolys & MAXWORD][sizeOfArray(*polyIndices)]; if (p_storage->Read(polyIndices, (numPolys & MAXWORD) * sizeof(*polyIndices)) != SUCCESS) { goto done; } @@ -153,7 +153,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text } if (numTextureIndices > 0) { - textureIndices = new LegoU32[numPolys & MAXWORD][_countof(*textureIndices)]; + textureIndices = new LegoU32[numPolys & MAXWORD][sizeOfArray(*textureIndices)]; if (p_storage->Read(textureIndices, (numPolys & MAXWORD) * sizeof(*textureIndices)) != SUCCESS) { goto done; } @@ -212,7 +212,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text if (textureName != NULL) { if (mesh->GetUnknown0x21()) { - LegoROI::FUN_100a9cf0(textureName, paletteEntries, _countof(paletteEntries)); + LegoROI::FUN_100a9cf0(textureName, paletteEntries, sizeOfArray(paletteEntries)); } textureInfo = p_textureContainer->Get(mesh->GetTextureName()); diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index 7bee2c40..33fbbb8e 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -609,7 +609,7 @@ LegoBool LegoROI::FUN_100a9bf0(const LegoChar* p_param, float& p_red, float& p_g // FUNCTION: LEGO1 0x100a9c50 LegoBool LegoROI::ColorAliasLookup(const LegoChar* p_param, float& p_red, float& p_green, float& p_blue, float& p_alpha) { - for (MxU32 i = 0; i < _countof(g_roiColorAliases); i++) { + for (MxU32 i = 0; i < sizeOfArray(g_roiColorAliases); i++) { if (strcmpi(g_roiColorAliases[i].m_name, p_param) == 0) { p_red = g_roiColorAliases[i].m_red / 255.0; p_green = g_roiColorAliases[i].m_green / 255.0; diff --git a/LEGO1/mxdirectx/mxdirectdraw.cpp b/LEGO1/mxdirectx/mxdirectdraw.cpp index 0b3d05ff..cdd5f3b7 100644 --- a/LEGO1/mxdirectx/mxdirectdraw.cpp +++ b/LEGO1/mxdirectx/mxdirectdraw.cpp @@ -147,7 +147,7 @@ BOOL MxDirectDraw::SetPaletteEntries(const PALETTEENTRY* pPaletteEntries, int pa { int reservedLowEntryCount = 10; int reservedHighEntryCount = 10; - int arraySize = _countof(m_paletteEntries); + int arraySize = sizeOfArray(m_paletteEntries); HDC hdc; int i; @@ -184,7 +184,7 @@ BOOL MxDirectDraw::SetPaletteEntries(const PALETTEENTRY* pPaletteEntries, int pa if (m_pPalette) { HRESULT result; - result = m_pPalette->SetEntries(0, 0, _countof(m_paletteEntries), m_paletteEntries); + result = m_pPalette->SetEntries(0, 0, sizeOfArray(m_paletteEntries), m_paletteEntries); if (result != DD_OK) { Error("SetEntries failed", result); return FALSE; diff --git a/util/decomp.h b/util/decomp.h index 100f9f21..81cb1d13 100644 --- a/util/decomp.h +++ b/util/decomp.h @@ -13,8 +13,8 @@ #define DECOMP_SIZE_ASSERT(T, S) #endif -#ifndef _countof -#define _countof(arr) (sizeof(arr) / sizeof(arr[0])) +#ifndef sizeOfArray +#define sizeOfArray(arr) (sizeof(arr) / sizeof(arr[0])) #endif typedef unsigned char undefined;