LoneGazebo / Community-Patch-DLL

Community Patch for Civilization V - Brave New World
Other
285 stars 158 forks source link

CTD on save load 4/20 #4247

Closed Herpsta closed 6 years ago

Herpsta commented 6 years ago

1. Mod version (i.e Date - 4/23): 4/20 with IamBlichos's hotfix from here: https://github.com/LoneGazebo/Community-Patch-DLL/issues/4216

2. Mod list (if using Vox Populi only, leave blank): VP Full Version w/ EUI

3. Error description: Game crashes to desktop when loading the save or any of the autosaves for that game.

4. Steps to reproduce (optional): Just load any of the saves.


Supporting information: Please note that you can attach .zip files by dragging-and-dropping them. If possible, zip up all supporting data and post that way.

  1. Log files (always attach your Logs folder, located at My Documents/My Games/Sid Meier's Civilization 5. Make sure you have enabled logging before experiencing an error! Go here to find out how: http://forums.civfanatics.com/showthread.php?t=487482):

Logs.zip

  1. Save game (always attach a save that was made a turn before the error; located at My Documents/My Games/Sid Meier's Civilization 5/ModdedSaves):

2 Autosaves before hard save: AutoSave_0234 AD-1620.zip

AutoSave_0235 AD-1625.zip

Hard save: Lehomo_0236 AD-1630.zip

  1. CvMiniDump.dmp file (attach if experiencing a game crash. Located at Program Files/Steam/steamapps/common/Sid Meier's Civilization V):

CvMiniDump.zip

  1. Screenshots (optional):
Infixo commented 6 years ago

I am not sure this fix is save-game compatible, there are some DB changes after all. Start a new game, do few turns and try to reload. See if the problem still exists.

LoneGazebo commented 6 years ago

@Infixo database changes are savegame compatible (they don't always update the database, but they don't break so long as you don't add entirely new entries).

Iamblichos commented 6 years ago

Some tables you can add entirely new entries. If it’s a table that has enums, it can often break save game compatibility.

Herpsta commented 6 years ago

I added the hotfix before I started this save.

Herpsta commented 6 years ago

I'm not using any of the hotfixes Gazebo released in the 4/20 release thread. Just the initial 4/20 release and the Iamblichos fix from Github.

Also I just did a new game to turn 50 and reloaded it with no crash, however the game I uploaded above was doing fine for a save I made on turn 212: Lehomo_0212 AD-1510.zip Logs.zip

Are the hotfixes save game compatiable? If so I may just reinstall the mod with the latest hotfix. As well as reinstall Civ and switch the hard drive it's installed on to see if any of that fixes it.

Infixo commented 6 years ago

I was able to load your save file from turn 212 and play with no issues. Using VP 4-20-4 version. Lehomo_0215 AD-1525.zip

I was not able to load turn 236.

Infixo commented 6 years ago

Breaks in CvTeam.cpp on line 9498

CvInfosSerializationHelper::ReadHashedDataArray(kStream, m_aiForceTeamVoteEligibilityCount, GC.getNumVoteSourceInfos());

LoneGazebo commented 6 years ago

@infixo that’s a weird place to crash, I don’t think we’ve added any new memory variables to cvteam in a long time.

Infixo commented 6 years ago

Yeah, I know. A desync probably is way before that. But assuming that both saves were done using the same .exe then the problem lies within those 20 turns. The game must have produced some data that were saved but couldn’t be read. If this is the situation then there could be more reports of crashes like this. We’ll see.

bigcat88 commented 6 years ago

Maybe it is related to what I wrote here: https://github.com/LoneGazebo/Community-Patch-DLL/issues/4268

Herpsta commented 6 years ago

Is there any more info that you need from me? It appears my save is completely toast. Which is fine. I've started over many times, but I don't want to start over just to have it happen again.

Jotaro31400 commented 6 years ago

I've got the same issue but I couldn't load my save, I will upload my save when I m home.

Infixo commented 6 years ago

@John12000 I suggest you install the latest hotfixed VP i.e. 4-20-4. I was able to load and play your save from T212 using it. Then just play and pay attention to what @bigcat88 wrote in #4268 (I'm not saying this is an issue, has not been confirmed). Also, set autosaves to every turn and if a CTD happens again then post the save file from the last turn you were playing. The point is that we need to be able to recreate a CTD to debug it.

Jotaro31400 commented 6 years ago

I'm using 4-20-4 and I still have got this issue.

Herpsta commented 6 years ago

Ok so I went back to turn 212, the save that you were able to load Infixo. I had the game autosave every turn from turn 212 to turn 236, the turn that I couldn't load my save. The game crashes on the autosave from turn 229, which is when one of Mongolia's cities revolts. I can load all of the autosaves before the revolt, but not any of the saves after the revolt.

Turn 228: AutoSave_0228 AD-1590.zip Logs.zip

Turn 229: AutoSave_0229 AD-1595.zip Logs.zip CvMiniDump.zip

I'm also going to install the latest hotfix as suggested and see if the 2 saves uploaded above will load.

Herpsta commented 6 years ago

Also I wasn't sure if I was supposed to clear the logs folder each time, so here is the full log from me playing turns 212 to turn 236. Logs.zip

Jotaro31400 commented 6 years ago
  1. Mod version (i.e Date - 4/23): 4/20 version 4

  2. Mod list (if using Vox Populi only, leave blank): VP Infox EUI improved less ice on the map less warmonger More unique component reforestation really advanced setup ( removed venise as AI ) Infox' UI filter in trade route more wonder(infox)

(None of the extra mod brought those issue with 4-4 version )

  1. Error description: Game crashes to desktop when loading the save or any of the autosaves for that game.

  2. Steps to reproduce (optional): Just load any of the saves.

Replay&CivMiniDump.zip

I can't load any save, you have the mini dump with it

Herpsta commented 6 years ago

Updated to the latest version 4-20-4 and the save still crashes on load for turn 229 and any save after, and doesn't crash for turn 228 and any save before.

Jotaro31400 did you or any of the AI have any city revolts? It seems bigcat88 from https://github.com/LoneGazebo/Community-Patch-DLL/issues/4268 and I both started having issues with loading our saves after there was a city revolt.

Infixo commented 6 years ago

The game certainly produces a corrupted save file at some point - gamecore.log has tons of "type not found hash" errors when trying to load such a file. Looks like it is related to revolts.

Infixo commented 6 years ago

@John12000 @bigcat88 Below is a DLL with a fix. I tested it on @John12000's file from Turn 228. Got a revolt, then saved and loaded again with no problems. CvGameCore_Expansion2.zip You also need to change one UI file because I made a fix that is not yet released. But this is unrelated to CTD, simply if you want to play further you should change this file because otherwise the diplo window will be broken. DiploGlobalRelationships.zip

Infixo commented 6 years ago

@Jotaro31400 Try out the above fix. I was not able to check your files because I don't have required mods. If your issue is related to revolts then you should have it fixed.

Important: you need to apply the fix BEFORE any city would revolt. Once the city revolted, the internal game data becomes corrupted and you cannot take it back.

Infixo commented 6 years ago

Explanation CvTeam class keeps the members in m_members vector, but also there's a variable m_iNumMembers that keeps how many there are. When a city revolts the game looks for a free team ID and a player ID. Eventually team is ignored, and the game uses the team pre-assigned to a free player ID. Then the game adds a new player (that used to be a revolted city) to the team. It increases m_iNumMembers and calls CvTeam::addPlayer(). And here is the problem: addPlayer actually doesn't add a player because it's already there, pre-assigned. All ends up in a state where m_iNumPlayers = 2 but m_members.size() = 1. When saving, the Write function writes to a save file 2 (m_iNumMembers) and outputs only 1 member from m_members. When reloading, the game reads 2 members thus making a desync in the input stream. The crash happens some time later and as usual in such cases is totally unrelated to the root cause. I got it in VoteSources, because the game couldn't read properly the hash and make into a VoteType.

Infixo commented 6 years ago

Fix addPlayer returns a bool that tells if a player ID was really added to the team. Depending on that, m_NumMembers is either increased or decreased thus always being in sync with m_members.size().

LoneGazebo commented 6 years ago

@Infixo that makes sense - wonder why I'm saving and loading without issue? Very strange.

LoneGazebo commented 6 years ago

@Infixo we'll need a method to check against preexisting CSs that have revolted (for a retroactive hotfix solution), no?

Iamblichos commented 6 years ago

Is this a team game or multiplayer?

Infixo commented 6 years ago

Could be difficult to solve it. There's no way of knowing how many players are in the team while reading the input stream, because the very first integer you get has this info. There's no "wrong" number here, any value is a valid one. Especially while playing MP. I suppose only in SP we could assume that it is always 1 and basically ignore it, but still this is a bit risky. I certainly have no proof that it is always 1. Plus I don't wanna touch those Read and Write functions, they are fragile.

Infixo commented 6 years ago

I posted info in the forum, we'll see if the problem affects many people. As for now there are 2 confirmed cases and maybe 2 other. Maybe it's better to just release a hotfixed version asap and don't allow it to spread into many games.

LoneGazebo commented 6 years ago

@Infixo i intend to hotfix ASAP, though I do think we could make nummembers = 1 for the hotfix as a safety

Infixo commented 6 years ago

If you want to do so, then one line in CvTeam::Read() needs a change. After reading m_iNumMembers use std::min(...,1) Cannot just set it to 1 because 0 is actually valid. I wrote in explanation that a new team is searched but ignored. Alas, init() is called for it and it resets the members to 0. This is then written into a file and it’s ok, there are no problems reading it.

LoneGazebo commented 6 years ago

I think we should, at least for the hotfix. I'll make the change. I still can't figure out why I'm saving/loading on my end okay...

Infixo commented 6 years ago

I comment on that in the other thread. The issue is only with City-States, i think. If a city revolts and joins somebody, no new team is needed and the faulty code is not executed.

LoneGazebo commented 6 years ago

I know, but I debugged with CS spawning and still no issue. Anyways it's irrelevant, going to push the hotfix shortly.

Herpsta commented 6 years ago

Ok looks like the 2 files above fixed the issue.

bigcat88 commented 6 years ago

In new version all is fine, check load after revolt - no crashes.