Esempio n. 1
0
void
gen_board_write(struct board_data *board, struct creature *ch, char *argument)
{
    struct creature *player;

    if (IS_PC(ch))
        player = ch;
    else if (ch->desc && ch->desc->original)
        player = ch->desc->original;
    else {
        send_to_char(ch, "You're a mob.  Go awei.\r\n");
        return;
    }

    if (ALLOW != react(board->post_perms, player)) {
        send_to_char(ch, "%s\r\n", board->deny_post);
        return;
    }

    if (!*argument) {
        send_to_char(ch,
            "If you wish to post a message, write <subject of message>\r\n");
        return;
    }

    act("$n starts to write on the board.", true, ch, NULL, NULL, TO_ROOM);
    SET_BIT(PLR_FLAGS(ch), PLR_WRITING);
    start_editing_board(ch->desc, board->name, -1, argument, NULL);
}
Esempio n. 2
0
void die(struct char_data *ch)
{
  gain_exp(ch, -(GET_EXP(ch) / 2));
  if (!IS_NPC(ch))
    REMOVE_BIT(PLR_FLAGS(ch), PLR_KILLER | PLR_THIEF);
  raw_kill(ch);
}
Esempio n. 3
0
/* I'm not particularly pleased with the MOB/PLR hoops that have to be jumped
 * through but it hardly calls for a completely new variable. Ideally it would
 * be its own list, but that would change the '->next' pointer, potentially
 * confusing some code. -gg This doesn't handle recursive extractions. */
void extract_pending_chars(void)
{
  struct char_data *vict, *next_vict, *prev_vict;

  if (extractions_pending < 0)
    log("SYSERR: Negative (%d) extractions pending.", extractions_pending);

  for (vict = character_list, prev_vict = NULL; vict && extractions_pending; vict = next_vict) {
    next_vict = vict->next;

    if (MOB_FLAGGED(vict, MOB_NOTDEADYET))
      REMOVE_BIT_AR(MOB_FLAGS(vict), MOB_NOTDEADYET);
    else if (PLR_FLAGGED(vict, PLR_NOTDEADYET))
      REMOVE_BIT_AR(PLR_FLAGS(vict), PLR_NOTDEADYET);
    else {
      /* Last non-free'd character to continue chain from. */
      prev_vict = vict;
      continue;
    }

    extract_char_final(vict);
    extractions_pending--;

    if (prev_vict)
      prev_vict->next = next_vict;
    else
      character_list = next_vict;
  }

  if (extractions_pending > 0)
    log("SYSERR: Couldn't find %d extractions as counted.", extractions_pending);

  extractions_pending = 0;
}
Esempio n. 4
0
void Board_write_message(int board_type, struct char_data * ch, char *arg)
{
  char *tmstr;
  int len;
  time_t ct;
  char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];

  if (WRITE_LVL(board_type) != 0 && !COM_FLAGGED(ch, WRITE_LVL(board_type))) {
    send_to_char("You are not holy enough to write on this board.\r\n", ch);
    return;
  }
  if (num_of_msgs[board_type] >= MAX_BOARD_MESSAGES) {
    send_to_char("The board is full.\r\n", ch);
    return;
  }
  if ((NEW_MSG_INDEX(board_type).slot_num = find_slot()) == -1) {
    send_to_char("The board is malfunctioning - sorry.\r\n", ch);
    stderr_log("SYSERR: Board: failed to find empty slot on write.");
    return;
  }
  /* skip blanks */
  skip_spaces(&arg);
  delete_doubledollar(arg);

  if (!*arg) {
    send_to_char("We must have a headline!\r\n", ch);
    return;
  }
  ct = time(0);
  tmstr = (char *) asctime(localtime(&ct));
  *(tmstr + strlen(tmstr) - 1) = '\0';

  sprintf(buf2, "(%s)", GET_NAME(ch));
  sprintf(buf, "%6.10s %-12s :: %s", tmstr, buf2, arg);
  len = strlen(buf) + 1;
  if (!(NEW_MSG_INDEX(board_type).heading = (char *) malloc(sizeof(char) * len))) {
    send_to_char("The board is malfunctioning - sorry.\r\n", ch);
    return;
  }
  strcpy(NEW_MSG_INDEX(board_type).heading, buf);
  NEW_MSG_INDEX(board_type).heading[len - 1] = '\0';
  NEW_MSG_INDEX(board_type).level = GET_LEVEL(ch);
  sprintf(logbuffer, "%s writing new message (%s) on board in #%d", GET_NAME(ch), buf, world[ch->in_room].number);
  mudlog(logbuffer, 'B', COM_ADMIN, FALSE);
  send_to_char("Write your message. (/s saves /h for help)\r\n\r\n", ch);
  act("$n starts to write a message.", TRUE, ch, 0, 0, TO_ROOM);

  if (!IS_NPC(ch))
    SET_BIT(PLR_FLAGS(ch), PLR_WRITING);

  ch->desc->str = &(msg_storage[NEW_MSG_INDEX(board_type).slot_num]);
  ch->desc->max_str = MAX_MESSAGE_LENGTH;
  ch->desc->mail_to = (char*) board_type + BOARD_MAGIC;

  num_of_msgs[board_type]++;
}
Esempio n. 5
0
void pk_check_spamm(CHAR_DATA * ch)
{
	if (pk_calc_spamm(ch) > MAX_PKILL_FOR_PERIOD)
	{
		SET_GOD_FLAG(ch, GF_GODSCURSE);
		GCURSE_DURATION(ch) = time(0) + TIME_GODS_CURSE * 60 * 60;
		act("Боги прокляли тот день, когда ты появился на свет!", FALSE, ch, 0, 0, TO_CHAR);
	}
	if (pk_player_count(ch) >= KillerPK)
		SET_BIT(PLR_FLAGS(ch, PLR_KILLER), PLR_KILLER);
}
Esempio n. 6
0
/* Why do we do this? Because trying to iterate over the character list with
 * 'ch = ch->next' does bad things if the current character happens to die. The
 * trivial workaround of 'vict = next_vict' doesn't work if the _next_ person
 * in the list gets killed, for example, by an area spell. Why do we leave them
 * on the character_list? Because code doing 'vict = vict->next' would get
 * really confused otherwise. */
void extract_char(struct char_data *ch)
{
  char_from_furniture(ch);
  clear_char_event_list(ch);

  if (IS_NPC(ch))
    SET_BIT_AR(MOB_FLAGS(ch), MOB_NOTDEADYET);
  else
    SET_BIT_AR(PLR_FLAGS(ch), PLR_NOTDEADYET);

  extractions_pending++;
}
Esempio n. 7
0
void check_killer(struct char_data *ch, struct char_data *vict)
{
  if (PLR_FLAGGED(vict, PLR_KILLER) || PLR_FLAGGED(vict, PLR_THIEF))
    return;
  if (PLR_FLAGGED(ch, PLR_KILLER) || IS_NPC(ch) || IS_NPC(vict) || ch == vict)
    return;

  SET_BIT(PLR_FLAGS(ch), PLR_KILLER);
  send_to_char(ch, "If you want to be a PLAYER KILLER, so be it...\r\n");
  mudlog(BRF, LVL_IMMORT, TRUE, "PC Killer bit set on %s for initiating attack on %s at %s.",
	    GET_NAME(ch), GET_NAME(vict), world[IN_ROOM(vict)].name);
}
Esempio n. 8
0
void Crash_save_all(void)
{
  struct descriptor_data *d;
  for (d = descriptor_list; d; d = d->next) {
    if ((d->connected == CON_PLAYING) && !IS_NPC(d->character)) {
      if (PLR_FLAGGED(d->character, PLR_CRASH)) {
	Crash_crashsave(d->character);
	save_char(d->character, d->character->in_room);
	REMOVE_BIT(PLR_FLAGS(d->character), PLR_CRASH);
      }
    }
  }
}
Esempio n. 9
0
void Crash_cryosave(struct char_data *ch, int cost)
{
  char buf[MAX_INPUT_LENGTH];
  struct rent_info rent;
  int j;
  FILE *fp;

  if (IS_NPC(ch))
    return;

  if (!get_filename(buf, sizeof(buf), CRASH_FILE, GET_NAME(ch)))
    return;
  
  if (!(fp = fopen(buf, "w")))
    return;

  Crash_extract_norent_eq(ch);
  Crash_extract_norents(ch->carrying);

  GET_GOLD(ch) = MAX(0, GET_GOLD(ch) - cost);

  rent.rentcode = RENT_CRYO;
  rent.time = time(0);
  rent.gold = GET_GOLD(ch);
  rent.account = GET_BANK_GOLD(ch);
  rent.net_cost_per_diem = 0;

  fprintf(fp,"%d %d %d %d %d %d\r\n",rent.rentcode,rent.time,
           rent.net_cost_per_diem,rent.gold,rent.account,rent.nitems);


  for (j = 0; j < NUM_WEARS; j++)
    if (GET_EQ(ch, j)) {
      if (!Crash_save(GET_EQ(ch, j), fp, j + 1)) {
        fclose(fp);
        return;
      }
      Crash_restore_weight(GET_EQ(ch, j));
      Crash_extract_objs(GET_EQ(ch, j));
    }
  if (!Crash_save(ch->carrying, fp, 0)) {
    fclose(fp);
    return;
  }
  fprintf(fp, "$~\n");
  fclose(fp);

  Crash_extract_objs(ch->carrying);
  SET_BIT(PLR_FLAGS(ch), PLR_CRYO);
}
Esempio n. 10
0
void
postmaster_send_mail (struct char_data *ch, struct char_data *mailman,
					  int cmd, char *arg)
{
	long recipient;
	char buf[256], **write;

	if (GET_LEVEL (ch) < MIN_MAIL_LEVEL)
	{
		sprintf (buf,
				 "$n tells you, 'Sorry, you have to be level %d to send mail!'",
				 MIN_MAIL_LEVEL);
		act (buf, FALSE, mailman, 0, ch, TO_VICT);
		return;
	}
	one_argument (arg, buf);

	if (!*buf)
	{							/* you'll get no argument from me! */
		act ("$n tells you, 'You need to specify an addressee!'",
			 FALSE, mailman, 0, ch, TO_VICT);
		return;
	}
	if (GET_GOLD (ch) < STAMP_PRICE)
	{
		sprintf (buf, "$n tells you, 'A stamp costs %d coins.'\r\n"
				 "$n tells you, '...which I see you can't afford.'",
				 STAMP_PRICE);
		act (buf, FALSE, mailman, 0, ch, TO_VICT);
		return;
	}
	if ((recipient = get_id_by_name (buf)) < 0)
	{
		act ("$n tells you, 'No one by that name is registered here!'",
			 FALSE, mailman, 0, ch, TO_VICT);
		return;
	}
	act ("$n starts to write some mail.", TRUE, ch, 0, 0, TO_ROOM);
	sprintf (buf, "$n tells you, 'I'll take %d coins for the stamp.'\r\n"
			 "$n tells you, 'Write your message, use @ on a new line when done.'",
			 STAMP_PRICE);

	act (buf, FALSE, mailman, 0, ch, TO_VICT);
	GET_GOLD (ch) -= STAMP_PRICE;
	SET_BIT (PLR_FLAGS (ch), PLR_MAILING);	/* string_write() sets writing. */

	/* Start writing! */
	CREATE (write, char *, 1);
	string_write (ch->desc, write, MAX_MAIL_SIZE, recipient, NULL);
}
Esempio n. 11
0
void
start_editing_poll(struct descriptor_data *d, const char *header)
{
    struct polleditor_data *poll_data;
    if (d->text_editor) {
        errlog("Text editor object not null in start_editing_poll");
        REMOVE_BIT(PLR_FLAGS(d->creature),
            PLR_WRITING | PLR_OLC | PLR_MAILING);
        return;
    }

    SET_BIT(PLR_FLAGS(d->creature), PLR_WRITING);

    d->text_editor = make_editor(d, MAX_POLL_SIZE);
    CREATE(poll_data, struct polleditor_data, 1);
    d->text_editor->finalize = polleditor_finalize;
    d->text_editor->cancel = polleditor_cancel;
    d->text_editor->mode_data = poll_data;

    poll_data->header = strdup(header);

    emit_editor_startup(d->text_editor);
}
Esempio n. 12
0
/*
 * Basic API function to start writing somewhere.
 *
 * 'data' isn't used in stock CircleMUD but you can use it to pass whatever
 * else you may want through it.  The improved editor patch when updated
 * could use it to pass the old text buffer, for instance.
 */
