placement: handle existing block edge case
This commit is contained in:
@@ -31,6 +31,7 @@ local lastNormalId: Enum.NormalId? = nil
|
|||||||
local lastRaycastFailure: string? = nil
|
local lastRaycastFailure: string? = nil
|
||||||
local lastSelectedChunkKey: string? = nil
|
local lastSelectedChunkKey: string? = nil
|
||||||
local lastSelectedBlockKey: string? = nil
|
local lastSelectedBlockKey: string? = nil
|
||||||
|
local duplicateResyncCooldown: {[string]: number} = {}
|
||||||
local BREAK_ROLLBACK_TIMEOUT = 0.6
|
local BREAK_ROLLBACK_TIMEOUT = 0.6
|
||||||
local pendingBreaks = {}
|
local pendingBreaks = {}
|
||||||
local clearSelection
|
local clearSelection
|
||||||
@@ -426,14 +427,14 @@ function PlacementManager:PlaceBlock(cx, cy, cz, x, y, z, blockId: string)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if the client already thinks this block is the same id, skip sending
|
-- allow sending even if the client thinks the id matches; server truth wins
|
||||||
if chunk then
|
if chunk then
|
||||||
local existing = chunk:GetBlockAt(x, y, z)
|
local existing = chunk:GetBlockAt(x, y, z)
|
||||||
local existingId = existing and existing.id
|
local existingId = existing and existing.id
|
||||||
if existingId and tostring(existingId) == tostring(blockId) then
|
if existingId and tostring(existingId) == tostring(blockId) then
|
||||||
debugPlacementLog(
|
debugPlacementLog(
|
||||||
"[PLACE][CLIENT][SKIP]",
|
"[PLACE][CLIENT][DUPLICATE]",
|
||||||
"duplicate id",
|
"still sending",
|
||||||
"chunk",
|
"chunk",
|
||||||
cx,
|
cx,
|
||||||
cy,
|
cy,
|
||||||
@@ -447,7 +448,14 @@ function PlacementManager:PlaceBlock(cx, cy, cz, x, y, z, blockId: string)
|
|||||||
"blockId",
|
"blockId",
|
||||||
blockId
|
blockId
|
||||||
)
|
)
|
||||||
return
|
local ck = makeChunkKey(cx, cy, cz)
|
||||||
|
local last = duplicateResyncCooldown[ck]
|
||||||
|
if not last or (tick() - last) > 0.5 then
|
||||||
|
duplicateResyncCooldown[ck] = tick()
|
||||||
|
task.defer(function()
|
||||||
|
ChunkManager:RefreshChunk(cx, cy, cz)
|
||||||
|
end)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
debugPlacementLog(
|
debugPlacementLog(
|
||||||
"[PLACE][CLIENT][EXISTING]",
|
"[PLACE][CLIENT][EXISTING]",
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ local function isBlockInsidePlayer(blockPos: Vector3): boolean
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local DEBUG_PLACEMENT = true
|
local DEBUG_PLACEMENT = false
|
||||||
local function debugPlacementLog(...: any)
|
local function debugPlacementLog(...: any)
|
||||||
if DEBUG_PLACEMENT then
|
if DEBUG_PLACEMENT then
|
||||||
Util.StudioLog(...)
|
Util.StudioLog(...)
|
||||||
|
|||||||
Reference in New Issue
Block a user