Page 1 of 1

GiveDefaultInventory() always gives another BasicArmor

PostPosted: Fri Jun 14, 2019 1:39 am
by FishyClockwork
IE it gives another one without checking if the player already has one.
https://github.com/coelckers/gzdoom/blob/2d1c7ba17cac3ccd201e77ad01a9dd06ab22cb2e/wadsrc/static/zscript/actors/player/player.zs#L1837

I only noticed this while playing a mapset that utilizes ResetInventory in its MAPINFO by typing printinv right after finishing a map (was testing stuff) and seeing multiple BasicArmors being listed.

As I understand it, there should be only one "BasicArmor" in the inventory chain at any time.

Quick edit: was testing in 4.1.3

Re: GiveDefaultInventory() always gives another BasicArmor

PostPosted: Fri Jun 14, 2019 1:56 am
by Graf Zahl
This function was actually never meant to be called on a PlayerPawn with an initialized inventory. It really should clear the entire inventory before doing its stuff.

Re: GiveDefaultInventory() always gives another BasicArmor

PostPosted: Fri Jun 14, 2019 2:06 am
by FishyClockwork
Hmm. In that case maybe change ClearInventory() to DestroyAllInventory() here?
[EDIT]Nevermind. I think mental has the right approach.[/EDIT]

Again, I found out about this without any custom PlayerPawn actors.

Re: GiveDefaultInventory() always gives another BasicArmor

PostPosted: Fri Jun 14, 2019 2:08 am
by _mental_
In my opinion, these lines
Code: Select allExpand view
let barmor = BasicArmor(Spawn('BasicArmor'));
barmor.BecomeItem ();
AddInventory (barmor);

should be replaced with
Code: Select allExpand view
GiveInventoryType('BasicArmor');

It's the same thing that already works for Hexen armor.

Re: GiveDefaultInventory() always gives another BasicArmor

PostPosted: Wed Jul 17, 2019 1:07 pm
by Graf Zahl
fixed