Better match for add_unused_obj_index (#734)

This commit is contained in:
MegaMech 2025-07-19 17:07:35 -06:00 committed by GitHub
parent a927b1db49
commit bb8ac997a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 11 deletions

View File

@ -161,26 +161,18 @@ s32 add_unused_obj_index(s32* listIdx, s32* nextFree, s32 size) {
}
count = 0;
id = &listIdx[*nextFree];
/**
* @todo This HAS to be a for-loop of some variety, but I can't make a for-loop to match.
* If you replace this with ```for(var_v1 = 0; var_v1 < size; var_v1++)```
* The diff gets massive.
*/
if (size > 0) {
loop_3:
for (count = 0; count < size; count++) {
if (*id == NULL_OBJECT_ID) {
objectIndex = find_unused_obj_index(id);
*nextFree += 1;
break;
} else {
*nextFree += 1;
if (*nextFree >= size) {
*nextFree = 0;
}
count += 1;
id = &listIdx[*nextFree];
if (count != size) { // check if don't check all element of the list
goto loop_3;
}
}
}
if (count == size) {