@@ -689,17 +689,20 @@ func (p *parser) bindPlayerWeapons(playerEntity st.Entity, pl *common.Player) {
689689
690690func (p * parser ) bindPlayerWeaponsS2 (pawnEntity st.Entity , pl * common.Player ) {
691691 const inventoryCapacity = 64
692+
692693 var inventorySize uint64 = 64
693694
694695 type eq struct {
695696 * common.Equipment
696697 entityID int
697698 }
699+
698700 playerInventory := make (map [int ]eq )
699701
700702 getWep := func (wepSlotPropertyValue st.PropertyValue ) (uint64 , * common.Equipment ) {
701703 entityID := wepSlotPropertyValue .S2UInt64 () & constants .EntityHandleIndexMaskSource2
702704 wep := p .gameState .weapons [int (entityID )]
705+
703706 if wep == nil {
704707 // sometimes a weapon is assigned to a player before the weapon entity is created
705708 wep = common .NewEquipment (common .EqUnknown )
@@ -711,6 +714,7 @@ func (p *parser) bindPlayerWeaponsS2(pawnEntity st.Entity, pl *common.Player) {
711714
712715 setPlayerInventory := func () {
713716 inventory := make (map [int ]* common.Equipment , inventorySize )
717+
714718 for i := uint64 (0 ); i < inventorySize ; i ++ {
715719 val := pawnEntity .Property (playerWeaponPrefixS2 + fmt .Sprintf ("%04d" , i )).Value ()
716720 if val .Any == nil {
@@ -720,6 +724,7 @@ func (p *parser) bindPlayerWeaponsS2(pawnEntity st.Entity, pl *common.Player) {
720724 entityID , wep := getWep (val )
721725 inventory [int (entityID )] = wep
722726 }
727+
723728 pl .Inventory = inventory
724729 }
725730
@@ -759,6 +764,7 @@ func (p *parser) bindPlayerWeaponsS2(pawnEntity st.Entity, pl *common.Player) {
759764 setPlayerInventory ()
760765 }
761766 }
767+
762768 property := pawnEntity .Property (playerWeaponPrefixS2 + fmt .Sprintf ("%04d" , i ))
763769 updateWeapon (property .Value ())
764770 property .OnUpdate (updateWeapon )
0 commit comments