feat(component): add ComponentValidateBase

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

View File

@ -127,3 +127,27 @@ int32_t BuildComponentArray(uint32_t varArrayLength, st_race** varArrayPtr) {
return 1;
}
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;
}
auto& section = varArray[(raceId * UNITSEX_NUM_SEXES + sexId)].sections[sectionIndex];
if (variationIndex >= section.variationCount || section.variationCount == 0) {
return 0;
}
if (colorIndex < 0) {
return 0;
}
auto& variation = section.variationArray[variationIndex];
if (colorIndex >= variation.colorCount || variation.colorCount == 0) {
return 0;
}
return 1;
}

View File

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