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

fixed crash with no music found

git-svn-id: http://svn.net-core.org/repos/t-engine4@633 51575b47-30f0-44d4-a5cc-537603b46e54
parent eaa702e0
No related branches found
No related tags found
No related merge requests found
......@@ -40,11 +40,10 @@ function _M:init(actor)
ACCEPT = function() self:use() end,
})
self:mouseZones{
{ x=2, y=45, w=350, h=self.font_h*self.max, fct=function(button, x, y, xrel, yrel, tx, ty)
{ x=2, y=10 + self.font:lineSkip()*6, w=350, h=self.font_h*self.max, fct=function(button, x, y, xrel, yrel, tx, ty)
self.changed = true
self.sel = util.bound(self.scroll + math.floor(ty / self.font_h), 1, #self.list)
if button == "left" then self:learn(true)
elseif button == "right" then self:learn(false)
if button == "left" then self:use()
end
self.changed = true
end },
......@@ -57,6 +56,7 @@ function _M:cleanActor()
-- Go through all spell effects
for eff_id, p in pairs(self.actor.tmp) do
local e = self.actor.tempeffect_def[eff_id]
effs[#effs+1] = {"effect", eff_id}
end
......
......@@ -42,6 +42,7 @@ static int music_new(lua_State *L)
SDL_RWops *rops = PHYSFSRWOPS_openRead(name);
if (!rops)
{
*m = NULL;
return 0;
}
*m = Mix_LoadMUS_RW(rops);
......@@ -53,7 +54,7 @@ static int music_new(lua_State *L)
static int music_free(lua_State *L)
{
Mix_Music **m = (Mix_Music**)auxiliar_checkclass(L, "core{music}", 1);
Mix_FreeMusic(*m);
if (*m) Mix_FreeMusic(*m);
lua_pushnumber(L, 1);
return 1;
}
......@@ -98,6 +99,7 @@ static int sound_new(lua_State *L)
SDL_RWops *rops = PHYSFSRWOPS_openRead(name);
if (!rops)
{
*m = NULL;
return 0;
}
*m = Mix_LoadWAV_RW(rops, 1);
......@@ -110,7 +112,7 @@ static int sound_new(lua_State *L)
static int sound_free(lua_State *L)
{
Mix_Chunk **m = (Mix_Chunk**)auxiliar_checkclass(L, "core{sound}", 1);
Mix_FreeChunk(*m);
if (*m) Mix_FreeChunk(*m);
lua_pushnumber(L, 1);
return 1;
}
......
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