Author: cazfi Date: Thu Feb 11 21:40:30 2016 New Revision: 31888 URL: http://svn.gna.org/viewcvs/freeciv?rev=31888&view=rev Log: Inlined map_move_cost() and map_move_cost_unit() that are just simple wrappers for tile_move_cost_ptrs().
See patch #6934 Modified: branches/S2_5/common/map.c branches/S2_5/common/map.h Modified: branches/S2_5/common/map.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/map.c?rev=31888&r1=31887&r2=31888&view=diff ============================================================================== --- branches/S2_5/common/map.c (original) +++ branches/S2_5/common/map.c Thu Feb 11 21:40:30 2016 @@ -733,23 +733,25 @@ the tiles are assumed to be adjacent, and the (x,y) values are used only to get the river bonus correct. - May also be used with punit==NULL, in which case punit + May also be used with punit == NULL, in which case punit tests are not done (for unit-independent results). ***************************************************************/ -static int tile_move_cost_ptrs(const struct unit *punit, - const struct unit_class *pclass, - const struct player *pplayer, - const struct tile *t1, const struct tile *t2) +int tile_move_cost_ptrs(const struct unit *punit, + const struct unit_class *pclass, + const struct player *pplayer, + const struct tile *t1, const struct tile *t2) { bool native = TRUE; int cost = tile_terrain(t2)->movement_cost * SINGLE_MOVE; bool cardinal_move; bool ri; - fc_assert(punit == NULL || pclass == NULL || unit_class(punit) == pclass); - if (punit) { - pclass = unit_class(punit); + struct unit_class *puclass = unit_class(punit); + + fc_assert(pclass == NULL || puclass == pclass); + + pclass = puclass; native = is_native_tile_to_class(pclass, t2); } @@ -864,25 +866,6 @@ } /*************************************************************** - The cost to move punit from where it is to tile x,y. - It is assumed the move is a valid one, e.g. the tiles are adjacent. -***************************************************************/ -int map_move_cost_unit(struct unit *punit, const struct tile *ptile) -{ - return tile_move_cost_ptrs(punit, NULL, unit_owner(punit), - unit_tile(punit), ptile); -} - -/*************************************************************** - Move cost between two tiles -***************************************************************/ -int map_move_cost(const struct player *pplayer, const struct unit_class *pclass, - const struct tile *src_tile, const struct tile *dst_tile) -{ - return tile_move_cost_ptrs(NULL, pclass, pplayer, src_tile, dst_tile); -} - -/*************************************************************** Are two tiles adjacent to each other. ***************************************************************/ bool is_tiles_adjacent(const struct tile *tile0, const struct tile *tile1) Modified: branches/S2_5/common/map.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/map.h?rev=31888&r1=31887&r2=31888&view=diff ============================================================================== --- branches/S2_5/common/map.h (original) +++ branches/S2_5/common/map.h Thu Feb 11 21:40:30 2016 @@ -357,10 +357,34 @@ bool is_tiles_adjacent(const struct tile *ptile0, const struct tile *ptile1); bool is_move_cardinal(const struct tile *src_tile, const struct tile *dst_tile); -int map_move_cost_unit(struct unit *punit, const struct tile *ptile); -int map_move_cost(const struct player *pplayer, const struct unit_class *pclass, - const struct tile *src_tile, - const struct tile *dst_tile); + +int tile_move_cost_ptrs(const struct unit *punit, + const struct unit_class *pclass, + const struct player *pplayer, + const struct tile *t1, const struct tile *t2); + +/*************************************************************** + The cost to move punit from where it is to tile x,y. + It is assumed the move is a valid one, e.g. the tiles are adjacent. +***************************************************************/ +static inline int map_move_cost_unit(struct unit *punit, + const struct tile *ptile) +{ + return tile_move_cost_ptrs(punit, NULL, unit_owner(punit), + unit_tile(punit), ptile); +} + +/*************************************************************** + Move cost between two tiles +***************************************************************/ +static inline int map_move_cost(const struct player *pplayer, + const struct unit_class *pclass, + const struct tile *src_tile, + const struct tile *dst_tile) +{ + return tile_move_cost_ptrs(NULL, pclass, pplayer, src_tile, dst_tile); +} + bool is_safe_ocean(const struct tile *ptile); bv_special get_tile_infrastructure_set(const struct tile *ptile, int *count); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits