MapGen: fix annotations warnings

This commit is contained in:
Van
2026-01-14 17:16:18 +03:00
parent 03ce7983eb
commit 907230e67d
4 changed files with 42 additions and 40 deletions

View File

@@ -5,9 +5,9 @@ local mathAbs, mathRound, mathMin, mathMax, id
local pastCalcNoiseValue = {
---@type MapGen.Triangle?
triangle = nil,
---@type number?
---@type integer?
x = nil,
---@type number?
---@type integer?
z = nil,
---@type number?
noiseValue = nil,
@@ -353,9 +353,9 @@ end
---Returns `true` if there is a cavern at the specified coordinates.
---@param layer MapGen.Layer
---@param x number
---@param y number
---@param z number
---@param x integer
---@param y integer
---@param z integer
---@return boolean
local function isCavern(layer, x, y, z)
for _, cavern in ipairs(layer.cavernsList) do
@@ -376,9 +376,9 @@ end
---@param humidity number
---@param data number[]
---@param index number
---@param x number
---@param y number
---@param z number
---@param x integer
---@param y integer
---@param z integer
local function generateNode(mapGenerator, layer, height, temp, humidity, data, index, x, y, z)
local ids = mapGenerator.nodeIDs
local waterLevel = layer.waterLevel
@@ -388,6 +388,7 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
local scatteringVertical = layer.biomesVerticalScattering or 0
local scattTemp = temp
local scattHumidity = humidity
---@type number
local scattHeight = y
if scatteringGorizontal ~= 0 then
@@ -467,9 +468,9 @@ end
---the triangle's height and specifying the distance to the peak
---for which the weight is calculated.
---@param height MapGen.Triangulation.Edge
---@param x number
---@param y number
---@param z number
---@param x integer
---@param y integer
---@param z integer
---@return number
local function calcWeight(height, x, y, z)
local pos1 = vector.new(x, y, z)
@@ -491,8 +492,8 @@ end
---Returns `true` if the point is within the triangle's region.
---The barycentric coordinate method is used.
---@param px number
---@param pz number
---@param px integer
---@param pz integer
---@param triangle MapGen.Triangle
local function pointInTriangle(px, pz, triangle)
local posP = vector.new(px, 0, pz)
@@ -521,9 +522,9 @@ end
---@param category MapGen.Layer.Category
---@param layer MapGen.Layer
---@param triangle MapGen.Triangle
---@param x number
---@param y number
---@param z number
---@param x integer
---@param y integer
---@param z integer
---@return number
local function calcNoise2dValue(category, layer, triangle, x, y, z)
local peak1 = triangle.p1
@@ -561,9 +562,9 @@ end
---Returns `nil` if the point is not included in any triangle.
---@param category MapGen.Layer.Category
---@param layer MapGen.Layer
---@param x number
---@param y number
---@param z number
---@param x integer
---@param y integer
---@param z integer
---@return number?
function MapGen:getNoises2dValue(category, layer, x, y, z)
---@type MapGen.PastCalcNoiseValue
@@ -696,9 +697,9 @@ end
---@param mapGenerator MapGen
---@param data number[]
---@param index number
---@param x number
---@param y number
---@param z number
---@param x integer
---@param y integer
---@param z integer
local function generatorHandler(mapGenerator, data, index, x, y, z)
-- If the node belongs to a static layer, then a static node is generated.
local static = mapGenerator:getStaticByHeight(y)
@@ -732,8 +733,8 @@ end
---Chunk generation handler.
---@param voxelManip VoxelManip
---@param minPos table
---@param maxPos table
---@param minPos Position
---@param maxPos Position
---@param blockseed number
function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
-- We obtain a generation area for further manipulations
@@ -795,6 +796,7 @@ function MapGen:run()
error('Only one instance of a `MapGen` class can be running.')
end
---@param ... VoxelManip
core.register_on_generated(function(...)
self:onMapGenerated(...)
end)

View File

@@ -90,9 +90,9 @@ local function calcCavernWeight(y, smoothDistance, minY, maxY)
end
---Returns `true` if there is a cavern at the specified coordinates.
---@param x number
---@param y number
---@param z number
---@param x integer
---@param y integer
---@param z integer
---@return boolean
function Cavern:isCavern(x, y, z)
local minY, maxY = self.minY, self.maxY

View File

@@ -1,12 +1,12 @@
---@class MapGen.Layer
---@field name string
---@field minY number
---@field maxY number
---@field minTemp number
---@field maxTemp number
---@field minHumidity number
---@field maxHumidity number
---@field waterLevel number
---@field minY integer
---@field maxY integer
---@field minTemp integer
---@field maxTemp integer
---@field minHumidity integer
---@field maxHumidity integer
---@field waterLevel integer
---@field calcTemp fun(self:MapGen.Layer, value:number, height:number):number
---@field calcHumidity fun(self:MapGen.Layer, value:number, height:number):number
---@field peaksList {['landscape']:MapGen.Peak[],['temp']:MapGen.Peak[],['humidity']:MapGen.Peak[]}
@@ -15,8 +15,8 @@
---@field biomesByName table<string, MapGen.Biome>
---@field biomesList MapGen.Biome[]
---@field biomesDiagram table
---@field biomesGorizontalScattering number
---@field biomesVerticalScattering number
---@field biomesGorizontalScattering integer
---@field biomesVerticalScattering integer
---@field cavernsByName table<string, MapGen.Cavern>
---@field cavernsList MapGen.Cavern[]
---@field trianglesList {['landscape']:MapGen.Triangle[],['temp']:MapGen.Triangle[],['humidity']:MapGen.Triangle[]}
@@ -130,7 +130,7 @@ end
---@param color ColorString
---@param noiseParams NoiseParams
function Layer:addNoiseParamsColor(category, color, noiseParams)
color = core.colorspec_to_colorstring(core.colorspec_to_table(color))
color = Smc.fixColorString(color)
local noisesParams = self.noisesParamsByColor
@@ -153,7 +153,7 @@ end
---@param color ColorString
---@return ValueNoise
function Layer:getNoiseByColor(category, color)
color = core.colorspec_to_colorstring(core.colorspec_to_table(color))
color = Smc.fixColorString(color)
local noises = self.noisesByColor

View File

@@ -66,7 +66,7 @@ local function ff2luat(filepath, backgroundColor)
if not backgroundColor then backgroundColor = '#000000FF' end
--HACK: normalizing colorstring for future string comparison ('#000' -> '#000000FF')
backgroundColor = core.colorspec_to_colorstring(core.colorspec_to_table(backgroundColor))
backgroundColor = Smc.fixColorString(backgroundColor)
---@type ColoredDotsTable
local dots = { size = { w = uintb2num(ff:sub(9,12)), h = uintb2num(ff:sub(13,16)) } }
@@ -83,7 +83,7 @@ local function ff2luat(filepath, backgroundColor)
}
---@type string @ColorString
local color = core.colorspec_to_colorstring(colorT)
local color = core.colorspec_to_colorstring(colorT) or ''
if color ~= backgroundColor then
if not dots[color] then