[Freeciv-Dev] (PR#5082) [PATCH] packet_short_unit
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
This version
- Applies to latest CVS
- Compiles
- Minimally tested
Second patch is for removing capability checks (to be applied when
capstr cleared).
- Caz
packet_short_unit.diff.gz
Description: packet_short_unit.diff.gz
diff client/civclient.c client/civclient.c
--- client/civclient.c Sun Aug 17 01:20:41 2003
+++ client/civclient.c Sun Aug 17 01:20:55 2003
@@ -563,8 +563,6 @@
info.activity_count = 0;
info.goto_dest_x = 0;
info.goto_dest_y = 0;
- info.info_city_id = 0;
- info.serial_num = 0;
info.fuel = 0;
/* These fields are used. */
@@ -578,7 +576,6 @@
info.movesleft=punit->moves_left;
info.activity=punit->activity;
info.activity_target=punit->activity_target;
- info.packet_use = UNIT_INFO_IDENTITY;
send_packet_unit_info(&aconnection, &info);
}
diff client/packhand.c client/packhand.c
--- client/packhand.c Sun Aug 17 01:20:41 2003
+++ client/packhand.c Sun Aug 17 01:22:53 2003
@@ -894,57 +894,12 @@
**************************************************************************/
void handle_unit_info(struct packet_unit_info *packet)
{
- struct city *pcity;
struct unit *punit;
- /* Old server might send usr packet_unit_info about enemy unit so
- this log message is commented out for now -- caz */
- /*
if (packet->owner != game.player_idx )
freelog(LOG_ERROR, "Got packet_unit_info for unit of %s.",
game.players[packet->owner].name);
- */
-
- /* When removing capability packet_short_unit, remove this
- whole diplomat investigate block. It should appear only in
- handle_short_unit(). */
-
- /* Special case for a diplomat/spy investigating a city:
- The investigator needs to know the supported and present
- units of a city, whether or not they are fogged. So, we
- send a list of them all before sending the city info. */
- if ((packet->packet_use == UNIT_INFO_CITY_SUPPORTED) ||
- (packet->packet_use == UNIT_INFO_CITY_PRESENT)) {
- static int last_serial_num = 0;
- /* fetch city -- abort if not found */
- pcity = find_city_by_id(packet->info_city_id);
- if (!pcity) {
- return;
- }
- /* new serial number -- clear everything */
- if (last_serial_num != packet->serial_num) {
- last_serial_num = packet->serial_num;
- unit_list_iterate(pcity->info_units_supported, psunit) {
- destroy_unit_virtual(psunit);
- } unit_list_iterate_end;
- unit_list_unlink_all(&(pcity->info_units_supported));
- unit_list_iterate(pcity->info_units_present, ppunit) {
- destroy_unit_virtual(ppunit);
- } unit_list_iterate_end;
- unit_list_unlink_all(&(pcity->info_units_present));
- }
- /* okay, append a unit struct to the proper list */
- punit = unpackage_unit(packet);
- if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) {
- unit_list_insert(&(pcity->info_units_supported), punit);
- } else {
- assert(packet->packet_use == UNIT_INFO_CITY_PRESENT);
- unit_list_insert(&(pcity->info_units_present), punit);
- }
- /* done with special case */
- return;
- }
punit = unpackage_unit(packet);
handle_unit_packet_common(punit, packet->carried);
}
diff common/packets.c common/packets.c
--- common/packets.c Sun Aug 17 01:20:41 2003
+++ common/packets.c Sun Aug 17 01:24:32 2003
@@ -1291,14 +1291,6 @@
dio_put_uint8(&dout, req->goto_dest_y);
dio_put_uint16(&dout, req->activity_target);
- /* There is patch for removing capability "packet_short_unit" as
- part of RT ticket #5082. --caz */
- if(!has_capability("packet_short_unit",pc->capability)) {
- dio_put_uint8(&dout, req->packet_use);
- dio_put_uint16(&dout, req->info_city_id);
- dio_put_uint16(&dout, req->serial_num);
- }
-
if (req->fuel > 0)
dio_put_uint8(&dout, req->fuel);
@@ -1578,12 +1570,6 @@
dio_get_uint8(&din, &packet->goto_dest_y);
dio_get_uint16(&din, (int *) &packet->activity_target);
- if (!has_capability("packet_short_unit", pc->capability)) {
- dio_get_uint8(&din, &packet->packet_use);
- dio_get_uint16(&din, &packet->info_city_id);
- dio_get_uint16(&din, &packet->serial_num);
- }
-
if (dio_input_remaining(&din) >= 1) {
dio_get_uint8(&din, &packet->fuel);
} else {
@@ -1972,73 +1958,26 @@
int send_packet_short_unit(struct connection *pc,
const struct packet_short_unit *req)
{
- /* When removing capability packet_short_unit, see also
- common/packets.h packet_unit_info
- common/packets.c send_packet_unit_info()
- common/packets.c receive_packet_unit_info()
- client/packhand.c handle_unit_info()
- server/unittools.c package_unit()
-
- There is patch for removing capability "packet_short_unit" as
- part of RT ticket #5082. --caz */
-
- if (!has_capability("packet_short_unit", pc->capability)) {
-
- /* Send packet_unit_info instead. */
- struct packet_unit_info old;
-
- old.id = req->id;
- old.owner = req->owner;
- old.x = req->x;
- old.y = req->y;
- old.veteran = req->veteran;
- old.type = req->type;
- old.hp = req->hp;
- old.activity = req->activity;
- old.packet_use = req->packet_use;
- old.info_city_id = req->info_city_id;
- old.serial_num = req->serial_num;
-
- old.homecity = 0;
- old.movesleft = 0;
- old.activity_count = 0;
- old.unhappiness = 0;
- old.upkeep = 0;
- old.upkeep_food = 0;
- old.upkeep_gold = 0;
- old.ai = 0;
- old.fuel = 0;
- old.goto_dest_x = -1;
- old.goto_dest_y = -1;
- old.activity_target = 0;
- old.paradropped = 0;
- old.connecting = 0;
- old.carried = 0;
-
- return send_packet_unit_info(pc, &old);
- } /* !has_capability(packet_short_unit) */
- {
- int pack;
- SEND_PACKET_START(PACKET_SHORT_UNIT);
+ int pack;
+ SEND_PACKET_START(PACKET_SHORT_UNIT);
- dio_put_uint16(&dout, req->id);
- dio_put_uint8(&dout, req->owner);
- dio_put_uint8(&dout, req->x);
- dio_put_uint8(&dout, req->y);
- dio_put_uint8(&dout, req->type);
- dio_put_uint8(&dout, req->hp);
- dio_put_uint8(&dout, req->activity);
+ dio_put_uint16(&dout, req->id);
+ dio_put_uint8(&dout, req->owner);
+ dio_put_uint8(&dout, req->x);
+ dio_put_uint8(&dout, req->y);
+ dio_put_uint8(&dout, req->type);
+ dio_put_uint8(&dout, req->hp);
+ dio_put_uint8(&dout, req->activity);
- pack=(COND_SET_BIT(req->carried, 3) |
- COND_SET_BIT(req->veteran, 4));
- dio_put_uint8(&dout, pack);
+ pack=(COND_SET_BIT(req->carried, 3) |
+ COND_SET_BIT(req->veteran, 4));
+ dio_put_uint8(&dout, pack);
- dio_put_uint8(&dout, req->packet_use);
- dio_put_uint16(&dout, req->info_city_id);
- dio_put_uint16(&dout, req->serial_num);
+ dio_put_uint8(&dout, req->packet_use);
+ dio_put_uint16(&dout, req->info_city_id);
+ dio_put_uint16(&dout, req->serial_num);
- SEND_PACKET_END;
- }
+ SEND_PACKET_END;
}
/*************************************************************************
diff common/packets.h common/packets.h
--- common/packets.h Sun Aug 17 01:20:41 2003
+++ common/packets.h Sun Aug 17 01:20:55 2003
@@ -326,14 +326,6 @@
bool connecting;
/* in packet only, not in unit struct */
bool carried;
-
-/* These should be only at packet_short_unit. Remove when removing
- capability for packet_short_unit. */
- int packet_use; /* see enum unit_info_use */
- int info_city_id; /* for UNIT_INFO_CITY_SUPPORTED
- and UNIT_INFO_CITY_PRESENT uses */
- int serial_num; /* a 16-bit unsigned number, never zero
- (not used by UNIT_INFO_IDENTITY) */
};
/*********************************************************
diff server/unittools.c server/unittools.c
--- server/unittools.c Sun Aug 17 01:20:41 2003
+++ server/unittools.c Sun Aug 17 01:20:55 2003
@@ -1836,11 +1836,6 @@
packet->paradropped = punit->paradropped;
packet->connecting = punit->connecting;
packet->carried = carried;
-
- /* Remove when removing capability "packet_short_unit" --caz */
- packet->packet_use = UNIT_INFO_IDENTITY;
- packet->serial_num = 0;
- packet->info_city_id = 0;
}
|
|