<URL: http://bugs.freeciv.org/Ticket/Display.html?id=37632 >
On 3/6/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > This stores turn unit has been born to unit structure. Main reason > for this is to get rid of the barbarian fuel hack. - born_turn renamed as birth_turn - ML
diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c --- freeciv/ai/aiunit.c 2007-03-06 05:46:13.000000000 +0200 +++ freeciv/ai/aiunit.c 2007-03-07 16:37:33.000000000 +0200 @@ -2080,14 +2080,14 @@ } /************************************************************************** - Barbarian units may disband spontaneously if their age is more then 5, - they are not in cities, and they are far from any enemy units. It is to - remove barbarians that do not engage into any activity for a long time. + Barbarian units may disband spontaneously if their age is more than + BARBARIAN_MIN_LIFESPAN, they are not in cities, and they are far from + any enemy units. It is to remove barbarians that do not engage into any + activity for a long time. **************************************************************************/ static bool unit_can_be_retired(struct unit *punit) { - if (punit->fuel > 0) { /* fuel abused for barbarian life span */ - punit->fuel--; + if (punit->birth_turn + BARBARIAN_MIN_LIFESPAN > game.info.turn) { return FALSE; } @@ -2431,7 +2431,8 @@ } players_iterate_end; /* Disappearance - 33% chance on coast, when older than barbarian life span */ - if (is_ocean_near_tile(leader->tile) && leader->fuel == 0) { + if (is_ocean_near_tile(leader->tile) + && leader->birth_turn + BARBARIAN_MIN_LIFESPAN < game.info.turn) { if(myrand(3) == 0) { UNIT_LOG(LOG_DEBUG, leader, "barbarian leader disappearing..."); wipe_unit(leader); diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c --- freeciv/common/unit.c 2007-03-06 03:34:32.000000000 +0200 +++ freeciv/common/unit.c 2007-03-07 16:37:11.000000000 +0200 @@ -1268,6 +1268,7 @@ punit->foul = FALSE; punit->debug = FALSE; punit->fuel = unit_type(punit)->fuel; + punit->birth_turn = game.info.turn; punit->hp = unit_type(punit)->hp; punit->moves_left = unit_move_rate(punit); punit->moved = FALSE; diff -Nurd -X.diff_ignore freeciv/common/unit.h freeciv/common/unit.h --- freeciv/common/unit.h 2007-03-05 21:11:49.000000000 +0200 +++ freeciv/common/unit.h 2007-03-07 16:36:59.000000000 +0200 @@ -133,6 +133,7 @@ int unhappiness; int upkeep[O_MAX]; int fuel; + int birth_turn; int bribe_cost; struct unit_ai ai; enum unit_activity activity; diff -Nurd -X.diff_ignore freeciv/server/barbarian.h freeciv/server/barbarian.h --- freeciv/server/barbarian.h 2007-03-05 21:09:47.000000000 +0200 +++ freeciv/server/barbarian.h 2007-03-07 16:36:43.000000000 +0200 @@ -27,6 +27,8 @@ #define MAP_FACTOR 2000 /* adjust this to get a good uprising frequency */ +#define BARBARIAN_MIN_LIFESPAN 5 + bool unleash_barbarians(struct tile *ptile); void summon_barbarians(void); bool is_land_barbarian(struct player *pplayer); diff -Nurd -X.diff_ignore freeciv/server/diplomats.c freeciv/server/diplomats.c --- freeciv/server/diplomats.c 2007-03-06 03:34:32.000000000 +0200 +++ freeciv/server/diplomats.c 2007-03-07 16:37:48.000000000 +0200 @@ -461,6 +461,7 @@ gained_unit->fuel = pvictim->fuel; gained_unit->foul = pvictim->foul; gained_unit->paradropped = pvictim->paradropped; + gained_unit->birth_turn = pvictim->birth_turn; /* Inform owner about less than full fuel */ send_unit_info(pplayer, gained_unit); diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c --- freeciv/server/savegame.c 2007-03-05 21:09:47.000000000 +0200 +++ freeciv/server/savegame.c 2007-03-07 16:38:13.000000000 +0200 @@ -1683,6 +1683,8 @@ punit->moves_left = secfile_lookup_int(file, "player%d.u%d.moves", plrno, i); punit->fuel = secfile_lookup_int(file, "player%d.u%d.fuel", plrno, i); + punit->birth_turn = secfile_lookup_int_default(file, game.info.turn, + "player%d.u%d.born", plrno, i); activity = secfile_lookup_int(file, "player%d.u%d.activity", plrno, i); if (activity == ACTIVITY_PATROL_UNUSED) { /* Previously ACTIVITY_PATROL and ACTIVITY_GOTO were used for @@ -2922,6 +2924,8 @@ plrno, i); secfile_insert_int(file, punit->fuel, "player%d.u%d.fuel", plrno, i); + secfile_insert_int(file, punit->birth_turn, "player%d.u%d.born", + plrno, i); secfile_insert_int(file, punit->battlegroup, "player%d.u%d.battlegroup", plrno, i);
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev