From 1ebd7d9b7b62c8e05d527611a1944ed1a876b890 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 3 Feb 2023 19:37:28 +0000 Subject: debug drawing change, zoom clamping, partial refactoring of class mechanisms to allow inheritance, minor refactor of noise generator, changes to temp worldgen, rework of class constructor mechanism --- common/chunk.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'common/chunk.lua') diff --git a/common/chunk.lua b/common/chunk.lua index 8e2ec40..1d3faa6 100644 --- a/common/chunk.lua +++ b/common/chunk.lua @@ -1,6 +1,7 @@ local json = require"common.dkjson" +local class = require"common.class" -local CHUNK_SIZE = 128 +local CHUNK_SIZE = 64 -- for now tiles shall be booleans @@ -15,10 +16,9 @@ local function index(offq,offr) return CHUNK_SIZE*offq + offr + 1 end -local Chunk = {} -Chunk.__index = Chunk -function Chunk.make(tiles) - return setmetatable({tiles=tiles},Chunk) +local Chunk = class() +function Chunk.make(cls,tiles) + return setmetatable({tiles=tiles},cls) end function Chunk.at(self,hoffs) if not index_ok(hoffs.q,hoffs.r) then return nil end @@ -35,11 +35,12 @@ end function Chunk.from_packet_data(packet) -- assuming packet has already been json.decoded -- since otherwise how would we know it's a chunk packet - return Chunk.make(packet.tiles) + return Chunk:make(packet.tiles) end return { Chunk=Chunk, SIZE=CHUNK_SIZE, - index=index + index=index, + index_ok=index_ok, } -- cgit v1.2.3