Inventory

class Inventory

A compressed internal representation of an inventory, to be transmitted with the various inventory update packets. Rather than use a List, we pool these Inventory instances to avoid generating significant amounts of garbage. For a popular server, it is perfectly reasonable to expect north of a gigabyte of memory to be wasted through List instances in the span of an hour. We eliminate all garbage generation by using soft-reference pooled inventory objects. While this does result in a small hit due to the synchronization involved, it is nothing compared to the hit caused by garbage collection and memory allocation involved with inventories.

Constructors

Link copied to clipboard
constructor(capacity: Int)

Properties

Link copied to clipboard
var count: Int

the current count of objs in this inventory

Functions

Link copied to clipboard
fun add(obj: Long)

Adds an obj into this inventory

Link copied to clipboard
fun clear()

Clears the inventory by setting the count to zero. The actual backing long array can remain filled with values, as those will be overridden by real usages whenever necessary.

Link copied to clipboard
operator fun get(slot: Int): Long

Gets the obj in slot.