[Freeciv-Dev] (PR#11730) Constifying common/unit (more)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#11730) Constifying common/unit (more) |
From: |
"Frédéric Brière" <fbriere@xxxxxxxxxxx> |
Date: |
Thu, 30 Dec 2004 01:31:08 -0800 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11730 >
Here's a couple more for common/unit.[ch]. This needs to be applied
after #11725.
--
Frédéric Brière <*> fbriere@xxxxxxxxxxx
=> <fbriere@xxxxxxxxxx> IS NO MORE: <http://www.abacomsucks.com> <=
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.224
diff -u -r1.224 unit.c
--- common/unit.c 24 Dec 2004 01:52:44 -0000 1.224
+++ common/unit.c 30 Dec 2004 06:25:23 -0000
@@ -393,7 +393,8 @@
Return TRUE iff the player should consider this unit to be a threat on
the ground.
**************************************************************************/
-static bool is_ground_threat(struct player *pplayer, const struct unit *punit)
+static bool is_ground_threat(const struct player *pplayer,
+ const struct unit *punit)
{
return (pplayers_at_war(pplayer, unit_owner(punit))
&& (unit_flag(punit, F_DIPLOMAT)
@@ -404,7 +405,8 @@
Return TRUE iff this tile is threatened from any threatening ground unit
within 2 tiles.
**************************************************************************/
-bool is_square_threatened(struct player *pplayer, const struct tile *ptile)
+bool is_square_threatened(const struct player *pplayer,
+ const struct tile *ptile)
{
square_iterate(ptile, 2, ptile1) {
unit_list_iterate(ptile1->units, punit) {
@@ -453,7 +455,7 @@
Return TRUE iff this unit may be disbanded to add its pop_cost to a
city at its current location.
**************************************************************************/
-bool can_unit_add_to_city(struct unit *punit)
+bool can_unit_add_to_city(const struct unit *punit)
{
return (test_unit_add_or_build_city(punit) == AB_ADD_OK);
}
@@ -462,7 +464,7 @@
Return TRUE iff this unit is capable of building a new city at its
current location.
**************************************************************************/
-bool can_unit_build_city(struct unit *punit)
+bool can_unit_build_city(const struct unit *punit)
{
return (test_unit_add_or_build_city(punit) == AB_BUILD_OK);
}
@@ -471,7 +473,7 @@
Return TRUE iff this unit can add to a current city or build a new city
at its current location.
**************************************************************************/
-bool can_unit_add_or_build_city(struct unit *punit)
+bool can_unit_add_or_build_city(const struct unit *punit)
{
enum add_build_city_result r = test_unit_add_or_build_city(punit);
@@ -483,7 +485,7 @@
its current location, and return a 'result' value telling what is
allowed.
**************************************************************************/
-enum add_build_city_result test_unit_add_or_build_city(struct unit *punit)
+enum add_build_city_result test_unit_add_or_build_city(const struct unit
*punit)
{
struct city *pcity = map_get_city(punit->tile);
bool is_build = unit_flag(punit, F_CITIES);
@@ -1307,7 +1309,7 @@
containing units from B and C will return false)
**************************************************************************/
struct unit *is_allied_unit_tile(const struct tile *ptile,
- struct player *pplayer)
+ const struct player *pplayer)
{
struct unit *punit = NULL;
@@ -1326,7 +1328,7 @@
is there an enemy unit on this tile?
**************************************************************************/
struct unit *is_enemy_unit_tile(const struct tile *ptile,
- struct player *pplayer)
+ const struct player *pplayer)
{
unit_list_iterate(ptile->units, punit) {
if (pplayers_at_war(unit_owner(punit), pplayer))
@@ -1341,7 +1343,7 @@
is there an non-allied unit on this tile?
**************************************************************************/
struct unit *is_non_allied_unit_tile(const struct tile *ptile,
- struct player *pplayer)
+ const struct player *pplayer)
{
unit_list_iterate(ptile->units, punit) {
if (!pplayers_allied(unit_owner(punit), pplayer))
@@ -1356,7 +1358,7 @@
is there an unit we have peace or ceasefire with on this tile?
**************************************************************************/
struct unit *is_non_attack_unit_tile(const struct tile *ptile,
- struct player *pplayer)
+ const struct player *pplayer)
{
unit_list_iterate(ptile->units, punit) {
if (pplayers_non_attack(unit_owner(punit), pplayer))
@@ -1379,7 +1381,7 @@
client-specific features, like FoW and the fact that the client cannot
see units inside enemy cities.
**************************************************************************/
-bool is_my_zoc(struct player *pplayer, const struct tile *ptile0)
+bool is_my_zoc(const struct player *pplayer, const struct tile *ptile0)
{
square_iterate(ptile0, 1, ptile) {
if (is_ocean(ptile->terrain)) {
@@ -1426,7 +1428,7 @@
6. The spot you're moving from or to is in your ZOC
**************************************************************************/
bool can_step_taken_wrt_to_zoc(Unit_Type_id type,
- struct player *unit_owner,
+ const struct player *unit_owner,
const struct tile *src_tile,
const struct tile *dst_tile)
{
@@ -1549,7 +1551,7 @@
10) there is no non-allied unit blocking (zoc) [or igzoc is true]
**************************************************************************/
enum unit_move_result test_unit_move_to_tile(Unit_Type_id type,
- struct player *unit_owner,
+ const struct player *unit_owner,
enum unit_activity activity,
const struct tile *pfromtile,
const struct tile *ptotile,
@@ -1627,7 +1629,7 @@
to know more. The AI code uses base_trireme_loss_pct and
base_unsafe_terrain_loss_pct directly.
**************************************************************************/
-int unit_loss_pct(struct player *pplayer, const struct tile *ptile,
+int unit_loss_pct(const struct player *pplayer, const struct tile *ptile,
const struct unit *punit)
{
int loss_pct = 0;
@@ -1657,7 +1659,8 @@
Triremes have a varying loss percentage based on tech and veterancy
level.
**************************************************************************/
-int base_trireme_loss_pct(struct player *pplayer, const struct unit *punit)
+int base_trireme_loss_pct(const struct player *pplayer,
+ const struct unit *punit)
{
if (get_player_bonus(pplayer, EFT_NO_SINK_DEEP) > 0) {
return 0;
@@ -1673,7 +1676,7 @@
/**************************************************************************
All units except air units have a flat 15% chance of being lost.
**************************************************************************/
-int base_unsafe_terrain_loss_pct(struct player *pplayer,
+int base_unsafe_terrain_loss_pct(const struct player *pplayer,
const struct unit *punit)
{
return is_air_unit(punit) ? 0 : 15;
@@ -1687,7 +1690,7 @@
- inside a city
- ground unit inside a fortress within 3 squares of a friendly city
**************************************************************************/
-bool unit_being_aggressive(struct unit *punit)
+bool unit_being_aggressive(const struct unit *punit)
{
if (!is_attack_unit(punit))
return FALSE;
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.132
diff -u -r1.132 unit.h
--- common/unit.h 24 Dec 2004 01:52:44 -0000 1.132
+++ common/unit.h 30 Dec 2004 06:25:23 -0000
@@ -261,7 +261,8 @@
bool is_attack_unit(const struct unit *punit);
bool is_military_unit(const struct unit *punit); /* !set !dip !cara
*/
bool is_diplomat_unit(const struct unit *punit);
-bool is_square_threatened(struct player *pplayer, const struct tile *ptile);
+bool is_square_threatened(const struct player *pplayer,
+ const struct tile *ptile);
bool is_field_unit(const struct unit *punit); /* ships+aero */
bool is_hiding_unit(const struct unit *punit);
bool is_sailing_unit(const struct unit *punit);
@@ -270,10 +271,10 @@
bool is_ground_unit(const struct unit *punit);
#define COULD_OCCUPY(punit) \
((is_ground_unit(punit) || is_heli_unit(punit)) && is_military_unit(punit))
-bool can_unit_add_to_city (struct unit *punit);
-bool can_unit_build_city (struct unit *punit);
-bool can_unit_add_or_build_city (struct unit *punit);
-enum add_build_city_result test_unit_add_or_build_city(struct unit *punit);
+bool can_unit_add_to_city (const struct unit *punit);
+bool can_unit_build_city (const struct unit *punit);
+bool can_unit_add_or_build_city (const struct unit *punit);
+enum add_build_city_result test_unit_add_or_build_city(const struct unit
*punit);
bool kills_citizen_after_attack(const struct unit *punit);
const char *unit_activity_text(const struct unit *punit);
@@ -292,23 +293,25 @@
struct player *unit_owner(const struct unit *punit);
struct unit *is_allied_unit_tile(const struct tile *ptile,
- struct player *pplayer);
+ const struct player *pplayer);
struct unit *is_enemy_unit_tile(const struct tile *ptile,
- struct player *pplayer);
+ const struct player *pplayer);
struct unit *is_non_allied_unit_tile(const struct tile *ptile,
- struct player *pplayer);
+ const struct player *pplayer);
struct unit *is_non_attack_unit_tile(const struct tile *ptile,
- struct player *pplayer);
+ const struct player *pplayer);
-int unit_loss_pct(struct player *pplayer, const struct tile *ptile,
+int unit_loss_pct(const struct player *pplayer, const struct tile *ptile,
const struct unit *punit);
-int base_trireme_loss_pct(struct player *pplayer, const struct unit *punit);
-int base_unsafe_terrain_loss_pct(struct player *pplayer,
+int base_trireme_loss_pct(const struct player *pplayer,
+ const struct unit *punit);
+int base_unsafe_terrain_loss_pct(const struct player *pplayer,
const struct unit *punit);
-bool is_my_zoc(struct player *unit_owner, const struct tile *ptile);
-bool unit_being_aggressive(struct unit *punit);
-bool can_step_taken_wrt_to_zoc(Unit_Type_id type, struct player *unit_owner,
+bool is_my_zoc(const struct player *unit_owner, const struct tile *ptile);
+bool unit_being_aggressive(const struct unit *punit);
+bool can_step_taken_wrt_to_zoc(Unit_Type_id type,
+ const struct player *unit_owner,
const struct tile *src_tile,
const struct tile *dst_tile);
bool can_unit_exist_at_tile(const struct unit *punit, const struct tile
*ptile);
@@ -317,7 +320,7 @@
bool can_unit_move_to_tile(const struct unit *punit, const struct tile *ptile,
bool igzoc);
enum unit_move_result test_unit_move_to_tile(Unit_Type_id type,
- struct player *unit_owner,
+ const struct player *unit_owner,
enum unit_activity activity,
const struct tile *src_tile,
const struct tile *dst_tile,
Index: common/aicore/path_finding.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/path_finding.h,v
retrieving revision 1.10
diff -u -r1.10 path_finding.h
--- common/aicore/path_finding.h 29 Sep 2004 02:24:23 -0000 1.10
+++ common/aicore/path_finding.h 30 Dec 2004 06:25:23 -0000
@@ -332,7 +332,7 @@
* ZoC for strategic planning purposes (take into account enemy cities
* but not units for example).
* If this callback is NULL, ZoC are ignored.*/
- bool (*get_zoc) (struct player *pplayer, const struct tile *ptile);
+ bool (*get_zoc) (const struct player *pplayer, const struct tile *ptile);
/* If this callback is non-NULL and returns TRUE this position is
* dangerous. The unit will never end a turn at a dangerous
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#11730) Constifying common/unit (more),
Frédéric Brière <=
|
|