[OasisOLC] BugFix Help Please

From: Mythran (kip_potter@hotmail.com)
Date: 11/16/02


Ok, it's 5 in the morning here, and I am tired as hel*.  Anywho, maybe it is
just because I am tired that I am missing this simple logic error...anywho,
let me know if you can see it from the code below....yes, this is the first look
into the new CEDIT function commands....What this code is doing wrong is,
when I save, none of the data is saved to the file.  When I type cedit again,
everything is blank, as if I am using a blank structure again with no data
loaded in it :(

Thanks, Mythran...

void cedit_setup(struct descriptor_data *d)
{
  /****************************************************************************/
  /** Create the config_data struct.                                         **/
  /****************************************************************************/
  CREATE(OLC_CONFIG(d), struct config_data, 1);

  /****************************************************************************/
  /** Copy the current configuration from the config_info to this one.       **/
  /****************************************************************************/
  CREATE(OLC_CONFIG(d)->play, struct game_data, 1);
  CREATE(OLC_CONFIG(d)->csd, struct crash_save_data, 1);
  CREATE(OLC_CONFIG(d)->room_nums, struct room_numbers, 1);
  CREATE(OLC_CONFIG(d)->operation, struct game_operation, 1);
  CREATE(OLC_CONFIG(d)->autowiz, struct autowiz_data, 1);

  OLC_CONFIG(d) = config_info;

  OLC_CONFIG(d)->play      = config_info->play;
  OLC_CONFIG(d)->csd       = config_info->csd;
  OLC_CONFIG(d)->room_nums = config_info->room_nums;
  OLC_CONFIG(d)->operation = config_info->operation;
  OLC_CONFIG(d)->autowiz   = config_info->autowiz;

  /****************************************************************************/
  /** Allocate space for the strings.                                        **/
  /****************************************************************************/
  OLC_CONFIG(d)->play->OK       = str_udup(config_info->play->OK);
  OLC_CONFIG(d)->play->NOPERSON = str_udup(config_info->play->NOPERSON);
  OLC_CONFIG(d)->play->NOEFFECT = str_udup(config_info->play->NOEFFECT);


  if (config_info->operation->DFLT_IP)
    OLC_CONFIG(d)->operation->DFLT_IP     =
strdup(config_info->operation->DFLT_IP);
  else
    OLC_CONFIG(d)->operation->DFLT_IP     = NULL;


  if (config_info->operation->DFLT_DIR)
    OLC_CONFIG(d)->operation->DFLT_DIR    =
strdup(config_info->operation->DFLT_DIR);
  else
    OLC_CONFIG(d)->operation->DFLT_DIR    = NULL;

  if (config_info->operation->LOGNAME)
    OLC_CONFIG(d)->operation->LOGNAME     =
strdup(config_info->operation->LOGNAME);
  else
    OLC_CONFIG(d)->operation->LOGNAME     = NULL;

  if (config_info->operation->MENU)
    OLC_CONFIG(d)->operation->MENU        = strdup(config_info->operation->MENU);
  else
    OLC_CONFIG(d)->operation->MENU        = NULL;

  if (config_info->operation->WELC_MESSG)
    OLC_CONFIG(d)->operation->WELC_MESSG  =
strdup(config_info->operation->WELC_MESSG);
  else
    OLC_CONFIG(d)->operation->WELC_MESSG  = NULL;

  if (config_info->operation->START_MESSG)
    OLC_CONFIG(d)->operation->START_MESSG =
strdup(config_info->operation->START_MESSG);
  else
    OLC_CONFIG(d)->operation->START_MESSG = NULL;

  cedit_disp_menu(d);
}

/******************************************************************************/

void cedit_save_internally(struct descriptor_data *d)
{
  /****************************************************************************/
  /** Copy the data back from the descriptor to the config_info structure.   **/
  /****************************************************************************/

  /****************************************************************************/
  /** First, free the config_info structure and all it's strings.            **/
  /****************************************************************************/
  free_config(config_info);

  /****************************************************************************/
  /** Create the config_info structure.                                      **/
  /****************************************************************************/
  /****************************************************************************/
  /** Create the config_data struct.                                         **/
  /****************************************************************************/
  CREATE(config_info, struct config_data, 1);

  /****************************************************************************/
  /** Copy the current configuration from the config_info to this one.       **/
  /****************************************************************************/
  CREATE(config_info->play, struct game_data, 1);
  CREATE(config_info->csd, struct crash_save_data, 1);
  CREATE(config_info->room_nums, struct room_numbers, 1);
  CREATE(config_info->operation, struct game_operation, 1);
  CREATE(config_info->autowiz, struct autowiz_data, 1);

  config_info = OLC_CONFIG(d);

  config_info->play      = OLC_CONFIG(d)->play;
  config_info->csd       = OLC_CONFIG(d)->csd;
  config_info->room_nums = OLC_CONFIG(d)->room_nums;
  config_info->operation = OLC_CONFIG(d)->operation;
  config_info->autowiz   = OLC_CONFIG(d)->autowiz;

  if (config_info->play->OK)
    log("use_autowiz #1: %d", config_info->autowiz->use_autowiz);
  else
    log("use_autowiz #2: %d", OLC_CONFIG(d)->autowiz->use_autowiz);

  /****************************************************************************/
  /** Allocate space for the strings.                                        **/
  /****************************************************************************/
  config_info->play->OK       = str_udup(OLC_CONFIG(d)->play->OK);
  config_info->play->NOPERSON = str_udup(OLC_CONFIG(d)->play->NOPERSON);
  config_info->play->NOEFFECT = str_udup(OLC_CONFIG(d)->play->NOEFFECT);


  if (OLC_CONFIG(d)->operation->DFLT_IP)
    config_info->operation->DFLT_IP     =
strdup(OLC_CONFIG(d)->operation->DFLT_IP);
  else
    config_info->operation->DFLT_IP     = NULL;


  if (OLC_CONFIG(d)->operation->DFLT_DIR)
    config_info->operation->DFLT_DIR    =
strdup(OLC_CONFIG(d)->operation->DFLT_DIR);
  else
    config_info->operation->DFLT_DIR    = NULL;

  if (OLC_CONFIG(d)->operation->LOGNAME)
    config_info->operation->LOGNAME     =
strdup(OLC_CONFIG(d)->operation->LOGNAME);
  else
    config_info->operation->LOGNAME     = NULL;

  if (OLC_CONFIG(d)->operation->MENU)
    config_info->operation->MENU        = strdup(OLC_CONFIG(d)->operation->MENU);
  else
    config_info->operation->MENU        = NULL;

  if (OLC_CONFIG(d)->operation->WELC_MESSG)
    config_info->operation->WELC_MESSG  =
strdup(OLC_CONFIG(d)->operation->WELC_MESSG);
  else
    config_info->operation->WELC_MESSG  = NULL;

  if (OLC_CONFIG(d)->operation->START_MESSG)
    config_info->operation->START_MESSG =
strdup(OLC_CONFIG(d)->operation->START_MESSG);
  else
    config_info->operation->START_MESSG = NULL;

  add_to_save_list(NOWHERE, SL_CFG);
}

--
   +---------------------------------------------------------------+
   | 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