[Freeciv-Dev] Re: (PR#3771) Uproar display of cities
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
The attached patch adds the happy and unhappy city status to the
dumb_city and to the short_city packet.
It includes the PR#4676 patch, although this should go in separately
(first).
Untested.
jason
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.320
diff -u -r1.320 packhand.c
--- client/packhand.c 2003/07/23 13:46:01 1.320
+++ client/packhand.c 2003/07/25 14:28:18
@@ -457,8 +457,12 @@
&need_effect_update);
} impr_type_iterate_end;
- pcity->occupied =
+ /* Since we can see inside the city, just determine the client status
+ * from what we know. */
+ pcity->client.occupied =
(unit_list_size(&(map_get_tile(pcity->x, pcity->y)->units)) > 0);
+ pcity->client.happy = city_happy(pcity);
+ pcity->client.unhappy = city_unhappy(pcity);
popup = (city_is_new && can_client_change_view() &&
pcity->owner==game.player_idx && popup_new_cities)
@@ -591,16 +595,23 @@
pcity->size=packet->size;
pcity->tile_trade = packet->tile_trade;
- pcity->occupied = packet->occupied;
+ /* We can't actually see the internals of the city, but the server tells
+ * us this much. */
+ pcity->client.occupied = packet->occupied;
+ pcity->client.happy = packet->happy;
+ pcity->client.unhappy = packet->unhappy;
+
+ pcity->ppl_happy[4] = 0;
+ pcity->ppl_content[4] = 0;
+ pcity->ppl_unhappy[4] = 0;
+ pcity->ppl_angry[4] = 0;
if (packet->happy) {
- pcity->ppl_happy[4] = pcity->size;
- pcity->ppl_unhappy[4] = 0;
- pcity->ppl_angry[4] = 0;
- } else {
- pcity->ppl_happy[4] = 0;
+ pcity->ppl_happy[4] = pcity->size;
+ } else if (packet->unhappy) {
pcity->ppl_unhappy[4] = pcity->size;
- pcity->ppl_angry[4] = 0;
+ } else {
+ pcity->ppl_content[4] = pcity->size;
}
if (city_is_new) {
@@ -624,7 +635,7 @@
int i;
int x, y;
- pcity->ppl_elvis = pcity->size;
+ pcity->ppl_elvis = 0;
pcity->ppl_scientist = 0;
pcity->ppl_taxman = 0;
for (i = 0; i < NUM_TRADEROUTES; i++) {
@@ -993,7 +1004,11 @@
return;
}
if(pcity) {
- pcity->occupied =
+ /* Unit moved out of a city - update the occupied status. The
+ * logic is a little shaky since it's not clear whether we can
+ * see the internals of the city or not; however, the server should
+ * send us a city update to clear things up. */
+ pcity->client.occupied =
(unit_list_size(&(map_get_tile(pcity->x, pcity->y)->units)) > 0);
if(pcity->id==punit->homecity)
@@ -1003,7 +1018,9 @@
}
if((pcity=map_get_city(punit->x, punit->y))) {
- pcity->occupied = TRUE;
+ /* Unit moved into a city - obviously it's occupied. */
+ pcity->client.occupied = TRUE;
+
if(pcity->id == punit->homecity)
repaint_city = TRUE;
else
@@ -1086,7 +1103,8 @@
agents_unit_new(punit);
if ((pcity = map_get_city(punit->x, punit->y))) {
- pcity->occupied = TRUE;
+ /* The unit is in a city - obviously it's occupied. */
+ pcity->client.occupied = TRUE;
}
}
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.124
diff -u -r1.124 tilespec.c
--- client/tilespec.c 2003/07/24 16:17:21 1.124
+++ client/tilespec.c 2003/07/25 14:28:19
@@ -1269,7 +1269,7 @@
}
}
- if (pcity->occupied) {
+ if (pcity->client.occupied) {
*sprs++ = get_city_occupied_sprite(pcity);
}
@@ -1283,7 +1283,7 @@
if(map_has_special(pcity->x, pcity->y, S_FALLOUT))
*sprs++ = sprites.tx.fallout;
- if(city_unhappy(pcity))
+ if (pcity->client.unhappy)
*sprs++ = sprites.city.disorder;
if(tile_get_known(pcity->x, pcity->y) == TILE_KNOWN_FOGGED &&
draw_fog_of_war)
@@ -1312,14 +1312,15 @@
*sprs++ = get_city_nation_flag_sprite(pcity);
}
- if (pcity->occupied) {
+ if (pcity->client.occupied) {
*sprs++ = get_city_occupied_sprite(pcity);
}
*sprs++ = get_city_sprite(pcity);
- if (city_unhappy(pcity))
+ if (pcity->client.unhappy) {
*sprs++ = sprites.city.disorder;
+ }
return sprs - save_sprs;
}
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.132
diff -u -r1.132 city.h
--- common/city.h 2003/07/23 13:46:03 1.132
+++ common/city.h 2003/07/25 14:28:19
@@ -255,8 +255,11 @@
struct unit_list units_supported;
- /* TRUE iff there units in the town. Only set at the client. */
- bool occupied;
+ struct {
+ /* Only used at the client (the serer is omniscient). */
+ bool occupied;
+ bool happy, unhappy;
+ } client;
int steal; /* diplomats steal once; for spies, gets harder */
/* turn states */
Index: common/packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.251
diff -u -r1.251 packets.c
--- common/packets.c 2003/07/23 13:46:03 1.251
+++ common/packets.c 2003/07/25 14:28:19
@@ -1497,7 +1497,9 @@
dio_put_uint8(&dout, (COND_SET_BIT(req->happy, 0) |
COND_SET_BIT(req->capital, 1) |
COND_SET_BIT(req->walls, 2) |
- COND_SET_BIT(req->occupied, 3)));
+ COND_SET_BIT(req->occupied, 3) |
+ COND_SET_BIT(req->happy, 4) |
+ COND_SET_BIT(req->unhappy, 5)));
dio_put_uint16(&dout, req->tile_trade);
@@ -1526,6 +1528,8 @@
packet->capital = TEST_BIT(i, 1);
packet->walls = TEST_BIT(i, 2);
packet->occupied = TEST_BIT(i, 3);
+ packet->happy = TEST_BIT(i, 4);
+ packet->unhappy = TEST_BIT(i, 5);
dio_get_uint16(&din, &packet->tile_trade);
Index: common/packets.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v
retrieving revision 1.149
diff -u -r1.149 packets.h
--- common/packets.h 2003/07/23 13:46:03 1.149
+++ common/packets.h 2003/07/25 14:28:19
@@ -387,6 +387,7 @@
char name[MAX_LEN_NAME];
int size; /* uint8 */
bool happy; /* boolean */
+ bool unhappy; /* boolean */
bool capital; /* boolean */
bool walls; /* boolean */
bool occupied; /* boolean */
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.180
diff -u -r1.180 unit.c
--- common/unit.c 2003/07/21 01:19:36 1.180
+++ common/unit.c 2003/07/25 14:28:19
@@ -1173,7 +1173,7 @@
struct city *pcity = is_non_allied_city_tile(ptile, pplayer);
if (pcity
- && (pcity->occupied
+ && (pcity->client.occupied
|| map_get_known2(x1, y1, pplayer) == TILE_KNOWN_FOGGED)) {
/* If the city is fogged, we assume it's occupied */
return FALSE;
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.226
diff -u -r1.226 citytools.c
--- server/citytools.c 2003/07/24 17:41:05 1.226
+++ server/citytools.c 2003/07/25 14:28:19
@@ -1325,14 +1325,6 @@
sz_strlcpy(packet->name, pdcity->name);
packet->size=pdcity->size;
- if (map_get_known_and_seen(x, y, pplayer)) {
- /* Since the tile is visible the player can see the tile,
- and if it didn't actually have a city pdcity would be NULL */
- assert(pcity != NULL);
- packet->happy = !city_unhappy(pcity);
- } else {
- packet->happy = TRUE;
- }
if (pcity && pcity->id == pdcity->id && city_got_building(pcity, B_PALACE))
packet->capital = TRUE;
@@ -1341,6 +1333,8 @@
packet->walls = pdcity->has_walls;
packet->occupied = pdcity->occupied;
+ packet->happy = pdcity->happy;
+ packet->unhappy = pdcity->unhappy;
if (pcity && player_has_traderoute_with_city(pplayer, pcity)) {
packet->tile_trade = pcity->tile_trade;
@@ -1655,13 +1649,16 @@
* unit list to check the occupied status. */
bool occupied =
(unit_list_size(&(map_get_tile(pcity->x, pcity->y)->units)) > 0);
+ bool happy = city_happy(pcity), unhappy = city_unhappy(pcity);
if (pdcity
&& pdcity->id == pcity->id
&& strcmp(pdcity->name, pcity->name) == 0
&& pdcity->size == pcity->size
&& pdcity->has_walls == city_got_citywalls(pcity)
- && pdcity->occupied == occupied
+ && pdcity->occupied == occupied
+ && pdcity->happy == happy
+ && pdcity->unhappy == unhappy
&& pdcity->owner == pcity->owner) {
return FALSE;
}
@@ -1679,6 +1676,8 @@
pdcity->size = pcity->size;
pdcity->has_walls = city_got_citywalls(pcity);
pdcity->occupied = occupied;
+ pdcity->happy = happy;
+ pdcity->unhappy = unhappy;
pdcity->owner = pcity->owner;
return TRUE;
Index: server/maphand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.h,v
retrieving revision 1.36
diff -u -r1.36 maphand.h
--- server/maphand.h 2003/07/23 13:46:04 1.36
+++ server/maphand.h 2003/07/25 14:28:19
@@ -27,6 +27,7 @@
int id;
bool has_walls;
bool occupied;
+ bool happy, unhappy;
char name[MAX_LEN_NAME];
unsigned short size;
unsigned char owner;
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, Gregory Berkolaiko, 2003/07/17
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, Gregory Berkolaiko, 2003/07/19
- Message not available
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, Jason Short, 2003/07/19
- Message not available
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities,
Jason Short <=
- Message not available
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, Jason Short, 2003/07/25
- Message not available
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, ChrisK@xxxxxxxx, 2003/07/25
- Message not available
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, Jason Short, 2003/07/25
- Message not available
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, ChrisK@xxxxxxxx, 2003/07/25
- Message not available
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, Jason Short, 2003/07/25
- Message not available
- [Freeciv-Dev] Re: (PR#3771) Uproar display of cities, ChrisK@xxxxxxxx, 2003/07/25
[Freeciv-Dev] Re: (PR#3771) Uproar display of cities, Gregory Berkolaiko, 2003/07/25
|
|