Factorio-Xander-Mod / Xander-Mod

An extensive overhaul, emphasizing detailed and realistic chemistry, materials, and production. Extends the base game to marathon-style scope and difficulty.
https://mods.factorio.com/mods/Repofme1/xander-mod
GNU General Public License v3.0
7 stars 9 forks source link

Can not load preexisting world. ('steel-charge-a' migration error) #5

Open lossycrypt opened 6 years ago

lossycrypt commented 6 years ago

As has been mentioned by several people on the forum thread the mod crashes when loading a savegame that never had xanders mod before.

This is a simple migration error and can be fixed by checking if a recipe/technology exists at all before trying to migrate it.

Or possibly more simple by using http://lua-api.factorio.com/latest/LuaForce.html#LuaForce.reset_technology_effects

GeekinaCave commented 6 years ago

it seem to be triggered because the factorio mod name system is case sensitive. if you changed from "Xander-Mod" to "xander-mod" (as it was in earlier version) it runs fine...

lossycrypt commented 6 years ago

@GeekinaCave: I have no clue what you're suggesting. Both the .zip file and info.json lists the mods name as all lowercase. And the migration file has no mention of the modname.

GeekinaCave commented 6 years ago

allow me to explain; when i update from 1.3.1 to 1.3.2 that error appear to me, what i did was change the name not of the .zip file but for the folder inside the zip which has the same name:

xander-mod_1.3.2.zip > Xander-Mod-1.3.2 (folder) to xander-mod_1.3.2.zip > xander-mod-1.3.2 (folder)

im not sure, but it seems the game thinks internally that it is a different mod instead of being an update from the same mod...

Repofme1 commented 6 years ago

I believe the name change to the folder inside the zip file was on my end, due to slight differences (capitalization and hyphen) in the GitHub name that I didn't catch before the release. Also, the zip releases downloaded from here might have a different internal folder name since I think it's auto-generated based on the name of the repo) than the ones I upload to the mod portal. However, I don't know whether or not this is the actual cause of the crash on loading worlds that never had XM before.

Repofme1 commented 6 years ago

For now I'll merge the fix from @jodokus31, since it seems to make sense. Moving forward I want to better keep to my original naming convention, at least in the zip uploaded to the mod portal. Although it seems like the difference in capitalization and hyphens is going to keep coming back due to the name of the repo, so the problem may persist. Unless it turns out that the it all works even with slightly different capitalization and hyphens in the name of the folder directly inside the zip, then it's fine I guess.

mspielberg commented 6 years ago

Note that you can rename the repository if desired. It's important to keep capitalization and punctuation consistent, or you will very possibly end up with something that works on Windows and OSX, but breaks on Linux.

lossycrypt commented 6 years ago

@Repofme1 I looked at the changes by @jodokus31 and i think that should fix it. Though it seems such a common usecase that personally i'd probably have written a function for it :P

@GeekinaCave The last time i checked the name of the folder /inside/ the .zip file can literally be "whateveryouwant" it shouldn't affect anything. If you can reproduce that it causes errors with migrations in general i suggest a bug report to wube.

jodokus31 commented 6 years ago

@Repofme1 I looked at the changes by @jodokus31 and i think that should fix it. Though it seems such a common usecase that personally i'd probably have written a function for it :P

Thanks for review. Im totally aware, that it could be done with a function taking a recipe and technology. But i'm just at the beginning with lua and factorio modding, that i didnt know how exactly it should be located. I know, that bobslibrary is a collection of usefull functions, which could be used in xander, too. Afaik, it doesnt rely on other bobs mods. Does anybody use it in other mods?

lossycrypt commented 6 years ago

@jodokus31 My guess would be that most people don't use other mods libraries. It's mostly just the mod authors themselfs that use those. Because with the current state of modding it's only easy in the data stage where there's not that much complicated stuff going on anyway. Also i checked data-lifecycle (yea, have to read it again and again and again) because i've never done migrations before. And it seems like you'd have to define the function again in each migration file (tho require should work). I wouldn't bother changing it now tho, it was just a general comment that slipped my tounge because of all the c/p :P.

"Migrations do have access to the game state but are isolated from all other data stages. Migrations are each run in their own Lua state that's discarded after the migration haves been applied."

ironchefpython commented 6 years ago

I have a 1.3.1 save, when 1.3.3 is on the mod portal, I'll test the migration and close the issue if it works.

lossycrypt commented 6 years ago

@ironchefpython You have to test a savegame that has NEVER had xanders mod before. Otherwise not all migrations will fire. Simply creating a new empty world without xander active, then saving, re-enabling and loading should work.

jodokus31 commented 6 years ago

I did some testing with a save from my bobs/angels game and I also tested several old savegames from previous xander versions. I simply tested, if it wouldn't crash, not, if tech tree would look ok, 'cause honestly, I cannot really estimate, if everything would be good from one short look. As i understood migrations, they only update a save from an older version of the mod, to apply structure changes after the mod update. A save with no xander before runs them all. (I think, people do that only, to take sneek preview of the mod). Hopefully, the most people will start a new game, and then migrations doesnt matter or only for future updates.

@jodokus31 My guess would be that most people don't use other mods libraries. It's mostly just the mod authors themselfs that use those. Because with the current state of modding it's only easy in the data stage where there's not that much complicated stuff going on anyway

Ah, ok. I think, bobslibrary could be a thing to mimic or at least to get some inspiration.