packet size improvements
- change structure resource packets - make more booleans default to false - use encode_string - massive decrease in packet size!!
This commit is contained in:
parent
523f6d5914
commit
085776d42b
14 changed files with 131 additions and 134 deletions
|
|
@ -15,7 +15,8 @@ function KafkatorioPacketEmitter.prototype.emitKeyedPacket(self, data)
|
|||
end
|
||||
function KafkatorioPacketEmitter.emitPacket(self, packet)
|
||||
local data = game.table_to_json(packet)
|
||||
localised_print("KafkatorioPacket: " .. data)
|
||||
local encoded = game.encode_string(data)
|
||||
print("KafkatorioPacket encoded::: " .. tostring(encoded))
|
||||
end
|
||||
local PacketEmitter = __TS__New(____exports.KafkatorioPacketEmitter)
|
||||
____exports.default = PacketEmitter
|
||||
|
|
|
|||
|
|
@ -42,13 +42,6 @@ do
|
|||
end
|
||||
return masks
|
||||
end
|
||||
function Converters.convertResourceEntity(entity)
|
||||
if entity.type ~= "resource" then
|
||||
return nil
|
||||
else
|
||||
return {amount = entity.amount, initialAmount = entity.initial_amount}
|
||||
end
|
||||
end
|
||||
local function convertEntityStatus(status)
|
||||
if status == nil then
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -142,16 +142,23 @@ function EntityUpdatesHandler.throttleResourcesUpdate(self, eventName, eventTick
|
|||
local ____data_events_eventName_17 = data.events[eventName]
|
||||
____data_events_eventName_17[#____data_events_eventName_17 + 1] = eventTick
|
||||
for ____, entity in ipairs(resourceEntities) do
|
||||
local resourceUpdate = Converters.convertResourceEntity(entity)
|
||||
if resourceUpdate ~= nil then
|
||||
if data.resourcesXY == nil then
|
||||
data.resourcesXY = {}
|
||||
if data.amounts == nil then
|
||||
data.amounts = {}
|
||||
end
|
||||
local ____data_amounts_18, ____tostring_result_19 = data.amounts, tostring(entity.position.x)
|
||||
if ____data_amounts_18[____tostring_result_19] == nil then
|
||||
____data_amounts_18[____tostring_result_19] = {}
|
||||
end
|
||||
data.amounts[tostring(entity.position.x)][tostring(entity.position.y)] = entity.amount
|
||||
if entity.initial_amount ~= nil then
|
||||
if data.initialAmounts == nil then
|
||||
data.initialAmounts = {}
|
||||
end
|
||||
local ____data_resourcesXY_18, ____tostring_result_19 = data.resourcesXY, tostring(entity.position.x)
|
||||
if ____data_resourcesXY_18[____tostring_result_19] == nil then
|
||||
____data_resourcesXY_18[____tostring_result_19] = {}
|
||||
local ____data_initialAmounts_20, ____tostring_result_21 = data.initialAmounts, tostring(entity.position.x)
|
||||
if ____data_initialAmounts_20[____tostring_result_21] == nil then
|
||||
____data_initialAmounts_20[____tostring_result_21] = {}
|
||||
end
|
||||
data.resourcesXY[tostring(entity.position.x)][tostring(entity.position.y)] = resourceUpdate
|
||||
data.initialAmounts[tostring(entity.position.x)][tostring(entity.position.y)] = entity.initial_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue