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 lastSelectedChunkKey: string? = nil
|
||||
local lastSelectedBlockKey: string? = nil
|
||||
local duplicateResyncCooldown: {[string]: number} = {}
|
||||
local BREAK_ROLLBACK_TIMEOUT = 0.6
|
||||
local pendingBreaks = {}
|
||||
local clearSelection
|
||||
@@ -426,14 +427,14 @@ function PlacementManager:PlaceBlock(cx, cy, cz, x, y, z, blockId: string)
|
||||
return
|
||||
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
|
||||
local existing = chunk:GetBlockAt(x, y, z)
|
||||
local existingId = existing and existing.id
|
||||
if existingId and tostring(existingId) == tostring(blockId) then
|
||||
debugPlacementLog(
|
||||
"[PLACE][CLIENT][SKIP]",
|
||||
"duplicate id",
|
||||
"[PLACE][CLIENT][DUPLICATE]",
|
||||
"still sending",
|
||||
"chunk",
|
||||
cx,
|
||||
cy,
|
||||
@@ -447,7 +448,14 @@ function PlacementManager:PlaceBlock(cx, cy, cz, x, y, z, blockId: string)
|
||||
"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
|
||||
debugPlacementLog(
|
||||
"[PLACE][CLIENT][EXISTING]",
|
||||
|
||||
@@ -138,7 +138,7 @@ local function isBlockInsidePlayer(blockPos: Vector3): boolean
|
||||
return false
|
||||
end
|
||||
|
||||
local DEBUG_PLACEMENT = true
|
||||
local DEBUG_PLACEMENT = false
|
||||
local function debugPlacementLog(...: any)
|
||||
if DEBUG_PLACEMENT then
|
||||
Util.StudioLog(...)
|
||||
|
||||
Reference in New Issue
Block a user