URL:
<http://gna.org/bugs/?15426>
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: [email protected]
Open/Closed: Open
Release:
Discussion Lock: Any
Operating System: None
Planned Release:
_______________________________________________________
Details:
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.
JKL
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?15426>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev