Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: [Patch] Cleanup of units and unittypes (PR#951)
Home

[Freeciv-Dev] Re: [Patch] Cleanup of units and unittypes (PR#951)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] Cleanup of units and unittypes (PR#951)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Sep 2001 11:27:24 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Sep 10, 2001 at 10:05:22PM -0400, Ross W. Wetmore wrote:
> At 03:01 AM 01/09/10 -0700, rf13@xxxxxxxxxxxxxxxxxxxxxx wrote:
> >On Mon, Sep 10, 2001 at 02:33:06AM -0400, Ross W. Wetmore wrote:
> [...]
> >> BTW: what is the real value of getting rid of Unit_Type_ids that seems
> >>      to be driving this?
> [...]
> >3) the "type" field in "struct unit *" may change to "struct unit_type
> >   *" in the long run.
> 
> If this is the case, then simply using punit->type or acity->type makes 
> a lot more sense than unit_type(punit) and city_unit_type(acity), and 
> none of this extensive CVS updating is required.

We can switch in one step, but the patch would be huge.

> Also, there is a current problem, but it can be solved by a rather
> inexpensive id range checking macro.
> 
> But with unit_type(punit) being used everywhere unchecked there are 
> going to be a lot of code constructs like
> 
>   if( punit && unit_type(punit) && unit_type(punit)-><field> == <blort> )
> 
> which doubles the function call cost (if the optimizer can't catch it
> and as it probably doesn't understand what a function might return this
> is quite likely) plus it makes for very unwieldy constructs.

Since every unit should have a valid unit type it is safe to say that
unit_type() returns a valid pointer. unit_type() may also check this
using unit_type_exists().

> Since the long term goal doesn't need this, is it not better to move
> directly to that on a struct by struct basis?

I very huge patch.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Of course, someone who knows more about this will correct me if I'm
  wrong, and someone who knows less will correct me if I'm right."
    -- David Palmer (palmer@xxxxxxxxxxxxxxxxxx)


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