@@ -689,17 +689,20 @@ func (p *parser) bindPlayerWeapons(playerEntity st.Entity, pl *common.Player) {
689
689
690
690
func (p * parser ) bindPlayerWeaponsS2 (pawnEntity st.Entity , pl * common.Player ) {
691
691
const inventoryCapacity = 64
692
+
692
693
var inventorySize uint64 = 64
693
694
694
695
type eq struct {
695
696
* common.Equipment
696
697
entityID int
697
698
}
699
+
698
700
playerInventory := make (map [int ]eq )
699
701
700
702
getWep := func (wepSlotPropertyValue st.PropertyValue ) (uint64 , * common.Equipment ) {
701
703
entityID := wepSlotPropertyValue .S2UInt64 () & constants .EntityHandleIndexMaskSource2
702
704
wep := p .gameState .weapons [int (entityID )]
705
+
703
706
if wep == nil {
704
707
// sometimes a weapon is assigned to a player before the weapon entity is created
705
708
wep = common .NewEquipment (common .EqUnknown )
@@ -711,6 +714,7 @@ func (p *parser) bindPlayerWeaponsS2(pawnEntity st.Entity, pl *common.Player) {
711
714
712
715
setPlayerInventory := func () {
713
716
inventory := make (map [int ]* common.Equipment , inventorySize )
717
+
714
718
for i := uint64 (0 ); i < inventorySize ; i ++ {
715
719
val := pawnEntity .Property (playerWeaponPrefixS2 + fmt .Sprintf ("%04d" , i )).Value ()
716
720
if val .Any == nil {
@@ -720,6 +724,7 @@ func (p *parser) bindPlayerWeaponsS2(pawnEntity st.Entity, pl *common.Player) {
720
724
entityID , wep := getWep (val )
721
725
inventory [int (entityID )] = wep
722
726
}
727
+
723
728
pl .Inventory = inventory
724
729
}
725
730
@@ -759,6 +764,7 @@ func (p *parser) bindPlayerWeaponsS2(pawnEntity st.Entity, pl *common.Player) {
759
764
setPlayerInventory ()
760
765
}
761
766
}
767
+
762
768
property := pawnEntity .Property (playerWeaponPrefixS2 + fmt .Sprintf ("%04d" , i ))
763
769
updateWeapon (property .Value ())
764
770
property .OnUpdate (updateWeapon )
0 commit comments