corpses on the blockmap list of corpse entities will not displace revived players from the blockmap list of living player entities (#1071)

This commit is contained in:
Fate-JH 2023-04-27 12:12:10 -04:00 committed by GitHub
parent 72572ad125
commit a5a232ffdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,11 +120,11 @@ class SectorListOf[A](eqFunc: (A, A) => Boolean = (a: A, b: A) => a equals b) {
class Sector(val longitude: Int, val latitude: Int, val span: Int) class Sector(val longitude: Int, val latitude: Int, val span: Int)
extends SectorPopulation { extends SectorPopulation {
private val livePlayers: SectorListOf[Player] = new SectorListOf[Player]( private val livePlayers: SectorListOf[Player] = new SectorListOf[Player](
(a: Player, b: Player) => a.CharId == b.CharId (a: Player, b: Player) => a.GUID == b.GUID
) )
private val corpses: SectorListOf[Player] = new SectorListOf[Player]( private val corpses: SectorListOf[Player] = new SectorListOf[Player](
(a: Player, b: Player) => a.GUID == b.GUID || (a eq b) (a: Player, b: Player) => a eq b
) )
private val vehicles: SectorListOf[Vehicle] = new SectorListOf[Vehicle]( private val vehicles: SectorListOf[Vehicle] = new SectorListOf[Vehicle](
@ -140,11 +140,11 @@ class Sector(val longitude: Int, val latitude: Int, val span: Int)
) )
private val buildings: SectorListOf[Building] = new SectorListOf[Building]( private val buildings: SectorListOf[Building] = new SectorListOf[Building](
(a: Building, b: Building) => a eq b (a: Building, b: Building) => a.GUID == b.GUID
) )
private val amenities: SectorListOf[Amenity] = new SectorListOf[Amenity]( private val amenities: SectorListOf[Amenity] = new SectorListOf[Amenity](
(a: Amenity, b: Amenity) => a eq b (a: Amenity, b: Amenity) => a.GUID == b.GUID
) )
private val environment: SectorListOf[PieceOfEnvironment] = new SectorListOf[PieceOfEnvironment]( private val environment: SectorListOf[PieceOfEnvironment] = new SectorListOf[PieceOfEnvironment](
@ -185,16 +185,12 @@ class Sector(val longitude: Int, val latitude: Int, val span: Int)
*/ */
def addTo(o: BlockMapEntity): Boolean = { def addTo(o: BlockMapEntity): Boolean = {
o match { o match {
case p: Player => case p: Player if p.isBackpack =>
//players and corpses are the same kind of object, but are distinguished by a single flag
//when adding to the "corpse" list, first attempt to remove from the "player" list //when adding to the "corpse" list, first attempt to remove from the "player" list
if (!p.isBackpack) { livePlayers.removeFrom(p)
livePlayers.list.size < livePlayers.addTo(p).size corpses.list.size < corpses.addTo(p).size
} case p: Player =>
else { livePlayers.list.size < livePlayers.addTo(p).size
livePlayers.removeFrom(p)
corpses.list.size < corpses.addTo(p).size
}
case v: Vehicle => case v: Vehicle =>
vehicles.list.size < vehicles.addTo(v).size vehicles.list.size < vehicles.addTo(v).size
case e: Equipment => case e: Equipment =>
@ -222,9 +218,10 @@ class Sector(val longitude: Int, val latitude: Int, val span: Int)
*/ */
def removeFrom(o: Any): Boolean = { def removeFrom(o: Any): Boolean = {
o match { o match {
case p: Player => case p: Player if p.isBackpack =>
livePlayers.list.size > livePlayers.removeFrom(p).size ||
corpses.list.size > corpses.removeFrom(p).size corpses.list.size > corpses.removeFrom(p).size
case p: Player =>
livePlayers.list.size > livePlayers.removeFrom(p).size
case v: Vehicle => case v: Vehicle =>
vehicles.list.size > vehicles.removeFrom(v).size vehicles.list.size > vehicles.removeFrom(v).size
case e: Equipment => case e: Equipment =>