playMaker

Author Topic: Prefabs disconnecting if containing FsmEnums with negative values  (Read 1201 times)

PollitronicDev

  • Playmaker Newbie
  • *
  • Posts: 13
Bug description
---------------

Prefabs are disconnected when a custom PlayMaker action has an FsmEnum whose Enum has negative values.
The crash says "Index was out of range. Must be non-negative and less than the size of the collection".
The bug doesn't happen 100% of the times.


How can we reproduce it
-----------------------

1.- Put an FsmEnum in a custom PlayMaker action.
2.- Insert in the regular referenced Enum some negative values.
3.- Set the Reset value of the FsmEnum to some of the negative Enum's values.
4.- Notice that when adding the action to an Fsm, the default value it takes can not be a negative value, but you can set it by hand. If you set it manually, this will cause these prefabs to disconnect at some point later (but not 100% of the times)

For example, using this enum in an FsmEnum causes the problem:

public class ClassX
{
   public enum example
   {
       NEGATIVE_VALUE = -1,
       VALUE_0,
       VALUE_1
   }
}

And then in the custom action:

[ObjectType(typeof(ClassX.example))]
public FsmEnum m_example;
       
public override void Reset()
{
   m_example = ClassX.example.NEGATIVE_VALUE;
}


We think it is related to these problems:
https://hutonggames.com/playmakerforum/index.php?topic=19088.msg83045#msg83045

NOTE: this problem is present in v1.9.3 but also on previous versions.

SergioM

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Prefabs disconnecting if containing FsmEnums with negative values
« Reply #1 on: October 06, 2021, 12:16:34 PM »
Hello, we are expecting this same problem. This is causing our prefabs to get modified externally and they get corrupted. Because of that we have to go one by one reverting the changes. It is causing us a lot of problems and we are loosing a lot of time finding which prefabs has disconnected. And we suspect that it comes from FSMEnums that points to enums that starts in index -1.

 public enum eMapSubZones
    {
        NONE = -1,

        CAVE_ENTRANCE = 0,
        CAVE_NEST,
        CAVE_WATERFALL,
        CAVE_DEPTHS,

Can anybody give us some support about this bug?

Regards and thank you in advance

SergioM

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Prefabs disconnecting if containing FsmEnums with negative values
« Reply #2 on: November 03, 2021, 12:01:55 PM »
Hello is there any news on this topic? We are expecting serious problems due to this errors. Is there any way to get some support on this problem from anyone at Hutong Games? Having randomly this error and having to go instance by instance reverting this random changes Playmaker do makes me doubt about if this asset is abandoned or not.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Prefabs disconnecting if containing FsmEnums with negative values
« Reply #3 on: November 03, 2021, 01:08:57 PM »
Moved to bug reports. Alex will need to look at this one.

For your consideration, negative enum values do not have desirable semantics and are often considered bad practice. If never using negative values does circumvent the issue, I would suggest simply not using negative values.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

SergioM

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Prefabs disconnecting if containing FsmEnums with negative values
« Reply #4 on: November 03, 2021, 01:31:15 PM »
Hello the problem is that we have several of places where we are using enums that starts in negative as this one. Renaming to NONE = 0 will mean loosing the correct references on enums in all the FSMs. Maybe for a early production phase could have been a solution to us but right now we cannot do it. :( . Anyway thank you for move this to bugs support because we really need a fix for that. Thank you

public enum eMapSubZones
    {
        NONE = -1,

        CAVE_ENTRANCE = 0,
        CAVE_NEST,
        CAVE_WATERFALL,
        CAVE_DEPTHS,

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Prefabs disconnecting if containing FsmEnums with negative values
« Reply #5 on: November 09, 2021, 02:31:33 AM »
Hi,

 I am unable to repro this issue with negative enums.

Maybe there is another step in the repro procedure to end up with a disconnected prefab?

Bye,

 Jean