onLoadGame in SDK?

phungus420

Deity
Joined
Mar 1, 2003
Messages
6,296
Are there any corresponding functions in the SDK for onLoadGame and onGameStart? Looking in CvGame I can't find anything, but would like to add some initialization code for when a game is loaded, or when it starts in the SDK, and I'd rather not hack it in via python, since it only effects SDK code anyway.
 
The only thing I could find was CvEventReporter::gameStart for onGameStart. It look like this gets called from the exe file. So I believe that it's the only place that you can catch it.
 
Yeah, couldn't find anything either. So I just set it up to be handled in python, which seems to be working. Seems odd there isn't an onGameLoad function in the SDK though...
 
I just noticed these comments in CvAppInterface.py. I'm just guessing, but this may have something to do with it being difficult to find.

# CvAppInterface.py
#
# These functions are App Entry Points from C++
# WARNING: These function names should not be changed
# WARNING: These functions can not be placed into a class
#
# No other modules should import this
#
# DONT ADD ANY MORE IMPORTS HERE - Moose


Along with this code.

Code:
def onLoad(argsList):
	'Called when a file is loaded'
	import pickle	
	import CvEventInterface
	loadDataStr=argsList[0]	
	if len(loadDataStr):
		CvEventInterface.onEvent( ('OnLoad',pickle.loads(loadDataStr),0,0,0,0,0 ) )

It looks like this is what triggers OnLoadGame in CvEventmanager and this function gets called in some unusal way from c++.
 
A trick I use is to call functions at the end of CvGame::read, which is when most of the save data has been loaded.
 
Top Bottom