Fix car charging bugs

This commit is contained in:
Alexander Batalov 2022-08-06 17:49:24 +03:00
parent 02e83a1989
commit d8ae5fbd32
1 changed files with 15 additions and 4 deletions

View File

@ -927,6 +927,9 @@ static int _obj_use_power_on_car(Object* item)
return -1; return -1;
} }
// SFALL: Fix for cells getting consumed even when the car is already fully
// charged.
int rc;
if (carGetFuel() < CAR_FUEL_MAX) { if (carGetFuel() < CAR_FUEL_MAX) {
int energy = ammoGetQuantity(item) * energyDensity; int energy = ammoGetQuantity(item) * energyDensity;
int capacity = ammoGetCapacity(item); int capacity = ammoGetCapacity(item);
@ -938,15 +941,17 @@ static int _obj_use_power_on_car(Object* item)
// You charge the car with more power. // You charge the car with more power.
messageNum = 595; messageNum = 595;
rc = 1;
} else { } else {
// The car is already full of power. // The car is already full of power.
messageNum = 596; messageNum = 596;
rc = 0;
} }
char* text = getmsg(&gProtoMessageList, &messageListItem, messageNum); char* text = getmsg(&gProtoMessageList, &messageListItem, messageNum);
displayMonitorAddMessage(text); displayMonitorAddMessage(text);
return 1; return rc;
} }
// 0x49BE88 // 0x49BE88
@ -1180,9 +1185,15 @@ static int _protinst_default_use_item(Object* a1, Object* a2, Object* item)
return rc; return rc;
case ITEM_TYPE_AMMO: case ITEM_TYPE_AMMO:
// SFALL: Fix for being able to charge the car by using cells on other
// scenery/critters.
if (a2->pid == PROTO_ID_CAR || a2->pid == PROTO_ID_CAR_TRUNK) {
rc = _obj_use_power_on_car(item); rc = _obj_use_power_on_car(item);
if (rc == 1) { if (rc == 1) {
return 1; return 1;
} else if (rc == 0) {
return -1;
}
} }
break; break;
case ITEM_TYPE_WEAPON: case ITEM_TYPE_WEAPON: