From f55c9f415a081a175e48b51db894f23e59ce47a2 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sun, 18 Jun 2023 22:28:37 +0100 Subject: fix line lengths --- common/map.lua | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'common/map.lua') diff --git a/common/map.lua b/common/map.lua index 67e2834..0437a12 100644 --- a/common/map.lua +++ b/common/map.lua @@ -1,15 +1,23 @@ -- a Map is a 2d array of chunks -- it handles loading and unloading of chunks --- each slot in the Map is either a Chunk object (if that chunk is loaded), --- nil (if not loaded), or false (if 'loading'). on the client 'loading' means --- the request for the chunk is currently in flight. on the server it might one day --- mean that terrain generation for that chunk is currently in progress. --- to test whether a chunk is loaded you can do if map:chunk(cp) then ... end --- to test whether a chunk needs to be loaded you do if map:chunk(cp) == nil then ... end. --- it will probably also do things relating to entities and multiblock things - --- note that the Map never creates any Chunks itself, which means it should be agnostic --- to whatever actual Chunk class is being used (ChunkC or ChunkS or whatever) +-- each slot in the Map is either a Chunk if that chunk is loaded, +-- nil if not loaded, or false (if 'loading'). +-- on the client 'loading' means the request for the chunk is +-- currently in flight. +-- on the server it might one day mean that terrain generation +-- for that chunk is currently in progress. +-- +-- to test whether a chunk is loaded you can do +-- if map:chunk(cp) then ... end +-- to test whether a chunk needs to be loaded you do +-- if map:chunk(cp) == nil then ... end +-- +-- it will probably also do things relating to entities +-- and multiblock things +-- +-- note that the Map never creates any Chunks itself, which means +-- it should be agnostic to whatever actual Chunk class is being used +-- (ChunkC or ChunkS or whatever) local class = require"common.class" local coords = require"common.coords" @@ -50,10 +58,12 @@ function Map.at(self,hpos) -- returns tile at world coord hpos -- if that tile's containing chunk isn't loaded, return nil - -- not using the methods for doing this, in order to avoid lots of allocations + -- not using the methods for doing this, to avoid many allocations -- inside the main drawing loop - local cpu,cpv = math.floor(hpos.q/CHUNK_SIZE),math.floor(hpos.r/CHUNK_SIZE) - local hoffq,hoffr = hpos.q-(cpu*CHUNK_SIZE), hpos.r-(cpv*CHUNK_SIZE) + local cpu = math.floor(hpos.q/CHUNK_SIZE) + local cpv = math.floor(hpos.r/CHUNK_SIZE) + local hoffq = hpos.q - (cpu*CHUNK_SIZE) + local hoffr = hpos.r - (cpv*CHUNK_SIZE) local ch = self:_chunkuv(cpu,cpv) if not ch then return nil end return ch:_atqr(hoffq,hoffr) -- cgit v1.2.3