src/oasis.c
void cleanup_olc(struct descriptor_data *d, byte cleanup_type)
{
  /*
   * Clean up WHAT?
   */
  if (d->olc == NULL)
    return;

  /*
   * Check for a room. free_room doesn't perform
   * sanity checks, we must be careful here.
   */
  if (OLC_ROOM(d)) {
    switch (cleanup_type) {
    case CLEANUP_ALL:
      free_room(OLC_ROOM(d));
      break;
    case CLEANUP_STRUCTS:
      free(OLC_ROOM(d));
      break;
    case CLEANUP_CONFIG:
      free_config(OLC_CONFIG(d));
      break;
    default: /* The caller has screwed up. */
      log("SYSERR: cleanup_olc: Unknown type!");
      break;
    }
  }

  /*
   * Check for an existing object in the OLC.  The strings
   * aren't part of the prototype any longer.  They get added
   * with strdup().
   */
  if (OLC_OBJ(d)) {
    free_object_strings(OLC_OBJ(d));
    free(OLC_OBJ(d));
  }

  /*
   * Check for a mob.  free_mobile() makes sure strings are not in
   * the prototype.
   */
  if (OLC_MOB(d))
    free_mobile(OLC_MOB(d));

  /*
   * Check for a zone.  cleanup_type is irrelevant here, free() everything.
   */
  if (OLC_ZONE(d)) {
    free(OLC_ZONE(d)->name);
    free(OLC_ZONE(d)->cmd);
    free(OLC_ZONE(d));
  }

  /*
   * Check for a shop.  free_shop doesn't perform sanity checks, we must
   * be careful here.
   */
  if (OLC_SHOP(d)) {
    switch (cleanup_type) {
    case CLEANUP_ALL:
      free_shop(OLC_SHOP(d));
      break;
    case CLEANUP_STRUCTS:
      free(OLC_SHOP(d));
      break;
    default:
      /* The caller has screwed up but we already griped above. */
      break;
    }
  }

  /* free storage if allocated (for tedit) */
   /* Triggers */
   /* 
    * this is the command list - it's been copied to disk already,
    * so just free it -- Welcor
    */
   if (OLC_STORAGE(d)) { 
    free(OLC_STORAGE(d));
     OLC_STORAGE(d) = NULL;
   }
   /*
    * Free this one regardless. If we've left olc, we've either made
    * a fresh copy of it in the trig index, or we lost connection.
    * Either way, we need to get rid of this.
    */
   if (OLC_TRIG(d)) {
     free_trigger(OLC_TRIG(d));
     OLC_TRIG(d) = NULL;
   }
  /*
   * Restore descriptor playing status.
   */
  if (d->character) {
    REMOVE_BIT(PLR_FLAGS(d->character), PLR_WRITING);
    act("$n stops using OLC.", TRUE, d->character, NULL, NULL, TO_ROOM);
    
    if (cleanup_type == CLEANUP_CONFIG)
      mudlog(BRF, LVL_IMMORT, TRUE, "OLC: %s stops editing the game configuration", GET_NAME(d->character));
    else if (STATE(d) == CON_TEDIT)
      mudlog(BRF, LVL_IMMORT, TRUE, "OLC: %s stops editing text files.", GET_NAME(d->character));
    else
      mudlog(BRF, LVL_IMMORT, TRUE, "OLC: %s stops editing zone %d allowed zone %d", GET_NAME(d->character), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(d->character));

    STATE(d) = CON_PLAYING;
  }

  free(d->olc);
  d->olc = NULL;
}
/*
 * This procedure frees up the strings and/or the structures
 * attatched to a descriptor, sets all flags back to how they
 * should be.
 */
