Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: [Patch][RFC] Reduce superfluous tile_info packets
Home

[Freeciv-Dev] Re: [Patch][RFC] Reduce superfluous tile_info packets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx, freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch][RFC] Reduce superfluous tile_info packets
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Wed, 24 Oct 2001 17:51:12 -0700 (PDT)

--- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> The attached patch is a rough first version of a patch which change
> the server to only sent tile information if this information has
> really changed.
> 
> Test: loading a normal game (1600AD) and pressing three times return.
> Results (packet type 7 is tile info):
> 
>   without patch:
> 2:   [ 7]:  41882 packets;   376938 bytes total;     9 bytes/packet average
> 2: transmitted 534864 bytes in 44000 packets;average size per packet 12 bytes
> 
>   with patch:
> 2:   [ 7]:   4076 packets;    36684 bytes total;     9 bytes/packet average
> 2: transmitted 185739 bytes in 6000 packets;average size per packet 30 bytes
> 

Impressive. What about throught out the game? I suspect your patch should
reduce the amount of packets overall. It would be nice to see a graph
of total amount of packets sent before and packets after.

> Note that 4000 packets are needed at the start to transfer all tiles
> to the client. The human player has the Apollo Program.
> 
>       Raimar
> 
> -- 
>  email: rf13@xxxxxxxxxxxxxxxxx
>   "With a PC, I always felt limited by the software available.
>    On Unix, I am limited by my knowledge."
>     -- Peter J. Schoenster <pschon@xxxxxxxxxxxxxxxxx>
> > ? civscore.log
> ? change_field1.diff
> ? data/misc/chiefs_front.spec
> ? data/misc/shields_front.spec
> Index: client/civclient.c
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
> retrieving revision 1.102
> diff -u -r1.102 civclient.c
> --- client/civclient.c        2001/09/16 18:49:44     1.102
> +++ client/civclient.c        2001/10/24 21:32:56
> @@ -399,6 +399,10 @@
>      handle_processing_finished();
>      break;
>  
> +  case PACKET_START_TURN:
> +    handle_start_turn();
> +    break;
> +
>    default:
>      freelog(LOG_ERROR, "Received unknown packet (type %d) from server!",
> type);
>      /* Old clients (<= some 1.11.5-devel, capstr +1.11) used to exit()
> Index: common/map.c
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
> retrieving revision 1.97
> diff -u -r1.97 map.c
> --- common/map.c      2001/10/15 13:42:50     1.97
> +++ common/map.c      2001/10/24 21:32:57
> @@ -1144,11 +1144,12 @@
>    ptile->terrain  = T_UNKNOWN;
>    ptile->special  = S_NO_SPECIAL;
>    ptile->known    = 0;
> -  ptile->sent     = 0;
>    ptile->city     = NULL;
>    unit_list_init(&ptile->units);
>    ptile->worked   = NULL; /* pointer to city working tile */
>    ptile->assigned = 0; /* bitvector */
> +  ptile->server.changed = -1;
> +  ptile->server.sent = 0;
>  }
>  
>  /***************************************************************
> @@ -1181,7 +1182,10 @@
>  {
>    assert(is_real_tile(x, y));
>    normalize_map_pos(&x, &y);
> -  MAP_TILE(x, y)->continent = val;
> +  if (MAP_TILE(x, y)->continent != val) {
> +    MAP_TILE(x, y)->continent = val;
> +    map_tile_set_changed(x, y, NULL, 0);
> +  }
>  }
>  
>  
> @@ -1214,19 +1218,30 @@
>  {
>    assert(is_real_tile(x, y));
>    normalize_map_pos(&x, &y);
> -  MAP_TILE(x, y)->terrain = ter;
> +  if (MAP_TILE(x, y)->terrain != ter) {
> +    MAP_TILE(x, y)->terrain = ter;
> +    map_tile_set_changed(x, y, NULL, 1);
> +  }
>  }
>  
>  /***************************************************************
>  ...
>  ***************************************************************/
> -void map_set_special(int x, int y, enum tile_special_type spe)
> +void base_map_set_special(int x, int y, enum tile_special_type spe)
>  {
>    assert(is_real_tile(x, y));
>    normalize_map_pos(&x, &y);
>  
>    MAP_TILE(x, y)->special |= spe;
> +}
>  
> +void map_set_special(int x, int y, enum tile_special_type spe)
> +{
> +  if (!(MAP_TILE(x, y)->special & spe)) {
> +    map_tile_set_changed(x, y, NULL, 2);
> +  }
> +  base_map_set_special(x, y, spe);
> +
>    if (spe & (S_ROAD | S_RAILROAD))
>      reset_move_costs(x, y);
>  }
> @@ -1234,12 +1249,22 @@
>  /***************************************************************
>  ...
>  ***************************************************************/
> -void map_clear_special(int x, int y, enum tile_special_type spe)
> +void base_map_clear_special(int x, int y, enum tile_special_type spe)
>  {
>    assert(is_real_tile(x, y));
>    normalize_map_pos(&x, &y);
> -  MAP_TILE(x, y)->special &= ~spe;
>  
> +  if (MAP_TILE(x, y)->special & spe) {
> +    MAP_TILE(x, y)->special &= ~spe;
> +  }
> +}
> +
> +void map_clear_special(int x, int y, enum tile_special_type spe)
> +{
> +  if (MAP_TILE(x, y)->special & spe) {
> +    map_tile_set_changed(x, y, NULL, 3);
> +  }
> +  base_map_clear_special(x, y, spe);
>    if (spe & (S_ROAD | S_RAILROAD))
>      reset_move_costs(x, y);
>  }
> @@ -1431,4 +1456,37 @@
>  
>    /* FIXME: this check will not work with an orthogonal map */
>    return (start_x == end_x) || (start_y == end_y);
> +}
> +
> +/***************************************************************
> +...
> +***************************************************************/
> +void map_tile_set_changed(int x, int y, struct player *pplayer, int n)
> +{
> +  if (pplayer) {
> +    if(!pplayer->ai.control)
> +     freelog(LOG_NORMAL, "map_tile_set_changed(x=%d, y=%d, player=%s n=%d)",
> +             x, y, pplayer->name, n);
> +    MAP_TILE(x, y)->server.changed |= (1u << pplayer->player_no);
> +  } else {
> +    freelog(LOG_NORMAL, "map_tile_set_changed(x=%d, y=%d, no player n=%d)",
> +         x, y, n);
> +    MAP_TILE(x, y)->server.changed = 0xffffffff;
> +  }
> +}
> +
> +/***************************************************************
> +...
> +***************************************************************/
> +void map_tile_clear_changed(int x, int y, struct player *pplayer)
> +{
> +  MAP_TILE(x, y)->server.changed &= ~(1u << pplayer->player_no);
> +}
> +
> +/***************************************************************
> +...
> +***************************************************************/
> +int map_tile_get_changed(int x, int y, struct player *pplayer)
> +{
> +  return 1||(MAP_TILE(x, y)->server.changed & (1u << pplayer->player_no));
>  }
> Index: common/map.h
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
> retrieving revision 1.100
> diff -u -r1.100 map.h
> --- common/map.h      2001/10/19 08:12:52     1.100
> +++ common/map.h      2001/10/24 21:32:57
> @@ -52,13 +52,17 @@
>    unsigned int known;   /* A bitvector on the server side, an
>                          enum known_type on the client side.
>                          Player_no is index */
> -  unsigned int sent;    /* Indicates if  the client know the tile
> -                        as TILE_KNOWN_NODRAW. A bitvector like known.
> -                        Not used on the client side. */
>    int assigned; /* these can save a lot of CPU usage -- Syela */
>    struct city *worked;      /* city working tile, or NULL if none */
>    signed short continent;
>    signed char move_cost[8]; /* don't know if this helps! */
> +  struct {
> +    unsigned int changed;
> +    unsigned int sent;               /* Indicates if the client know the
> +                                tile as TILE_KNOWN_NODRAW. A
> +                                bitvector like known.  Not used on
> +                                the client side. */
> +  } server;
>  };
>  
>  
> @@ -269,7 +273,9 @@
>  enum tile_special_type map_get_special(int x, int y);
>  void map_set_terrain(int x, int y, enum tile_terrain_type ter);
>  void map_set_special(int x, int y, enum tile_special_type spe);
> +void base_map_set_special(int x, int y, enum tile_special_type spe);
>  void map_clear_special(int x, int y, enum tile_special_type spe);
> +void base_map_clear_special(int x, int y, enum tile_special_type spe);
>  void tile_init(struct tile *ptile);
>  enum known_type tile_is_known(int x, int y);
>  int is_real_tile(int x, int y);
> @@ -334,6 +340,10 @@
>  
>  int can_channel_land(int x, int y);
>  int can_reclaim_ocean(int x, int y);
> +
> +void map_tile_set_changed(int x, int y, struct player *pplayer, int n);
> +int map_tile_get_changed(int x, int y, struct player *pplayer);
> +void map_tile_clear_changed(int x, int y, struct player *pplayer);
>  
>  extern struct civ_map map;
>  
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com


[Prev in Thread] Current Thread [Next in Thread]