From 9b941768becc1362598b7939a2e24dd2b12a9d5f Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Tue, 29 Jun 2010 17:32:03 +0000
Subject: [PATCH] Reworked the internal CMap, it now does not know what a
 terrain or an actor is, instead the map objects are just textures, positioned
 on a z-order, each map object can tell if it can be seen, remembered, ...
 Trees are now made of two or more map objects, a patch of grass and one or
 more tree, randomly placed on the tile, to make forests look less tilish

git-svn-id: http://svn.net-core.org/repos/t-engine4@863 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engine/Actor.lua                         |   4 +
 game/engine/Entity.lua                        |  38 ++++-
 game/engine/Grid.lua                          |   4 +
 game/engine/Map.lua                           |  18 +-
 game/engine/Object.lua                        |   4 +
 game/engine/Trap.lua                          |   4 +
 game/engine/generator/map/Forest.lua          |  29 ++--
 game/engine/generator/map/Roomer.lua          |  33 ++--
 game/modules/tome/class/Grid.lua              |  25 +++
 .../tome/data/general/grids/forest.lua        |  10 +-
 .../tome/data/gfx/terrain/tree_alpha1.png     | Bin 0 -> 829 bytes
 .../tome/data/gfx/terrain/tree_alpha2.png     | Bin 0 -> 777 bytes
 .../tome/data/gfx/terrain/tree_alpha3.png     | Bin 0 -> 1016 bytes
 src/core_lua.c                                |   4 +-
 src/main.c                                    |  12 +-
 src/map.c                                     | 156 +++++++-----------
 src/map.h                                     |  12 +-
 src/sdnoise1234.c                             |   2 +-
 18 files changed, 209 insertions(+), 146 deletions(-)
 create mode 100644 game/modules/tome/data/gfx/terrain/tree_alpha1.png
 create mode 100644 game/modules/tome/data/gfx/terrain/tree_alpha2.png
 create mode 100644 game/modules/tome/data/gfx/terrain/tree_alpha3.png

diff --git a/game/engine/Actor.lua b/game/engine/Actor.lua
index a6449ddd78..812635a84b 100644
--- a/game/engine/Actor.lua
+++ b/game/engine/Actor.lua
@@ -24,6 +24,10 @@ local Faction = require "engine.Faction"
 
 module(..., package.seeall, class.inherit(Entity))
 
+_M.display_on_seen = true
+_M.display_on_remember = false
+_M.display_on_unknown = false
+
 function _M:init(t, no_default)
 	t = t or {}
 
diff --git a/game/engine/Entity.lua b/game/engine/Entity.lua
index 2078878392..05d782664d 100644
--- a/game/engine/Entity.lua
+++ b/game/engine/Entity.lua
@@ -154,11 +154,25 @@ end
 -- Do not touch unless you *KNOW* what you are doing.<br/>
 -- You do *NOT* need this, this is used by the engine.Map class automatically.<br/>
 -- *DO NOT TOUCH!!!*
-function _M:makeMapObject(tiles)
-	if self._mo and self._mo:isValid() then return self._mo end
+function _M:makeMapObject(tiles, idx)
+	if idx > 1 and not tiles.use_images then return nil end
+	if idx > 1 then
+		if not self.add_displays or not self.add_displays[idx] then return end
+		return self.add_displays[idx]:makeMapObject(tiles, 1)
+	else
+		if self._mo and self._mo:isValid() then return self._mo, self.z end
+	end
 
 	-- Create the map object with 1 + additional textures
