mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 07:24:53 +00:00
improved object name exposure for log messages; removed 'init with GUID' constructors that were no longer necessary
This commit is contained in:
parent
65c8de0790
commit
1d956c834c
12 changed files with 228 additions and 43 deletions
|
|
@ -45,7 +45,7 @@ object AmmoBox {
|
||||||
*/
|
*/
|
||||||
def Split(box : AmmoBox) : List[AmmoBox] = {
|
def Split(box : AmmoBox) : List[AmmoBox] = {
|
||||||
val ammoDef = box.Definition
|
val ammoDef = box.Definition
|
||||||
var boxCap : Int = box.Capacity
|
val boxCap : Int = box.Capacity
|
||||||
val maxCap : Int = ammoDef.Capacity
|
val maxCap : Int = ammoDef.Capacity
|
||||||
val splitCap : Int = boxCap / maxCap
|
val splitCap : Int = boxCap / maxCap
|
||||||
val list : List[AmmoBox] = List.fill(splitCap)(new AmmoBox(ammoDef))
|
val list : List[AmmoBox] = List.fill(splitCap)(new AmmoBox(ammoDef))
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,12 @@ class Avatar(val name : String, val faction : PlanetSideEmpire.Value, val sex :
|
||||||
private val implants : Array[ImplantSlot] = Array.fill[ImplantSlot](3)(new ImplantSlot)
|
private val implants : Array[ImplantSlot] = Array.fill[ImplantSlot](3)(new ImplantSlot)
|
||||||
/** Loadouts */
|
/** Loadouts */
|
||||||
private val loadouts : Array[Option[Loadout]] = Array.fill[Option[Loadout]](10)(None)
|
private val loadouts : Array[Option[Loadout]] = Array.fill[Option[Loadout]](10)(None)
|
||||||
/** Locker (fifth inventory slot) */
|
/** Locker (inventory slot number five) */
|
||||||
private val locker : LockerContainer = LockerContainer()
|
private val locker : LockerContainer = new LockerContainer() {
|
||||||
|
override def toString : String = {
|
||||||
|
s"$name's ${Definition.Name}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def BEP : Long = bep
|
def BEP : Long = bep
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,4 @@ object ConstructionItem {
|
||||||
def apply(cItemDef : ConstructionItemDefinition) : ConstructionItem = {
|
def apply(cItemDef : ConstructionItemDefinition) : ConstructionItem = {
|
||||||
new ConstructionItem(cItemDef)
|
new ConstructionItem(cItemDef)
|
||||||
}
|
}
|
||||||
|
|
||||||
import net.psforever.packet.game.PlanetSideGUID
|
|
||||||
def apply(guid : PlanetSideGUID, cItemDef : ConstructionItemDefinition) : ConstructionItem = {
|
|
||||||
val obj = new ConstructionItem(cItemDef)
|
|
||||||
obj.GUID = guid
|
|
||||||
obj
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -16,11 +16,4 @@ object Kit {
|
||||||
def apply(kitDef : KitDefinition) : Kit = {
|
def apply(kitDef : KitDefinition) : Kit = {
|
||||||
new Kit(kitDef)
|
new Kit(kitDef)
|
||||||
}
|
}
|
||||||
|
|
||||||
import net.psforever.packet.game.PlanetSideGUID
|
|
||||||
def apply(guid : PlanetSideGUID, kitDef : KitDefinition) : Kit = {
|
|
||||||
val obj = new Kit(kitDef)
|
|
||||||
obj.GUID = guid
|
|
||||||
obj
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ abstract class PlanetSideGameObject extends IdentifiableEntity with WorldEntity
|
||||||
|
|
||||||
object PlanetSideGameObject {
|
object PlanetSideGameObject {
|
||||||
def toString(obj : PlanetSideGameObject) : String = {
|
def toString(obj : PlanetSideGameObject) : String = {
|
||||||
val guid : String = try { obj.GUID.guid.toString } catch { case _ : Exception => "NOGUID" }
|
val guid : String = if(obj.HasGUID) { obj.GUID.toString } else { "NOGUID" }
|
||||||
val P = obj.Position
|
val P = obj.Position
|
||||||
s"[$guid](x,y,z=${P.x%.3f},${P.y%.3f},${P.z%.3f})"
|
s"[$guid](x,y,z=${P.x%.3f},${P.y%.3f},${P.z%.3f})"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,4 @@ object SimpleItem {
|
||||||
def apply(simpDef : SimpleItemDefinition) : SimpleItem = {
|
def apply(simpDef : SimpleItemDefinition) : SimpleItem = {
|
||||||
new SimpleItem(simpDef)
|
new SimpleItem(simpDef)
|
||||||
}
|
}
|
||||||
|
|
||||||
import net.psforever.packet.game.PlanetSideGUID
|
|
||||||
def apply(guid : PlanetSideGUID, simpDef : SimpleItemDefinition) : SimpleItem = {
|
|
||||||
val obj = new SimpleItem(simpDef)
|
|
||||||
obj.GUID = guid
|
|
||||||
obj
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,14 @@ abstract class Equipment extends PlanetSideGameObject {
|
||||||
def Tile : InventoryTile = Definition.Tile
|
def Tile : InventoryTile = Definition.Tile
|
||||||
|
|
||||||
def Definition : EquipmentDefinition
|
def Definition : EquipmentDefinition
|
||||||
|
|
||||||
|
override def toString : String = {
|
||||||
|
Equipment.toString(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object Equipment {
|
||||||
|
def toString(obj : Equipment) : String = {
|
||||||
|
obj.Definition.Name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ class GridInventory extends Container {
|
||||||
* @param tile the dimensions of the blank space
|
* @param tile the dimensions of the blank space
|
||||||
* @return the grid index of the upper left corner where equipment to which the `tile` belongs should be placed
|
* @return the grid index of the upper left corner where equipment to which the `tile` belongs should be placed
|
||||||
*/
|
*/
|
||||||
def Fit(tile : InventoryTile) : Option[Int] = {
|
override def Fit(tile : InventoryTile) : Option[Int] = {
|
||||||
val tWidth = tile.Width
|
val tWidth = tile.Width
|
||||||
val tHeight = tile.Height
|
val tHeight = tile.Height
|
||||||
val gridIter = (0 until (grid.length - (tHeight - 1) * width))
|
val gridIter = (0 until (grid.length - (tHeight - 1) * width))
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,8 @@ class ConverterTest extends Specification {
|
||||||
"Kit" should {
|
"Kit" should {
|
||||||
"convert to packet" in {
|
"convert to packet" in {
|
||||||
val kdef = KitDefinition(Kits.medkit)
|
val kdef = KitDefinition(Kits.medkit)
|
||||||
val obj = Kit(PlanetSideGUID(90), kdef)
|
val obj = Kit(kdef)
|
||||||
|
obj.GUID = PlanetSideGUID(90)
|
||||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||||
case Success(pkt) =>
|
case Success(pkt) =>
|
||||||
pkt mustEqual DetailedAmmoBoxData(0, 1)
|
pkt mustEqual DetailedAmmoBoxData(0, 1)
|
||||||
|
|
@ -113,7 +114,8 @@ class ConverterTest extends Specification {
|
||||||
cdef.Modes += DeployedItem.deployable_shield_generator
|
cdef.Modes += DeployedItem.deployable_shield_generator
|
||||||
cdef.Tile = InventoryTile.Tile63
|
cdef.Tile = InventoryTile.Tile63
|
||||||
cdef.Packet = new ACEConverter()
|
cdef.Packet = new ACEConverter()
|
||||||
val obj = ConstructionItem(PlanetSideGUID(90), cdef)
|
val obj = ConstructionItem(cdef)
|
||||||
|
obj.GUID = PlanetSideGUID(90)
|
||||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||||
case Success(pkt) =>
|
case Success(pkt) =>
|
||||||
pkt mustEqual DetailedACEData(0)
|
pkt mustEqual DetailedACEData(0)
|
||||||
|
|
@ -134,7 +136,8 @@ class ConverterTest extends Specification {
|
||||||
"convert to packet" in {
|
"convert to packet" in {
|
||||||
val sdef = SimpleItemDefinition(SItem.remote_electronics_kit)
|
val sdef = SimpleItemDefinition(SItem.remote_electronics_kit)
|
||||||
sdef.Packet = new REKConverter()
|
sdef.Packet = new REKConverter()
|
||||||
val obj = SimpleItem(PlanetSideGUID(90), sdef)
|
val obj = SimpleItem(sdef)
|
||||||
|
obj.GUID = PlanetSideGUID(90)
|
||||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||||
case Success(pkt) =>
|
case Success(pkt) =>
|
||||||
pkt mustEqual DetailedREKData(8)
|
pkt mustEqual DetailedREKData(8)
|
||||||
|
|
|
||||||
|
|
@ -306,9 +306,9 @@ class InventoryTest extends Specification {
|
||||||
sampleDef63.Tile = InventoryTile.Tile63
|
sampleDef63.Tile = InventoryTile.Tile63
|
||||||
|
|
||||||
val obj : GridInventory = GridInventory(9, 9)
|
val obj : GridInventory = GridInventory(9, 9)
|
||||||
obj += 0 -> SimpleItem(PlanetSideGUID(0), sampleDef22)
|
obj += 0 -> SimpleItem(sampleDef22)
|
||||||
obj += 20 -> SimpleItem(PlanetSideGUID(1), sampleDef63)
|
obj += 20 -> SimpleItem(sampleDef63)
|
||||||
obj += 56 -> SimpleItem(PlanetSideGUID(2), sampleDef33)
|
obj += 56 -> SimpleItem(sampleDef33)
|
||||||
obj.Fit(InventoryTile.Tile33) match {
|
obj.Fit(InventoryTile.Tile33) match {
|
||||||
case Some(x) =>
|
case Some(x) =>
|
||||||
x mustEqual 50
|
x mustEqual 50
|
||||||
|
|
@ -329,14 +329,14 @@ class InventoryTest extends Specification {
|
||||||
sampleDef4.Tile = InventoryTile.Tile63
|
sampleDef4.Tile = InventoryTile.Tile63
|
||||||
|
|
||||||
val list : ListBuffer[InventoryItem] = ListBuffer()
|
val list : ListBuffer[InventoryItem] = ListBuffer()
|
||||||
list += new InventoryItem(SimpleItem(PlanetSideGUID(0), sampleDef2), -1)
|
list += new InventoryItem(SimpleItem(sampleDef2), -1)
|
||||||
list += new InventoryItem(SimpleItem(PlanetSideGUID(1), sampleDef3), -1)
|
list += new InventoryItem(SimpleItem(sampleDef3), -1)
|
||||||
list += new InventoryItem(SimpleItem(PlanetSideGUID(2), sampleDef1), -1)
|
list += new InventoryItem(SimpleItem(sampleDef1), -1)
|
||||||
list += new InventoryItem(SimpleItem(PlanetSideGUID(3), sampleDef4), -1)
|
list += new InventoryItem(SimpleItem(sampleDef4), -1)
|
||||||
list += new InventoryItem(SimpleItem(PlanetSideGUID(4), sampleDef1), -1)
|
list += new InventoryItem(SimpleItem(sampleDef1), -1)
|
||||||
list += new InventoryItem(SimpleItem(PlanetSideGUID(5), sampleDef4), -1)
|
list += new InventoryItem(SimpleItem(sampleDef4), -1)
|
||||||
list += new InventoryItem(SimpleItem(PlanetSideGUID(6), sampleDef2), -1)
|
list += new InventoryItem(SimpleItem(sampleDef2), -1)
|
||||||
list += new InventoryItem(SimpleItem(PlanetSideGUID(7), sampleDef3), -1)
|
list += new InventoryItem(SimpleItem(sampleDef3), -1)
|
||||||
val obj : GridInventory = GridInventory(9, 9)
|
val obj : GridInventory = GridInventory(9, 9)
|
||||||
|
|
||||||
val (elements, out) = GridInventory.recoverInventory(list.toList, obj)
|
val (elements, out) = GridInventory.recoverInventory(list.toList, obj)
|
||||||
|
|
|
||||||
|
|
@ -3440,9 +3440,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
val item_guid = item.GUID
|
val item_guid = item.GUID
|
||||||
val source_guid = source.GUID
|
val source_guid = source.GUID
|
||||||
val destination_guid = destination.GUID
|
val destination_guid = destination.GUID
|
||||||
val indexSlot = source.Slot(index)
|
|
||||||
val player_guid = player.GUID
|
val player_guid = player.GUID
|
||||||
val sourceIsNotDestination : Boolean = source != destination //if source is destination, OCDM style is not required
|
val indexSlot = source.Slot(index)
|
||||||
|
val sourceIsNotDestination : Boolean = source != destination //if source is destination, explicit OCDM is not required
|
||||||
if(sourceIsNotDestination) {
|
if(sourceIsNotDestination) {
|
||||||
log.info(s"MoveItem: $item moved from $source @ $index to $destination @ $dest")
|
log.info(s"MoveItem: $item moved from $source @ $index to $destination @ $dest")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue