feat(component): add ComponentValidateBase

This commit is contained in:
fallenoak committed 2025-10-16 19:47:05 -05:00
1 parent e8487187d8
commit 33d817f394
2 files changed
+26

No files matched your search

+24
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;
}
+2
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