From 83162a015a37d06b69f39cc3b067295f9c63f55c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 28 Jan 2022 06:11:29 +0200 Subject: [PATCH 33/33] fcdb lua: Add conn_established signal See osdn #43464 Signed-off-by: Marko Lindqvist --- doc/README.fcdb | 3 +++ server/connecthand.c | 5 +++++ server/scripting/script_fcdb.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/doc/README.fcdb b/doc/README.fcdb index 530bce9363..1d837afe54 100644 --- a/doc/README.fcdb +++ b/doc/README.fcdb @@ -202,6 +202,9 @@ Freeciv expects the following lua functions to be defined in database.lua: -- Free the database connection function database_free() + -- Called when connection has been fully established + function conn_established(conn) + Where 'conn' is on object representing the connection to the client which requests access. diff --git a/server/connecthand.c b/server/connecthand.c index 538ca5d93c..49e55701a2 100644 --- a/server/connecthand.c +++ b/server/connecthand.c @@ -50,6 +50,9 @@ #include "stdinhand.h" #include "voting.h" +/* server/scripting */ +#include "script_fcdb.h" + #include "connecthand.h" @@ -179,6 +182,8 @@ void establish_new_connection(struct connection *pconn) /* Notify the console that you're here. */ log_normal(_("%s has connected from %s."), pconn->username, pconn->addr); + script_fcdb_call("conn_established", pconn); + conn_compression_freeze(pconn); send_rulesets(dest); send_server_setting_control(pconn); diff --git a/server/scripting/script_fcdb.c b/server/scripting/script_fcdb.c index 88125bebf1..8052c146b1 100644 --- a/server/scripting/script_fcdb.c +++ b/server/scripting/script_fcdb.c @@ -103,6 +103,9 @@ static struct fc_lua *fcl = NULL; Bool observer): - returns Bool, whether requester is allowed to attach taker to pplayer. + conn_established(Connection pconn) + - called when connection has been fully established + If an error occurred, the functions return a non-NULL string error message as the last return value. **************************************************************************/ @@ -125,6 +128,7 @@ static void script_fcdb_functions_define(void) luascript_func_add(fcl, "user_take", FALSE, 4, 1, API_TYPE_CONNECTION, API_TYPE_CONNECTION, API_TYPE_PLAYER, API_TYPE_BOOL, API_TYPE_BOOL); + luascript_func_add(fcl, "conn_established", FALSE, 1, 0, API_TYPE_CONNECTION); } /**********************************************************************//** -- 2.34.1