示例#1
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);
}
示例#2
0
文件: names.cpp 项目: bodrich/bylins
// Check if name agree (name must be parsed)
int was_agree_name(DESCRIPTOR_DATA * d)
{
	log("was_agree_name start");
	FILE *fp;
	char temp[MAX_INPUT_LENGTH];
	char immname[MAX_INPUT_LENGTH];
	char mortname[6][MAX_INPUT_LENGTH];
	int immlev;
	int sex;
	int i;

//1. Load list

	if (!(fp = fopen(ANAME_FILE, "r")))
	{
		perror("SYSERR: Unable to open '" ANAME_FILE "' for reading");
	log("was_agree_name end");
		return (1);
	}
//2. Find name in list ...
	while (get_line(fp, temp))
	{
		// Format First name/pad1/pad2/pad3/pad4/pad5/sex immname immlev
		sscanf(temp, "%s %s %s %s %s %s %d %s %d", mortname[0],
			   mortname[1], mortname[2], mortname[3], mortname[4], mortname[5], &sex, immname, &immlev);
		if (!strcmp(mortname[0], GET_NAME(d->character)))
		{
			// We find char ...
			for (i = 1; i < 6; i++)
			{
				GET_PAD(d->character, i) = str_dup(mortname[i]);
			}
			GET_SEX(d->character) = sex;
			// Auto-Agree char ...
			NAME_GOD(d->character) = immlev + 1000;
			NAME_ID_GOD(d->character) = get_id_by_name(immname);
			sprintf(buf, "\r\nВаше имя одобрено!\r\n");
			SEND_TO_Q(buf, d);
			sprintf(buf, "AUTOAGREE: %s was agreed by %s", GET_PC_NAME(d->character), immname);
			log(buf, d);
			fclose(fp);
	log("was_agree_name end");
			return (0);
		}
	}
	fclose(fp);
	log("was_agree_name end");
	return (1);
}
示例#3
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);
}
示例#4
0
文件: clan.c 项目: ryantm/deimos-mud
 /* Apply to a clan for membership */
 void do_apply( struct char_data *ch, struct clan_type *cptr )
 {
   int i;
   long leader;

   if (IS_NPC(ch))
     return;

   if (!strcmp(cptr->leadersname, "NoOne") ) 
   {
     send_to_char("The clan is currently without a leader.\r\n", ch);
     return;
   }

   for (i = 0; i < 20; i++) {
     if (cptr->applicants[i] == NULL)
       break;
     if (!strcmp(cptr->applicants[i], GET_NAME(ch))) {
       send_to_char("You have already applied to this clan.\r\n", ch);
       return;
     }
   }
     if ((cptr->applicants[i] == NULL) && (i < 20)) {
       cptr->applicants[i] = str_dup(GET_NAME(ch));
       save_clans();
       /* send some sort of mail to leader notifying him/her of application */
       leader = get_id_by_name(cptr->leadersname);
       sprintf(buf, "%s,\r\n\r\n"
         "   Hi there!  I'd like to apply to your clan.  I have some abilities\r\n"
         "that I feel will be useful to you.  Please feel free to contact me \r\n"
         "for any information that you might need about me.\r\n"
         "Hope to hear from you soon!\r\n"
         "\r\n%s\r\n",
         cptr->leadersname, GET_NAME(ch));
       store_mail(leader, GET_IDNUM(ch), -1, buf);
       /* now that the mail has been sent, let's continue. */
       sprintf(buf, "Your application for admittance to %s has been noted.\r\n"
         "You will receive notification when you have been accepted.\r\n",
         cptr->name);
       send_to_char(buf, ch);
     } else
       send_to_char("This clan is already being applied to by 20 other players, try again later.\r\n", ch);
     save_clans();
     return;

 }