-	self._mo = core.map.newObject(1 + (tiles.use_images and self.textures and #self.textures or 0))
+	self._mo = core.map.newObject(
+		1 + (tiles.use_images and self.textures and #self.textures or 0),
+		self:check("display_on_seen"),
+		self:check("display_on_remember"),
+		self:check("display_on_unknown"),
+		self:check("display_x") or 0,
+		self:check("display_y") or 0,
+		self:check("display_scale") or 1
+	)
 	_M.__mo_repo[#_M.__mo_repo+1] = self._mo
 
 	-- Setup tint
@@ -171,7 +185,7 @@ function _M:makeMapObject(tiles)
 	if tiles.use_images and self.textures then
 		for i = 1, #self.textures do
 			local t = self.textures[i]
-			if type(t) == "function" then local tex, is3d = t(self, tiles); self._mo:texture(i, tex, is3d) tiles.texture_store[tex] = true
+			if type(t) == "function" then local tex, is3d = t(self, tiles); if tex then self._mo:texture(i, tex, is3d) tiles.texture_store[tex] = true end
 			elseif type(t) == "table" then
 				if t[1] == "image" then local tex = tiles:get('', 0, 0, 0, 0, 0, 0, t[2]); self._mo:texture(i, tex, false) tiles.texture_store[tex] = true
 				end
@@ -184,7 +198,21 @@ function _M:makeMapObject(tiles)
 		self._mo:shader(Shader.new(self.shader, self.shader_args).shad)
 	end
 
-	return self._mo
+	return self._mo, self.z
+end
+
+--- Get all "map objects" representing this entity
+-- Do not touch unless you *KNOW* what you are doing.<br/>
+-- You do *NOT* need this, this is used by the engine.Map class automatically.<br/>
+-- *DO NOT TOUCH!!!*
+function _M:getMapObjects(tiles, mos, z)
+	local i = -1
+	local mo, dz
+	repeat
+		i = i + 1
+		mo, dz = self:makeMapObject(tiles, 1+i)
+		mos[dz or z+i] = mo
+	until not mo
 end
 
 --- Resolves an entity
diff --git a/game/engine/Grid.lua b/game/engine/Grid.lua
index 9abb285928..a9478cc7a9 100644
--- a/game/engine/Grid.lua
+++ b/game/engine/Grid.lua
@@ -25,6 +25,10 @@ module(..., package.seeall, class.inherit(Entity))
 -- When used on the map, do not draw alpha channel
 _M._noalpha = true
 
+_M.display_on_seen = true
+_M.display_on_remember = true
+_M.display_on_unknown = false
+
 function _M:init(t, no_default)
 	t = t or {}
 	self.name = t.name
diff --git a/game/engine/Map.lua b/game/engine/Map.lua
index a252224aca..0981dc49c0 100644
--- a/game/engine/Map.lua
+++ b/game/engine/Map.lua
@@ -27,6 +27,9 @@ local DamageType = require "engine.DamageType"
 --- Represents a level map, handles display and various low level map work
 module(..., package.seeall, class.make)
 
+--- The map vertical depth storage
+zdepth = 10
+
 --- The place of a terrain entity in a map grid
 TERRAIN = 1
 --- The place of a terrain entity in a map grid
@@ -211,7 +214,7 @@ function _M:save()
 end
 
 function _M:makeCMap()
-	self._map = core.map.newMap(self.w, self.h, self.mx, self.my, self.viewport.mwidth, self.viewport.mheight, self.tile_w, self.tile_h, self.multidisplay)
+	self._map = core.map.newMap(self.w, self.h, self.mx, self.my, self.viewport.mwidth, self.viewport.mheight, self.tile_w, self.tile_h, self.zdepth)
 	self._map:setObscure(unpack(self.color_obscure))
 	self._map:setShown(unpack(self.color_shown))
 	self._map:setupMiniMap(
@@ -342,6 +345,7 @@ function _M:updateMap(x, y)
 
 	-- Update minimap if any
 	local mm = MM_FLOOR
+	local mos = {}
 
 	if g then
 		-- Update path caches from path strings
@@ -352,19 +356,19 @@ function _M:updateMap(x, y)
 
 		mm = mm + (g:check("block_move") and MM_BLOCK or 0)
 		mm = mm + (g:check("change_level") and MM_LEVEL_CHANGE or 0)
-		g = g:makeMapObject(self.tiles)
+		g:getMapObjects(self.tiles, mos, 1)
 	end
 	if t then
 		-- Handles invisibility and telepathy and other such things
 		if not self.actor_player or t:knownBy(self.actor_player) then
-			t = t:makeMapObject(self.tiles)
+			t:getMapObjects(self.tiles, mos, 3)
 			mm = mm + MM_TRAP
 		else
 			t = nil
 		end
 	end
 	if o then
-		o = o:makeMapObject(self.tiles)
+		o:getMapObjects(self.tiles, mos, 5)
 		mm = mm + MM_OBJECT
 	end
 	if a then
@@ -372,14 +376,12 @@ function _M:updateMap(x, y)
 		if not self.actor_player or self.actor_player:canSee(a) then
 			local r = self.actor_player:reactionToward(a)
 			mm = mm + (r > 0 and MM_FRIEND or (r == 0 and MM_NEUTRAL or MM_HOSTILE))
-			a = a:makeMapObject(self.tiles)
-		else
-			a = nil
+			a:getMapObjects(self.tiles, mos, 7)
 		end
 	end
 
 	-- Cache the map objects in the C map
-	self._map:setGrid(x, y, g, t, o, a, mm)
+	self._map:setGrid(x, y, mm, mos)
 
 	-- Update FOV caches
 	if self:checkAllEntities(x, y, "block_sight", self.actor_player) then self._fovcache.block_sight:set(x, y, true)
diff --git a/game/engine/Object.lua b/game/engine/Object.lua
index 564412665b..8fab136179 100644
--- a/game/engine/Object.lua
+++ b/game/engine/Object.lua
@@ -22,6 +22,10 @@ local Entity = require "engine.Entity"
 
 module(..., package.seeall, class.inherit(Entity))
 
+_M.display_on_seen = true
+_M.display_on_remember = true
+_M.display_on_unknown = false
+
 function _M:init(t, no_default)
 	t = t or {}
 
diff --git a/game/engine/Trap.lua b/game/engine/Trap.lua
index 4ff8b05df1..7fb75503bc 100644
--- a/game/engine/Trap.lua
+++ b/game/engine/Trap.lua
@@ -24,6 +24,10 @@ local Map = require "engine.Map"
 --- Describes a trap
 module(..., package.seeall, class.inherit(Entity))
 
+_M.display_on_seen = true
+_M.display_on_remember = true
+_M.display_on_unknown = false
+
 function _M:init(t, no_default)
 	t = t or {}
 
diff --git a/game/engine/generator/map/Forest.lua b/game/engine/generator/map/Forest.lua
index d342c47db2..c7a4031fa9 100644
--- a/game/engine/generator/map/Forest.lua
+++ b/game/engine/generator/map/Forest.lua
@@ -45,12 +45,21 @@ end
 function _M:resolve(c)
 	local res = self.data[c]
 	if type(res) == "function" then
-		return res()
+		res = res()
 	elseif type(res) == "table" then
-		return res[rng.range(1, #res)]
+		res = res[rng.range(1, #res)]
 	else
-		return res
+		res = res
 	end
+	if not res then return end
+	res = self.grid_list[res]
+	if not res then return end
+	if res.force_clone then
+		res = res:clone()
+	end
+	res:resolve()
+	res:resolve(nil, true)
+	return res
 end
 
 function _M:addPond(x, y, spots)
@@ -108,7 +117,7 @@ end
 
 function _M:generate(lev, old_lev)
 	for i = 0, self.map.w - 1 do for j = 0, self.map.h - 1 do
-		self.map(i, j, Map.TERRAIN, self.grid_list[self:resolve("floor")])
+		self.map(i, j, Map.TERRAIN, self:resolve("floor"))
 	end end
 
 	-- make the noise
@@ -117,9 +126,9 @@ function _M:generate(lev, old_lev)
 		for j = 1, self.map.h do
 			local v = math.floor((noise[self.noise](noise, self.zoom * i / self.map.w, self.zoom * j / self.map.h, self.octave) / 2 + 0.5) * self.max_percent)
 			if (v >= self.sqrt_percent and rng.percent(v)) or (v < self.sqrt_percent and rng.percent(math.sqrt(v))) then
-				self.map(i-1, j-1, Map.TERRAIN, self.grid_list[self:resolve("wall")])
+				self.map(i-1, j-1, Map.TERRAIN, self:resolve("wall"))
 			else
-				self.map(i-1, j-1, Map.TERRAIN, self.grid_list[self:resolve("floor")])
+				self.map(i-1, j-1, Map.TERRAIN, self:resolve("floor"))
 			end
 		end
 	end
@@ -150,7 +159,7 @@ function _M:makeStairsInside(lev, old_lev, spots)
 		while true do
 			dx, dy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
 			if not self.map:checkEntity(dx, dy, Map.TERRAIN, "block_move") and not self.map.room_map[dx][dy].special then
-				self.map(dx, dy, Map.TERRAIN, self.grid_list[self:resolve("down")])
+				self.map(dx, dy, Map.TERRAIN, self:resolve("down"))
 				self.map.room_map[dx][dy].special = "exit"
 				break
 			end
@@ -162,7 +171,7 @@ function _M:makeStairsInside(lev, old_lev, spots)
 	while true do
 		ux, uy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
 		if not self.map:checkEntity(ux, uy, Map.TERRAIN, "block_move") and not self.map.room_map[ux][uy].special then
-			self.map(ux, uy, Map.TERRAIN, self.grid_list[self:resolve("up")])
+			self.map(ux, uy, Map.TERRAIN, self:resolve("up"))
 			self.map.room_map[ux][uy].special = "exit"
 			break
 		end
@@ -184,7 +193,7 @@ function _M:makeStairsSides(lev, old_lev, sides, spots)
 			end
 
 			if not self.map.room_map[dx][dy].special then
-				self.map(dx, dy, Map.TERRAIN, self.grid_list[self:resolve("down")])
+				self.map(dx, dy, Map.TERRAIN, self:resolve("down"))
 				self.map.room_map[dx][dy].special = "exit"
 				break
 			end
@@ -201,7 +210,7 @@ function _M:makeStairsSides(lev, old_lev, sides, spots)
 		end
 
 		if not self.map.room_map[ux][uy].special then
-			self.map(ux, uy, Map.TERRAIN, self.grid_list[self:resolve("up")])
+			self.map(ux, uy, Map.TERRAIN, self:resolve("up"))
 			self.map.room_map[ux][uy].special = "exit"
 			break
 		end
diff --git a/game/engine/generator/map/Roomer.lua b/game/engine/generator/map/Roomer.lua
index aab0c7e557..49d9b50dad 100644
--- a/game/engine/generator/map/Roomer.lua
+++ b/game/engine/generator/map/Roomer.lua
@@ -75,12 +75,21 @@ end
 function _M:resolve(c)
 	local res = self.data[c]
 	if type(res) == "function" then
-		return res()
+		res = res()
 	elseif type(res) == "table" then
-		return res[rng.range(1, #res)]
+		res = res[rng.range(1, #res)]
 	else
-		return res
+		res = res
 	end
+	if not res then return end
+	res = self.grid_list[res]
+	if not res then return end
+	if res.force_clone then
+		res = res:clone()
+	end
+	res:resolve()
+	res:resolve(nil, true)
+	return res
 end
 
 --- Make up a room
@@ -118,9 +127,9 @@ function _M:roomAlloc(room, id, lev, old_lev)
 						if c == '!' then
 							self.map.room_map[i-1+x][j-1+y].room = nil
 							self.map.room_map[i-1+x][j-1+y].can_open = true
-							self.map(i-1+x, j-1+y, Map.TERRAIN, self.grid_list[self:resolve('#')])
+							self.map(i-1+x, j-1+y, Map.TERRAIN, self:resolve('#'))
 						else
-							self.map(i-1+x, j-1+y, Map.TERRAIN, self.grid_list[self:resolve(c)])
+							self.map(i-1+x, j-1+y, Map.TERRAIN, self:resolve(c))
 						end
 						if is_lit then self.map.lites(i-1+x, j-1+y, true) end
 					end
@@ -252,9 +261,9 @@ function _M:tunnel(x1, y1, x2, y2, id)
 	for _, t in ipairs(tun) do
 		local nx, ny = t[1], t[2]
 		if t[3] and self.data.door and rng.percent(self.data.door_chance) then
-			self.map(nx, ny, Map.TERRAIN, self.grid_list[self:resolve("door")])
+			self.map(nx, ny, Map.TERRAIN, self:resolve("door"))
 		else
-			self.map(nx, ny, Map.TERRAIN, self.grid_list[self:resolve('.')])
+			self.map(nx, ny, Map.TERRAIN, self:resolve('.'))
 		end
 	end
 end
@@ -267,7 +276,7 @@ function _M:makeStairsInside(lev, old_lev, spots)
 		while true do
 			dx, dy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
 			if not self.map:checkEntity(dx, dy, Map.TERRAIN, "block_move") and not self.map.room_map[dx][dy].special then
-				self.map(dx, dy, Map.TERRAIN, self.grid_list[self:resolve("down")])
+				self.map(dx, dy, Map.TERRAIN, self:resolve("down"))
 				self.map.room_map[dx][dy].special = "exit"
 				break
 			end
@@ -279,7 +288,7 @@ function _M:makeStairsInside(lev, old_lev, spots)
 	while true do
 		ux, uy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
 		if not self.map:checkEntity(ux, uy, Map.TERRAIN, "block_move") and not self.map.room_map[ux][uy].special then
-			self.map(ux, uy, Map.TERRAIN, self.grid_list[self:resolve("up")])
+			self.map(ux, uy, Map.TERRAIN, self:resolve("up"))
 			self.map.room_map[ux][uy].special = "exit"
 			break
 		end
@@ -303,7 +312,7 @@ function _M:makeStairsSides(lev, old_lev, sides, rooms, spots)
 			if not self.map.room_map[dx][dy].special then
 				local i = rng.range(1, #rooms)
 				self:tunnel(dx, dy, rooms[i].cx, rooms[i].cy, rooms[i].id)
-				self.map(dx, dy, Map.TERRAIN, self.grid_list[self:resolve("down")])
+				self.map(dx, dy, Map.TERRAIN, self:resolve("down"))
 				self.map.room_map[dx][dy].special = "exit"
 				break
 			end
@@ -322,7 +331,7 @@ function _M:makeStairsSides(lev, old_lev, sides, rooms, spots)
 		if not self.map.room_map[ux][uy].special then
 			local i = rng.range(1, #rooms)
 			self:tunnel(ux, uy, rooms[i].cx, rooms[i].cy, rooms[i].id)
-			self.map(ux, uy, Map.TERRAIN, self.grid_list[self:resolve("up")])
+			self.map(ux, uy, Map.TERRAIN, self:resolve("up"))
 			self.map.room_map[ux][uy].special = "exit"
 			break
 		end
@@ -334,7 +343,7 @@ end
 --- Make rooms and connect them with tunnels
 function _M:generate(lev, old_lev)
 	for i = 0, self.map.w - 1 do for j = 0, self.map.h - 1 do
-		self.map(i, j, Map.TERRAIN, self.grid_list[self:resolve("#")])
+		self.map(i, j, Map.TERRAIN, self:resolve("#"))
 	end end
 
 	local nb_room = self.data.nb_rooms or 10
diff --git a/game/modules/tome/class/Grid.lua b/game/modules/tome/class/Grid.lua
index 706e27ff3e..756675bed2 100644
--- a/game/modules/tome/class/Grid.lua
+++ b/game/modules/tome/class/Grid.lua
@@ -76,3 +76,28 @@ function _M:tooltip()
 	end
 end
 
+
+--- Generate sub entities to make nice trees
+function _M:makeTrees(base)
+	local function makeTree(nb, z, base)
+		nb = 4 - nb
+		return engine.Entity.new{
+			z = z,
+			display_scale = rng.float(0.5 + nb / 6, 1.3),
+			display_x = rng.range(-engine.Map.tile_w / 3 * nb / 3, engine.Map.tile_w / 3 * nb / 3),
+			display_y = rng.range(-engine.Map.tile_h / 3 * nb / 3, engine.Map.tile_h / 3 * nb / 3),
+			display_on_seen = true,
+			display_on_remember = true,
+			image = (base or "terrain/tree_alpha")..rng.range(1,3)..".png",
+		}
+	end
+
+	local v = rng.range(0, 100)
+	if v < 15 then
+		return { makeTree(3, 8), makeTree(3, 9), makeTree(3, 10), }
+	elseif v < 56 then
+		return { makeTree(2, 8), makeTree(2, 9), }
+	else
+		return { makeTree(1, 8), }
+	end
+end
diff --git a/game/modules/tome/data/general/grids/forest.lua b/game/modules/tome/data/general/grids/forest.lua
index 56cdddec56..3a84b25fb8 100644
--- a/game/modules/tome/data/general/grids/forest.lua
+++ b/game/modules/tome/data/general/grids/forest.lua
@@ -25,9 +25,11 @@ newEntity{
 
 newEntity{
 	define_as = "TREE",
-	name = "tree", image = "terrain/tree.png",
+	name = "tree",
+	image = "terrain/grass.png",
+	force_clone = true,
+	add_displays = resolvers.generic(function(e) return e:makeTrees("terrain/tree_alpha") end),
 	display = '#', color=colors.LIGHT_GREEN, back_color={r=44,g=95,b=43},
---	shader = "forest", textures = { {"image","terrain/tree_test2.png"}, function() return _3DNoise, true end },
 	always_remember = true,
 	can_pass = {pass_tree=1},
 	does_block_move = true,
@@ -43,7 +45,9 @@ newEntity{
 
 newEntity{
 	define_as = "TREE_DARK1",
-	name = "tree", image = "terrain/tree_dark1.png",
+	name = "tree", image = "terrain/grass_dark1.png",
+	force_clone = true,
+	add_displays = resolvers.generic(function(e) return e:makeTrees("terrain/tree_alpha") end),
 	display = '#', color=colors.GREEN, back_color={r=44,g=95,b=43},
 	always_remember = true,
 	can_pass = {pass_tree=1},
diff --git a/game/modules/tome/data/gfx/terrain/tree_alpha1.png b/game/modules/tome/data/gfx/terrain/tree_alpha1.png
new file mode 100644
index 0000000000000000000000000000000000000000..c81bfcdb5db734efc6d1ad3e8c88af742e93020d
GIT binary patch
literal 829
zcmV-D1H$}?P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800001b5ch_0Itp)
z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igW5
z3J@Ega<O0l00O;9L_t(o!|j$oNE=}o#(&Y^C8uHuqM^`;R7ju&3DqH?sa8s{v{Tzb
zibLp-(z>~qP&zu7LI!aVx9;N5R)x3-Qko$FOK6trwWO42(nzk?A$*s+%f<XDC={P1
z$@hKadEV!J-tP`BaDj7%qn*Q(aknPE?`?MjP<emkI1>SrakrM38>RPT7J%cP_3HXU
zPCwI$7)Lu*$EF7WnDBZ4*geRT%DMnZem&G(X-ABsm8t=HPi8spSvQdiVu0|-Fwu~#
z@4s37L1ka99?F#(@;I9*+&#!M<$1zpevJvQhg8<3liHmX`@smLhsppHaBGc3G<6_6
zGHhBilBY9e0)EM~pU#v`zY9s}-yB%D@eqK`{2HmOi`eu4sjQ3ZqrX|qC^})lFOkla
zDJgO_1Hyg)Uk46|>Z2jq)PDhM4ul&*pf#A4ebv?pN3-y)>=cQHWK*B50tA_ne0d{B
zNs)066)7olLjlfa;fsdWS=lMp^*=n~s#`M#G~ky=Q>+n<byKkk<Ebr(O%LcZZxojJ
z_=|L=%+tF*Q?<c}Y6@W?DVYV>xZr5z0!qw{)>*&2QM&<+LPQt~NeSne;bQ7E1EONP
zacndJR#f&?`om@0k!+ZOTd&e=#RE)uJuGGvpql7lL^aKONs-x80AzEu2K0x8IJNaL
z?4Rq>w&DTZ`sc5Yh;>~h@#hNw!HBAlm=I;XkOF>*z3po6+s=S<rcZnOvahc1Q=h#Y
zKK`j&ZgfPnLO4_BNUIqziqLPw`9V|gtR!OI#iwztQ2^U}A@R92W2&vyi9KO=E7iCC
zMue|6ngUDrW>|gqflsnlBQl;l<w4Za!^i~7pS`#<Zco&N)QGP0ektu(!1$o7<-UCf
z;L7kN#s_8XOa;t8x~+eox*7Z@5p84X*?sN7waXe8_#f~W@?4mv3&a1-00000NkvXX
Hu0mjf!o7e|

literal 0
HcmV?d00001

diff --git a/game/modules/tome/data/gfx/terrain/tree_alpha2.png b/game/modules/tome/data/gfx/terrain/tree_alpha2.png
new file mode 100644
index 0000000000000000000000000000000000000000..231b4f39819ae076c5a086ccb0064e95900a3b96
GIT binary patch
literal 777
zcmV+k1NQuhP)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800001b5ch_0Itp)
z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igW5
z3okF{+6CSK00N0gL_t(o!|hi+YujKDek45g7Zh8uMFn0<p@^UgS^_SZ7z$n7-2__5
z&?$@OZ2kxR1071If(iytvPqRLS)C|}WI5y)bX5oWUY)EjTQQ|WZn1Ro``&ZUJ$J7J
zJlYQIWQ4H)8DW*R@~%L9{Gg)>2zeLTANPmi-gv(q2zi@8S$;17+~pXS?VzP>pFpi@
zaPoCc9a^IUFL1E%fqQ?)08T~-yQUu9j2r=kd|IQE`2W);03f{n4e3E8;8|;p4zxxG
z$NeERC8B+P>i~%8cb8)Tz+MwDjR?fEmz!xpDg!_i1AsL>g&V9uv3ipa0PI<OeeVNh
zOh_A1pJBv6Th+xq0r6J9q=_OBwX)W7mt(OxXM@bL9cT(LIRjd&@+|zg95#wIQ7g(k
zFF3WGro^S77Np>tnp8$V56ZLVI+&a#*K;Py^iVj6)`QP)9Z`F#Gf@u!2m5hw>WVTp
z3g-Y1Ox9L)v{j`13m=%2u(0(g)*78uaLxqJey^Dwj2Ot94RT)niT>`ZVWQ8)0Alli
zQ{GaLI1|bkC@cXD9ugaMgvS7J0UqqfzD>J9&QrfNJw;p9MQ}GrPCVXv{F(rnMjAv`
z8FDqyR`t}h^H$jt%|#;fg0wHI6>C|GxbS%2b9EO5<e(~PfK$D`F>PoX(X(~+)AhPP
zZxH2*kk9mUTb%P^^KV}h=YJ~Ob31-sbReYwShgeTOc}2hhdi54Zx3;E72xOfMP>pl
zVByP2>H&YLoPEz;*fZ+k>o+d|05?|wroS$6;r)?N!BPz51?Bc*b|(P{j|LG753x$G
z<vpVw9t{pLckhJndF#o)`7r4j^$-Bw4ZcW}eO3A&?Z2?U+$3bFGm0BZ00000NkvXX
Hu0mjf=v_*5

literal 0
HcmV?d00001

diff --git a/game/modules/tome/data/gfx/terrain/tree_alpha3.png b/game/modules/tome/data/gfx/terrain/tree_alpha3.png
new file mode 100644
index 0000000000000000000000000000000000000000..3cb5f05f8462385e8ec7d6ce2c445060971378de
GIT binary patch
literal 1016
zcmV<U0|)$xP)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800001b5ch_0Itp)
z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igW5
z3os$gI3`B`00VeQL_t(o!|j$mXd_n?g}<>J7)>)`2#j!yehfinz>pxB6cR$VF#&^%
zUDXRA5OB4yslt*rkjl+E5ErSG#$ZTcTL`&WY>~pfnw4a<i^T>ZHRCa1cT$Y*lg75R
zk~btp_BQkPm~-yA=f3;kL;T-En`QCFUc#%jI`k_R0B@eZ)Br+Xe&UTj&l2;~EV7=4
zy>#4WC%?((dq3kXIz&<~eSBau-vv<5vk=jy0WW4v9xpuv;HMYA0q}U~A)kKtt52k2
zDN?<<j@CA&CNVcjZn<BM`jS_jGR=mr$gHoL^y>Ohfr>>W<*I*3X=YYnV=v)}+{LU(
zv!UNwb9mfmeboe@*6L8qnv_oZLw{UcF}LFJ_Edw5t~NCR0k1k`&M&(v+p1G0XB5<X
zKoLtMU78JDT>*~v{!&CH5xCQY0@7^gu;kah+0Y?VR=_*?O{&o{Pf88ICXsY`wtEd+
z4>B{}2|l(2*3+=}V=*}-F$l?UD`Su|3d)eBlfGKhtLv<<nn49%ERnf!;5nlJz)pUX
zt&9->Kfmm<T{%!{q~kWltZ&Fj%H{CbC*&<UgkoVru`t9e@0|n$Ttc!JB@#)OoKavo
zYAHgsRtJD*yVq!K1As`%#anc^cN>byr0<1Dv!PRU$^mlH1(B4CneUR0+e!%uQQ|HY
z0tC`=o19TlKwB9<Be@E>{WFJJtE1Ylm^D@XMFF|L*H*lhG1xzINF-gBqZT=%KrTO2
zLu60KZNQ~;(pNj6Uw<E5N}{#LcSJyeTC1b_U1I;tujO{-K=~jYw@JrsYOM~t--lGz
zYmYu6l5!QW#H4n-(*xU;0}@F$-~)MHj#`0|c#96bx=yd|E7Pm%QycIWf$k4i+LKZv
zu%ij^sOioxy9#W5)eIPJG=#{cHk`j}@(FP1q>r>^v*8SCZ*zEj4fx<f<fidP%P^?~
z^EVYJfhXft%;ayk{<N#*JL>)6aUZR1p#i-yz@b?9p67v><;|@GRg>u_+pI`@({zEX
zW0p5*9*jK?2=lk6+O07x;9A>Y<03pBe8LQv?nE?TF9!<&mH1}iV|HKt83djJbow*l
z;74zszZ^)Z0awHC3nQR20>4*$``|P0;FqtxuT~bk_x+c4AMmxcFE~2-!%w>Xn%_@f
m{X3bDk^uN86!;MTdHfCT2kUjSedYxK0000<MNUMnLSTZ{7t)RZ

literal 0
HcmV?d00001

diff --git a/src/core_lua.c b/src/core_lua.c
index afa923e557..e4431da33a 100644
--- a/src/core_lua.c
+++ b/src/core_lua.c
@@ -1012,7 +1012,7 @@ static int sdl_texture_outline(lua_State *L)
 	glMatrixMode(GL_PROJECTION);
 	CHECKGL(glPushMatrix());
 	glLoadIdentity();
-	glOrtho(0, w, 0, h, -100, 100);
+	glOrtho(0, w, 0, h, -101, 101);
 	glMatrixMode( GL_MODELVIEW );
 
 	/* Reset The View */
@@ -1160,7 +1160,7 @@ static int gl_fbo_use(lua_State *L)
 		glMatrixMode(GL_PROJECTION);
 		glPushMatrix();
 		glLoadIdentity();
-		glOrtho(0, fbo->w, fbo->h, 0, -100, 100);
+		glOrtho(0, fbo->w, fbo->h, 0, -101, 101);
 		glMatrixMode(GL_MODELVIEW);
 
 		// Reset The View
diff --git a/src/main.c b/src/main.c
index a33c7344c4..1af0b2131f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -270,7 +270,7 @@ void on_redraw()
 	static int Frames = 0;
 	static int T0     = 0;
 
-	glClear( GL_COLOR_BUFFER_BIT);
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 	glLoadIdentity();
 
 	if (current_game != LUA_NOREF)
@@ -378,13 +378,11 @@ int initGL()
 	glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
 
 	/* Depth buffer setup */
-//	glClearDepth( 1.0f );
-
-	/* Enables Depth Testing */
-//	glEnable( GL_DEPTH_TEST );
+	glClearDepth( 1.0f );
 
 	/* The Type Of Depth Test To Do */
-//	glDepthFunc( GL_LEQUAL );
+	glDepthFunc(GL_LEQUAL);
+//	glDepthFunc(GL_LESS);
 
 	/* Really Nice Perspective Calculations */
 	//	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
@@ -424,7 +422,7 @@ int resizeWindow(int width, int height)
 
 	/* Set our perspective */
 	//gluPerspective( 45.0f, ratio, 0.1f, 100.0f );
-	glOrtho(0, width, height, 0, -100, 100);
+	glOrtho(0, width, height, 0, -101, 101);
 
 	/* Make sure we're chaning the model view and not the projection */
 	glMatrixMode( GL_MODELVIEW );
diff --git a/src/map.c b/src/map.c
index 59edfe906f..46b0b4730b 100644
--- a/src/map.c
+++ b/src/map.c
@@ -44,7 +44,14 @@ static int map_object_new(lua_State *L)
 	obj->textures_is3d = calloc(nb_textures, sizeof(bool));
 	obj->nb_textures = nb_textures;
 
+	obj->on_seen = lua_toboolean(L, 2);
+	obj->on_remember = lua_toboolean(L, 3);
+	obj->on_unknown = lua_toboolean(L, 4);
+
 	obj->valid = TRUE;
+	obj->dx = luaL_checknumber(L, 5);
+	obj->dy = luaL_checknumber(L, 6);
+	obj->scale = luaL_checknumber(L, 7);
 	obj->shader = 0;
 	obj->tint_r = obj->tint_g = obj->tint_b = 1;
 	for (i = 0; i < nb_textures; i++)
@@ -136,7 +143,7 @@ static int map_new(lua_State *L)
 	int mheight = luaL_checknumber(L, 6);
 	int tile_w = luaL_checknumber(L, 7);
 	int tile_h = luaL_checknumber(L, 8);
-	bool multidisplay = lua_toboolean(L, 9);
+	int zdepth = luaL_checknumber(L, 9);
 
 	map_type *map = (map_type*)lua_newuserdata(L, sizeof(map_type));
 	auxiliar_setclass(L, "core{map}", -1);
@@ -149,75 +156,51 @@ static int map_new(lua_State *L)
 	map->mm_floor = map->mm_block = map->mm_object = map->mm_trap = map->mm_friend = map->mm_neutral = map->mm_hostile = map->mm_level_change = 0;
 	map->minimap_gridsize = 4;
 
-	map->multidisplay = multidisplay;
 	map->w = w;
 	map->h = h;
+	map->zdepth = zdepth;
 	map->tile_w = tile_w;
 	map->tile_h = tile_h;
 	map->mx = mx;
 	map->my = my;
 	map->mwidth = mwidth;
 	map->mheight = mheight;
-	map->grids_terrain = calloc(w, sizeof(map_object**));
-	map->grids_actor = calloc(w, sizeof(map_object**));
-	map->grids_trap = calloc(w, sizeof(map_object**));
-	map->grids_object = calloc(w, sizeof(map_object**));
+	map->grids= calloc(w, sizeof(map_object***));
 	map->grids_seens = calloc(w, sizeof(float*));
 	map->grids_remembers = calloc(w, sizeof(bool*));
 	map->grids_lites = calloc(w, sizeof(bool*));
 	map->minimap = calloc(w, sizeof(unsigned char*));
 	printf("C Map size %d:%d :: %d\n", mwidth, mheight,mwidth * mheight);
 
-	int i;
+	int i, j;
 	for (i = 0; i < w; i++)
 	{
-		map->grids_terrain[i] = calloc(h, sizeof(map_object*));
-		map->grids_actor[i] = calloc(h, sizeof(map_object*));
-		map->grids_object[i] = calloc(h, sizeof(map_object*));
-		map->grids_trap[i] = calloc(h, sizeof(map_object*));
+		map->grids[i] = calloc(h, sizeof(map_object**));
+		for (j = 0; j < h; j++) map->grids[i][j] = calloc(zdepth, sizeof(map_object*));
 		map->grids_seens[i] = calloc(h, sizeof(float));
 		map->grids_remembers[i] = calloc(h, sizeof(bool));
 		map->grids_lites[i] = calloc(h, sizeof(bool));
 		map->minimap[i] = calloc(h, sizeof(unsigned char));
 	}
 
-
-	/* New compiled box display list */
-	/*
-	map->dlist = glGenLists(1);
-	glNewList(map->dlist, GL_COMPILE);
-		glBegin(GL_QUADS);
-		glTexCoord2f(0,0); glVertex2f(0  , 0  );
-		glTexCoord2f(0,1); glVertex2f(0  , 16 );
-		glTexCoord2f(1,1); glVertex2f(16 , 16 );
-		glTexCoord2f(1,0); glVertex2f(16 , 0  );
-		glEnd();
-	glEndList();
-	*/
-
 	return 1;
 }
 
 static int map_free(lua_State *L)
 {
 	map_type *map = (map_type*)auxiliar_checkclass(L, "core{map}", 1);
-	int i;
+	int i, j;
 
 	for (i = 0; i < map->w; i++)
 	{
-		free(map->grids_terrain[i]);
-		free(map->grids_actor[i]);
-		free(map->grids_trap[i]);
-		free(map->grids_object[i]);
+		for (j = 0; j < map->h; j++) free(map->grids[i][j]);
+		free(map->grids[i]);
 		free(map->grids_seens[i]);
 		free(map->grids_remembers[i]);
 		free(map->grids_lites[i]);
 		free(map->minimap[i]);
 	}
-	free(map->grids_terrain);
-	free(map->grids_actor);
-	free(map->grids_object);
-	free(map->grids_trap);
+	free(map->grids);
 	free(map->grids_seens);
 	free(map->grids_remembers);
 	free(map->grids_lites);
@@ -305,19 +288,17 @@ static int map_set_grid(lua_State *L)
 	map_type *map = (map_type*)auxiliar_checkclass(L, "core{map}", 1);
 	int x = luaL_checknumber(L, 2);
 	int y = luaL_checknumber(L, 3);
-
-	map_object *g = lua_isnil(L, 4) ? NULL : (map_object*)auxiliar_checkclass(L, "core{mapobj}", 4);
-	map_object *t = lua_isnil(L, 5) ? NULL : (map_object*)auxiliar_checkclass(L, "core{mapobj}", 5);
-	map_object *o = lua_isnil(L, 6) ? NULL : (map_object*)auxiliar_checkclass(L, "core{mapobj}", 6);
-	map_object *a = lua_isnil(L, 7) ? NULL : (map_object*)auxiliar_checkclass(L, "core{mapobj}", 7);
-	unsigned char mm = lua_tonumber(L, 8);
-
 	if (x < 0 || y < 0 || x >= map->w || y >= map->h) return 0;
+	unsigned char mm = lua_tonumber(L, 4);
 
-	map->grids_terrain[x][y] = g ? g : 0;
-	map->grids_trap[x][y] = t ? t : 0;
-	map->grids_actor[x][y] = a ? a : 0;
-	map->grids_object[x][y] = o ? o : 0;
+	int i;
+	for (i = 0; i < map->zdepth; i++)
+	{
+		lua_pushnumber(L, i + 1);
+		lua_gettable(L, -2);
+		map->grids[x][y][i] = lua_isnoneornil(L, -1) ? NULL : (map_object*)auxiliar_checkclass(L, "core{mapobj}", -1);
+		lua_pop(L, 1);
+	}
 
 	map->minimap[x][y] = mm;
 	return 0;
@@ -403,8 +384,17 @@ static int map_set_scroll(lua_State *L)
 	return 0;
 }
 
-inline void display_map_quad(map_type *map, int dx, int dy, map_object *m, int i, int j, float a, bool obscure) ALWAYS_INLINE;
-void display_map_quad(map_type *map, int dx, int dy, map_object *m, int i, int j, float a, bool obscure)
+#define DO_QUAD(dx, dy, dz, zoom) {\
+		glBegin(GL_QUADS); \
+		glTexCoord2f(0,0); glVertex3f((dx), (dy),				(dz)); \
+		glTexCoord2f(1,0); glVertex3f(map->tile_w * (zoom) + (dx), (dy),			(dz)); \
+		glTexCoord2f(1,1); glVertex3f(map->tile_w * (zoom) + (dx), map->tile_h * (zoom) + (dy),	(dz)); \
+		glTexCoord2f(0,1); glVertex3f((dx), map->tile_h * (zoom) + (dy),			(dz)); \
+		glEnd(); }
+
+
+inline void display_map_quad(map_type *map, int dx, int dy, float dz, map_object *m, int i, int j, float a, bool obscure) ALWAYS_INLINE;
+void display_map_quad(map_type *map, int dx, int dy, float dz, map_object *m, int i, int j, float a, bool obscure)
 {
 	float r, g, b;
 	if (!obscure)
@@ -430,6 +420,7 @@ void display_map_quad(map_type *map, int dx, int dy, map_object *m, int i, int j
 		}
 	}
 	glColor4f(r, g, b, a);
+
 	int z;
 	if (m->shader) useShader(m->shader, i, j, map->tile_w, map->tile_h, r, g, b, a);
 	for (z = (!shaders_active) ? 0 : (m->nb_textures - 1); z >= 0; z--)
@@ -437,12 +428,8 @@ void display_map_quad(map_type *map, int dx, int dy, map_object *m, int i, int j
 		if (multitexture_active && shaders_active) glActiveTexture(GL_TEXTURE0+z);
 		glBindTexture(m->textures_is3d[z] ? GL_TEXTURE_3D : GL_TEXTURE_2D, m->textures[z]);
 	}
-	glBegin(GL_QUADS);
-	glTexCoord2f(0,0); glVertex3f(0  +dx, 0  +dy,-99);
-	glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0  +dy,-99);
-	glTexCoord2f(1,1); glVertex3f(map->tile_w +dx, map->tile_h +dy,-99);
-	glTexCoord2f(0,1); glVertex3f(0  +dx, map->tile_h +dy,-99);
-	glEnd();
+	DO_QUAD(dx + m->dx, dy + m->dy, z, m->scale);
+
 	if (m->shader) glUseProgramObjectARB(0);
 }
 
@@ -451,56 +438,34 @@ static int map_to_screen(lua_State *L)
 	map_type *map = (map_type*)auxiliar_checkclass(L, "core{map}", 1);
 	int x = luaL_checknumber(L, 2);
 	int y = luaL_checknumber(L, 3);
-	int i = 0, j = 0;
-	float a;
+	int i = 0, j = 0, z = 0;
 
-	for (i = map->mx; i < map->mx + map->mwidth; i++)
+	/* Enables Depth Testing */
+	glEnable(GL_DEPTH_TEST);
+
+	for (z = 0; z < map->zdepth; z++)
 	{
-		for (j = map->my; j < map->my + map->mheight; j++)
+		for (i = map->mx; i < map->mx + map->mwidth; i++)
 		{
-			if ((i < 0) || (j < 0) || (i >= map->w) || (j >= map->h)) continue;
+			for (j = map->my; j < map->my + map->mheight; j++)
+			{
+				if ((i < 0) || (j < 0) || (i >= map->w) || (j >= map->h)) continue;
 
-			int dx = x + (i - map->mx) * map->tile_w;
-			int dy = y + (j - map->my) * map->tile_h;
+				int dx = x + (i - map->mx) * map->tile_w;
+				int dy = y + (j - map->my) * map->tile_h;
+				map_object *mo = map->grids[i][j][z];
+				if (!mo) continue;
 
-			if (map->grids_seens[i][j] || map->grids_remembers[i][j])
-			{
-				if (map->grids_seens[i][j])
+				if ((mo->on_seen && map->grids_seens[i][j]) || (mo->on_remember && map->grids_remembers[i][j]) || mo->on_unknown)
 				{
-					a = map->shown_a * map->grids_seens[i][j];
-					if (map->multidisplay)
+					if (map->grids_seens[i][j])
 					{
-						if (map->grids_terrain[i][j]) display_map_quad(map, dx, dy, map->grids_terrain[i][j], i, j, a, FALSE);
-						if (map->grids_trap[i][j]) display_map_quad(map, dx, dy, map->grids_trap[i][j], i, j, a, FALSE);
-						if (map->grids_object[i][j]) display_map_quad(map, dx, dy, map->grids_object[i][j], i, j, a, FALSE);
-						if (map->grids_actor[i][j]) display_map_quad(map, dx, dy, map->grids_actor[i][j], i, j, a, FALSE);
+						display_map_quad(map, dx, dy, z, mo, i, j, map->shown_a * map->grids_seens[i][j], FALSE);
 					}
 					else
 					{
-						if (map->grids_actor[i][j]) display_map_quad(map, dx, dy, map->grids_actor[i][j], i, j, a, FALSE);
-						else if (map->grids_object[i][j]) display_map_quad(map, dx, dy, map->grids_object[i][j], i, j, a, FALSE);
-						else if (map->grids_trap[i][j]) display_map_quad(map, dx, dy, map->grids_trap[i][j], i, j, a, FALSE);
-						else if (map->grids_terrain[i][j]) display_map_quad(map, dx, dy, map->grids_terrain[i][j], i, j, a, FALSE);
-					}
-				}
-				else
-				{
-					a = map->obscure_a;
-					if (map->grids_terrain[i][j]) display_map_quad(map, dx, dy, map->grids_terrain[i][j], i, j, a, TRUE);
-					/*
-					a = map->obscure_a;
-					if (map->multidisplay)
-					{
-						if (map->grids_terrain[i][j]) display_map_quad(map, dx, dy, map->grids_terrain[i][j], i, j, a, TRUE);
-						if (map->grids_trap[i][j]) display_map_quad(map, dx, dy, map->grids_trap[i][j], i, j, a, TRUE);
-						if (map->grids_object[i][j]) display_map_quad(map, dx, dy, map->grids_object[i][j], i, j, a, TRUE);
+						display_map_quad(map, dx, dy, z, mo, i, j, map->obscure_a, TRUE);
 					}
-					else
-					{
-						if (map->grids_object[i][j]) display_map_quad(map, dx, dy, map->grids_object[i][j], i, j, a, TRUE);
-						else if (map->grids_trap[i][j]) display_map_quad(map, dx, dy, map->grids_trap[i][j], i, j, a, TRUE);
-						else if (map->grids_terrain[i][j]) display_map_quad(map, dx, dy, map->grids_terrain[i][j], i, j, a, TRUE);
-					}*/
 				}
 			}
 		}
@@ -508,11 +473,17 @@ static int map_to_screen(lua_State *L)
 
 	// Restore normal display
 	glColor4f(1, 1, 1, 1);
+
+	/* Disables Depth Testing, we do not need it for the rest of the display */
+	glDisable(GL_DEPTH_TEST);
+
 	return 0;
 }
 
 static int minimap_to_screen(lua_State *L)
 {
+	return 0;
+#if 0
 	map_type *map = (map_type*)auxiliar_checkclass(L, "core{map}", 1);
 	int x = luaL_checknumber(L, 2);
 	int y = luaL_checknumber(L, 3);
@@ -659,6 +630,7 @@ static int minimap_to_screen(lua_State *L)
 	// Restore normal display
 	glColor4f(1, 1, 1, 1);
 	return 0;
+#endif
 }
 
 static const struct luaL_reg maplib[] =
diff --git a/src/map.h b/src/map.h
index bf3f823d86..664e389a1c 100644
--- a/src/map.h
+++ b/src/map.h
@@ -28,17 +28,18 @@ typedef struct {
 	GLuint *textures;
 	bool *textures_is3d;
 	GLuint shader;
+	float dx, dy, scale;
 	float tint_r;
 	float tint_g;
 	float tint_b;
+	bool on_seen;
+	bool on_remember;
+	bool on_unknown;
 	bool valid;
 } map_object;
 
 typedef struct {
-	map_object* **grids_terrain;
-	map_object* **grids_actor;
-	map_object* **grids_object;
-	map_object* **grids_trap;
+	map_object* ***grids;
 	float **grids_seens;
 	bool **grids_remembers;
 	bool **grids_lites;
@@ -47,8 +48,6 @@ typedef struct {
 
 	int minimap_gridsize;
 
-	bool multidisplay;
-
 	// Map parameters
 	float obscure_r, obscure_g, obscure_b, obscure_a;
 	float shown_r, shown_g, shown_b, shown_a;
@@ -56,6 +55,7 @@ typedef struct {
 	// Map size
 	int w;
 	int h;
+	int zdepth;
 	int tile_w, tile_h;
 
 	// Scrolling
diff --git a/src/sdnoise1234.c b/src/sdnoise1234.c
index f95a8be8cf..21117d917f 100644
--- a/src/sdnoise1234.c
+++ b/src/sdnoise1234.c
@@ -146,7 +146,7 @@ static unsigned char simplex[64][4] = {
  * and gradients-dot-residualvectors in 2D to 4D.
  */
 
-float grad1( int hash, float *gx ) {
+void grad1( int hash, float *gx ) {
 	int h = hash & 15;
 	*gx = 1.0f + (h & 7);   // Gradient value is one of 1.0, 2.0, ..., 8.0
 	if (h&8) *gx = - *gx;   // Make half of the gradients negative
-- 
GitLab