void string_write(struct descriptor_data *d, char **writeto, size_t len, long mailto, void *data)
{
  if (d->character && !IS_NPC(d->character))
    SET_BIT(PLR_FLAGS(d->character), PLR_WRITING);

  if (using_improved_editor)
    d->backstr = (char *)data;
  else if (data)
    free(data);

  d->str = writeto;
  d->max_str = len;
  d->mail_to = mailto;
}
Esempio n. 13
0
/* Some initializations for characters, including initial skills */
void do_start(struct char_data *ch)
{
  GET_LEVEL(ch) = 1;
  GET_TOT_LEVEL(ch) = 1;
  GET_EXP(ch) = 1;
  GET_CLASS_1(ch) = GET_CLASS(ch);
  GET_MULTIS(ch) = 1;

  set_title(ch, NULL);
  roll_real_abils(ch);

  GET_MAX_HIT(ch)  = 10;
  GET_MAX_MANA(ch) = 100;
  GET_MAX_MOVE(ch) = 100;

  switch (GET_CLASS(ch)) {

  case CLASS_ADEPT:
    break;

  case CLASS_MEDIC:
    break;

  case CLASS_BANDIT:
    SET_SKILL(ch, SKILL_SNEAK, 10);
    SET_SKILL(ch, SKILL_HIDE, 5);
    SET_SKILL(ch, SKILL_STEAL, 15);
    SET_SKILL(ch, SKILL_BACKSTAB, 10);
    SET_SKILL(ch, SKILL_PICK_LOCK, 10);
    SET_SKILL(ch, SKILL_TRACK, 10);
    break;

  case CLASS_SOLDIER:
    break;
  }

  advance_level(ch);

  GET_HIT(ch) = GET_MAX_HIT(ch);
  GET_MANA(ch) = GET_MAX_MANA(ch);
  GET_MOVE(ch) = GET_MAX_MOVE(ch);

  GET_COND(ch, THIRST) = 24;
  GET_COND(ch, HUNGER) = 24;
  GET_COND(ch, DRUNK) = 0;

  if (CONFIG_SITEOK_ALL)
    SET_BIT_AR(PLR_FLAGS(ch), PLR_SITEOK);
}
Esempio n. 14
0
void Crash_cryosave(struct char_data * ch, int cost)
{
  char buf[MAX_INPUT_LENGTH];
  struct rent_info rent;
  int j;
  FILE *fp;

  if (IS_NPC(ch))
    return;

  if (!get_filename(GET_NAME(ch), buf, CRASH_FILE))
    return;
  if (!(fp = fopen(buf, "wb")))
    return;
  for (j = 0; j < NUM_WEARS; j++)
    if (GET_EQ(ch, j))
      obj_to_char(unequip_char(ch, j), ch);
  Crash_extract_norents_from_equipped(ch);
  Crash_extract_norents(ch->carrying);

  GET_GOLD(ch) = MAX(0L, (long)GET_GOLD(ch) - cost);

  rent.rentcode = RENT_CRYO;
  rent.time = time(0);
  rent.gold = GET_GOLD(ch);
  rent.account = GET_BANK_GOLD(ch);
  rent.net_cost_per_diem = 0;
  if (!Crash_write_rentcode(ch, fp, &rent)) {
    fclose(fp);
    return;
  }
  for (j = 0; j < NUM_WEARS; j++)
    if (GET_EQ(ch,j)) {
      if (!Crash_save(GET_EQ(ch,j), fp, j+1)) {
	fclose(fp);
	return;
      }
      Crash_restore_weight(GET_EQ(ch,j));
      Crash_extract_objs(GET_EQ(ch,j));
    }
  if (!Crash_save(ch->carrying, fp, 0)) {
    fclose(fp);
    return;
  }
  fclose(fp);

  Crash_extract_objs(ch->carrying);
  SET_BIT(PLR_FLAGS(ch), PLR_CRYO);
}
Esempio n. 15
0
void clan_postmaster_send_mail(struct char_data * ch, 
                       struct char_data *mailman, int cmd, char *arg)
{
  long recipient;
  char buf[256];