示例#5
0
文件: clan.c 项目: ryantm/deimos-mud
 /* Reject an applicant from a clan/Withdraw an application */
 void do_creject( struct char_data *ch, struct clan_type *cptr, struct char_data *vict)
 {
   int i=0;
   long leader;
 
   if (vict != ch) {
     if (vict != NULL) {
       /* send some sort of mail to player notifying him/her of rejection */
       sprintf(buf, "%s,\r\n\r\n"
         "   You have been rejected from the clan of %s.\r\n"
         "If you are unsure of the reason why, please feel\r\n"
         "free to contact the leader, %s.\r\n",
         GET_NAME(vict), cptr->name, cptr->leadersname);
       store_mail(GET_IDNUM(vict), GET_IDNUM(ch), -1, buf);
       /* mail's been sent, let's move on */
     }
   } else {
       for (i=0; i<20; i++) {
         if (!str_cmp(cptr->applicants[i], GET_NAME(ch))) {
           send_to_char("You aren't applying to the clan...\r\n", ch);
           break;
         }
       }
 
       /* send some sort of mail to leader notifying him/her of withdrawal */
       leader = get_id_by_name(cptr->leadersname);
       sprintf(buf, "%s,\r\n\r\n"
         "   I have withdrawn my application from the clan.\r\n"
         "\r\n%s\r\n",
         cptr->leadersname, GET_NAME(ch));
       store_mail(leader, GET_IDNUM(ch), -1, buf);
       /* now that the mail has been sent, let's continue. */
   }
   GET_CLAN(vict) = CLAN_NONE;
   GET_CLAN_RANK(vict) = 0;
   save_char(vict, NOWHERE);
   /* now remove the player from the petition list */
   remove_applicant(cptr, vict);
   save_clans();
   return;
 }
