~gpcf/advtrains-devel

[PATCH v5] De-hardcode the speed limit of 20 m/s

Details
Message ID
<56092B49-CB9C-4000-BA5F-CFB837074EF8@1f616emo.xyz>
DKIM signature
pass
Download raw message
About Ks speed indicators: I’ve not yet investigated backward compatibility problems of them, so I left them as is until I have time to check.

> Y. Wang <y5nw@protonmail.com>於2024年10月22日 20:02寫道:
> 
> (Code review only. I have not tested this myself, but I assume it works
> given that you seem to have this patch applied on your server.)
> 
>> diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
>> index f9f4876..731ad6d 100644
>> --- a/advtrains/trainhud.lua
>> +++ b/advtrains/trainhud.lua
> 
> The HUD definitely needs another rework even at its current state
> (without dehardcoding the speed limit). I am not sure whether it should
> be done now or after this patch.
> 
>> diff --git a/advtrains_signals_ks/init.lua b/advtrains_signals_ks/init.lua
>> index 258b868..d614069 100755
>> --- a/advtrains_signals_ks/init.lua
>> +++ b/advtrains_signals_ks/init.lua
>> @@ -306,11 +306,17 @@ for _, rtab in ipairs({
>>     for typ, prts in pairs {
>>         -- Speed restrictions:
>> -        ["4"] = {asp = { main = 4, shunt = true }, n = "6"},
>> -        ["6"] = {asp = { main = 6, shunt = true }, n = "8"},
>> -        ["8"] = {asp = { main = 8, shunt = true }, n = "12"},
>> -        ["12"] = {asp = { main = 12, shunt = true }, n = "16"},
>> -        ["16"] = {asp = { main = 16, shunt = true }, n = "e"},
>> +        ["4"]  = {asp = { main =  4, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 6 and "6" or "e"},
>> +        ["6"]  = {asp = { main =  6, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 8 and "8" or "e"},
>> +        ["8"]  = {asp = { main =  8, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 12 and "12" or "e"},
>> +        ["12"] = {asp = { main = 12, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 16 and "16" or "e"},
>> +        ["16"] = {asp = { main = 16, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 20 and "20" or "e"},
>> +        ["20"] = {asp = { main = 20, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 24 and "24" or "e"},
>> +        ["24"] = {asp = { main = 24, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 28 and "28" or "e"},
>> +        ["28"] = {asp = { main = 28, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 30 and "30" or "e"},
>> +        ["30"] = {asp = { main = 30, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 32 and "32" or "e"},
>> +        ["32"] = {asp = { main = 32, shunt = true }, n = advtrains.TRAIN_MAX_SPEED >= 36 and "36" or "e"},
>> +        ["36"] = {asp = { main = 36, shunt = true }, n = "e"},
>>         -- Speed restriction lifted
>>         ["e"] = {asp = { main = -1, shunt = true }, n = "4", mesh = "_zs10"},
>>     } do
> 
> IMO we should change this to a use a list instead:
> for _, speed in ipairs {4, 6, 8, ..., 36, -1} do
>  local typ = speed == "-1" and "e" or ("%d"):format(speed)
>  local ptrs = {asp = ..., n = ...} -- or drop the ptrs table entirely
>  ...
> end
> 
> Also: is it intended that the speed indicators mounted onto Ks signals
> do not have speeds above 20m/s?
Reply to thread Export thread (mbox)