diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/client/climisc.c freeciv/client/climisc.c --- FreecivCVS/client/climisc.c Sun Mar 12 23:32:57 2000 +++ freeciv/client/climisc.c Fri Apr 21 14:08:10 2000 @@ -240,13 +240,15 @@ && tile_is_known(i,j)>=TILE_KNOWN_FOGGED && map_get_terrain(i,j)!=T_OCEAN) { con = map_get_continent(i,j); - if(this_con==-1) { - ptile->continent = this_con = con; - } else if(con != this_con) { - freelog(LOG_DEBUG, "renumbering client continent %d to %d at (%d %d)", - con, this_con, x, y); - climap_renumber_continent(i, j, this_con); - recycle_continent_num(con); + if(con>0) { + if(this_con==-1) { + ptile->continent = this_con = con; + } else if(con != this_con) { + freelog(LOG_DEBUG, "renumbering client continent %d to %d at (%d %d)", + con, this_con, x, y); + climap_renumber_continent(i, j, this_con); + recycle_continent_num(con); + } } } } @@ -255,7 +257,6 @@ ptile->continent = new_continent_num(); freelog(LOG_DEBUG, "new client continent %d at (%d %d)", ptile->continent, x, y); - return; } } diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/client/packhand.c freeciv/client/packhand.c --- FreecivCVS/client/packhand.c Sun Apr 16 10:39:07 2000 +++ freeciv/client/packhand.c Fri Apr 21 14:08:10 2000 @@ -332,6 +332,9 @@ if(game.player_ptr->ai.control && !ai_manual_turn_done) user_ended_turn(); } +/************************************************************************** +... +**************************************************************************/ void handle_before_new_year(void) { clear_notify_window(); @@ -972,6 +975,7 @@ void handle_tile_info(struct packet_tile_info *packet) { struct tile *ptile = map_get_tile(packet->x, packet->y); + enum tile_terrain_type old_terrain = ptile->terrain; enum known_type old_known = ptile->known; int tile_changed = 0; @@ -994,9 +998,24 @@ } /* update continents */ - if(packet->known >= TILE_KNOWN_FOGGED && old_known == TILE_UNKNOWN - && ptile->terrain != T_OCEAN) { + if ((packet->known >= TILE_KNOWN_FOGGED && + old_known == TILE_UNKNOWN && ptile->terrain != T_OCEAN) || + ((old_terrain == T_OCEAN) && (ptile->terrain != T_OCEAN))) { + /* new knowledge or new land -- update can handle incrementally */ climap_update_continents(packet->x, packet->y); + } else if (old_known >= TILE_KNOWN_FOGGED && + ((old_terrain != T_OCEAN) && (ptile->terrain == T_OCEAN))) { + /* land changed into ocean -- rebuild continents map from scratch */ + int x, y; + for (y = 0; y < map.ysize; y++) + for (x = 0; x < map.xsize; x++) + map_set_continent(x, y, 0); + climap_init_continents(); + for (y = 0; y < map.ysize; y++) + for (x = 0; x < map.xsize; x++) + if ((tile_is_known(x, y) >= TILE_KNOWN_FOGGED) && + (map_get_terrain(x, y) != T_OCEAN)) + climap_update_continents(x, y); } /* refresh tiles */ diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/common/map.c freeciv/common/map.c --- FreecivCVS/common/map.c Sun Mar 12 23:32:58 2000 +++ freeciv/common/map.c Fri Apr 21 14:08:10 2000 @@ -662,6 +662,21 @@ /*************************************************************** ... ***************************************************************/ +static void clear_infrastructure(int x, int y) +{ + map_clear_special(x, y, S_ROAD); + map_clear_special(x, y, S_IRRIGATION); + map_clear_special(x, y, S_RAILROAD); + map_clear_special(x, y, S_MINE); + map_clear_special(x, y, S_POLLUTION); + map_clear_special(x, y, S_FORTRESS); + map_clear_special(x, y, S_FARMLAND); + map_clear_special(x, y, S_AIRBASE); +} + +/*************************************************************** +... +***************************************************************/ void map_irrigate_tile(int x, int y) { enum tile_terrain_type now, result; @@ -678,6 +693,8 @@ } else if(result!=T_LAST) { map_set_terrain(x, y, result); + if (result==T_OCEAN) + clear_infrastructure(x, y); reset_move_costs(x, y); } map_clear_special(x, y, S_MINE); @@ -697,6 +714,8 @@ map_set_special(x, y, S_MINE); else if(result!=T_LAST) { map_set_terrain(x, y, result); + if (result==T_OCEAN) + clear_infrastructure(x, y); reset_move_costs(x, y); } map_clear_special(x,y, S_FARMLAND); @@ -715,6 +734,8 @@ if (result != T_LAST) { map_set_terrain(x, y, result); + if (result==T_OCEAN) + clear_infrastructure(x, y); reset_move_costs(x, y); } diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/common/unit.c freeciv/common/unit.c --- FreecivCVS/common/unit.c Thu Apr 20 14:33:45 2000 +++ freeciv/common/unit.c Fri Apr 21 14:08:10 2000 @@ -963,9 +963,11 @@ ( (ptile->terrain==type->mining_result && !(ptile->special&S_MINE)) || (ptile->terrain!=type->mining_result && - type->irrigation_result!=T_LAST && + type->mining_result!=T_LAST && (ptile->terrain!=T_OCEAN || - can_reclaim_ocean(punit->x, punit->y))) )) { + can_reclaim_ocean(punit->x, punit->y)) && + (type->mining_result!=T_OCEAN || + !(map_get_city(punit->x, punit->y)))) )) { unit_list_iterate(ptile->units, tunit) { if(tunit->activity==ACTIVITY_IRRIGATE) return 0; } @@ -986,7 +988,9 @@ (ptile->terrain!=type->irrigation_result && type->irrigation_result!=T_LAST && (ptile->terrain!=T_OCEAN || - can_reclaim_ocean(punit->x, punit->y))) )) { + can_reclaim_ocean(punit->x, punit->y)) && + (type->irrigation_result!=T_OCEAN || + !(map_get_city(punit->x, punit->y)))) )) { unit_list_iterate(ptile->units, tunit) { if(tunit->activity==ACTIVITY_MINE) return 0; } @@ -1051,6 +1055,8 @@ (ptile->terrain!=type->transform_result) && (ptile->terrain!=T_OCEAN || can_reclaim_ocean(punit->x, punit->y)) && + (type->transform_result!=T_OCEAN || + !(map_get_city(punit->x, punit->y))) && unit_flag(punit->type, F_TRANSFORM); default: diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/data/default/terrain.ruleset freeciv/data/default/terrain.ruleset --- FreecivCVS/data/default/terrain.ruleset Sun Apr 16 08:55:10 2000 +++ freeciv/data/default/terrain.ruleset Fri Apr 21 14:08:10 2000 @@ -234,9 +234,9 @@ irrigation_result = "Plains" irrigation_food_incr = 0 irrigation_time = 5 -mining_result = "no" +mining_result = "Swamp" mining_shield_incr = 0 -mining_time = 0 +mining_time = 15 transform_result = "Grassland" transform_time = 24 helptext = _("\ @@ -522,8 +522,8 @@ mining_result = "Forest" mining_shield_incr = 0 mining_time = 15 -transform_result = "Plains" -transform_time = 24 +transform_result = "Ocean" +transform_time = 36 helptext = _("\ Swamps suffer from an over-abundance of water, making agriculture\ somewhat problematic.\ diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/server/gamelog.c freeciv/server/gamelog.c --- FreecivCVS/server/gamelog.c Sun Jan 2 06:32:15 2000 +++ freeciv/server/gamelog.c Fri Apr 21 14:39:23 2000 @@ -68,7 +68,10 @@ va_start(args, message); my_vsnprintf(buf, sizeof(buf), message, args); if (level==GAMELOG_MAP){ - fprintf(fs,"%s\n",buf); + if (buf[0] == '(') /* KLUGE!! FIXME: remove when we fix the gamelog format --jjm */ + fprintf(fs,"%i %s\n", game.year,buf); + else + fprintf(fs,"%s\n",buf); } else if (level==GAMELOG_EOT){ fprintf(fs,"*** %s\n",buf); } else { diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/server/unitfunc.c freeciv/server/unitfunc.c --- FreecivCVS/server/unitfunc.c Thu Apr 20 12:13:08 2000 +++ freeciv/server/unitfunc.c Fri Apr 21 14:42:11 2000 @@ -39,6 +39,7 @@ #include "civserver.h" #include "gamelog.h" #include "gotohand.h" +#include "mapgen.h" /* assign_continent_numbers */ #include "maphand.h" #include "plrhand.h" #include "settlers.h" @@ -1749,7 +1750,8 @@ /************************************************************************** For each city adjacent to (x,y), check if landlocked. If so, sell all improvements in the city that depend upon being next to an ocean tile. - (Should be called after any terrain changes. Assumes no city at (x,y).) + (Should be called after any ocean to land terrain changes. + Assumes no city at (x,y).) **************************************************************************/ static void city_landlocked_sell_coastal_improvements(int x, int y) { @@ -1791,6 +1793,27 @@ } /************************************************************************** + Checks for terrain change between ocean and land. Handles side-effects. + (Should be called after any potential ocean/land terrain changes.) +**************************************************************************/ +static void check_terrain_ocean_land_change(int x, int y, + enum tile_terrain_type old) +{ + enum tile_terrain_type new = map_get_terrain(x, y); + + if ((old == T_OCEAN) && (new != T_OCEAN)) { + /* ocean to land ... */ + city_landlocked_sell_coastal_improvements(x, y); + assign_continent_numbers(); + gamelog(GAMELOG_MAP, "(%d,%d) land created from ocean", x, y); + } else if ((old != T_OCEAN) && (new == T_OCEAN)) { + /* land to ocean ... */ + assign_continent_numbers(); + gamelog(GAMELOG_MAP, "(%d,%d) ocean created from land", x, y); + } +} + +/************************************************************************** progress settlers in their current tasks, and units that is pillaging. also move units that is on a goto. @@ -1883,8 +1906,9 @@ if (activity==ACTIVITY_IRRIGATE) { if (total_activity (punit->x, punit->y, ACTIVITY_IRRIGATE) >= map_build_irrigation_time(punit->x, punit->y)) { + enum tile_terrain_type old = map_get_terrain(punit->x, punit->y); map_irrigate_tile(punit->x, punit->y); - city_landlocked_sell_coastal_improvements(punit->x, punit->y); + check_terrain_ocean_land_change(punit->x, punit->y, old); unit_activity_done = 1; } } @@ -1908,8 +1932,9 @@ if (activity==ACTIVITY_MINE) { if (total_activity (punit->x, punit->y, ACTIVITY_MINE) >= map_build_mine_time(punit->x, punit->y)) { + enum tile_terrain_type old = map_get_terrain(punit->x, punit->y); map_mine_tile(punit->x, punit->y); - city_landlocked_sell_coastal_improvements(punit->x, punit->y); + check_terrain_ocean_land_change(punit->x, punit->y, old); unit_activity_done = 1; } } @@ -1917,8 +1942,9 @@ if (activity==ACTIVITY_TRANSFORM) { if (total_activity (punit->x, punit->y, ACTIVITY_TRANSFORM) >= map_transform_time(punit->x, punit->y)) { + enum tile_terrain_type old = map_get_terrain(punit->x, punit->y); map_transform_tile(punit->x, punit->y); - city_landlocked_sell_coastal_improvements(punit->x, punit->y); + check_terrain_ocean_land_change(punit->x, punit->y, old); unit_activity_done = 1; } }