Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
ethaniccc committed Jan 10, 2024
1 parent 19b3acc commit 403c0d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
19 changes: 2 additions & 17 deletions server/world/chunk/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
15 changes: 2 additions & 13 deletions server/world/chunk/sub_chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 403c0d4

Please sign in to comment.