Too much stuff to fix.
This commit is contained in:
@@ -30,6 +30,14 @@ function ClientRelayCommands.ReceiveExecuteAmputationAction(args)
|
||||
end
|
||||
|
||||
|
||||
--* APPLY RELAY *--
|
||||
|
||||
function ClientRelayCommands.ReceiveApplyFromServer()
|
||||
TOC_DEBUG.print("Received forced re-apply from server")
|
||||
local key = CommandsData.GetKey(getPlayer():getUsername())
|
||||
ModData.request(key)
|
||||
end
|
||||
|
||||
|
||||
--* TRIGGERED BY ADMINS *--
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ function DataController:setup(key)
|
||||
end
|
||||
|
||||
-- Initialize prostheses stuff
|
||||
for i=1, #StaticData.PROSTHESES_GROUPS_STR do
|
||||
local group = StaticData.PROSTHESES_GROUPS_STR[i]
|
||||
for i=1, #StaticData.AMP_GROUPS_STR do
|
||||
local group = StaticData.AMP_GROUPS_STR[i]
|
||||
self.tocData.prostheses[group] = {
|
||||
isProstEquipped = false,
|
||||
prostFactor = 0,
|
||||
@@ -103,7 +103,7 @@ end
|
||||
function DataController:loadLocalData(key)
|
||||
self.tocData = ModData.get(key)
|
||||
|
||||
TOC_DEBUG.printTable(self.tocData)
|
||||
--TOC_DEBUG.printTable(self.tocData)
|
||||
|
||||
if self.tocData and self.tocData.limbs then
|
||||
TOC_DEBUG.print("Found and loaded local data")
|
||||
@@ -345,13 +345,19 @@ end
|
||||
--* Global Mod Data Handling *--
|
||||
|
||||
function DataController:apply()
|
||||
TOC_DEBUG.print("Applying data for " .. self.username)
|
||||
ModData.transmit(CommandsData.GetKey(self.username))
|
||||
|
||||
-- if getPlayer():getUsername() ~= self.username then
|
||||
-- sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayApplyFromOtherClient, {patientUsername = self.username} )
|
||||
-- -- force request from the server for that other client...
|
||||
-- end
|
||||
end
|
||||
|
||||
|
||||
---Online only, Global Mod Data doesn't trigger this in SP
|
||||
---@param key any
|
||||
---@param data any
|
||||
---@param key string
|
||||
---@param data tocModDataType
|
||||
function DataController.ReceiveData(key, data)
|
||||
-- During startup the game can return Bob as the player username, adding a useless ModData table
|
||||
if key == "TOC_Bob" then return end
|
||||
@@ -370,25 +376,47 @@ function DataController.ReceiveData(key, data)
|
||||
-- so for now, I'm gonna assume that the local data (for the local client) is the
|
||||
-- most recent (and correct) one instead of trying to fetch it from the server every single time
|
||||
|
||||
if username == getPlayer():getUsername() and not handler.isResetForced then
|
||||
handler:loadLocalData(key)
|
||||
elseif handler.isResetForced or data == nil then
|
||||
TOC_DEBUG.print("Data is nil or empty!?")
|
||||
TOC_DEBUG.printTable(data)
|
||||
|
||||
-- TODO Add update from server scenario
|
||||
|
||||
if handler.isResetForced then
|
||||
handler:setup(key)
|
||||
elseif data and data.limbs then
|
||||
handler:applyOnlineData(data)
|
||||
elseif data then
|
||||
if data.isUpdateFromServer then
|
||||
TOC_DEBUG.print("Update from the server")
|
||||
end
|
||||
handler:applyOnlineData(data)
|
||||
elseif username == getPlayer():getUsername() then
|
||||
handler:loadLocalData(key)
|
||||
end
|
||||
|
||||
|
||||
handler:setIsResetForced(false)
|
||||
handler:setIsDataReady(true)
|
||||
|
||||
-- Event, triggers caching
|
||||
triggerEvent("OnReceivedTocData", handler.username)
|
||||
|
||||
|
||||
|
||||
-- if username == getPlayer():getUsername() and not handler.isResetForced then
|
||||
-- handler:loadLocalData(key)
|
||||
-- elseif handler.isResetForced or data == nil then
|
||||
-- TOC_DEBUG.print("Data is nil or empty!?")
|
||||
-- TOC_DEBUG.printTable(data)
|
||||
-- handler:setup(key)
|
||||
-- elseif data and data.limbs then
|
||||
-- handler:applyOnlineData(data)
|
||||
-- end
|
||||
|
||||
-- handler:setIsResetForced(false)
|
||||
-- handler:setIsDataReady(true)
|
||||
|
||||
-- -- Event, triggers caching
|
||||
-- triggerEvent("OnReceivedTocData", handler.username)
|
||||
|
||||
-- Transmit it back to the server
|
||||
ModData.transmit(key)
|
||||
TOC_DEBUG.print("Transmitting data after receiving it for: " .. handler.username)
|
||||
--ModData.transmit(key)
|
||||
--TOC_DEBUG.print("Transmitting data after receiving it for: " .. handler.username)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -22,8 +22,12 @@ end
|
||||
---Will calculate all the values that we need
|
||||
function CachedDataHandler.CalculateCacheableValues(username)
|
||||
CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
||||
|
||||
-- FIX This should be run ONLY on the actual client, never on other clients. Just a placeholder fix for now
|
||||
if getPlayer():getUsername() == username then
|
||||
CachedDataHandler.CalculateBothHandsFeasibility()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ function CleanWoundAction:new(doctor, otherPlayer, bandage, bodyPart)
|
||||
o.bandage = bandage
|
||||
o.stopOnWalk = true
|
||||
o.stopOnRun = true
|
||||
|
||||
o.bandagedPlayerX = otherPlayer:getX()
|
||||
o.bandagedPlayerY = otherPlayer:getY()
|
||||
|
||||
o.maxTime = 250 - (o.doctorLevel * 6)
|
||||
if doctor:isTimedActionInstant() then
|
||||
o.maxTime = 1
|
||||
@@ -79,8 +81,8 @@ function CleanWoundAction:stop()
|
||||
end
|
||||
|
||||
function CleanWoundAction:perform()
|
||||
-- needed to remove from queue / start next.
|
||||
ISBaseTimedAction.perform(self)
|
||||
|
||||
TOC_DEBUG.print("CleanWound for " .. self.otherPlayer:getUsername())
|
||||
|
||||
if self.character:HasTrait("Hemophobic") then
|
||||
self.character:getStats():setPanic(self.character:getStats():getPanic() + 15)
|
||||
@@ -113,6 +115,9 @@ function CleanWoundAction:perform()
|
||||
visual:setBlood(bbptEnum, 0)
|
||||
|
||||
ISHealthPanel.setBodyPartActionForPlayer(self.otherPlayer, self.bodyPart, nil, nil, nil)
|
||||
|
||||
-- needed to remove from queue / start next.
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
return CleanWoundAction
|
||||
@@ -7,6 +7,8 @@ local CommandsData = require("TOC/CommandsData")
|
||||
---@class CutLimbAction : ISBaseTimedAction
|
||||
---@field patient IsoPlayer
|
||||
---@field character IsoPlayer
|
||||
---@field patientX number
|
||||
---@field patientY number
|
||||
---@field limbName string
|
||||
---@field item InventoryItem
|
||||
---@field stitchesItem InventoryItem?
|
||||
@@ -32,6 +34,9 @@ function CutLimbAction:new(surgeon, patient, limbName, item, stitchesItem, banda
|
||||
o.limbName = limbName
|
||||
o.item = item
|
||||
|
||||
o.patientX = patient:getX()
|
||||
o.patientY = patient:getY()
|
||||
|
||||
o.stitchesItem = stitchesItem or nil
|
||||
o.bandageItem = bandageItem or nil
|
||||
|
||||
@@ -45,7 +50,7 @@ function CutLimbAction:new(surgeon, patient, limbName, item, stitchesItem, banda
|
||||
end
|
||||
|
||||
function CutLimbAction:isValid()
|
||||
return not ISHealthPanel.DidPatientMove(self.patient, self.character, self.patient:getX(), self.patient:getY())
|
||||
return not ISHealthPanel.DidPatientMove(self.character,self.patient, self.patientX, self.patientY)
|
||||
end
|
||||
|
||||
function CutLimbAction:start()
|
||||
|
||||
@@ -133,13 +133,15 @@ function ISHealthPanel:update()
|
||||
og_ISHealthPanel_update(self)
|
||||
-- TODO Listen for changes on other player side instead of looping this
|
||||
|
||||
|
||||
-- FIX Re-enable it, just for test
|
||||
if self.character then
|
||||
local locPlUsername = getPlayer():getUsername()
|
||||
local remPlUsername = self.character:getUsername()
|
||||
if locPlUsername ~= remPlUsername and self:isReallyVisible() then
|
||||
-- Request update for TOC DATA?
|
||||
-- Request update for TOC DATA
|
||||
local key = CommandsData.GetKey(remPlUsername)
|
||||
ModData.request(key)
|
||||
--ModData.request(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -208,7 +208,8 @@ end
|
||||
function CutLimbInteractionHandler:addToMenu(context)
|
||||
--TOC_DEBUG.print("CutLimbInteractionHandler addToMenu")
|
||||
local types = self:getAllItemTypes(self.items.ITEMS)
|
||||
if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance():getIsCut(self.limbName) then
|
||||
local patientUsername = self:getPatient():getUsername()
|
||||
if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance(patientUsername):getIsCut(self.limbName) then
|
||||
TOC_DEBUG.print("addToMenu, types > 0")
|
||||
for i=1, #types do
|
||||
context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected, types[i])
|
||||
@@ -230,7 +231,8 @@ end
|
||||
function CutLimbInteractionHandler:isValid()
|
||||
--TOC_DEBUG.print("CutLimbInteractionHandler isValid")
|
||||
self:checkItems()
|
||||
return not DataController.GetInstance():getIsCut(self.limbName)
|
||||
local patientUsername = self:getPatient():getUsername()
|
||||
return not DataController.GetInstance(patientUsername):getIsCut(self.limbName)
|
||||
end
|
||||
|
||||
function CutLimbInteractionHandler:perform(previousAction, itemType)
|
||||
|
||||
@@ -126,10 +126,12 @@ function BaseHandler:toPlayerInventory(item, previousAction)
|
||||
return previousAction
|
||||
end
|
||||
|
||||
---@return IsoPlayer
|
||||
function BaseHandler:getDoctor()
|
||||
return self.panel.otherPlayer or self.panel.character
|
||||
end
|
||||
|
||||
---@return IsoPlayer
|
||||
function BaseHandler:getPatient()
|
||||
return self.panel.character
|
||||
end
|
||||
|
||||
@@ -35,6 +35,7 @@ end
|
||||
|
||||
function WoundCleaningInteractionHandler:addToMenu(context)
|
||||
--TOC_DEBUG.print("WoundCleaningInteraction addToMenu")
|
||||
|
||||
local types = self:getAllItemTypes(self.items.ITEMS)
|
||||
if #types > 0 and self:isValid() then
|
||||
TOC_DEBUG.print("WoundCleaningInteraction inside addToMenu")
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
if isClient() then return end -- The event makes this necessary to prevent clients from running this file
|
||||
local StaticData = require("TOC/StaticData")
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local ServerDataHandler = {}
|
||||
ServerDataHandler.modData = {}
|
||||
|
||||
@@ -21,10 +26,36 @@ function ServerDataHandler.AddTable(key, table)
|
||||
if not luautils.stringStarts(key, StaticData.MOD_NAME .. "_") then return end
|
||||
|
||||
TOC_DEBUG.print("Received TOC ModData: " .. tostring(key))
|
||||
TOC_DEBUG.printTable(table)
|
||||
--TOC_DEBUG.printTable(table)
|
||||
|
||||
-- Set that the data has been modified and it's updated on the server
|
||||
table.isUpdateFromServer = true
|
||||
|
||||
ModData.add(key, table) -- Add it to the server mod data
|
||||
ServerDataHandler.modData[key] = table
|
||||
|
||||
|
||||
-- Since this could be triggered by a different client than the one referenced in the key, we're gonna
|
||||
-- apply the changes back to the key client again to be sure that everything is in sync
|
||||
local username = CommandsData.GetUsername(key)
|
||||
TOC_DEBUG.print("Reapplying to " .. username)
|
||||
|
||||
-- Since getPlayerFromUsername doesn't work in mp, we're gonna do this workaround. ew
|
||||
local onlinePlayers = getOnlinePlayers()
|
||||
local selectedPlayer
|
||||
for i=0, onlinePlayers:size() - 1 do
|
||||
|
||||
---@type IsoPlayer
|
||||
local player = onlinePlayers:get(i)
|
||||
if player:getUsername() == username then
|
||||
selectedPlayer = player
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
TOC_DEBUG.print("Player username from IsoPlayer: " .. selectedPlayer:getUsername())
|
||||
sendServerCommand(selectedPlayer, CommandsData.modules.TOC_RELAY, CommandsData.client.Relay.ReceiveApplyFromServer, {})
|
||||
|
||||
end
|
||||
|
||||
Events.OnReceiveGlobalModData.Add(ServerDataHandler.AddTable)
|
||||
|
||||
@@ -28,7 +28,6 @@ function ServerRelayCommands.RelayExecuteAmputationAction(surgeonPl, args)
|
||||
sendServerCommand(patientPl, CommandsData.modules.TOC_RELAY, CommandsData.client.Relay.ReceiveExecuteAmputationAction, params)
|
||||
end
|
||||
|
||||
|
||||
--* ADMIN ONLY *--
|
||||
---Relay a local init from another client
|
||||
---@param adminObj IsoPlayer
|
||||
|
||||
@@ -13,6 +13,9 @@ CommandsData.client = {
|
||||
ReceiveDamageDuringAmputation = "ReceiveDamageDuringAmputation", ---@alias receiveDamageDuringAmputationParams { limbName : string}
|
||||
ReceiveExecuteAmputationAction = "ReceiveExecuteAmputationAction", ---@alias receiveExecuteAmputationActionParams {surgeonNum : number, limbName : string}
|
||||
|
||||
--* APPLY *--
|
||||
ReceiveApplyFromServer = "ReceiveApplyFromServer",
|
||||
|
||||
--* ADMIN ONLY --*
|
||||
ReceiveExecuteInitialization = "ReceiveExecuteInitialization"
|
||||
|
||||
@@ -28,8 +31,6 @@ CommandsData.server = {
|
||||
Relay = {
|
||||
RelayDamageDuringAmputation = "RelayDamageDuringAmputation", ---@alias relayDamageDuringAmputationParams {patientNum : number, limbName : string}
|
||||
RelayExecuteAmputationAction = "RelayExecuteAmputationAction", ---@alias relayExecuteAmputationActionParams {patientNum : number, limbName : string}
|
||||
|
||||
|
||||
--* ADMIN ONLY *--
|
||||
RelayExecuteInitialization = "RelayExecuteInitialization" ---@alias relayExecuteInitializationParams {patientNum : number}
|
||||
}
|
||||
@@ -42,6 +43,10 @@ function CommandsData.GetKey(username)
|
||||
return StaticData.MOD_NAME .. "_" .. username
|
||||
end
|
||||
|
||||
function CommandsData.GetUsername(key)
|
||||
return string.sub(key, #StaticData.MOD_NAME + 2, #key) -- Not sure why +2... Something with kahlua, it should be +1
|
||||
end
|
||||
|
||||
function CommandsData.GetZombieKey()
|
||||
return StaticData.MOD_NAME .. "_ZOMBIES"
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
---@alias limbsTable {Hand_L : partDataType, ForeArm_L : partDataType, UpperArm_L : partDataType, Hand_R : partDataType, ForeArm_R : partDataType, UpperArm_R : partDataType }
|
||||
---@alias prosthesisData {isProstEquipped : boolean, prostFactor : number }
|
||||
---@alias prosthesesTable {Top_L : prosthesisData, Top_R : prosthesisData } -- TODO add Bottom_L and Bottom_R
|
||||
---@alias tocModDataType { limbs : limbsTable, prostheses : prosthesesTable, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean }
|
||||
---@alias tocModDataType { limbs : limbsTable, prostheses : prosthesesTable, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean, isUpdateFromServer : boolean }
|
||||
---------------------------
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ end
|
||||
|
||||
StaticData.TOURNIQUET_BODYLOCS_TO_GROUPS_IND_STR = {
|
||||
["HandsLeft"] = StaticData.AMP_GROUPS_IND_STR.Top_L,
|
||||
["HandsRight"] = StaticData.AMP_GROUPS.IND_STR.Top_R
|
||||
["HandsRight"] = StaticData.AMP_GROUPS_IND_STR.Top_R
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user