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 17 Jul 2013 10:46:27 AM UTC  
 
Category: generalPriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Planned Release: 

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)

Tue 25 Feb 2014 07:05:19 PM UTC, 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 25 Feb 2014 06:50:51 PM UTC, 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 25 Feb 2014 05:08:18 PM UTC, 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 25 Feb 2014 03:51:16 PM UTC, 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 25 Feb 2014 03:12:08 PM UTC, comment #4:

I checked another time...

File: server/sanitycheck.c

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

Specific:
193 SANITY_TILE(ptile, cont > 0);
and
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 04 Jan 2014 10:37:50 PM UTC, 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 30 Oct 2013 09:56:50 AM UTC, 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 01 Sep 2013 02:09:03 PM UTC, 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 17 Jul 2013 10:46:27 AM UTC, original submission:

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

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):
   
   
Comment:
   

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

Items that depend on this one: None found

 

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.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 04 Jan 2014 10:37:50 PM UTCgorbAttached File-=>Added europe-200x100-v2.sav, #19670
    Wed 17 Jul 2013 10:46:27 AM UTCgorbAttached File-=>Added change_terrain_and_place_resource.diff, #18310
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup