frontlib: Using macros for simplification of callbacks
authorMedo <smaxein@googlemail.com>
Mon, 25 Jun 2012 15:21:18 +0200
changeset 7273 8eed495fd8da
parent 7271 5608ac657362
child 7275 15f722e0b96f
frontlib: Using macros for simplification of callbacks
project_files/frontlib/net/netconn.c
project_files/frontlib/net/netconn_callbacks.c
project_files/frontlib/net/netconn_internal.h
--- a/project_files/frontlib/net/netconn.c	Mon Jun 25 00:42:07 2012 +0200
+++ b/project_files/frontlib/net/netconn.c	Mon Jun 25 15:21:18 2012 +0200
@@ -33,89 +33,6 @@
 #include <errno.h>
 #include <ctype.h>
 
-static void defaultCallback_onMessage(void *context, int msgtype, const char *msg) {
-	flib_log_i("Net: [%i] %s", msgtype, msg);
-}
-
-static void defaultCallback_void(void *context) {}
-static void defaultCallback_bool(void *context, bool isChief) {}
-static void defaultCallback_str(void *context, const char *str) {}
-static void defaultCallback_int_str(void *context, int i, const char *str) {}
-static void defaultCallback_str_str(void *context, const char *str1, const char *str2) {}
-static void defaultCallback_str_bool(void *context, const char *str, bool b) {}
-static void defaultCallback_str_int(void *context, const char *str, int i) {}
-
-static void defaultCallback_onRoomAdd(void *context, const flib_roomlist_room *room) {}
-static void defaultCallback_onRoomUpdate(void *context, const char *oldName, const flib_roomlist_room *room) {}
-static void defaultCallback_onChat(void *context, const char *nick, const char *msg) {
-	flib_log_i("%s: %s", nick, msg);
-}
-
-// Change the name by suffixing it with a number. If it already ends in a number, increase that number by 1.
-static void defaultCallback_onNickTaken(void *context, const char *requestedNick) {
-	flib_netconn *conn = context;
-	size_t namelen = strlen(requestedNick);
-	int digits = 0;
-	while(digits<namelen && isdigit(requestedNick[namelen-1-digits])) {
-		digits++;
-	}
-	long suffix = 0;
-	if(digits>0) {
-		suffix = atol(requestedNick+namelen-digits)+1;
-	}
-	char *newPlayerName = flib_asprintf("%.*s%li", namelen-digits, requestedNick, suffix);
-	if(newPlayerName) {
-		flib_netconn_send_nick(conn, newPlayerName);
-	} else {
-		flib_netconn_send_quit(conn, "Nick already taken.");
-	}
-	free(newPlayerName);
-}
-
-// Default behavior: Quit
-static void defaultCallback_onPasswordRequest(void *context, const char *requestedNick) {
-	flib_netconn_send_quit((flib_netconn*)context, "Authentication failed");
-}
-
-static void defaultCallback_onTeamAdd(void *context, flib_team *team) {}
-static void defaultCallback_onTeamColorChanged(void *context, const char *teamName, uint32_t color) {}
-static void defaultCallback_onCfgScheme(void *context, flib_cfg *scheme) {}
-static void defaultCallback_onMapChanged(void *context, const flib_map *map, int changetype) {}
-static void defaultCallback_onWeaponsetChanged(void *context, flib_weaponset *weaponset) {}
-
-static void clearCallbacks(flib_netconn *conn) {
-	flib_netconn_onMessage(conn, NULL, NULL);
-	flib_netconn_onConnected(conn, NULL, NULL);
-	flib_netconn_onDisconnected(conn, NULL, NULL);
-	flib_netconn_onRoomAdd(conn, NULL, NULL);
-	flib_netconn_onRoomDelete(conn, NULL, NULL);
-	flib_netconn_onRoomUpdate(conn, NULL, NULL);
-	flib_netconn_onChat(conn, NULL, NULL);
-	flib_netconn_onLobbyJoin(conn, NULL, NULL);
-	flib_netconn_onLobbyLeave(conn, NULL, NULL);
-	flib_netconn_onRoomJoin(conn, NULL, NULL);
-	flib_netconn_onRoomLeave(conn, NULL, NULL);
-	flib_netconn_onNickTaken(conn, NULL, NULL);
-	flib_netconn_onPasswordRequest(conn, NULL, NULL);
-	flib_netconn_onRoomChiefStatus(conn, NULL, NULL);
-	flib_netconn_onReadyState(conn, NULL, NULL);
-	flib_netconn_onEnterRoom(conn, NULL, NULL);
-	flib_netconn_onLeaveRoom(conn, NULL, NULL);
-	flib_netconn_onTeamAdd(conn, NULL, NULL);
-	flib_netconn_onTeamDelete(conn, NULL, NULL);
-	flib_netconn_onRunGame(conn, NULL, NULL);
-	flib_netconn_onTeamAccepted(conn, NULL, NULL);
-	flib_netconn_onHogCountChanged(conn, NULL, NULL);
-	flib_netconn_onTeamColorChanged(conn, NULL, NULL);
-	flib_netconn_onEngineMessage(conn, NULL, NULL);
-	flib_netconn_onCfgScheme(conn, NULL, NULL);
-	flib_netconn_onMapChanged(conn, NULL, NULL);
-	flib_netconn_onScriptChanged(conn, NULL, NULL);
-	flib_netconn_onWeaponsetChanged(conn, NULL, NULL);
-	flib_netconn_onAdminAccess(conn, NULL, NULL);
-	flib_netconn_onServerVar(conn, NULL, NULL);
-}
-
 flib_netconn *flib_netconn_create(const char *playerName, flib_cfg_meta *metacfg, const char *host, uint16_t port) {
 	flib_netconn *result = NULL;
 	if(!playerName || !metacfg || !host) {
@@ -185,286 +102,6 @@
 	return result;
 }
 
-/*
- * Callback registration functions
- */
-
-void flib_netconn_onMessage(flib_netconn *conn, void (*callback)(void *context, int msgtype, const char *msg), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onMessage");
-	} else {
-		conn->onMessageCb = callback ? callback : &defaultCallback_onMessage;
-		conn->onMessageCtx = context;
-	}
-}
-
-void flib_netconn_onConnected(flib_netconn *conn, void (*callback)(void *context), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onConnected");
-	} else {
-		conn->onConnectedCb = callback ? callback : &defaultCallback_void;
-		conn->onConnectedCtx = context;
-	}
-}
-
-void flib_netconn_onDisconnected(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onDisconnected");
-	} else {
-		conn->onDisconnectedCb = callback ? callback : &defaultCallback_int_str;
-		conn->onDisconnectedCtx = context;
-	}
-}
-
-void flib_netconn_onRoomAdd(flib_netconn *conn, void (*callback)(void *context, const flib_roomlist_room *room), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onRoomAdd");
-	} else {
-		conn->onRoomAddCb = callback ? callback : &defaultCallback_onRoomAdd;
-		conn->onRoomAddCtx = context;
-	}
-}
-
-void flib_netconn_onRoomDelete(flib_netconn *conn, void (*callback)(void *context, const char *name), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onRoomDelete");
-	} else {
-		conn->onRoomDeleteCb = callback ? callback : &defaultCallback_str;
-		conn->onRoomDeleteCtx = context;
-	}
-}
-
-void flib_netconn_onRoomUpdate(flib_netconn *conn, void (*callback)(void *context, const char *oldName, const flib_roomlist_room *room), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onRoomUpdate");
-	} else {
-		conn->onRoomUpdateCb = callback ? callback : &defaultCallback_onRoomUpdate;
-		conn->onRoomUpdateCtx = context;
-	}
-}
-
-void flib_netconn_onChat(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *msg), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onChat");
-	} else {
-		conn->onChatCb = callback ? callback : &defaultCallback_onChat;
-		conn->onChatCtx = context;
-	}
-}
-
-void flib_netconn_onLobbyJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onLobbyJoin");
-	} else {
-		conn->onLobbyJoinCb = callback ? callback : &defaultCallback_str;
-		conn->onLobbyJoinCtx = context;
-	}
-}
-
-void flib_netconn_onLobbyLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMsg), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onLobbyLeave");
-	} else {
-		conn->onLobbyLeaveCb = callback ? callback : &defaultCallback_str_str;
-		conn->onLobbyLeaveCtx = context;
-	}
-}
-
-void flib_netconn_onRoomJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onRoomJoin");
-	} else {
-		conn->onRoomJoinCb = callback ? callback : &defaultCallback_str;
-		conn->onRoomJoinCtx = context;
-	}
-}
-
-void flib_netconn_onRoomLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onRoomLeave");
-	} else {
-		conn->onRoomLeaveCb = callback ? callback : &defaultCallback_str_str;
-		conn->onRoomLeaveCtx = context;
-	}
-}
-
-void flib_netconn_onNickTaken(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onNickTaken");
-	} else if(!callback) {
-		conn->onNickTakenCb = &defaultCallback_onNickTaken;
-		conn->onNickTakenCtx = conn;
-	} else {
-		conn->onNickTakenCb = callback;
-		conn->onNickTakenCtx = context;
-	}
-}
-
-void flib_netconn_onPasswordRequest(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onPasswordRequest");
-	} else if(!callback) {
-		conn->onPasswordRequestCb = &defaultCallback_onPasswordRequest;
-		conn->onPasswordRequestCtx = conn;
-	} else {
-		conn->onPasswordRequestCb = callback;
-		conn->onPasswordRequestCtx = context;
-	}
-}
-
-void flib_netconn_onRoomChiefStatus(flib_netconn *conn, void (*callback)(void *context, bool chief), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onRoomChiefStatus");
-	} else {
-		conn->onRoomChiefStatusCb = callback ? callback : &defaultCallback_bool;
-		conn->onRoomChiefStatusCtx = context;
-	}
-}
-
-void flib_netconn_onReadyState(flib_netconn *conn, void (*callback)(void *context, const char *nick, bool ready), void* context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onReadyState");
-	} else {
-		conn->onReadyStateCb = callback ? callback : &defaultCallback_str_bool;
-		conn->onReadyStateCtx = context;
-	}
-}
-
-void flib_netconn_onEnterRoom(flib_netconn *conn, void (*callback)(void *context, bool chief), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onEnterRoom");
-	} else {
-		conn->onEnterRoomCb = callback ? callback : &defaultCallback_bool;
-		conn->onEnterRoomCtx = context;
-	}
-}
-
-void flib_netconn_onLeaveRoom(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onLeaveRoom");
-	} else {
-		conn->onLeaveRoomCb = callback ? callback : &defaultCallback_int_str;
-		conn->onLeaveRoomCtx = context;
-	}
-}
-
-void flib_netconn_onTeamAdd(flib_netconn *conn, void (*callback)(void *context, flib_team *team), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onTeamAdd");
-	} else {
-		conn->onTeamAddCb = callback ? callback : &defaultCallback_onTeamAdd;
-		conn->onTeamAddCtx = context;
-	}
-}
-
-void flib_netconn_onTeamDelete(flib_netconn *conn, void (*callback)(void *context, const char *teamname), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onTeamDelete");
-	} else {
-		conn->onTeamDeleteCb = callback ? callback : &defaultCallback_str;
-		conn->onTeamDeleteCtx = context;
-	}
-}
-
-void flib_netconn_onRunGame(flib_netconn *conn, void (*callback)(void *context), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onRunGame");
-	} else {
-		conn->onRunGameCb = callback ? callback : &defaultCallback_void;
-		conn->onRunGameCtx = context;
-	}
-}
-
-void flib_netconn_onTeamAccepted(flib_netconn *conn, void (*callback)(void *context, const char *teamName), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onTeamAccepted");
-	} else {
-		conn->onTeamAcceptedCb = callback ? callback : &defaultCallback_str;
-		conn->onTeamAcceptedCtx = context;
-	}
-}
-
-void flib_netconn_onHogCountChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int hogs), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onHogCountChanged");
-	} else {
-		conn->onHogCountChangedCb = callback ? callback : &defaultCallback_str_int;
-		conn->onHogCountChangedCtx = context;
-	}
-}
-
-void flib_netconn_onTeamColorChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, uint32_t colorARGB), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onTeamColorChanged");
-	} else {
-		conn->onTeamColorChangedCb = callback ? callback : &defaultCallback_onTeamColorChanged;
-		conn->onTeamColorChangedCtx = context;
-	}
-}
-
-void flib_netconn_onEngineMessage(flib_netconn *conn, void (*callback)(void *context, const char *message, int size), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onEngineMessage");
-	} else {
-		conn->onEngineMessageCb = callback ? callback : &defaultCallback_str_int;
-		conn->onEngineMessageCtx = context;
-	}
-}
-
-void flib_netconn_onCfgScheme(flib_netconn *conn, void (*callback)(void *context, flib_cfg *scheme), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onCfgScheme");
-	} else {
-		conn->onCfgSchemeCb = callback ? callback : &defaultCallback_onCfgScheme;
-		conn->onCfgSchemeCtx = context;
-	}
-}
-
-void flib_netconn_onMapChanged(flib_netconn *conn, void (*callback)(void *context, const flib_map *map, int changetype), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onMapChanged");
-	} else {
-		conn->onMapChangedCb = callback ? callback : &defaultCallback_onMapChanged;
-		conn->onMapChangedCtx = context;
-	}
-}
-
-void flib_netconn_onScriptChanged(flib_netconn *conn, void (*callback)(void *context, const char *script), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onScriptChanged");
-	} else {
-		conn->onScriptChangedCb = callback ? callback : &defaultCallback_str;
-		conn->onScriptChangedCtx = context;
-	}
-}
-
-void flib_netconn_onWeaponsetChanged(flib_netconn *conn, void (*callback)(void *context, flib_weaponset *weaponset), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onWeaponsetChanged");
-	} else {
-		conn->onWeaponsetChangedCb = callback ? callback : &defaultCallback_onWeaponsetChanged;
-		conn->onWeaponsetChangedCtx = context;
-	}
-}
-
-void flib_netconn_onAdminAccess(flib_netconn *conn, void (*callback)(void *context), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onAdminAccess");
-	} else {
-		conn->onAdminAccessCb = callback ? callback : &defaultCallback_void;
-		conn->onAdminAccessCtx = context;
-	}
-}
-
-void flib_netconn_onServerVar(flib_netconn *conn, void (*callback)(void *context, const char *name, const char *value), void *context) {
-	if(!conn) {
-		flib_log_e("null parameter in flib_netconn_onServerVar");
-	} else {
-		conn->onServerVarCb = callback ? callback : &defaultCallback_str_str;
-		conn->onServerVarCtx = context;
-	}
-}
-
 void leaveRoom(flib_netconn *conn) {
 	conn->netconnState = NETCONN_STATE_LOBBY;
 	conn->isChief = false;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/frontlib/net/netconn_callbacks.c	Mon Jun 25 15:21:18 2012 +0200
@@ -0,0 +1,134 @@
+#include "netconn_internal.h"
+
+#include "../util/logging.h"
+#include "../util/util.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+static void defaultCallback_onMessage(void *context, int msgtype, const char *msg) {
+	flib_log_i("Net: [%i] %s", msgtype, msg);
+}
+
+static void defaultCallback_onChat(void *context, const char *nick, const char *msg) {
+	flib_log_i("%s: %s", nick, msg);
+}
+
+// Change the name by suffixing it with a number. If it already ends in a number, increase that number by 1.
+static void defaultCallback_onNickTaken(void *context, const char *requestedNick) {
+	flib_netconn *conn = context;
+	size_t namelen = strlen(requestedNick);
+	int digits = 0;
+	while(digits<namelen && isdigit(requestedNick[namelen-1-digits])) {
+		digits++;
+	}
+	long suffix = 0;
+	if(digits>0) {
+		suffix = atol(requestedNick+namelen-digits)+1;
+	}
+	char *newPlayerName = flib_asprintf("%.*s%li", namelen-digits, requestedNick, suffix);
+	if(newPlayerName) {
+		flib_netconn_send_nick(conn, newPlayerName);
+	} else {
+		flib_netconn_send_quit(conn, "Nick already taken.");
+	}
+	free(newPlayerName);
+}
+
+// Default behavior: Quit
+static void defaultCallback_onPasswordRequest(void *context, const char *requestedNick) {
+	flib_netconn_send_quit((flib_netconn*)context, "Authentication failed");
+}
+
+void clearCallbacks(flib_netconn *conn) {
+	flib_netconn_onMessage(conn, NULL, NULL);
+	flib_netconn_onConnected(conn, NULL, NULL);
+	flib_netconn_onDisconnected(conn, NULL, NULL);
+	flib_netconn_onRoomAdd(conn, NULL, NULL);
+	flib_netconn_onRoomDelete(conn, NULL, NULL);
+	flib_netconn_onRoomUpdate(conn, NULL, NULL);
+	flib_netconn_onChat(conn, NULL, NULL);
+	flib_netconn_onLobbyJoin(conn, NULL, NULL);
+	flib_netconn_onLobbyLeave(conn, NULL, NULL);
+	flib_netconn_onRoomJoin(conn, NULL, NULL);
+	flib_netconn_onRoomLeave(conn, NULL, NULL);
+	flib_netconn_onNickTaken(conn, NULL, NULL);
+	flib_netconn_onPasswordRequest(conn, NULL, NULL);
+	flib_netconn_onRoomChiefStatus(conn, NULL, NULL);
+	flib_netconn_onReadyState(conn, NULL, NULL);
+	flib_netconn_onEnterRoom(conn, NULL, NULL);
+	flib_netconn_onLeaveRoom(conn, NULL, NULL);
+	flib_netconn_onTeamAdd(conn, NULL, NULL);
+	flib_netconn_onTeamDelete(conn, NULL, NULL);
+	flib_netconn_onRunGame(conn, NULL, NULL);
+	flib_netconn_onTeamAccepted(conn, NULL, NULL);
+	flib_netconn_onHogCountChanged(conn, NULL, NULL);
+	flib_netconn_onTeamColorChanged(conn, NULL, NULL);
+	flib_netconn_onEngineMessage(conn, NULL, NULL);
+	flib_netconn_onCfgScheme(conn, NULL, NULL);
+	flib_netconn_onMapChanged(conn, NULL, NULL);
+	flib_netconn_onScriptChanged(conn, NULL, NULL);
+	flib_netconn_onWeaponsetChanged(conn, NULL, NULL);
+	flib_netconn_onAdminAccess(conn, NULL, NULL);
+	flib_netconn_onServerVar(conn, NULL, NULL);
+}
+
+/**
+ * This macro generates a callback setter function. It uses the name of the callback to
+ * automatically generate the function name and the fields to set, so a consistent naming
+ * convention needs to be enforced (not that that is a bad thing). If null is passed as
+ * callback to the generated function, the defaultCb will be set instead (with conn
+ * as the context).
+ */
+#define GENERATE_CB_SETTER(cbName, cbParameterTypes, defaultCb) \
+	void flib_netconn_##cbName(flib_netconn *conn, void (*callback)cbParameterTypes, void *context) { \
+		if(!conn) { \
+			flib_log_e("null parameter in flib_netconn_%s", #cbName); \
+		} else { \
+			conn->cbName##Cb = callback ? callback : &defaultCb; \
+			conn->cbName##Ctx = callback ? context : conn; \
+		} \
+	}
+
+/**
+ * Generate a callback setter function like GENERATE_CB_SETTER, and automatically generate a
+ * no-op callback function as well that is used as default.
+ */
+#define GENERATE_CB_SETTER_AND_DEFAULT(cbName, cbParameterTypes) \
+	static void _noop_callback_##cbName cbParameterTypes {} \
+	GENERATE_CB_SETTER(cbName, cbParameterTypes, _noop_callback_##cbName)
+
+GENERATE_CB_SETTER(onMessage, (void *context, int msgtype, const char *msg), defaultCallback_onMessage);
+GENERATE_CB_SETTER_AND_DEFAULT(onConnected, (void *context));
+GENERATE_CB_SETTER_AND_DEFAULT(onDisconnected, (void *context, int reason, const char *message));
+GENERATE_CB_SETTER_AND_DEFAULT(onRoomAdd, (void *context, const flib_roomlist_room *room));
+GENERATE_CB_SETTER_AND_DEFAULT(onRoomDelete, (void *context, const char *name));
+GENERATE_CB_SETTER_AND_DEFAULT(onRoomUpdate, (void *context, const char *oldName, const flib_roomlist_room *room));
+GENERATE_CB_SETTER(onChat, (void *context, const char *nick, const char *msg), defaultCallback_onChat);
+GENERATE_CB_SETTER_AND_DEFAULT(onLobbyJoin, (void *context, const char *nick));
+GENERATE_CB_SETTER_AND_DEFAULT(onLobbyLeave, (void *context, const char *nick, const char *partMsg));
+GENERATE_CB_SETTER_AND_DEFAULT(onRoomJoin, (void *context, const char *nick));
+GENERATE_CB_SETTER_AND_DEFAULT(onRoomLeave, (void *context, const char *nick, const char *partMessage));
+GENERATE_CB_SETTER(onNickTaken, (void *context, const char *nick), defaultCallback_onNickTaken);
+GENERATE_CB_SETTER(onPasswordRequest, (void *context, const char *nick), defaultCallback_onPasswordRequest);
+GENERATE_CB_SETTER_AND_DEFAULT(onRoomChiefStatus, (void *context, bool chief));
+GENERATE_CB_SETTER_AND_DEFAULT(onReadyState, (void *context, const char *nick, bool ready));
+GENERATE_CB_SETTER_AND_DEFAULT(onEnterRoom, (void *context, bool chief));
+GENERATE_CB_SETTER_AND_DEFAULT(onLeaveRoom, (void *context, int reason, const char *message));
+GENERATE_CB_SETTER_AND_DEFAULT(onTeamAdd, (void *context, flib_team *team));
+GENERATE_CB_SETTER_AND_DEFAULT(onTeamDelete, (void *context, const char *teamname));
+GENERATE_CB_SETTER_AND_DEFAULT(onRunGame, (void *context));
+GENERATE_CB_SETTER_AND_DEFAULT(onTeamAccepted, (void *context, const char *teamName));
+GENERATE_CB_SETTER_AND_DEFAULT(onHogCountChanged, (void *context, const char *teamName, int hogs));
+GENERATE_CB_SETTER_AND_DEFAULT(onTeamColorChanged, (void *context, const char *teamName, uint32_t colorRGB));
+GENERATE_CB_SETTER_AND_DEFAULT(onEngineMessage, (void *context, const char *message, int size));
+GENERATE_CB_SETTER_AND_DEFAULT(onCfgScheme, (void *context, flib_cfg *scheme));
+GENERATE_CB_SETTER_AND_DEFAULT(onMapChanged, (void *context, const flib_map *map, int changetype));
+GENERATE_CB_SETTER_AND_DEFAULT(onScriptChanged, (void *context, const char *script));
+GENERATE_CB_SETTER_AND_DEFAULT(onWeaponsetChanged, (void *context, flib_weaponset *weaponset));
+GENERATE_CB_SETTER_AND_DEFAULT(onAdminAccess, (void *context));
+GENERATE_CB_SETTER_AND_DEFAULT(onServerVar, (void *context, const char *name, const char *value));
+
+#undef GENERATE_CB_SETTER_AND_DEFAULT
+#undef GENERATE_CB_SETTER
--- a/project_files/frontlib/net/netconn_internal.h	Mon Jun 25 00:42:07 2012 +0200
+++ b/project_files/frontlib/net/netconn_internal.h	Mon Jun 25 15:21:18 2012 +0200
@@ -123,4 +123,6 @@
 	bool destroyRequested;
 };
 
+void clearCallbacks(flib_netconn *conn);
+
 #endif