This procedure frees up the strings and/or the structures
attatched to a descriptor, sets all flags back to how they
should be.
This procedure frees up the strings and / or the structures attatched to a descriptor sets all flags back to how they should be .
void cleanup_olc(struct descriptor_data *d, byte cleanup_type)
{
  if (d->olc == NULL)
    return;
  if (OLC_ROOM(d)) {
    switch (cleanup_type) {
    case CLEANUP_ALL:
      free_room(OLC_ROOM(d));
      break;
    case CLEANUP_STRUCTS:
      free(OLC_ROOM(d));
      break;
    case CLEANUP_CONFIG:
      free_config(OLC_CONFIG(d));
      break;
    default: 
      log("SYSERR: cleanup_olc: Unknown type!");
      break;
    }
  }
  if (OLC_OBJ(d)) {
    free_object_strings(OLC_OBJ(d));
    free(OLC_OBJ(d));
  }
  if (OLC_MOB(d))
    free_mobile(OLC_MOB(d));
  if (OLC_ZONE(d)) {
    free(OLC_ZONE(d)->name);
    free(OLC_ZONE(d)->cmd);
    free(OLC_ZONE(d));
  }
  if (OLC_SHOP(d)) {
    switch (cleanup_type) {
    case CLEANUP_ALL:
      free_shop(OLC_SHOP(d));
      break;
    case CLEANUP_STRUCTS:
      free(OLC_SHOP(d));
      break;
    default:
      break;
    }
  }
   if (OLC_STORAGE(d)) { 
    free(OLC_STORAGE(d));
     OLC_STORAGE(d) = NULL;
   }
   if (OLC_TRIG(d)) {
     free_trigger(OLC_TRIG(d));
     OLC_TRIG(d) = NULL;
   }
  if (d->character) {
    REMOVE_BIT(PLR_FLAGS(d->character), PLR_WRITING);
    act("$n stops using OLC.", TRUE, d->character, NULL, NULL, TO_ROOM);
    if (cleanup_type == CLEANUP_CONFIG)
      mudlog(BRF, LVL_IMMORT, TRUE, "OLC: %s stops editing the game configuration", GET_NAME(d->character));
    else if (STATE(d) == CON_TEDIT)
      mudlog(BRF, LVL_IMMORT, TRUE, "OLC: %s stops editing text files.", GET_NAME(d->character));
    else
      mudlog(BRF, LVL_IMMORT, TRUE, "OLC: %s stops editing zone %d allowed zone %d", GET_NAME(d->character), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(d->character));
    STATE(d) = CON_PLAYING;
  }
  free(d->olc);
  d->olc = NULL;
}
void cleanup_olc ( struct descriptor_data * d , byte cleanup_type ) { if ( d -> olc == NULL ) return ; if ( OLC_ROOM ( d ) ) { switch ( cleanup_type ) { case CLEANUP_ALL : free_room ( OLC_ROOM ( d ) ) ; break ; case CLEANUP_STRUCTS : free ( OLC_ROOM ( d ) ) ; break ; case CLEANUP_CONFIG : free_config ( OLC_CONFIG ( d ) ) ; break ; default : log ( " " ) ; break ; } } if ( OLC_OBJ ( d ) ) { free_object_strings ( OLC_OBJ ( d ) ) ; free ( OLC_OBJ ( d ) ) ; } if ( OLC_MOB ( d ) ) free_mobile ( OLC_MOB ( d ) ) ; if ( OLC_ZONE ( d ) ) { free ( OLC_ZONE ( d ) -> name ) ; free ( OLC_ZONE ( d ) -> cmd ) ; free ( OLC_ZONE ( d ) ) ; } if ( OLC_SHOP ( d ) ) { switch ( cleanup_type ) { case CLEANUP_ALL : free_shop ( OLC_SHOP ( d ) ) ; break ; case CLEANUP_STRUCTS : free ( OLC_SHOP ( d ) ) ; break ; default : break ; } } if ( OLC_STORAGE ( d ) ) { free ( OLC_STORAGE ( d ) ) ; OLC_STORAGE ( d ) = NULL ; } if ( OLC_TRIG ( d ) ) { free_trigger ( OLC_TRIG ( d ) ) ; OLC_TRIG ( d ) = NULL ; } if ( d -> character ) { REMOVE_BIT ( PLR_FLAGS ( d -> character ) , PLR_WRITING ) ; act ( " " , TRUE , d -> character , NULL , NULL , TO_ROOM ) ; if ( cleanup_type == CLEANUP_CONFIG ) mudlog ( BRF , LVL_IMMORT , TRUE , " " , GET_NAME ( d -> character ) ) ; else if ( STATE ( d ) == CON_TEDIT ) mudlog ( BRF , LVL_IMMORT , TRUE , " " , GET_NAME ( d -> character ) ) ; else mudlog ( BRF , LVL_IMMORT , TRUE , " " , GET_NAME ( d -> character ) , zone_table [ OLC_ZNUM ( d ) ] . number , GET_OLC_ZONE ( d -> character ) ) ; STATE ( d ) = CON_PLAYING ; } free ( d -> olc ) ; d -> olc = NULL ; }
This procedure frees up the strings and/or the structures
 attatched to a descriptor, sets all flags back to how they
 should be.
This procedure frees up the strings and / or the structures attatched to a descriptor sets all flags back to how they should be .
/*
   * Clean up WHAT?
   */ /*
   * Check for a room. free_room doesn't perform
   * sanity checks, we must be careful here.
   */ /* The caller has screwed up. */ /*
   * Check for an existing object in the OLC.  The strings
   * aren't part of the prototype any longer.  They get added
   * with strdup().
   */ /*
   * Check for a mob.  free_mobile() makes sure strings are not in
   * the prototype.
   */ /*
   * Check for a zone.  cleanup_type is irrelevant here, free() everything.
   */ /*
   * Check for a shop.  free_shop doesn't perform sanity checks, we must
   * be careful here.
   */ /* The caller has screwed up but we already griped above. */ /* free storage if allocated (for tedit) */ /* Triggers */ /* 
    * this is the command list - it's been copied to disk already,
    * so just free it -- Welcor
    */ /*
    * Free this one regardless. If we've left olc, we've either made
    * a fresh copy of it in the trig index, or we lost connection.
    * Either way, we need to get rid of this.
    */ /*
   * Restore descriptor playing status.
   */