Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] Re: (PR#3649) Network usage optimization
Home

[Freeciv-Dev] Re: (PR#3649) Network usage optimization

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] Re: (PR#3649) Network usage optimization
From: "Arnstein Lindgard" <arnstein.lindgard@xxxxxxx>
Date: Fri, 7 Mar 2003 13:15:09 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Fri, 7 Mar 2003 10:43:08 -0800
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> wrote:

> - I'd like to see assertions somewhere to verify that the variables do 
> fall within the smaller bounds.  Perhaps this is going too far, though; 
> it seems obvious that they do.

At first glance it seems obvious. I can demonstrate that none of
the int's are likely to exceed 255, which is uint8 limit.

struct player_diplstate {
  enum diplstate_type type;     /* this player's disposition towards other */
  /* the following are for "pacts" */
  int turns_left;               /* until pact (e.g., cease-fire) ends */
  int has_reason_to_cancel;     /* 0: no, 1: this turn, 2: this or next turn */
};

enum diplstate_type {
  DS_NEUTRAL = 0,
  DS_WAR,
  DS_CEASEFIRE,
  DS_PEACE,
  DS_ALLIANCE,
  DS_NO_CONTACT,
  DS_LAST       /* leave this last */
};

Turns_left is set to 16 and counting down, and the last item is
almost a bool. I don't know, did you maybe think that one of the
int's could reach -1, and that would cause problems with the
uint8 in the serializer?

Or are you just saying it would be good coding practice generally to
use asserts when you change something fundamental, and leave it in
there for awhile? I'm not sure why and where to put any asserts here.


Arnstein



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