aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSingularis <singularis@volny.cz>2025-01-01 08:56:09 +0100
committerorwell <orwell@bleipb.de>2025-05-27 20:22:01 +0200
commit1d3e1cf073eb1edb2e50b78b6e05115fc8649174 (patch)
treedb22b40fcb214d2a26007b9c6a609e4548f668cb
parent3c9b10c52d11ac72f300e6b3d6fc77d0e2c3d23c (diff)
downloadadvtrains-1d3e1cf073eb1edb2e50b78b6e05115fc8649174.tar.gz
advtrains-1d3e1cf073eb1edb2e50b78b6e05115fc8649174.tar.bz2
advtrains-1d3e1cf073eb1edb2e50b78b6e05115fc8649174.zip
[advtrains] opravena chyba způsobující zasekávání kamery při jízdě vlakem některými směry
- [advtrains_line_automation] opraven pád serveru při zobrazení posledních jízd na lince za určitých okolností - [advtrains_line_automation] příkaz /vlaky nově bere v úvahu i zpoždění na příjezdu do následující zastávky - [ch_containers] vývoj
-rw-r--r--advtrains/helpers.lua8
-rw-r--r--advtrains/wagons.lua8
-rw-r--r--advtrains_line_automation/line_editor.lua19
-rw-r--r--advtrains_line_automation/line_functions.lua29
4 files changed, 51 insertions, 13 deletions
diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua
index db5023b..33950ec 100644
--- a/advtrains/helpers.lua
+++ b/advtrains/helpers.lua
@@ -516,3 +516,11 @@ function advtrains.after_place_signal(pos, placer, itemstack, pointed_thing)
node.param2 = n[2]
advtrains.ndb.swap_node(pos, node)
end
+
+function advtrains.yaw_equals(yaw1, yaw2)
+ if yaw1 ~= nil and yaw2 ~= nil then
+ return math.abs(yaw2 - yaw1) < 1.0e-9
+ else
+ return yaw1 == yaw2
+ end
+end
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 3ecd60d..02e0709 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -562,18 +562,20 @@ function wagon:on_step(dtime)
end
end
+ local wagon_yaw_changed = not advtrains.yaw_equals(self.old_yaw, oyaw)
+
if not self.old_velocity_vector
or not vector.equals(velocityvec, self.old_velocity_vector)
or not self.old_acceleration_vector
or not vector.equals(accelerationvec, self.old_acceleration_vector)
- or self.old_yaw~=oyaw
+ or wagon_yaw_changed
or updatepct_timer_elapsed then--only send update packet if something changed
self.object:set_pos(pos)
self.object:set_velocity(velocityvec)
self.object:set_acceleration(accelerationvec)
- if #self.seats > 0 and self.old_yaw ~= oyaw then
+ if #self.seats > 0 and wagon_yaw_changed then
if not self.player_yaw then
self.player_yaw = {}
end
@@ -592,7 +594,7 @@ function wagon:on_step(dtime)
end
end
self.turning = true
- elseif self.old_yaw == oyaw then
+ elseif not wagon_yaw_changed then
-- train is no longer turning
self.turning = false
end
diff --git a/advtrains_line_automation/line_editor.lua b/advtrains_line_automation/line_editor.lua
index 0862579..9c89946 100644
--- a/advtrains_line_automation/line_editor.lua
+++ b/advtrains_line_automation/line_editor.lua
@@ -760,19 +760,24 @@ show_last_passages_formspec = function(player, linevar_def, selected_linevar)
-- odjezd z výchozí zastávky:
table.insert(formspec, ","..F(stops[1][1])..","..F(stops[1][2]).." (odj.)")
for j = 1, 10 do
- local time = assert(passages[j][1])
- table.insert(formspec, ",("..time..")")
- if max_time[j] < time then
- max_time[j] = time
+ local time = passages[j][1]
+ if time ~= nil then
+ table.insert(formspec, ",("..time..")")
+ if max_time[j] < time then
+ max_time[j] = time
+ end
+ else
+ table.insert(formspec, ",-")
end
end
-- odjezdy z ostatních zasŧávek:
for i = 2, #stops do -- i = index zastávky
table.insert(formspec, ","..F(stops[i][1])..","..F(stops[i][2]))
for j = 1, 10 do -- j = index jízdy
+ local dep_vych = passages[j][1]
local time = passages[j][i]
- if time ~= nil then
- table.insert(formspec, ","..(time - passages[j][1]))
+ if time ~= nil and dep_vych ~= nil then
+ table.insert(formspec, ","..(time - dep_vych))
if max_time[j] < time then
max_time[j] = time
end
@@ -783,7 +788,7 @@ show_last_passages_formspec = function(player, linevar_def, selected_linevar)
end
table.insert(formspec, ",,DOBA JÍZDY:")
for i = 1, 10 do
- if max_time[i] ~= nil then
+ if max_time[i] ~= 0 then
table.insert(formspec, ",_"..(max_time[i] - passages[i][1]).."_")
else
table.insert(formspec, ",-")
diff --git a/advtrains_line_automation/line_functions.lua b/advtrains_line_automation/line_functions.lua
index aba7e01..e23bd6f 100644
--- a/advtrains_line_automation/line_functions.lua
+++ b/advtrains_line_automation/line_functions.lua
@@ -379,14 +379,37 @@ end
text = string,
}
]]
-function al.get_delay_description(line_status, linevar_def)
+function al.get_delay_description(line_status, linevar_def, rwtime)
assert(line_status)
if linevar_def == nil then
return {text = ""}
end
- local expected_departure = line_status.linevar_dep + assert(linevar_def.stops[line_status.linevar_index]).dep
+ local stops = linevar_def.stops
+ local expected_departure = line_status.linevar_dep + assert(stops[line_status.linevar_index]).dep
local real_departure = line_status.linevar_last_dep
local delay = real_departure - expected_departure
+
+ if rwtime ~= nil then
+ local expected_departure_next
+ for i = line_status.linevar_index + 1, #stops do
+ if stops[i] == nil then
+ break
+ else
+ local mode = stops[i].mode
+ if mode == nil or mode ~= MODE_DISABLED then
+ expected_departure_next = line_status.linevar_dep + stops[i].dep
+ break
+ end
+ end
+ end
+ if expected_departure_next ~= nil then
+ local delay2 = rwtime - expected_departure_next
+ if delay2 > delay then
+ delay = delay2
+ end
+ end
+ end
+
if delay < -1 or delay > 10 then
return {
has_delay = true,
@@ -851,7 +874,7 @@ local function get_train_position(line_status, linevar_def, rwtime)
local last_pos = last_pos_info.last_pos
if last_pos ~= nil then
local result = "„"..get_station_name(last_pos.stn).."“"
- local delay_info = al.get_delay_description(line_status, linevar_def)
+ local delay_info = al.get_delay_description(line_status, linevar_def, rwtime)
if last_pos_info.type ~= "standing" then
result = result.." (před "..(rwtime - last_pos.rwtime).." sekundami)"
end