http://bugs.freeciv.org/Ticket/Display.html?id=40274 >
2008/6/13 Marko Lindqvist:
> My version is mainly for one multiline popup. This is meant for
> casual user, who may don't even realize what he is doing when he
> selects server from metaserver list. Popup (by default) at least makes
> it clear that something 'unusual' happens; (s)he is no longer playing
> local game on his/her computer, but has connected to server where
> rules may differ from the ones (s)he is used to and other people may
> interfere with his/her game.
Moved popup before even player authentication. This allows message to
contain registration related information, and more importantly;
information where to get compatible tileset before client exits due to
incompatible one.
Jason's idea about localized messages produced in client side
requires some thinking - will leave it to future tickets.
- ML
diff -Nurd -X.diff_ignore freeciv/common/game.c freeciv/common/game.c
--- freeciv/common/game.c 2008-03-08 16:32:49.0 +0200
+++ freeciv/common/game.c 2008-06-19 02:56:07.0 +0300
@@ -387,6 +387,7 @@
game.meta_info.user_message_set = FALSE;
game.meta_info.user_message[0] = '\0';
+ game.connectmsg[0] = '\0';
}
/
diff -Nurd -X.diff_ignore freeciv/common/game.h freeciv/common/game.h
--- freeciv/common/game.h 2008-06-19 01:24:53.0 +0300
+++ freeciv/common/game.h 2008-06-19 02:56:07.0 +0300
@@ -59,7 +59,7 @@
* use. The "stored" value is a value the player can change; it won't
* take effect until the next turn. */
bool simultaneous_phases_stored;
- char *startmessage;
+ char connectmsg[MAX_LEN_MSG];
struct player players[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
struct conn_list *all_connections;/* including not yet established */
struct conn_list *est_connections;/* all established client conns */
diff -Nurd -X.diff_ignore freeciv/server/commands.c freeciv/server/commands.c
--- freeciv/server/commands.c 2008-02-02 09:34:49.0 +0200
+++ freeciv/server/commands.c 2008-06-19 02:56:07.0 +0300
@@ -116,6 +116,13 @@
N_("For each connected client, pops up a window showing the message "
"entered.")
},
+ {"connectmsg", ALLOW_HACK,
+ /* TRANS: translate text between <> only */
+ N_("connectmsg "),
+ N_("Set message to show to connecting players."),
+ N_("Set message to sends to clients when they connect.\n"
+ "Empty message means that no message is sent.")
+ },
{"vote", ALLOW_INFO,
/* TRANS: translate text between [] only */
N_("vote yes|no [vote number]"),
diff -Nurd -X.diff_ignore freeciv/server/commands.h freeciv/server/commands.h
--- freeciv/server/commands.h 2008-02-02 09:34:49.0 +0200
+++ freeciv/server/commands.h 2008-06-19 02:56:07.0 +0300
@@ -37,6 +37,7 @@
CMD_EXPLAIN,
CMD_SHOW,
CMD_WALL,
+ CMD_CONNECTMSG,
CMD_VOTE,
/* mostly non-harmful: */
diff -Nurd -X.diff_ignore freeciv/server/connecthand.c freeciv/server/connecthand.c
--- freeciv/server/connecthand.c 2008-05-07 17:44:45.0 +0300
+++ freeciv/server/connecthand.c 2008-06-19 03:11:45.0 +0300
@@ -297,6 +297,12 @@
}
} conn_list_iterate_end;
+ if (game.connectmsg[0] != '\0') {
+freelog(LOG_DEBUG, "Sending connectmsg: %s", game.connectmsg);
+notify_conn(pconn->self, NULL, E_MESSAGE_WALL,
+"%s", game.connectmsg);
+ }
+
if (srvarg.auth_enabled) {
return authenticate_user(pconn, req->username);
} else {
diff -Nurd -X.diff_ignore freeciv/server/stdinhand.c freeciv/server/stdinhand.c
--- freeciv/server/stdinhand.c 2008-06-19 01:24:53.0 +0300
+++ freeciv/server/stdinhand.c 2008-06-19 02:56:07.0 +0300
@@ -1121,8 +1121,7 @@
}
/**
-...
-('caller' argument is unused)
+ Generate init script from settings currently in use
**/
static bool write_command(struct connection *caller, char *arg, bool check)
{
@@ -1638,6 +1637,46 @@
return TRUE;
}
+/**
+ Set message to send to all new connections
+**/
+static bool connectmsg_command(struct connection *caller, char *str,
+ bool check)
+{
+ unsigned int bufsize = sizeof(game.connectmsg);
+
+ if (is_restricted(caller)) {
+return FALSE;
+ }
+ if (!check) {
+int i;
+int c = 0;
+
+for (i = 0; c < bufsize -1 && str[i] != '\0'; i++) {
+ if (str[i] == '\\') {
+i++;
+
+if (str[i] == 'n') {
+ game.connectmsg[c++] = '\n';
+} else {
+ game.connectmsg[c++] = str[i];
+}
+ } else {
+game.connectmsg[c++] = str[i];
+ }
+}
+
+game.connectmsg[c++] = '\