Archive the weapon clip amount in persistent data

This commit is contained in:
smallmodel 2024-03-06 19:33:39 +01:00
parent 6675a491be
commit 98c61529b9
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -2214,11 +2214,25 @@ void Sentient::ArchivePersistantData(Archiver& arc)
error("ArchivePersistantData", "Non Item in inventory\n");
}
}
arc.ArchiveString(&name);
arc.ArchiveInteger(&amount);
if (arc.Loading()) {
item = giveItem(name, amount);
}
if (item && item->IsSubclassOfWeapon()) {
Weapon* pWeap = static_cast<Weapon*>(item);
item->CancelEventsOfType(EV_Weapon_GiveStartingAmmo);
if (arc.Saving()) {
amount = pWeap->ClipAmmo(FIRE_PRIMARY);
}
arc.ArchiveInteger(&amount);
if (arc.Loading()) {
pWeap->SetAmmoAmount(amount, FIRE_PRIMARY);
}
}
}