Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#9899) Assertion failed: cont > 0, file improvement.c,
Home

[Freeciv-Dev] (PR#9899) Assertion failed: cont > 0, file improvement.c,

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: brett.albertson@xxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#9899) Assertion failed: cont > 0, file improvement.c, line 289
From: "Benoit Hudson" <bh@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 2 Sep 2004 07:20:58 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9899 >

> [jdorje - Thu Sep 02 05:22:14 2004]:
> > Enums pose a special problem all their own.  I don't see how we can do
> > anything with them but:
> >         int tmp;
> >         dio(&tmp);
> >         myenum = tmp
> > solution.
> 
> Indeed.  However this can be done "automatically" by making the field in 
> the packet struct an int.  For instance packets.def has
> 
>    type CLAUSE                = uint8(enum clause_type)
> 
> meaning the packet struct uses the enum clause_type, and we have a 
> problem.  However if this were
> 
>    type CLAUSE           = uint8(uint8)
> 
> then there would be no cast needed later, but the conversion would be 
> done automatically when the packet struct was filled out.

I think I prefer having the enum maintained as long as possible; the only 
problem is that the decision of how wide the type is should probably be 
in only one place: if someone changes the enum, they should immediately
see that they might have to change the size.  I propose we make an 
      enumtype CLAUSE = clause_type
directive.  It should use "enum clause_type" as the type for the variable it 
reads from or writes to, and "clause_type_xfer_type" as the type to be 
sending over the network.  For any enum that will be transfered, the
author must write a
    typedef uint8 clause_type_xfer_type;
after the enum.

Also, dio or maybe only enum-sending code should assert that we don't
send a value larger than what fits in the transfer type.


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