- Apr 1, 2015
Spoiler Context: :
DLL - Various Mod Components
are you interested in an "Pre_Save" Event or similar? I would need such an event that is triggered shortly before the game is saved (by autosave,quicksave, normal save and so on).
Why do I need such an event? For example for mods like your Scouting XP mod. Saving data in ModDB or with SaveUtilis or any other tool in real time is very laggy.
But saving the stuff simply shortly before a savegame would be the ultimate solution.
Do you think such an event exists/is possible to add?
I only found various places where "gDLL->AutoSave(..) or gDLL->QuickSave(...) or gDLL->SaveGame(...)" is called, but I think these functions itself are inaccessable? And pushing a custom event in fornt of every line like this would be quite hacky I guess... not the best solution.
Myself, Pazyryk and ls612 delved deeply into this for his Éa Fantasy Mod and game to the conclusion that you cannot trap every possible exit from the game via C++/Lua, which is why he ended up using a heavily modded version of SaveUtils IIRC.
It would be far easier IMHO to make another Cv class and hang it off one of the existing ones (eg CvTeam or CvPlayer) and have it serialise/deserialise as it's owning object does - but "easier" is a relative term, it's still a mass of work
Thank you very much for the fast response (I created a new thread, because it would be too much offtopic in your thread)
Yes, I already tried to add a GameEvent before all the occurrences of "gDLL->SaveGame(...)" and so on, but for whatever reason it is not triggered (only the autosave when the map was generated works).
I have no experience regarding serialise/deserialise, so I guess this is no option for me.
Regarding SaveUtilis: Do you have a link to the most efficient version of it you know?
My current project:
I have a mod that shares visbility of one team with another team (eg. when they are friends). I achieved this by adding an event to the DLLs plot function "changeVisibilityCount". This way I get in lua notified about every visibility change and then I can "copy" this over to the friend-team.
But when friendship ends, I need to revert the visibilty to default somehow. And the only solution that came to my mind is, that I need to save all the plots with viscounts that are shared. (only alternative may be that I hide the whole map and then call a function that builds of visibilty from scratch based on current units and so on. But I don't think there is such a function).
So I save an array like this:
g_visible_made_plots[iTeam][iCivTeam][iPlot] = g_visible_made_plots[iTeam][iCivTeam][iPlot] + viscount
Depending on the number of teams, the units and the map size, this gets a really huge array. And this array is updated on every single call of "changeVisibilityCount", which is very often eg. when a unit moves, while we need to seperately save the array every single time of them. I already only save the relevant info for the specific team with:
but it is still by far too much, even on medium maps after ~50 turns it starts heavily lagging.