No announcement yet.

Assets Getting Corrupted Between Mod Sessions

  • Filter
  • Time
  • Show
Clear All
new posts

    Assets Getting Corrupted Between Mod Sessions

    I have set up a variable storage structure for my Total Conversion, where I have a Settings Notebook initially generate it, load it with all of the default variables, and then creatures and objects and things draw their settings from it. All of this works fine usually, but if I so much as think about changing any variables or logic in either the dino's or the object (which cast between one another through various events), then specifically the object gets corrupted. If I try to load the DevKit with the object in my mod's folder, then it will not start. This makes my life very inconvenient as this settings object is one of the most important objects in my TC, and I will frequently be adding new variables to it. I would rather not have to rebuild the object from a functional backup every time I want to change anything.

    More Specific Information: The Object itself is an Indestructible, Unstasisable Tek Foundation, which all dino's perform a small line trace to initially find, and then keep as a variable for future reference. It contains a name tag sorting algorithm (For my Settings Notebook, to make it easier to select a specific dino), a Dino Update Function (Casts to all dino's of a given class, and commands them to update their settings from it), and the initialization of many variables, mostly Arrays as they can store information specific to each dino neatly, such as Scale or Health. It is initially spawned when a player opens the Settings Notebook for the first time, and will remain in that world permanently. I have arrays which are accessed by the notebook set to Public, and some which are Private.

    So it sounds like what you are running into is a circular dependancy issue. Basically because these classes are directly referencing each other it can't actually resolve the classes when it loads them. (You can look up C++ circular dependancy to get a better understanding of what is happening under the hood)

    Here is the kind of setup you seem to have:

    Class A (Constructs and references Class B)
    Class B (references Class A)

    What you want to do is the following:

    1. Create a child of Class A (Which I will call A_Child going forward)
    2. In Class A_Child, override all of the functions you declared in Class A and move the implementations to Class A_Child
    3. Replace all of the implementations in Class A with very generic ones and make sure to remove ALL references to Class B from Class A.
    4. Make sure Class B ONLY references Class A and not Class A_Child. A reference to the A_Child instance can be stored here but should be stored AS Class A and never casted to A_Child (You won't need to, because all the functions are declared in Class A)

    Which will leave you with the following
    Class A (Declares functions and variables only)
    Class A_Child (Spawns and references Class B)
    Class B (References Class A)
    Last edited by ZenRowe; 09-12-2018, 11:01 AM.