diff --git a/game/engines/default/engine/Map.lua b/game/engines/default/engine/Map.lua index 362a6b681f5356c3ce30eceb0dcf51fc5af05dce..e57ebbb082f250f17817c93925dd499e448f6752 100644 --- a/game/engines/default/engine/Map.lua +++ b/game/engines/default/engine/Map.lua @@ -885,6 +885,47 @@ function _M:import(map, dx, dy, sx, sy, sw, sh) self.seens(x, y, map.seens(i, j)) self.lites(x, y, map.lites(i, j)) + self:updateMap(x, y) + end end + + self.changed = true +end + +--- Import a map into the current one as an overlay, only replacing defined entities +-- @param map the map to import +-- @param dx coordinate where to import it in the current map +-- @param dy coordinate where to import it in the current map +-- @param sx coordinate where to start importing the map, defaults to 0 +-- @param sy coordinate where to start importing the map, defaults to 0 +-- @param sw size of the imported map to get, defaults to map size +-- @param sh size of the imported map to get, defaults to map size +function _M:overlay(map, dx, dy, sx, sy, sw, sh) + sx = sx or 0 + sy = sy or 0 + sw = sw or map.w + sh = sh or map.h + + for i = sx, sx + sw - 1 do for j = sy, sy + sh - 1 do + local x, y = dx + i, dy + j + + if map.attrs[i + j * map.w] then + self.attrs[x + y * self.w] = self.attrs[x + y * self.w] or {} + table.merge(self.attrs[x + y * self.w], map.attrs[i + j * map.w] or {}) + end + for z, e in pairs(map.map[i + j * map.w] or {}) do + self.map[x + y * self.w][z] = map.map[i + j * map.w][z] + if e.move then + e.x = nil e.y = nil e:move(x, y, true) + end + end + + if self.room_map then + self.room_map[x] = self.room_map[x] or {} + table.merge(self.room_map[x][y], map.room_map[i][j] or {}) + end + self.remembers(x, y, map.remembers(i, j)) + self.seens(x, y, map.seens(i, j)) + self.lites(x, y, map.lites(i, j)) self:updateMap(x, y) end end diff --git a/game/engines/default/engine/generator/map/Static.lua b/game/engines/default/engine/generator/map/Static.lua index 4d503ec0304461f39fb795b75470f3a5751154a9..92469c652b2230d3ce9b2dad1a52f53352366f2e 100644 --- a/game/engines/default/engine/generator/map/Static.lua +++ b/game/engines/default/engine/generator/map/Static.lua @@ -275,7 +275,7 @@ function _M:generate(lev, old_lev) end end end - self:triggerHook{"mapGeneratorStatic:subgenRegister", mapfile=self.data.map, list=self.subgen} + self:triggerHook{"MapGeneratorStatic:subgenRegister", mapfile=self.data.map, list=self.subgen} for i = 1, #self.subgen do local g = self.subgen[i] @@ -293,7 +293,11 @@ function _M:generate(lev, old_lev) ) local ux, uy, dx, dy, subspots = generator:generate(lev, old_lev) - self.map:import(map, g.x, g.y) + if g.overlay then + self.map:overlay(map, g.x, g.y) + else + self.map:import(map, g.x, g.y) + end table.append(self.spots, subspots) diff --git a/game/engines/default/engine/utils.lua b/game/engines/default/engine/utils.lua index 897153c94fea34a04496f3efae8110c927070ab5..f604ac360009f9d8a8beba6afa57fb4e552d4a21 100644 --- a/game/engines/default/engine/utils.lua +++ b/game/engines/default/engine/utils.lua @@ -28,6 +28,18 @@ function lpeg.anywhere (p) return lpeg.P{ p + 1 * lpeg.V(1) } end +function table.concatNice(t, sep, endsep) + if not endsep then return table.concat(t, sep) end + local str = "" + for i, s in ipairs(t) do + if i == #t then str = str..endsep..s + elseif i == 1 then str = s + else str = str..sep..s + end + end + return str +end + function table.min(t) local m = nil for _, v in pairs(t) do diff --git a/game/modules/tome/data/zones/shertul-fortress/zone.lua b/game/modules/tome/data/zones/shertul-fortress/zone.lua index 6c20bfd838bae71fbc330ff645e04aa238aca2eb..e81b2c30db5d79823f3391e116b00c36382a0f2d 100644 --- a/game/modules/tome/data/zones/shertul-fortress/zone.lua +++ b/game/modules/tome/data/zones/shertul-fortress/zone.lua @@ -21,7 +21,7 @@ return { name = "Yiilkgur, the Sher'Tul Fortress", display_name = function(x, y) local zn = game.level.map.attrs(x or game.player.x, y or game.player.y, "zonename") - if zn then return "Yiilkgur, the Sher'Tul Fortress ("..zn..")" + if zn then return zn.." (Yiilkgur, the Sher'Tul Fortress)" else return "Yiilkgur, the Sher'Tul Fortress" end end, variable_zone_name = true, diff --git a/game/modules/tome/dialogs/Donation.lua b/game/modules/tome/dialogs/Donation.lua index 3b670c2bbeda5c6721dfbd2789b4f2f09e9faf6d..7fe9e0cae065b5b92df70b0dc6e21d64ae7e0466 100644 --- a/game/modules/tome/dialogs/Donation.lua +++ b/game/modules/tome/dialogs/Donation.lua @@ -38,6 +38,9 @@ function _M:init(source) local recur = false if not profile.auth or not tonumber(profile.auth.donated) or tonumber(profile.auth.donated) <= 1 then + local donation_features = { "#GOLD#Custom character tiles#WHITE#", "#GOLD#Exploration mode (infinite lives)#WHITE#"} + self:triggerHook{"DonationDialog:features", list=donation_features} + -- First time donation desc = Textzone.new{width=self.iw, auto_height=true, text=[[Hi, I am Nicolas (DarkGod), the maker of this game. It is my dearest hope that you find my game enjoyable, and that you will continue to do so for many years to come! @@ -45,7 +48,7 @@ It is my dearest hope that you find my game enjoyable, and that you will continu ToME is free and open-source and will stay that way, but that does not mean I can live without money, so I have come to disturb you here and now to ask for your kindness. If you feel that the (many) hours you have spent having fun were worth it, please consider making a donation for the future of the game. -Donators are also granted a few special features: #GOLD#Custom character tiles#WHITE# and #GOLD#Exploration mode (infinite lives)#WHITE#.]]} +Donators are also granted a few special features: ]]..table.concatNice(donation_features, ", ", " and ").."."} else -- Recurring donation recur = true