collinsmith/riiablo

Created dirty flag for item serialization

Opened this issue · 2 comments

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.

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.

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.