[A15] Hash collision on game load with mod that adds buildings

Started by Hatti, August 27, 2016, 06:54:03 PM

Previous topic - Next topic

Hatti

Hey all!

i´m trying to add new buildings with a mod. they work super fine on a new game. But after save and load i get hash collision errors for as it looks every thing:



it only happens after i load up a save game (save is new, nothing is build, nothing is done, just started new game and saved)
the output.log dont have any other informations as the exception message in the call stack.
in A14 it works just fine

also all mountain tiles are flat




any advices how to fix that?

RawCode

1) IL spy or any other reflector (there are no "decompilers")
2) Notepad++
3) Use keywords to find place, where check is located

                                    Verse.Log.Error(string.Concat(new object[] { "Hash collision between ", this.<def>__2, " and  ", this.<thingDefsByShortHash>__0[this.<def>__2.shortHash], ": both have short hash ", this.<def>__2.shortHash }));

4) Then, follow keywords to find, how hash is computed for objects

5)
        public static void GiveShortHash(Def def)
        {
            if (def.shortHash != 0)
            {
                Log.Error(def + " already has short hash.");
            }
            else
            {
                ushort item = (ushort) (GenText.StableStringHash(def.defName) % 0xffff);
                int num2 = 0;
                while (takenHashes.Contains(item) || (item == 0))
                {
                    item = (ushort) (item + 1);
                    num2++;
                    if (num2 > 0x3e8)
                    {
                        Log.Message("Short hashes are saturated because there are too many definitions. Compressed saveload will fail.");
                    }
                }
                def.shortHash = item;
                takenHashes.Add(item);
            }
        }


6) You have too many zeros, probably
        public override void PostLoad()
        {
            base.PostLoad();
            ShortHashGiver.GiveShortHash(this);
        }

not executed properly

7) Make sure, that your objects have proper postload code and no hook is injected into given method

8) Check log (it's located inside _data folder) for warnings and errors, probably you have too many objects

Hatti

Ok got it. It seems, my ThingDef classes dont had a defName for hash generation.
thanks

1000101

Also note that changing anything about floors and terrain requires a new game or you will get the "sand bug".
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

RawCode

Quote from: Hatti on August 27, 2016, 10:44:34 PM
Ok got it. It seems, my ThingDef classes dont had a defName for hash generation.
thanks

very good that you managed to solve problem self, you have bright future ahead, keep going.

Jaxxa

Thanks for posting the solution that you found.

I was having a similar issue but hadnt had time to look into it. I will try that fix when I get back to my machine.