The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on March 28, 2020, 12:03:14 AM

Title: command_x causes Simutrans to crash.
Post by: Yona-TYT on March 28, 2020, 12:03:14 AM

When using script text tag with "command_x" to build a road section, simutrans stops working and the terminal shows this: "sim: boden/wege/weg.cc:87: static weg_t* weg_t::alloc(waytype_t): Assertion `0' failed."
This is not present in older reviews, so I am assuming something has broken recently.
Title: Re: command_x causes Simutrans to crash.
Post by: Dwachs on March 28, 2020, 10:46:34 AM
Can you post the script text that triggers the error? Is this related to building of powerlines?
Title: Re: command_x causes Simutrans to crash.
Post by: Yona-TYT on March 28, 2020, 11:31:04 AM
Script:
https://www.mediafire.com/file/bvwsl0i5y1jec6m/tutorial_pak128-error-test.zip/file

Savegame:
https://www.mediafire.com/file/6a9oz6vt1lv5u8n/tutorial_pak128-error-test.sve/file

Click on the link "go to next step", this will execute the following code block:

file "class/class_chapter_02.nut" line 1234
switch (this.step) {
            case 1:
                delay_mark_tile(coordb, coordb,0, true)
                //Para la carretera
                local t1 = command_x(tool_remover)
                local err1 = t1.work(player_x(0), square_x(coordb.x, coordb.y).get_ground_tile(), "")
                local t2 = command_x(tool_build_way)           
                local err2 = t2.work(player_x(0), square_x( coorda.x, coorda.y ).get_ground_tile(), square_x(coordb.x, coordb.y).get_ground_tile(),"Road_070")
                return null
                break;
Title: Re: command_x causes Simutrans to crash.
Post by: Dwachs on March 28, 2020, 12:24:23 PM
Will check.

Please use command_x::build_way for this purpose:

http://dwachs.github.io/simutrans-sqapi-doc/classcommand__x.html#a1881d81fa6116af1227429b1c7f7699c

It has more parameter checks than command_x::work
Title: Re: command_x causes Simutrans to crash.
Post by: Dwachs on March 28, 2020, 02:40:32 PM
should work with r8981 again.