Losing image handle
Displaying 1-20 of 21 total.
12 next
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Zip

For some reason, mid program run, one of my image handles is running away. Note the code compiles and runs fine for a while, then I get a crash. Code and log below, any ideas? (Old version of verge by the way, can't stand the broken automax)

Relevant code:

void ActionEDone()
{
Log("ed1cP: "+str(enemy[0].cPortrait)+" p: "+str(enemy[0].portrait));
enemy[event[gl_first_event].target - 8].cur_p = RGB(64, 198, 128);
Log("ed2cP: "+str(enemy[0].cPortrait)+" p: "+str(enemy[0].portrait));
enemy[event[gl_first_event].target - 8].cPortrait = RGB(64, 198, 128);
RenderEnemy();
}

void RenderEnemy()
{
if (enemy[0].cPortrait == cWhite)
{
TBlit(325, 225, enemy[0].portrait, screen);
}
else
{
Silhouette(325, 225, enemy[0].cPortrait, enemy[0].portrait, screen);
TBlitLucent(325, 225, 50, enemy[0].portrait, screen);
}
}

Log:
ed1cP: 16777215 p: 7
ed2cP: 16777215 p: 4245120
Exiting: ImageForHandle() - Image reference is bogus! (4245120):

RenderEnemy - render_functions.vc(329)

Thanks in advance,

Zip

(Edited for pre-tag goodness. -Grue)

Posted on 2004-05-19 01:09:20 (last edited on 2004-05-19 01:31:13)

RageCage

what about automax makes you stray from v3?
I'm sure v3 can do nice windows because of pulsor and if you want the window completely maximized, why dont you just use full screen mode?

but anyway, let seeee....

well it's having a problem with enemy[0].portrait which you didn't seem to post the code of where it's defined. Did you define it?

Posted on 2004-05-19 01:51:49

Zip

Old verge as in 2004.04.04-A build not 2004.04.21 Build.

enemy[].portrait stores handle to image:
enemy[0].portrait = LoadImage("bush.gif");


enemy[].cPortrait stores colour mask (white is none):
enemy[0].cPortrait = cWhite;


enemy[].cur_p stores base colour mask:
enemy[0].cur_p = cWhite;


Full def. of enemy is:
struct character

{
string name;
string options[4];
int opt_sp[4];
int opt_cur;
int portrait;
int cPortrait;
int cur_p;
int new_p;
int at;
int df;
int sp;
int at_base;
int df_base;
int sp_base;
int action;
};

character enemy[4];


I'm still stumped.

Zip

[Edit: Out of guilt for grue pre tagging my first message]

Posted on 2004-05-19 02:03:38 (last edited on 2004-05-19 02:06:08)

RageCage

weird... one thing that I notice is that you semi-colin the struct... thats not necessary and maybe not legal... could it be screwing you up?

Posted on 2004-05-19 02:12:20

mcgrue

Automax 0 doesn't work in the current iteration of v3. This is apparently being delayed for something Zeromus needs to finish.

Posted on 2004-05-19 02:21:13

RageCage

Quote:Originally posted by mcgrue

Automax 0 doesn't work in the current iteration of v3. This is apparently being delayed for something Zeromus needs to finish.



ahh, I did not know that... =p

Posted on 2004-05-19 02:25:16

vecna

well the problem is definitely that enemy[0].portraits value is being changed at some point. It could even be an out of bounds array access on another variable. In any case the problem is almost certainly not in any of the code you posted..

Posted on 2004-05-19 02:25:30

vecna

and semicolons after struct definitions are optional; its legal either way.

Posted on 2004-05-19 02:26:13

Zip

It's odd as I log the .portrait value correctly (7), then assign a new value to .cur_p (an int) with RGB (which returns an int) then log .portrait as different value (4245120)!

Does RGB(64, 198, 128) return 4245120? And if so, why is the value being assigned to the wrong variable in the struct?

By the way, the struct variable are declared as int x; int y; rather than int x, y; as I'm using some of the code in pure c++ and want to be able to easily change some of the variables to unsigned char, short, and such like.

Zip

Posted on 2004-05-19 02:53:31

RageCage

whoa, I didnt notice it until you said that, but your right... that is really weird... bogus even!

Posted on 2004-05-19 03:22:20

mcgrue

Quote:Originally posted by Zip


Does RGB(64, 198, 128) return 4245120? And if so, why is the value being assigned to the wrong variable in the struct?
Zip


Yes, yes it does. 4245120 is exactly what that returns.

You can prove this for yourself like so:


autoexec{
exit( str(RGB( 64, 198, 128 )) );
}


So, yeah, that's weird. Also, it lends some weight to vecna's suggestion that it's caused by an array out-of-bounds error somewhere, since the value is going to the wrong place...

Posted on 2004-05-19 03:41:28 (last edited on 2004-05-19 03:43:28)

el_desconocido

Does
log(str(event[gl_first_event].target - 8));
log as -1?

Posted on 2004-05-19 03:53:14

mcgrue

Quote:Originally posted by El Desconocido

Does
log(str(event[gl_first_event].target - 8));
log as -1?


Or any number not between 0 and (ARRAY_MAX-1)?

Posted on 2004-05-19 03:55:57

Zip

Quote:Originally posted by mcgrue

Quote:Originally posted by El Desconocido

Does
log(str(event[gl_first_event].target - 8));
log as -1?


Or any number not between 0 and (ARRAY_MAX-1)?


At the moment, always (8) - 8, as I only have one enemy.

If anyone wants to brave the world of ugly code and worse art, go here and see if you can get the same crash. Interestingly, TomT64 couldn't.

It the newest version now, so you'll have to de-max yourself. :)

Also, might want to comment out the following line in event_actions.vc as it is liable to cause other, unrelated (but handleable) errors:
//EventDelay(enemy[event[gl_first_event].who - 8].action, 100);

Zip

Posted on 2004-05-19 04:04:05

el_desconocido

Just to be sure: if you have your enemy in an array, and event[gl_first_event].target points to said enemy (entity number eight), it is in fact ent[7], and 7 - 8 = -1.
Rar makes me go rar. (cuz m laZ)

[edit]
Then I remembered there was this one time I wasn't lazy, and DO have a un-raring program.
By adding log(str(event[gl_first_event].target)); I have determined that it's values starts at 8, but changes to various other values, seemingly at random.
Note:
cP: 16777215 p: 7
ed1cP: 16777215 p: 7
8
ed2cP: 16777215 p: 7
ed3cP: 4245120 p: 7
cP: 4245120 p: 7
ed4cP: 4245120 p: 7
[snip]
ed1cP: 16777215 p: 7
7
ed2cP: 16777215 p: 7
ed3cP: 16777215 p: 7
cP: 16777215 p: 7
ed4cP: 16777215 p: 7
[snip]
ed1cP: 16777215 p: 7
3
ed2cP: 16777215 p: 7
ed3cP: 16777215 p: 7
cP: 16777215 p: 7
ed4cP: 16777215 p: 7
[snip]
ed1cP: 16777215 p: 7
2
ed2cP: 16777215 p: 7
ed3cP: 16777215 p: 7
[big snip]
cP: 16711680 p: 7
cP: 16777215 p: 7
Knock_Back: 5716 Character: Sabra
Exiting: Event 0 not in stack

El

Posted on 2004-05-19 04:14:34 (last edited on 2004-05-19 04:33:08)

Zip

I presumed this would give me an array over/underflow error similar to this one I've recieved in the past:
Exiting: Bad offset on reading array player_cur_p (10/4): 


ActionEThinking - event_actions.vc(162)


However, a little experimenting reveals this is not the case. I'll have a careful look at what I'm pushing the target as. :)

Do you realy not have an ap. that decompresses .rar files? Wow.

Zip

Posted on 2004-05-19 04:26:36

el_desconocido

See above.

[edit]
To add some small amount of value to this post. Zip uploads .rar files. ;)

Posted on 2004-05-19 04:34:58 (last edited on 2004-05-19 04:36:46)

Zip

Not quite that El D, but set me along the right lines. Fixed
Always the stupidest of mistakes leads to the most confusing bugs. Turns out I should have typed .who rather than .target - after all it is the enemy who has just acted, so in the event they are indicated by .who - with .target being something else entirely. The call was therefore going out of bounds and causing strange errors above.


Zip

Posted on 2004-05-19 04:42:16

el_desconocido

Glad to have not quite helped. ;)
Looking good, aside from the whole crashing thing, by the way. Love the intro effect.

Posted on 2004-05-19 04:46:36

Zip

I see your new posts just as I find the source of the problem - thanks for you help, set everything right.

So as a request for the devs, slightly better error detecting when stupidly going out of bounds on an array. :D

Rar

Posted on 2004-05-19 04:47:02


Displaying 1-20 of 21 total.
12 next
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.