Re: System.ini Loading/Writing

From: Kras Kresh (
Date: 06/12/02

>From: David Cole <tiznor@SOFTHOME.NET>
>I'm working on saving most mud values to a ini file. I guess it's not
>an ini file, I will probably rename it to dat later on. But my problem is
>doesn't seem to be loading correctly or at all: Reason being is all the
>SystemData info is not what I have it defined in System.ini. My code is
>below, maybe I just wrote this completly wrong? Any comments, suggestion
>would be greatly appreciated.
>struct SystemData {
>   unsigned char LevelForger;
>   unsigned char LevelCoOrd;
>   unsigned char LevelGreater;
>   unsigned char LevelDemi;
>   unsigned char LevelLesser;
>   unsigned char LevelGuest;
>   unsigned char LevelPlayerImortality;
>   signed char   ThirstNumber;
>   signed char   HungerNumber;
>   unsigned long HistorySize;
>   unsigned long MaxStringLength;
>   unsigned long MaxInputLength;
>   unsigned long RawInputLength;
>   unsigned long MaxMessages;
>   unsigned long MaxNameLength;
>   unsigned long MaxPasswordLength;
>   unsigned long MaxTitleLength;
>   unsigned long MaxRankLength;
>   unsigned long HostLength;
>   unsigned long ExtraDescriptionLength;
>   unsigned long MaxLanguages;
>   unsigned long MaxSkills;
>   unsigned long MaxSpells;
>   unsigned long MaxAffections;
>   unsigned long NumberOfBoards;
>   unsigned long MaxMessageLength;
>   unsigned long BanSiteLength;
>   struct SystemData *Next;
>void LoadSystemIni(void)
>   struct SystemData *System = NULL;
>   FILE *SystemFile;
>   int Number = 0;
>   char Data[24];
>   if ((SystemFile = fopen("System/System.ini", "r")) != NULL) {
>     if (!strcmp(Data, "LevelForger           : "))
>       System->LevelForger = Number;

----------- snipped ------------------

Its a minor problem. Before you open the file, do a

CREATE(System, struct SystemData, 1);

that will perform a calloc() which will basically start your System pointer.

One thing however... Your System pointer will be lost once the init function
is called. I suggest you declare it outside the function. I'm also assuming
you'll be calling the init function before the write function... You
probably won't want to pass the write function the System pointer since
you'll probably only be using the global "System" pointer.

Get your FREE download of MSN Explorer at

   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT