network: creating user's RPCs dictionary
This commit is contained in:
parent
ff7767bfac
commit
1476d4dfe4
2 changed files with 35 additions and 1 deletions
|
@ -2,6 +2,12 @@ local vmf = get_mod("VMF")
|
||||||
|
|
||||||
local _RPC_CALLBACKS = {}
|
local _RPC_CALLBACKS = {}
|
||||||
|
|
||||||
|
local _LOCAL_MODS_MAP = {}
|
||||||
|
local _LOCAL_RPCS_MAP = {}
|
||||||
|
|
||||||
|
local _SHARED_MODS_MAP = {}
|
||||||
|
local _SHARED_RPCS_MAP = {}
|
||||||
|
|
||||||
VMFMod.rpc_register = function (self, rpc_name, rpc_function)
|
VMFMod.rpc_register = function (self, rpc_name, rpc_function)
|
||||||
|
|
||||||
if type(rpc_name) ~= "string" then
|
if type(rpc_name) ~= "string" then
|
||||||
|
@ -18,3 +24,30 @@ VMFMod.rpc_register = function (self, rpc_name, rpc_function)
|
||||||
|
|
||||||
_RPC_CALLBACKS[self:get_name()][rpc_name] = rpc_function
|
_RPC_CALLBACKS[self:get_name()][rpc_name] = rpc_function
|
||||||
end
|
end
|
||||||
|
|
||||||
|
vmf.create_network_dictionary = function()
|
||||||
|
|
||||||
|
local i = 0
|
||||||
|
for mod_name, mod_rpcs in pairs(_RPC_CALLBACKS) do
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
|
||||||
|
_SHARED_MODS_MAP[mod_name] = i
|
||||||
|
_LOCAL_MODS_MAP[i] = mod_name
|
||||||
|
|
||||||
|
_SHARED_RPCS_MAP[mod_name] = {}
|
||||||
|
_LOCAL_RPCS_MAP[i] = {}
|
||||||
|
|
||||||
|
local j = 0
|
||||||
|
for rpc_name, _ in pairs(mod_rpcs) do
|
||||||
|
|
||||||
|
j = j + 1
|
||||||
|
|
||||||
|
_SHARED_RPCS_MAP[mod_name][rpc_name] = j
|
||||||
|
_LOCAL_RPCS_MAP[i][j] = rpc_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
_SHARED_MODS_MAP = cjson.encode(_SHARED_MODS_MAP)
|
||||||
|
_SHARED_RPCS_MAP = cjson.encode(_SHARED_RPCS_MAP)
|
||||||
|
end
|
||||||
|
|
|
@ -40,6 +40,7 @@ return {
|
||||||
|
|
||||||
object.vmf.initialize_keybinds()
|
object.vmf.initialize_keybinds()
|
||||||
object.vmf.initialize_vmf_options_view()
|
object.vmf.initialize_vmf_options_view()
|
||||||
|
object.vmf.create_network_dictionary()
|
||||||
|
|
||||||
object.vmf.all_mods_were_loaded = true
|
object.vmf.all_mods_were_loaded = true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue