Fix out-of-bounds in 'combine' texture modifier
Co-authored-by: tenplus1 <tenplus1@users.noreply.github.com>
52
api.lua
@ -467,15 +467,6 @@ signs_lib.charwidth_wide32 = build_char_db(32)
|
|||||||
|
|
||||||
local math_max = math.max
|
local math_max = math.max
|
||||||
|
|
||||||
local function fill_line(x, y, w, c, font_size, colorbgw)
|
|
||||||
c = c or "0"
|
|
||||||
local tex = { }
|
|
||||||
for xx = 0, math.max(0, w), colorbgw do
|
|
||||||
table.insert(tex, (":%d,%d=signs_lib_color_"..font_size.."px_%s.png"):format(x + xx, y, c))
|
|
||||||
end
|
|
||||||
return table.concat(tex)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- make char texture file name
|
-- make char texture file name
|
||||||
-- if texture file does not exist use fallback texture instead
|
-- if texture file does not exist use fallback texture instead
|
||||||
local function char_tex(font_name, ch)
|
local function char_tex(font_name, ch)
|
||||||
@ -511,6 +502,26 @@ local function char_tex_wide(font_name, ch)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- sign colour table
|
||||||
|
local colgrid = {
|
||||||
|
["0"] = "000000", -- black
|
||||||
|
["1"] = "000080", -- blue
|
||||||
|
["2"] = "008000", -- dark green
|
||||||
|
["3"] = "008080", -- dark cyan
|
||||||
|
["4"] = "800000", -- red
|
||||||
|
["5"] = "800080", -- purple
|
||||||
|
["6"] = "804000", -- brown
|
||||||
|
["7"] = "808080", -- light grey
|
||||||
|
["8"] = "404040", -- dark grey
|
||||||
|
["9"] = "8080ff", -- light blue
|
||||||
|
["A"] = "80ff80", -- green
|
||||||
|
["B"] = "80ffff", -- cyan
|
||||||
|
["C"] = "ff8080", -- skin pink
|
||||||
|
["D"] = "ff80ff", -- pink
|
||||||
|
["E"] = "ffff00", -- yellow
|
||||||
|
["F"] = "ffffff" -- white
|
||||||
|
}
|
||||||
|
|
||||||
local function make_line_texture(line, lineno, pos, line_width, line_height, cwidth_tab, font_size, colorbgw, cwidth_tab_wide, force_unicode_font)
|
local function make_line_texture(line, lineno, pos, line_width, line_height, cwidth_tab, font_size, colorbgw, cwidth_tab_wide, force_unicode_font)
|
||||||
local width = 0
|
local width = 0
|
||||||
local maxw = 0
|
local maxw = 0
|
||||||
@ -647,36 +658,25 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||||||
local xpos = start_xpos
|
local xpos = start_xpos
|
||||||
local ypos = (line_height + def.line_spacing)* lineno + def.y_offset
|
local ypos = (line_height + def.line_spacing)* lineno + def.y_offset
|
||||||
|
|
||||||
cur_color = nil
|
|
||||||
|
|
||||||
for word_i, word in ipairs(words) do
|
for word_i, word in ipairs(words) do
|
||||||
local xoffs = (xpos - start_xpos)
|
local xoffs = (xpos - start_xpos)
|
||||||
if (xoffs > 0) and ((xoffs + word.w) > maxw) then
|
if (xoffs > 0) and ((xoffs + word.w) > maxw) then
|
||||||
table.insert(texture, fill_line(xpos, ypos, maxw, "n", font_size, colorbgw))
|
|
||||||
xpos = start_xpos
|
xpos = start_xpos
|
||||||
ypos = ypos + line_height + def.line_spacing
|
ypos = ypos + line_height + def.line_spacing
|
||||||
lineno = lineno + 1
|
lineno = lineno + 1
|
||||||
if lineno >= def.number_of_lines then break end
|
if lineno >= def.number_of_lines then break end
|
||||||
table.insert(texture, fill_line(xpos, ypos, maxw, cur_color, font_size, colorbgw))
|
|
||||||
end
|
end
|
||||||
for ch_i, ch in ipairs(word.chars) do
|
for ch_i, ch in ipairs(word.chars) do
|
||||||
if ch.col ~= cur_color then
|
|
||||||
cur_color = ch.col
|
-- colorize character texture
|
||||||
table.insert(texture, fill_line(xpos + ch.off, ypos, maxw, cur_color, font_size, colorbgw))
|
local newtex = ch.tex .. '\\^[colorize\\:#' .. colgrid[ch.col]
|
||||||
|
|
||||||
|
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, newtex))
|
||||||
end
|
end
|
||||||
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
|
|
||||||
end
|
|
||||||
table.insert(
|
|
||||||
texture,
|
|
||||||
(":%d,%d="):format(xpos + word.w, ypos) .. char_tex(font_name, " ")
|
|
||||||
)
|
|
||||||
xpos = xpos + word.w + cwidth_tab[" "]
|
xpos = xpos + word.w + cwidth_tab[" "]
|
||||||
if xpos >= (line_width + cwidth_tab[" "]) then break end
|
if xpos >= (line_width + cwidth_tab[" "]) then break end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(texture, fill_line(xpos, ypos, maxw, "n", font_size, colorbgw))
|
|
||||||
table.insert(texture, fill_line(start_xpos, ypos + line_height, maxw, "n", font_size, colorbgw))
|
|
||||||
|
|
||||||
return table.concat(texture), lineno
|
return table.concat(texture), lineno
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -721,7 +721,7 @@ function signs_lib.make_sign_texture(lines, pos)
|
|||||||
table.insert(texture, linetex)
|
table.insert(texture, linetex)
|
||||||
lineno = ln + 1
|
lineno = ln + 1
|
||||||
end
|
end
|
||||||
table.insert(texture, "^[makealpha:0,0,0")
|
|
||||||
return table.concat(texture, "")
|
return table.concat(texture, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 285 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 275 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 280 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 274 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 263 B |
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 241 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 289 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 256 B |
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 244 B |
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 89 B After Width: | Height: | Size: 237 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 255 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 263 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 247 B |
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 274 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 280 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 265 B |