[Freeciv-Dev] (PR#12997) [PATCH] More unit bonuses
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#12997) [PATCH] More unit bonuses |
From: |
"Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx> |
Date: |
Fri, 6 May 2005 13:09:31 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12997 >
Before implementing the UnitFlag requirement, I found that some unit
targetted effects were still using get_player_bonus when they can now
use get_unit_bonus perfectly well.
The effects are: EFT_NO_SINK_DEEP, EFT_UNIT_RECOVER, EFT_LAND_VET_COMBAT.
This patch changes them to unit effects. To commit ASAP.
Index: ai/aiexplorer.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiexplorer.c,v
retrieving revision 1.13
diff -u -u -r1.13 aiexplorer.c
--- ai/aiexplorer.c 1 May 2005 05:11:53 -0000 1.13
+++ ai/aiexplorer.c 6 May 2005 20:06:17 -0000
@@ -102,8 +102,8 @@
Is there a chance that a trireme would be lost, given information that
the player actually has.
***************************************************************/
-static bool is_likely_trireme_loss(struct player *pplayer,
- struct tile *ptile)
+static bool is_likely_trireme_loss(struct tile *ptile, struct player *pplayer,
+ struct unit *punit)
{
/*
* If we are in a city or next to land, we have no chance of losing
@@ -112,7 +112,7 @@
*/
if ((likely_ocean(ptile, pplayer) < 50) ||
is_likely_coastline(ptile, pplayer) ||
- get_player_bonus(pplayer, EFT_NO_SINK_DEEP) > 0) {
+ get_unit_bonus(punit, EFT_NO_SINK_DEEP) > 0) {
return FALSE;
} else {
return TRUE;
@@ -176,7 +176,7 @@
* tile is on a different continent, or if we're a barbarian and
* the tile has a hut, don't go there. */
if ((unit_flag(punit, F_TRIREME) &&
- is_likely_trireme_loss(pplayer, ptile))
+ is_likely_trireme_loss(ptile, pplayer, punit))
|| tile_get_city(ptile)
|| (is_barbarian(pplayer) && tile_has_special(ptile, S_HUT))) {
return 0;
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.172
diff -u -u -r1.172 control.c
--- client/control.c 5 May 2005 18:32:46 -0000 1.172
+++ client/control.c 6 May 2005 20:06:18 -0000
@@ -810,8 +810,7 @@
if ((path = path_to_nearest_allied_city(punit))) {
int turns = pf_last_position(path)->turn;
- if (punit->hp + turns * get_player_bonus(game.player_ptr,
- EFT_UNIT_RECOVER)
+ if (punit->hp + turns * get_unit_bonus(punit, EFT_UNIT_RECOVER)
< unit_type(punit)->hp) {
struct unit_order order;
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.239
diff -u -u -r1.239 unit.c
--- common/unit.c 5 May 2005 18:32:52 -0000 1.239
+++ common/unit.c 6 May 2005 20:06:18 -0000
@@ -1341,7 +1341,7 @@
int base_trireme_loss_pct(const struct player *pplayer,
const struct unit *punit)
{
- if (get_player_bonus(pplayer, EFT_NO_SINK_DEEP) > 0) {
+ if (get_unit_bonus(punit, EFT_NO_SINK_DEEP) > 0) {
return 0;
} else if (player_knows_techs_with_flag(pplayer, TF_REDUCE_TRIREME_LOSS2)) {
return game.trireme_loss_chance[punit->veteran] / 4;
Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.192
diff -u -u -r1.192 gotohand.c
--- server/gotohand.c 23 Apr 2005 17:40:29 -0000 1.192
+++ server/gotohand.c 6 May 2005 20:06:20 -0000
@@ -931,8 +931,7 @@
struct unit *passenger;
struct player *pplayer = unit_owner(punit);
bool afraid_of_sinking = (unit_flag(punit, F_TRIREME)
- && get_player_bonus(pplayer,
- EFT_NO_SINK_DEEP) == 0);
+ && get_unit_bonus(punit, EFT_NO_SINK_DEEP) == 0);
/*
* If the destination is one step away, look around first or just go
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.351
diff -u -u -r1.351 unittools.c
--- server/unittools.c 5 May 2005 20:00:43 -0000 1.351
+++ server/unittools.c 6 May 2005 20:06:21 -0000
@@ -65,7 +65,7 @@
/* We need this global variable for our sort algorithm */
static struct tile *autoattack_target;
-static void unit_restore_hitpoints(struct player *pplayer, struct unit *punit);
+static void unit_restore_hitpoints(struct unit *punit);
static void unit_restore_movepoints(struct player *pplayer, struct unit
*punit);
static void update_unit_activity(struct unit *punit);
static void wakeup_neighbor_sentries(struct unit *punit);
@@ -163,13 +163,10 @@
|| unit_flag(punit, F_NO_VETERAN)) {
return FALSE;
} else {
- struct player *plr;
int mod = 100;
- plr = get_player(punit->owner);
-
if (is_ground_unittype(punit->type)) {
- mod += get_player_bonus(plr, EFT_LAND_VET_COMBAT);
+ mod += get_unit_bonus(punit, EFT_LAND_VET_COMBAT);
}
/* The modification is tacked on as a multiplier to the base chance.
@@ -353,7 +350,7 @@
unit_list_iterate_safe(pplayer->units, punit) {
/* 2) Modify unit hitpoints. Helicopters can even lose them. */
- unit_restore_hitpoints(pplayer, punit);
+ unit_restore_hitpoints(punit);
/* 3) Check that unit has hitpoints */
if (punit->hp<=0) {
@@ -469,7 +466,7 @@
Units which have moved don't gain hp, except the United Nations and
helicopter effects still occur.
*****************************************************************************/
-static void unit_restore_hitpoints(struct player *pplayer, struct unit *punit)
+static void unit_restore_hitpoints(struct unit *punit)
{
bool was_lower;
@@ -480,7 +477,7 @@
}
/* Bonus recovery HP (traditionally from the United Nations) */
- punit->hp += get_player_bonus(pplayer, EFT_UNIT_RECOVER);
+ punit->hp += get_unit_bonus(punit, EFT_UNIT_RECOVER);
if(is_heli_unit(punit)) {
struct city *pcity = tile_get_city(punit->tile);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12997) [PATCH] More unit bonuses,
Vasco Alexandre da Silva Costa <=
|
|