From 403c0d408a89af386898c79a7ee7157bf9df16d9 Mon Sep 17 00:00:00 2001 From: ethaniccc Date: Wed, 10 Jan 2024 22:17:51 +0000 Subject: [PATCH] simplify --- server/world/chunk/chunk.go | 19 ++----------------- server/world/chunk/sub_chunk.go | 15 ++------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/server/world/chunk/chunk.go b/server/world/chunk/chunk.go index 0e249fa0a..c9d9ba484 100644 --- a/server/world/chunk/chunk.go +++ b/server/world/chunk/chunk.go @@ -46,23 +46,8 @@ func New(air uint32, r cube.Range) *Chunk { // Equals returns if the chunk passed is equal to the current one func (chunk *Chunk) Equals(c *Chunk) bool { - if c.r != chunk.r { - return false - } - - if c.air != chunk.air { - return false - } - - if c.recalculateHeightMap != chunk.recalculateHeightMap { - return false - } - - if !slices.Equal(c.heightMap, chunk.heightMap) { - return false - } - - if len(c.sub) != len(chunk.sub) { + if c.r != chunk.r || c.air != chunk.air || + !slices.Equal(c.heightMap, chunk.heightMap) || len(c.sub) != len(chunk.sub) { return false } diff --git a/server/world/chunk/sub_chunk.go b/server/world/chunk/sub_chunk.go index 3aafab649..9b280cc49 100644 --- a/server/world/chunk/sub_chunk.go +++ b/server/world/chunk/sub_chunk.go @@ -18,19 +18,8 @@ func NewSubChunk(air uint32) *SubChunk { // Equals returns if the sub chunk passed is equal to the current one. func (sub *SubChunk) Equals(s *SubChunk) bool { - if s.air != sub.air { - return false - } - - if !slices.Equal(s.blockLight, sub.blockLight) { - return false - } - - if !slices.Equal(s.skyLight, sub.skyLight) { - return false - } - - if len(s.storages) != len(sub.storages) { + if s.air != sub.air || !slices.Equal(s.blockLight, sub.blockLight) || + !slices.Equal(s.skyLight, sub.skyLight) || len(s.storages) != len(sub.storages) { return false }