The Dink Network

variable limit and debug info

April 30th, 08:01 AM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
PQ Redux is being tested (just by me)

And I'm creating various scripts that generate sprites etc for rocks falling in the machine mountain exit sequence once Dink has grabbed the scale.

As my scripts are looping the creation of the falling rocks I found that I have exceeded various variable limits (discovered this yesterday in the log.txt file because certain actions/procedures stopped working during the run) and then I thought I had fixed it, but tonight found that I was now exceeding sprite creation limit.

Is there a DinkC command that can check if all sprite available numbers are being used?

And looking at the log tonight I noticed that while the log seems to say out of var space, my debug lines which I have placed just before a spawning of falling rocks, say that I've not exceeded the variable limit of 249, as I have a check to kill the spawning script if the var_used() value is above that.

Below is the code showing the warning that I've used all 250 spaces but the var_used is returning a different value that is less, haven't changed screens between looping the rock creation.

** adding mobile Skard script to sprite 20 **
** adding mobile Cthullos script to sprite 21 **
*** rockfall spawned on screen 447 - 106 variables used***
*** Rockfall loop start - 114 variables used***
** adding mobile Skard script to sprite 22 **
** adding mobile Cthullos script to sprite 23 **
ERROR: Out of var space, all 250 used.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: Out of var space, all 250 used.
ERROR: (var equals2) Unknown var &hold in brock offset 1634.
ERROR: Out of var space, all 250 used.
ERROR: Out of var space, all 250 used.
ERROR: (var equals2) Unknown var &damrock in brock offset 311.
ERROR: (var equals2) Unknown var &damrock in brock offset 329.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
ERROR: (var equals2) Unknown var &pcrap in brock offset 661.
** creating more blue rocks on screen 447 **
*** Rockfall loop start - 145 variables used***

and tonight, I get the out of sprites error...
so I'm killing off the rockfall script once I know that Dink has failed to reach the exit in time and thus can fill the screen with rocks, since I can't have both rock spawning scripts running at the same time.

I could just create on big sprite with all the rocks on it and move that down - which may be the better solution - but I like the rocks killing off all character sprites still on the screen.

** creating more blue rocks on screen 734 **
*** Rockfall loop start - 159 variables used***
** reaching end of music que **
** blrckill.c spawned DINK 216 life **
** checking sprite 6 is frozen from decrunf.c **
** row 1 of rocks created - 1 pass **
** row 2 of rocks created - 1 pass **
** checking sprite 6 is frozen from decrunf.c **
** row 3 of rocks created - 1 pass **
** row 4 of rocks created - 1 pass **
** checking sprite 6 is frozen from decrunf.c **
** row 5 of rocks created - 1 pass **
** have done 2 passes through rock creation **
Out of sprites, can't create!
Out of sprites, can't create!
Out of sprites, can't create!
Out of sprites, can't create!
Out of sprites, can't create!
Out of sprites, can't create!
Out of sprites, can't create!
April 30th, 08:28 AM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
That's weird that var_used is saying there's variable slots available when there isn't..

As for checking how many sprite numbers are being used, you could do this:
 int &sprites_used = 1;
 int &count;
sprites_used:
 sp_active(&sprites_used, -1);
 if (&return == 1)
 {
  &count += 1;
 }
 if (&sprites_used < 300)
 {
  //300 is the upper limit for DinkHD, check all active sprite slots
  &sprites_used += 1;
  goto sprites_used;
 }
 
 say("There are currently &count active sprites on this screen", 1);


No wait required in the loop, it'll process basically instantly. You can give it a custom proc name and call it whenever via external too.
You can use 2 global juggle vars there instead of using up 2 locals. If you have something like &save_x/&save_y in PQ just change it to them. It won't affect anything else since there's no wait in the procedure.

Im not sure on the variable thing, although if you wanna send me sample scripts to re-create the sequence, I'd play around with it and see if I can see any reason why.

EDIT: If it would help to see currently used scripts, vars and active sprites in real time while you play on the screen, I just quickly wrote a script to achieve this. Just put these in the story folder: key-83.c, stracker.c and press 's' in game. It will show the currently used vars, scripts and sprites at the bottom of the screen, updating every wait(1). It does use a few local vars to achieve it though.
April 30th, 09:15 AM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
thanks for that code,

I called it before each row of rock generation, with killing the script if the sprite limit reach over 290 and all I got was 1 row of rocks out of, but at least the game didn't freeze/lock up because it couldn't create more sprites.

Given that may be the case, I might have to create just the large sprite that has all the rocks in place and use that to wipe out everyone. Or I could push my luck and just create a row of rocks sprite and then stack those 5 high, which is still less than 7 individual rock sprites per row I'm now down to.

As for the other stuff about the game reporting to the log file variable limit exceeded but the var_used() not matching... weird, but that's DinkC for me...

EDIT

Hey thanks for those two scripts, they were funky. I reassigned the first to B key as S is used in PQ for the 6 stats display (strength, defense, magic, agility, honour, luck).

Man it killed the screen update performance even using herb boots to run Dink is moving through molasses - very funny . The limits are getting high on about 1/3 of the screens during the run which is interesting.

I will record this, as well as the run without B key press to compare, but I've going to have to remove the checks the first bit of code did so I can crash the game again with the scripts running.

Will do all of this tomorrow and let you know.
April 30th, 11:10 AM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
"Man it killed the screen update performance even using herb boots to run Dink is moving through molasses - very funny"

You can probably fix that performance issue, by making the script, sprite and var limit text refresh every wait(200) instead of every wait(1). Look for the wait(1) line near the bottom of the main procedure in stracker.c, change it to wait(200). Every 200 milliseconds is still a decently fast update to show you the stuff being used.

EDIT: There's actually a bug in that stracker.c script I whipped up where sometimes it won't show one or two of the lines of text showing the limits.
Fixed now: stracker.c
I also upped the wait time between updates of the sprite, script and var limits for better performance.
April 30th, 07:16 PM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
Thanks, I have updated, or gone back to original 40 rock sprites coming down, and sometimes the game crashes sometimes it doesn't. Will post a video soon.

Okay there is a video of the crash happening on YouTube

Crashing DinkHD with PQ
May 1st, 05:37 AM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
So got around this by using a sprite with all 8 rocks in a row,x5 to fill the screen. Has worked so far without crashing 8 times on various screens. No out of var space, no can't create sprites error log messages.