From eab4e5bec4ac8310a7e8479dfb89fb5d3245dcab Mon Sep 17 00:00:00 2001 From: CrIcKeT Date: Sun, 28 Nov 2021 14:38:40 +0300 Subject: [PATCH 1/5] Added Windows and Linux64 --- lua/autorun/metrostroi.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lua/autorun/metrostroi.lua b/lua/autorun/metrostroi.lua index 1995bdc..8d5e346 100644 --- a/lua/autorun/metrostroi.lua +++ b/lua/autorun/metrostroi.lua @@ -339,7 +339,9 @@ end if SERVER then local OSes = { Windows = "win32", + Windows64 = "win64", Linux = "linux", + Linux64 = "linux64", BSD = "linux", POSIX = "linux", OSX = "osx", @@ -360,8 +362,18 @@ if SERVER then else print("Metrostroi: Turbostroi library loaded successfuly.") end - elseif jit.arch ~= "x86" then - ErrorNoHalt("Metrostroi: Unsupported architecture "..jit.arch..".\nTurbostroi works only on x86(32 bit) version of server\n") + elseif jit.arch == "x64" and OSes[jit.os.."64"] and file.Exists(Format("lua/bin/gmsv_turbostroi_%s.dll",OSes[jit.os.."64"]), "GAME") then + if not pcall(require,"turbostroi") then + if system.IsWindows() then + ErrorNoHalt("======================================================\nMetrostroi: Turbostroi library can't be loaded because of missing libraries!\nCheck, that you have Microsoft visual c++ 2010 and 2017 redistributable(x64) installed\nYou can download it from:\n") + MsgC(Color(255,0,0),"https://www.microsoft.com/en-us/download/details.aspx?id=5555\nhttps://aka.ms/vs/15/release/vc_redist.x64.exe\n") + ErrorNoHalt("======================================================\n") + else + ErrorNoHalt("Metrostroi: Turbostroi library can't be loaded!\n") + end + else + print("Metrostroi: Turbostroi library loaded successfuly.") + end elseif system.IsWindows() then ErrorNoHalt("======================================================\nMetrostroi: Turbostroi DLL not found.\nYou can found turbostroi for Windows at \n") MsgC(Color(255,0,0),"https://metrostroi.net/turbostroi\n") From cf963920218f3fc58d9156e99d9f6f6205a24e84 Mon Sep 17 00:00:00 2001 From: CrIcKeT Date: Sun, 28 Nov 2021 14:57:33 +0300 Subject: [PATCH 2/5] Added Win64 & Linux, Linux64 --- lua/metrostroi/sv_turbostroi_railnetwork.lua | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lua/metrostroi/sv_turbostroi_railnetwork.lua b/lua/metrostroi/sv_turbostroi_railnetwork.lua index 08d02a7..e586b1e 100644 --- a/lua/metrostroi/sv_turbostroi_railnetwork.lua +++ b/lua/metrostroi/sv_turbostroi_railnetwork.lua @@ -12,7 +12,26 @@ end print("[!] RailNetwork initialized!") -- NEW API local ffi = require("ffi") -local C = ffi.load("gmsv_turbostroi_win32") +local OSName = "gmsv_turbostroi_" + +if jis.os == "Windows" then + OSName = OSName.."win" + if jit.arch == "x86" + OSName = OSName.."86" + else + OSName = OSName.."64" + end +elseif jit.os == "Linux" then + OSName = OSName.."linux" + if jit.arch == "x86" + OSName = OSName.."86" + else + OSName = OSName.."64" + end +end + +local C = ffi.load(OSName) + ffi.cdef[[ bool RnThreadSendMessage(int ent_id, int id, const char* name, double value); ]] From fe07119585fd4bf378f8f0b551cc3ad7f1ce9c5f Mon Sep 17 00:00:00 2001 From: CrIcKeT Date: Sun, 28 Nov 2021 14:58:57 +0300 Subject: [PATCH 3/5] Added Win64 & Linux, Linux64 --- lua/metrostroi/sv_turbostroi_v2.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lua/metrostroi/sv_turbostroi_v2.lua b/lua/metrostroi/sv_turbostroi_v2.lua index 1edc9ec..b23398c 100644 --- a/lua/metrostroi/sv_turbostroi_v2.lua +++ b/lua/metrostroi/sv_turbostroi_v2.lua @@ -214,7 +214,26 @@ typedef struct { } thread_msg; thread_msg ThreadRecvMessage(void* p); ]] -local TS = ffi.load("gmsv_turbostroi_win32") + +local OSName = "gmsv_turbostroi_" + +if jis.os == "Windows" then + OSName = OSName.."win" + if jit.arch == "x86" + OSName = OSName.."86" + else + OSName = OSName.."64" + end +elseif jit.os == "Linux" then + OSName = OSName.."linux" + if jit.arch == "x86" + OSName = OSName.."86" + else + OSName = OSName.."64" + end +end + +local TS = ffi.load(OSName) Metrostroi = {} local dataCache = {wires = {},wiresW = {},wiresL = {}} From 94cc16a8e4ebd3896cb45296696437601d8cf5a6 Mon Sep 17 00:00:00 2001 From: CrIcKeT Date: Tue, 28 Dec 2021 18:57:00 +0300 Subject: [PATCH 4/5] Minor fixs --- lua/metrostroi/sv_turbostroi_railnetwork.lua | 6 +++--- lua/metrostroi/sv_turbostroi_v2.lua | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/metrostroi/sv_turbostroi_railnetwork.lua b/lua/metrostroi/sv_turbostroi_railnetwork.lua index e586b1e..ab19211 100644 --- a/lua/metrostroi/sv_turbostroi_railnetwork.lua +++ b/lua/metrostroi/sv_turbostroi_railnetwork.lua @@ -14,17 +14,17 @@ print("[!] RailNetwork initialized!") local ffi = require("ffi") local OSName = "gmsv_turbostroi_" -if jis.os == "Windows" then +if jit.os == "Windows" then OSName = OSName.."win" if jit.arch == "x86" - OSName = OSName.."86" + OSName = OSName.."32" else OSName = OSName.."64" end elseif jit.os == "Linux" then OSName = OSName.."linux" if jit.arch == "x86" - OSName = OSName.."86" + OSName = OSName.."32" else OSName = OSName.."64" end diff --git a/lua/metrostroi/sv_turbostroi_v2.lua b/lua/metrostroi/sv_turbostroi_v2.lua index b23398c..b2205ce 100644 --- a/lua/metrostroi/sv_turbostroi_v2.lua +++ b/lua/metrostroi/sv_turbostroi_v2.lua @@ -220,14 +220,14 @@ local OSName = "gmsv_turbostroi_" if jis.os == "Windows" then OSName = OSName.."win" if jit.arch == "x86" - OSName = OSName.."86" + OSName = OSName.."32" else OSName = OSName.."64" end elseif jit.os == "Linux" then OSName = OSName.."linux" if jit.arch == "x86" - OSName = OSName.."86" + OSName = OSName.."32" else OSName = OSName.."64" end From 1900e281386a9168c9ec50e8cc1756eabb0a2c8e Mon Sep 17 00:00:00 2001 From: CrIcKeT Date: Tue, 28 Dec 2021 19:21:02 +0300 Subject: [PATCH 5/5] Ultra super best code --- lua/metrostroi/sv_turbostroi_railnetwork.lua | 18 +++++++----------- lua/metrostroi/sv_turbostroi_v2.lua | 17 +++++++---------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/lua/metrostroi/sv_turbostroi_railnetwork.lua b/lua/metrostroi/sv_turbostroi_railnetwork.lua index ab19211..69e23e0 100644 --- a/lua/metrostroi/sv_turbostroi_railnetwork.lua +++ b/lua/metrostroi/sv_turbostroi_railnetwork.lua @@ -14,20 +14,16 @@ print("[!] RailNetwork initialized!") local ffi = require("ffi") local OSName = "gmsv_turbostroi_" -if jit.os == "Windows" then +if jis.os == "Windows" then OSName = OSName.."win" - if jit.arch == "x86" - OSName = OSName.."32" - else - OSName = OSName.."64" - end elseif jit.os == "Linux" then OSName = OSName.."linux" - if jit.arch == "x86" - OSName = OSName.."32" - else - OSName = OSName.."64" - end +end + +if jit.arch == "x86" + OSName = OSName.."32" +else + OSName = OSName.."64" end local C = ffi.load(OSName) diff --git a/lua/metrostroi/sv_turbostroi_v2.lua b/lua/metrostroi/sv_turbostroi_v2.lua index b2205ce..0322076 100644 --- a/lua/metrostroi/sv_turbostroi_v2.lua +++ b/lua/metrostroi/sv_turbostroi_v2.lua @@ -219,20 +219,17 @@ local OSName = "gmsv_turbostroi_" if jis.os == "Windows" then OSName = OSName.."win" - if jit.arch == "x86" - OSName = OSName.."32" - else - OSName = OSName.."64" - end elseif jit.os == "Linux" then OSName = OSName.."linux" - if jit.arch == "x86" - OSName = OSName.."32" - else - OSName = OSName.."64" - end end +if jit.arch == "x86" + OSName = OSName.."32" +else + OSName = OSName.."64" +end + + local TS = ffi.load(OSName) Metrostroi = {}