  if (GET_LEVEL(ch) < MIN_MAIL_LEVEL) {
    sprintf(buf, "$n tells you, 'Sorry, you have to be level %d to send mail!'",
            MIN_MAIL_LEVEL);
    act(buf, FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  one_argument(arg, buf);

  if (!*buf) {                  /* you'll get no argument from me! */
    act("$n tells you, 'You need to specify an addressee!'",
        FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  if ((recipient = get_id_by_name(buf)) < 0) {
    act("$n tells you, 'No one by that name is registered here!'",
        FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  act("$n starts to write some mail.", TRUE, ch, 0, 0, TO_ROOM);

  act("$n tells you, 'Write your message, (/s saves /h for help)'",
            FALSE, mailman, 0, ch, TO_VICT);
  SET_BIT_AR(PLR_FLAGS(ch), PLR_MAILING);
  SET_BIT_AR(PLR_FLAGS(ch), PLR_WRITING);

  ch->desc->mail_to = recipient; 
  ch->desc->str = (char **) malloc(sizeof(char *));
  *(ch->desc->str) = NULL;
  ch->desc->max_str = MAX_MAIL_SIZE;
} 
Esempio n. 16
0
/* give an object to a char   */
void obj_to_char(struct obj_data * object, struct char_data * ch)
{
  if (object && ch) {
    object->next_content = ch->carrying;
    ch->carrying = object;
    object->carried_by = ch;
    object->in_room = NOWHERE;
    IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object);
    IS_CARRYING_N(ch)++;

    /* set flag for crash-save system */
    SET_BIT(PLR_FLAGS(ch), PLR_CRASH);
  } else
    log("SYSERR: NULL obj or char passed to obj_to_char");
}
Esempio n. 17
0
int
do_pass_remort_test(struct creature *ch)
{
    int i;

    // Wipe thier skills
    for (i = 1; i <= MAX_SKILLS; i++)
        SET_SKILL(ch, i, 0);

    do_start(ch, false);

    REMOVE_BIT(PRF_FLAGS(ch),
        PRF_NOPROJECT | PRF_ROOMFLAGS | PRF_HOLYLIGHT | PRF_NOHASSLE |
        PRF_LOG1 | PRF_LOG2 | PRF_NOWIZ);

    REMOVE_BIT(PLR_FLAGS(ch), PLR_HALT | PLR_INVSTART | PLR_MORTALIZED |
        PLR_OLCGOD);

    GET_INVIS_LVL(ch) = 0;
    GET_COND(ch, DRUNK) = 0;
    GET_COND(ch, FULL) = 0;
    GET_COND(ch, THIRST) = 0;

    // Give em another gen
    if (GET_REMORT_GEN(ch) == 10)
        account_set_quest_points(ch->account, ch->account->quest_points + 1);
    else
        GET_REMORT_GEN(ch)++;

    // At gen 1 they enter the world of pk, like it or not
    if (GET_REMORT_GEN(ch) >= 1 && RAW_REPUTATION_OF(ch) <= 0)
        gain_reputation(ch, 5);
    // Whack thier remort invis
    GET_WIMP_LEV(ch) = 0;       // wimpy
    GET_TOT_DAM(ch) = 0;        // cyborg damage

    // Tell everyone that they remorted
    char *msg = tmp_sprintf("%s completed gen %d remort test",
        GET_NAME(ch), GET_REMORT_GEN(ch));
    mudlog(LVL_IMMORT, BRF, false, "%s", msg);

    REMOVE_BIT(ch->in_room->room_flags, ROOM_NORECALL);

    // Save the char and its implants but not its eq
    creature_remort(ch);

    return 1;
}
Esempio n. 18
0
static void postmaster_send_mail(struct char_data *ch, struct char_data *mailman,
			  int cmd, char *arg)
{
  long recipient;
  char buf[MAX_INPUT_LENGTH], **mailwrite;

  if (GET_LEVEL(ch) < MIN_MAIL_LEVEL) {
    snprintf(buf, sizeof(buf), "$n tells you, 'Sorry, you have to be level %d to send mail!'", MIN_MAIL_LEVEL);
    act(buf, FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  one_argument(arg, buf);

  if (!*buf) {			/* you'll get no argument from me! */
    act("$n tells you, 'You need to specify an addressee!'",
	FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  if (GET_GOLD(ch) < STAMP_PRICE && GET_ADMLEVEL(ch) < ADMLVL_IMMORT) {
    snprintf(buf, sizeof(buf), "$n tells you, 'A stamp costs %d coin%s.'\r\n"
	    "$n tells you, '...which I see you can't afford.'", STAMP_PRICE,
            STAMP_PRICE == 1 ? "" : "s");
    act(buf, FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  if ((recipient = get_id_by_name(buf)) < 0 || !mail_recip_ok(buf)) {
    act("$n tells you, 'No one by that name is registered here!'",
	FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  act("$n starts to write some mail.", TRUE, ch, 0, 0, TO_ROOM);
  snprintf(buf, sizeof(buf), "$n tells you, 'I'll take %d coins for the stamp.'\r\n"
       "$n tells you, 'Write your message. (/s saves /h for help).'",
	  STAMP_PRICE);

  act(buf, FALSE, mailman, 0, ch, TO_VICT);

  if (GET_ADMLEVEL(ch) < ADMLVL_IMMORT)
    decrease_gold(ch, STAMP_PRICE);

  SET_BIT_AR(PLR_FLAGS(ch), PLR_MAILING);	/* string_write() sets writing. */

  /* Start writing! */
  CREATE(mailwrite, char *, 1);
  string_write(ch->desc, mailwrite, MAX_MAIL_SIZE, recipient, NULL);
}
Esempio n. 19
0
/* Give an object to a char. */
void obj_to_char(struct obj_data *object, struct char_data *ch)
{
  if (object && ch) {
    object->next_content = ch->carrying;
    ch->carrying = object;
    object->carried_by = ch;
    IN_ROOM(object) = NOWHERE;
    IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object);
    IS_CARRYING_N(ch)++;

    autoquest_trigger_check(ch, NULL, object, AQ_OBJ_FIND);

    /* set flag for crash-save system, but not on mobs! */
    if (!IS_NPC(ch))
      SET_BIT_AR(PLR_FLAGS(ch), PLR_CRASH);
  } else
    log("SYSERR: NULL obj (%p) or char (%p) passed to obj_to_char.", object, ch);
}
Esempio n. 20
0
/* take an object from a char */
void obj_from_char(struct obj_data * object)
{
  struct obj_data *temp;

  if (object == NULL) {
    log("SYSERR: NULL object passed to obj_from_char");
    return;
  }
  REMOVE_FROM_LIST(object, object->carried_by->carrying, next_content); 

  /* set flag for crash-save system */
  SET_BIT(PLR_FLAGS(object->carried_by), PLR_CRASH); 

  IS_CARRYING_W(object->carried_by) -= GET_OBJ_WEIGHT(object);
  IS_CARRYING_N(object->carried_by)--;
  object->carried_by = NULL;
  object->next_content = NULL;
}
Esempio n. 21
0
void Crash_crashsave(struct char_data *ch)
{
  char buf[MAX_INPUT_LENGTH];
  struct rent_info rent;
  int j;
  FILE *fp;

  if (IS_NPC(ch))
    return;

  if (!get_filename(buf, sizeof(buf), CRASH_FILE, GET_NAME(ch)))
    return;
  
  if (!(fp = fopen(buf, "w")))
    return;

  rent.rentcode = RENT_CRASH;
  rent.time = time(0);

  fprintf(fp,"%d %d %d %d %d %d\r\n",rent.rentcode,rent.time,
           rent.net_cost_per_diem,rent.gold,rent.account,rent.nitems);

  for (j = 0; j < NUM_WEARS; j++)
    if (GET_EQ(ch, j)) {
      if (!Crash_save(GET_EQ(ch, j), fp, j + 1)) {
        fclose(fp);
        return;
      }
      Crash_restore_weight(GET_EQ(ch, j));
    }

  if (!Crash_save(ch->carrying, fp, 0)) {
    fclose(fp);
    return;
  }
  Crash_restore_weight(ch->carrying);

  fprintf(fp, "$~\n");
  fclose(fp);
  REMOVE_BIT(PLR_FLAGS(ch), PLR_CRASH);
}
Esempio n. 22
0
void Crash_crashsave(struct char_data * ch)
{
  char buf[MAX_INPUT_LENGTH];
  struct rent_info rent;
  int j;
  FILE *fp;

  if (IS_NPC(ch))
    return;

  if (!get_filename(GET_NAME(ch), buf, CRASH_FILE))
    return;
  if (!(fp = fopen(buf, "wb")))
    return;

  rent.rentcode = RENT_CRASH;
  rent.time = time(0);
  if (!Crash_write_rentcode(ch, fp, &rent)) {
    fclose(fp);
    return;
  }
  if (!Crash_save(ch->carrying, fp, 0)) {
    fclose(fp);
    return;
  }
  Crash_restore_weight(ch->carrying);

  for (j = 0; j < NUM_WEARS; j++) {
    if (GET_EQ(ch, j)) {
      if (!Crash_save(GET_EQ(ch, j), fp, j+1)) {
	fclose(fp);
	return;
      }
      Crash_restore_weight(GET_EQ(ch, j));
    }
  }
  fclose(fp);
  REMOVE_BIT(PLR_FLAGS(ch), PLR_CRASH);
}
Esempio n. 23
0
// Saves the given characters equipment to a file. Intended for use while
// the character is still in the game.
bool
crashsave(struct creature *ch)
{
    time_t now = time(NULL);

    if (IS_NPC(ch))
        return false;
    if (!ch->in_room)
        return false;
    ch->player_specials->rentcode = RENT_CRASH;
    ch->player_specials->rent_currency = ch->in_room->zone->time_frame;

    ch->player.time.played += now - ch->player.time.logon;
    ch->player.time.logon = now;

    if (!save_player_objects(ch))
        return false;

    REMOVE_BIT(PLR_FLAGS(ch), PLR_CRASH);
    save_player_to_xml(ch);
    return true;
}
Esempio n. 24
0
void
check_idling( CharData * ch )
{
#define VOID_TIME 8
#define EXTRACT_TIME 32
  void Crash_rentsave(CharData *ch, int cost);
  void Crash_cryosave(CharData *ch, int cost);

  /*
  ** CONJURED timer
  */
  int i = 0;

  for(;i < 4;i++) {
      if( GET_CONJ_CNT(ch, i) > 0)
      {
          SET_CONJ_CNT(ch, i) -= 1;
          
          if(SET_CONJ_CNT(ch, i) == 0)
              switch(GET_CLASS(ch)) {
                  case CLASS_RANGER:
                      sendChar( ch, "The creatures of the wild will answer your call again.\r\n" );
                      break;
                  case CLASS_NECROMANCER:
                      sendChar(ch, "The dead will heed your summons once more.\r\n");
                  case CLASS_MAGIC_USER:
                      switch(i) {
                          case TIMER_GATE: sendChar(ch, "Demons will answer your summons again.\r\n"); break;
                          case TIMER_MONSTER: sendChar(ch, "Monsters will answer your summons again.\r\n"); break;
                          case TIMER_ELEMENTAL: sendChar(ch, "Elementals will answer your summons again.\r\n"); break;
                      }
                      break;
                  default:
                      sendChar( ch, "Conjured creatures will answer your summons again.\r\n" );
              }
      }
  }
  
  /*
  ** HUNTED timer
  */
  if( IS_SET_AR( PLR_FLAGS(ch), PLR_HUNTED ) && ch->desc &&
    (--(ch)->player_specials->saved.phunt_countdown <= 0))
  {
    sendChar( ch, "You are no longer hunted.\r\n" );
    unset_hunted_player(ch);
  }
  /*
  ** THIEF timer
  */
  if( IS_SET_AR(PLR_FLAGS(ch), PLR_THIEF) && ch->desc &&
    (--(ch)->player_specials->saved.pthief_countdown <= 0))
  {
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_THIEF);
    send_to_char("You are no longer a registered thief.\r\n", ch);
    (ch)->player_specials->saved.pthief_countdown = 0;
  }
  /* KILLER timer */
  if (IS_SET_AR(PLR_FLAGS(ch), PLR_KILLER)
     && (--(ch)->player_specials->saved.pkill_countdown <= 0))
  {
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_KILLER);
    send_to_char("You are no longer a registered killer.\r\n", ch);
    (ch)->player_specials->saved.pkill_countdown = 0;
  }
  /* JAILED timer */
  if (IS_SET_AR(PLR_FLAGS(ch), PLR_JAILED)
     && (--(ch)->player_specials->saved.jail_timer <= 0))
  {
    int jail_exit_room;
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_JAILED);

    if (PRF_FLAGGED(ch, PRF_GOLD_TEAM) && IN_ROOM(ch) == real_room(GOLD_TEAM_JAIL))
    {
      jail_exit_room = real_room(GOLD_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }
    if (PRF_FLAGGED(ch, PRF_BLACK_TEAM) && IN_ROOM(ch) == real_room(BLACK_TEAM_JAIL))
    {
      jail_exit_room = real_room(BLACK_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }    
    if (PRF_FLAGGED(ch, PRF_ROGUE_TEAM) && IN_ROOM(ch) == real_room(ROGUE_TEAM_JAIL))
    {
      jail_exit_room = real_room(ROGUE_TEAM_START_ROOM);
      GET_HIT(ch) = GET_MAX_HIT(ch);
      GET_MANA(ch) = GET_MAX_MANA(ch);
      GET_MOVE(ch) = GET_MAX_MOVE(ch);
      char_from_room(ch);
      char_to_room(ch, jail_exit_room);
      look_at_room(ch, 0);
    }    
    sendChar(ch, "Your imprisonement is over.\r\n");
//    if (PRF_FLAGGED(ch, PRF_GOLD_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//    else if (PRF_FLAGGED(ch, PRF_BLACK_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//	else if (PRF_FLAGGED(ch, PRF_ROGUE_TEAM))
//	jail_exit_room = IN_ROOM(ch);
//    else
//	jail_exit_room = getStartRoom(ch);

//    char_to_room(ch, jail_exit_room);
//    look_at_room(ch, 0);
  }
  /*
  ** If your hunted there is NO escape.
  */
  if(( ++(ch->char_specials.timer) > VOID_TIME ) &&
    !IS_SET_AR(PLR_FLAGS(ch), PLR_HUNTED))
  {
    if (GET_WAS_IN(ch) == NOWHERE && ch->in_room != NOWHERE)
    {
      GET_WAS_IN(ch) = ch->in_room;
      end_fight(ch);
      act("$n disappears into the void.", TRUE, ch, 0, 0, TO_ROOM);
      send_to_char("You have been idle, and are pulled into a void.\r\n", ch);
      save_char(ch, NOWHERE);
      Crash_crashsave(ch);
      GET_WAS_IN(ch) = ch->in_room;
      char_from_room(ch);
      char_to_room(ch, 1);
    }
    //else if (ch->char_specials.timer > EXTRACT_TIME)
    //{
      //if (ch->in_room != NOWHERE)
	//char_from_room(ch);
      //char_to_room(ch, 1);
      //if (ch->desc)
	//SET_DCPENDING(ch->desc);
      //ch->desc = NULL;

      //Crash_idlesave(ch);	/* apparently causing problems? */
      //crashRentSave(ch, -1);

      //mudlog( NRM, LVL_LRGOD, TRUE, "%s force-rented and extracted (idle).", GET_NAME(ch));
      //extract_char(ch);
    //}
  }
#undef VOID_TIME
#undef EXTRACT_TIME
}
Esempio n. 25
0
void postmaster_send_mail(struct char_data * ch, struct char_data *mailman,
			  int cmd, char *arg)
{
  long recipient;
  char buf[256];

  if (GET_LEVEL(ch) < MIN_MAIL_LEVEL && GET_CLASS(ch) < CLASS_VAMPIRE) {
    sprintf(buf, "$n tells you, 'Sorry, you have to be level %d to send mail!'",
	    MIN_MAIL_LEVEL);
    act(buf, FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  one_argument(arg, buf);

  if (!*buf) {			/* you'll get no argument from me! */
    act("$n tells you, 'You need to specify an addressee!'",
	FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  if (GET_GOLD(ch) < STAMP_PRICE && GET_LEVEL(ch) < LVL_IMMORT) {
    sprintf(buf, "$n tells you, 'A stamp costs %d coins.'\r\n"
	    "$n tells you, '...which I see you can't afford.'", STAMP_PRICE);
    act(buf, FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
/* REMOVED FOR MAIL_ALL SNIPPET
  if ((recipient = get_id_by_name(buf)) < 0) {
    act("$n tells you, 'No one by that name is registered here!'",
	FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
*/
/* BEGIN MAIL_ALL SNIPPET */
  if ((!(str_cmp(buf, "all")) || !(str_cmp(buf, "imms"))) && GET_LEVEL(ch) < LVL_IMPL) {
    act("$n tells you, 'You must be an Implementor to send a message to everyone or immortals!'",
        FALSE, mailman, 0, ch, TO_VICT);
    return;
  }

  if (!(str_cmp(buf, "all"))) {
    recipient = -1;
  } else if ((recipient = get_id_by_name(buf)) < 0) {
    act("$n tells you, 'No one by that name is registered here!'",
      FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
/* END MAIL_ALL SNIPPET */

  if ((recipient = get_id_by_name(buf)) == 1 && GET_LEVEL(ch) < LVL_IMMORT) {
    act("$n tells you, 'No one by that name exists within Dibrova.'",
        FALSE, mailman, 0, ch, TO_VICT);
    return;
  }
  act("$n starts to write some mail.", TRUE, ch, 0, 0, TO_ROOM);
  sprintf(buf, "$n tells you, 'I'll take %d coins for the stamp.'\r\n"
       "$n tells you, 'Write your message, (/s saves /h for help)'",
	  STAMP_PRICE);

  act(buf, FALSE, mailman, 0, ch, TO_VICT);
  GET_GOLD(ch) -= STAMP_PRICE;
  SET_BIT_AR(PLR_FLAGS(ch), PLR_MAILING);
  SET_BIT_AR(PLR_FLAGS(ch), PLR_WRITING);

  ch->desc->mail_to = recipient;
  ch->desc->str = (char **) malloc(sizeof(char *));
  *(ch->desc->str) = NULL;
  ch->desc->max_str = MAX_MAIL_SIZE;
}
Esempio n. 26
0
int gen_receptionist(struct char_data * ch, struct char_data * recep,
			 int cmd, char *arg, int mode)
{
  int cost = 0;
  extern int free_rent;
  sh_int save_room;
  char *action_table[] = {"smile", "dance", "sigh", "blush", "burp",
  "cough", "giggle", "twiddle", "yawn"};

  if (!ch->desc || IS_NPC(ch))
    return FALSE;

  if (!cmd && !number(0, 5)) {
    do_action(recep, "", find_command(action_table[number(0, 8)]), 0);
    return FALSE;
  }
  if (!CMD_IS("offer") && !CMD_IS("rent"))
    return FALSE;
  if (!AWAKE(recep)) {
    send_to_char("She is unable to talk to you...\r\n", ch);
    return TRUE;
  }
  if (!CAN_SEE(recep, ch)) {
    act("$n says, 'I don't deal with people I can't see!'", FALSE, recep, 0, 0, TO_ROOM);
    return TRUE;
  }
  if (free_rent) {
    act("$n tells you, 'Rent is free here.  Just quit, and your objects will be saved!'",
	FALSE, recep, 0, ch, TO_VICT);
    return 1;
  }
  if (CMD_IS("rent")) {
    if (mode == RENT_FACTOR)
      sprintf(buf, "%s Rent will cost you %d gold coins per day.",
			GET_NAME(ch), cost);
    else if (mode == CRYO_FACTOR)
      sprintf(buf, "%s It will cost you %d gold coins to be frozen.",
			GET_NAME(ch), cost);
    do_tell(recep, buf, 0, 0);
    if (cost > GET_GOLD(ch)) {
      sprintf(buf, "%s ...which I see you can't afford.", GET_NAME(ch));
      do_tell(recep, buf, 0, 0);
      return TRUE;
    }
    if (mode == RENT_FACTOR)
      Crash_rent_deadline(ch, recep, cost);

    if (mode == RENT_FACTOR) {
      act("$n stores your belongings and helps you into your private chamber.",
	  FALSE, recep, 0, ch, TO_VICT);
      Crash_rentsave(ch, cost);
      sprintf(buf, "%s has rented (%d/day, %ld tot.)", GET_NAME(ch),
	      cost, GET_GOLD(ch) + GET_BANK_GOLD(ch));
    } else {                    /* cryo */
      act("$n stores your belongings and helps you into your private chamber.\r\n"
	  "A white mist appears in the room, chilling you to the bone...\r\n"
	  "You begin to lose consciousness...",
	  FALSE, recep, 0, ch, TO_VICT);
      Crash_cryosave(ch, cost);
      sprintf(buf, "%s has cryo-rented.", GET_NAME(ch));
      SET_BIT(PLR_FLAGS(ch), PLR_CRYO);
    }

    mudlog(buf, NRM, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE);
    act("$n helps $N into $S private chamber.", FALSE, recep, 0, ch, TO_NOTVICT);
    save_room = ch->in_room;
    extract_char(ch);
    save_char(ch, save_room);
  } else {
    Crash_offer_rent(ch, recep, TRUE, mode);
    act("$N gives $n an offer.", FALSE, ch, 0, recep, TO_ROOM);
  }
  return TRUE;
}
Esempio n. 27
0
void medit_parse(struct descriptor_data *d, char *arg)
{

    int number;
    int mob_number;  // the RNUM

    switch(d->edit_mode)
    {
    case MEDIT_CONFIRM_EDIT:
        /* if player hits 'Y' then edit mob */
        switch (*arg) {
        case 'y':
        case 'Y':
            medit_disp_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            /* free up the editing mob */
            if (d->edit_mob)
                Mem->DeleteCh(d->edit_mob);
            d->edit_mob = NULL;
            d->edit_number = 0;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to edit it?\r\n", CH);
            break;
        }
        break;                      /* end of MEDIT_CONFIRM_EDIT */

    case MEDIT_CONFIRM_SAVESTRING:
        switch(*arg) {
        case 'y':
        case 'Y':
            // first write to the internal tables
            if (!from_ip_zone(d->edit_number)) {
                sprintf(buf,"%s wrote new mob #%ld",
                        GET_CHAR_NAME(d->character), d->edit_number);
                mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            }
            mob_number = real_mobile(d->edit_number);
            if (mob_number > 0) {
                // first we go through the entire list of mobs to find out
                // which are pointing to this prototype; if it is, it gets
                // replaced
                struct char_data *i, *temp;
                int c;
                for (i = character_list; i; i = i->next) {
                    if (mob_number == i->nr) {
                        // alloc a temp mobile
                        temp = Mem->GetCh();
                        *temp = *i;
                        *i = *d->edit_mob;
                        /* copy game-time dependent vars over */
                        i->in_room = temp->in_room;
                        i->nr = mob_number;
                        i->affected = temp->affected;
                        i->carrying = temp->carrying;
                        i->cyberware = temp->cyberware;
                        i->bioware = temp->bioware;
                        // any eq worn
                        for (c = 0; c < NUM_WEARS; ++c)
                            i->equipment[c] = temp->equipment[c];
                        i->next_in_room = temp->next_in_room;
                        i->next = temp->next;
                        i->next_fighting = temp->next_fighting;
                        i->followers = temp->followers;
                        i->master = temp->master;
                        i->char_specials.fighting = temp->char_specials.fighting;
                        i->char_specials.hunting = temp->char_specials.hunting;
                        i->mob_specials.last_direction = temp->mob_specials.last_direction;
                        i->mob_specials.memory = temp->mob_specials.memory;
                        i->mob_specials.wait_state = temp->mob_specials.wait_state;
                        Mem->ClearCh(temp);
                    } // end if statement

                } // end for loop

                // now you can free the old prototype and put in the new one
                if (mob_proto[mob_number].player.physical_text.keywords)
                    delete [] mob_proto[mob_number].player.physical_text.keywords;
                if (mob_proto[mob_number].player.title)
                    delete [] mob_proto[mob_number].player.title;
                if (mob_proto[mob_number].player.physical_text.name)
                    delete [] mob_proto[mob_number].player.physical_text.name;
                if (mob_proto[mob_number].player.physical_text.room_desc)
                    delete [] mob_proto[mob_number].player.physical_text.room_desc;
                if (mob_proto[mob_number].player.physical_text.look_desc)
                    delete [] mob_proto[mob_number].player.physical_text.look_desc;
                if (mob_proto[mob_number].mob_specials.arrive)
                    delete [] mob_proto[mob_number].mob_specials.arrive;
                if (mob_proto[mob_number].mob_specials.leave)
                    delete [] mob_proto[mob_number].mob_specials.leave;


                mob_proto[mob_number] = *d->edit_mob;
                mob_proto[mob_number].nr = mob_number;

            } else {  // if not, we need to make a new spot in the list
                int             counter;
                int             found = FALSE;

                struct char_data *new_mob_proto;
                struct index_data *new_mob_index;
                struct char_data *temp_mob;

                // two because you are adding one and you need one over
                new_mob_index = new struct index_data[top_of_mobt + 2];
                new_mob_proto = new struct char_data[top_of_mobt + 2];
                // count through the tables
                for (counter = 0; counter < top_of_mobt + 1; counter++) {
                    /* if we haven't found it */
                    if (!found) {
                        /* check if current virtual is bigger than our virtual */
                        if (MOB_VNUM_RNUM(counter) > d->edit_number) {
                            /* eureka. insert now */
                            /*---------*/
                            new_mob_index[counter].vnum = d->edit_number;
                            new_mob_index[counter].number = 0;
                            new_mob_index[counter].func = NULL;
                            /*---------*/
                            new_mob_proto[counter] = *(d->edit_mob);
                            new_mob_proto[counter].in_room = NOWHERE;
                            /* it is now safe (and necessary!) to assign real number to
                             * the edit_mob, which has been -1 all this time */
                            d->edit_mob->nr = counter;
                            /* and assign to prototype as well */
                            new_mob_proto[counter].nr = counter;
                            found = TRUE;
                            /* insert the other proto at this point */
                            new_mob_index[counter + 1] = mob_index[counter];
                            new_mob_proto[counter + 1] = mob_proto[counter];
                            new_mob_proto[counter + 1].nr = counter + 1;
                        } else {
                            /* just copy from old to new, no num change */
                            new_mob_proto[counter] = mob_proto[counter];
                            new_mob_index[counter] = mob_index[counter];
                        }

                    } else { // if !found else
                        /* we HAVE already found it.. therefore copy to mobile + 1 */
                        new_mob_index[counter + 1] = mob_index[counter];
                        new_mob_proto[counter + 1] = mob_proto[counter];
                        new_mob_proto[counter + 1].nr = counter + 1;
                    }
                } // for loop through list


                /* if we STILL haven't found it, means the mobile was > than all
                * the other mobs.. so insert at end */
                if (!found) {
                    new_mob_index[top_of_mobt + 1].vnum = d->edit_number;
                    new_mob_index[top_of_mobt + 1].number = 0;
                    new_mob_index[top_of_mobt + 1].func = NULL;

                    clear_char(new_mob_proto + top_of_mobt + 1);
                    new_mob_proto[top_of_mobt + 1] = *(d->edit_mob);
                    new_mob_proto[top_of_mobt + 1].in_room = NOWHERE;
                    new_mob_proto[top_of_mobt + 1].nr = top_of_mobt + 1;
                    /* it is now safe (and necessary!) to assign real number to
                     * the edit_mob, which has been -1 all this time */
                    d->edit_mob->nr = top_of_mobt + 1;
                }
                top_of_mobt++;

                /* we also have to renumber all the mobiles currently    *
                *  existing in the world. This is because when I start   *
                * extracting mobiles, bad things will happen!           */
                for (temp_mob = character_list; temp_mob; temp_mob = temp_mob->next)
                    if (GET_MOB_RNUM (temp_mob) >= d->edit_mob->nr)
                        GET_MOB_RNUM (temp_mob)++;

                /* free and replace old tables */
                delete [] mob_proto;
                delete [] mob_index;
                mob_proto = new_mob_proto;
                mob_index = new_mob_index;

                /* RENUMBER ZONE TABLES HERE, only              *
                *   because I ADDED a mobile!                   *
                *   This code shamelessly ripped off from db.c */

                int zone, cmd_no;
                for (zone = 0; zone <= top_of_zone_table; zone++)
                    for (cmd_no = 0; cmd_no < zone_table[zone].num_cmds; cmd_no++) {
                        switch (ZCMD.command) {
                        case 'M':
                            ZCMD.arg1 = (ZCMD.arg1 >= d->edit_mob->nr ? ZCMD.arg1 + 1 : ZCMD.arg1);
                            break;
                        }

                    }

            } // finally done putting the mobile into memory

            send_to_char("Writing mobile to disk...", CH);
            write_mobs_to_disk(d->character->player_specials->saved.zonenum);

            // again, here we don't delete it cause we don't want to end up
            // deleting the strings from the prototypes
            if (d->edit_mob)
                Mem->ClearCh(d->edit_mob);
            d->edit_mob = NULL;
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            send_to_char("Done.\r\n", d->character);
            break;
        case 'n':
        case 'N':
            send_to_char("Mobile not saved, aborting.\r\n", d->character);
            STATE(d) = CON_PLAYING;
            // complete nuke
            if (d->edit_mob)
                Mem->DeleteCh(d->edit_mob);
            d->edit_mob = NULL;
            d->edit_number = 0;
            d->edit_zone = 0;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("Invalid choice!\r\n", d->character);
            send_to_char("Do you wish to save this mobile internally?\r\n", d->character);
            break;
        }

        break;

    case MEDIT_MAIN_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            d->edit_mode = MEDIT_CONFIRM_SAVESTRING;
            medit_parse(d, "y");
            break;
        case 'x':
        case 'X':
            d->edit_mode = MEDIT_CONFIRM_SAVESTRING;
            medit_parse(d, "n");
            break;
        case '1':
            send_to_char("Enter keywords:", CH);
            d->edit_mode = MEDIT_EDIT_NAMELIST;
            break;
        case '2':
            send_to_char("Enter name:", CH);
            d->edit_mode = MEDIT_SHORT_DESCR;
            break;
        case '3':
            send_to_char("Enter room description:", CH);
            d->edit_mode = MEDIT_REG_DESCR;
            d->str = new (char *);
            if (!d->str) {
                mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE);
                shutdown();
            }

            *(d->str) = NULL;
            d->max_str = MAX_REG_DESC_LENGTH;
            d->mail_to = 0;
            break;
        case '4':
            // go to modify.cc
            send_to_char("Enter look description:\r\n", CH);
            d->edit_mode = MEDIT_LONG_DESCR;
            d->str = new (char *);
            if (!d->str) {
                mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE);
                shutdown();
            }

            *(d->str) = NULL;
            d->max_str = MAX_MESSAGE_LENGTH;
            d->mail_to = 0;
            break;
        case '5':
            medit_disp_mobflags_menu(d);
            d->edit_mode = MEDIT_MOB_FLAGS;
            break;
        case '6':
            medit_disp_affected_menu(d);
            d->edit_mode = MEDIT_AFF_FLAGS;
            break;
        case '8':
            send_to_char("Enter average nuyen: ", CH);
            d->edit_mode = MEDIT_NUYEN;
            break;
        case '9':
            send_to_char("Enter bonus karma points: ", CH);
            d->edit_mode = MEDIT_EXPERIENCE;
            break;
        case 'a':
            medit_disp_att_menu(d);
            d->edit_mode = MEDIT_ATTRIBUTES;
            break;
        case 'b':
            send_to_char("Enter level: ", CH);
            d->edit_mode = MEDIT_LEVEL;
            break;
        case 'c':
            send_to_char("Enter ballistic armor points: ", CH);
            d->edit_mode = MEDIT_BALLISTIC;
            break;
        case 'd':
            send_to_char("Enter impact armor points: ", CH);
            d->edit_mode = MEDIT_IMPACT;
            break;
        case 'e':
            send_to_char("Enter max physical points: ", CH);
            d->edit_mode = MEDIT_PHYSICAL;
            break;
        case 'f':
            send_to_char("Enter max mental points: ", CH);
            d->edit_mode = MEDIT_MENTAL;
            break;
        case 'g':
            medit_disp_pos_menu(d);
            send_to_char("Enter position: ", CH);
            d->edit_mode = MEDIT_POSITION;
            break;
        case 'h':
            medit_disp_pos_menu(d);
            send_to_char("Enter default position: ", CH);
            d->edit_mode = MEDIT_DEFAULT_POSITION;
            break;
        case 'i':
            medit_disp_gender_menu(d);
            d->edit_mode = MEDIT_GENDER;
            break;
        case 'j':
            send_to_char("Enter weight (in kilograms): ", CH);
            d->edit_mode = MEDIT_WEIGHT;
            break;
        case 'k':
            send_to_char("Enter height (in centimeters): ", CH);
            d->edit_mode = MEDIT_HEIGHT;
            break;
        case 'l':
            medit_disp_class_menu(d);
            d->edit_mode = MEDIT_CLASS;
            break;
        case 'm':
            medit_disp_attack_menu(d);
            d->edit_mode = MEDIT_ATTACK_TYPE;
            break;
        case 'n':
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
            break;
        case 'o':
            send_to_char("Enter arrive text: ", CH);
            d->edit_mode = MEDIT_ARRIVE_MSG;
            break;
        case 'p':
            send_to_char("Enter leave text: ", CH);
            d->edit_mode = MEDIT_LEAVE_MSG;
            break;

        default:
            medit_disp_menu(d);
            break;
        }
        break;

    case MEDIT_EDIT_NAMELIST:
        if (MOB->player.physical_text.keywords)
            delete [] MOB->player.physical_text.keywords;
        MOB->player.physical_text.keywords = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_SHORT_DESCR:
        if (MOB->player.physical_text.name)
            delete [] MOB->player.physical_text.name;
        MOB->player.physical_text.name = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_ARRIVE_MSG:
        if (MOB->mob_specials.arrive)
            delete [] MOB->mob_specials.arrive;
        MOB->mob_specials.arrive = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_LEAVE_MSG:
        if (MOB->mob_specials.leave)
            delete [] MOB->mob_specials.leave;
        MOB->mob_specials.leave = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_REG_DESCR:
        // you should not come here
        break;

    case MEDIT_LONG_DESCR:
        // you should not come here
        break;

    case MEDIT_MOB_FLAGS:
        number = atoi(arg);
        if ((number < 0) || (number > MOB_MAX))
            medit_disp_mobflags_menu(d);
        else {
            if (number == 0) // 0 = quit
                medit_disp_menu(d);
            else {
                MOB_FLAGS(MOB).ToggleBit(number-1);
                medit_disp_mobflags_menu(d);
            }
        }
        break;

    case MEDIT_AFF_FLAGS:
        number = atoi(arg);
        if ((number < 0) || (number > AFF_MAX))
            medit_disp_affected_menu(d);
        else {
            if (number == 0) // 0 = quit
                medit_disp_menu(d);
            else {
                AFF_FLAGS(MOB).ToggleBit(number - 1);
                medit_disp_affected_menu(d);
            }
        }
        break;

    case MEDIT_NUYEN:
        number = atoi(arg);
        if ((number < 0) || (number > 999999)) {
            send_to_char("Value must range between 0 and 999999.\r\n", CH);
            send_to_char("Enter average nuyen: ", CH);
        } else {
            GET_NUYEN(MOB) = number;
            send_to_char("Enter average credstick value: ", CH);
            d->edit_mode = MEDIT_CREDSTICK;
        }
        break;

    case MEDIT_CREDSTICK:
        number = atoi(arg);
        if ((number < 0) || (number > 999999)) {
            send_to_char("Value must range between 0 and 999999.\r\n", CH);
            send_to_char("Enter average credstick value: ", CH);
        } else {
            GET_BANK(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_EXPERIENCE:
        number = atoi(arg);
        if ((number < 0) || (number > 7500)) {
            send_to_char("Value must range between 0 and 7500.\r\n", CH);
            send_to_char("Enter bonus karma points: ", CH);
        } else {
            int karma;
            if (number > (karma=calc_karma(NULL, MOB))) {
                send_to_char("Bonus karma may not be higher than actual karma.  Lowering.\r\n", CH);
                number = karma;
            }
            GET_KARMA(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_SKILLS:
        switch (*arg) {
        case '0':
            medit_disp_menu(d);
            break;
        case '1':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL1;
            break;
        case '2':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL2;
            break;
        case '3':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL3;
            break;
        case '4':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL4;
            break;
        case '5':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL5;
            break;

        default:
            medit_disp_skill_menu(d);
            break;
        }
        break; // end of MEDIT_SKILLS

    case MEDIT_SKILL1:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL1_VAL;
        }
        break;

    case MEDIT_SKILL2:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL2_VAL;
        }
        break;
    case MEDIT_SKILL3:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL3_VAL;
        }
        break;
    case MEDIT_SKILL4:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL4_VAL;
        }
        break;
    case MEDIT_SKILL5:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL5_VAL;
        }
        break;

    case MEDIT_SKILL1_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[0] = 0;
            MOB->mob_specials.mob_skills[1] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[1] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[0]) = MOB->mob_specials.mob_skills[1];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0],
                      MOB->mob_specials.mob_skills[1]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL2_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[2] = 0;
            MOB->mob_specials.mob_skills[3] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[3] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[2]) = MOB->mob_specials.mob_skills[3];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[2],
                      MOB->mob_specials.mob_skills[3]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL3_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[4] = 0;
            MOB->mob_specials.mob_skills[5] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[5] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[4]) = MOB->mob_specials.mob_skills[5];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[4],
                      MOB->mob_specials.mob_skills[5]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL4_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[6] = 0;
            MOB->mob_specials.mob_skills[7] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[7] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[6]) = MOB->mob_specials.mob_skills[7];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[6],
                      MOB->mob_specials.mob_skills[7]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL5_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[8] = 0;
            MOB->mob_specials.mob_skills[9] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[9] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[8]) = MOB->mob_specials.mob_skills[9];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[8],
                      MOB->mob_specials.mob_skills[9]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;


    case MEDIT_ATTRIBUTES:
        switch (*arg) {
        case '1':
            send_to_char("Enter body attribute: ", CH);
            d->edit_mode = MEDIT_BOD;
            break;
        case '2':
            send_to_char("Enter quickness attribute: ", CH);
            d->edit_mode = MEDIT_QUI;
            break;
        case '3':
            send_to_char("Enter strength attribute: ", CH);
            d->edit_mode = MEDIT_STR;
            break;
        case '4':
            send_to_char("Enter charisma attribute: ", CH);
            d->edit_mode = MEDIT_CHA;
            break;
        case '5':
            send_to_char("Enter intelligence attribute: ", CH);
            d->edit_mode = MEDIT_INT;
            break;
        case '6':
            send_to_char("Enter willpower attribute: ", CH);
            d->edit_mode = MEDIT_WIL;
            break;
        case '7':
            send_to_char("Enter magic attribute: ", CH);
            d->edit_mode = MEDIT_MAG;
            break;
        case 'q':
        case 'Q': // back to main menu
            medit_disp_menu(d);
            break;
        default:
            medit_disp_att_menu(d);
            break;
        }
        break;

    case MEDIT_BOD:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter body attribute: ", CH);
        } else {
            GET_REAL_BOD(MOB) = number;
            MOB->real_abils.bod_index = number * 100;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_QUI:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter quickness attribute: ", CH);
        } else {
            GET_REAL_QUI(MOB) = number;
            GET_REAL_REA(MOB) = (number + GET_REAL_INT(MOB)) >> 1;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_STR:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter strength attribute: ", CH);
        } else {
            GET_REAL_STR(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_CHA:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter charisma attribute: ", CH);
        } else {
            GET_REAL_CHA(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_INT:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter intelligence attribute: ", CH);
        } else {
            GET_REAL_INT(MOB) = number;
            GET_REAL_REA(MOB) = (number + GET_REAL_QUI(MOB)) >> 1;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_WIL:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter willpower attribute: ", CH);
        } else {
            GET_REAL_WIL(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_MAG:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Value must range between 0 and 50.\r\n", CH);
            send_to_char("Enter magic attribute: ", CH);
        } else {
            MOB->real_abils.mag = number * 100;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_LEVEL:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Invalid choice.\r\n", CH);
            send_to_char("Enter level: ", CH);
        } else {
            GET_LEVEL(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_BALLISTIC:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter ballistic armor points: ", CH);
        } else {
            GET_BALLISTIC(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_IMPACT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter impact armor points: ", CH);
        } else {
            GET_IMPACT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_PHYSICAL:
        number = atoi(arg);
        if ((number < 0) || (number > 10)) {
            send_to_char("Value must range between 0 and 10.\r\n", CH);
            send_to_char("Enter max physical points: ", CH);
        } else {
            GET_MAX_PHYSICAL(MOB) = number * 100;
            GET_PHYSICAL(MOB) = number * 100;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_MENTAL:
        number = atoi(arg);
        if ((number < 0) || (number > 10)) {
            send_to_char("Value must range between 0 and 10.\r\n", CH);
            send_to_char("Enter max mental points: ", CH);
        } else {
            GET_MAX_MENTAL(MOB) = number * 100;
            GET_MENTAL(MOB) = number * 100;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_WEIGHT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter weight (in kilograms): ", CH);
        } else {
            GET_WEIGHT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_HEIGHT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter height (in centimeters): ", CH);
        } else {
            GET_HEIGHT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_CLASS:
        number = atoi(arg);
        if ((number < 1) || (number > NUM_MOB_CLASSES))
            medit_disp_class_menu(d);
        else {
            GET_RACE(MOB) = (number - 1);
            medit_disp_menu(d);
        }
        break;

    case MEDIT_POSITION:
        number = atoi(arg);
        if ((number < POS_MORTALLYW) || (number > POS_STANDING)) {
            send_to_char("Invalid choice.\r\nEnter position: ", CH);
            medit_disp_pos_menu(d);
        } else {
            GET_POS(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_DEFAULT_POSITION:
        number = atoi(arg);
        if ((number < POS_MORTALLYW) || (number > POS_STANDING)) {
            send_to_char("Invalid choice.\r\nEnter default position: ", CH);
            medit_disp_pos_menu(d);
        } else {
            GET_DEFAULT_POS(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_GENDER:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            send_to_char("Invalid choice.\r\n", CH);
            medit_disp_gender_menu(d);
        } else if (number != 0) // 0 = quit
            GET_SEX(MOB) = (number - 1);
        medit_disp_menu(d);
        break;

    case MEDIT_ATTACK_TYPE:
        number = atoi(arg);
        if ((number < 0) || (number > NUM_ATTACK_TYPES)) {
            send_to_char("Invalid choice.\r\n", CH);
            medit_disp_attack_menu(d);
        } else if (number != 0) // 0 = quit
            MOB->mob_specials.attack_type = number-1 + TYPE_HIT;
        medit_disp_menu(d);
        break;

    }
}
Esempio n. 28
0
/* 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)
{
  /* 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(OLC_SCRIPT(d)) equivalent */
      free_proto_script(OLC_ROOM(d), WLD_TRIGGER);
      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)) {
    if (OLC_ZONE(d)->builders)
      free(OLC_ZONE(d)->builders);
    if (OLC_ZONE(d)->name)
      free(OLC_ZONE(d)->name);
    if (OLC_ZONE(d)->cmd)
      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. OLC_SHOP(d) is a _copy_ - no pointers to the original. Just
   * go ahead and free it all. */
  if (OLC_SHOP(d))
      free_shop(OLC_SHOP(d));

  /* Check for a quest. */
  if (OLC_QUEST(d)) {
    switch (cleanup_type) {
      case CLEANUP_ALL:
        free_quest(OLC_QUEST(d));
        break;
      case CLEANUP_STRUCTS:
        free(OLC_QUEST(d));
        break;
      default:
        break;
    }
  }

  /*. Check for aedit stuff -- M. Scott */
  if (OLC_ACTION(d))  {
    switch(cleanup_type)  {
      case CLEANUP_ALL:
 	free_action(OLC_ACTION(d));
 	break;
      case CLEANUP_STRUCTS:
        free(OLC_ACTION(d));
        break;
      default:
        /* Caller has screwed up */
 	break;
    }
  }

  /* Used for cleanup of Hedit */
  if (OLC_HELP(d))  {
    switch(cleanup_type)  {
      case CLEANUP_ALL:
 	free_help(OLC_HELP(d));
 	break;
      case CLEANUP_STRUCTS:
        free(OLC_HELP(d));
        break;
      default:
 	break;
    }
  }

   if (OLC_IBT(d)) {
	   free_olc_ibt(OLC_IBT(d));
	   OLC_IBT(d) = NULL;
   }
   
   if (OLC_MSG_LIST(d)) {
     free_message_list(OLC_MSG_LIST(d));
     OLC_MSG_LIST(d) = NULL;  
     OLC_MSG(d) = NULL;
   }

  /* Free storage if allocated (tedit, aedit, and trigedit). 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;
   }

   /* Free this one regardless. If we've left olc, we've either copied the    *
    * preferences to the player, or we lost connection. Either way, we need   *
    * to get rid of this. */
   if(OLC_PREFS(d)) {
     /*. There is nothing else really to free, except this... .*/
     free(OLC_PREFS(d));
     OLC_PREFS(d) = NULL;
   }

   /* OLC_SCRIPT is always set as trig_proto of OLC_OBJ/MOB/ROOM. Therefore it
    * should not be free'd here. */

  /* Restore descriptor playing status. */
  if (d->character) {
    REMOVE_BIT_AR(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, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing the game configuration", GET_NAME(d->character));
    else if (STATE(d) == CON_TEDIT)
      mudlog(BRF, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing text files.", GET_NAME(d->character));
    else if (STATE(d) == CON_HEDIT)
      mudlog(CMP, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing help files.", GET_NAME(d->character));
    else
      mudlog(CMP, ADMLVL_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;
}
Esempio n. 29
0
// MAIN LOOP!
void zedit_parse(struct descriptor_data *d, char *arg)
{
    int number, i = 0, zone;

    switch (d->edit_mode)
    {
    case ZEDIT_CONFIRM_EDIT_DATA:
        switch (*arg) {
        case 'y':
        case 'Y':
            d->edit_zon = new zone_data;
            // we do need to zero it out since we are accessing its elements
            memset((char *) ZON, 0, sizeof(struct zone_data));

            *d->edit_zon = zone_table[d->edit_number];
            if (zone_table[d->edit_number].name)
                d->edit_zon->name = str_dup(zone_table[d->edit_number].name);
            zedit_disp_data_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", d->character);
            send_to_char("Do you wish to edit the data?\r\n", d->character);
            break;
        }
        break;
    case ZEDIT_CONFIRM_CREATE_DATA:
        switch (*arg) {
        case 'y':
        case 'Y':
            d->edit_zon = new zone_data;
            // we do need to zero it out since we are accessing its elements
            memset((char *) ZON, 0, sizeof(struct zone_data));

            // set a few vars
            ZON->name = str_dup("an unfinished zone");
            ZON->number = CH->player_specials->saved.zonenum;
            ZON->top = ZON->number * 100 + 99;
            zedit_disp_data_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", d->character);
            send_to_char("Do you wish to edit the data?\r\n", d->character);
            break;
        }
        break;
    case ZEDIT_CONFIRM_SAVEDATA:
        switch (*arg) {
            int zone_num;
        case 'y':
        case 'Y':
            zone_num = real_zone(ZON->number);
            sprintf(buf,"%s wrote new zcmd %ld in zone %d",
                    GET_CHAR_NAME(d->character), d->edit_number, zone_table[zone_num].number);
            mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            // first we insert into memory
            if (zone_num > -1) { // ie, it already exists
                ZON->cmd = zone_table[zone_num].cmd;
                delete [] zone_table[zone_num].name;
                zone_table[zone_num] = *ZON;
            } else { // here we got to add a new spot
                int counter;
                int found = 0;
                struct zone_data *new_z_table;
                // create new table + 2
                new_z_table = new struct zone_data[top_of_zone_table + 2];

                for (counter = 0; counter < top_of_zone_table + 1; counter++) {
                    if (!found) {
                        if (zone_table[counter].number > CH->player_specials->saved.zonenum) {
                            new_z_table[counter] = *(ZON);
                            found = 1;
                            new_z_table[counter + 1] = zone_table[counter];
                        } else
                            new_z_table[counter] = zone_table[counter];
                    } else
                        new_z_table[counter + 1] = zone_table[counter];
                }
                if (!found)
                    new_z_table[top_of_zone_table + 1] = *(ZON);
                top_of_zone_table++;
                delete [] zone_table;
                zone_table = new_z_table;
            }
            write_zone_to_disk(ZONENUM);
            write_index_file("zon");
            d->edit_mode = 0;
            delete ZON;
            ZON = NULL;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            STATE(d) = CON_PLAYING;
            send_to_char("Done.\r\n", d->character);

            break; // end of 'y' case in confirm savestring
        case 'n':
        case 'N':
            if (ZON) {
                if (ZON->name)
                    delete [] ZON->name;
                delete ZON;
            }
            STATE(d) = CON_PLAYING;
            ZON = NULL;
            d->edit_number = 0;
            PLR_FLAGS(CH).RemoveBit(PLR_EDITING);
            break; // end of 'n' case in confirm savestring
        default:
            send_to_char("Please enter yes or no.\r\n"
                         "Do you wish to save this zone internally?\r\n", CH);
            break;
        }
        break; // end of confirm savestring

    case ZEDIT_CONFIRM_ADD_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            COM->command = '*';
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to add a command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_CONFIRM_INSERT_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            COM->command = '*';
            // so it knows to insert if they decide to save
            d->edit_number2 = TRUE;
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to insert a command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_CONFIRM_EDIT_CMD:
        switch (*arg) {
        case 'y':
        case 'Y':
            COM = new reset_com;
            *COM = zone_table[real_zone(ZONENUM)].cmd[d->edit_number];
            zedit_disp_command_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to edit the command?\r\n", CH);
            break;
        }
        break;
    case ZEDIT_DATA_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            send_to_char("Do you wish to save this zone internally?\r\n", CH);
            d->edit_mode = ZEDIT_CONFIRM_SAVEDATA;
            break;
        case '1':
            send_to_char("Enter zone name: ", CH);
            d->edit_mode = ZEDIT_ZONE_NAME;
            break;
        case '2':
            send_to_char("Enter top of zone: ", CH);
            d->edit_mode = ZEDIT_TOP_OF_ZONE;
            break;
        case '3':
            send_to_char("Lifespan (in ticks between resets): ", CH);
            d->edit_mode = ZEDIT_LIFESPAN;
            break;
        case '4':
            CLS(CH);
            send_to_char("1) Don't reset\r\n"
                         "2) Reset only if no PCs are in the zone\r\n"
                         "3) Always reset\r\n"
                         "0) Quit\r\n"
                         "Enter reset mode: ", CH);
            d->edit_mode = ZEDIT_RESET_MODE;
            break;
        case '5':
            send_to_char("Zone security (1 (none) - 15 (paranoid)):\r\n", CH);
            d->edit_mode = ZEDIT_SECURITY;
            break;
        case '6':
            send_to_char("0) Seattle\r\n"
                         "1) Portland\r\n"
                         "Enter juridiction: ", CH);
            d->edit_mode = ZEDIT_JURID;
            break;
        case '7':
            if (!access_level(CH, LVL_VICEPRES)) {
                send_to_char("That's not a valid choice.\r\n", CH);
                return;
            }
            send_to_char("Enter ID list seperated by spaces:\r\n", CH);
            d->edit_mode = ZEDIT_ID_LIST;
            break;
        case '8':
            if (!access_level(CH, LVL_VICEPRES)) {
                send_to_char("That's not a valid choice.\r\n", CH);
                return;
            }
            send_to_char("Zone is connected (1 - yes, 0 - no)? ", CH);
            d->edit_mode = ZEDIT_CONNECTED;
            break;
        default:
            send_to_char("That's not a valid choice.\r\n", CH);
            zedit_disp_data_menu(d);
            break;
        }
        break;

    case ZEDIT_COMMAND_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            send_to_char("Do you wish to save this zone command internally?\r\n", CH);
            d->edit_mode = ZEDIT_CONFIRM_SAVECMDS;
            break;
        case '1':
            zedit_disp_type_cmd(d);
            d->edit_mode = ZEDIT_CMD_TYPE;
            break;
        case '2':
            send_to_char("\r\n1) Always\r\n2) If last\r\nEnter your selection: ",
                         CH);
            d->edit_mode = ZEDIT_IF_FLAG_CMD;
            break;
        case '3':
            switch (COM->command) {
            case 'M':
            case 'S':
                send_to_char("\r\nEnter virtual number of mob: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            case 'H':
            case 'U':
            case 'I':
            case 'O':
            case 'P':
            case 'E':
            case 'G':
            case 'R':
            case 'N':
            case 'C':
                send_to_char("\r\nEnter virtual number of obj: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            case 'D':
                zedit_disp_direction_menu(d);
                d->edit_mode = ZEDIT_DIRECTION_OF_DOOR;
                break;
            case 'V':
                send_to_char("\r\nEnter virtual number of vehicle: ", CH);
                d->edit_mode = ZEDIT_ARG1;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        case '4':
            switch (COM->command) {
            case 'M':
            case 'S':
            case 'U':
            case 'I':
            case 'O':
            case 'P':
            case 'E':
            case 'N':
            case 'G':
            case 'H':
            case 'V':
                send_to_char("Enter max allowed to exist in game: ", CH);
                d->edit_mode = ZEDIT_ARG2;
                break;
            case 'R':
            case 'D':
                send_to_char("Enter the room number: ", CH);
                d->edit_mode = ZEDIT_REMOVE_ROOM;
                break;
            case 'C':
                send_to_char(" 0) Cyberware\r\n 1) Bioware\r\nEnter location to place obj: ", CH);
                d->edit_mode = ZEDIT_ARG2;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        case '5':
            switch (COM->command) {
            case 'M':
            case 'O':
            case 'V':
                send_to_char("Enter the room number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'H':
                send_to_char("Enter the host number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'P':
                send_to_char("Enter the object number: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            case 'E':
                zedit_disp_wear_menu(d);
                d->edit_mode = ZEDIT_WEAR;
                break;
            case 'D':
                zedit_disp_state_menu(d);
                d->edit_mode = ZEDIT_DOOR_STATE;
                break;
            case 'N':
                send_to_char("Enter total number to give mob: ", CH);
                d->edit_mode = ZEDIT_ARG3;
                break;
            default:
                zedit_disp_command_menu(d);
                break;
            }
            break;
        }
        break;

    case ZEDIT_CONFIRM_SAVECMDS:
        int zone_num, top_of_cmds;
        switch (*arg) {
        case 'y':
        case 'Y':
            zone_num = real_zone(ZONENUM);
            top_of_cmds = zone_table[zone_num].num_cmds;
            sprintf(buf,"%s wrote new zcmd %ld in zone %d",
                    GET_CHAR_NAME(d->character), d->edit_number, zone_table[zone_num].number);
            mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            // first, determine if you are adding or replacing
            if (d->edit_number < top_of_cmds) {
                if (!d->edit_number2)
                    zone_table[zone_num].cmd[d->edit_number] = *(COM);
                else {
                    int counter;
                    struct reset_com *new_cmds;
                    new_cmds = new struct reset_com[top_of_cmds + 1];
                    if (top_of_cmds > 1) {
                        // first count your way up
                        for (counter = 0; counter < d->edit_number; counter++)
                            new_cmds[counter] = zone_table[zone_num].cmd[counter];
                        for (counter = top_of_cmds; counter > d->edit_number;
                                counter--)
                            new_cmds[counter] = zone_table[zone_num].cmd[counter-1];
                        new_cmds[d->edit_number] = *(COM);
                        zone_table[zone_num].num_cmds++;
                        delete [] zone_table[zone_num].cmd;
                        zone_table[zone_num].cmd = new_cmds;
                    } else {
                        new_cmds[1] = zone_table[zone_num].cmd[0];
                        new_cmds[0] = *(COM);
                        zone_table[zone_num].num_cmds++;
                        if (zone_table[zone_num].cmd)
                            delete [] zone_table[zone_num].cmd;
                        zone_table[zone_num].cmd = new_cmds;
                    }
                }
            } else {
                int counter;
                struct reset_com *new_cmds;
                // create a new set of commands, with 1 extra spot
                new_cmds = new struct reset_com[top_of_cmds + 1];
                // we know it is always going in at the end, so we copy the old 1st
                if (top_of_cmds > 0) { // you have to do this in case there are 0 cmds
                    for (counter = 0; counter < top_of_cmds; counter++)
                        new_cmds[counter] = zone_table[zone_num].cmd[counter];
                    // tada, here it goes now, do not increase counter, for loop
                    new_cmds[counter] = *(COM);          // already did!
                    zone_table[zone_num].num_cmds++;
                    delete [] zone_table[zone_num].cmd;
                    zone_table[zone_num].cmd = new_cmds;
                } else {
                    new_cmds[0] = *(COM);
                    zone_table[zone_num].num_cmds++;
                    if (zone_table[zone_num].cmd)
                        delete [] zone_table[zone_num].cmd;
                    zone_table[zone_num].cmd = new_cmds;
                }
            } // end else
            write_zone_to_disk(ZONENUM);
            d->edit_mode = 0;
            delete COM;
            COM = NULL;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            STATE(d) = CON_PLAYING;
            send_to_char("Done.\r\n", d->character);
            break; // for 'y' case
        case 'n':
        case 'N':
            if (COM)
                delete COM;
            STATE(d) = CON_PLAYING;
            COM = NULL;
            d->edit_number = 0;
            PLR_FLAGS(CH).RemoveBit(PLR_EDITING);
            break; // for 'n' case
        default:
            send_to_char("That's not a valid choice.\r\n", CH);
            send_to_char("Do you wish to save this zone command internally?\r\n", CH);
            break;
        } // for switch in confirm save cmds
        break; // for ZEDIT_CONFIRM_SAVECMDS

    case ZEDIT_ARG3:
        number = atoi(arg);
        switch (COM->command) {
        case 'H':
            COM->arg3 = MAX(0, real_host(number));
            break;
        case 'M':
        case 'V':
        case 'O':
            COM->arg3 = MAX(0, real_room(number));
            if (!access_level(CH, LVL_ADMIN) && !(number >= (ZONENUM * 100) &&
                                                  number <= zone_table[real_zone(ZONENUM)].top))
                COM->arg3 = 0;
            break;
        case 'P':
            COM->arg3 = MAX(0, real_object(number));
            if (!access_level(CH, LVL_ADMIN) && (number < 600 || number > 699)) {
                for (zone = 0; zone <= top_of_zone_table; zone++)
                    if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                        break;
                if (zone <= top_of_zone_table) {
                    for (i = 0; i < 5; i++)
                        if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                            break;
                } else
                    i = 5;
            }
            if (i >= 5)
                COM->arg3 = 0;
            break;
        case 'N':
            COM->arg3 = MIN(25, MAX(0, number));
            break;
        }
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_DOOR_STATE:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            zedit_disp_state_menu(d);
            return;
        } else if (number != 0)
            COM->arg3 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_WEAR:
        number = atoi(arg);
        if ((number < 0) || (number > (NUM_WEARS - 1))) {
            zedit_disp_wear_menu(d);
            return;
        } else if (number != 0)
            COM->arg3 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_REMOVE_ROOM:
        number = atoi(arg);
        COM->arg1 = MAX(0, real_room(number));
        if (!access_level(CH, LVL_ADMIN) && !(number >= (ZONENUM * 100) &&
                                              number <= zone_table[real_zone(ZONENUM)].top))
            COM->arg1 = 0;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_ARG2:
        number = atoi(arg);
        if (COM->command == 'C' && (number < 0 || number > 1)) {
            send_to_char("Value must be either 0 (cyberware) or 1 (bioware).\r\n"
                         "Enter location to place obj: ", CH);
            return;
        } else if ((number < -1) || (number > 1000)) {
            send_to_char("Value must be between -1 and 1000.\r\n"
                         "Enter max allowed to exist in game: ", CH);
            return;
        }
        COM->arg2 = number;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_DIRECTION_OF_DOOR:
        number = atoi(arg);
        if (number < 0 || number > 10) {
            zedit_disp_direction_menu(d);
            return;
        } else if (number != 0)
            COM->arg2 = number - 1;
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_ARG1:
        number = atoi(arg);
        if (COM->command == 'V') {
            COM->arg1 = MAX(0, real_vehicle(number));
        } else {
            if (COM->command == 'M' || COM->command == 'S') {
                COM->arg1 = MAX(0, real_mobile(number));
                if (!access_level(CH, LVL_ADMIN)) {
                    for (zone = 0; zone <= top_of_zone_table; zone++)
                        if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                            break;
                    if (zone <= top_of_zone_table) {
                        for (i = 0; i < 5; i++)
                            if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                                break;
                    } else
                        i = 5;
                }
                if (i >= 5)
                    COM->arg1 = 0;
            } else {
                if (COM->command == 'R')
                    COM->arg2 = MAX(0, real_object(number));
                else
                    COM->arg1 = MAX(0, real_object(number));
                if (!access_level(CH, LVL_ADMIN) && (number < 300 || number > 699 || (number > 499 && number < 600))) {
                    for (zone = 0; zone <= top_of_zone_table; zone++)
                        if (number >= (zone_table[zone].number * 100) && number <= zone_table[zone].top)
                            break;
                    if (zone <= top_of_zone_table) {
                        for (i = 0; i < 5; i++)
                            if (zone_table[zone].editor_ids[i] == GET_IDNUM(CH))
                                break;
                    } else
                        i = 5;
                }
                if (i >= 5) {
                    if (COM->command == 'R')
                        COM->arg2 = 0;
                    else
                        COM->arg1 = 0;
                }
            }
        }
        zedit_disp_command_menu(d);
        break;

    case ZEDIT_CMD_TYPE:
        number = atoi(arg);
        if ((number < 0) || (number > 9) && *arg != 'n') {
            zedit_disp_type_cmd(d);
            send_to_char("\r\nInvalid selection.  Please try again: ", CH);
            return;
        } else {
            COM->command = get_real_type(arg);
            if ((COM->command == 'E') || (COM->command == 'G') ||
                    (COM->command == 'P') || (COM->command == 'N') || (COM->command == 'C'))
                COM->if_flag = 1;
            else
                COM->if_flag = 0;
            COM->arg1 = 0;
            COM->arg2 = 0;
            COM->arg3 = 0;
        }

        zedit_disp_command_menu(d);
        break;

    case ZEDIT_IF_FLAG_CMD:
        number = atoi(arg);
        if ((number < 1) || (number > 2)) {
            send_to_char("Invalid selection.\r\n1) Always\r\n2) If last\r\n"
                         "Enter your selection: ", CH);
        } else {
            COM->if_flag = COM->if_flag;
            zedit_disp_command_menu(d);
        }
        break;

    case ZEDIT_ZONE_NAME:
        if (ZON->name)
            delete [] ZON->name;
        ZON->name = str_dup(arg);
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_SECURITY:
        number = atoi(arg);
        if (number < 1 || number > 15) {
            send_to_char("Security rating must range from 1 to 15.\r\nZone security: ", CH);
            return;
        }
        ZON->security = number;
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_ID_LIST: {
        int t[5] = {0, 0, 0, 0, 0};
        if (sscanf(arg, "%d %d %d %d %d\n", &t[0], &t[1], &t[2], &t[3], &t[4]) == 5) {
            ZON->editor_ids[0] = t[0];
            ZON->editor_ids[1] = t[1];
            ZON->editor_ids[2] = t[2];
            ZON->editor_ids[3] = t[3];
            ZON->editor_ids[4] = t[4];
        }
        zedit_disp_data_menu(d);
    }
    break;
    case ZEDIT_CONNECTED:
        number = atoi(arg);
        if (number != 0 && number != 1) {
            send_to_char("Value must be 0 or 1!  Zone is connected? ", CH);
            return;
        }

        sprintf(arg, "%s set zone %d to connected %d (was %d)",
                GET_CHAR_NAME( CH ), ZON->number, number, ZON->connected );
        mudlog(arg, CH, LOG_WIZLOG, TRUE);

        ZON->connected = number;
        zedit_disp_data_menu(d);
        break;
    case ZEDIT_TOP_OF_ZONE:
        number = atoi(arg);
        if ((d->edit_number == top_of_zone_table) || (d->edit_number == -1))
            if ((number < ZON->number * 100) || (number > (ZON->number * 100 + 499))) {
                send_to_char(CH, "Value must range from %d to %d\r\n", ZON->number * 100,
                             (ZON->number * 100 + 499));
                send_to_char("Enter top of zone: ", CH);
                return;
            } else
                ZON->top = number;
        else if ((number < ZON->number * 100) ||
                 (number > zone_table[d->edit_number + 1].number * 100 - 1)) {
            send_to_char(CH, "Value must range from %d to %d\r\n", ZON->number * 100,
                         zone_table[d->edit_number + 1].number * 100 - 1);
            send_to_char("Enter top of zone: ", CH);
            return;
        } else
            ZON->top = number;
        zedit_disp_data_menu(d);
        break;

    case ZEDIT_LIFESPAN:
        number = atoi(arg);
        if ((number < 0) || (number > 1440)) {
            send_to_char("Value must range from 0 to 1440\r\n", CH);
            send_to_char("Lifespan (in ticks between resets): ", CH);
        } else {
            ZON->lifespan = number;
            zedit_disp_data_menu(d);
        }
        break;

    case ZEDIT_RESET_MODE:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            send_to_char("Invalid choice.  Please enter from 0 to 3.\r\n", CH);
            send_to_char("Enter reset mode: ", CH);
            return;
        } else if (number != 0)
            ZON->reset_mode = number - 1;
        zedit_disp_data_menu(d);
        break;
    case ZEDIT_JURID:
        number = atoi(arg);
        if (number < 0 || number > 3) {
            send_to_char("Invalid choice.  Please enter from 0 to 1.\r\n", CH);
            send_to_char("Enter Juridiction: ", CH);
            return;
        } else
            ZON->juridiction = number;
        zedit_disp_data_menu(d);
        break;
    }
}
Esempio n. 30
0
void gain_exp_unchecked(CharData *ch, int gain)
{
    // PC mobs do NOT gain exps at all.
    if (IS_AFFECTED(ch, AFF_CHARM) || MOB_FLAGGED(ch, MOB_CONJURED))
        return;
 
    // stop xps clocking over.
    if ((GET_EXP(ch) > 2000000000) && gain > 0)
        return;

    if (!IS_NPC(ch) && ((GET_LEVEL(ch) < 1 || GET_LEVEL(ch) > MAX_MORTAL)))
        return;

    if (IN_ARENA(ch)) return;
    if (ZONE_FLAGGED(world[ch->in_room].zone, ZONE_ARENA)) return;
    if (ZONE_FLAGGED(world[ch->in_room].zone, ZONE_SLEEPTAG)) return;

    /* NPCs just get their exp mod and leave */
    if (IS_NPC(ch)) {
        GET_EXP(ch) += gain;
        return;
    }

    if (gain > 0) {
        if ((GET_EXP(ch) + gain ) > INT_MAX)
            return;

        GET_EXP(ch) += gain;

        /* Did the player just earn a level? */
        if( GET_LEVEL(ch) < MAX_MORTAL &&
           GET_EXP(ch) >= titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 1].exp)
        {
            send_to_char("You rise a level!\r\n", ch);
            GET_EXP(ch) = titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 1].exp;
            GET_LEVEL(ch) += 1;
            level_up(ch);
            set_title(ch, NULL);
        }
    } else if (gain < 0) {
        long thisLvl = (titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 0].exp);
        long nextLvl = (titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 1].exp);
        long neg100 = thisLvl - nextLvl + thisLvl;

        GET_EXP(ch) += gain;

        /* uh oh spaghettios! */
        if (GET_EXP(ch) < 0 && IS_MORTAL(ch)) {
            mudlog(NRM, LVL_IMMORT, TRUE, "SOUL DEATH: %s reduced to 0 xps by death, deleting!",
                    GET_NAME(ch));   
            sendChar(ch, "Your soul is too weak to return to the world...");
            sendChar(ch, "Utter darkness surrounds you as you slowly slip "
                         "into oblivion...");
            act("A look of utter despair crosses $n's face as their very soul"
                " is destroyed.", TRUE, ch, 0, 0, TO_ROOM );
            SET_BIT_AR(PLR_FLAGS(ch), PLR_DELETED);
            if (ch->desc) SET_DCPENDING(ch->desc);
        }

        /* Did the player just lose a level? */
        if (GET_LEVEL(ch) > 1 && IS_MORTAL(ch) && GET_EXP(ch) <= neg100) {
            send_to_char("You have lost a level!\r\n", ch);
            GET_LEVEL(ch) -= 1;
            retreat_level(ch);
            set_title(ch, NULL);

            /* make sure they don't drop below 0% at their new level */
            if (GET_EXP(ch) < titles[(int)GET_CLASS(ch)][GET_LEVEL(ch)].exp)
                GET_EXP(ch) = titles[(int)GET_CLASS(ch)][GET_LEVEL(ch)].exp;
        }
    }
}