[Freeciv-Dev] (PR#13556) use the city_production struct in pcity->change
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13556 >
This patch changes pcity->changed_from_is_unit and changed_from_id to
use the city_production struct as pcity->changed_from.
Aside from the city.h and network (citytools/packhand) bits, it is
simple search-and-replace:
s/changed_from_is_unit/changed_from.is_unit/
s/changed_from_id/changed_from.value/
-jason
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.539
diff -p -u -r1.539 packhand.c
--- client/packhand.c 26 Jul 2005 16:35:57 -0000 1.539
+++ client/packhand.c 28 Jul 2005 18:35:32 -0000
@@ -481,8 +481,8 @@ void handle_city_info(struct packet_city
pcity->turn_last_built=packet->turn_last_built;
pcity->turn_founded = packet->turn_founded;
- pcity->changed_from_id=packet->changed_from_id;
- pcity->changed_from_is_unit=packet->changed_from_is_unit;
+ pcity->changed_from.value = packet->changed_from_id;
+ pcity->changed_from.is_unit = packet->changed_from_is_unit;
pcity->before_change_shields=packet->before_change_shields;
pcity->disbanded_shields=packet->disbanded_shields;
pcity->caravan_shields=packet->caravan_shields;
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.361
diff -p -u -r1.361 city.c
--- common/city.c 26 Jul 2005 17:21:54 -0000 1.361
+++ common/city.c 28 Jul 2005 18:35:33 -0000
@@ -1208,9 +1208,9 @@ int city_change_production_penalty(const
enum production_class_type new_class;
int unpenalized_shields = 0, penalized_shields = 0;
- if (pcity->changed_from_is_unit)
+ if (pcity->changed_from.is_unit)
orig_class=TYPE_UNIT;
- else if (is_wonder(pcity->changed_from_id))
+ else if (is_wonder(pcity->changed_from.value))
orig_class=TYPE_WONDER;
else
orig_class=TYPE_NORMAL_IMPROVEMENT;
@@ -2448,8 +2448,8 @@ struct city *create_city_virtual(struct
pcity->airlift = FALSE;
pcity->turn_last_built = game.info.turn;
- pcity->changed_from_id = pcity->production.value;
- pcity->changed_from_is_unit = pcity->production.is_unit;
+ pcity->changed_from.value = pcity->production.value;
+ pcity->changed_from.is_unit = pcity->production.is_unit;
pcity->before_change_shields = 0;
pcity->disbanded_shields = 0;
pcity->caravan_shields = 0;
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.221
diff -p -u -r1.221 city.h
--- common/city.h 28 Jul 2005 17:59:06 -0000 1.221
+++ common/city.h 28 Jul 2005 18:35:34 -0000
@@ -266,8 +266,10 @@ struct city {
bool did_buy;
bool did_sell, is_updated;
int turn_last_built; /* The last year in which something was built */
- int changed_from_id; /* If changed this turn, what changed from (id) */
- bool changed_from_is_unit; /* If changed this turn, what changed from
(unit?) */
+
+ /* If changed this turn, what we changed from */
+ struct city_production changed_from;
+
int disbanded_shields; /* If you disband unit in a city. Count them */
int caravan_shields; /* If caravan has helped city to build wonder. */
int before_change_shields; /* If changed this turn, shields before penalty
*/
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.340
diff -p -u -r1.340 citytools.c
--- server/citytools.c 26 Jul 2005 16:36:00 -0000 1.340
+++ server/citytools.c 28 Jul 2005 18:35:35 -0000
@@ -1574,8 +1574,8 @@ void package_city(struct city *pcity, st
packet->turn_last_built=pcity->turn_last_built;
packet->turn_founded = pcity->turn_founded;
- packet->changed_from_id=pcity->changed_from_id;
- packet->changed_from_is_unit=pcity->changed_from_is_unit;
+ packet->changed_from_id = pcity->changed_from.value;
+ packet->changed_from_is_unit = pcity->changed_from.is_unit;
packet->before_change_shields=pcity->before_change_shields;
packet->disbanded_shields=pcity->disbanded_shields;
packet->caravan_shields=pcity->caravan_shields;
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.326
diff -p -u -r1.326 cityturn.c
--- server/cityturn.c 26 Jul 2005 16:36:00 -0000 1.326
+++ server/cityturn.c 28 Jul 2005 18:35:35 -0000
@@ -1409,15 +1409,15 @@ static void define_orig_production_value
* city have been dedicated toward the project that was chosen last turn,
* so the player shouldn't be penalized if the governor has to pick
* something different. See city_change_production_penalty(). */
- pcity->changed_from_id = pcity->production.value;
- pcity->changed_from_is_unit = pcity->production.is_unit;
+ pcity->changed_from.value = pcity->production.value;
+ pcity->changed_from.is_unit = pcity->production.is_unit;
freelog(LOG_DEBUG,
"In %s, building %s. Beg of Turn shields = %d",
pcity->name,
- pcity->changed_from_is_unit ?
- get_unit_type(pcity->changed_from_id)->name :
- get_improvement_name(pcity->changed_from_id),
+ pcity->changed_from.is_unit ?
+ get_unit_type(pcity->changed_from.value)->name :
+ get_improvement_name(pcity->changed_from.value),
pcity->before_change_shields
);
}
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.270
diff -p -u -r1.270 savegame.c
--- server/savegame.c 28 Jul 2005 17:59:07 -0000 1.270
+++ server/savegame.c 28 Jul 2005 18:35:36 -0000
@@ -2066,26 +2066,26 @@ static void player_load(struct player *p
* way to convert this into a turn value. */
pcity->turn_last_built = 0;
}
- pcity->changed_from_is_unit=
+ pcity->changed_from.is_unit=
secfile_lookup_bool_default(file, pcity->production.is_unit,
- "player%d.c%d.changed_from_is_unit", plrno, i);
+ "player%d.c%d.changed_from.is_unit", plrno, i);
name = secfile_lookup_str_default(file, NULL,
"player%d.c%d.changed_from_name",
plrno, i);
- if (pcity->changed_from_is_unit) {
+ if (pcity->changed_from.is_unit) {
if (!name) {
- id = secfile_lookup_int(file, "player%d.c%d.changed_from_id",
+ id = secfile_lookup_int(file, "player%d.c%d.changed_from.value",
plrno, i);
name = old_unit_type_name(id);
}
- pcity->changed_from_id = find_unit_type_by_name_orig(name)->index;
+ pcity->changed_from.value = find_unit_type_by_name_orig(name)->index;
} else {
if (!name) {
- id = secfile_lookup_int(file, "player%d.c%d.changed_from_id",
+ id = secfile_lookup_int(file, "player%d.c%d.changed_from.value",
plrno, i);
name = old_impr_type_name(id);
}
- pcity->changed_from_id = find_improvement_by_name_orig(name);
+ pcity->changed_from.value = find_improvement_by_name_orig(name);
}
pcity->before_change_shields=
@@ -2802,19 +2802,19 @@ static void player_save(struct player *p
plrno, i);
secfile_insert_int(file, pcity->turn_last_built,
"player%d.c%d.turn_last_built", plrno, i);
- secfile_insert_bool(file, pcity->changed_from_is_unit,
- "player%d.c%d.changed_from_is_unit", plrno, i);
- if (pcity->changed_from_is_unit) {
- struct unit_type *punittype = get_unit_type(pcity->changed_from_id);
+ secfile_insert_bool(file, pcity->changed_from.is_unit,
+ "player%d.c%d.changed_from.is_unit", plrno, i);
+ if (pcity->changed_from.is_unit) {
+ struct unit_type *punittype = get_unit_type(pcity->changed_from.value);
secfile_insert_int(file, old_unit_type_id(punittype),
- "player%d.c%d.changed_from_id", plrno, i);
+ "player%d.c%d.changed_from.value", plrno, i);
secfile_insert_str(file, unit_name_orig(punittype),
"player%d.c%d.changed_from_name", plrno, i);
} else {
- secfile_insert_int(file, old_impr_type_id(pcity->changed_from_id),
- "player%d.c%d.changed_from_id", plrno, i);
+ secfile_insert_int(file, old_impr_type_id(pcity->changed_from.value),
+ "player%d.c%d.changed_from.value", plrno, i);
secfile_insert_str(file, get_improvement_name_orig(
- pcity->changed_from_id),
+ pcity->changed_from.value),
"player%d.c%d.changed_from_name", plrno, i);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13556) use the city_production struct in pcity->changed_from,
Jason Short <=
|
|