System.ini Loading/Writing

From: David Cole (tiznor@softhome.net)
Date: 06/12/02


I'm working on saving most mud values to a ini file. I guess it's not really
an ini file, I will probably rename it to dat later on. But my problem is It
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 etc
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;
    if (!strcmp(Data, "LevelCoOrd            : "))
      System->LevelCoOrd = Number;
    if (!strcmp(Data, "LevelGreater          : "))
      System->LevelGreater = Number;
    if (!strcmp(Data, "LevelDemi             : "))
      System->LevelDemi = Number;
    if (!strcmp(Data, "LevelLesser           : "))
      System->LevelLesser = Number;
    if (!strcmp(Data, "LevelGuest            : "))
      System->LevelGuest = Number;
    if (!strcmp(Data, "LevelPlayerImortality : "))
      System->LevelPlayerImortality = Number;
    if (!strcmp(Data, "ThirstNumber          : "))
      System->ThirstNumber = Number;
    if (!strcmp(Data, "HungerNumber          : "))
      System->HungerNumber = Number;
    if (!strcmp(Data, "HistorySize           : "))
      System->HistorySize = Number;
    if (!strcmp(Data, "MaxStringLength       : "))
      System->MaxStringLength = Number;
    if (!strcmp(Data, "MaxInputLength        : "))
      System->MaxInputLength = Number;
    if (!strcmp(Data, "RawInputLength        : "))
      System->RawInputLength = Number;
    if (!strcmp(Data, "MaxMessages           : "))
      System->MaxMessages = Number;
    if (!strcmp(Data, "MaxNameLength         : "))
      System->MaxMessageLength = Number;
    if (!strcmp(Data, "MaxPasswordLength     : "))
      System->MaxPasswordLength = Number;
    if (!strcmp(Data, "MaxTitleLength        : "))
      System->MaxTitleLength = Number;
    if (!strcmp(Data, "MaxRankLength         : "))
      System->MaxRankLength = Number;
    if (!strcmp(Data, "HostLength            : "))
      System->HostLength = Number;
    if (!strcmp(Data, "ExtraDescriptionLength: "))
      System->ExtraDescriptionLength = Number;
    if (!strcmp(Data, "MaxLanguages          : "))
      System->MaxLanguages = Number;
    if (!strcmp(Data, "MaxSkills             : "))
      System->MaxSkills = Number;
    if (!strcmp(Data, "MaxSpells             : "))
      System->MaxSpells = Number;
    if (!strcmp(Data, "MaxAffections         : "))
      System->MaxAffections = Number;
    if (!strcmp(Data, "NumberOfBoards        : "))
      System->NumberOfBoards = Number;
    if (!strcmp(Data, "MaxMessageLength      : "))
      System->MaxMessageLength = Number;
    if (!strcmp(Data, "BanSiteLength         : "))
      System->BanSiteLength = Number;

    fclose(SystemFile);
  } else {
 log("System Error: Cannot open System.ini.");
    exit(1);
  }
}

void WriteSystemFile(struct SystemData *System)
{
  FILE *SystemFile;

  sprintf(BufOne, "System/System.ini");
  if (!(SystemFile = fopen(BufOne, "s"))) {
    mudlog("System Error: Cannot open System.ini.", NRM, LVL_FORGER, TRUE);
    return;
  }

  fprintf(SystemFile, "LevelForger           : %d\n", System->LevelForger);
  fprintf(SystemFile, "LevelCoOrd            : %d\n", System->LevelCoOrd);
  fprintf(SystemFile, "LevelGreater          : %d\n", System->LevelGreater);
  fprintf(SystemFile, "LevelDemi             : %d\n", System->LevelDemi);
  fprintf(SystemFile, "LevelLesser           : %d\n", System->LevelLesser);
  fprintf(SystemFile, "LevelGuest            : %d\n", System->LevelGuest);
  fprintf(SystemFile, "LevelPlayerImortality : %d\n",
System->LevelPlayerImortality);
  fprintf(SystemFile, "ThirstNumber          : %d\n", System->ThirstNumber);
  fprintf(SystemFile, "HungerNumber          : %d\n", System->HungerNumber);
  fprintf(SystemFile, "HistorySize           : %d\n", System->HistorySize);
  fprintf(SystemFile, "MaxStringLength       : %d\n",
System->MaxStringLength);
  fprintf(SystemFile, "MaxInputLength        : %d\n",
System->MaxInputLength);
  fprintf(SystemFile, "RawInputLength        : %d\n",
System->RawInputLength);
  fprintf(SystemFile, "MaxMessages           : %d\n", System->MaxMessages);
  fprintf(SystemFile, "MaxNameLength         : %d\n",
System->MaxMessageLength);
  fprintf(SystemFile, "MaxPasswordLength     : %d\n",
System->MaxPasswordLength);
  fprintf(SystemFile, "MaxTitleLength        : %d\n",
System->MaxTitleLength);
  fprintf(SystemFile, "MaxRankLength         : %d\n",
System->MaxRankLength);
  fprintf(SystemFile, "HostLength            : %d\n", System->HostLength);
  fprintf(SystemFile, "ExtraDescriptionLength: %d\n",
System->ExtraDescriptionLength);
  fprintf(SystemFile, "MaxLanguages          : %d\n", System->MaxLanguages);
  fprintf(SystemFile, "MaxSkills             : %d\n", System->MaxSkills);
  fprintf(SystemFile, "MaxSpells             : %d\n", System->MaxSpells);
  fprintf(SystemFile, "MaxAffections         : %d\n",
System->MaxAffections);
  fprintf(SystemFile, "NumberOfBoards        : %d\n",
System->NumberOfBoards);
  fprintf(SystemFile, "MaxMessageLength      : %d\n",
System->MaxMessageLength);
  fprintf(SystemFile, "BanSiteLength         : %d\n",
System->BanSiteLength);

  fclose(SystemFile);
}

Anyone see what I'm doing wrong here?

Thanks,
Dave

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



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