diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-10-17 23:41:13 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-10-19 22:25:49 +0200 |
commit | 210e33c8b32f3bbc696e5ffd1affef65a7d66b5d (patch) | |
tree | 2b9eb5447860e7ea92c8ec378ebe03d8ddf8636e /example/serverdata | |
parent | 943fdc0eb7237790a469a81fba4c914f9e085977 (diff) | |
download | manaserv-210e33c8b32f3bbc696e5ffd1affef65a7d66b5d.tar.gz manaserv-210e33c8b32f3bbc696e5ffd1affef65a7d66b5d.tar.bz2 manaserv-210e33c8b32f3bbc696e5ffd1affef65a7d66b5d.tar.xz manaserv-210e33c8b32f3bbc696e5ffd1affef65a7d66b5d.zip |
Prevent server crash by not having beings talk after spawn for now
At the moment it is the responsibility of the script to make sure any
references to beings passed into script functions are valid.
This means you can't schedule delayed scripts like the one making
maggots say 'Roaaarrrr!!!', since the being might have been removed
before the script gets executed. In the case of this bug the maggots are
removed by some script code testing 'mana.monster_remove'.
We should of course fix the way actor handles are used in Lua so that
scripts can't end up crashing the server.
Mantis-issue: 384
Reviewed-by: Yohann Ferreira
Diffstat (limited to 'example/serverdata')
-rw-r--r-- | example/serverdata/scripts/maps/desert.lua | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/example/serverdata/scripts/maps/desert.lua b/example/serverdata/scripts/maps/desert.lua index d11be2fb..57b4533d 100644 --- a/example/serverdata/scripts/maps/desert.lua +++ b/example/serverdata/scripts/maps/desert.lua @@ -91,17 +91,22 @@ function Tamer(npc, ch, list) mana.being_say(npc, "I will now spawn a monster for your training session.") -- Remove monsters in the area - for i, b in ipairs(mana.get_beings_in_rectangle( - mana.posX(npc) - 3 * TILESIZE, mana.posY(npc) - 3 * TILESIZE, - 6 * TILESIZE, 6 * TILESIZE)) do + for i, b in ipairs(mana.get_beings_in_rectangle(mana.posX(npc) - 3 * TILESIZE, + mana.posY(npc) - 3 * TILESIZE, + 6 * TILESIZE, 6 * TILESIZE)) do if mana.being_type(b) == TYPE_MONSTER then mana.monster_remove(b) end end local m1 = mana.monster_create("Maggot", mana.posX(ch), mana.posY(ch)) - schedule_in(0.5, function() - mana.being_say(m1, "Roaaarrrr!!!") - mana.monster_change_anger(m1, ch, 100) - end) + mana.monster_change_anger(m1, ch, 100) + + -- (The following is not safe, since the being might have been removed by + -- the time this function gets executed (especially with the above code)) + -- + --schedule_in(0.5, function() + -- mana.being_say(m1, "Roaaarrrr!!!") + -- mana.monster_change_anger(m1, ch, 100) + -- end) end |