[Freeciv-Dev] (PR#5789) Don't send info about transported units to clien
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Attached is most of a patch to accomplish this.
The client-side code is probably complete. The remaining problems are
at the server end, because transported_by still isn't handled very
rigorously. When a unit moves onto or off of a transporter we need to
send updated information about the transporter.
There's also a problem with send_unit_info_to_onlookers: this packet is
used to send actions as well as general info. So for instance if a unit
moves onto a tririeme, the movement will not be sent because it's on a
tririeme. Just as with moving into/out of cities, we have to make an
exception in this case. A short-term solution would be the introduction
of a boolean 'force' option. A long-term one would probably separate
action packets from info packets (this problem exists elsewhere; for
instance with revolution ending).
jason
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.112
diff -u -r1.112 control.c
--- client/control.c 2003/09/15 16:05:35 1.112
+++ client/control.c 2003/09/19 21:11:52
@@ -1361,14 +1361,15 @@
return;
}
- if(unit_list_size(&ptile->units) == 1) {
+ if (unit_list_size(&ptile->units) == 1
+ && !unit_list_get(&ptile->units, 0)->client.occupied) {
struct unit *punit=unit_list_get(&ptile->units, 0);
if(game.player_idx==punit->owner) {
if(can_unit_do_activity(punit, ACTIVITY_IDLE)) {
set_unit_focus_and_select(punit);
}
}
- } else if(unit_list_size(&ptile->units) >= 2) {
+ } else if(unit_list_size(&ptile->units) > 0) {
/* The stack list is always popped up, even if it includes enemy units.
* If the server doesn't want the player to know about them it shouldn't
* tell him! The previous behavior would only pop up the stack if you
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.58
diff -u -r1.58 mapview_common.c
--- client/mapview_common.c 2003/08/12 18:54:37 1.58
+++ client/mapview_common.c 2003/09/19 21:11:52
@@ -416,9 +416,9 @@
int unit_offset_x, int unit_offset_y,
int unit_width, int unit_height)
{
- struct drawn_sprite sprites[40];
+ struct drawn_sprite drawn_sprites[40];
bool solid_bg;
- int count = fill_unit_sprite_array(sprites, punit, &solid_bg), i;
+ int count = fill_unit_sprite_array(drawn_sprites, punit, &solid_bg), i;
if (!is_isometric && solid_bg) {
gui_put_rectangle(pcanvas_store, player_color(unit_owner(punit)),
@@ -426,15 +426,21 @@
}
for (i = 0; i < count; i++) {
- if (sprites[i].sprite) {
- int ox = sprites[i].offset_x, oy = sprites[i].offset_y;
+ if (drawn_sprites[i].sprite) {
+ int ox = drawn_sprites[i].offset_x, oy = drawn_sprites[i].offset_y;
/* units are never fogged */
gui_put_sprite(pcanvas_store, canvas_x + ox, canvas_y + oy,
- sprites[i].sprite,
+ drawn_sprites[i].sprite,
unit_offset_x - ox, unit_offset_y - oy,
unit_width - ox, unit_height - oy);
}
+ }
+
+ if (punit->client.occupied) {
+ gui_put_sprite(pcanvas_store, canvas_x, canvas_y,
+ sprites.unit.stack,
+ unit_offset_x, unit_offset_y, unit_width, unit_height);
}
}
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.330
diff -u -r1.330 packhand.c
--- client/packhand.c 2003/09/15 19:40:52 1.330
+++ client/packhand.c 2003/09/19 21:11:52
@@ -109,6 +109,7 @@
punit->activity_target = packet->activity_target;
punit->paradropped = packet->paradropped;
punit->connecting = packet->connecting;
+ punit->client.occupied = FALSE;
return punit;
}
@@ -130,6 +131,7 @@
punit->veteran = packet->veteran;
punit->hp = packet->hp;
punit->activity = packet->activity;
+ punit->client.occupied = packet->occupied;
return punit;
}
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.131
diff -u -r1.131 tilespec.c
--- client/tilespec.c 2003/08/28 16:02:03 1.131
+++ client/tilespec.c 2003/09/19 21:11:52
@@ -2079,8 +2079,10 @@
if (punit && (draw_units || (draw_focus_unit && pfocus == punit))) {
sprs += fill_unit_sprite_array(sprs, punit, solid_bg);
*pplayer = unit_owner(punit);
- if (unit_list_size(&ptile->units) > 1)
+ if (unit_list_size(&ptile->units) > 1
+ || unit_list_get(&ptile->units, 0)->client.occupied) {
ADD_SPRITE_SIMPLE(sprites.unit.stack);
+ }
return sprs - save_sprs;
}
@@ -2234,7 +2236,8 @@
no_backdrop = (pcity != NULL);
sprs += fill_unit_sprite_array(sprs, punit, &dummy);
no_backdrop = FALSE;
- if (unit_list_size(&ptile->units) > 1) {
+ if (unit_list_size(&ptile->units) > 1
+ || unit_list_get(&ptile->units, 0)->client.occupied) {
ADD_SPRITE_SIMPLE(sprites.unit.stack);
}
}
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.143
diff -u -r1.143 capstr.c
--- common/capstr.c 2003/09/09 20:10:28 1.143
+++ common/capstr.c 2003/09/19 21:11:52
@@ -80,7 +80,7 @@
"+no_nation_selected +diplomacy +no_extra_tiles " \
"+diplomacy2 +citizens_style +root_tech auth " \
"+nat_ulimit +retake +goto_pack borders dip " \
- "+packet_short_unit"
+ "+packet_short_unit +unit_occupied"
/* "+1.14.0" is protocol for 1.14.0 release.
*
@@ -149,6 +149,9 @@
*
* "packet_short_unit" is packet sent instead of full packet_unit_info to
* enemies, so that not all info about the unit is sent.
+ *
+ * "unit_occupied" means units occupying transporters are not sent to enemies.
+ * instead an 'occupied' flag is set for the transporter.
*/
void init_our_capability(void)
Index: common/packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.256
diff -u -r1.256 packets.c
--- common/packets.c 2003/09/15 19:40:53 1.256
+++ common/packets.c 2003/09/19 21:11:52
@@ -1980,7 +1980,8 @@
dio_put_uint8(&dout, req->activity);
pack = (COND_SET_BIT(req->carried, 3)
- | COND_SET_BIT(req->veteran, 4));
+ | COND_SET_BIT(req->veteran, 4)
+ | COND_SET_BIT(req->occupied, 5));
dio_put_uint8(&dout, pack);
dio_put_uint8(&dout, req->packet_use);
@@ -2010,6 +2011,7 @@
dio_get_uint8(&din, &pack);
packet->carried = TEST_BIT(pack, 3);
packet->veteran = TEST_BIT(pack, 4);
+ packet->occupied = TEST_BIT(pack, 5);
dio_get_uint8(&din, &packet->packet_use);
dio_get_uint16(&din, &packet->info_city_id);
Index: common/packets.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v
retrieving revision 1.153
diff -u -r1.153 packets.h
--- common/packets.h 2003/09/15 19:40:53 1.153
+++ common/packets.h 2003/09/19 21:11:52
@@ -345,6 +345,7 @@
int type;
int hp;
int activity;
+ bool occupied;
/* in packet only, not in unit struct */
int carried; /* FIXME: should not send carried units at all? */
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.182
diff -u -r1.182 unit.c
--- common/unit.c 2003/08/26 08:36:24 1.182
+++ common/unit.c 2003/09/19 21:11:52
@@ -1481,6 +1481,7 @@
punit->ord_map = 0;
punit->ord_city = 0;
set_unit_activity(punit, ACTIVITY_IDLE);
+ punit->client.occupied = FALSE;
return punit;
}
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.99
diff -u -r1.99 unit.h
--- common/unit.h 2003/08/26 11:12:52 1.99
+++ common/unit.h 2003/09/19 21:11:52
@@ -137,6 +137,10 @@
bool paradropped;
bool connecting;
int transported_by;
+ struct {
+ /* Only used at the client (the server is omniscient). */
+ bool occupied; /* True iff the transporter is occupied. */
+ } client;
struct goto_route *pgr;
};
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.251
diff -u -r1.251 unittools.c
--- server/unittools.c 2003/09/19 14:14:45 1.251
+++ server/unittools.c 2003/09/19 21:11:52
@@ -1861,6 +1861,7 @@
packet->veteran = punit->veteran;
packet->type = punit->type;
packet->hp = punit->hp;
+ packet->occupied = (get_transporter_occupancy(punit) > 0);
if (punit->activity == ACTIVITY_GOTO
|| punit->activity == ACTIVITY_EXPLORE
@@ -1891,8 +1892,10 @@
}
package_unit(punit, &info, carried);
- package_short_unit(punit, &sinfo, carried,
- UNIT_INFO_IDENTITY, FALSE, FALSE);
+ if (punit->transported_by == -1) {
+ package_short_unit(punit, &sinfo, carried,
+ UNIT_INFO_IDENTITY, FALSE, FALSE);
+ }
conn_list_iterate(*dest, pconn) {
struct player *pplayer = pconn->player;
@@ -1906,7 +1909,7 @@
if ((!pplayer && pconn->observer)
|| pplayer->player_no == punit->owner) {
send_packet_unit_info(pconn, &info);
- } else if (see_pos || see_xy) {
+ } else if ((see_pos || see_xy) && (punit->transported_by == -1)) {
send_packet_short_unit(pconn, &sinfo);
}
} conn_list_iterate_end;
- [Freeciv-Dev] (PR#5789) Don't send info about transported units to clients without shared vision,
Jason Short <=
- Message not available
|
|