aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-08-29 21:11:27 +0200
committerorwell96 <orwell@bleipb.de>2019-08-29 21:11:27 +0200
commit986c8fcf92925f8f36ea8957270eeff829b7abf1 (patch)
tree57af461a9cd449ce6725965e0cf9fc3ec3103bb9 /advtrains_interlocking
parent7b488f40d95c2d68db898d7cb228e17e001cea73 (diff)
downloadadvtrains-986c8fcf92925f8f36ea8957270eeff829b7abf1.tar.gz
advtrains-986c8fcf92925f8f36ea8957270eeff829b7abf1.tar.bz2
advtrains-986c8fcf92925f8f36ea8957270eeff829b7abf1.zip
Do not throw error when sync_tcb_neighbors fails
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/database.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua
index 7571a2c..8df874f 100644
--- a/advtrains_interlocking/database.lua
+++ b/advtrains_interlocking/database.lua
@@ -336,7 +336,8 @@ function ildb.sync_tcb_neighbors(pos, connid)
local found_tcbs = { {p = pos, s = connid} }
local node_ok, conns, rhe = advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)
if not node_ok then
- error("update_tcb_neighbors but node is NOK: "..minetest.pos_to_string(pos))
+ atwarn("update_tcb_neighbors but node is NOK: "..minetest.pos_to_string(pos))
+ return
end
--atdebug("Traversing from ",pos, connid)
%'> -rw-r--r--advtrains_line_automation/textures/advtrains_line_automation_white_pixel.pngbin0 -> 82 bytes-rw-r--r--advtrains_line_automation/time_table.lua12
9 files changed, 759 insertions, 56 deletions
diff --git a/advtrains_line_automation/ch_functions.lua b/advtrains_line_automation/ch_functions.lua
new file mode 100644
index 0000000..0b4514f
--- /dev/null
+++ b/advtrains_line_automation/ch_functions.lua
@@ -0,0 +1,658 @@
+--advtrains_line_automation
+
+-- Functions from Cesky Hvozd utility libraries which are used in the code integrated from Singularis are now provided here.
+
+local ch_core = {}
+
+-- gives various info about a player. we return only what is relevant outside CH
+function ch_core.normalize_player(player_name_or_player)
+ local arg_type = type(player_name_or_player)
+ local player_name, player
+ if arg_type == "string" then
+ player_name = player_name_or_player
+ elseif arg_type == "number" then
+ player_name = tostring(player_name_or_player)
+ elseif (arg_type == "table" or arg_type == "userdata") and type(player_name_or_player.get_player_name) == "function" then
+ player_name = player_name_or_player:get_player_name()
+ if type(player_name) ~= "string" then
+ player_name = ""
+ else
+ if minetest.is_player(player_name_or_player) then
+ player = player_name_or_player
+ end
+ end
+ else
+ player_name = ""
+ end
+ if player_name == "" then
+ return {role = "none", player_name = "", viewname = "", privs = {}}
+ end
+ local privs = minetest.get_player_privs(player_name)
+ return {
+ role = "default",
+ player_name = player_name,
+ viewname = player_name,
+ privs = privs,
+ player = player or minetest.get_player_by_name(player_name),
+ }
+end
+
+-- == UTF8 helpers == --
+
+local utf8_charlen = {}
+for i = 1, 191, 1 do
+ -- 1 to 127 => jednobajtové znaky
+ -- 128 až 191 => nejsou dovoleny jako první bajt (=> vrátit 1 bajt)
+ utf8_charlen[i] = 1
+end
+for i = 192, 223, 1 do
+ utf8_charlen[i] = 2
+end
+for i = 224, 239, 1 do
+ utf8_charlen[i] = 3
+end
+for i = 240, 247, 1 do
+ utf8_charlen[i] = 4
+end
+for i = 248, 255, 1 do
+ utf8_charlen[i] = 1 -- neplatné UTF-8
+end
+
+local utf8_sort_data_1 = {
+ ["\x20"] = "\x20", -- < >
+ ["\x21"] = "\x21", -- <!>
+ ["\x22"] = "\x22", -- <">
+ ["\x23"] = "\x23", -- <#>
+ ["\x25"] = "\x24", -- <%>
+ ["\x26"] = "\x25", -- <&>
+ ["\x27"] = "\x26", -- <'>
+ ["\x28"] = "\x27", -- <(>
+ ["\x29"] = "\x28", -- <)>
+ ["\x2a"] = "\x29", -- <*>
+ ["\x2b"] = "\x2a", -- <+>
+ ["\x2c"] = "\x2b", -- <,>
+ ["\x2d"] = "\x2c", -- <->
+ ["\x2e"] = "\x2d", -- <.>
+ ["\x2f"] = "\x2e", -- </>
+ ["\x3a"] = "\x2f", -- <:>
+ ["\x3b"] = "\x30", -- <;>
+ ["\x3c"] = "\x31", -- <<>
+ ["\x3d"] = "\x32", -- <=>
+ ["\x3e"] = "\x33", -- <>>
+ ["\x3f"] = "\x34", -- <?>
+ ["\x40"] = "\x35", -- <@>
+ ["\x5b"] = "\x36", -- <[>
+ ["\x5c"] = "\x37", -- <\>
+ ["\x5d"] = "\x38", -- <]>
+ ["\x5e"] = "\x39", -- <^>
+ ["\x5f"] = "\x3a", -- <_>
+ ["\x60"] = "\x3b", -- <`>
+ ["\x7b"] = "\x3c", -- <{>
+ ["\x7c"] = "\x3d", -- <|>
+ ["\x7d"] = "\x3e", -- <}>
+ ["\x7e"] = "\x3f", -- <~>
+ ["\x24"] = "\x40", -- <$>
+ ["\x61"] = "\x41", -- <a>
+ ["\x41"] = "\x42", -- <A>
+ ["\x62"] = "\x47", -- <b>
+ ["\x42"] = "\x48", -- <B>
+ ["\x64"] = "\x4d", -- <d>
+ ["\x44"] = "\x4e", -- <D>
+ ["\x65"] = "\x51", -- <e>
+ ["\x45"] = "\x52", -- <E>
+ ["\x66"] = "\x57", -- <f>
+ ["\x46"] = "\x58", -- <F>
+ ["\x67"] = "\x59", -- <g>
+ ["\x47"] = "\x5a", -- <G>
+ ["\x68"] = "\x5b", -- <h>
+ ["\x48"] = "\x5c", -- <H>
+ ["\x69"] = "\x61", -- <i>
+ ["\x49"] = "\x62", -- <I>
+ ["\x6a"] = "\x65", -- <j>
+ ["\x4a"] = "\x66", -- <J>
+ ["\x6b"] = "\x67", -- <k>
+ ["\x4b"] = "\x68", -- <K>
+ ["\x6c"] = "\x69", -- <l>
+ ["\x4c"] = "\x6a", -- <L>
+ ["\x6d"] = "\x6f", -- <m>
+ ["\x4d"] = "\x70", -- <M>
+ ["\x6e"] = "\x71", -- <n>
+ ["\x4e"] = "\x72", -- <N>
+ ["\x6f"] = "\x75", -- <o>
+ ["\x4f"] = "\x76", -- <O>
+ ["\x70"] = "\x7b", -- <p>
+ ["\x50"] = "\x7c", -- <P>
+ ["\x71"] = "\x7d", -- <q>
+ ["\x51"] = "\x7e", -- <Q>
+ ["\x72"] = "\x7f", -- <r>
+ ["\x52"] = "\x80", -- <R>
+ ["\x73"] = "\x85", -- <s>
+ ["\x53"] = "\x86", -- <S>
+ ["\x74"] = "\x89", -- <t>
+ ["\x54"] = "\x8a", -- <T>
+ ["\x75"] = "\x8d", -- <u>
+ ["\x55"] = "\x8e", -- <U>
+ ["\x76"] = "\x93", -- <v>
+ ["\x56"] = "\x94", -- <V>
+ ["\x77"] = "\x95", -- <w>
+ ["\x57"] = "\x96", -- <W>
+ ["\x78"] = "\x97", -- <x>
+ ["\x58"] = "\x98", -- <X>
+ ["\x79"] = "\x99", -- <y>
+ ["\x59"] = "\x9a", -- <Y>
+ ["\x7a"] = "\x9d", -- <z>
+ ["\x5a"] = "\x9e", -- <Z>
+ ["\x30"] = "\xa1", -- <0>
+ ["\x31"] = "\xa2", -- <1>
+ ["\x32"] = "\xa3", -- <2>
+ ["\x33"] = "\xa4", -- <3>
+ ["\x34"] = "\xa5", -- <4>
+ ["\x35"] = "\xa6", -- <5>
+ ["\x36"] = "\xa7", -- <6>
+ ["\x37"] = "\xa8", -- <7>
+ ["\x38"] = "\xa9", -- <8>
+ ["\x39"] = "\xaa", -- <9>
+}
+
+local utf8_sort_data_2 = {
+ ["\xc3\xa1"] = "\x43", -- <á>
+ ["\xc3\x81"] = "\x44", -- <Á>
+ ["\xc3\xa4"] = "\x45", -- <ä>
+ ["\xc3\x84"] = "\x46", -- <Ä>
+ ["\xc4\x8d"] = "\x4b", -- <č>
+ ["\xc4\x8c"] = "\x4c", -- <Č>
+ ["\xc4\x8f"] = "\x4f", -- <ď>
+ ["\xc4\x8e"] = "\x50", -- <Ď>
+ ["\xc3\xa9"] = "\x53", -- <é>
+ ["\xc3\x89"] = "\x54", -- <É>
+ ["\xc4\x9b"] = "\x55", -- <ě>
+ ["\xc4\x9a"] = "\x56", -- <Ě>
+ ["\x63\x68"] = "\x5d", -- <ch>
+ ["\x63\x48"] = "\x5e", -- <cH>
+ ["\x43\x68"] = "\x5f", -- <Ch>
+ ["\x43\x48"] = "\x60", -- <CH>
+ ["\xc3\xad"] = "\x63", -- <í>
+ ["\xc3\x8d"] = "\x64", -- <Í>
+ ["\xc4\xba"] = "\x6b", -- <ĺ>
+ ["\xc4\xb9"] = "\x6c", -- <Ĺ>
+ ["\xc4\xbe"] = "\x6d", -- <ľ>
+ ["\xc4\xbd"] = "\x6e", -- <Ľ>
+ ["\xc5\x88"] = "\x73", -- <ň>
+ ["\xc5\x87"] = "\x74", -- <Ň>
+ ["\xc3\xb3"] = "\x77", -- <ó>
+ ["\xc3\x93"] = "\x78", -- <Ó>
+ ["\xc3\xb4"] = "\x79", -- <ô>
+ ["\xc3\x94"] = "\x7a", -- <Ô>
+ ["\xc5\x95"] = "\x81", -- <ŕ>
+ ["\xc5\x94"] = "\x82", -- <Ŕ>
+ ["\xc5\x99"] = "\x83", -- <ř>
+ ["\xc5\x98"] = "\x84", -- <Ř>
+ ["\xc5\xa1"] = "\x87", -- <š>
+ ["\xc5\xa0"] = "\x88", -- <Š>
+ ["\xc5\xa5"] = "\x8b", -- <ť>
+ ["\xc5\xa4"] = "\x8c", -- <Ť>
+ ["\xc3\xba"] = "\x8f", -- <ú>
+ ["\xc3\x9a"] = "\x90", -- <Ú>
+ ["\xc5\xaf"] = "\x91", -- <ů>
+ ["\xc5\xae"] = "\x92", -- <Ů>
+ ["\xc3\xbd"] = "\x9b", -- <ý>
+ ["\xc3\x9d"] = "\x9c", -- <Ý>
+ ["\xc5\xbe"] = "\x9f", -- <ž>
+ ["\xc5\xbd"] = "\xa0", -- <Ž>
+}
+
+local utf8_sort_data_3 = {
+ ["\x63"] = "\x49", -- <c>
+ ["\x43"] = "\x4a", -- <C>
+}
+
+--[[
+Vrátí počet UTF-8 znaků řetězce.
+]]
+function ch_core.utf8_length(s)
+ if s == "" then
+ return 0
+ end
+ local i, byte, bytes, chars
+ i = 1
+ chars = 0
+ bytes = string.len(s)
+ while i <= bytes do
+ byte = string.byte(s, i)
+ if byte < 192 then
+ i = i + 1
+ else
+ i = i + utf8_charlen[byte]
+ end
+ chars = chars + 1
+ end
+ return chars