[Freeciv-Dev] Re: (PR#3771) Uproar display of cities
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Jason Short wrote:
> 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.
And an update. Still untested.
jason
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.321
diff -u -r1.321 packhand.c
--- client/packhand.c 2003/07/25 14:48:32 1.321
+++ client/packhand.c 2003/07/25 15:40:33
@@ -457,10 +457,12 @@
&need_effect_update);
} impr_type_iterate_end;
- /* Since we can see inside the city, just determine the occupied status
- * from the units present. */
+ /* 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)
@@ -597,15 +599,19 @@
/* 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) {
@@ -629,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++) {
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.125
diff -u -r1.125 tilespec.c
--- client/tilespec.c 2003/07/25 14:48:32 1.125
+++ client/tilespec.c 2003/07/25 15:40:33
@@ -1283,8 +1283,9 @@
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)
*sprs++ = sprites.tx.fog;
@@ -1318,8 +1319,9 @@
*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.133
diff -u -r1.133 city.h
--- common/city.h 2003/07/25 14:48:32 1.133
+++ common/city.h 2003/07/25 15:40:33
@@ -257,8 +257,9 @@
struct {
/* Only used at the client (the serer is omniscient). */
- bool occupied;
- } client;
+ 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 15:40:33
@@ -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 15:40:33
@@ -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: 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 15:40:34
@@ -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 15:40:34
@@ -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, 2003/07/25
- 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, 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
|
|