|
Bitmap pointer array + randomiser |
Ju-Han Soon
Member #6,738
December 2005
|
Hi all,
|
orz
Member #565
August 2000
|
Dunno. Perhaps you should try commenting out things until it stops crashing. |
Maikol
Member #4,997
September 2004
|
First of all, you ought to view if data's NULL; I would even do a cast in: face[0] = (BITMAP *) data[D_face].dat ... To ensure it makes a good conversion. However I think here's the problem: although Allegro stores every datum in dynamic memory, you should not move his pointers as you're doing in:
Maybe Allegro crashes because some faces[...] will point out of his datafile. I recommend you to load ALL data into your own memory; that has never failed me
El sabio no dice todo lo que piensa, pero siempre piensa todo lo que dice |
orz
Member #565
August 2000
|
Quote: First of all, you ought to view if data's NULL; I would even do a cast in: face[0] = (BITMAP *) data[D_face].dat To ensure it makes a good conversion. Double checking the type is probably a good idea, but a cast like that is strictly a static, compile time thing - the only thing it could effect is compile time errors or warnings. To double-check the validity of those pointers, you need to check (data[whatever].type == DAT_BITMAP) instead. Quote:
However I think here's the problem: although Allegro stores every datum in dynamic memory, you should not move his pointers as you're doing in: There are potential issues with the datafiles allocations yes, but in the code he showed, he never modifies anything that came out of a data file, only pointers at them. Unless I'm missing something. |
Dennis
Member #1,090
July 2003
|
Does it really crash at unload_datafile or perhaps at some point later, when you try to access any of face,mouth,eye? --- 0xDB | @dennisbusch_de --- |
Ju-Han Soon
Member #6,738
December 2005
|
My workaround solution would be to load a single bitmap that has all the face, mouth and eye as tiles and grab them. That should turn out good. But its just stumping to have a problem like this with a simple construct but yet seems buggy. And unload_datafile is the 2nd last command in my main(), before set_gfx_mode(GFX_TEXT...) |
orz
Member #565
August 2000
|
It really is simple enough that commenting out pieces ought to be informative. Does it crash with just load/unload datafile? Perhaps you could upload enough to compile and run? |
Ju-Han Soon
Member #6,738
December 2005
|
The reason I know that its the randomizer function thats causing problems is that commenting it out solves my problem. Right now, I'm loading the pictures into memory and removing the datafile. All is well. |
|