Lymia / MPPatch

Patch for Civilization V to allow modded multiplayer. Currently under development.
MIT License
46 stars 6 forks source link

MPPatch corrupts lua runtime environment across loads/saves #78

Open Personwithhat opened 1 year ago

Personwithhat commented 1 year ago

Difficult to reproduce: Leave an active mppatch modded game (e.g. to relobby since someone else crashed) Join new lobby without restarting Civ ~1/10 chance of instantly crashing during load (random for each individual) Error is sporadic/random, with PDB debugger on a custom modded DLL am able to trace it down to lua.

Logs confirm - eventually after repeating load/unload load/unload of a save you will get something like this: [20480.437] LoadMenu: [MPPatch] MPPatch runtime loaded in GameMenu/LoadMenu [20480.453] LoadMenu: [MPPatch] MPPatch runtime loaded in GameMenu/LoadMenu [20480.484] ContentSwitch: [MPPatch] MPPatch runtime loaded in InGame/ContentSwitch [20480.500] InGame: [MPPatch] Loading soft hook for context InGame... [20480.500] InGame: [MPPatch] - Loading include mppatch_runtime.lua [20480.500] InGame: [MPPatch] MPPatch runtime loaded in {...}/InGame/InGame [20480.500] InGame: [MPPatch] - Injecting mppatch_patch_4_protocol_resetleaders.lua [20480.500] InGame: [MPPatch] - Injecting mppatch_patch_5_protocol_kickunpatched.lua [20480.500] InGame: [MPPatch] - Injecting mppatch_patch_6_ingame_chatcommands.lua [20480.500] InGame: [MPPatch] - Injecting mppatch_patch_7_eventsdebug.lua [20480.500] InGame: [MPPatch] Intercepting write to G.OnUpdate [20480.546] Runtime Error: [string "Assets\DLC\UIbc1\UnitFlagManager\UnitFlagMan..."]:948: attempt to index global 'Teams' (a nil value) [20480.546] AdvisorInfoPopup: Closing Advisor Info [20480.546] Demographics: Dequeuing demographics [20480.546] Demographics: Dequeuing demographics or [23418.187] Runtime Error: [string "Assets\DLC\UI_bc1\UnitFlagManager\UnitFlagMan..."]:517: attempt to call global 'print' (a nil value)

As far as I can see CvLuaTeam::pRegister() and the like successfully pass even on failed instances, and the same save loads fine for everyone most of the time. I've tested the same saves ~100+ times and issue is sporadic. There have been 0 cases where a freshly started Civ5 instance would lead to this sort of crash, it is only on repeated rehosts that this issue crops up.

Personwithhat commented 1 year ago

I can confirm that after ~30 tries with luajit disabled this was a non-issue. Afterwards reproduced issue with luajit, took 4 tries