aboutsummaryrefslogtreecommitdiff
path: root/advtrains/path.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-12-05 10:14:07 +0100
committerorwell96 <orwell@bleipb.de>2019-12-05 10:15:36 +0100
commiteeef07d05a7e53de469f19a23fe1e69f569fc924 (patch)
tree6330ae717f337ec1a039004349d9c4c045ab632c /advtrains/path.lua
parent9c1d3565058799f21b6985c100ccf1abe045d3da (diff)
downloadadvtrains-eeef07d05a7e53de469f19a23fe1e69f569fc924.tar.gz
advtrains-eeef07d05a7e53de469f19a23fe1e69f569fc924.tar.bz2
advtrains-eeef07d05a7e53de469f19a23fe1e69f569fc924.zip
Add profiling instructions for advprofiler
Diffstat (limited to 'advtrains/path.lua')
-rw-r--r--advtrains/path.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/advtrains/path.lua b/advtrains/path.lua
index 825e59b..1e224e4 100644
--- a/advtrains/path.lua
+++ b/advtrains/path.lua
@@ -156,6 +156,9 @@ function advtrains.path_get(train, index)
if index ~= atfloor(index) then
error("For train "..train.id..": Called path_get() but index="..index.." is not a round number")
end
+
+ advtrains.profiler:enter("path_get")
+
local pef = train.path_ext_f
while index > pef do
local pos = train.path[pef]
@@ -224,6 +227,8 @@ function advtrains.path_get(train, index)
train.path_req_f = index
end
+ advtrains.profiler:leave("path_get")
+
return train.path[index], (index<=train.path_trk_f and index>=train.path_trk_b)
end
@@ -257,6 +262,8 @@ function advtrains.path_get_adjacent(train, index)
end
function advtrains.path_get_index_by_offset(train, index, offset)
+ advtrains.profiler:enter("path_get_index_by_offset")
+
local off = offset
local idx = atfloor(index)
-- go down to floor. Calculate required path_dist
@@ -286,6 +293,8 @@ function advtrains.path_get_index_by_offset(train, index, offset)
-- we should now be on the floor of the index we actually want.
-- give them the rest!
+ advtrains.profiler:leave("path_get_index_by_offset")
+
return idx + (off / train.path_dist[idx])
end