Reworked some stuff for MP
This commit is contained in:
54
media/lua/server/TOC/ServerDataCommands.lua
Normal file
54
media/lua/server/TOC/ServerDataCommands.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
-- TODO Switch EVERYTHING to global mod data
|
||||
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
|
||||
local ServerDataCommands = {}
|
||||
local moduleName = "test_sync"
|
||||
|
||||
|
||||
local function PrintModDataTable(key, table)
|
||||
print("Received key: " .. key)
|
||||
end
|
||||
|
||||
|
||||
Events.OnReceiveGlobalModData.Add(PrintModDataTable)
|
||||
|
||||
|
||||
|
||||
-- TODO Consider delays
|
||||
|
||||
|
||||
|
||||
|
||||
-- TODO Use transmit from client
|
||||
-- ---comment
|
||||
-- ---@param playerObj IsoPlayer
|
||||
-- ---@param args any
|
||||
-- function ServerDataCommands.AddTable(playerObj, args)
|
||||
-- ModData.add(GetKey(playerObj), args.tocData)
|
||||
-- end
|
||||
|
||||
|
||||
-- function ServerDataCommands.GetTable(playerObj, args)
|
||||
-- local requestedPlayer = getSpecificPlayer(args.playerNum)
|
||||
-- local data = ModData.get(CommandsData.GetKey(requestedPlayer))
|
||||
|
||||
-- -- TODO Request from that client again just to be sure that it's synced?
|
||||
|
||||
-- sendServerCommand()
|
||||
-- end
|
||||
|
||||
|
||||
|
||||
------------------------------
|
||||
|
||||
-- local function OnClientDataCommand(module, command, playerObj, args)
|
||||
-- if module == moduleName and ServerDataCommands[command] then
|
||||
-- ServerDataCommands[command](playerObj, args)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- Events.OnClientCommand.Add(OnClientDataCommand)
|
||||
|
||||
|
||||
|
||||
@@ -10,20 +10,25 @@ local moduleName = CommandsData.modules.TOC_SYNC
|
||||
|
||||
---A client has asked the server to ask another client to send its toc mod data
|
||||
---@param surgeonPl IsoPlayer
|
||||
---@param args {patientNum : number}
|
||||
---@param args askPlayerDataParams
|
||||
function ServerSyncCommands.AskPlayerData(surgeonPl, args)
|
||||
local patientPl = getSpecificPlayer(args.patientNum)
|
||||
local surgeonNum = surgeonPl:getOnlineID()
|
||||
sendServerCommand(patientPl, moduleName, CommandsData.client.Sync.SendPlayerData, {surgeonNum = surgeonNum})
|
||||
|
||||
---@type sendPlayerDataParams
|
||||
local params = {surgeonNum = surgeonPl:getOnlineID()}
|
||||
sendServerCommand(patientPl, moduleName, CommandsData.client.Sync.SendPlayerData, params)
|
||||
end
|
||||
|
||||
---Relay the toc mod data from a certain player to another one
|
||||
---@param patientPl IsoPlayer
|
||||
---@param args {surgeonNum : number, tocData : tocModData}
|
||||
---@param args relayPlayerDataParams
|
||||
function ServerSyncCommands.RelayPlayerData(patientPl, args)
|
||||
local surgeonPl = getSpecificPlayer(args.surgeonNum)
|
||||
local patientNum = patientPl:getOnlineID()
|
||||
sendServerCommand(surgeonPl, moduleName, CommandsData.client.Sync.ReceivePlayerData, {patientNum = patientNum, tocData = args.tocData})
|
||||
|
||||
---@type receivePlayerDataParams
|
||||
local params = {patientNum = patientNum, tocData = args.tocData}
|
||||
sendServerCommand(surgeonPl, moduleName, CommandsData.client.Sync.ReceivePlayerData, params)
|
||||
end
|
||||
|
||||
------------------------------
|
||||
|
||||
Reference in New Issue
Block a user