Fix amount of credits handed out in GotCredits (#198)

This commit is contained in:
Anonymous Maarten 2022-10-16 10:13:39 +02:00 committed by GitHub
parent 4689b4e9a6
commit 1dab154c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -1368,12 +1368,11 @@ void EarnCredits2(int pAmount, char* pPrefix_text) {
if (pAmount == 0) {
return;
}
if (gNet_mode != eNet_mode_none && (gProgram_state.credits_earned - gProgram_state.credits_lost + pAmount) < 0) {
// Should this also substract pAmount?
if (gNet_mode != eNet_mode_none && gProgram_state.credits_earned - gProgram_state.credits_lost + pAmount < 0) {
pAmount = gProgram_state.credits_lost - gProgram_state.credits_lost;
}
original_amount = pAmount;
if (gLast_credit_headup__displays >= 0 && (the_time - gLast_earn_time) < 2000) {
if (gLast_credit_headup__displays >= 0 && the_time - gLast_earn_time < 2000) {
pAmount += gLast_credit_amount;
}
gLast_credit_amount = pAmount;
@ -1384,7 +1383,7 @@ void EarnCredits2(int pAmount, char* pPrefix_text) {
sprintf(s, "%s1 %s", pPrefix_text, GetMiscString(13));
gProgram_state.credits_earned += original_amount;
} else if (pAmount >= -1) {
sprintf(s, "%s%s 1 %s", pPrefix_text, GetMiscString(14), GetMiscString(15));
sprintf(s, "%s%s 1 %s", pPrefix_text, GetMiscString(14), GetMiscString(13));
gProgram_state.credits_lost -= original_amount;
} else {
sprintf(s, "%s%s %d %s", GetMiscString(14), pPrefix_text, -pAmount, GetMiscString(12));

View File

@ -356,12 +356,12 @@ void LoadPowerups() {
the_powerup->got_proc = NULL;
}
the_powerup->number_of_float_params = GetAnInt(f);
the_powerup->float_params = BrMemAllocate(4 * the_powerup->number_of_float_params, kMem_powerup_float_parms);
the_powerup->float_params = BrMemAllocate(sizeof(float) * the_powerup->number_of_float_params, kMem_powerup_float_parms);
for (j = 0; j < the_powerup->number_of_float_params; j++) {
the_powerup->float_params[j] = GetAFloat(f);
}
the_powerup->number_of_integer_params = GetAnInt(f);
the_powerup->integer_params = BrMemAllocate(4 * the_powerup->number_of_integer_params, kMem_powerup_int_parms);
the_powerup->integer_params = BrMemAllocate(sizeof(int) * the_powerup->number_of_integer_params, kMem_powerup_int_parms);
for (j = 0; j < the_powerup->number_of_integer_params; j++) {
the_powerup->integer_params[j] = GetAnInt(f);
}
@ -578,7 +578,7 @@ int GotCredits(tPowerup* pPowerup, tCar_spec* pCar) {
if (pCar->driver == eDriver_local_human) {
strcpy(s, pPowerup->message);
strcat(s, " ");
EarnCredits2((IRandomBetween(pPowerup->integer_params[0], pPowerup->integer_params[1] / 100) * 100), s);
EarnCredits2((IRandomBetween(pPowerup->integer_params[0], pPowerup->integer_params[1]) / 100) * 100, s);
}
return GET_POWERUP_INDEX(pPowerup);
}