www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/25/06:47:51

From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: HELP! A Bug....
Date: Sun, 25 Jan 1998 12:24:43 +0100
Organization: Lehrstuhl fuer Stroemungsmechanik
Lines: 50
Message-ID: <34CB20FA.6957492@LSTM.Ruhr-UNI-Bochum.De>
References: <19980124 DOT 222145 DOT 4351 DOT 2 DOT greenfreak-conspiracy AT juno DOT com>
NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019