-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,942 additions
and
66 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,71 @@ | ||
if not GRPC then | ||
GRPC = { | ||
-- scaffold nested tables to allow direct assignment in config file | ||
tts = { provider = { gcloud = {}, aws = {}, azure = {}, win = {} } }, | ||
srs = {}, | ||
auth = { tokens = {} } | ||
} | ||
GRPC = { | ||
-- scaffold nested tables to allow direct assignment in config file | ||
tts = { provider = { gcloud = {}, aws = {}, azure = {}, win = {}, parler = {} } }, | ||
srs = {}, | ||
auth = { tokens = {} } | ||
} | ||
end | ||
|
||
-- load settings from `Saved Games/DCS/Config/dcs-grpc.lua` | ||
do | ||
env.info("[GRPC] Checking optional config at `Config/dcs-grpc.lua` ...") | ||
local file, err = io.open(lfs.writedir() .. [[Config\dcs-grpc.lua]], "r") | ||
if file then | ||
local f = assert(loadstring(file:read("*all"))) | ||
setfenv(f, GRPC) | ||
f() | ||
env.info("[GRPC] `Config/dcs-grpc.lua` successfully read") | ||
else | ||
env.info("[GRPC] `Config/dcs-grpc.lua` not found (" .. tostring(err) .. ")") | ||
end | ||
env.info("[GRPC] Checking optional config at `Config/dcs-grpc.lua` ...") | ||
local file, err = io.open(lfs.writedir() .. [[Config\dcs-grpc.lua]], "r") | ||
if file then | ||
local f = assert(loadstring(file:read("*all"))) | ||
setfenv(f, GRPC) | ||
f() | ||
env.info("[GRPC] `Config/dcs-grpc.lua` successfully read") | ||
else | ||
env.info("[GRPC] `Config/dcs-grpc.lua` not found (" .. tostring(err) .. ")") | ||
end | ||
end | ||
|
||
-- Set default settings. | ||
if not GRPC.luaPath then | ||
GRPC.luaPath = lfs.writedir() .. [[Scripts\DCS-gRPC\]] | ||
GRPC.luaPath = lfs.writedir() .. [[Scripts\DCS-gRPC\]] | ||
end | ||
if not GRPC.dllPath then | ||
GRPC.dllPath = lfs.writedir() .. [[Mods\tech\DCS-gRPC\]] | ||
GRPC.dllPath = lfs.writedir() .. [[Mods\tech\DCS-gRPC\]] | ||
end | ||
if GRPC.throughputLimit == nil or GRPC.throughputLimit == 0 or type(GRPC.throughputLimit) ~= "number" then | ||
GRPC.throughputLimit = 600 | ||
GRPC.throughputLimit = 600 | ||
end | ||
|
||
-- load version | ||
dofile(GRPC.luaPath .. [[version.lua]]) | ||
|
||
-- Let DCS know where to find the DLLs | ||
if not string.find(package.cpath, GRPC.dllPath) then | ||
package.cpath = package.cpath .. [[;]] .. GRPC.dllPath .. [[?.dll;]] | ||
package.cpath = package.cpath .. [[;]] .. GRPC.dllPath .. [[?.dll;]] | ||
end | ||
|
||
-- Load DLL before `require` gets sanitized. | ||
local ok, grpc = pcall(require, "dcs_grpc_hot_reload") | ||
if ok then | ||
env.info("[GRPC] loaded hot reload version") | ||
env.info("[GRPC] loaded hot reload version") | ||
else | ||
grpc = require("dcs_grpc") | ||
grpc = require("dcs_grpc") | ||
end | ||
|
||
-- Keep a reference to `lfs` before it gets sanitized | ||
local lfs = _G.lfs | ||
|
||
local loaded = false | ||
function GRPC.load() | ||
if loaded then | ||
env.info("[GRPC] already loaded") | ||
return | ||
end | ||
if loaded then | ||
env.info("[GRPC] already loaded") | ||
return | ||
end | ||
|
||
local env = setmetatable({grpc = grpc, lfs = lfs}, {__index = _G}) | ||
local f = setfenv(assert(loadfile(GRPC.luaPath .. [[grpc.lua]])), env) | ||
f() | ||
local env = setmetatable({ grpc = grpc, lfs = lfs }, { __index = _G }) | ||
local f = setfenv(assert(loadfile(GRPC.luaPath .. [[grpc.lua]])), env) | ||
f() | ||
|
||
loaded = true | ||
loaded = true | ||
end | ||
|
||
if GRPC.autostart == true then | ||
env.info("[GRPC] auto starting") | ||
GRPC.load() | ||
env.info("[GRPC] auto starting") | ||
GRPC.load() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.