Summary: BASE type should be signed
                 Project: Freeciv
            Submitted by: None
            Submitted on: Friday 02/19/2010 at 05:50 CET
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: jkl102...@yahoo.com
             Open/Closed: Open
         Discussion Lock: Any
        Operating System: None
         Planned Release: 



At revision 15190, the type "enum base_type_id" was replaced with the type
"Base_type_id", which is an int.  When this change was made, occurrences of
the enum value BASE_LAST were changed to the literal integer value "-1."
However, in the network code (common/packets.def), the associated network
type was defined as

type BASE               = uint8(Base_type_id)

Note that is an unsigned type.  Hence when the value -1 is sent as a
Base_type_id (which happens frequently), it is incorrectly received on the
other end as the value 255.

I think the right thing to do here is change the definition of BASE to the
corresponding 8-bit signed type.

type BASE               = sint8(Base_type_id)

An additional issue may be that the literal value -1 should be replaced with
a symbolic constant such as BASE_TYPE_INVALID or BASE_NONE in the code.  But
even if that is a valid issue, it is separate from this issue, which is about
how the value 0xff is interpreted when received.



Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to