Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] Re: Delta and dynamic size packets
Home

[Freeciv-Dev] Re: Delta and dynamic size packets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Marko Lindqvist <marko.lindqvist@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Delta and dynamic size packets
From: Raimar Falke <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Thu, 22 Apr 2004 20:18:59 +0200

On Thu, Apr 22, 2004 at 08:16:04PM +0300, Marko Lindqvist wrote:
> 
>  Before delta, I were using this kind of packets:
> 
> {
>    /* These are sent first... */
>    int misc_variable_1;
>    int misc_variable_2;
>    ...
>    int subpacket_count;
> 
>    /* ... and then subpacket_count blocks like this are sent */
>    {
>       int sp_variable_1;
>       int sp_variable_2;
>    }
> }
> 
>  Is there any way to send this as one packet in delta?
> 
>  If I have to split this into separate packets, one for header and then 
> subpacket_count separate packets, information in receiving end would be 
> inconsistent between packets. Building temporary storages or avoiding 
> usage of inconsistent information altogether would be nightmarish job 
> (and quite error prone too).

You can do this if you split the subpacket into
fields. PACKET_UNIT_ORDERS does this:

PACKET_UNIT_ORDERS=59;cs
  UNIT unit_id;
  UINT16 length;
  BOOL repeat, vigilant;
  ORDERS orders[MAX_LEN_ROUTE:length];
  DIRECTION dir[MAX_LEN_ROUTE:length];
  COORD dest_x, dest_y;
end

The subpacket is

struct {
  ORDERS orders;
  DIRECTION dir;
};

and is repeated "length" times.

delta doesn't support real subpackets. For more complex subpackets you
can define a new struct. Here you have to provide the put and get
functions. EFFECT does this.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "The Internet is really just a series of bottlenecks 
  joined by high speed networks."
    -- Sam Wilson


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