Mail Archives: djgpp/1998/01/25/06:47:51
greenfreak - conspiracy wrote:
[...]
> Here's some more info, I have.
>
> map_tile *_current_map =
> malloc(sizeof(map_tile)*map_xsize*map_ysize*300);
>
> Not exactly like that, but you know, the general idea it eventually turns
> out like that. Well, anyway(oh, btw 300 tiles per screen), and so that
> is the first layer, and then for the second layer, I'm using linked lists
> that I malloc as they are placed down.
>
> I am saving and retrieving in the same order, and I save it something
> like this:
>
> for(......
> fwrite(&_current_map[index], sizeof.......
>
> if(layer_2)
> fwrite(&_current_map[index].next, sizeof.....
>
> And when the second layer is loaded, its like all the index values for
> the bitmaps are uninitialized(for the second layer, first is fine),
> whether there was a tile on that spot in the 2nd layer or not.
Two things I don't completely catch.
The if(layer2) construct is really a fwrite ?
If so, and _current_map[index].next is a pointer to a tile
(BTW, can anybody enlighten me what tiles are),
then you are saveing the memory location of the pointer
to disk, and not what it is pointing to.
simply say
fwrite(_current_map[index].next, sizeof.....
and that'll cure it.
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -