1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

Merge pull request #395 from metrostroi-repo/#103

#103
This commit is contained in:
HellReach
2021-12-28 20:23:40 +03:00
committed by GitHub
3 changed files with 47 additions and 4 deletions

View File

@@ -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")

View File

@@ -12,7 +12,22 @@ 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"
elseif jit.os == "Linux" then
OSName = OSName.."linux"
end
if jit.arch == "x86"
OSName = OSName.."32"
else
OSName = OSName.."64"
end
local C = ffi.load(OSName)
ffi.cdef[[
bool RnThreadSendMessage(int ent_id, int id, const char* name, double value);
]]

View File

@@ -214,7 +214,23 @@ 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"
elseif jit.os == "Linux" then
OSName = OSName.."linux"
end
if jit.arch == "x86"
OSName = OSName.."32"
else
OSName = OSName.."64"
end
local TS = ffi.load(OSName)
Metrostroi = {}
local dataCache = {wires = {},wiresW = {},wiresL = {}}