algernon-A / ZoningAdjuster

MIT License
5 stars 7 forks source link

Error going from asset editor back to saved game #5

Closed dakotahawkins closed 3 years ago

dakotahawkins commented 3 years ago

I get this every time after playing the game, quitting to main menu, editing an intersection asset, quitting to main menu, then loading my latest save:

Screenshot

A workaround is to quit to desktop and rerun the game.

Steam Discussion

algernon-A commented 3 years ago

When running a modded Unity game, including Cities: Skylines, you should ALWAYS quit to desktop between game loads. This includes editors.

dakotahawkins commented 3 years ago

@algernon-A I've been using a ton of mods and this is the first I've ever had it happen.

dakotahawkins commented 3 years ago

Presumably you should try to Patcher.UnpatchAll() from OnReleased/OnLevelUnloading overrides in ZoningAdjuster/Code/Loading.cs.

It sounds like this happens because doing this lets it try to load/patch a second time, and that fails.

Since you already try to unpatch if you're going into an editor, I think it's probably worth seeing whether cleaning up in one of those functions makes things a little better.

dakotahawkins commented 3 years ago

I can try it if you're willing to reopen and would accept a PR.

algernon-A commented 3 years ago

No offence, but if you geniunely think that "I've been using a ton of mods and this is the first I've ever had it happen" is a valid response to the issues inherent with the Unity engine and its memory management, and the memory leakage and mod initialization issues on second-loads, then I'm not going to be trusting any PRs from you, sorry.

I'll be revisiting the patching functions once another project regarding load and patching orders is complete, but not before then. Adressing something that is only an issue when people are doing something they shouldn't be doing in the first place is not something I'm going to go out of my way for.

dakotahawkins commented 3 years ago

It's the only response I had, because it's my experience. Not just with CS, but with several other Unity games with Harmony mods. I just haven't seen that "you should ALWAYS quit to desktop between game loads" anywhere else. Dismissing it as something "that is only an issue when people are doing something they shouldn't be doing in the first place" without anything compelling to back that up makes me doubt that it's true, or think that maybe while it used to be true it hasn't been a problem for a long time.

I could be wrong of course, maybe it's a problem that I've just not noticed for whatever reason. Maybe I've been lucky.

I'll be revisiting the patching functions

You may take a look at something like MoveIt which seems comparatively well behaved in this regard.

Sorry you seem to feel resistant to having me help with this, but at least we figured that out here instead of after time spent working on a PR.

Thanks, and good luck!

algernon-A commented 3 years ago

Thanks for your response.

Before I go further, though, I will unreservedly apologise for being overly harsh in my comment yesterday. Due to some IRL issues I was not in the best frame of mind - which is a contributing factor, not an excuse, and if I wasn't able to engage more productively I should have simply delayed a response instead of saying what I did.

And, of course, a PR should be assesed on its merits, and I was very wrong in saying that I wouldn't accept a PR due to other factors. Again, that is entirely on me, and I once more apologise unreservedly.

Onto the subject matter: I'm a little surprised about not hearing about never second-loading modded Unity games; certainly in the CS community this is a message that is always being spread. Nevertheless, let's be clear: modded Unity does not work well with second-loads. Even if you can overcome the mod initialization problems (which, although not impossible, are very difficult for modders to adequately address, with the result that many mods don't do this), there are the memory leaks to consider as well. Unfortunately, I'm not currently at my development station and don't have the resources to hand, but a quick Google for "cities skylines" "second load" should provide a wealth of resources (and a little more Google-fu to uncover the more generic Unity situation).

Putting this more eloquently than I did yesterday: you may not have encountered any problems (although I would posit that perhaps 'noticed' might be more accurate), but others certainly have, and continue to do so. Subjective individual experience and opinion is not a substitute for objective and empirical datapoints and extrapolation from known technical realities (and it is incumbent upon the modder to ensure they have a reasonable knowledge of their enviromnent). Almost every day I encounter comments from users along the lines of "but it's always worked for me until now". An analogy can be drawn with e.g. driving while drunk, in that it's always works fine - until it doesn't. The underlying issue is the risky behaviour that leads to the undesirable outcome. Just because you've been lucky so far.... and, of course, your luck is not transferrable to others.

MoveIt, incidentally, doesn't do Harmony patching. Also, regarding "I've been using a ton of mods and this is the first I've ever had it happen." - this is a custom detection and notification included with my mods, but not with others. My philosophy is to try to detect major issues and notify users; many other mods don't do this, and I suggest that the better word for you to use would be "noticed".

Finally, I'll apologise again for yesterday. Regarding the general patching/unpatching sequence, as I said, there's already a plan to revisit that after another related project is completed; however, if you want to submit a PR in the meantime, I undertake to not reject it upfront and will consider it on its merits.

dakotahawkins commented 3 years ago

I'll look at it. At first glance it looks like it should be relatively straightforward. I submitted a PR to add a license file though, which I'd like to get in place (some license of some sort) before trying to contribute anything.