MedievaLands Forums

Are you dropping to the login screen? It might be YsBuffSystem!

Back to Forum

In the game code, every temporary effect on every player and monster stack - from athletics to poison - is represented and operationalized by a collection of classes called "Buffs".

YsBuffSystem is the class that handles adding, removing, and ticking buffs.

Over the past month and more I've seen a handful of server side exceptions related to YsBuffSystem. The server itself is fairly crash resistant - I've written it so it can return to a known good state after an error. Where a player's actions are the cause of the error, I kick the player to restore their state. On the player side, this looks like a drop to the login screen.

(I should probably add an error pop-up for these events so you have a better idea what is happening!)

The exceptions in YsBuffSystem usually occur during transitions from combat to exploration and back again. This is purely server-side simulation; players won't see the transition, they'll just be booted, usually towards the end of combat.

My assumption is that this exception is caused by the fact that the combat simulation runs on one thread, and the packet reader that is the source of all player actions runs on a second thread. If this is the case, then it is possible that the combat simulation might cause YsBuffSystem to tick all the buffs, while at the exact same instant, a player action might cause YsBuffSystem to clear the current list of buffs. You can't tick what doesn't exist, which raises an exception.

I've reorganized YsBuffSystem so that there are only two lines of code that can change the list of buffs on a player - one to add buffs, and one to remove buffs - and I've added thread safety in appropriate places in the methods that contain those lines.

Hopefull this means that the server will no longer "randomly" drop you to the login screen. Unless there's another bug out there, waiting to be discovered.

Take care out there, and keep in touch!


It continued to happen, so I've done the only sensible thing and completely rewritten the buff system. The source code versioning system I use says I changed 40 files and 328 lines of code. Perhaps this will resolve the ongoing drops in combat?



Whatever you did the time before was working for me. Thanks for your diligence! Hopefully what you changed this time works for everyone.


Just want to update and say I have not had a single crash in over a month of speedrunning. :)


Thanks for letting me know. Cheers, Miller - good luck down there!

1 of 1

Terms of Service - Privacy Policy - Rules of Conduct

Made with love in MPLS. Write to me at