patchFreeciv - Patches: patch #4011, Lua: edit.change_terrain and...

Show feedback again

patch #4011: Lua: edit.change_terrain and edit.place_resource

Submitted by:  J. M. Gorbach <gorb>
Submitted on:  Wed Jul 17 10:46:27 2013  
Category: generalPriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Planned Release: 3.0.0Contains string changes: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Thu Jan 21 07:21:39 2016, comment #9:

As resources are becoming form of extras separate edit.place_resource() is not to be added. edit.changed_terrain() would still be interesting.

Marko Lindqvist <cazfi>
Project Administrator
Tue Feb 25 19:05:19 2014, comment #8:

Well, editor needs to handle similar case of terrain changes, so checking edithand.c... see check_edited_tile_terrains().

Marko Lindqvist <cazfi>
Project Administrator
Tue Feb 25 18:50:51 2014, comment #7:

>Are you recalculating the continents?

Ehm... no, because I don't know where I have to look. I searched in the code num_continents and last_num_continents. Maybe I have to work in server/generator files (i.e. utilities.c) or in ai/default/ (i.e. aidata.c and aidata.h) or elsewhere (common, client, etc).

If you have any advice it would be very much appreciated!

J. M. Gorbach <gorb>
Tue Feb 25 17:08:18 2014, comment #6:

You have not said anything about my comment #2. Are you recalculating the continents? (note also the case that changing one ocean tile to land tile can cause two continents to merge, requuiring complete reorganization of their ids)

Marko Lindqvist <cazfi>
Project Administrator
Tue Feb 25 15:51:16 2014, comment #5:

In my patch from 'tile_change_terrain' to 'tile_set_terrain'.

Fix... but when I turn Grassland into Ocean (resource: Whales).

in begin_turn() [srv_main.c::881]: assertion 'cont < 0' failed.
in begin_phase() [srv_main.c::972]: assertion 'cont < 0' failed.

J. M. Gorbach <gorb>
Tue Feb 25 15:12:08 2014, comment #4:

I checked another time...

File: server/sanitycheck.c

Function: static void check_map(const char file, const char function, int line)

193 SANITY_TILE(ptile, cont > 0);
195 if (!is_ocean_tile(tile1)) {
196 SANITY_TILE(ptile, tile_continent(tile1) == cont);
197 }

There is a warning when I start a game (file #19670), I open and close Editing Mode and Turn Done.

Tileset problem, it's probably incompatible with the ruleset: Map topology and tileset incompatible.

J. M. Gorbach <gorb>
Sat Jan 4 22:37:50 2014, comment #3:

I checked another time...

I added scripting lua (transform terrain -mountain- and place resource -gold-) in the scenario. If I turn ocean, deep ocean or lake in mountains, there are error messages. Same position, exactly on sanity_check().

If I turn plain in mountain, nothing... I don't know if swamp, glacier, forest, hill or other terrains are ok, but I think so.

(file #19670)

J. M. Gorbach <gorb>
Wed Oct 30 09:56:50 2013, comment #2:

"cont" is probably short for "continent". You are not setting continent id correctly (< 0 indicates the tile is oceanic).

Marko Lindqvist <cazfi>
Project Administrator
Sun Sep 1 14:09:03 2013, comment #1:

How you can debug the assertions (in case you didn't know):

The text "in begin_turn() [srv_main.c::881]" indicate that you should look at the function begin_turn() in the file srv_main.c, line 881. If you don't have the sources that gave the asserting failure apply your patch and compile again to see were the problems now are located.

An assertion is something that the code assume always will be true. I suggest following the data checked. In this case the variable cont. (Tips: Use a tool so you won't have to locate everything by hand) Look forwards to see if the new value breaks something. Look backwards to see if you changed it by accident or if the new value is expected.

Sveinung Kvilhaugsvik <sveinung>
Project Member
Wed Jul 17 10:46:27 2013, original submission:

Add two new lua functions in module edit:
edit.change_terrain, change terrain

I've tested with:
Works, the result is a transformation from deep ocean to mountain, with a resource (gold), but there are messages.
Only change function:
Both functions (change and place):

J. M. Gorbach <gorb>


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #19670:  europe-200x100-v2.sav added by gorb (60kB - application/x-spss-sav)
file #18310:  change_terrain_and_place_resource.diff added by gorb (3kB - application/octet-stream)


Depends on the following items: None found

   task dependencies.


Carbon-Copy List
  • -unavailable- added by cazfi (Posted a comment)
  • -unavailable- added by sveinung (Posted a comment)
  • -unavailable- added by gorb (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Jan 21 07:21:39 2016cazfiPlanned Release=>3.0.0
    Sat Jan 4 22:37:50 2014gorbAttached File-=>Added europe-200x100-v2.sav, #19670
    Wed Jul 17 10:46:27 2013gorbAttached File-=>Added change_terrain_and_place_resource.diff, #18310
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup