project_files/frontlib/ipc/gameconn.c
changeset 7320 e704706008d4
parent 7316 f7b49b2c5d84
child 7482 d70a5b0d1190
--- a/project_files/frontlib/ipc/gameconn.c	Thu Jul 05 22:22:48 2012 +0200
+++ b/project_files/frontlib/ipc/gameconn.c	Tue Jul 10 19:33:57 2012 +0200
@@ -54,7 +54,7 @@
 	void (*onChatCb)(void* context, const char *msg, bool teamchat);
 	void *onChatCtx;
 
-	void (*onGameRecordedCb)(void *context, const uint8_t *record, int size, bool isSavegame);
+	void (*onGameRecordedCb)(void *context, const uint8_t *record, size_t size, bool isSavegame);
 	void *onGameRecordedCtx;
 
 	void (*onEngineMessageCb)(void *context, const uint8_t *em, size_t size);
@@ -64,22 +64,17 @@
 	bool destroyRequested;
 };
 
-static void defaultCallback_onConnect(void* context) {}
-static void defaultCallback_onDisconnect(void* context, int reason) {}
 static void defaultCallback_onErrorMessage(void* context, const char *msg) {
 	flib_log_w("Error from engine (no callback set): %s", msg);
 }
-static void defaultCallback_onChat(void* context, const char *msg, bool teamchat) {}
-static void defaultCallback_onGameRecorded(void *context, const uint8_t *record, int size, bool isSavegame) {}
-static void defaultCallback_onEngineMessage(void *context, const uint8_t *em, size_t size) {}
 
 static void clearCallbacks(flib_gameconn *conn) {
-	conn->onConnectCb = &defaultCallback_onConnect;
-	conn->onDisconnectCb = &defaultCallback_onDisconnect;
-	conn->onErrorMessageCb = &defaultCallback_onErrorMessage;
-	conn->onChatCb = &defaultCallback_onChat;
-	conn->onGameRecordedCb = &defaultCallback_onGameRecorded;
-	conn->onEngineMessageCb = &defaultCallback_onEngineMessage;
+	flib_gameconn_onConnect(conn, NULL, NULL);
+	flib_gameconn_onDisconnect(conn, NULL, NULL);
+	flib_gameconn_onErrorMessage(conn, NULL, NULL);
+	flib_gameconn_onChat(conn, NULL, NULL);
+	flib_gameconn_onGameRecorded(conn, NULL, NULL);
+	flib_gameconn_onEngineMessage(conn, NULL, NULL);
 }
 
 static flib_gameconn *flib_gameconn_create_partial(bool record, const char *playerName, bool netGame) {
@@ -312,7 +307,7 @@
 GENERATE_CB_SETTER_AND_DEFAULT(onDisconnect, (void* context, int reason));
 GENERATE_CB_SETTER(onErrorMessage, (void* context, const char *msg), defaultCallback_onErrorMessage);
 GENERATE_CB_SETTER_AND_DEFAULT(onChat, (void* context, const char *msg, bool teamchat));
-GENERATE_CB_SETTER_AND_DEFAULT(onGameRecorded, (void *context, const uint8_t *record, int size, bool isSavegame));
+GENERATE_CB_SETTER_AND_DEFAULT(onGameRecorded, (void *context, const uint8_t *record, size_t size, bool isSavegame));
 GENERATE_CB_SETTER_AND_DEFAULT(onEngineMessage, (void *context, const uint8_t *em, size_t size));
 
 #undef GENERATE_CB_SETTER_AND_DEFAULT