mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-24 16:13:20 +00:00
## About The Pull Request This component added in #77417 never actually worked. It has 2 problems **1. Nothing even gets dismounted** https://github.com/tgstation/tgstation/assets/110812394/8859794c-e2da-4bf2-bf2e-cd44fb240872 This is because a ton of objects in game don't actually pass a callback when the object is getting dismounted i.e. they pass no params to the `find_and_hang_on_wall()` proc for e.g.11ec431834/code/game/objects/items/wall_mounted.dm (L58)and because the callback is null the action11ec431834/code/datums/components/wall_mounted.dm (L54)never gets executed. Now to combat this in the `Initialize()` proc a null check is done to ensure the callback is not null11ec431834/code/datums/components/wall_mounted.dm (L15-L18)But this code itself is broken for 2 reasons 1. We create a callback using the `CALLBACK` macro they are not the same as `TYPE_PROC_REF` also we never specify which object this proc ref should even be called on 2. `on_drop` ends up null anyway because we first check if the param is null and set its value here11ec431834/code/datums/components/wall_mounted.dm (L15-L16)But then we again overwrite `on_drop` with the param passed(which is null) so it ends up becoming null again11ec431834/code/datums/components/wall_mounted.dm (L18)So this never did it's job. Also we simply can't create a callback on `obj/deconstruct` because this proc accepts a boolean as it's param11ec431834/code/game/objects/obj_defense.dm (L150)But we pass the `hanging_param` as its param when invoking the callback11ec431834/code/datums/components/wall_mounted.dm (L54)Which would cause undefined behaviour so we have to manually do a null check for this param and call the `deconstruct` proc explicitly to ensure correct behaviour **2. Wall mounts created in round would runtime** **Reproduction** 1. Use some iron sheets to construct an air alarm wall frame(or any wallmount of your choice) 4. Put on wall 5. Get stack trace  This occurred because the component received an invalid parent when mounting was attempted.  Which was caused by11ec431834/code/game/objects/items/wall_mounted.dm (L45)We should be doing this the other way around i.e. `hanging_object.AddComponent(/datum/component/wall_mounted, on_wall)` But the truth is even this is not required nor is this11ec431834/code/game/objects/items/wall_mounted.dm (L58)These 2 lines of code are not necessary because a lot of objects call `find_and_hang_on_wall()` proc by themselves in their `Initialization()` proc for e.g.11ec431834/code/modules/atmospherics/machinery/air_alarm/_air_alarm.dm (L127)So the work is already done for us. we were just adding the component 2 more times for no reason and causing problems. ## Changelog 🆑 fix: wall mounted objects air alarms, fire alarms etc now actually falls off/gets destroyed when their attached wall is deconstructed fix: wall mounts crafted in game also properly falls off/gets destroyed when their attached wall is deconstructed /🆑