1
0
Fork 0

Fix: Improve manager face randomisation

pull/13787/head
Richard Wheeler 2025-03-08 22:47:27 +00:00 committed by rubidium42
parent ee45c8ec1d
commit 1eddd7fed0
1 changed files with 4 additions and 6 deletions

View File

@ -117,8 +117,7 @@ inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFac
/**
* Increase/Decrease the company manager's face variable by the given amount.
* If the new value greater than the max value for this variable it will be set to 0.
* Or is it negative (< 0) it will be set to max value.
* The value wraps around to stay in the valid range.
*
* @param cmf the company manager face to write the bits to
* @param cmfv the company manager face variable to write the data of
@ -132,11 +131,10 @@ inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManag
int8_t val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv
/* scales the new value to the correct scope */
if (val >= _cmf_info[cmfv].valid_values[ge]) {
val = 0;
} else if (val < 0) {
val = _cmf_info[cmfv].valid_values[ge] - 1;
while (val < 0) {
val += _cmf_info[cmfv].valid_values[ge];
}
val %= _cmf_info[cmfv].valid_values[ge];
SetCompanyManagerFaceBits(cmf, cmfv, ge, val); // save the new value
}