Hi all, Anyone have an idea where can i put a function to be executed after a load game? Also after map generation on the load process. Thanks in advance, Keldath
For a specific map script, or for all of them? Map scripts provide the "afterGeneration" function that is called after the map has been generated. The more generic "GameStart" Python event should also work, though.
Assuming that this is (also) about loading savegames and the DLL, here's my crib sheet for the order of the read(FDataStreamBase*) calls: (I use it mostly for debugging savegame compatibility bugs.) Code: CvInitCore CvGameAI --> CvGame --> CvDeal --> CvRandom --> CvReplayMessage CvMap --> CvPlot --> CvArea CvTeamAI --> CvTeam CvPlayerAI --> CvPlayer --> CvCityAI --> CvCity --> CvUnitAI --> CvUnit --> CvSelectionGroupAI --> CvSelectionGroup CvStatistics The last part is initiated by the EXE, via CvEventReporter: Code: void CvEventReporter::readStatistics(FDataStreamBase* pStream) { m_kStatistics.reset(); m_kStatistics.read(pStream); GC.getGame().onAllGameDataRead(); } So that's where I've added a call to CvGame (as the catch-all class) for code that should run after a savegame has been fully loaded. However, I use that (almost?) exclusively for hacks to maintain save-compatibility. The procedure at the start of a game doesn't have much overlap with loading a game; mostly the reset functions I think. More generally, when having to place some new step in the order of initialization, I try to figure out what data is needed beforehand and what the earliest step is where all the required data is available.
hey folks, thanks for the replies. i needed a code to color plots after load game for my city state mechanizem. eventually, i experimented with CvGame:nAllGameDataRead() where i added my function for culture plot coloring. i added a counter of executions on the main interface function and i found the combo i needed to make sure the coloring will take place, the main issue that a clear was executed on the plots which deleted my border coloring. so f1, i was in the right place according to your post. Leo - thanks - but i was looking for a dll code part rather then the python, but thanks
Initialization of graphics actually, for the most part, works the same way when loading a savegame as when launching a new game. Gets initiated by the EXE in various places, e.g. CvGame::updateColoredPlots, which would normally be the place for coloring plots. I've also tied some graphics init code to CvGlobals::SetGraphicsInitialized in the past.