feat(component): add ComponentGetSectionsRecord

This commit is contained in:
fallenoak 2025-10-16 19:51:53 -05:00
parent 33d817f394
commit 686bd6b0d9
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 20 additions and 0 deletions

View File

@ -128,6 +128,24 @@ int32_t BuildComponentArray(uint32_t varArrayLength, st_race** varArrayPtr) {
return 1;
}
CharSectionsRec* ComponentGetSectionsRecord(st_race* varArray, int32_t raceId, int32_t sexId, COMPONENT_VARIATIONS sectionIndex, int32_t variationIndex, int32_t colorIndex, bool* found) {
if (!ComponentValidateBase(varArray, raceId, sexId, sectionIndex, variationIndex, colorIndex)) {
if (found) {
*found = false;
}
return nullptr;
}
auto& section = varArray[(raceId * UNITSEX_NUM_SEXES + sexId)].sections[sectionIndex];
if (found) {
*found = true;
}
return section.variationArray[variationIndex].colorArray[colorIndex].rec;
}
int32_t ComponentValidateBase(st_race* varArray, int32_t raceId, int32_t sexId, COMPONENT_VARIATIONS sectionIndex, int32_t variationIndex, int32_t colorIndex) {
if (sectionIndex >= NUM_COMPONENT_VARIATIONS || variationIndex < 0) {
return 0;

View File

@ -28,6 +28,8 @@ struct st_variation {
int32_t BuildComponentArray(uint32_t varArrayLength, st_race** varArrayPtr);
CharSectionsRec* ComponentGetSectionsRecord(st_race* varArray, int32_t raceId, int32_t sexId, COMPONENT_VARIATIONS sectionIndex, int32_t variationIndex, int32_t colorIndex, bool* found);
int32_t ComponentValidateBase(st_race* varArray, int32_t raceId, int32_t sexId, COMPONENT_VARIATIONS sectionIndex, int32_t variationIndex, int32_t colorIndex);
#endif