Nightinggale Posted June 1, 2019 Share Posted June 1, 2019 Generally the decompiled code is fairly readable and useful for modders. However I have encountered a big exception related to KMonoBehaviour.Subscribe, which converts GameHashes to unreadable int values. Take for instance the following lines: base.Subscribe((int)GameHashes.CopySettings, new Action<object>(this.OnCopySettings)); this.Subscribe(GameHashes.CopySettings, new Action<object>(this.OnCopySettings)); After being compiled and then decompiled, it becomes: base.Subscribe(-905833192, new Action<object>(this.OnCopySettings)); this.Subscribe(GameHashes.CopySettings, new Action<object>(this.OnCopySettings)); Looking up GameHashes, CopySettings is indeed -905833192. The ingame functionality is the same. The problem is that decompiling Klei's code will consistently act like the top line. Needless to say this makes the code unreasonably hard to read. It also results in a rather steep learning curve for the event based actions and I fear it will make modders check for changes every 200 ms instead of being idle until a certain event occurs. This will result in slower mods. Before I figured out how to copy settings, all I could find online was somebody else who couldn't figure it out either and had just given up. That's another nasty sideeffect from unclean decompiled code. The extension method I wrote to test this: Feel free to copy it, though admittedly it's as simple as it can be. public static void Subscribe(this KMonoBehaviour behavior, GameHashes hash, Action<object> handler) { behavior.Subscribe((int)hash, handler); } There are other enums, but GameHashes is the worst affected by this issue. SimHashes appears to only be used in a way where the names are preserved. Grid.Objects[cell, layer] loses the ObjectLayer and writes the int. This means we get 12 and 16 instead of gas and liquid pipes respectively. It's at least human readable numbers, unlike GameHashes. Would you please provide us with human readable code for GameHashes. Link to comment https://forums.kleientertainment.com/forums/topic/106999-add-extension-methods-to-preserve-gamehashes-names/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.