CloudSixteen / Clockwork

A roleplaying framework developed by Cloud Sixteen for the people.
http://CloudSixteen.com
MIT License
44 stars 43 forks source link

[PhaseFour] broken item chat spam #345

Closed bugreporters closed 6 years ago

bugreporters commented 7 years ago

After firing any weapon until the point the durability reaches 0 it breaks. That works like it's intended, but what then happens is it floods the players chat and console with this:

[HTML] http://forums.cloudsixteen.com/js/xenforo/xenforo.js?_v=073095e7:170: Uncaught TypeError: Property 'group' of object # is not a function

This weapon is broken and needs to be repaired! This weapon is broken and needs to be repaired! This weapon is broken and needs to be repaired!

After switching off the weapon immediately stops this spam but the second you switch back to the weapon it starts back up. Even after holster / dropping then re-equipping the same thing happens.

Edit: I found out the HTML Message occurs every time you open the Tab Menu.

xRJx commented 6 years ago

This looks like an infinite loop issue. Here's the trace of functions being called: PhaseFour:PlayerCanFireWeapon > Clockwork.kernel:HandleWeaponFireDelay > Clockwork.player:UpdateWeaponRaised > Clockwork:PlayerThink

So what ends up happening is that the code checking for durability is called every time the PlayerThink function is called. My suggestion is to move the durability code to a different callback, such as when the player explicitly tries to fire a weapon.

I'm not sure if this is possible, I'll look in to it.

xRJx commented 6 years ago

I've reproduced the bug.

xRJx commented 6 years ago

I've gotten this fixed. The fix has been committed to the private repository for Phase Four.

I had to do a sort of workaround by adding the NotifyBrokenWeapon command which gets executed when primary/secondary attack is pressed with the broken weapon equipped, it also gets executed when the weapon is wielded.

Fun fact: Clockwork.player:Notify can't be executed in clientside files, hence the workaround.

If anyone knows of a way to use Clockwork.player:Notify without having to use a command then feel free to let me know. :)