mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 23:44:40 +00:00
Priority Fixes (20200405) (#347)
* no longer assuming non-empty equipment slot; restructured the equipment CLOB to remove Option.get assumptions * bundling move item packets
This commit is contained in:
parent
610f0b092f
commit
840006dca8
1 changed files with 48 additions and 68 deletions
|
|
@ -4812,14 +4812,16 @@ class WorldSessionActor extends Actor
|
||||||
}
|
}
|
||||||
} && indexSlot.Equipment.contains(item)) {
|
} && indexSlot.Equipment.contains(item)) {
|
||||||
if(PermitEquipmentStow(item, destination)) {
|
if(PermitEquipmentStow(item, destination)) {
|
||||||
|
StartBundlingPackets()
|
||||||
PerformMoveItem(item, source, index, destination, dest, destItemEntry)
|
PerformMoveItem(item, source, index, destination, dest, destItemEntry)
|
||||||
|
StopBundlingPackets()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.error(s"MoveItem: $item disallowed storage in $destination")
|
log.error(s"MoveItem: $item disallowed storage in $destination")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!indexSlot.Equipment.contains(item)) {
|
else if(!indexSlot.Equipment.contains(item)) {
|
||||||
log.error(s"MoveItem: wanted to move $item_guid, but found unexpected ${indexSlot.Equipment.get} at source location")
|
log.error(s"MoveItem: wanted to move $item_guid, but found unexpected ${indexSlot.Equipment} at source location")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
destinationCollisionTest match {
|
destinationCollisionTest match {
|
||||||
|
|
@ -4862,7 +4864,9 @@ class WorldSessionActor extends Actor
|
||||||
}, target.Fit(item)) match {
|
}, target.Fit(item)) match {
|
||||||
case (Some((source, Some(index))), Some(dest)) =>
|
case (Some((source, Some(index))), Some(dest)) =>
|
||||||
if(PermitEquipmentStow(item, target)) {
|
if(PermitEquipmentStow(item, target)) {
|
||||||
|
StartBundlingPackets()
|
||||||
PerformMoveItem(item, source, index, target, dest, None)
|
PerformMoveItem(item, source, index, target, dest, None)
|
||||||
|
StopBundlingPackets()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.error(s"LootItem: $item disallowed storage in $target")
|
log.error(s"LootItem: $item disallowed storage in $target")
|
||||||
|
|
@ -10080,76 +10084,33 @@ class WorldSessionActor extends Actor
|
||||||
}
|
}
|
||||||
|
|
||||||
def SaveLoadoutToDB(owner : Player, label : String, line : Int) = {
|
def SaveLoadoutToDB(owner : Player, label : String, line : Int) = {
|
||||||
var megaList : String = ""
|
val charId = owner.CharId
|
||||||
var localType : String = ""
|
val exosuitId = owner.ExoSuit.id
|
||||||
var ammoInfo : String = ""
|
var clob : String = {
|
||||||
(0 until 5).foreach(index => {
|
val clobber : StringBuilder = new StringBuilder()
|
||||||
if(owner.Slot(index).Equipment.isDefined) {
|
//encode holsters
|
||||||
owner.Slot(index).Equipment.get match {
|
owner.Holsters()
|
||||||
case test : Tool =>
|
.zipWithIndex
|
||||||
localType = "Tool"
|
.collect { case (slot, index) if slot.Equipment.nonEmpty =>
|
||||||
case test : AmmoBox =>
|
clobber.append(EncodeLoadoutCLOBFragment(slot.Equipment.get, index))
|
||||||
localType = "AmmoBox"
|
|
||||||
case test : ConstructionItem =>
|
|
||||||
localType = "ConstructionItem"
|
|
||||||
case test : BoomerTrigger =>
|
|
||||||
localType = "BoomerTrigger"
|
|
||||||
case test : SimpleItem =>
|
|
||||||
localType = "SimpleItem"
|
|
||||||
case test : Kit =>
|
|
||||||
localType = "Kit"
|
|
||||||
case _ =>
|
|
||||||
localType = ""
|
|
||||||
}
|
}
|
||||||
if(localType == "Tool") {
|
//encode inventory
|
||||||
owner.Slot(index).Equipment.get.asInstanceOf[Tool].AmmoSlots.indices.foreach(index2 => {
|
owner.Inventory.Items.foreach { case InventoryItem(obj, index) =>
|
||||||
if (owner.Slot(index).Equipment.get.asInstanceOf[Tool].AmmoSlots(index2).AmmoTypeIndex != 0) {
|
clobber.append(EncodeLoadoutCLOBFragment(obj, index))
|
||||||
ammoInfo = ammoInfo+"_"+index2+"-"+owner.Slot(index).Equipment.get.asInstanceOf[Tool].AmmoSlots(index2).AmmoTypeIndex+"-"+owner.Slot(index).Equipment.get.asInstanceOf[Tool].AmmoSlots(index2).AmmoType.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
megaList = megaList + "/" + localType + "," + index + "," + owner.Slot(index).Equipment.get.Definition.ObjectId + "," + ammoInfo
|
|
||||||
ammoInfo = ""
|
|
||||||
}
|
}
|
||||||
})
|
clobber.mkString
|
||||||
owner.Inventory.Items.foreach(test => {
|
}
|
||||||
test.obj match {
|
//database
|
||||||
case test : Tool =>
|
|
||||||
localType = "Tool"
|
|
||||||
case test : AmmoBox =>
|
|
||||||
localType = "AmmoBox"
|
|
||||||
case test : ConstructionItem =>
|
|
||||||
localType = "ConstructionItem"
|
|
||||||
case test : BoomerTrigger =>
|
|
||||||
localType = "BoomerTrigger"
|
|
||||||
case test : SimpleItem =>
|
|
||||||
localType = "SimpleItem"
|
|
||||||
case test : Kit =>
|
|
||||||
localType = "Kit"
|
|
||||||
case _ =>
|
|
||||||
localType = ""
|
|
||||||
}
|
|
||||||
if(localType == "Tool") {
|
|
||||||
owner.Slot(test.start).Equipment.get.asInstanceOf[Tool].AmmoSlots.indices.foreach(index2 => {
|
|
||||||
if (owner.Slot(test.start).Equipment.get.asInstanceOf[Tool].AmmoSlots(index2).AmmoTypeIndex != 0) {
|
|
||||||
ammoInfo = ammoInfo+"_"+index2+"-"+owner.Slot(test.start).Equipment.get.asInstanceOf[Tool].AmmoSlots(index2).AmmoTypeIndex+"-"+owner.Slot(test.start).Equipment.get.asInstanceOf[Tool].AmmoSlots(index2).AmmoType.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
megaList = megaList + "/" + localType + "," + test.start + "," + owner.Slot(test.start).Equipment.get.Definition.ObjectId + "," + ammoInfo
|
|
||||||
ammoInfo = ""
|
|
||||||
})
|
|
||||||
|
|
||||||
Database.getConnection.connect.onComplete {
|
Database.getConnection.connect.onComplete {
|
||||||
case scala.util.Success(connection) =>
|
case scala.util.Success(connection) =>
|
||||||
Database.query(connection.sendPreparedStatement(
|
Database.query(connection.sendPreparedStatement(
|
||||||
"SELECT id, exosuit_id, name, items FROM loadouts where characters_id = ? AND loadout_number = ?", Array(owner.CharId, line)
|
"SELECT id, exosuit_id, name, items FROM loadouts where characters_id = ? AND loadout_number = ?", Array(charId, line)
|
||||||
)).onComplete {
|
)).onComplete {
|
||||||
case scala.util.Success(queryResult) =>
|
case scala.util.Success(queryResult) =>
|
||||||
queryResult match {
|
queryResult match {
|
||||||
case row: ArrayRowData => // Update
|
case row: ArrayRowData => // Update
|
||||||
connection.sendPreparedStatement(
|
connection.sendPreparedStatement(
|
||||||
"UPDATE loadouts SET exosuit_id=?, name=?, items=? where id=?", Array(owner.ExoSuit.id, label, megaList.drop(1), row(0))
|
"UPDATE loadouts SET exosuit_id=?, name=?, items=? where id=?", Array(exosuitId, label, clob.drop(1), row(0))
|
||||||
).onComplete {
|
).onComplete {
|
||||||
case _ =>
|
case _ =>
|
||||||
if(connection.isConnected) connection.disconnect
|
if(connection.isConnected) connection.disconnect
|
||||||
|
|
@ -10158,7 +10119,7 @@ class WorldSessionActor extends Actor
|
||||||
case _ => // Save
|
case _ => // Save
|
||||||
connection.sendPreparedStatement(
|
connection.sendPreparedStatement(
|
||||||
"INSERT INTO loadouts (characters_id, loadout_number, exosuit_id, name, items) VALUES(?,?,?,?,?) RETURNING id",
|
"INSERT INTO loadouts (characters_id, loadout_number, exosuit_id, name, items) VALUES(?,?,?,?,?) RETURNING id",
|
||||||
Array(owner.CharId, line, owner.ExoSuit.id, label, megaList.drop(1))
|
Array(charId, line, exosuitId, label, clob.drop(1))
|
||||||
).onComplete {
|
).onComplete {
|
||||||
case _ =>
|
case _ =>
|
||||||
if(connection.isConnected) connection.disconnect
|
if(connection.isConnected) connection.disconnect
|
||||||
|
|
@ -10170,10 +10131,31 @@ class WorldSessionActor extends Actor
|
||||||
log.error(s"SaveLoadoutToDB: query failed - ${e.getMessage}")
|
log.error(s"SaveLoadoutToDB: query failed - ${e.getMessage}")
|
||||||
}
|
}
|
||||||
case scala.util.Failure(e) =>
|
case scala.util.Failure(e) =>
|
||||||
log.error(s"SaveLoadoutToDB: no conenction ${e.getMessage}")
|
log.error(s"SaveLoadoutToDB: no connection ${e.getMessage}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* na
|
||||||
|
* @param equipment
|
||||||
|
* @param index
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
def EncodeLoadoutCLOBFragment(equipment : Equipment, index : Int) : String = {
|
||||||
|
val ammoInfo : String = equipment match {
|
||||||
|
case tool : Tool =>
|
||||||
|
tool.AmmoSlots
|
||||||
|
.zipWithIndex
|
||||||
|
.collect { case (ammoSlot, index2) if ammoSlot.AmmoTypeIndex != 0 =>
|
||||||
|
s"_$index2-${ammoSlot.AmmoTypeIndex}-${ammoSlot.AmmoType.id}"
|
||||||
|
}
|
||||||
|
.mkString
|
||||||
|
case _ =>
|
||||||
|
""
|
||||||
|
}
|
||||||
|
s"/${equipment.getClass.getSimpleName},$index,${equipment.Definition.ObjectId},$ammoInfo"
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A selection of up to ten customized equipment loadouts that are saved externally.
|
* A selection of up to ten customized equipment loadouts that are saved externally.
|
||||||
* The loadouts are encoded through number and text and procedural assembly is required.
|
* The loadouts are encoded through number and text and procedural assembly is required.
|
||||||
|
|
@ -10233,16 +10215,14 @@ class WorldSessionActor extends Actor
|
||||||
doll.Slot(lIndex).Equipment = AmmoBox(GetToolDefFromObjectID(lObjectId).asInstanceOf[AmmoBoxDefinition])
|
doll.Slot(lIndex).Equipment = AmmoBox(GetToolDefFromObjectID(lObjectId).asInstanceOf[AmmoBoxDefinition])
|
||||||
case "ConstructionItem" =>
|
case "ConstructionItem" =>
|
||||||
doll.Slot(lIndex).Equipment = ConstructionItem(GetToolDefFromObjectID(lObjectId).asInstanceOf[ConstructionItemDefinition])
|
doll.Slot(lIndex).Equipment = ConstructionItem(GetToolDefFromObjectID(lObjectId).asInstanceOf[ConstructionItemDefinition])
|
||||||
case "BoomerTrigger" =>
|
|
||||||
log.error("LoadDataBaseLoadouts: found a BoomerTrigger in a loadout?!")
|
|
||||||
case "SimpleItem" =>
|
case "SimpleItem" =>
|
||||||
doll.Slot(lIndex).Equipment = SimpleItem(GetToolDefFromObjectID(lObjectId).asInstanceOf[SimpleItemDefinition])
|
doll.Slot(lIndex).Equipment = SimpleItem(GetToolDefFromObjectID(lObjectId).asInstanceOf[SimpleItemDefinition])
|
||||||
case "Kit" =>
|
case "Kit" =>
|
||||||
doll.Slot(lIndex).Equipment = Kit(GetToolDefFromObjectID(lObjectId).asInstanceOf[KitDefinition])
|
doll.Slot(lIndex).Equipment = Kit(GetToolDefFromObjectID(lObjectId).asInstanceOf[KitDefinition])
|
||||||
case _ =>
|
case thing =>
|
||||||
log.error("LoadDataBaseLoadouts: what's that item in the loadout?!")
|
log.warn(s"LoadDataBaseLoadouts: what's that $thing doing in the loadout?")
|
||||||
}
|
}
|
||||||
if (args2.length == 4) {
|
if (args2.length == 4) { //tool ammo info
|
||||||
val args3 = args2(3).split("_")
|
val args3 = args2(3).split("_")
|
||||||
(1 until args3.length).foreach(j => {
|
(1 until args3.length).foreach(j => {
|
||||||
val args4 = args3(j).split("-")
|
val args4 = args3(j).split("-")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue