Add opSetWeaponAmmoPid
This commit is contained in:
parent
17a4ee8a68
commit
3b951b8578
|
@ -163,6 +163,30 @@ static void opGetWeaponAmmoPid(Program* program)
|
|||
programStackPushInteger(program, pid);
|
||||
}
|
||||
|
||||
// There are two problems with this function.
|
||||
//
|
||||
// 1. Sfall's implementation changes ammo PID of misc items, which is impossible
|
||||
// since it's stored in proto, not in the object.
|
||||
// 2. Changing weapon's ammo PID is done without checking for ammo
|
||||
// quantity/capacity which can probably lead to bad things.
|
||||
//
|
||||
// set_weapon_ammo_pid
|
||||
static void opSetWeaponAmmoPid(Program* program)
|
||||
{
|
||||
int ammoTypePid = programStackPopInteger(program);
|
||||
Object* obj = static_cast<Object*>(programStackPopPointer(program));
|
||||
|
||||
if (obj != nullptr) {
|
||||
if (PID_TYPE(obj->pid) == OBJ_TYPE_ITEM) {
|
||||
switch (itemGetType(obj)) {
|
||||
case ITEM_TYPE_WEAPON:
|
||||
obj->data.item.weapon.ammoTypePid = ammoTypePid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get_weapon_ammo_count
|
||||
static void opGetWeaponAmmoCount(Program* program)
|
||||
{
|
||||
|
@ -297,6 +321,7 @@ void sfallOpcodesInit()
|
|||
interpreterRegisterOpcode(0x8211, opGetVersionMinor);
|
||||
interpreterRegisterOpcode(0x8212, opGetVersionPatch);
|
||||
interpreterRegisterOpcode(0x8217, opGetWeaponAmmoPid);
|
||||
interpreterRegisterOpcode(0x8218, opSetWeaponAmmoPid);
|
||||
interpreterRegisterOpcode(0x8219, opGetWeaponAmmoCount);
|
||||
interpreterRegisterOpcode(0x821A, opSetWeaponAmmoCount);
|
||||
interpreterRegisterOpcode(0x821C, opGetMouseX);
|
||||
|
|
Loading…
Reference in New Issue