[Freeciv-Dev] (PR#40496) Taking a city doesn't notify the change correctly
http://bugs.freeciv.org/Ticket/Display.html?id=40496 > For any city transfer, all notifications are ok. However, in the case a unit enter in a city, the city info packet is sent before the size was reduced except for the new city owner. So any player can see the new nation of the city, but only one can see the real size of it. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40490) offline msg
http://bugs.freeciv.org/Ticket/Display.html?id=40490 > > [EMAIL PROTECTED] - Wed Sep 17 09:06:09 2008]: > > Maho just told me that there is something like that ready in 2.0 > server. So i can only ask to upgrade it to 2.1 if it is not ready > yet :) There is my offline messaging patch for longturn (branched from freeciv 2.0) available on mantis (the longturn bug tracker). I'll see about getting it ported to freeciv 2.2 and perhaps longturn 2.1 eventually. -- この核反応炉は組み立てが簡単でしょう。 ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40495) Server sends too much player infos
http://bugs.freeciv.org/Ticket/Display.html?id=40495 > > [EMAIL PROTECTED] - Fri Sep 19 00:39:59 2008]: > > This is a significant bug and should be backported, possibly even back > to 2.0. Ok, though this porting business is starting to get on my nerves, what with the 4 freeciv, 2 warclient, and 3 longturn branches, especially as most of the time the only difference between them is in arbitrary cosmetic code changes (name/access conventions). Well, too late to change it now, but something to keep in mind for the future. >:} (Also notice that in this case the patch gets larger as the branch version increases; clearly a sign of progress. ;)) > To avoid crashes maybe a placeholder data could be sent instead? > Like anarchy rather than NULL government. I do like that idea better than mucking about in common/ and having to hunt down all the non-NULL government assumptions in the client. Version 2 of the patch set uses the "government when anarchy/revolution" field of the game structure as a placeholder. --- 確かにその能力は役に立っていますが、本当に副作用がありませんか? diff --git a/server/plrhand.c b/server/plrhand.c index e3e46ca..e98cfcc 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -1166,8 +1166,7 @@ static void package_player_info(struct player *plr, if (server_state == RUN_GAME_STATE) packet->inventions[city_styles[get_player_city_style(plr)].techreq] = '1'; -/* FIXME: temporary kludge */ -packet->government = plr->government; /*G_MAGIC;*/ +packet->government = game.government_when_anarchy; } if (info_level >= INFO_EMBASSY) { diff --git a/server/plrhand.c b/server/plrhand.c index 315b332..5b497c2 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -1624,8 +1624,13 @@ static void package_player_info(struct player *plr, info_level = min_info_level; } - packet->gold= plr->economic.gold; - packet->government = plr->government; + if (info_level >= INFO_MEETING) { +packet->gold = plr->economic.gold; +packet->government = plr->government; + } else { +packet->gold = 0; +packet->government = game.government_when_anarchy; + } /* Send diplomatic status of the player to everyone they are in * contact with. */ diff --git a/server/plrhand.c b/server/plrhand.c index 098bf5e..755b4e7 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -877,11 +877,6 @@ static void package_player_common(struct player *plr, packet->small_wonders[i] = plr->small_wonders[i]; } packet->science_cost = plr->ai.science_cost; - - packet->gold = plr->economic.gold; - packet->government = government_of_player(plr) - ? government_number(government_of_player(plr)) - : -1; } /** @@ -902,6 +897,7 @@ static void package_player_info(struct player *plr, enum plr_info_level info_level; enum plr_info_level highest_team_level; struct player_research* research = get_player_research(plr); + struct government *pgov = NULL; if (receiver) { info_level = player_info_level(plr, receiver); @@ -928,6 +924,15 @@ static void package_player_info(struct player *plr, packet->score = 0; } + if (info_level >= INFO_MEETING) { +packet->gold = plr->economic.gold; +pgov = government_of_player(plr); + } else { +packet->gold = 0; +pgov = game.government_during_revolution; + } + packet->government = pgov ? government_number(pgov) : -1; + /* Send diplomatic status of the player to everyone they are in * contact with. */ if (info_level >= INFO_EMBASSY diff --git a/server/plrhand.c b/server/plrhand.c index 49cae2c..b49c8ff 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -862,11 +862,6 @@ static void package_player_common(struct player *plr, packet->small_wonders[i] = plr->small_wonders[i]; } packet->science_cost = plr->ai.science_cost; - - packet->gold = plr->economic.gold; - packet->government = government_of_player(plr) - ? government_of_player(plr)->index - : -1; } /** @@ -887,6 +882,7 @@ static void package_player_info(struct player *plr, enum plr_info_level info_level; enum plr_info_level highest_team_level; struct player_research* research = get_player_research(plr); + struct government *pgov = NULL; if (receiver) { info_level = player_info_level(plr, receiver); @@ -913,6 +909,15 @@ static void package_player_info(struct player *plr, packet->score = 0; } + if (info_level >= INFO_MEETING) { +packet->gold = plr->economic.gold; +pgov = government_of_player(plr); + } else { +packet->gold = 0; +pgov = game.government_when_anarchy; + } + packet->government = pgov ? pgov->index : -1; + /* Send diplomatic status of the player to everyone the
Re: [Freeciv-Dev] (PR#40495) Server sends too much player infos
http://bugs.freeciv.org/Ticket/Display.html?id=40495 > This is a significant bug and should be backported, possibly even back to 2.0. To avoid crashes maybe a placeholder data could be sent instead? Like anarchy rather than NULL government. -jason ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40495) Server sends too much player infos
http://bugs.freeciv.org/Ticket/Display.html?id=40495 > I can confirm that by modifying the client source (i.e. changing can_intel_with_player to always return TRUE) a player could access information not normally available (the other players' gold amounts and governments, even without contact). The attached patch changes the server to only send the gold and government information if the player's info level is INFO_MEETING or greater. Otherwise zero is sent as the gold value and -1 (corresponding to NULL on the client side) for the government. Unfortunately the seem to be a lot of places where the client assumes that the government will never be NULL. The patch changes some of the common/government.c functions to be more forgiving of NULL input; hopefully these were the only places where such assumptions were made. The alternative would be to modify the client to always allow showing the gold and government information, but I do not really like that this information is available in the first place. My opinion is that it would be better if this information remain hidden from players without contact. -- 一緒にプチプチつぶししませんか? common/government.c | 33 ++--- server/plrhand.c| 14 +- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/common/government.c b/common/government.c index 8fc37ac..57fe090 100644 --- a/common/government.c +++ b/common/government.c @@ -30,8 +30,6 @@ struct government *governments = NULL; -#define CHECK_GOVERNMENT(gp) assert((NULL != gp) && ((gp) == &governments[(gp)->index])) - / Returns the government that has the given (translated) name. Returns NULL if none match. @@ -102,7 +100,10 @@ struct government *government_of_city(const struct city *pcity) / const char *government_rule_name(const struct government *gov) { - CHECK_GOVERNMENT(gov); + if (!gov) { +return "Unknown"; + } + return Qn_(gov->name.vernacular); } @@ -112,7 +113,10 @@ const char *government_rule_name(const struct government *gov) / const char *government_name_translation(struct government *gov) { - CHECK_GOVERNMENT(gov); + if (!gov) { +return _("Unknown"); + } + if (NULL == gov->name.translated) { /* delayed (unified) translation */ gov->name.translated = ('\0' == gov->name.vernacular[0]) @@ -137,13 +141,22 @@ const char *government_name_for_player(const struct player *pplayer) ***/ const char *ruler_title_translation(const struct player *pp) { - struct government *gp = government_of_player(pp); - struct nation_type *np = nation_of_player(pp); + struct government *gp; + struct nation_type *np; struct ruler_title *best_match = NULL; struct name_translation *sex; int i; - CHECK_GOVERNMENT(gp); + if (!pp) { +return ""; + } + + gp = government_of_player(pp); + if (!gp) { +return pp->is_male ? _("Mr.") : _("Ms."); + } + + np = nation_of_player(pp); for(i=0; inum_ruler_titles; i++) { struct ruler_title *title = &gp->ruler_titles[i]; @@ -163,7 +176,7 @@ const char *ruler_title_translation(const struct player *pp) gp->index, nation_rule_name(np), np->index); -return pp->is_male ? "Mr." : "Ms."; +return pp->is_male ? _("Mr.") : _("Ms."); } sex = pp->is_male ? &best_match->male : &best_match->female; @@ -187,9 +200,7 @@ const char *ruler_title_translation(const struct player *pp) bool can_change_to_government(struct player *pplayer, const struct government *gov) { - CHECK_GOVERNMENT(gov); - - if (!pplayer) { + if (!pplayer || !gov) { return FALSE; } diff --git a/server/plrhand.c b/server/plrhand.c index 49cae2c..a390a93 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -862,11 +862,6 @@ static void package_player_common(struct player *plr, packet->small_wonders[i] = plr->small_wonders[i]; } packet->science_cost = plr->ai.science_cost; - - packet->gold = plr->economic.gold; - packet->government = government_of_player(plr) - ? government_of_player(plr)->index - : -1; } /** @@ -913,6 +908,15 @@ static void package_player_info(struct player *plr, packet->score = 0; } + if (info_level >= INFO_MEETING) { +packet->gold = plr->economic.gold; +packet->government = government_of_player(plr) + ? government_of_player(plr)->index : -1; + } else { +packet->gold = 0; +packet->government = -1; + } + /* Send diplomatic status of the player to everyone they are in * contact with. */ if (info_level >= INF
[Freeciv-Dev] (PR#40487) Re: add chat buttons
http://bugs.freeciv.org/Ticket/Display.html?id=40487 > Alright, obviously attaching via "Jumbo" doesn't do what I expect. Let's see if this will work. :) --- この野郎! client/gui-gtk-2.0/chatline.c | 60 - client/gui-gtk-2.0/gui_main.c | 52 +-- client/gui-gtk-2.0/gui_main.h |3 ++ client/gui-gtk-2.0/pages.c|1 + 4 files changed, 112 insertions(+), 4 deletions(-) diff --git a/client/gui-gtk-2.0/chatline.c b/client/gui-gtk-2.0/chatline.c index 1354ea3..9753f36 100644 --- a/client/gui-gtk-2.0/chatline.c +++ b/client/gui-gtk-2.0/chatline.c @@ -26,6 +26,7 @@ #include "packets.h" #include "support.h" +#include "civclient.h" #include "climisc.h" #include "gui_main.h" #include "gui_stuff.h" @@ -36,6 +37,56 @@ struct genlist *history_list; int history_pos; +/** + Helper function to determine if a given client input line is intended as + a "plain" public message. Note that messages prefixed with : are a + special case (explicit public messages), and will return FALSE. +**/ +static bool is_plain_public_message(const char *s) +{ + /* FIXME: These constants' definitions are duplicated in the server. */ + const char ALLIESCHAT_COMMAND_PREFIX = '.'; + const char SERVER_COMMAND_PREFIX = '/'; + const char MESSAGE_PREFIX = ':'; + + const char *p; + + /* If it is a server command or an explicit ally + * message, then it is not a public message. */ + if (s[0] == SERVER_COMMAND_PREFIX + || s[0] == ALLIESCHAT_COMMAND_PREFIX) { +return FALSE; + } + + /* It might be a private message of the form + * 'player name with spaces':the message + * or with ". So skip past the player name part. */ + if (s[0] == '\'' || s[0] == '"') { +p = strchr(s + 1, s[0]); + } else { +p = s; + } + + /* Now we just need to check that it is not a private + * message. If we encounter a space then the preceeding + * text could not have been a user/player name (the + * quote check above eliminated names with spaces) so + * it must be a public message. Otherwise if we encounter + * the message prefix : then the text parsed up until now + * was a player/user name and the line is intended as + * a private message (or explicit public message if the + * first character is :). */ + while (p != NULL && *p != '\0') { +if (my_isspace(*p)) { + return TRUE; +} else if (*p == MESSAGE_PREFIX) { + return FALSE; +} +p++; + } + return TRUE; +} + /** ... @@ -47,7 +98,14 @@ void inputline_return(GtkEntry *w, gpointer data) theinput = gtk_entry_get_text(w); if (*theinput) { -send_chat(theinput); +if (client_state() == C_S_RUNNING && allied_chat_only +&& is_plain_public_message(theinput)) { + char buf[MAX_LEN_MSG]; + my_snprintf(buf, sizeof(buf), ". %s", theinput); + send_chat(buf); +} else { + send_chat(theinput); +} if (genlist_size(history_list) >= MAX_CHATLINE_HISTORY) { void *data; diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c index 1ed2e8b..dd7dc95 100644 --- a/client/gui-gtk-2.0/gui_main.c +++ b/client/gui-gtk-2.0/gui_main.c @@ -55,6 +55,7 @@ #include "clinet.h" #include "colors.h" #include "connectdlg.h" +#include "connectdlg_common.h" #include "control.h" #include "cma_fe.h" #include "dialogs.h" @@ -95,6 +96,7 @@ int overview_canvas_store_height = 2 * 50; bool enable_tabs = TRUE; bool better_fog = TRUE; +bool allied_chat_only = FALSE; GtkWidget *toplevel; GdkWindow *root_window; @@ -271,6 +273,7 @@ static int unit_ids[MAX_NUM_UNITS_BELOW]; /* ids of the units icons in GtkTextView *main_message_area; GtkTextBuffer *message_buffer; static GtkWidget *inputline; +static GtkWidget *allied_chat_toggle_button; static enum Display_color_type display_color_type; /* practically unused */ static gint timer_id; /* ditto*/ @@ -300,6 +303,8 @@ static gboolean select_unit_pixmap_callback(GtkWidget *w, GdkEvent *ev, gpointer data); static gboolean quit_dialog_callback(void); +static void allied_chat_button_toggled(GtkToggleButton *button, + gpointer user_data); / Called by the tileset code to set the font size that should be used to @@ -986,7 +991,7 @@ void enable_menus(bool enable) static void setup_widgets(void) { GtkWidget *box, *ebox, *hbox, *sbox, *align, *label; - GtkWidget *frame, *table, *table2, *paned, *sw, *text; + GtkWidget *frame, *table, *table2, *paned, *sw, *text, *button; int i; char buf[256];
[Freeciv-Dev] (PR#40487) Re: add chat buttons
http://bugs.freeciv.org/Ticket/Display.html?id=40487 > Here is my port of the allies-only button warclient feature for S2_1 and later. It has some improvements over the warclient version, namely that for local games (i.e. games on a forked server) the feature is hidden, and much improved code comments. The utility of this feature is in games involving allies; it prevents you from accidentally revealing your communications to enemies if you should forget the leading '.' in ally messages. In short, while the toggle button is set, the default mode for messages is to send to allies, with public messages requiring a ':' in front to explicitly make them public (of course private messages and server commands still work as expected). Since this feature is already present in the "warclient" for 2.1: http://freeciv.freeforums.org/warclient-source-code-for-version-2-1- t22.html I will aim to commit this patch to S2_2 and trunk only, pending any objections and suggestions for improvement. --- 空手ではお前は俺にかなわないぞ。 ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40495) Server sends too much player infos
http://bugs.freeciv.org/Ticket/Display.html?id=40495 > The packet_player_info always gives the government and the gold of any players, including when you never met this player. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40494) giving units
http://bugs.freeciv.org/Ticket/Display.html?id=40494 > there should be easier way of giving units than changing owner of city, changing homecity and giving city back. Maybe new command available only if units is inside ally/teammember city? there should be easier way of giving units than changing owner of city, changing homecity and giving city back. Maybe new command available only if units is inside ally/teammember city? ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev