[Freeciv-Dev] (PR#13460) consistent names for index-to-pointer lookups
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<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);
Note that get_unit_class is put at the end. This isn't actually an
index-to-pointer lookup function but it has the exact same name form as
most of the existing index-to-pointer lookups! This is very bad
(solution is to rename it and change its parameter to a struct unit_type
*, or just to remove it).
So, I'd like to make all these names consistent. Also I'd still like to
make the struct fields consistent (pstruct->index). The unit_class
currently uses an "id" field and player uses "player_no".
For the function names, there are obviously several possibilities. Any
of the above naming schemes could be extended to all the functions. I
probably prefer index_to_xxx but that's mostly because the map code uses
it and the map code already has its own naming scheme, so renaming
index_to_tile would break that scheme.
Opinions?
-jason
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13460) consistent names for index-to-pointer lookups,
Jason Short <=
|
|