Blu3wolf / Treefarm-Lite

This mod enables you to cultivate trees or other plants
GNU General Public License v3.0
11 stars 9 forks source link

Crash on loading save after installing other mods? #60

Closed Glendening closed 8 years ago

Glendening commented 8 years ago

Factorio 13.6 Treefarm-lite 5.0.1

When loading saved game with treefarm enabled after installing other non treefarm mods an error is reported and the save will not load.

Error while running mod-Treefarm-Lite::on_load().

Detected modifications to the 'global' table: CRC before: 2954502010 CRC after: 1701740150

Saved game that generates error Derp 13 Bobs re-tree planted.zip

Mod list for saved game and new additions that triggered treefarm error. mod list treefarm bug

Temporary Workaround: Disable treefarm > load save > let game clear all treefarm items > save game > enable treefarm > load game and everything works fine from that point on saving and loading.

Glendening commented 8 years ago

This also happened previously to this report (I think I posted that bug report in the wrong git page) When I updated/installed mods on the 7th the same results happened with different CRC codes. I used the workaround noted to continue playing until finally reproducing the error.

Blu3wolf commented 8 years ago

Thanks for the report; Ill take a look at this tonight.

To clarify, this happens when you change the installed mods?

Blu3wolf commented 8 years ago

Loading just Treefarm Lite and AC, placing some trees, and farms, saving, installing bobs MCI, then loading the save, doesnt reproduce the error. Will try some of the mods marked out in red.

Blu3wolf commented 8 years ago

Reproduced locally. Seems pretty simple. Treefarm Lite modifies the global table during on_load, and factorio doesnt want it to do that.

Attempting to mutate the 'global' table of a mod in the 'on_load' event handler will result in an error. The 'on_load' event handler is only meant for re-registering conditional event handlers and setting up meta-tables. Use 'on_configuration_changed', 'on_init', and migration scripts in all other instances.

@StephenWard this was your section of code. Im going to take a look at this and see if I can fix it, but your input would not go amiss.

Blu3wolf commented 8 years ago

Going to be playing with this branch: https://github.com/Blu3wolf/Treefarm-Lite/tree/strip_global_changes_out_of_on_load

Blu3wolf commented 8 years ago

As an aside, great report. Contains almost all the details I would want to know to start tracking the bug down. Very impressive!

Glendening commented 8 years ago

I used to work QA at my previous job so I learned a thing or two about bug reporting. Keep up the good work and thanks for a wonderful mod.

FYI your mod now has competition of a sort. It looks like Bob released a tree farm/greenhouse for lumber production.

Blu3wolf commented 8 years ago

More power to him! Unless it spawns trees though, its not really competition. There are already other free wood generators out there, like BioIndustries... difference is, all of them generate pollution. Treefarm soaks pollution.

funnysunnybunny commented 8 years ago

Hey, I came here to report the same bug happening to me, pity I forgot it was happening (Second time already^) Just added MoWeather and ran into it again, I tried the version without global onload but with it the tree planting won't work and throws an error complaining about missing what was removed in the 'commented on load out' version of treefarm I could upload the save game but there's so many needed mods that I just don't

Many thanks to you for keeping the mod up to date

StephenWard commented 8 years ago

I'll take a look at this tonight, @Blu3wolf

DArrigoni commented 8 years ago

I got this to happen without changing the mods. The only thing of note that happened was that I hard reset my computer while factorio was running.

Error while running mod-Treefarm-Lite::on_load().

Detected modifications to the 'global' table: CRC before: 200947184 CRC after: 1243560790

Save file: Khadoosh.zip

Blu3wolf commented 8 years ago

Thanks for the file! The reason this happens with the current version is known; the worry now is fixing it. @StephenWard as you may have noted Ive not done any new pushes to it. Been a little busy of late. I think our fix is to just get the rebuilding of tables to happen only in on_configuration_changed and just leave the global tables alone in on_load.

thorus90 commented 8 years ago

I'm also seein this issue without changes to the mods.

Blu3wolf commented 8 years ago

Thanks for reporting

blueimpb commented 8 years ago

Also seeing this issue. In my case I didn't make any changes to the mods. The only other mod I had installed was the Charcoal mod. I loaded a save, played about 5 minutes, made another save, and at that point I could load the first save but not the second. (Got the same error about modifying the global table during on_load).

Valerate commented 8 years ago

I have updated the Dytech mod to 0.13 and it has the same issue with its rubber tree growing script. I'd love if you found a way to let me know so I can fix my dytech too :)

blueimpb commented 8 years ago

I have the feeling it's a hard problem. I took a look at the code and it's modifying global.tf all over the place. Kinda sucks they made this illegal, but I think it had to do with fixing multiplayer desyncs.

Anyway, I tried commenting out a couple of global.tf modifications in initialize() just for the heck of it, but was unable to avoid the problem.

credomane commented 8 years ago

Looks like just moving initialize() from on_load() to the top of when_loaded_mods_changed. Then having populate_seed_name_to_plant_group check to make sure global.tf.plantGroups is not nil would solve the problem in the short term.

Am I missing something?

DArrigoni commented 8 years ago

Tried the https://github.com/Blu3wolf/Treefarm-Lite/tree/strip_global_changes_out_of_on_load branch and got this:

Error while running the event handler: Treefarm-Lite/control.lua:480: attempt to index upvalue 'immaturePlantNames' (a nil value)

StephenWard commented 8 years ago

fixed in v0.5.2

cyprus2056 commented 8 years ago

While load, ill get this error: Error while running mod-Treefarm-Lite::on_load().

Detected modifications to the 'global' table: CRC before: 2843566698 CRC after: 67294550

Factorio 0.13.13 Bobs 0.13.3 Railtanker 1.3.32 Warehouse 0.0.1 RSO 2.0.11

~8h into game

StephenWard commented 8 years ago

@cyprus2056 which version of Treefarm are you using?