The Dink Network

100th callback problem

February 20th 2011, 06:45 AM
pillbug.gif
dinkinfreak
Peasant He/Him Greece
Real lurkers don't appear on the lurkers list. 
In Dink Smallwood 1.08(maybe 1.07 too), adding a callback with an ID of 100
will corrupt memory and may distort game data, crash the game, or go on without damaging anything important.
Beware if writing callback intensive scripts.
February 20th 2011, 07:43 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
I've never heard of this, can you give an example of the script you discovered this in? Seth is still fixing stuff like that for DinkHD and I'm pretty sure he'd be interested in knowing about this critical bug.
February 21st 2011, 07:36 PM
fairy.gif
Someone
Peasant He/Him Australia
 
Yup. It's not that '100' is special while '101' would theoretically work, it's just that the game runs out of callback slots. This puts a limit on recursion in DinkC. Beuc also noticed this while making his minesweeper clone, which is how I know about it.

There's a limit to everything in DinkC it seems (variables, sprites, scripts, callbacks, etc.). Seth apparently only used fixed size arrays. I don't think it would be that hard to remove the limits but it would be better to just replace DinkC with a better language altogether if someone was interested in that in my opinion.
February 22nd 2011, 05:36 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
I wish someone would, but its doubtful after all these years that someone would in fact go to the trouble
February 22nd 2011, 09:32 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
RedInk was considering adding Python scripting but timing was an issue. Beuc was going to add guile scripting but hasn't done it for some reason.
February 27th 2011, 10:56 AM
pillbug.gif
dinkinfreak
Peasant He/Him Greece
Real lurkers don't appear on the lurkers list. 
Well, the engine can handle running out of callback slots; it simply returns 0 as the callback ID.
I had problems running the kill_all_callbacks procedure; it runs from 1 to max_callbacks(100), while the table has max_callbacks(0 to 99) slots.
I had tinkered with the source and a bitmap was placed right after the callback table, the inexistent slot 100 was marked as active, and the game crashed as soon as it tried to kill_all_callbacks.

tl;dr: editing the line
call_back callback[max_callbacks]

in dinkvar.h to
call_back callback[max_callbacks+1]

should fix it.