Author: cazfi
Date: Mon Jun 20 11:20:33 2016
New Revision: 32928

URL: http://svn.gna.org/viewcvs/freeciv?rev=32928&view=rev
Log:
Added packet type web_city_info_addition to be sent on freeciv-web mode.

See patch #7279

Modified:
    trunk/client/packhand.c
    trunk/common/networking/packets.def
    trunk/common/networking/packets.h
    trunk/fc_version
    trunk/server/citytools.c
    trunk/server/citytools.h
    trunk/server/diplomats.c

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=32928&r1=32927&r2=32928&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Mon Jun 20 11:20:33 2016
@@ -879,6 +879,16 @@
           || (city_is_new && 0 < city_num_trade_routes(pcity)))) {
     update_map_canvas_visible();
   }
+}
+
+/****************************************************************************
+  This is packet that only the web-client needs. Regular client has no use
+  for it.
+  TODO: Do not generate code calling this in C-client.
+****************************************************************************/
+void handle_web_city_info_addition(int granary_size, int granary_turns,
+                                   int buy_gold_cost)
+{
 }
 
 /****************************************************************************

Modified: trunk/common/networking/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/networking/packets.def?rev=32928&r1=32927&r2=32928&view=diff
==============================================================================
--- trunk/common/networking/packets.def (original)
+++ trunk/common/networking/packets.def Mon Jun 20 11:20:33 2016
@@ -2192,3 +2192,12 @@
 PACKET_PLAY_MUSIC = 245; sc, lsend
   STRING tag[MAX_LEN_NAME];
 end
+
+/*************** Webclient specific packets ****************/
+/* Use range 256:511 for these                             */
+
+PACKET_WEB_CITY_INFO_ADDITION = 256; sc, lsend, is-game-info, force, 
cancel(PACKET_CITY_SHORT_INFO)
+  UINT16 granary_size;
+  TURN granary_turns;
+  UINT16 buy_gold_cost;
+end

Modified: trunk/common/networking/packets.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/networking/packets.h?rev=32928&r1=32927&r2=32928&view=diff
==============================================================================
--- trunk/common/networking/packets.h   (original)
+++ trunk/common/networking/packets.h   Mon Jun 20 11:20:33 2016
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/***********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,6 +20,10 @@
 struct connection;
 struct data_in;
 
+/* utility */
+#include "shared.h"            /* MAX_LEN_ADDR */
+
+/* common */
 #include "connection.h"                /* struct connection, MAX_LEN_* */
 #include "diptreaty.h"
 #include "effects.h"
@@ -27,7 +31,6 @@
 #include "improvement.h"       /* bv_imprs */
 #include "player.h"
 #include "requirements.h"
-#include "shared.h"            /* MAX_LEN_ADDR */
 #include "spaceship.h"
 #include "team.h"
 #include "tile.h"
@@ -38,7 +41,17 @@
 
 /* Used in network protocol. */
 #define MAX_LEN_MSG             1536
-#define MAX_LEN_ROUTE          2000      /* MAX_LEN_PACKET/2 - header */
+#define MAX_LEN_ROUTE          2000      /* MAX_LEN_PACKET / 2 - header */
+
+#ifdef FREECIV_WEB
+#define web_send_packet(packetname, ...) \
+  send_packet_web_ ##packetname( __VA_ARGS__ )
+#define web_lsend_packet(packetname, ...) \
+  lsend_packet_web_ ##packetname( __VA_ARGS__ )
+#else  /* FREECIV_WEB */
+#define web_send_packet(packetname, ...)
+#define web_lsend_packet(packetname, ...)
+#endif /* FREECIV_WEB */
 
 /* The size of opaque (void *) data sent in the network packet.  To avoid
  * fragmentation issues, this SHOULD NOT be larger than the standard

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=32928&r1=32927&r2=32928&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Mon Jun 20 11:20:33 2016
@@ -56,7 +56,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Jun.20b"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Jun.20c"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.c?rev=32928&r1=32927&r2=32928&view=diff
==============================================================================
--- trunk/server/citytools.c    (original)
+++ trunk/server/citytools.c    Mon Jun 20 11:20:33 2016
@@ -2098,17 +2098,19 @@
 static void broadcast_city_info(struct city *pcity)
 {
   struct packet_city_info packet;
+  struct packet_web_city_info_addition web_packet;
   struct packet_city_short_info sc_pack;
   struct player *powner = city_owner(pcity);
   struct traderoute_packet_list *routes = traderoute_packet_list_new();
 
   /* Send to everyone who can see the city. */
