More tracy wrappers for path/LZB-related functions
This commit is contained in:
parent
b5d2c23b32
commit
c7ff2958a6
|
@ -308,6 +308,7 @@ function advtrains.get_adjacent_rail(this_posnr, this_conns_p, conn_idx, drives_
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tracy.ZoneBeginN("advtrains.get_adjacent_rail")
|
||||||
local conn = this_conns[conn_idx]
|
local conn = this_conns[conn_idx]
|
||||||
local conn_y = conn.y or 0
|
local conn_y = conn.y or 0
|
||||||
local adj_pos = advtrains.dirCoordSet(this_pos, conn.c);
|
local adj_pos = advtrains.dirCoordSet(this_pos, conn.c);
|
||||||
|
@ -323,10 +324,12 @@ function advtrains.get_adjacent_rail(this_posnr, this_conns_p, conn_idx, drives_
|
||||||
conn_y = conn_y + 1
|
conn_y = conn_y + 1
|
||||||
nextnode_ok, nextconns, nextrail_y=advtrains.get_rail_info_at(adj_pos, drives_on)
|
nextnode_ok, nextconns, nextrail_y=advtrains.get_rail_info_at(adj_pos, drives_on)
|
||||||
if not nextnode_ok then
|
if not nextnode_ok then
|
||||||
|
tracy.ZoneEnd()
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local adj_connid = advtrains.conn_matches_to({c=conn.c, y=conn_y}, nextconns)
|
local adj_connid = advtrains.conn_matches_to({c=conn.c, y=conn_y}, nextconns)
|
||||||
|
tracy.ZoneEnd()
|
||||||
if adj_connid then
|
if adj_connid then
|
||||||
return adj_pos, adj_connid, conn_idx, nextrail_y, nextconns
|
return adj_pos, adj_connid, conn_idx, nextrail_y, nextconns
|
||||||
end
|
end
|
||||||
|
|
|
@ -241,6 +241,7 @@ end
|
||||||
-- If you DON'T modify lzbdata, you MUST pass nil as lzbdata. Always modify the lzbdata table in place, never overwrite it!
|
-- If you DON'T modify lzbdata, you MUST pass nil as lzbdata. Always modify the lzbdata table in place, never overwrite it!
|
||||||
-- udata: user-defined data, do not use externally
|
-- udata: user-defined data, do not use externally
|
||||||
function advtrains.lzb_add_checkpoint(train, index, speed, callback, lzbdata, udata)
|
function advtrains.lzb_add_checkpoint(train, index, speed, callback, lzbdata, udata)
|
||||||
|
tracy.ZoneBeginN("advtrains.lzb_add_checkpoint")
|
||||||
local lzb = train.lzb
|
local lzb = train.lzb
|
||||||
local pos = advtrains.path_get(train, index)
|
local pos = advtrains.path_get(train, index)
|
||||||
local lzbdata_c = nil
|
local lzbdata_c = nil
|
||||||
|
@ -260,6 +261,7 @@ function advtrains.lzb_add_checkpoint(train, index, speed, callback, lzbdata, ud
|
||||||
table.insert(lzb.checkpoints, ckp)
|
table.insert(lzb.checkpoints, ckp)
|
||||||
|
|
||||||
apply_checkpoint_to_path(train, ckp)
|
apply_checkpoint_to_path(train, ckp)
|
||||||
|
tracy.ZoneEnd()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -269,17 +269,23 @@ end
|
||||||
--nil if the node is neither loaded nor in trackdb
|
--nil if the node is neither loaded nor in trackdb
|
||||||
--the distraction between false and nil will be needed only in special cases.(train initpos)
|
--the distraction between false and nil will be needed only in special cases.(train initpos)
|
||||||
function advtrains.get_rail_info_at(pos, drives_on)
|
function advtrains.get_rail_info_at(pos, drives_on)
|
||||||
|
tracy.ZoneBegin("advtrains.get_rail_info_at")
|
||||||
local rdp=advtrains.round_vector_floor_y(pos)
|
local rdp=advtrains.round_vector_floor_y(pos)
|
||||||
|
|
||||||
local node=ndb.get_node_or_nil(rdp)
|
local node=ndb.get_node_or_nil(rdp)
|
||||||
if not node then return end
|
if not node then
|
||||||
|
tracy.ZoneEnd()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local nodename=node.name
|
local nodename=node.name
|
||||||
if(not advtrains.is_track_and_drives_on(nodename, drives_on)) then
|
if(not advtrains.is_track_and_drives_on(nodename, drives_on)) then
|
||||||
|
tracy.ZoneEnd()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local conns, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2)
|
local conns, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2)
|
||||||
|
|
||||||
|
tracy.ZoneEnd()
|
||||||
return true, conns, railheight
|
return true, conns, railheight
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,7 @@ function advtrains.path_get(train, index)
|
||||||
local pef = train.path_ext_f
|
local pef = train.path_ext_f
|
||||||
-- generate forward (front of train, positive)
|
-- generate forward (front of train, positive)
|
||||||
while index > pef do
|
while index > pef do
|
||||||
|
tracy.ZoneBeginN("advtrains.path_get:forward")
|
||||||
local pos = train.path[pef]
|
local pos = train.path[pef]
|
||||||
local connid = train.path_cn[pef]
|
local connid = train.path_cn[pef]
|
||||||
local node_ok, this_conns, adj_pos, adj_connid, conn_idx, nextrail_y, next_conns
|
local node_ok, this_conns, adj_pos, adj_connid, conn_idx, nextrail_y, next_conns
|
||||||
|
@ -238,6 +239,7 @@ function advtrains.path_get(train, index)
|
||||||
end
|
end
|
||||||
train.path[pef] = adj_pos
|
train.path[pef] = adj_pos
|
||||||
train.path_dist[pef] = train.path_dist[pef-1] + vector.distance(pos, adj_pos)
|
train.path_dist[pef] = train.path_dist[pef-1] + vector.distance(pos, adj_pos)
|
||||||
|
tracy.ZoneEnd()
|
||||||
end
|
end
|
||||||
train.path_ext_f = pef
|
train.path_ext_f = pef
|
||||||
|
|
||||||
|
@ -245,6 +247,7 @@ function advtrains.path_get(train, index)
|
||||||
local peb = train.path_ext_b
|
local peb = train.path_ext_b
|
||||||
-- generate backward (back of train, negative)
|
-- generate backward (back of train, negative)
|
||||||
while index < peb do
|
while index < peb do
|
||||||
|
tracy.ZoneBeginN("advtrains.path_get:backward")
|
||||||
local pos = train.path[peb]
|
local pos = train.path[peb]
|
||||||
local connid = train.path_cp[peb]
|
local connid = train.path_cp[peb]
|
||||||
local node_ok, this_conns, adj_pos, adj_connid, conn_idx, nextrail_y, next_conns
|
local node_ok, this_conns, adj_pos, adj_connid, conn_idx, nextrail_y, next_conns
|
||||||
|
@ -277,6 +280,7 @@ function advtrains.path_get(train, index)
|
||||||
end
|
end
|
||||||
train.path[peb] = adj_pos
|
train.path[peb] = adj_pos
|
||||||
train.path_dist[peb] = train.path_dist[peb+1] - vector.distance(pos, adj_pos)
|
train.path_dist[peb] = train.path_dist[peb+1] - vector.distance(pos, adj_pos)
|
||||||
|
tracy.ZoneEnd()
|
||||||
end
|
end
|
||||||
train.path_ext_b = peb
|
train.path_ext_b = peb
|
||||||
|
|
||||||
|
|
|
@ -858,9 +858,11 @@ local function mknodecallback(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return callt, function(pos, id, train, index, paramx1, paramx2, paramx3)
|
return callt, function(pos, id, train, index, paramx1, paramx2, paramx3)
|
||||||
|
tracy.ZoneBegin("advtrains.run_callbacks_" .. name .. "node")
|
||||||
for _,f in ipairs(callt) do
|
for _,f in ipairs(callt) do
|
||||||
f(pos, id, train, index, paramx1, paramx2, paramx3)
|
f(pos, id, train, index, paramx1, paramx2, paramx3)
|
||||||
end
|
end
|
||||||
|
tracy.ZoneEnd()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue