@Vinnz,
This one identifies a major flaw in mod setup logic. FAY_PLAYER_INDEX is gotten in a way that only works for new games. For loaded games, it is unreliable. This is definitely a source for errors that look like game load corruption.
@ls612, if you are wondering, the value is stored in EaSetupData.db in UserData during game setup and then retrieved during mod init. This db is used to pass info around during game setup and map generation (there are no Lua "super globals" like MapModData at that time). It's a reasonable way to communicate Fay player ID from game setup to AssignStartingPlots.lua. But it's a stupid way to get this player ID in the main mod, since it will always be set from the last new game rather than the specific load, and will be nil if player deleted ModUserData.
Here's the fix. In EaMain/EaDefines.lua, delete lines 77 & 78:
Code:
local EaSetupDB = Modding.OpenUserData("EaSetupData", 1)
FAY_PLAYER_INDEX = EaSetupDB.GetValue("FAY_PLAYER_INDEX")
Substitute these lines in the same place:
Code:
for iPlayer = 0, BARB_PLAYER_INDEX do
local player = Players[iPlayer]
if player:GetCivilizationType() == GameInfoTypes.CIVILIZATION_THE_FAY then
FAY_PLAYER_INDEX = iPlayer
break
end
end
This may clear up a number of the random "corrupt saves" issues.