BarryBadpak / Staxel-ItemWheelMod

MIT License
2 stars 1 forks source link

Joining server crashes game #5

Open BarryBadpak opened 6 years ago

BarryBadpak commented 6 years ago

On joining a server the ClientContext gets reloaded if the client and server do not have identical files, make sure that when the ClientContext gets reloaded we don't execute methods twice that shouldn't be executed twice.

Now this causes the web overlay bound events to be bound twice, where the 2nd bind will result in a exception as its already in the event dictionary.

mindforger commented 6 years ago

how about not creating a second instance, especially without cleaning up the previous

https://github.com/stefanhaan/Staxel-ItemWheelMod/blob/master/ClassicItemWheelMod/HotbarManager.cs#L32

this.Controller = new HotBarController();

you should check if "this.Controller" is already an instance before creating a new one also maybe initialize it in the contructor properly with null, just to make everything clean.

Second idea would be to create the instance right at the beginning in the constuctor but limiting it's functions until the ContextInit is called and enable it's functions then (or make all Context calls inherently failsafe, to name the worst to implement variant but the safest)