Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2005:
[Freeciv-Dev] Re: (PR#13460) consistent names for index-to-pointer looku
Home

[Freeciv-Dev] Re: (PR#13460) consistent names for index-to-pointer looku

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#13460) consistent names for index-to-pointer lookups
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 1 Sep 2005 14:06:08 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13460 >

Jason Short wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13460 >
> 
> A lot of functions do index-to-pointer lookups.  Many of them have
> inconsistent names.  In a few cases this is a major problem since all
> these lookups take integers and its easy to confuse them.
> 
>   struct tile *index_to_tile(int index);
>   struct player *get_player(int player_id);
>   struct unit_type *get_unit_type(Unit_type_id id);
>   struct nation_type *get_nation_by_idx(Nation_type_id nation);
>   struct team *team_get_by_id(Team_type_id id);
>   /* techs have no lookup function */
>   struct terrain *get_terrain(Terrain_type_id type);
>   struct specialist *get_specialist(Specialist_type_id spec);
>   struct government *get_government(int gov);
> 
>   /* Connections, units, and cities have different lookup mechanisms */
> 
>   struct unit_class *get_unit_class(Unit_type_id type);

Thus I suggest:

   player_get_by_id
   unit_type_get_by_id
   nation_get_by_id
   team_get_by_id
   terrain_get_by_id
   specialist_get_by_id
   government_get_by_id
   unit_class_get_by_id

Also all pvalue->index, pvalue->id, and pvalue->xxx_id fields will be 
renamed as pvalue->id.

Still not sure how to integrate tiles (index_to_tile), 
cities/units/connections (find_xxx_by_id).

-jason





[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#13460) consistent names for index-to-pointer lookups, Jason Short <=