[Freeciv-Dev] (PR#39450) Make rule names available in the scripting api
URL: http://bugs.freeciv.org/Ticket/Display.html?id=39450 Make rule names available in the scripting api. Right now, in a callback in lua; for example: hut_entered_callback(punit) there is no way to get the rule name of punit, only the reverse by find.unit_type('Settlers') and similar. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#17187) Move hut code into lua script
URL: http://bugs.freeciv.org/Ticket/Display.html?id=17187 Updated the patch to the latest revision trunk. The patch is almost ready but depends on #39450: Make rule names available in the scripting api; right now there is no way to tell the user Your %s was killed by barbarians Expanded the patch slightly by porting hut_get_barbarians to Lua, using a new method Tile:city_exists_within_city_radius and a new action barbarian_uprising(tile) Added a copyright header to the script.lua file since it now has a substantial amount of code; I hope that it is correct. Index: server/scripting/api_actions.h === --- server/scripting/api_actions.h (revision 13086) +++ server/scripting/api_actions.h (arbetskopia) @@ -16,6 +16,7 @@ #include api_types.h +bool api_unleash_barbarians(Tile *ptile); Unit *api_actions_create_unit(Player *pplayer, Tile *ptile, Unit_Type *ptype, int veteran_level, City *homecity, int moves_left); Index: server/scripting/api_methods.h === --- server/scripting/api_methods.h (revision 13086) +++ server/scripting/api_methods.h (arbetskopia) @@ -16,12 +16,17 @@ #include api_types.h +bool api_methods_unit_city_can_be_built_here(Unit *punit); + int api_methods_player_num_cities(Player *pplayer); int api_methods_player_num_units(Player *pplayer); bool api_methods_unit_type_has_flag(Unit_Type *punit_type, const char *flag); bool api_methods_unit_type_has_role(Unit_Type *punit_type, const char *role); +bool api_methods_tile_city_exists_within_city_radius(Tile *ptile, + bool may_be_on_center); + bool api_methods_building_type_is_wonder(Building_Type *pbuilding); bool api_methods_building_type_is_great_wonder(Building_Type *pbuilding); bool api_methods_building_type_is_small_wonder(Building_Type *pbuilding); Index: server/scripting/api.pkg === --- server/scripting/api.pkg (revision 13086) +++ server/scripting/api.pkg (arbetskopia) @@ -94,6 +94,7 @@ /* Class methods. */ + int api_methods_player_num_cities @ methods_player_num_cities (Player *pplayer); int api_methods_player_num_units @@ -103,7 +104,12 @@ @ methods_unit_type_has_flag (Unit_Type *punit_type, const char *flag); bool api_methods_unit_type_has_role @ methods_unit_type_has_role (Unit_Type *punit_type, const char *role); +bool api_methods_unit_city_can_be_built_here + @ methods_unit_city_can_be_built_here (Unit *punit); +bool api_methods_tile_city_exists_within_city_radius + @ methods_tile_city_exists_within_city_radius (Tile *ptile, bool center); + bool api_methods_building_type_is_wonder @ methods_building_type_is_wonder (Building_Type *pbuilding); bool api_methods_building_type_is_great_wonder @@ -133,6 +139,15 @@ return find.city(self.owner, self.homecity_id) end +function Unit:is_on_possible_city_tile() + return methods_unit_city_can_be_built_here(self) +end + +-- Tile methods +function Tile:city_exists_within_city_radius(center) + return methods_tile_city_exists_within_city_radius(self, center) +end + -- Building_Type methods. function Building_Type:build_shield_cost() return self.build_cost @@ -402,4 +417,4 @@ void api_actions_change_gold @ change_gold (Player *pplayer, int amount); Tech_Type *api_actions_give_technology @ give_technology (Player *pplayer, Tech_Type *ptech); - +bool api_unleash_barbarians @ unleash_barbarians (Tile *ptile); Index: server/scripting/api_actions.c === --- server/scripting/api_actions.c (revision 13086) +++ server/scripting/api_actions.c (arbetskopia) @@ -15,6 +15,7 @@ #include config.h #endif +#include barbarian.h #include plrhand.h #include citytools.h #include techtools.h @@ -26,6 +27,14 @@ /** + Unleash barbarians on a tile, for example from a hut +**/ +bool api_unleash_barbarians(Tile *ptile) +{ + return unleash_barbarians(ptile); +} + +/** Create a new unit. **/ Unit *api_actions_create_unit(Player *pplayer, Tile *ptile, Unit_Type *ptype, Index: server/scripting/api_methods.c === --- server/scripting/api_methods.c (revision 13086) +++ server/scripting/api_methods.c (arbetskopia) @@ -21,6 +21,14 @@ #include script.h /** + Can punit found a city on its tile? +**/ +bool
[Freeciv-Dev] (PR#39442) Lua script newlines not restored correctly from save
URL: http://bugs.freeciv.org/Ticket/Display.html?id=39442 Committed to S2_1 as r13087 and trunk as r13088 (PR#39442) Lua script newlines not restored correctly from save Make escaped an attribute of entry so that it can be carried over from load to save Changed moutstr so that it takes a full_escapes argument just like minstr. moutstr to returns a string with delimiters to simplify the code throughout. Add secfile_insert_str_noescape so that noescaped strings (script.code and script.vars) can be inserted. Small refactoring: added entry_init(struct *entry) Now script.code and script.vars use secfile_insert_str_noescape ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#39451) Add signal emit to scripting api
URL: http://bugs.freeciv.org/Ticket/Display.html?id=39451 Allow signals to be emitted from Lua scripts. Add a wrapper for script_signal_emit to the signal module. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#15260) GTK2: interface quirks being observer
URL: http://bugs.freeciv.org/Ticket/Display.html?id=15260 Consolidated the above posted patches, ready for commit to trunk and S2_1 disable_reports.diff end_phase.diff observer_keys.diff Changed the observer keys handling a bit: Now the shift-arrow keys to scroll the mapview work as well, just like center on capital (not when being global observer, then the message Oh my, You seem to have no capital is generated, which seems harmless. The logic was also simplified in key handling: return if observer after having handled shift-key events. Removal of the large else clause caused a lot of reindenting in the patch, but no changes. Index: server/srv_main.c === --- server/srv_main.c (revision 13088) +++ server/srv_main.c (arbetskopia) @@ -759,6 +759,14 @@ freelog(LOG_DEBUG, Endturn); + /* Hack: because observer players never get an end-phase packet we send + * one here. It would be better perhaps to have a full end-turn packet. */ + conn_list_iterate(game.est_connections, pconn) { +if (!pconn-player) { + send_packet_end_phase(pconn); +} + } conn_list_iterate_end; + map_calculate_borders(); /* Output some AI measurement information */ Index: client/gui-gtk-2.0/gui_main.c === --- client/gui-gtk-2.0/gui_main.c (revision 13088) +++ client/gui-gtk-2.0/gui_main.c (arbetskopia) @@ -455,89 +455,93 @@ return FALSE; } - if (!client_is_observer()) { /* FIXME: is this check right? */ -if ((ev-state GDK_SHIFT_MASK)) { - switch (ev-keyval) { - case GDK_Left: - scroll_mapview(DIR8_WEST); - return TRUE; - case GDK_Right: - scroll_mapview(DIR8_EAST); - return TRUE; + if ((ev-state GDK_SHIFT_MASK)) { +switch (ev-keyval) { +case GDK_Left: + scroll_mapview(DIR8_WEST); + return TRUE; - case GDK_Up: - scroll_mapview(DIR8_NORTH); - return TRUE; +case GDK_Right: + scroll_mapview(DIR8_EAST); + return TRUE; - case GDK_Down: - scroll_mapview(DIR8_SOUTH); - return TRUE; +case GDK_Up: + scroll_mapview(DIR8_NORTH); + return TRUE; - case GDK_Home: - key_center_capital(); - return TRUE; +case GDK_Down: + scroll_mapview(DIR8_SOUTH); + return TRUE; - case GDK_Return: - case GDK_KP_Enter: - key_end_turn(); - return TRUE; +case GDK_Home: + key_center_capital(); + return TRUE; -case GDK_Page_Up: - g_signal_emit_by_name(main_message_area, move_cursor, - GTK_MOVEMENT_PAGES, -1, FALSE); - return TRUE; +case GDK_Return: +case GDK_KP_Enter: + key_end_turn(); + return TRUE; -case GDK_Page_Down: - g_signal_emit_by_name(main_message_area, move_cursor, - GTK_MOVEMENT_PAGES, 1, FALSE); - return TRUE; - - default: - break; - } +case GDK_Page_Up: + g_signal_emit_by_name(main_message_area, move_cursor, + GTK_MOVEMENT_PAGES, -1, FALSE); + return TRUE; + +case GDK_Page_Down: + g_signal_emit_by_name(main_message_area, move_cursor, + GTK_MOVEMENT_PAGES, 1, FALSE); + return TRUE; + +default: + break; } + } + /* Return here if observer */ + if (client_is_observer()) { +return FALSE; + } -if (GTK_WIDGET_HAS_FOCUS(map_canvas)) { - switch (ev-keyval) { -case GDK_Up: - key_unit_move(DIR8_NORTH); - return TRUE; + if (GTK_WIDGET_HAS_FOCUS(map_canvas)) { +switch (ev-keyval) { +case GDK_Up: + key_unit_move(DIR8_NORTH); + return TRUE; -case GDK_Page_Up: - key_unit_move(DIR8_NORTHEAST); - return TRUE; +case GDK_Page_Up: + key_unit_move(DIR8_NORTHEAST); + return TRUE; -case GDK_Right: - key_unit_move(DIR8_EAST); - return TRUE; +case GDK_Right: + key_unit_move(DIR8_EAST); + return TRUE; -case GDK_Page_Down: - key_unit_move(DIR8_SOUTHEAST); - return TRUE; +case GDK_Page_Down: + key_unit_move(DIR8_SOUTHEAST); + return TRUE; -case GDK_Down: - key_unit_move(DIR8_SOUTH); - return TRUE; +case GDK_Down: + key_unit_move(DIR8_SOUTH); + return TRUE; -case GDK_End: - key_unit_move(DIR8_SOUTHWEST); - return TRUE; - -case GDK_Left: - key_unit_move(DIR8_WEST); - return TRUE; +case GDK_End: + key_unit_move(DIR8_SOUTHWEST); + return TRUE; + +case GDK_Left: + key_unit_move(DIR8_WEST); + return TRUE; -case GDK_Home: - key_unit_move(DIR8_NORTHWEST); - return TRUE; +case GDK_Home: + key_unit_move(DIR8_NORTHWEST); + return TRUE; - default: - break; - } +default: + break; } + } -assert(MAX_NUM_BATTLEGROUPS == 4); +
Re: [Freeciv-Dev] (PR#17191) Fixes for tutorial
URL: http://bugs.freeciv.org/Ticket/Display.html?id=17191 To be consistent with other naming conventions, that should be: has_unit_type_name(unit, rule_name) because its argument is a unit, not a utype. === Likewise, function has_tile_terrain_name(tile, rule_name) ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#17191) Fixes for tutorial
URL: http://bugs.freeciv.org/Ticket/Display.html?id=17191 [wsimpson - Tir. 10. Jul. 2007 22:00:55]: To be consistent with other naming conventions, that should be: has_unit_type_name(unit, rule_name) because its argument is a unit, not a utype. === Likewise, function has_tile_terrain_name(tile, rule_name) Absolutely. If it was my scenario, convenience function names could be sloppy. This one could be frequently copied and edited though so it is right. Also, it's sad that the == operator doesn't work on Unit_Types and the like, it seems to go after reference (actual instance) equality, and the id comparison is all I've got to reliably work. Also, I managed to attach v1 and not v2 last time, that's the reason for the unneeded print call. Attached v3 with your suggested changes Index: data/scenario/tutorial.sav === --- data/scenario/tutorial.sav (revision 13088) +++ data/scenario/tutorial.sav (arbetskopia) @@ -5,6 +5,13 @@ [script] code=$ +function has_unit_type_name(unit, utype_name) + return (unit.utype.id == find.unit_type(utype_name).id) +end +function has_tile_type_name(tile, terrain_name) + return (tile.terrain.id == find.terrain(terrain_name).id) +end + function turn_callback(turn, year) if turn == 0 then notify.event(nil, nil, E.TUTORIAL, @@ -20,9 +27,9 @@ function unit_moved_callback(unit, src_tile, dst_tile) if unit.owner:is_human() then if citiesbuilt == 0 - and unit.type.name == 'Settlers' - and (dst_tile.terrain.name == 'Grassland' - or dst_tile.terrain.name == 'Plains') then + and has_unit_type_name(unit, 'Settlers') + and (has_tile_type_name(dst_tile, 'Grassland') + or has_tile_type_name(dst_tile, 'Plains')) then notify.event(unit.owner, dst_tile, E.TUTORIAL, _(This looks like a good place to build a city. The next time this\n\ unit gets a chance to move, press (b) to found a city.\n\ @@ -195,7 +202,7 @@ if not unit.owner:is_human() then return end - if unit.type.name == 'Settlers' then + if has_unit_type_name(unit, 'Settlers') then if settlersbuilt == 0 then notify.event(unit.owner, unit.tile, E.TUTORIAL, _(You have built a settler unit. Settlers are best used to build \n\ @@ -233,7 +240,7 @@ if not city.owner:is_human() then return end - if building.name == 'Barracks' and not barracksmsg then + if building.id == find.building_type('Barracks').id and not barracksmsg then notify.event(city.owner, city.tile, E.TUTORIAL, _(You have built a Barracks. This building will make any military\n\ units you build start out as veterans. Veteran units are stronger\n\ @@ -255,7 +262,7 @@ if not city.owner:is_human() then return end - if unittype.name == 'Settlers' and not nosettlermsg then + if unittype.id == find.unit_type('Settlers').id and not nosettlermsg then notify.event(city.owner, city.tile, E.TUTORIAL, _(Your city cannot build a settler. Settlers take one unit of\n\ population to build, so a city of size one cannot build one without\n\ Index: data/scenario/tutorial.sav === --- data/scenario/tutorial.sav (revision 13088) +++ data/scenario/tutorial.sav (arbetskopia) @@ -5,6 +5,13 @@ [script] code=$ +function has_unit_type_name(unit, utype_name) + return (unit.utype.id == find.unit_type(utype_name).id) +end +function has_tile_type_name(tile, terrain_name) + return (tile.terrain.id == find.terrain(terrain_name).id) +end + function turn_callback(turn, year) if turn == 0 then notify.event(nil, nil, E.TUTORIAL, @@ -20,9 +27,9 @@ function unit_moved_callback(unit, src_tile, dst_tile) if unit.owner:is_human() then if citiesbuilt == 0 - and unit:type().name == 'Settlers' - and (dst_tile:terrain().name == 'Grassland' - or dst_tile:terrain().name == 'Plains') then + and has_unit_type_name(unit, 'Settlers') + and (has_tile_type_name(dst_tile, 'Grassland') + or has_tile_type_name(dst_tile, 'Plains')) then notify.event(unit.owner, dst_tile, E.TUTORIAL, _(This looks like a good place to build a city. The next time this\n\ unit gets a chance to move, press (b) to found a city.\n\ @@ -195,7 +202,7 @@ if not unit.owner:is_human() then return end - if unit:type().name == 'Settlers' then + if has_unit_type_name(unit, 'Settlers') then if settlersbuilt == 0 then notify.event(unit.owner, unit.tile, E.TUTORIAL, _(You have built a settler unit. Settlers are best used to build \n\ @@ -233,7 +240,7 @@ if not city.owner:is_human() then return end - if building.name == 'Barracks' and not barracksmsg then + if building.id == find.building_type('Barracks').id and not barracksmsg then notify.event(city.owner, city.tile, E.TUTORIAL, _(You have built a Barracks. This building will make any military\n\ units
[Freeciv-Dev] (PR#36323) 2.1 svn bugs
URL: http://bugs.freeciv.org/Ticket/Display.html?id=36323 [EMAIL PROTECTED] - Søn. 25. Feb. 2007 08:48:03]: Interesting glitch. Did you USE to have a city there? Nope, nowhere near. I've seen this glitch a few times since as well. Save games don't have history to determine the cause? The territory owned near Edinburgh has the fortress at its source. You won't lose that until someone conquers your fortress. Referring to #39394: Rigid border rules in S2_1 Btw, the sciencebox crash is probably fixed. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#39413) Effects-ize the calendar
URL: http://bugs.freeciv.org/Ticket/Display.html?id=39413 New version of the patch; now split up into three parts: effects_timeline_startyear_v3.diff startyear server option effects_timeline_doc_ruleset_v3.diff MinYear Req type, Effects and modifications to game_next_year effects_timeline_doc_ruleset_v3.diff Modifications to README.effects and civ1, civ2 and default rulesets Only changes from previous version: removed rounding in game_next_year. Added the step 15 years/turn for symmetry; it is not used in any default ruleset but then we have a symmetric list of year steps: 50, 25, 20, 15, 10, 5, 2, 1 The startyear option discards the year 0. We should really interpret that as year 1 AD, but setting startyear to 0 is disallowed since that year is never reached in the regular game otherwise, and there is no possibility to change the value in the validation callback startyear_callback in server/settings.c. Index: server/cityturn.c === --- server/cityturn.c (revision 13092) +++ server/cityturn.c (arbetskopia) @@ -888,6 +888,20 @@ API_TYPE_CITY, pcity, API_TYPE_STRING, need_terrainclass); break; + case REQ_MINYEAR: + /* FIXME: if negated: we should skip rather than postpone, + * since we'll never be able to meet this req... */ + notify_player(pplayer, pcity-tile, E_CITY_CANTBUILD, + _(%s can't build %s from the worklist; + Only available from %s. Postponing...), + pcity-name, + get_impr_name_ex(pcity, building-index), + textyear(preq-source.value.minyear)); + script_signal_emit(building_cant_be_built, 3, + API_TYPE_BUILDING_TYPE, building, + API_TYPE_CITY, pcity, + API_TYPE_STRING, need_minyear); + break; case REQ_NONE: case REQ_LAST: assert(0); Index: common/effects.c === --- common/effects.c (revision 13092) +++ common/effects.c (arbetskopia) @@ -93,6 +93,7 @@ No_Incite, Gain_AI_Love, Slow_Down_Timeline, + Slow_Down_Timeline_2, Civil_War_Chance, Empire_Size_Base, Empire_Size_Step, Index: common/effects.h === --- common/effects.h (revision 13092) +++ common/effects.h (arbetskopia) @@ -81,6 +81,7 @@ EFT_NO_INCITE, EFT_GAIN_AI_LOVE, EFT_SLOW_DOWN_TIMELINE, + EFT_SLOW_DOWN_TIMELINE_2, /* Space module tech slowdown */ EFT_CIVIL_WAR_CHANCE, EFT_EMPIRE_SIZE_BASE, /* +1 unhappy when more than this cities */ EFT_EMPIRE_SIZE_STEP, /* adds additional +1 unhappy steps to above */ Index: common/game.c === --- common/game.c (revision 13092) +++ common/game.c (arbetskopia) @@ -431,8 +431,10 @@ ***/ int game_next_year(int year) { - const int slowdown = (game.info.spacerace - ? get_world_bonus(EFT_SLOW_DOWN_TIMELINE) : 0); + const int calendar_slowdown = get_world_bonus(EFT_SLOW_DOWN_TIMELINE); + const int space_slowdown = (game.info.spacerace + ? get_world_bonus(EFT_SLOW_DOWN_TIMELINE_2) : 0); + int inc; if (year == 1) /* hacked it to get rid of year 0 */ year = 0; @@ -450,22 +452,31 @@ * about 1900 AD */ - /* Note the slowdown operates even if Enable_Space is not active. See - * README.effects for specifics. */ - if (year = 1900 || (slowdown = 3 year 0)) { -year += 1; - } else if (year = 1750 || slowdown = 2) { -year += 2; - } else if (year = 1500 || slowdown = 1) { -year += 5; - } else if( year = 1000 ) -year += 10; - else if( year = 0 ) -year += 20; - else if( year = -1000 ) /* used this line for tuning (was -1250) */ -year += 25; - else -year += 50; + /* Calendar slowdowns commented with years in the default ruleset + * Note the space_slowdown operates even if Enable_Space is not active. + * See README.effects for specifics. */ + if (calendar_slowdown = 7 || space_slowdown = 3 ) { /*1900*/ +if (year == 0) /* year 0 hack */ + inc = 2; +else + inc = 1; + } else if (calendar_slowdown = 6 || space_slowdown = 2) { /* = 1750 */ +inc = 2; + } else if (calendar_slowdown = 5 || space_slowdown = 1) { /* = 1500 */ +inc = 5; + } else if( calendar_slowdown = 4 ) {/* = 1000 */ +inc = 10; + } else if( calendar_slowdown = 3 ) {/*(not used)*/ +inc = 15; + } else if( calendar_slowdown = 2 ) {/* = 0 */ +inc = 20; + } else if( calendar_slowdown = 1 ) {/* = -1000 */ +inc = 25; + } else { +inc = 50; + } + + year += inc; if (year == 0) year = 1; Index: common/requirements.c === --- common/requirements.c (revision 13092) +++ common/requirements.c (arbetskopia) @@ -43,7 +43,8 @@ Specialist, MinSize, AI, - TerrainClass +
Re: [Freeciv-Dev] (PR#39441) tracking release 2.0.10
URL: http://bugs.freeciv.org/Ticket/Display.html?id=39441 Ulrik Sverdrup wrote: URL: http://bugs.freeciv.org/Ticket/Display.html?id=19044 Just for information, this ticket is open for 2.0.x: #19044: 2.0 = 2.1 forward compatibility No, it should be open for 2.1. Forward means (as the subject says) from 2.0 to 2.1. (This is also known as backward compatibility.) Of course, the subject could be wrong as written. The other way, 2.1 = 2.0 would be reverse compatibility. I have no interest in retrofitting old versions to read newer versions. Indeed, 2.1 doesn't save map.l lines, so 2.0 will exit with error. We should be able to read old savegames, but not those that are completely incompatible. AFAIK, the current cutoff is 1.14.x. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#39381) RFE civ3+ water support
URL: http://bugs.freeciv.org/Ticket/Display.html?id=39381 A bigger step toward civ3+ land and water. Add the new water terrain identifiers to the rulesets, updating the corresponding tilespecs. This is a straightforward process, duplicating existing terrain information. Merely enough to test the tile editor and show future graphics. Old savefiles continue to work, but (by definition) any editted water terrain will prevent loading by earlier versions. trunk revision 13092. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#39441) tracking release 2.0.10
URL: http://bugs.freeciv.org/Ticket/Display.html?id=39441 On Tue, Jul 10, 2007 at 08:49:55PM -0700, William Allen Simpson wrote: The other way, 2.1 = 2.0 would be reverse compatibility. I have no interest in retrofitting old versions to read newer versions. hmm. there has been a somewhat concerted effort in the past to make savegames both backwards and forwards compatible. That was the point of savegame capabilities and a lot of thought before making any changes to the savegame format. Retrofitting previous versions is pointless I agree. Indeed, 2.1 doesn't save map.l lines, so 2.0 will exit with error. I've had my head in the sand for the past year or so I grant, but this was necessary for what reason? We should be able to read old savegames, but not those that are completely incompatible. AFAIK, the current cutoff is 1.14.x. This shouldn't be the case AFAIK. I recall that there was a compatibility break in Jan 2001... M ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#39370) 2.1.0b4 city vision radius too small
URL: http://bugs.freeciv.org/Ticket/Display.html?id=39370 Committed trunk revision 13093. Adopted some of Per's syntax, with my ruleset option, attached for posterity. Index: server/citytools.c === --- server/citytools.c (revision 13092) +++ server/citytools.c (working copy) @@ -801,7 +801,8 @@ give_citymap_from_player_to_player(pcity, pgiver, ptaker); old_vision = pcity-server.vision; - pcity-server.vision = vision_new(ptaker, pcity-tile, FALSE); + pcity-server.vision = vision_new(ptaker, pcity-tile); + vision_reveal_tiles(pcity-server.vision, game.info.city_reveal_tiles); vision_layer_iterate(v) { vision_change_sight(pcity-server.vision, v, vision_get_sight(old_vision, v)); @@ -985,7 +986,8 @@ } /* Before arranging workers to show unknown land */ - pcity-server.vision = vision_new(pplayer, ptile, FALSE); + pcity-server.vision = vision_new(pplayer, ptile); + vision_reveal_tiles(pcity-server.vision, game.info.city_reveal_tiles); city_refresh_vision(pcity); tile_set_city(ptile, pcity); Index: server/ruleset.c === --- server/ruleset.c(revision 13092) +++ server/ruleset.c(working copy) @@ -2684,6 +2684,10 @@ exit(EXIT_FAILURE); } + /* civ1 2 didn't reveal tiles */ + game.info.city_reveal_tiles = +secfile_lookup_bool_default(file, FALSE, parameters.vision_reveal_tiles); + /* City Styles ... */ styles = secfile_get_secnames_prefix(file, CITYSTYLE_SECTION_PREFIX, nval); Index: server/maphand.c === --- server/maphand.c(revision 13092) +++ server/maphand.c(working copy) @@ -1713,14 +1713,13 @@ See documentation in maphand.h. / -struct vision *vision_new(struct player *pplayer, struct tile *ptile, - bool can_reveal_tiles) +struct vision *vision_new(struct player *pplayer, struct tile *ptile) { struct vision *vision = fc_malloc(sizeof(*vision)); vision-player = pplayer; vision-tile = ptile; - vision-can_reveal_tiles = can_reveal_tiles; + vision-can_reveal_tiles = TRUE; vision_layer_iterate(v) { vision-radius_sq[v] = -1; } vision_layer_iterate_end; @@ -1729,6 +1728,20 @@ } / + Sets the can_reveal_tiles flag. + Returns the old flag. + + See documentation in maphand.h. +/ +bool vision_reveal_tiles(struct vision *vision, bool reveal_tiles) +{ + bool was = vision-can_reveal_tiles; + + vision-can_reveal_tiles = reveal_tiles; + return was; +} + +/ Returns the sight points (radius_sq) that this vision source has. See documentation in maphand.h. Index: server/maphand.h === --- server/maphand.h(revision 13092) +++ server/maphand.h(working copy) @@ -120,9 +120,9 @@ only rarely be necessary since all fogging and unfogging operations are taken care of internally. - The can_reveal_tiles parameter controls whether the vision source can - discover new (unknown) tiles or simply maintain vision on already-known - tiles. Currently cities should pass FALSE for this since they cannot + vision_reveal_tiles() controls whether the vision source can discover + new (unknown) tiles or simply maintain vision on already-known tiles. + By default, cities should pass FALSE for this since they cannot discover new tiles. * IMPORTANT * @@ -137,7 +137,7 @@ visible. For instance to move a unit: old_vision = punit-server.vision; -punit-server.vision = vision_new(punit-owner, dest_tile, TRUE); +punit-server.vision = vision_new(punit-owner, dest_tile); vision_change_sight(punit-server.vision, get_unit_vision_at(punit, dest_tile)); @@ -151,8 +151,8 @@ a unit or city between players, etc. / struct vision; -struct vision *vision_new(struct player *pplayer, struct tile *ptile, - bool can_reveal_tiles); +struct vision *vision_new(struct player *pplayer, struct tile *ptile); +bool vision_reveal_tiles(struct vision *vision, bool reveal_tiles); int vision_get_sight(const struct vision *vision, enum vision_layer vlayer); void vision_change_sight(struct vision *vision, enum vision_layer vlayer, int radius_sq); Index: server/unittools.c === --- server/unittools.c (revision 13092) +++ server/unittools.c (working copy) @@ -1378,7 +1378,7 @@