Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameActuator.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp
index fcd32d5f4fe..91ddbbbfbc9 100644
--- a/source/gameengine/Ketsji/KX_GameActuator.cpp
+++ b/source/gameengine/Ketsji/KX_GameActuator.cpp
@@ -34,6 +34,7 @@
//#include <iostream>
#include "KX_Scene.h"
#include "KX_KetsjiEngine.h"
+#include "KX_PythonInit.h" /* for config load/saving */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -125,6 +126,71 @@ bool KX_GameActuator::Update()
}
break;
}
+ case KX_GAME_SAVECFG:
+ {
+ if (m_ketsjiengine)
+ {
+ char mashal_path[512];
+ char *marshal_buffer = NULL;
+ int marshal_length;
+ FILE *fp = NULL;
+
+ pathGamePythonConfig(mashal_path);
+ marshal_length = saveGamePythonConfig(&marshal_buffer);
+
+ if (marshal_length && marshal_buffer) {
+ fp = fopen(mashal_path, "wb");
+ if (fp) {
+ if (fwrite(marshal_buffer, 1, marshal_length, fp) != marshal_length) {
+ printf("Warning: could not write marshal data\n");
+ }
+ fclose(fp);
+ } else {
+ printf("Warning: could not open marshal file\n");
+ }
+ } else {
+ printf("Warning: could not create marshal buffer\n");
+ }
+ }
+ break;
+ }
+ case KX_GAME_LOADCFG:
+ {
+ if (m_ketsjiengine)
+ {
+ char mashal_path[512];
+ char *marshal_buffer;
+ int marshal_length;
+ FILE *fp = NULL;
+ int result;
+
+ pathGamePythonConfig(mashal_path);
+
+ fp = fopen(mashal_path, "rb");
+ if (fp) {
+ // obtain file size:
+ fseek (fp , 0 , SEEK_END);
+ marshal_length = ftell(fp);
+ rewind(fp);
+
+ marshal_buffer = (char*) malloc (sizeof(char)*marshal_length);
+
+ result = fread (marshal_buffer, 1, marshal_length, fp);
+
+ if (result == marshal_length) {
+ loadGamePythonConfig(marshal_buffer, marshal_length);
+ } else {
+ printf("warning: could not read all of '%s'\n", mashal_path);
+ }
+
+ free(marshal_buffer);
+ fclose(fp);
+ } else {
+ printf("warning: could not open '%s'\n", mashal_path);
+ }
+ }
+ break;
+ }
default:
; /* do nothing? this is an internal error !!! */
}