Page 1 of 1

(fixed) a bug report about DSB0.42

Posted: Thu May 06, 2010 3:20 pm
by Qwerty
Edit by Sophia: If you experience this problem, you don't have to do anything. The download has been fixed. Just download DSB 0.42 again and you'll have a corrected version.

I've got DSB0.42 and tested with my custom dungeon and your test_dungeon.
But, I've found a seriously bug, so I'll report it.

When Monster cast a spell in DSB0.42, It was crashed.
This is a log.

Code: Select all

FATAL LUA ERROR: Lua Function dragon.msg_handler[100111]: base/monster.lua:346: dsb_shoot requires int in param 10
@@@ LUA STACK @@@
[N:0][N:2953][N:100111][N:0][S:base/monster.lua:346: dsb_shoot requires int in param 10]
@@@@@@
I checked base/monster.lua and base/object.lua.
I guess that the source of crash is
:arrow: parameter in line 343 is "delta".
:arrow: "self.missile_damage_delta" is not defined in each monster of base/object.lua.

Therefor,
I added "missile_damage_delta" to each monster_arch in my own object.lua

Code: Select all

obj.materializer.missile_damage_delta = 1
and then copied function "monster_missile" from base/monster.lua and changed parameter "delta" to "ddelta" in my startup.lua.

Code: Select all

	
	local ddelta = nil
	if (self.missile_damage_delta) then
	ddelta = self.missile_damage_delta
	end

	dsb_shoot(missile_id, lev, xc, yc, facedir, shootside, pow, damage, delta, ddelta)
it was correctly worked.

Thanks.
-Qwerty-

Re: a bug report about DSB0.42

Posted: Thu May 06, 2010 8:57 pm
by Sophia
The line 343 thing was just a typo and is a good find. :D

However, passing a nil was intentional and is a case of me being too clever for my own good, apparently.
The explanation, those interested:
When you're calling a Lua function from Lua, the parameter count is extremely dynamic. Extra formal parameters are assumed to be nil, and there is essentially no distinction between an unspecified parameter and passing a parameter as a nil. However, such is not the case when calling a function written in C (i.e., most dsb_* functions), which make a firm distinction between a parameter that is simply not there and a parameter that is passed as a nil.

While I appreciate Qwerty's efforts in diagnosing and fixing this bug, and certainly don't want to discourage this sort of thing in the future, I recommend against applying the suggested fix of defining missile_damage_delta for every monster. Simply setting a damage_delta of 1 will cause most monsters' missiles to suddenly seem much more powerful. It required a fix in the core engine to actually fix it in a proper way, so I've done that and re-uploaded DSB.