Fread from Player file

Posted by Nargsbrood on Fri 26 Oct 2007 11:44 PM — 2 posts, 10,843 views.

#0
I am having an issue with reading in from a player file... the section of the player file that i am trying to read is the text in bold below:


Spell        100 'weaken'
Spell        100 'winter mist'
Spell        100 'word of recall'
Spell        100 'Wrath of Dominus'
Killed       24836 1
Killed       2407 1
Killed       21045 1
Killed       4000 1
Map          'Dwarven Daycare'
Map          'Haon Dor'
Map          'Tullfuhrzky Manor'
Map          'Sewer'
Map          'The Astral Plane'
MaxColors    111


i tried both of the below to read in the map lines:


            if( !strcmp( word, "Map" ) )
            {
		ch->pcdata->atlas[mapcnt++].area = fread_word( fp );
                fMatch = TRUE;
                break;
            }


AND


		KEY( "Map", ch->pcdata->atlas[mapcnt++].area, fread_word( fp ) ) ;



but they both produce the same result. When I print the contents that were saved into the ch->pcdata->atlas array I get

  Atlas
-----------

  END
  END
  END
  END
  END



The number of items read from the player file is correct but the contents is wrong.


Why is it saving the contents as 'End' ?

Any help is much appreciated
Amended on Fri 26 Oct 2007 11:45 PM by Nargsbrood
#1
nevermind - i believe I may have thought of why it's not working. I am assigning the address of fp to ->atlas[x].area and so if the value of fp is changing but atlas that points to it is still pointing to the same location.

the last thing that fp gets assigned is the word END and so every element in my array is pointing to FP. they'll all always have the same value since they all point to the same address.

i need to malloc some space for it and then do a string copy into it? kiddie halloween stuff now, i'll try this later.


sry for the trouble