-  package_city(pcity, &packet, routes, FALSE);
+  package_city(pcity, &packet, &web_packet, routes, FALSE);
   players_iterate(pplayer) {
     if (can_player_see_city_internals(pplayer, pcity)) {
       if (!send_city_suppressed || pplayer != powner) {
         update_dumb_city(powner, pcity);
         lsend_packet_city_info(powner->connections, &packet, FALSE);
+        web_lsend_packet(city_info_addition, powner->connections, &web_packet, 
FALSE);
         traderoute_packet_list_iterate(routes, route_packet) {
           lsend_packet_traderoute_info(powner->connections, route_packet);
         } traderoute_packet_list_iterate_end;
@@ -2128,6 +2130,7 @@
   conn_list_iterate(game.est_connections, pconn) {
     if (conn_is_global_observer(pconn)) {
       send_packet_city_info(pconn, &packet, FALSE);
+      web_send_packet(city_info_addition, pconn, &web_packet, FALSE);
     }
   } conn_list_iterate_end;
 
@@ -2237,6 +2240,7 @@
                            struct city *pcity, struct tile *ptile)
 {
   struct packet_city_info packet;
+  struct packet_web_city_info_addition web_packet;
   struct packet_city_short_info sc_pack;
   struct player *powner = NULL;
   struct traderoute_packet_list *routes = NULL;
@@ -2255,8 +2259,9 @@
 
       /* send all info to the owner */
       update_dumb_city(powner, pcity);
-      package_city(pcity, &packet, routes, FALSE);
+      package_city(pcity, &packet, &web_packet, routes, FALSE);
       lsend_packet_city_info(dest, &packet, FALSE);
+      web_lsend_packet(city_info_addition, dest, &web_packet, FALSE);
       traderoute_packet_list_iterate(routes, route_packet) {
         lsend_packet_traderoute_info(dest, route_packet);
       } traderoute_packet_list_iterate_end;
@@ -2278,8 +2283,9 @@
       if (pcity) {
         routes = traderoute_packet_list_new();
 
-       package_city(pcity, &packet, routes, FALSE);   /* should be dumb_city 
info? */
+       package_city(pcity, &packet, &web_packet, routes, FALSE);   /* should 
be dumb_city info? */
         lsend_packet_city_info(dest, &packet, FALSE);
+        web_lsend_packet(city_info_addition, dest, &web_packet, FALSE);
         traderoute_packet_list_iterate(routes, route_packet) {
           lsend_packet_traderoute_info(dest, route_packet);
         } traderoute_packet_list_iterate_end;
@@ -2316,6 +2322,7 @@
   Fill city info packet with information about given city.
 **************************************************************************/
 void package_city(struct city *pcity, struct packet_city_info *packet,
+                  struct packet_web_city_info_addition *web_packet,
                   struct traderoute_packet_list *routes,
                  bool dipl_invest)
 {
@@ -2399,7 +2406,7 @@
 
       /* And repackage */
       recursion = TRUE;
-      package_city(pcity, packet, routes, dipl_invest);
+      package_city(pcity, packet, web_packet, routes, dipl_invest);
       recursion = FALSE;
 
       return;
@@ -2473,6 +2480,12 @@
       BV_SET(packet->improvements, improvement_index(pimprove));
     }
   } improvement_iterate_end;
+
+#ifdef FREECIV_WEB
+  web_packet->granary_size = city_granary_size(city_size_get(pcity));
+  web_packet->granary_turns = city_turns_to_grow(pcity);
+  web_packet->buy_gold_cost = city_production_buy_gold_cost(pcity);
+#endif /* FREECIV_WEB */
 }
 
 /**************************************************************************

Modified: trunk/server/citytools.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.h?rev=32928&r1=32927&r2=32928&view=diff
==============================================================================
--- trunk/server/citytools.h    (original)
+++ trunk/server/citytools.h    Mon Jun 20 11:20:33 2016
@@ -51,6 +51,7 @@
 void send_all_known_cities(struct conn_list *dest);
 void send_player_cities(struct player *pplayer);
 void package_city(struct city *pcity, struct packet_city_info *packet,
+                  struct packet_web_city_info_addition *web_packet,
                   struct traderoute_packet_list *routes,
                  bool dipl_invest);
 

Modified: trunk/server/diplomats.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/diplomats.c?rev=32928&r1=32927&r2=32928&view=diff
==============================================================================
--- trunk/server/diplomats.c    (original)
+++ trunk/server/diplomats.c    Mon Jun 20 11:20:33 2016
@@ -178,6 +178,7 @@
   struct player *cplayer;
   struct packet_unit_short_info unit_packet;
   struct packet_city_info city_packet;
+  struct packet_web_city_info_addition web_packet;
   struct traderoute_packet_list *routes;
 
   /* Fetch target city's player.  Sanity checks. */
@@ -221,10 +222,11 @@
   /* Send city info to investigator's player.
      As this is a special case we bypass send_city_info. */
   routes = traderoute_packet_list_new();
-  package_city(pcity, &city_packet, routes, TRUE);
+  package_city(pcity, &city_packet, &web_packet, routes, TRUE);
   /* We need to force to send the packet to ensure the client will receive
    * something and popup the city dialog. */
   lsend_packet_city_info(pplayer->connections, &city_packet, TRUE);
+  web_lsend_packet(city_info_addition, pplayer->connections, &web_packet, 
TRUE);
   traderoute_packet_list_iterate(routes, route_packet) {
     lsend_packet_traderoute_info(pplayer->connections, route_packet);
     FC_FREE(route_packet);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to