diff -Nur -Xfreeciv/diff_ignore freeciv/common/tech.c freeciv-change/common/tech.c --- freeciv/common/tech.c Thu Aug 23 20:24:59 2001 +++ freeciv-change/common/tech.c Sat Aug 25 01:25:54 2001 @@ -27,7 +27,7 @@ client/packhand.c (for the client) */ static const char *flag_names[] = { - "Bonus_Tech","Boat_Fast","Bridge","Railroad","Fortress", + "Bonus_Tech","Boat_Fast","Bridge","Railroad","Fortress","Watchtower", "Population_Pollution_Inc","Trade_Revenue_Reduce","Airbase","Farmland", "Reduce_Trireme_Loss1", "Reduce_Trireme_Loss2" }; diff -Nur -Xfreeciv/diff_ignore freeciv/common/tech.h freeciv-change/common/tech.h --- freeciv/common/tech.h Thu Aug 23 20:24:59 2001 +++ freeciv-change/common/tech.h Sat Aug 25 01:43:08 2001 @@ -46,6 +46,7 @@ TF_BRIDGE, /* "Settler" unit types can build bridges over rivers */ TF_RAILROAD, /* "Settler" unit types can build rail roads */ TF_FORTRESS, /* "Settler" unit types can build fortress */ + TF_WATCHTOWER, /* Units get enhanced visionrange in a fortress (=fortress acts also as a watchtower) */ TF_POPULATION_POLLUTION_INC, /* Increase the pollution factor created by popultaion by one */ TF_TRADE_REVENUE_REDUCE, /* When known by the player establishing a trade route reduces the initial revenue by cumulative factors of 2/3 */ diff -Nur -Xfreeciv/diff_ignore freeciv/data/default/techs.ruleset freeciv-change/data/default/techs.ruleset --- freeciv/data/default/techs.ruleset Fri Mar 30 01:08:39 2001 +++ freeciv-change/data/default/techs.ruleset Sat Aug 25 01:25:13 2001 @@ -38,6 +38,7 @@ ; "Railroad" = "Settler" unit types can build rail roads ; "Farmland" = "Settler" unit types can build farmland ; "Fortress" = "Settler" unit types can build fortress +; "Watchtower" = Units get enhanced visionrange in a fortress ; "Population_Pollution_Inc" = Increase the pollution factor created by ; popultaion by one ; "Trade_Revenue_Reduce" = When known by the player establishing a trade @@ -271,7 +272,7 @@ name = _("Invention") req1 = "Engineering" req2 = "Literacy" -flags = "" +flags = "Watchtower" [advance_iron_working] name = _("Iron Working") diff -Nur -Xfreeciv/diff_ignore freeciv/server/citytools.c freeciv-change/server/citytools.c --- freeciv/server/citytools.c Fri Aug 24 10:22:07 2001 +++ freeciv-change/server/citytools.c Mon Aug 27 04:51:29 2001 @@ -897,8 +897,18 @@ city_refresh(pcity); city_incite_cost(pcity); + /* Put vision back to normal, if fortress acted as a watchtower */ + if (player_knows_techs_with_flag(pplayer, TF_WATCHTOWER) + && map_get_tile(x,y)->special & S_FORTRESS) + { + unit_list_iterate (map_get_tile(x,y)->units, punit) + unfog_area(pplayer, punit->x, punit->y, get_unit_type(punit->type)->vision_range); + fog_area(pplayer, punit->x, punit->y, get_watchtower_vision(punit)); + unit_list_iterate_end; + } map_clear_special(x, y, S_FORTRESS); send_tile_info(NULL, x, y); + initialize_infrastructure_cache(pcity); reset_move_costs(x, y); /* I stupidly thought that setting S_ROAD took care of this, but of course diff -Nur -Xfreeciv/diff_ignore freeciv/server/maphand.c freeciv-change/server/maphand.c --- freeciv/server/maphand.c Fri Aug 24 10:22:10 2001 +++ freeciv-change/server/maphand.c Mon Aug 27 05:55:27 2001 @@ -686,7 +686,11 @@ freelog(LOG_DEBUG, "Removing unit sight points at %i,%i", punit->x, punit->y); - fog_area(pplayer, x, y, range); + if (map_get_special(punit->x, punit->y) & S_FORTRESS + && unit_profits_of_watchtower(punit)) + fog_area(pplayer, x, y, get_watchtower_vision(punit)); + else + fog_area(pplayer, x, y, range); } /************************************************************************** diff -Nur -Xfreeciv/diff_ignore freeciv/server/plrhand.c freeciv-change/server/plrhand.c --- freeciv/server/plrhand.c Sat Jul 21 19:45:36 2001 +++ freeciv-change/server/plrhand.c Mon Aug 27 05:02:12 2001 @@ -259,6 +259,21 @@ upgrade_city_rails(plr, was_discovery); } + /* enhace vision of units inside a fortress */ + if (tech_flag(tech_found,TF_WATCHTOWER)) + { + unit_list_iterate(plr->units, punit) + { + if (map_get_tile(punit->x, punit->y)->special & S_FORTRESS + && is_ground_unit(punit)) + { + unfog_area(plr, punit->x, punit->y, get_watchtower_vision(punit)); + fog_area(plr, punit->x, punit->y, get_unit_type(punit->type)->vision_range); + } + } + unit_list_iterate_end; + } + if (tech_found==plr->ai.tech_goal) plr->ai.tech_goal=A_NONE; diff -Nur -Xfreeciv/diff_ignore freeciv/server/savegame.c freeciv-change/server/savegame.c --- freeciv/server/savegame.c Fri Aug 24 10:22:10 2001 +++ freeciv-change/server/savegame.c Mon Aug 27 05:57:53 2001 @@ -43,6 +43,7 @@ #include "ruleset.h" #include "spacerace.h" #include "srv_main.h" +#include "unittools.h" #include "aicity.h" #include "aiunit.h" @@ -1123,7 +1124,14 @@ } square_iterate_end; } /* allocate the unit's contribution to fog of war */ - unfog_area(unit_owner(punit), punit->x, punit->y, + if (unit_profits_of_watchtower(punit) + && map_get_special(punit->x, punit->y) & S_FORTRESS) + { + unfog_area(unit_owner(punit), punit->x, punit->y, + get_watchtower_vision(punit)); + } + else + unfog_area(unit_owner(punit), punit->x, punit->y, get_unit_type(punit->type)->vision_range); unit_list_insert_back(&plr->units, punit); diff -Nur -Xfreeciv/diff_ignore freeciv/server/unittools.c freeciv-change/server/unittools.c --- freeciv/server/unittools.c Fri Aug 24 10:22:12 2001 +++ freeciv-change/server/unittools.c Mon Aug 27 05:30:39 2001 @@ -822,6 +822,20 @@ send_tile_info(0, punit->x, punit->y); set_unit_activity(punit, ACTIVITY_IDLE); } + + /* If a watchtower has been pillaged, reduce sight to normal */ + if (what == S_FORTRESS + && player_knows_techs_with_flag(pplayer, TF_WATCHTOWER)) + { + freelog(LOG_VERBOSE, "Watchtower pillaged!"); + unit_list_iterate (map_get_tile(punit->x, punit->y)->units, punit2) + if (is_ground_unit(punit2)) + { + unfog_area(pplayer, punit2->x, punit2->y, get_unit_type(punit2->type)->vision_range); + fog_area(pplayer, punit2->x, punit2->y, get_watchtower_vision(punit2)); + } + unit_list_iterate_end; + } } } else if (total_activity_targeted (punit->x, punit->y, @@ -836,7 +850,21 @@ } unit_list_iterate_end; send_tile_info(NULL, punit->x, punit->y); - } + + /* If a watchtower has been pillaged, reduce sight to normal */ + if (what_pillaged == S_FORTRESS + && player_knows_techs_with_flag(pplayer, TF_WATCHTOWER)) + { + freelog(LOG_VERBOSE, "Watchtower(2) pillaged!"); + unit_list_iterate (map_get_tile(punit->x, punit->y)->units, punit2) + if (is_ground_unit(punit2)) + { + unfog_area(pplayer, punit2->x, punit2->y, get_unit_type(punit2->type)->vision_range); + fog_area(pplayer, punit2->x, punit2->y, get_watchtower_vision(punit2)); + } + unit_list_iterate_end; + } + } } if (activity==ACTIVITY_POLLUTION) { @@ -860,6 +888,18 @@ >= map_build_fortress_time(punit->x, punit->y)) { map_set_special(punit->x, punit->y, S_FORTRESS); unit_activity_done = 1; + /* watchtower becomes effective */ + if (player_knows_techs_with_flag(pplayer, TF_WATCHTOWER)) + { + unit_list_iterate(ptile->units, punit) + { + if (is_ground_unit(punit)) + { + fog_area(pplayer, punit->x, punit->y, get_unit_type(punit->type)->vision_range); + unfog_area(pplayer, punit->x, punit->y, get_watchtower_vision(punit)); + } + } unit_list_iterate_end; + } } } @@ -1538,8 +1578,18 @@ conn_list_do_buffer(&pplayer->connections); punit->type = to_unit; - unfog_area(pplayer,punit->x,punit->y, get_unit_type(to_unit)->vision_range); + + if (map_get_tile(punit->x, punit->y)->special & S_FORTRESS + && unit_profits_of_watchtower(punit)) + { + unfog_area(pplayer, punit->x, punit->y, get_watchtower_vision(punit)); + } + else + { + unfog_area(pplayer,punit->x,punit->y, get_unit_type(to_unit)->vision_range); + } fog_area(pplayer,punit->x,punit->y,range); + send_unit_info(0, punit); conn_list_do_unbuffer(&pplayer->connections); } @@ -1642,7 +1692,12 @@ punit->transported_by = -1; punit->pgr = NULL; - unfog_area(pplayer,x,y,get_unit_type(punit->type)->vision_range); + + if (map_get_tile(x, y)->special & S_FORTRESS + && unit_profits_of_watchtower(punit)) + unfog_area(pplayer, punit->x, punit->y, get_watchtower_vision(punit)); + else + unfog_area(pplayer, x, y, get_unit_type(punit->type)->vision_range); send_unit_info(0, punit); maybe_make_first_contact(x, y, punit->owner); wakeup_neighbor_sentries(punit); @@ -2892,7 +2947,15 @@ and then fog the old territory. This means that the player gets a chance to see the newly explored territory while the client moves the unit, and both areas are visible during the move */ - unfog_area(pplayer, dest_x, dest_y, get_unit_type(punit->type)->vision_range); + /* Enhace vision if unit steps into a fortress, only if its a + groundunit */ + if (unit_profits_of_watchtower(punit) + && pdesttile->special & S_FORTRESS) + { + unfog_area(pplayer, dest_x, dest_y, get_watchtower_vision(punit)); + } + else + unfog_area(pplayer, dest_x, dest_y, get_unit_type(punit->type)->vision_range); unit_list_unlink(&psrctile->units, punit); punit->x = dest_x; @@ -2915,7 +2978,11 @@ set_unit_activity(punit, ACTIVITY_SENTRY); } send_unit_info_to_onlookers(0, punit, src_x, src_y, 0, 0); - fog_area(pplayer, src_x, src_y, get_unit_type(punit->type)->vision_range); + if (unit_profits_of_watchtower(punit) + && psrctile->special & S_FORTRESS) + fog_area(pplayer, src_x, src_y, get_watchtower_vision(punit)); + else + fog_area(pplayer, src_x, src_y, get_unit_type(punit->type)->vision_range); handle_unit_move_consequences(punit, src_x, src_y, dest_x, dest_y); @@ -3077,4 +3144,28 @@ unit_types[punit->type].name); } return 0; +} + +/************************************************************************** +... +**************************************************************************/ +int get_watchtower_vision(struct unit *punit) +{ + int watchtower_vision=2; + int watchtower_extra_vision=0; + int base_vision=get_unit_type(punit->type)->vision_range; + + return MAX(base_vision, + MAX(watchtower_vision, base_vision+watchtower_extra_vision)); +} + +/************************************************************************** +... +**************************************************************************/ +int unit_profits_of_watchtower(struct unit *punit) +{ + int playerid = punit->owner; + struct player *pplayer = get_player(playerid); + return (is_ground_unit(punit) + && player_knows_techs_with_flag(pplayer, TF_WATCHTOWER)); } diff -Nur -Xfreeciv/diff_ignore freeciv/server/unittools.h freeciv-change/server/unittools.h --- freeciv/server/unittools.h Mon Aug 13 14:25:30 2001 +++ freeciv-change/server/unittools.h Sun Aug 26 16:57:42 2001 @@ -45,6 +45,8 @@ int teleport_unit_to_city(struct unit *punit, struct city *pcity, int move_cost, int verbose); void resolve_unit_stack(int x, int y, int verbose); +int get_watchtower_vision(struct unit *punit); +int unit_profits_of_watchtower(struct unit *punit); /* creation/deletion/upgrading */