Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] Small improvement at genlist and maphand
Home

[Freeciv-Dev] Re: [PATCH] Small improvement at genlist and maphand

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] Small improvement at genlist and maphand
From: Markus Linnala <maage@xxxxxxxxx>
Date: 20 Aug 2001 23:15:02 +0300
Reply-to: Markus Linnala <maage@xxxxxxxxx>

Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> writes:

> It is. I would like a discussion what is preferred: id or pointer. If
> one type is selected we can start our crusade.

With get_player, I think we need both and both inlined.
get_player is there to make things more understandable. Maybe we
should make some extra checks.

------------------------------------------------------------------------
struct player *get_player(int player_id)
{
    assert(player_id >= 0 && player_id < game.max_players);
    return &game.players[player_id];
}
int get_player_by_id(struct player *pplayer)
{
    assert(pplayer->player_no >= 0 && pplayer->player_no < game.max_players);
    return pplayer->player_no;
}
------------------------------------------------------------------------

Or something like that. Well, not so good example. But as simple
functions as these are, you might get smaller code size and game
is definitely faster when you get rid of actual function call.

-- 
//Markus


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