From 75fd7a6fbf7d03410481b89e244b1d6d8b015e58 Mon Sep 17 00:00:00 2001 From: Yonatan Date: Thu, 12 Aug 2021 18:34:48 -0400 Subject: [PATCH] Bugs fix, useless code cleanup --- class/class_basic_chapter.nut | 52 +++++++++----------------- class/class_chapter_02.nut | 3 -- class/class_chapter_03.nut | 7 +--- class/class_chapter_04.nut | 2 - class/class_chapter_05.nut | 3 -- class/class_chapter_06.nut | 1 - scenario.nut | 69 +---------------------------------- 7 files changed, 20 insertions(+), 117 deletions(-) diff --git a/class/class_basic_chapter.nut b/class/class_basic_chapter.nut index 25cc4a9..64bbf33 100644 --- a/class/class_basic_chapter.nut +++ b/class/class_basic_chapter.nut @@ -132,7 +132,6 @@ class basic_chapter function comm_start_convoy(pl, wt, sched, cov_list, depot) { - lin_flag = true pl.create_line(wt) // find the line - it is a line without schedule and convoys local list = pl.get_line_list() @@ -581,7 +580,7 @@ class basic_chapter function is_waystop_correct(player,schedule,nr,load,wait,coord, c_all = false) { - local result = null + local result = 0 // coord = x,y,z place to compare the waystop // nr = number of schedule.entrie to compare local nr2 = schedule.entries.len()-1 @@ -603,7 +602,12 @@ class basic_chapter local halt = entrie.get_halt( player_x(player) ) local targ_t = this.my_tile(coord) - local target = targ_t.get_halt() + + local target = square_x(coord.x,coord.y).get_halt() + local target_list = square_x(coord.x,coord.y).get_halt_list() + + + if (!halt) return translate("The schedule is not correct.") local t_list = halt.get_tile_list() local t2_list = targ_t.is_water() ? get_tiles_near_factory(t_list) : target.get_tile_list() @@ -620,20 +624,19 @@ class basic_chapter else if((c_buld1.x == c_buld2.x) && (c_buld1.y == c_buld2.y)) { result = null } - else{ + + if (result!=null){ local text = ttext("The waystop {nr} '{name}' isn't on place {pos}") - text.name = target.get_name() + text.name = target_list[0].get_name() text.pos = pos_to_text(coord) text.nr = (nr_st+1) result = text.tostring() return result } - if (result!=null) - return result if (entrie.load != load) { local text = ttext("The load of waystop {nr} '{name}' isn't {load}% {pos}") - text.name = halt.get_name() + text.name = target_list[0].get_name() text.pos = pos_to_text(coord) text.load = load text.nr = (nr+1) @@ -644,7 +647,7 @@ class basic_chapter //gui.add_message(""+entrie.wait+"") local text = ttext("The waittime in waystop {nr} '{name}' isn't {wait} {pos}") local txwait = get_wait_time_text(wait) - text.name = halt.get_name() + text.name = target_list[0].get_name() text.pos = pos_to_text(coord) text.wait = txwait text.nr = (nr+1) @@ -2424,34 +2427,15 @@ class basic_chapter local x = c.x+dx local y = c.y+dy - if (x>=0 && y>=0) area.append( (x << 16) + y ); - } - } - } - return get_find_places(area) - } - - function get_find_places(area) - { - local list = [] - // check for flat and empty ground - for(local i = 0; i0 && h == area[i-1]) continue; - - local x = h >> 16 - local y = h & 0xffff + if (x>=0 && y>=0 && world.is_coord_valid({x=x,y=y})){ + local tile = square_x(x, y).get_ground_tile() + area.append( tile ); - if (world.is_coord_valid({x=x,y=y})) { - local tile = square_x(x, y).get_ground_tile() - - - list.append(tile) - + } + } } } - return list.len() > 0 ? list : [] + return area.len() > 0 ? area : [] } function check_water_tile(result, tile, pos, nr) diff --git a/class/class_chapter_02.nut b/class/class_chapter_02.nut index b57a1d2..ea2a9da 100644 --- a/class/class_chapter_02.nut +++ b/class/class_chapter_02.nut @@ -937,10 +937,7 @@ class tutorial.chapter_02 extends basic_chapter } function is_schedule_allowed(pl, schedule) { - checks_current_line(pl, schedule) - local result=null // null is equivalent to 'allowed' - if ( (pl == 0) && (schedule.waytype != gl_wt) ) result = translate("Only road schedules allowed") local nr = schedule.entries.len() diff --git a/class/class_chapter_03.nut b/class/class_chapter_03.nut index 9407c01..b52b8ab 100644 --- a/class/class_chapter_03.nut +++ b/class/class_chapter_03.nut @@ -1879,13 +1879,8 @@ class tutorial.chapter_03 extends basic_chapter } function is_schedule_allowed(pl, schedule) { - checks_current_line(pl, schedule) - if (!sch_flag) - reset_stop_flag() - sch_flag = false - local nr = schedule.entries.len() local result=null // null is equivalent to 'allowed' - + local nr = schedule.entries.len() switch (this.step) { case 5: local selc = 0 diff --git a/class/class_chapter_04.nut b/class/class_chapter_04.nut index 3aa5a85..682574d 100644 --- a/class/class_chapter_04.nut +++ b/class/class_chapter_04.nut @@ -549,8 +549,6 @@ class tutorial.chapter_04 extends basic_chapter } function is_schedule_allowed(pl, schedule) { - checks_current_line(pl, schedule) - local result=null // null is equivalent to 'allowed' local nr = schedule.entries.len() switch (this.step) { diff --git a/class/class_chapter_05.nut b/class/class_chapter_05.nut index d7ad3ae..fc72e46 100644 --- a/class/class_chapter_05.nut +++ b/class/class_chapter_05.nut @@ -716,9 +716,6 @@ class tutorial.chapter_05 extends basic_chapter } function is_schedule_allowed(pl, schedule) { - - checks_current_line(pl, schedule) - local result=null // null is equivalent to 'allowed' if ( (pl == 0) && (schedule.waytype != wt_road) ) result = translate("Only road schedules allowed") diff --git a/class/class_chapter_06.nut b/class/class_chapter_06.nut index c459f68..0a80d30 100644 --- a/class/class_chapter_06.nut +++ b/class/class_chapter_06.nut @@ -605,7 +605,6 @@ class tutorial.chapter_06 extends basic_chapter function is_schedule_allowed(pl, schedule) { local result=null // null is equivalent to 'allowed' local nr = schedule.entries.len() - checks_current_line(pl, schedule) switch (this.step) { case 2: reset_glsw() diff --git a/scenario.nut b/scenario.nut index ac6717e..182068d 100644 --- a/scenario.nut +++ b/scenario.nut @@ -4,7 +4,7 @@ * * Can NOT be used in network game ! */ -const version = 1600 +const version = 1601 map.file = "tutorial.sve" scenario_name <- "Tutorial Scenario" scenario.short_description = scenario_name @@ -75,7 +75,6 @@ correct_cov <- true //---------------------------------------------------------------- sch_flag <- false //Bandera para schedule -lin_flag <- false //Bandera para line tile_delay <- 2 //delay for mark tiles tile_delay_list <- 2 @@ -509,72 +508,6 @@ function checks_all_convoys() return cov_nr } -function checks_current_line(pl, schedule) -{ - local list = player_x(pl).get_line_list() - local l_nr = list.get_count() - local line = null - for(local j=0;j0 && sch1_nr==sch2_nr){ - for(local i=0;i