Check if env region index is greater than 0 (#285)

This commit is contained in:
Agent X 2023-02-19 21:20:45 -05:00 committed by GitHub
parent ea8e7b75d8
commit 761cd5b66b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -337,16 +337,14 @@ void movtexqc_register(const char* name, s16 level, s16 area, s16 type) {
/// ///
f32 get_environment_region(u8 index) { f32 get_environment_region(u8 index) {
if (gEnvironmentRegions != NULL && index <= gEnvironmentRegions[0]) { if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0]) {
return gEnvironmentRegions[6 * (int)index]; return gEnvironmentRegions[6 * (int)index];
} }
return gLevelValues.floorLowerLimit; return gLevelValues.floorLowerLimit;
} }
///
void set_environment_region(u8 index, s32 value) { void set_environment_region(u8 index, s32 value) {
if (gEnvironmentRegions != NULL && index <= gEnvironmentRegions[0]) { if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0]) {
gEnvironmentRegions[6 * (int)index] = value; gEnvironmentRegions[6 * (int)index] = value;
} }
} }