|
Crash because of data file |
yipster
Member #7,168
April 2006
|
I had a whole bunch of images and midi files, and decided to try using a data file. It's all fine and dandy when compiling, but crashes when it tries to 'draw_sprite()'. I've commented what I think is relevant. As the code shown here was done in the heat of the moment, and I just did whatever popped into my brain for x's and o's. So any tips on fixing it up or efficiency is welcome. Here is a snippet: (max post size is 64k so I just cut and pasted the relevant stuff)
|
Michael Faerber
Member #4,800
July 2004
|
Have you checked if x_pic is zero? Have you properly initialized everything? -- |
yipster
Member #7,168
April 2006
|
BAF
Member #2,981
December 2002
|
Did oyu make sure data isn't null? |
Kitty Cat
Member #2,815
October 2002
|
Are you sure the sprite is the first object in the datafile? -- |
yipster
Member #7,168
April 2006
|
BAF said: Did oyu make sure data isn't null? Not sure what you mean. I've intialized data and made sure it was NULL. And then "data = load_datafile ("game.dat");" Kitty Cat said: Are you sure the sprite is the first object in the datafile? Hmm...I used the grabber, and the 'x' picture is at the top. So unless the grabber index's the last item as '0' , then I'm pretty sure the 'x' picture is at the top. |
scriptX
Member #6,574
November 2005
|
Maybe it's failing to load? if (!(data = load_datafile ("game.dat"))) { printf("error loading data file!\n"); return -1; } // --- or --- data = load_datafile ("game.dat"); if (!data) { printf("error loading data file!\n"); return -1; }
|
BAF
Member #2,981
December 2002
|
Quote: Not sure what you mean. I've intialized data and made sure it was NULL. And then "data = load_datafile ("game.dat");" I meant what scriptX meant in the example he posted. |
yipster
Member #7,168
April 2006
|
I did something like this to make sure and commented out all the game function calls. Compiled and ran, result: data file did not fail to load.
|
BAF
Member #2,981
December 2002
|
What is o_pic in your original source? |
yipster
Member #7,168
April 2006
|
x_pic represents the bitmap for 'X' |
BAF
Member #2,981
December 2002
|
Is it trying to draw o_pic and failing because it is null? (I dont see anything regarding it in your source so I cant be sure). |
yipster
Member #7,168
April 2006
|
At the start of the game, X goes first. So I'm pretty sure it has nothing to do with o_pic. As for the code posted at the beginning, there just snippets of what I thought was relevant. The entire source is attached. |
|