Skip to content
Snippets Groups Projects
Commit b2384b24 authored by dg's avatar dg
Browse files

Savefiles are marked as dead as soon as death happens

git-svn-id: http://svn.net-core.org/repos/t-engine4@4039 51575b47-30f0-44d4-a5cc-537603b46e54
parent 74da7e25
No related branches found
No related tags found
No related merge requests found
......@@ -165,10 +165,17 @@ end
--- Returns the player
-- Reimplement it in your module, this can just return nil if you dont want/need
-- the engine adjusting stuff to the player or if you have many players or whatever
function _M:getPlayer()
-- @param main if true the game should try to return the "main" player, if any
function _M:getPlayer(main)
return nil
end
--- Says if this savefile is usable or not
-- Reimplement it in your module, returning false when the player is dead
function _M:isLoadable()
return true
end
--- Gets/increment the savefile version
-- @param token if "new" this will create a new allowed save token and return it. Otherwise this checks the token against the allowed ones and returns true if it is allowed
function _M:saveVersion(token)
......
......@@ -229,6 +229,7 @@ function _M:saveGame(game, no_dialog)
f:write(("name = %q\n"):format(desc.name))
f:write(("short_name = %q\n"):format(self.short_name))
f:write(("timestamp = %d\n"):format(os.time()))
f:write(("loadable = %s\n"):format(game:isLoadable() and "true" or "false"))
f:write(("description = %q\n"):format(desc.description))
f:close()
......
......@@ -47,7 +47,7 @@ function _M:init()
for j, save in ipairs(m.savefiles) do
local mod_string = ("%s-%d.%d.%d"):format(m.short_name, save.module_version and save.module_version[1] or -1, save.module_version and save.module_version[2] or -1, save.module_version and save.module_version[3] or -1)
local mod = list[mod_string]
if mod then
if mod and save.loadable then
save.fct = function()
Module:instanciate(mod, save.name, false)
end
......
......@@ -180,6 +180,11 @@ function _M:getPlayer()
return self.player
end
--- Says if this savefile is usable or not
function _M:isLoadable()
return not self:getPlayer(true).dead
end
function _M:tick()
if self.level then
self:targetOnTick()
......
......@@ -180,6 +180,11 @@ function _M:getPlayer()
return self.player
end
--- Says if this savefile is usable or not
function _M:isLoadable()
return not self:getPlayer(true).dead
end
function _M:tick()
if self.level then
self:targetOnTick()
......
......@@ -167,7 +167,7 @@ function _M:run()
self:setupMouse()
-- Starting from here we create a new game
if not self.player then self:newGame() end
if not self.player or self.player.dead then util.showMainMenu() end
self:initTargeting()
......@@ -743,6 +743,11 @@ function _M:getPlayer(main)
end
end
--- Says if this savefile is usable or not
function _M:isLoadable()
return not self:getPlayer(true).dead
end
--- Clones the game world for chronomancy spells
function _M:chronoClone(name)
local d = Dialog:simplePopup("Chronomancy", "Folding the space time structure...")
......
......@@ -35,6 +35,7 @@ function _M:init(actor)
self:generateList()
if self.dont_show then return end
game:saveGame()
self.c_desc = Textzone.new{width=self.iw, auto_height=true, text=[[You have #LIGHT_RED#died#LAST#!
Death in ToME is usually permanent, but if you have a means of resurrection it will be proposed in the menu below.
......@@ -160,6 +161,7 @@ function _M:eidolonPlane()
game.log("#LIGHT_RED#From the brink of death you seem to be yanked to another plane.")
game.player:updateMainShader()
game:saveGame()
end)
return true
end
......@@ -169,10 +171,6 @@ function _M:use(item)
local act = item.action
if act == "exit" then
local save = Savefile.new(game.save_name)
save:delete()
save:close()
world:saveWorld()
if item.subaction == "none" then
util.showMainMenu()
elseif item.subaction == "restart" then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment