diff --git a/src/main/scala/net/psforever/objects/Tool.scala b/src/main/scala/net/psforever/objects/Tool.scala index 22284143..b5f4546c 100644 --- a/src/main/scala/net/psforever/objects/Tool.scala +++ b/src/main/scala/net/psforever/objects/Tool.scala @@ -183,7 +183,7 @@ object Tool { private var ammoTypeIndex: Int = 0 /** a reference to the actual `AmmoBox` of this slot */ - private var box: AmmoBox = AmmoBox(AmmoDefinition, fdef.Magazine) + private var box: AmmoBox = AmmoBox(AmmoDefinition, MaxMagazine()) private var chamber = fdef.Chamber def AmmoTypeIndex: Int = ammoTypeIndex @@ -223,6 +223,13 @@ object Tool { Chamber } + def MaxMagazine(): Int = { + fdef.CustomMagazine.get(AmmoType) match { + case Some(value) => value + case None => fdef.Magazine + } + } + def Box: AmmoBox = box def Box_=(toBox: AmmoBox): Option[AmmoBox] = { diff --git a/src/main/scala/net/psforever/objects/vehicles/control/VehicleControl.scala b/src/main/scala/net/psforever/objects/vehicles/control/VehicleControl.scala index 438fec3f..963d4984 100644 --- a/src/main/scala/net/psforever/objects/vehicles/control/VehicleControl.scala +++ b/src/main/scala/net/psforever/objects/vehicles/control/VehicleControl.scala @@ -178,10 +178,10 @@ class VehicleControl(vehicle: Vehicle) // (oldWeapons, weapons, afterInventory) //TODO for now, just refill ammo; assume weapons stay the same vehicle.Weapons - .collect { case (_, slot : EquipmentSlot) if slot.Equipment.nonEmpty => slot.Equipment.get } + .collect { case (_, slot: EquipmentSlot) if slot.Equipment.nonEmpty => slot.Equipment.get } .collect { - case weapon : Tool => - weapon.AmmoSlots.foreach { ammo => ammo.Box.Capacity = ammo.Box.Definition.Capacity } + case weapon: Tool => + weapon.AmmoSlots.foreach { ammo => ammo.Box.Capacity = ammo.MaxMagazine() } } (Nil, Nil, afterInventory) } @@ -486,11 +486,11 @@ class VehicleControl(vehicle: Vehicle) if (obj.VisibleSlots.contains(slot)) zone.id else channel, VehicleAction.SendResponse( Service.defaultPlayerGUID, - ObjectCreateMessage( + ObjectCreateDetailedMessage( definition.ObjectId, iguid, ObjectCreateMessageParent(oguid, slot), - definition.Packet.ConstructorData(item).get + definition.Packet.DetailedConstructorData(item).get ) ) )