collinsmith / riiablo

Diablo II remade using Java and LibGDX
http://riiablo.com
Apache License 2.0
869 stars 99 forks source link

Created dirty flag for item serialization #98

Open collinsmith opened 3 years ago

collinsmith commented 3 years ago

D2GS sends item data with every packet and which means items are serialized every frame. This is unnecessary as items should very rarely change. Items should keep a flag to indicate whether or not they require serialization. The serialized data may be stored within the item itself, or a ideally externally to keep serialization code as encapsulated from item code as possible.

collinsmith commented 3 years ago

As an aside -- this should probably be rethought a bit as an optimization -- since many items could be on the ground at once. I suppose basic item data could be sent once (quality, name, sockets) and the remaining data (attributes) when the item is picked up? Or send the entire item data repeatedly until it has been acked.

collinsmith commented 3 years ago

Looks like ITEMFLAG__SAVED is meant for this purpose. Unset that flag when the item needs to be serialized before sending or saving the item. Hopefully it's that simple.