Author Topic: Unofficial Support_RaycastingWeapons.cs update (critical bug fix)  (Read 2771 times)

Hello there everyone.
Have you been using Support_RaycastingWeapons sometimes and experienced crashes or just a frozen Blockland?
Did you put your raycastWeaponRange higher then 100 and not a full 100? (Like 256)
Then hurray, as for i have had this issue too.
And i fixed it, download the fixed support script here.
Alternatively, grab the one i attached (for those with problems with mediafire or something).

I will explain how i found it and what exactly the bug was below.

I dug through my own code and then the support script's and used the trace console command to find the issue at hand:

In the support script on line 146, the while starts.
This is what Blockland is stuck on forever.
If you trace, you will see a lot of isRaycastCritical calls.

The bug itself is the fact that in the while loop, it sets the range on the remembered range (the part that was too much for the raycast (old range - 100)).
Then if the range was higher then 100, it would decrease the remembered range by 100 and set the range to 100 (the max for the raycast).
It would then look if there was something by using a raycast from begin point to the calculated endpoint.
The bug here exactly is that if the range after it is set on the remembered range can be lower then 100, however, then the remembered range will stay what it is and thus be remembered to the next while and used again as the range is being set on the remembered range.
The remembered range never reaches 0 and neither does the range.

I fixed it by putting an else after the if, that checks if the range (that was set on the remembered range), that will set the remembered range on 0.
Thereby clearing the remembered range because the range is the last bit of range it needs.

I hope this is sort of clear.
Otherwise, i am sorry, it is kind of silly and complicated, but i fixed it for you! <3

I haven't contacted Space Guy yet, i am not sure if he is still around even, so yeah, if you read this Space Guy, please PM me if there is something on your mind about this.
If there are any trouble with this patch, please post below.
Thank you! :)
« Last Edit: July 06, 2013, 08:10:26 PM by lordician »

Contact anybody whose mods use this to let them know.

Thanks for your hard work figuring this out.

Contact anybody whose mods use this to let them know.
Yeah i already posted on Bushido's T+T topic, i should probably PM him and then find some others and PM them too. :)
Thanks for your hard work figuring this out.
It wasn't much after all, but i was really frustated when i couldn't find out what was freezing Blockland when i worked with this support script.
But thanks. :)

Makes sense. I remember trying to fix that crash a while back but didn't finish it for some reason. If you've changed the version number then anything with this should override previous ones.

Makes sense. I remember trying to fix that crash a while back but didn't finish it for some reason. If you've changed the version number then anything with this should override previous ones.
Yes i did, version 3.
I didn't see you around for a long time so i figured you were on hiatus.
Thanks for stopping by though!
I guess i just didn't quite visited the right topics. ;)