示例#1
0
/*
 * Copy strings over so bad things don't happen.  We do not free the
 * existing strings here because copy_room() did a shallow copy previously
 * and we'd be freeing the very strings we're copying.  If this function
 * is used elsewhere, be sure to free_room_strings() the 'dest' room first.
 */
int copy_room_strings(struct room_data *dest, struct room_data *source)
{
  int i;

  if (dest == NULL || source == NULL) {
    log("SYSERR: GenOLC: copy_room_strings: NULL values passed.");
    return FALSE;
  }

  dest->description = strdup(source->description ? source->description : "<NULL>");
  dest->name = strdup(source->name ? source->name : "<NULL>");

  for (i = 0; i < NUM_OF_DIRS; i++) {
    if (!R_EXIT(source, i))
      continue;

    CREATE(R_EXIT(dest, i), struct room_direction_data, 1);
    *R_EXIT(dest, i) = *R_EXIT(source, i);
    if (R_EXIT(source, i)->general_description)
      R_EXIT(dest, i)->general_description = strdup(R_EXIT(source, i)->general_description);
    if (R_EXIT(source, i)->keyword)
      R_EXIT(dest, i)->keyword = strdup(R_EXIT(source, i)->keyword);
  }

  if (source->ex_description)
    copy_ex_descriptions(&dest->ex_description, source->ex_description);

  return TRUE;
}
示例#2
0
void copy_object_strings(struct obj_data *to, struct obj_data *from)
{
  to->name = from->name ? strdup(from->name) : NULL;
  to->description = from->description ? strdup(from->description) : NULL;
  to->short_description = from->short_description ? strdup(from->short_description) : NULL;
  to->action_description = from->action_description ? strdup(from->action_description) : NULL;

  if (from->ex_description)
    copy_ex_descriptions(&to->ex_description, from->ex_description);
  else
    to->ex_description = NULL;
}
示例#3
0
/*
 * Idea by: Cris Jacobin <*****@*****.**>
 */
room_rnum duplicate_room(room_vnum dest_vnum, room_rnum orig)
{
  int new_rnum, znum;
  struct room_data nroom;

#if CIRCLE_UNSIGNED_INDEX
  if (orig == NOWHERE || orig > top_of_world) {
#else
  if (orig < 0 || orig > top_of_world) {
#endif
    log("SYSERR: GenOLC: copy_room: Given bad original real room.");
    return NOWHERE;
  } else if ((znum = real_zone_by_thing(dest_vnum)) == NOWHERE) {
    log("SYSERR: GenOLC: copy_room: No such destination zone.");
    return NOWHERE;
  }

  /*
   * add_room will make its own copies of strings.
   */
  if ((new_rnum = add_room(&nroom)) == NOWHERE) {
    log("SYSERR: GenOLC: copy_room: Problem adding room.");
    return NOWHERE;
  }

  nroom = world[new_rnum]; 
  nroom.number = dest_vnum;
  nroom.zone = znum;

  /* So the people and objects aren't in two places at once... */
  nroom.contents = NULL;
  nroom.people = NULL;

  return new_rnum;
}

/* -------------------------------------------------------------------------- */

/*
 * Copy strings over so bad things don't happen.  We do not free the
 * existing strings here because copy_room() did a shallow copy previously
 * and we'd be freeing the very strings we're copying.  If this function
 * is used elsewhere, be sure to free_room_strings() the 'dest' room first.
 */
int copy_room_strings(struct room_data *dest, struct room_data *source)
{
  int i;

  if (dest == NULL || source == NULL) {
    log("SYSERR: GenOLC: copy_room_strings: NULL values passed.");
    return FALSE;
  }

  dest->description = str_udup(source->description);
  dest->name = str_udup(source->name);

  for (i = 0; i < NUM_OF_DIRS; i++) {
    if (!R_EXIT(source, i))
      continue;

    CREATE(R_EXIT(dest, i), struct room_direction_data, 1);
    *R_EXIT(dest, i) = *R_EXIT(source, i);
    if (R_EXIT(source, i)->general_description)
      R_EXIT(dest, i)->general_description = strdup(R_EXIT(source, i)->general_description);
    if (R_EXIT(source, i)->keyword)
      R_EXIT(dest, i)->keyword = strdup(R_EXIT(source, i)->keyword);
  }

  if (source->ex_description)
    copy_ex_descriptions(&dest->ex_description, source->ex_description);

  return TRUE;
}