importing the GameLogic module was being done by adding the text "import GameLogic" to the start of all scripts used in the game engine, this meant every error line number was off by 1 (quite annoying). better to do this to the dictionary that the scripts run with.

This commit is contained in:
2008-07-14 00:47:07 +00:00
parent 8a19adeb58
commit 38cfe9c1a2
7 changed files with 27 additions and 22 deletions

View File

@@ -332,6 +332,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
PyObject *gameLogic = initGameLogic(startscene);
PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module.
initGameKeys();
initPythonConstraintBinding();
@@ -399,7 +400,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
exitstring = ketsjiengine->GetExitString();
// when exiting the mainloop
dictionaryClearByHand(gameLogic);
// Clears the dictionary by hand:
// This prevents, extra references to global variables
// inside the GameLogic dictionary when the python interpreter is finalized.
// which allows the scene to safely delete them :)
// see: (space.c)->start_game
PyDict_Clear(PyModule_GetDict(gameLogic));
ketsjiengine->StopEngine();
exitGamePythonScripting();
networkdevice->Disconnect();
@@ -591,6 +599,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
PyObject *gameLogic = initGameLogic(startscene);
PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module
initGameKeys();
initPythonConstraintBinding();