aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
Commit message (Collapse)AuthorAge
* Do not throw error when sync_tcb_neighbors failsorwell962019-08-29
|
* Don't allow to remove TCB when a signal is assignedorwell962019-08-26
|
* Various small fixesGabriel Pérez-Cerezo2019-07-16
| | | | | | - Also do atomic operations on nodedb - no longer require Worldedit for at_sync_ndb - "overrun LZB 0 restriction" should now show where it happened.
* Fix remote routesettingorwell962019-04-16
|
* Move LZB system to core and unify approach callback mechanismorwell962019-04-16
|
* Disable-ARS switch in signal and set this when cancelling an ARS routeorwell962019-03-15
|
* Ugly workaround for green signals bugorwell962019-03-15
|
* Fix cancelling "Unknown Route" when section is deleted.orwell962019-03-15
|
* Do not clear LZB control when invalidating.orwell962019-02-23
| | | | Prevents trains accelerating towards red signals on /at_reroute
* possible fix for "trains standing at green signals"orwell962019-02-21
|
* Fix moving Signal IPs (no duplicate IPs)orwell962019-02-21
|
* Add ARS rules for stop railsorwell962019-02-19
|
* Prioritize LZB callback (possible bugfix for H#100)orwell962019-02-19
|
* Improve Signal IP form/workfloworwell962019-02-16
|
* Fix TCBS crash also for route_uiorwell962019-02-16
|
* Fix routesetting when TCBS is missing (H#109)orwell962019-02-12
|
* Fixes regarding signal assignments/tcbsorwell962019-02-09
| | | | | - No longer crashes when assigned tcb is removed - don't forbid modification just because signal is assigned
* Signalling form auto-updateorwell962019-02-05
|
* Force LZB Halt settingorwell962019-02-05
|
* Minor Bugfixesorwell962019-02-03
|
* Basic functions of "stop rail", missing ARS rules and signal.orwell962019-01-24
| | | | For signal, need to think of a callback system for signals and moving atlatc queue to core?
* Point speed restriction railsorwell962019-01-24
|
* Fix last commit (and another warn2log)orwell962019-01-22
|
* Fix atc command evaluation BB commandorwell962019-01-22
|
* Make LZB params adjustableorwell962019-01-22
|
* another small fix for route_uiorwell962019-01-22
|
* Fix small bug in routeui and make another message log-onlyorwell962019-01-22
|
* disable debug print of ARSorwell962019-01-22
|
* Fix may_modify_section on newly created sectionsorwell962019-01-22
|
* Fix invalid path invalidation in ARS codeorwell962019-01-22
|
* Prohibit removing/changing of TCBs and sections while routes or signals are setorwell962019-01-22
|
* Do not run LZB traverser when path does not existorwell962019-01-21
|
* Fix route aspect dialogorwell962019-01-15
|
* Fix Routingcode ARSorwell962019-01-15
|
* Can disable automatic working without cancelling routeorwell962019-01-15
|
* Actual working ARSorwell962019-01-15
|
* Add Automatic Routesetting UIorwell962019-01-09
| | | | Settings have no effect so far
* Fix crashes:orwell962018-12-10
| | | | | 1. when train hit a route, nil access to already cancelled route caused crash 2. fix crash when trying to ensure_init a train that doesn't exist
* Signs (static signals)orwell962018-12-08
|
* Shunt signals (not exactly Ks), along with fixes in other components that ↵orwell962018-12-08
| | | | those rely on
* Apply speed restriction 0.5 indexes later, do not cap tarvelocity by ↵orwell962018-12-04
| | | | speed_restriction
* Do not set speed_restriction for nprorwell962018-12-04
|
* Added on_train_approach callback, non-permanent external LZB brakepoints and ↵orwell962018-11-29
| | | | | | basis for "stop rails" Stop rails ATM use the aforementioned things to add a pointwise "2" speed restriction. Seems to work.
* Permit basic signal aspect settingorwell962018-11-19
| | | | (basically only usable with Ks signals, because they're the only signals supporting slow move and/or shunt move
* Replace "Allow accelereting train towards signal"orwell962018-10-30
| | | | This is a better implementation of the same goal. The last commit caused trains to overrun the IP sometimes. Haven't noticed so far with this approach
* Make fillout_aspect also fill "info" fieldorwell962018-10-30
|
* Do not allow static signals for routesettingorwell962018-10-30
|
* Do not print "couldn't determine section" warning when all traverser ends ↵orwell962018-10-29
| | | | were end-of-track
* Allow to accelerate trains slowly towards red signals from stand.orwell962018-10-29
| | | | Previously, it was impossible to accelerate a standing train once it was ~10m in front of a red signal.
* Fix typo in signal assignment, causing crashorwell962018-10-29
|
visual_size = {x=1, y=1}, on_punch = function(self) if self.callback then self.callback() end self.object:remove() end, get_staticdata = function() return "STATIC" end, on_activate = function(self, sdata) if sdata=="STATIC" then self.object:remove() end end, static_save = false, }) -- Spawn or update a route sprite entity -- pos: position where this is going to be -- key: something unique to determine which entity to remove if this was set before -- img: texture local function routesprite(context, pos, key, img, itex, callback) if not markerent[context] then markerent[context] = {} end if markerent[context][key] then markerent[context][key]:remove() end local obj = minetest.add_entity(vector.add(pos, {x=0, y=0, z=0}), "advtrains_interlocking:routesprite") if not obj then return end obj:set_properties({ infotext = itex, textures = {img}, }) if callback then obj:get_luaentity().callback = callback end markerent[context][key] = obj end --[[ Route definition: route = { name = <string> [n] = { next = <sigd>, -- of the next (note: next) TCB on the route locks = {<pts> = "state"} -- route locks of this route segment } terminal = } The first item in the TCB path (namely i=0) is always the start signal of this route, so this is left out. All subsequent entries, starting from 1, contain: - all route locks of the segment on TS between the (i-1). and the i. TCB - the next TCB signal describer in proceeding direction of the route. 'Terminal' once again repeats the "next" entry of the last route segment. It is needed for distant signal aspect determination. If it is not set, the distant signal aspect is determined as DANGER. ]]-- local function chat(pname, message) minetest.chat_send_player(pname, "[Route programming] "..message) end local function clear_lock(locks, pname, pts) locks[pts] = nil chat(pname, pts.." is no longer affected when this route is set.") end local function otherside(s) if s==1 then return 2 else return 1 end end function advtrains.interlocking.clear_visu_context(context) if not markerent[context] then return end for key, obj in pairs(markerent[context]) do obj:remove() end markerent[context] = nil end -- visualize route. 'context' is a string that identifies the context of this visualization -- e.g. prog_<player> or vis_<pts> for later visualizations -- last 2 parameters are only to be used in the context of route programming! function advtrains.interlocking.visualize_route(origin, route, context, tmp_lcks, pname) advtrains.interlocking.clear_visu_context(context) local oyaw = 0 local onode_ok, oconns, orhe = advtrains.get_rail_info_at(origin.p, advtrains.all_tracktypes) if onode_ok then oyaw = advtrains.dir_to_angle(oconns[origin.s].c) end routemarker(context, origin.p, "rte_origin", "at_il_route_start.png", oyaw, route.name) local c_sigd = origin for k,v in ipairs(route) do c_sigd = v.next -- display route path -- Final "next" marker can be EOI, thus undefined. This is legitimate. if c_sigd then local yaw = 0 local node_ok, conns, rhe = advtrains.get_rail_info_at(c_sigd.p, advtrains.all_tracktypes) if node_ok then yaw = advtrains.dir_to_angle(conns[c_sigd.s].c) end local img = "at_il_route_set.png" if k==#route and not tmp_lcks then img = "at_il_route_end.png" end routemarker(context, c_sigd.p, "rte"..k, img, yaw, route.name.." #"..k) end -- display locks for pts, state in pairs(v.locks) do local pos = minetest.string_to_pos(pts) routesprite(context, pos, "fix"..k..pts, "at_il_route_lock.png", "Fixed in state '"..state.."' by route "..route.name.." until segment #"..k.." is freed.") end end -- The presence of tmp_lcks tells us that we are displaying during route programming. if tmp_lcks then -- display route end markers at appropriate places (check next TS, if it exists) local terminal = c_sigd if terminal then local term_tcbs = advtrains.interlocking.db.get_tcbs(terminal) if term_tcbs.ts_id then local over_ts = advtrains.interlocking.db.get_ts(term_tcbs.ts_id) for i, sigd in ipairs(over_ts.tc_breaks) do if not vector.equals(sigd.p, terminal.p) then local yaw = 0 local node_ok, conns, rhe = advtrains.get_rail_info_at(sigd.p, advtrains.all_tracktypes) if node_ok then yaw = advtrains.dir_to_angle(conns[otherside(sigd.s)].c) end routemarker(context, sigd.p, "rteterm"..i, "at_il_route_end.png", yaw, route.name.." Terminal "..i) end end end end -- display locks set by player for pts, state in pairs(tmp_lcks) do local pos = minetest.string_to_pos(pts) routesprite(context, pos, "fixp"..pts, "at_il_route_lock_edit.png", "Fixed in state '"..state.."' by route "..route.name.." (punch to unfix)", function() clear_lock(tmp_lcks, pname, pts) end) end end end local player_rte_prog = {} function advtrains.interlocking.init_route_prog(pname, sigd) if not minetest.check_player_privs(pname, "interlocking") then minetest.chat_send_player(pname, "Insufficient privileges to use this!") return end player_rte_prog[pname] = { origin = sigd, route = { name = "PROG["..pname.."]", }, tmp_lcks = {}, } advtrains.interlocking.visualize_route(sigd, player_rte_prog[pname].route, "prog_"..pname, player_rte_prog[pname].tmp_lcks, pname) minetest.chat_send_player(pname, "Route programming mode active. Punch TCBs to add route segments, punch turnouts to lock them.") end local function get_last_route_item(origin, route) if #route == 0 then return origin end return route[#route].next end local function do_advance_route(pname, rp, sigd, tsname) table.insert(rp.route, {next = sigd, locks = rp.tmp_lcks}) rp.tmp_lcks = {} chat(pname, "Added track section '"..tsname.."' to the route.") end local function finishrpform(pname) local rp = player_rte_prog[pname] if not rp then return end local form = "size[7,6]label[0.5,0.5;Finish programming route]" local terminal = get_last_route_item(rp.origin, rp.route) if terminal then local term_tcbs = advtrains.interlocking.db.get_tcbs(terminal) if term_tcbs.signal then form = form .. "label[0.5,1.5;Route ends at signal:]" form = form .. "label[0.5,2 ;"..term_tcbs.signal_name.."]" else form = form .. "label[0.5,1.5;WARNING: Route does not end at a signal.]" form = form .. "label[0.5,2 ;Routes should in most cases end at signals.]" form = form .. "label[0.5,2.5;Cancel if you are unsure!]" end else form = form .. "label[0.5,1.5;Route leads into]" form = form .. "label[0.5,2 ;non-interlocked area]" end form = form.."field[0.8,3.5;5.2,1;name;Enter Route Name;]" form = form.."button_exit[0.5,4.5; 5,1;save;Save Route]" minetest.show_formspec(pname, "at_il_routepf", form) end local function check_advance_valid(tcbpos, rp) -- track circuit break, try to advance route over it local lri = get_last_route_item(rp.origin, rp.route) if not lri then return false, false end local is_endpoint = false local this_sigd, this_ts, adv_side if vector.equals(lri.p, tcbpos) then -- If the player just punched the last TCB again, it's of course possible to -- finish the route here (although it can't be advanced by here. -- Fun fact: you can now program routes that end exactly where they begin :) is_endpoint = true this_sigd = lri else -- else, we need to check whether this TS actually borders local start_tcbs = advtrains.interlocking.db.get_tcbs(lri) if not start_tcbs.ts_id then return false, false end this_ts = advtrains.interlocking.db.get_ts(start_tcbs.ts_id) for _,sigd in ipairs(this_ts.tc_breaks) do if vector.equals(sigd.p, tcbpos) then adv_side = otherside(sigd.s) end end if not adv_side then -- this TCB is not bordering to the section return false, false end this_sigd = {p=tcbpos, s=adv_side} end -- check whether the ts at the other end is capable of "end over" local adv_tcbs = advtrains.interlocking.db.get_tcbs(this_sigd) local next_tsid = adv_tcbs.ts_id