KnuckleCracker / CW4-bug-tracker

The gathering point for bugs and supporting information, or suggestions about additional features.
Creative Commons Attribution Share Alike 4.0 International
13 stars 1 forks source link

[4RPL] Pitfall surrounding the interactions of SetUnitSelected and SetUnitSelectable #1047

Closed grabz-dev closed 2 years ago

grabz-dev commented 2 years ago

This issue mainly relates to this fact, from SetUnitSelected:

If the unit can not be selected, this call has no effect.

This makes sense at first glance, but a pitfall is created when one considers that SetUnitSelectable does not automatically deselect a unit.

If a player selects a unit before 4RPL makes it unselectable with FALSE SetUnitSelectable, the unit remains selected. If a programmer then tries to apply FALSE SetUnitSelected on that unit, the call will fizzle out due to the unit being unselectable, and the unit will remain selected.

This means that in order to make the player truly unable to suddenly interact with a unit at runtime, one has to be extra careful and ensure that they call FALSE SetUnitSelected before FALSE SetUnitSelectable.

This easy to cause unintended behavior can be solved in two ways in a future game:

knucracker commented 2 years ago

I implemented both... SetUnitSelected will now unselect a unit even it is is set to unselectable. SetUnitSelectable will now unselect the unit if the unit is being set to unselectable.