[Freeciv-Dev] (PR#7224) City styles should be saved by name
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7224) City styles should be saved by name |
From: |
"mateusz stefek" <matusik_s@xxxxx> |
Date: |
Thu, 8 Jan 2004 23:27:16 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7224 >
Start CVS-Freeciv, select tropical city style, build a city, save the game,
load it in Freeciv-1.14.1.
That's why I wrote attached patch. It just saves city styles by name. (just
like nations).
--
mateusz
diff -ur -Xdiff_ignore freeorig/client/gui-gtk/dialogs.c
freeciv/client/gui-gtk/dialogs.c
--- freeorig/client/gui-gtk/dialogs.c 2003-12-02 09:15:37.000000000 +0100
+++ freeciv/client/gui-gtk/dialogs.c 2003-12-16 11:27:41.000000000 +0100
@@ -2151,7 +2151,7 @@
box = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(city_style_toggles[i]), box);
gtk_box_pack_start(GTK_BOX(box),
- gtk_label_new(city_styles[city_style_idx[i]].name),
+ gtk_label_new(get_city_style_name(city_style_idx[i])),
FALSE, FALSE, 4);
sub_box = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box), sub_box);
diff -ur -Xdiff_ignore freeorig/client/gui-gtk-2.0/dialogs.c
freeciv/client/gui-gtk-2.0/dialogs.c
--- freeorig/client/gui-gtk-2.0/dialogs.c 2003-12-02 09:15:37.000000000
+0100
+++ freeciv/client/gui-gtk-2.0/dialogs.c 2003-12-16 11:27:41.000000000
+0100
@@ -1911,7 +1911,8 @@
s = crop_blankspace(sprites.city.tile[i][last]);
img = gdk_pixbuf_new_from_sprite(s);
free_sprite(s);
- gtk_list_store_set(store, &it, 0, i, 1, img, 2, city_styles[i].name, -1);
+ gtk_list_store_set(store, &it, 0, i, 1, img, 2,
+ get_city_style_name(i), -1);
g_object_unref(img);
}
diff -ur -Xdiff_ignore freeorig/common/city.c freeciv/common/city.c
--- freeorig/common/city.c 2003-12-12 09:50:29.000000000 +0100
+++ freeciv/common/city.c 2003-12-16 11:27:41.000000000 +0100
@@ -1293,6 +1293,40 @@
}
/**************************************************************************
+Get index to city_styles for untranslated style name.
+**************************************************************************/
+int get_style_by_name_orig(const char *style_name)
+{
+ int i;
+
+ for( i=0; i<game.styles_count; i++) {
+ if (strcmp(style_name, city_styles[i].name_orig) == 0)
+ break;
+ }
+ if( i < game.styles_count )
+ return i;
+ else
+ return -1;
+}
+
+/**************************************************************************
+ ...
+**************************************************************************/
+char* get_city_style_name(int style)
+{
+ return city_styles[style].name;
+}
+
+
+/**************************************************************************
+ ...
+**************************************************************************/
+char* get_city_style_name_orig(int style)
+{
+ return city_styles[style].name_orig;
+}
+
+/**************************************************************************
Compute and optionally apply the change-production penalty for the given
production change (to target,is_unit) in the given city (pcity).
Always returns the number of shields which would be in the stock if
diff -ur -Xdiff_ignore freeorig/common/city.h freeciv/common/city.h
--- freeorig/common/city.h 2003-12-12 09:50:29.000000000 +0100
+++ freeciv/common/city.h 2003-12-16 11:27:41.000000000 +0100
@@ -434,6 +434,9 @@
int get_city_style(struct city *pcity);
int get_player_city_style(struct player *plr);
int get_style_by_name(const char *);
+int get_style_by_name_orig(const char *);
+char* get_city_style_name(int style);
+char* get_city_style_name_orig(int style);
struct city *is_enemy_city_tile(struct tile *ptile, struct player *pplayer);
struct city *is_allied_city_tile(struct tile *ptile,
diff -ur -Xdiff_ignore freeorig/server/savegame.c freeciv/server/savegame.c
--- freeorig/server/savegame.c 2003-12-12 09:50:48.000000000 +0100
+++ freeciv/server/savegame.c 2003-12-16 11:48:01.000000000 +0100
@@ -594,7 +594,7 @@
static void player_load(struct player *plr, int plrno,
struct section_file *file)
{
- int i, j, x, y, nunits, ncities;
+ int i, j, x, y, nunits, ncities, c_s;
char *p;
char *savefile_options = secfile_lookup_str(file, "savefile.options");
@@ -650,9 +650,25 @@
}
plr->government=secfile_lookup_int(file, "player%d.government", plrno);
plr->embassy=secfile_lookup_int(file, "player%d.embassy", plrno);
- plr->city_style=secfile_lookup_int_default(file,
get_nation_city_style(plr->nation),
- "player%d.city_style", plrno);
+ p = secfile_lookup_str_default(file, NULL, "player%d.city_style_by_name",
+ plrno);
+ if (!p) {
+ char* old_order[4] = {"European", "Classical", "Tropical", "Asian"};
+ c_s = secfile_lookup_int_default(file, 0, "player%d.city_style", plrno);
+ if (c_s < 0 || c_s > 3) {
+ c_s = 0;
+ }
+ p = old_order[c_s];
+ }
+ c_s = get_style_by_name_orig(p);
+ if (c_s == -1) {
+ freelog(LOG_ERROR, _("Unsupported city style found in player%d section. "
+ "Changed to %s"), plrno, get_city_style_name(0));
+ c_s = 0;
+ }
+ plr->city_style = c_s;
+
plr->nturns_idle=0;
plr->is_male=secfile_lookup_bool_default(file, TRUE, "player%d.is_male",
plrno);
plr->is_alive=secfile_lookup_bool(file, "player%d.is_alive", plrno);
@@ -1376,7 +1392,10 @@
secfile_insert_int(file, plr->government, "player%d.government", plrno);
secfile_insert_int(file, plr->embassy, "player%d.embassy", plrno);
- secfile_insert_int(file, plr->city_style, "player%d.city_style", plrno);
+ secfile_insert_str(file, get_city_style_name_orig(plr->city_style),
+ "player%d.city_style_by_name", plrno);
+ /* This field won't be used, kept only for backward compatibility */
+ secfile_insert_int(file, 0, "player%d.city_style", plrno);
secfile_insert_bool(file, plr->is_male, "player%d.is_male", plrno);
secfile_insert_bool(file, plr->is_alive, "player%d.is_alive", plrno);
secfile_insert_bool(file, plr->ai.control, "player%d.ai.control", plrno);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#7224) City styles should be saved by name,
mateusz stefek <=
|
|