示例#6
0
文件: mail.c 项目: vedicveko/Dibrova
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;
} 
示例#7
0
文件: mail.c 项目: vedicveko/Dibrova
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;
}
示例#8
0
void hedit_parse(struct descriptor_data *d, char *arg)
{
	int i, j;

	if (OLC_MODE(d) > HEDIT_NUMERICAL_RESPONSE) {
		if (!isdigit(arg[0]) && ((*arg == '-') && (!isdigit(arg[1])))) {
			write_to_output(d, TRUE, "Field must be numerical, try again : ");
			return;
		}
	}
	switch (OLC_MODE(d)) {
/*-------------------------------------------------------------------*/
	case SEDIT_CONFIRM_SAVESTRING:
		switch (*arg) {
		case 'y':
		case 'Y':
			write_to_output(d, TRUE, "Saving house to memory.\r\n");
			hedit_save_internally(d);
			hedit_save_to_disk();
			extended_mudlog(BRF, SYSL_OLC, TRUE, "%s edits house %d.", GET_NAME(d->character), OLC_NUM(d));
			cleanup_olc(d, CLEANUP_STRUCTS);
			return;
		case 'n':
		case 'N':
			cleanup_olc(d, CLEANUP_ALL);
			return;
		default:
			write_to_output(d, TRUE, "Invalid choice!\r\nDo you wish to save the house? : ");
			return;
		}
		break;

/*-------------------------------------------------------------------*/
	case HEDIT_MAIN_MENU:
		i = 0;
		switch (*arg) {
		case 'q':
		case 'Q':
			if (OLC_VAL(d)) {		/* Anything been changed? */
				write_to_output(d, TRUE, "Do you wish to save the changes to the house? (y/n) : ");
				OLC_MODE(d) = HEDIT_CONFIRM_SAVESTRING;
			} else
				cleanup_olc(d, CLEANUP_ALL);
			return;
		case '0':
			OLC_MODE(d) = HEDIT_OWNER;
			write_to_output(d, TRUE, "Enter the name of the house owner : ");
			i--;
			return;
		case '1':
			OLC_MODE(d) = HEDIT_ATRIUM;
			write_to_output(d, TRUE, "Enter the room number of the atrium : ");
			i++;
			return;
		case '2':
			OLC_MODE(d) = HEDIT_EXIT;
			hedit_exits_menu(d);
			return;
		case '3':
			OLC_MODE(d) = HEDIT_MODE;
			hedit_modes_menu(d);
			return;
		case '4':
			OLC_MODE(d) = HEDIT_PRUNE_SAFE;
			hedit_prune_safe_menu(d);
			return;
		case '5':
			OLC_MODE(d) = HEDIT_COST;
			write_to_output(d, TRUE, "Enter the house cost : ");
			i++;
			return;
		case '6':
			OLC_MODE(d) = HEDIT_MAX_SECURE;
			write_to_output(d, TRUE, "Enter maximum number of secure containers : ");
			i++;
			return;
		case '7':
			OLC_MODE(d) = HEDIT_MAX_LOCKED;
			write_to_output(d, TRUE, "Enter maximum number of locked-down items : ");
			i++;
			return;
		case 'c':
		case 'C':
			hedit_owners_menu(d);
			return;
		case 'g':
		case 'G':
			hedit_guests_menu(d);
			return;
		case 'r':
		case 'R':
			hedit_rooms_menu(d);
			return;
		case 'd':
		case 'D':
			delete_house(d, OLC_NUM(d));
			cleanup_olc(d, CLEANUP_ALL);
			return;
		default:
			hedit_disp_menu(d);
			return;
		}

		if (i == 0)
			break;
		else if (i == 1)
			write_to_output(d, TRUE, "\r\nEnter new value : ");
		else if (i == -1)
			write_to_output(d, TRUE, "\r\nEnter new text :\r\n] ");
		else
			write_to_output(d, TRUE, "Oops...\r\n");
		return;
/*-------------------------------------------------------------------*/
	case HEDIT_ROOMS_MENU:
		switch (*arg) {
		case 'a':
		case 'A':
			write_to_output(d, TRUE, "\r\nEnter new room vnum number : ");
			OLC_MODE(d) = HEDIT_NEW_ROOM;
			return;
		case 'c':
		case 'C':
			hedit_compact_rooms_menu(d);
			return;
		case 'l':
		case 'L':
			hedit_rooms_menu(d);
			return;
		case 'd':
		case 'D':
			write_to_output(d, TRUE, "\r\nDelete which room? : ");
			OLC_MODE(d) = HEDIT_DELETE_ROOM;
			return;
		case 'q':
		case 'Q':
			break;
		}
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_COWNERS_MENU:
		switch (*arg) {
		case 'a':
		case 'A':
			write_to_output(d, TRUE, "\r\nEnter player name : ");
			OLC_MODE(d) = HEDIT_NEW_COWNER;
			return;
		case 'l':
		case 'L':
			hedit_owners_menu(d);
			return;
		case 'd':
		case 'D':
			write_to_output(d, TRUE, "\r\nDelete which co-owner? : ");
			OLC_MODE(d) = HEDIT_DELETE_COWNER;
			return;
		case 'q':
		case 'Q':
			break;
		}
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_GUESTS_MENU:
		switch (*arg) {
		case 'a':
		case 'A':
			write_to_output(d, TRUE, "\r\nEnter player name : ");
			OLC_MODE(d) = HEDIT_NEW_GUEST;
			return;
		case 'l':
		case 'L':
			hedit_guests_menu(d);
			return;
		case 'd':
		case 'D':
			write_to_output(d, TRUE, "\r\nDelete which guest? : ");
			OLC_MODE(d) = HEDIT_DELETE_GUEST;
			return;
		case 'q':
		case 'Q':
			break;
		}
		break;
/*-------------------------------------------------------------------*/
		/*
		 * Numerical responses.
		 */
/*-------------------------------------------------------------------*/
	case HEDIT_OWNER:
		if ((i = get_id_by_name(arg)) == NOBODY) {
			write_to_output(d, TRUE, "No such player, try again : ");
			return;
		}
		H_OWNER(OLC_HOUSE(d)) = i;
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_ATRIUM:
		if ((i = real_room(atoi(arg))) == NOWHERE) {
			write_to_output(d, TRUE, "No such room, try again : ");
			return;
		}
		if ((find_house(atoi(arg))) != NOWHERE) {
			write_to_output(d, TRUE, "That's a house room, try again : ");
			return;
		}
		H_ATRIUM(OLC_HOUSE(d)) = atoi(arg);
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_EXIT:
		/* Check for a valid exit. */
		if (atoi(arg) < 0 || atoi(arg) >= NUM_OF_DIRS) {
			write_to_output(d, TRUE, "\r\n&RThat's not a valid exit.&n\r\n\r\n");
			hedit_exits_menu(d);
			return;
		}
		/* Make sure we have a start room (first in list). */
		if ((i = real_room(H_ROOM(OLC_HOUSE(d), 0))) == NOWHERE) {
			write_to_output(d, TRUE, "\r\n&RYou have to define the starting room first.&n\r\n\r\n");
			break;
		}
		/* Make sure we have an atrium. */
		if ((j = real_room(H_ATRIUM(OLC_HOUSE(d)))) == NOWHERE) {
			write_to_output(d, TRUE, "\r\n&RYou have to define the atrium room first.&n\r\n\r\n");
			break;
		}
		/* Check for a valid exit leading out from start room. */
		if (TOROOM(i, atoi(arg)) == NOWHERE) {
			write_to_output(d, TRUE, "\r\n&RThere is no exit %s from room %d.&n\r\n\r\n", dirs[atoi(arg)], H_ROOM(OLC_HOUSE(d), 0));
			hedit_exits_menu(d);
			return;
		}
		/* Check for a valid return exit from the atrium. */
		if (TOROOM(j, rev_dir[atoi(arg)]) != i) {
			write_to_output(d, TRUE, "\r\n&RThe returning exit %s does not come from the atrium %d.&n\r\n\r\n", dirs[rev_dir[atoi(arg)]], H_ATRIUM(OLC_HOUSE(d)));
			hedit_exits_menu(d);
			return;
		}
		H_EXIT(OLC_HOUSE(d)) = atoi(arg);
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_MODE:
		i = atoi(arg);
		if (i < 0 || i >= NUM_HOUSE_FLAGS) {
			write_to_output(d, TRUE, "\r\n&RThat's not a valid house type.&n\r\n\r\n");
			hedit_modes_menu(d);
			return;
		}
		H_MODE(OLC_HOUSE(d)) = i;
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_PRUNE_SAFE:
		i = atoi(arg);
		if (i < 0 || i > 1) {
			write_to_output(d, TRUE, "\r\n&RValid choices are 0 or 1.&n\r\n\r\n");
			hedit_prune_safe_menu(d);
			return;
		}
		H_PRUNE_SAFE(OLC_HOUSE(d)) = i;
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_COST:
		H_COST(OLC_HOUSE(d)) = atoi(arg);
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_MAX_SECURE:
		if ((i = atoi(arg)) > HOUSE_MAX_SECURES) {
			write_to_output(d, TRUE, "Valid ranges are 0-%d : ", HOUSE_MAX_SECURES);
			return;
		}
		H_MAX_SECURE(OLC_HOUSE(d)) = i;
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_MAX_LOCKED:
		if ((i = atoi(arg)) > HOUSE_MAX_LOCKS) {
			write_to_output(d, TRUE, "Valid ranges are 0-%d : ", HOUSE_MAX_LOCKS);
			return;
		}
		H_MAX_LOCKED(OLC_HOUSE(d)) = i;
		break;
/*-------------------------------------------------------------------*/
	case HEDIT_NEW_ROOM:
		if ((i = atoi(arg)) != -1)
			if ((i = real_room(i)) < 0) {
				write_to_output(d, TRUE, "That room does not exist, try again : ");
				return;
			}
		if (i >= 0)
			add_to_house_list(&(H_ROOMS(OLC_HOUSE(d))), atoi(arg));
		hedit_rooms_menu(d);
		return;
	case HEDIT_DELETE_ROOM:
		remove_from_house_list(&(H_ROOMS(OLC_HOUSE(d))), atoi(arg));
		hedit_rooms_menu(d);
		return;

/*-------------------------------------------------------------------*/
	case HEDIT_NEW_COWNER:
		if ((i = get_id_by_name(arg)) == NOBODY) {
			write_to_output(d, TRUE, "No such player, try again : ");
			return;
		}
		if (i == H_OWNER(OLC_HOUSE(d))) {
			write_to_output(d, TRUE, "That player already owns the house, try again : ");
			return;
		}
		for (j = 0; H_COWNER(OLC_HOUSE(d), j) != NOBODY; j++) {
			if (i == H_COWNER(OLC_HOUSE(d), j)) {
				write_to_output(d, TRUE, "That player has already been added, try again : ");
				return;
			}
		}
		for (j = 0; H_GUEST(OLC_HOUSE(d), j) != NOBODY; j++) {
			if (i == H_GUEST(OLC_HOUSE(d), j)) {
				write_to_output(d, TRUE, "That player is listed as a guest, try again : ");
				return;
			}
		}
		if (i >= 0)
			add_to_house_list(&(H_COWNERS(OLC_HOUSE(d))), i);
		hedit_owners_menu(d);
		return;
	case HEDIT_DELETE_COWNER:
		remove_from_house_list(&(H_COWNERS(OLC_HOUSE(d))), atoi(arg));
		hedit_owners_menu(d);
		return;
/*-------------------------------------------------------------------*/
	case HEDIT_NEW_GUEST:
		if ((i = get_id_by_name(arg)) == NOBODY) {
			write_to_output(d, TRUE, "No such player, try again : ");
			return;
		}
		if (i == H_OWNER(OLC_HOUSE(d))) {
			write_to_output(d, TRUE, "That player already owns the house, try again : ");
			return;
		}
		for (j = 0; H_COWNER(OLC_HOUSE(d), j) != NOBODY; j++) {
			if (i == H_COWNER(OLC_HOUSE(d), j)) {
				write_to_output(d, TRUE, "That player is a co-owner, try again : ");
				return;
			}
		}
		for (j = 0; H_GUEST(OLC_HOUSE(d), j) != NOBODY; j++) {
			if (i == H_GUEST(OLC_HOUSE(d), j)) {
				write_to_output(d, TRUE, "That player has already been added, try again : ");
				return;
			}
		}
		if (i >= 0)
			add_to_house_list(&(H_GUESTS(OLC_HOUSE(d))), i);
		hedit_guests_menu(d);
		return;
	case HEDIT_DELETE_GUEST:
		remove_from_house_list(&(H_GUESTS(OLC_HOUSE(d))), atoi(arg));
		hedit_guests_menu(d);
		return;
/*-------------------------------------------------------------------*/
	default:
		/*
		 * We should never get here.
		 */
		cleanup_olc(d, CLEANUP_ALL);
		extended_mudlog(NRM, SYSL_BUGS, TRUE, "OLC: hedit_parse(): Reached default case!");
		write_to_output(d, TRUE, "Oops...\r\n");
		break;
	}
/*-------------------------------------------------------------------*/

/*
 * END OF CASE 
 * If we get here, we have probably changed something, and now want to
 * return to main menu.  Use OLC_VAL as a 'has changed' flag.
 */
	OLC_VAL(d) = 1;
	hedit_disp_menu(d);
}
示例#9
0
文件: house.c 项目: vedicveko/Dibrova
void hcontrol_build_house(struct char_data * ch, char *arg)
{
  char arg1[MAX_INPUT_LENGTH];
  struct house_control_rec temp_house;
  int virt_house, real_house, real_atrium, virt_atrium, exit_num;
  long owner;

  if (num_of_houses >= MAX_HOUSES) {
    send_to_char("Max houses already defined.\r\n", ch);
    return;
  }

  /* first arg: house's vnum */
  arg = one_argument(arg, arg1);
  if (!*arg1) {
    send_to_char(HCONTROL_FORMAT, ch);
    return;
  }
  virt_house = atoi(arg1);
  if ((real_house = real_room(virt_house)) < 0) {
    send_to_char("No such room exists.\r\n", ch);
    return;
  }
  if ((find_house(virt_house)) >= 0) {
    send_to_char("House already exists.\r\n", ch);
    return;
  }

  /* second arg: direction of house's exit */
  arg = one_argument(arg, arg1);
  if (!*arg1) {
    send_to_char(HCONTROL_FORMAT, ch);
    return;
  }
  if ((exit_num = search_block(arg1, dirs, FALSE)) < 0) {
    sprintf(buf, "'%s' is not a valid direction.\r\n", arg1);
    send_to_char(buf, ch);
    return;
  }
  if (TOROOM(real_house, exit_num) == NOWHERE) {
    sprintf(buf, "There is no exit %s from room %d.\r\n", dirs[exit_num],
	    virt_house);
    send_to_char(buf, ch);
    return;
  }

  real_atrium = TOROOM(real_house, exit_num);
  virt_atrium = world[real_atrium].number;

  if (TOROOM(real_atrium, rev_dir[exit_num]) != real_house) {
    send_to_char("A house's exit must be a two-way door.\r\n", ch);
    return;
  }

  /* third arg: player's name */
  arg = one_argument(arg, arg1);
  if (!*arg1) {
    send_to_char(HCONTROL_FORMAT, ch);
    return;
  }
  if ((owner = get_id_by_name(arg1)) < 0) {
    sprintf(buf, "Unknown player '%s'.\r\n", arg1);
    send_to_char(buf, ch);
    return;
  }

  temp_house.mode = HOUSE_PRIVATE;
  temp_house.vnum = virt_house;
  temp_house.atrium = virt_atrium;
  temp_house.exit_num = exit_num;
  temp_house.built_on = time(0);
  temp_house.last_payment = 0;
  temp_house.owner = owner;
  temp_house.num_of_guests = 0;

  house_control[num_of_houses++] = temp_house;

  SET_BIT_AR(ROOM_FLAGS(real_house), ROOM_HOUSE);
  SET_BIT_AR(ROOM_FLAGS(real_house), ROOM_PRIVATE);
  SET_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
  House_crashsave(virt_house);

  send_to_char("House built.  Mazel tov!\r\n", ch);
  House_save_control();
}