aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-08-24 22:39:13 +0200
committerorwell96 <orwell@bleipb.de>2018-08-24 22:39:13 +0200
commitd837e7e5e9d2d6de7903e91b3efc36e0dd032b92 (patch)
tree5dfb88b2ee30a4f674eb7517479fa4fa6b666e11 /advtrains_interlocking
parent5039c958a2bbc8e3ffa1e59522e3bc5e9b2e2872 (diff)
Add LuaAutomation interface functions for interlocking routesetting and aspect requesting.
This allows to incorporate interlocking to automated systems
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/route_prog.lua2
-rw-r--r--advtrains_interlocking/routesetting.lua7
2 files changed, 1 insertions, 8 deletions
diff --git a/advtrains_interlocking/route_prog.lua b/advtrains_interlocking/route_prog.lua
index f14ad60..0283bf5 100644
--- a/advtrains_interlocking/route_prog.lua
+++ b/advtrains_interlocking/route_prog.lua
@@ -364,5 +364,5 @@ minetest.register_chatcommand("at_rp_discard",
--TODO on route setting
--- unify luaautomation get/setstate interface to the core
-- routes should end at signals. complete route setting by punching a signal, and command as exceptional route completion
+-- Create simpler way to advance a route to the next tcb/signal on simple sections without turnouts
diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua
index 4e32b10..66f2d2b 100644
--- a/advtrains_interlocking/routesetting.lua
+++ b/advtrains_interlocking/routesetting.lua
@@ -20,13 +20,6 @@ ilrs.rte_callbacks = {
lck = {}
}
--- Requests the given route
--- This function will try to set the designated route.
--- If this is not possible, route is inserted in the subscriber list for
--- the problematic lock points
-function ilrs.request_route(signal, tcbs, routeid)
-
-end
-- main route setting. First checks if everything can be set as designated,
-- then (if "try" is not set) actually sets it
lass="hl opt">&banfilepath): m_banfilepath(banfilepath), m_modified(false) { try{ load(); } catch(SerializationError &e) { infostream<<"WARNING: BanManager: creating " <<m_banfilepath<<std::endl; } } BanManager::~BanManager() { save(); } void BanManager::load() { JMutexAutoLock lock(m_mutex); infostream<<"BanManager: loading from "<<m_banfilepath<<std::endl; std::ifstream is(m_banfilepath.c_str(), std::ios::binary); if(is.good() == false) { infostream<<"BanManager: failed loading from "<<m_banfilepath<<std::endl; throw SerializationError("BanManager::load(): Couldn't open file"); } while(!is.eof() && is.good()) { std::string line; std::getline(is, line, '\n'); Strfnd f(line); std::string ip = trim(f.next("|")); std::string name = trim(f.next("|")); if(!ip.empty()) { m_ips[ip] = name; } } m_modified = false; } void BanManager::save() { JMutexAutoLock lock(m_mutex); infostream << "BanManager: saving to " << m_banfilepath << std::endl; std::ostringstream ss(std::ios_base::binary); for (StringMap::iterator it = m_ips.begin(); it != m_ips.end(); ++it) ss << it->first << "|" << it->second << "\n"; if (!fs::safeWriteToFile(m_banfilepath, ss.str())) { infostream << "BanManager: failed saving to " << m_banfilepath << std::endl; throw SerializationError("BanManager::save(): Couldn't write file"); } m_modified = false; } bool BanManager::isIpBanned(const std::string &ip) { JMutexAutoLock lock(m_mutex); return m_ips.find(ip) != m_ips.end(); } std::string BanManager::getBanDescription(const std::string &ip_or_name) { JMutexAutoLock lock(m_mutex); std::string s = ""; for (StringMap::iterator it = m_ips.begin(); it != m_ips.end(); ++it) { if (it->first == ip_or_name || it->second == ip_or_name || ip_or_name == "") { s += it->first + "|" + it->second + ", "; } } s = s.substr(0, s.size() - 2); return s; } std::string BanManager::getBanName(const std::string &ip) { JMutexAutoLock lock(m_mutex); StringMap::iterator it = m_ips.find(ip); if (it == m_ips.end()) return ""; return it->second; } void BanManager::add(const std::string &ip, const std::string &name) { JMutexAutoLock lock(m_mutex); m_ips[ip] = name; m_modified = true; } void BanManager::remove(const std::string &ip_or_name) { JMutexAutoLock lock(m_mutex); for (StringMap::iterator it = m_ips.begin(); it != m_ips.end();) { if ((it->first == ip_or_name) || (it->second == ip_or_name)) { m_ips.erase(it++); } else { ++it; } } m_modified = true; } bool BanManager::isModified() { JMutexAutoLock lock(m_mutex); return m_modified; }