int board_display_msg(struct char_data *ch, char *arg) { char buf[512], number[MAX_INPUT_LENGTH], buffer[MAX_STRING_LENGTH]; int msg; one_argument(arg, number); if (!*number || !isdigit(*number)) return(0); if (!(msg = atoi(number))) return(0); if (!msg_num) { send_to_char("The board is empty!\n\r", ch); return(1); } if (msg < 1 || msg > msg_num) { send_to_char("That message exists only in your imagination..\n\r", ch); return(1); } /* sprintf(buf, "$n reads message %d titled : %s.", msg, head[msg - 1]); act(buf, TRUE, ch, 0, 0, TO_ROOM); */ /* Can PERFORM() handle this...? no. Sorry*/ /* sprintf(ch, "Message %d : %s\n\r%s", msg, head[msg - 1], msgs[msg - 1]); */ /* Bad news */ sprintf(buffer, "Message %d : %s\n\r\n\r%s", msg, head[msg - 1], msgs[msg - 1]); page_string(ch->desc, buffer, 1); return(1); }
void dream (CHAR_DATA *ch) { DREAM_DATA *dream; DREAM_DATA *dreamed; if ( !ch->pc || !ch->pc->dreams ) return; if ( GET_POS (ch) != POSITION_SLEEPING ) return; dream = ch->pc->dreams; ch->pc->dreams = dream->next; dream->next = NULL; if ( !ch->pc->dreamed ) ch->pc->dreamed = dream; else { for ( dreamed = ch->pc->dreamed; dreamed->next; ) dreamed = dreamed->next; dreamed->next = dream; } send_to_char ("While asleep, you have a dream.\n\n\r", ch); page_string (ch->desc, dream->dream); save_char (ch, TRUE); }
int board_show_board(struct char_data *ch, char *arg) { int i; char buf[MAX_STRING_LENGTH], tmp[MAX_INPUT_LENGTH]; one_argument(arg, tmp); if (!*tmp || !isname(tmp, "board bulletin")) return(0); act("$n studies the board.", TRUE, ch, 0, 0, TO_ROOM); strcpy(buf, "This is a bulletin board. Usage: READ/REMOVE <messg #>, WRITE <header>\n\r"); if (!msg_num) strcat(buf, "The board is empty.\n\r"); else { sprintf(buf + strlen(buf), "There are %d messages on the board.\n\r", msg_num); for (i = 0; i < msg_num; i++) sprintf(buf + strlen(buf), "%-2d : %s\n\r", i + 1, head[i]); } page_string(ch->desc, buf, 1); return(1); }
void perform_mob_level_list(struct char_data * ch, char *arg) { int num, mob_level, found = 0, len; struct char_data *mob; char buf[MAX_STRING_LENGTH]; mob_level = atoi(arg); if (mob_level < 0 || mob_level > 99) { send_to_char(ch, "Invalid mob level!\r\n"); return; } len = snprintf(buf, sizeof(buf), "Listing mobiles of level %s%d%s\r\n", QYEL, mob_level, QNRM); for(num=0;num<=top_of_mobt;num++) { if((mob_proto[num].player.level) == mob_level) { if ((mob = read_mobile(num, REAL)) != NULL) { char_to_room(mob, 0); len += snprintf(buf + len, sizeof(buf) - len, "%s%3d. %s[%s%5d%s]%s %s%s\r\n", CCNRM(ch, C_NRM),++found, CCCYN(ch, C_NRM), CCYEL(ch, C_NRM), GET_MOB_VNUM(mob), CCCYN(ch, C_NRM), CCNRM(ch, C_NRM), GET_NAME(mob), CCNRM(ch, C_NRM)); extract_char(mob); /* Finished with the mob - remove it from the MUD */ if (len > sizeof(buf)) break; } } } if (!found) send_to_char(ch,"None Found!\r\n"); else page_string(ch->desc, buf, TRUE); return; }
void perform_mob_flag_list(struct char_data * ch, char *arg) { int num, mob_flag, found = 0, len; struct char_data *mob; char buf[MAX_STRING_LENGTH]; mob_flag = atoi(arg); if (mob_flag < 0 || mob_flag > NUM_MOB_FLAGS) { send_to_char(ch, "Invalid flag number!\r\n"); return; } len = snprintf(buf, sizeof(buf), "Listing mobiles with %s%s%s flag set.\r\n", QYEL, action_bits[mob_flag], QNRM); for(num=0;num<=top_of_mobt;num++) { if(IS_SET_AR((mob_proto[num].char_specials.saved.act), mob_flag)) { if ((mob = read_mobile(num, REAL)) != NULL) { char_to_room(mob, 0); len += snprintf(buf + len, sizeof(buf) - len, "%s%3d. %s[%s%5d%s]%s Level %s%-3d%s %s%s\r\n", CCNRM(ch, C_NRM),++found, CCCYN(ch, C_NRM), CCYEL(ch, C_NRM), GET_MOB_VNUM(mob), CCCYN(ch, C_NRM), CCNRM(ch, C_NRM), CCYEL(ch, C_NRM), GET_LEVEL(mob), CCNRM(ch, C_NRM), GET_NAME(mob), CCNRM(ch, C_NRM)); extract_char(mob); /* Finished with the mob - remove it from the MUD */ if (len > sizeof(buf)) break; } } } if (!found) send_to_char(ch,"None Found!\r\n"); else page_string(ch->desc, buf, TRUE); return; }
/* List all rooms in a zone. */ static void list_rooms(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum vmax) { room_rnum i; room_vnum bottom, top; int j, counter = 0, len; char buf[MAX_STRING_LENGTH]; /* Expect a minimum / maximum number if the rnum for the zone is NOWHERE. */ if (rnum != NOWHERE) { bottom = zone_table[rnum].bot; top = zone_table[rnum].top; } else { bottom = vmin; top = vmax; } len = strlcpy(buf, "Index VNum Room Name Exits\r\n" "----- ------- -------------------------------------------- -----\r\n", sizeof(buf)); if (!top_of_world) return; for (i = 0; i <= top_of_world; i++) { /** Check to see if this room is one of the ones needed to be listed. **/ if ((world[i].number >= bottom) && (world[i].number <= top)) { counter++; len += snprintf(buf + len, sizeof(buf) - len, "%4d) [%s%-5d%s] %s%-*s%s %s", counter, QGRN, world[i].number, QNRM, QCYN, count_color_chars(world[i].name)+44, world[i].name, QNRM, world[i].proto_script ? "[TRIG] " : "" ); for (j = 0; j < DIR_COUNT; j++) { if (W_EXIT(i, j) == NULL) continue; if (W_EXIT(i, j)->to_room == NOWHERE) continue; if (world[W_EXIT(i, j)->to_room].zone != world[i].zone) len += snprintf(buf + len, sizeof(buf) - len, "(%s%d%s)", QYEL, world[W_EXIT(i, j)->to_room].number, QNRM); } len += snprintf(buf + len, sizeof(buf) - len, "\r\n"); if (len > sizeof(buf)) break; } } if (counter == 0) send_to_char(ch, "No rooms found for zone/range specified.\r\n"); else page_string(ch->desc, buf, TRUE); }
int Board_display_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board) { char number[MAX_INPUT_LENGTH], buffer[MAX_STRING_LENGTH]; int msg, ind; one_argument(arg, number); if (!*number) return (0); if (isname(number, board->name)) /* so "read board" works */ return (Board_show_board(board_type, ch, arg, board)); if (!is_number(number)) /* read 2.mail, look 2.sword */ return (0); if (!(msg = atoi(number))) return (0); if (GET_LEVEL(ch) < READ_LVL(board_type)) { send_to_char(ch, "You try but fail to understand the holy words.\r\n"); return (1); } if (!num_of_msgs[board_type]) { send_to_char(ch, "The board is empty!\r\n"); return (1); } if (msg < 1 || msg > num_of_msgs[board_type]) { send_to_char(ch, "That message exists only in your imagination.\r\n"); return (1); } #if NEWEST_AT_TOP ind = num_of_msgs[board_type] - msg; #else ind = msg - 1; #endif if (MSG_SLOTNUM(board_type, ind) < 0 || MSG_SLOTNUM(board_type, ind) >= INDEX_SIZE) { send_to_char(ch, "Sorry, the board is not working.\r\n"); log("SYSERR: Board is screwed up. (Room #%d)", GET_ROOM_VNUM(IN_ROOM(ch))); return (1); } if (!(MSG_HEADING(board_type, ind))) { send_to_char(ch, "That message appears to be screwed up.\r\n"); return (1); } if (!(msg_storage[MSG_SLOTNUM(board_type, ind)])) { send_to_char(ch, "That message seems to be empty.\r\n"); return (1); } snprintf(buffer, sizeof(buffer), "Message %d : %s\r\n\r\n%s\r\n", msg, MSG_HEADING(board_type, ind), msg_storage[MSG_SLOTNUM(board_type, ind)]); page_string(ch->desc, buffer, TRUE); return (1); }
void list_wands_staves (struct char_data *ch, char *input) { int type=0; int i=0; int j=0; int k=0; char *wsbuf = get_buffer(MAX_STRING_LENGTH); skip_spaces(&input); switch (input[0]) { case 'T': case 't': type = ITEM_STAFF; break; case 'W': case 'w': type = ITEM_WAND; break; default: extended_mudlog(NRM, SYSL_BUGS, TRUE, "Default reached in list_scrolls_potions (arg = %s)", input); release_buffer(wsbuf); return; } /*switch...*/ wsbuf[0]='\0'; for (i=0;i<top_of_objt;i++) { j=obj_proto[i].obj_flags.type_flag; /*look for specific sort of item*/ if (j == type) { /*found one*/ sprintf(wsbuf+strlen(wsbuf),"[%5d] %-30s", /*print vnum, short description*/ GET_OBJ_VNUM(&obj_proto[i]), obj_proto[i].short_description); /* * values 0-3: * Potion, Scroll - up to three spells [values 1-3] */ sprintf(wsbuf+strlen(wsbuf), " Spells: "); if (type==ITEM_STAFF) { /*staves have only one spell*/ if ((GET_OBJ_VAL(&obj_proto[i], 3)) != (-1)) sprintf(wsbuf+strlen(wsbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], 3))); } else { for (k=1; k < 4; k++) { if ((GET_OBJ_VAL(&obj_proto[i], k)) != (-1)) sprintf(wsbuf+strlen(wsbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], k))); } sprintf(wsbuf+strlen(wsbuf), "\r\n"); } } /*if j == type*/ } /*for i...*/ page_string (ch->desc, wsbuf, 1); release_buffer(wsbuf); }
void list_scrolls_potions (struct char_data *ch, char *input) { int type=0; int i=0; int j=0; int k=0; char *spbuf = get_buffer(MAX_STRING_LENGTH); skip_spaces(&input); switch (input[0]) { case 'S': case 's': type = ITEM_SCROLL; break; case 'P': case 'p': type = ITEM_POTION; break; default : mlog("SYSERR: Default reached in list_scrolls_potions (arg = %s)", input); release_buffer(spbuf); return; }/*switch...*/ spbuf[0]='\0'; for (i=0;i<top_of_objt;i++) { j=obj_proto[i].obj_flags.type_flag; /*look for specific sort of item*/ if (j == type) { /*found one*/ sprintf(spbuf+strlen(spbuf),"[%5d] %-20s", /*print vnum, short description*/ GET_OBJ_VNUM(&obj_proto[i]), obj_proto[i].short_description); /* * values 0-3: * Potion, Scroll - up to three spells [values 1-3] */ sprintf(spbuf+strlen(spbuf), " Spells: "); for (k=1;k<4;k++) { if ((GET_OBJ_VAL(&obj_proto[i], k)) != (-1)) sprintf(spbuf+strlen(spbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], k))); } sprintf(spbuf+strlen(spbuf), "\r\n"); }/*if j == type*/ }/*for i...*/ page_string (ch->desc, spbuf, 1); release_buffer(spbuf); }
void shopping_list(char *arg, struct char_data *ch, struct char_data * keeper, int shop_nr) { char buf[MAX_STRING_LENGTH], name[MAX_INPUT_LENGTH]; struct obj_data *obj, *last_obj = 0; int cnt = 0, index = 0; bool found = FALSE; if (!(is_ok(keeper, ch, shop_nr))) return; if (SHOP_SORT(shop_nr) < IS_CARRYING_N(keeper)) sort_keeper_objs(keeper, shop_nr); one_argument(arg, name); strcpy(buf, " ## Available Item Cost\n\r"); strcat(buf, "-------------------------------------------------------------------------\n\r"); if (keeper->carrying) for (obj = keeper->carrying; obj; obj = obj->next_content) if (CAN_SEE_OBJ(ch, obj) && (obj->obj_flags.cost > 0)) { if (!last_obj) { last_obj = obj; cnt = 1; } else if (same_obj(last_obj, obj)) cnt++; else { index++; if (!(*name) || isname(name, last_obj->name)) { strcat(buf, list_object(ch, last_obj, cnt, index, shop_nr)); found = TRUE; } cnt = 1; last_obj = obj; } } index++; if (!last_obj) stc("Currently, there is nothing for sale.\r\n", ch); else if (*name && !found) stc("Presently, none of those are for sale.\r\n", ch); else { if (!(*name) || isname(name, last_obj->name)) strcat(buf, list_object(ch, last_obj, cnt, index, shop_nr)); page_string(ch->desc, buf, 1); } }
int Board_display_msg(int board_type, struct char_data *ch, char *arg) { char buf[512], number[MAX_STRING_LENGTH], buffer[MAX_STRING_LENGTH]; int msg, ind; one_argument(arg, number); if (!*number || !isdigit(*number)) return 0; if (!(msg = atoi(number))) return 0; if (GET_LEVEL(ch) < READ_LVL(board_type)) { send_to_char("You try but fail to understand the holy words.\n\r", ch); return 1; } if (!num_of_msgs[board_type]) { send_to_char("The board is empty!\n\r", ch); return(1); } if (msg < 1 || msg > num_of_msgs[board_type]) { send_to_char("That message exists only in your imagination..\n\r", ch); return(1); } ind = msg - 1; if (MSG_SLOTNUM(board_type, ind) < 0 || MSG_SLOTNUM(board_type, ind) >= INDEX_SIZE) { send_to_char("Sorry, the board is not working.\n\r", ch); log("Board is screwed up."); return 1; } if (!(MSG_HEADING(board_type, ind))) { send_to_char("That message appears to be screwed up.\n\r", ch); return 1; } if(!(msg_storage[MSG_SLOTNUM(board_type, ind)])) { send_to_char("That message seems to be empty.\n\r", ch); return 1; } sprintf(buffer, "Message %d : %s\n\r\n\r%s\n\r", msg, MSG_HEADING(board_type, ind), msg_storage[MSG_SLOTNUM(board_type, ind)]); page_string(ch->desc, buffer, 1); return 1; }
void gen_board_read(struct board_data *board, struct creature *ch, char *argument) { struct creature *player; PGresult *res; time_t post_time; char time_buf[30]; int idx; 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->read_perms, player)) { send_to_char(ch, "%s\r\n", board->deny_read); return; } idx = atoi(argument) - 1; if (idx < 0) { send_to_char(ch, "That is not a valid message.\r\n"); return; } res = sql_query ("select extract(epoch from post_time), name, subject, body from board_messages where board='%s' order by idnum limit 1 offset %d", tmp_sqlescape(board->name), idx); if (PQntuples(res) == 0) { send_to_char(ch, "That message does not exist on this board.\r\n"); return; } acc_string_clear(); post_time = atol(PQgetvalue(res, 0, 0)); strftime(time_buf, 30, "%a %b %e %Y", localtime(&post_time)); acc_sprintf("%sMessage %s : %s %-12s :: %s%s\r\n\r\n%s\r\n", CCBLD(ch, C_CMP), argument, time_buf, tmp_sprintf("(%s)", PQgetvalue(res, 0, 1)), CCNRM(ch, C_CMP), PQgetvalue(res, 0, 2), PQgetvalue(res, 0, 3)); page_string(ch->desc, acc_get_string()); }
/* List all zones in the world (sort of like 'show zones'). */ static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax, char *name) { int counter = 0, len=0, tmp_len = 0; zone_rnum i; zone_vnum bottom, top; char buf[MAX_STRING_LENGTH]; bool use_name=FALSE; bottom = vmin; top = vmax; if (rnum != NOWHERE) { /* Only one parameter was supplied - just list that zone */ print_zone(ch, zone_table[rnum].number); return; } else if (name && *name) { use_name = TRUE; if (!vmin) bottom = zone_table[0].number; /* Lowest Zone */ if (!vmax) top = zone_table[top_of_zone_table].number; /* Highest Zone */ } len = snprintf(buf, sizeof(buf), "VNum Zone Name Builder(s)\r\n" "----- ------------------------------ --------------------------------------\r\n"); if (!top_of_zone_table) return; for (i = 0; i <= top_of_zone_table; i++) { if (zone_table[i].number >= bottom && zone_table[i].number <= top) { if ((!use_name) || (is_name(name, zone_table[i].builders))) { tmp_len = snprintf(buf+len, sizeof(buf)-len, "[%s%3d%s] %s%-*s %s%-1s%s\r\n", QGRN, zone_table[i].number, QNRM, QCYN, count_color_chars(zone_table[i].name)+30, zone_table[i].name, QYEL, zone_table[i].builders ? zone_table[i].builders : "None.", QNRM); len += tmp_len; counter++; } } } if (!counter) send_to_char(ch, " None found within those parameters.\r\n"); else page_string(ch->desc, buf, TRUE); }
void do_dreams (CHAR_DATA *ch, char *argument, int cmd) { char buf [MAX_STRING_LENGTH] = {'\0'}; DREAM_DATA *dream; int count = 0; if ( IS_NPC (ch) ) { send_to_char ("This is a PC only command.\n\r", ch); return; } if ( !ch->pc->dreamed ) { send_to_char ("You don't recall anything memorable.\n\r", ch); return; } argument = one_argument (argument, buf); for ( dream = ch->pc->dreamed; dream; dream = dream->next ) count++; if ( !*buf ) { snprintf (buf, MAX_STRING_LENGTH, "You recall having %d dream%s.\n\r", count, count > 1 ? "s" : ""); send_to_char (buf, ch); return; } if ( !isdigit (*buf) ) { send_to_char ("Either type 'dreams' or 'dreams <number>'.\n\r", ch); return; } if ( strtol(buf, NULL, 10) > count || strtol(buf, NULL, 10) < 1 ) { send_to_char ("That number doesn't correspond to a dream.\n\r", ch); return; } count = strtol(buf, NULL, 10) - 1; for ( dream = ch->pc->dreamed; count; count-- ) dream = dream->next; page_string (ch->desc, dream->dream); }
int Board_display_msg(int board_type, struct char_data * ch, char *arg) { char number[MAX_STRING_LENGTH], buffer[MAX_STRING_LENGTH]; int msg, ind; one_argument(arg, number); if (!*number) return 0; if (isname(number, "board bulletin")) /* so "read board" works */ return (Board_show_board(board_type, ch, arg)); if (!isdigit(*number) || (!(msg = atoi(number)))) return 0; if (READ_LVL(board_type) != 0 && !COM_FLAGGED(ch, READ_LVL(board_type))) { send_to_char("You try but fail to understand the holy words.\r\n", ch); return 1; } if (!num_of_msgs[board_type]) { send_to_char("The board is empty!\r\n", ch); return (1); } if (msg < 1 || msg > num_of_msgs[board_type]) { send_to_char("That message exists only in your imagination.\r\n", ch); return (1); } ind = msg - 1; if (MSG_SLOTNUM(board_type, ind) < 0 || MSG_SLOTNUM(board_type, ind) >= INDEX_SIZE) { send_to_char("Sorry, the board is not working.\r\n", ch); stderr_log("SYSERR: Board is screwed up."); return 1; } if (!(MSG_HEADING(board_type, ind))) { send_to_char("That message appears to be screwed up.\r\n", ch); return 1; } if (!(msg_storage[MSG_SLOTNUM(board_type, ind)])) { send_to_char("That message seems to be empty.\r\n", ch); return 1; } sprintf(buffer, "Message %d : %s\r\n\r\n%s\r\n", msg, MSG_HEADING(board_type, ind), msg_storage[MSG_SLOTNUM(board_type, ind)]); page_string(ch->desc, buffer, 1); return 1; }
/* List all objects in a zone. */ static void list_objects(struct char_data *ch, zone_rnum rnum, obj_vnum vmin, obj_vnum vmax) { obj_rnum i; obj_vnum bottom, top; char buf[MAX_STRING_LENGTH]; int counter = 0; int len; if (rnum != NOWHERE) { bottom = zone_table[rnum].bot; top = zone_table[rnum].top; } else { bottom = vmin; top = vmax; } len = strlcpy(buf, "Index VNum Object Name Object Type\r\n" "----- ------- -------------------------------------------- ----------------\r\n", sizeof(buf)); if (!top_of_objt) return; for (i = 0; i <= top_of_objt; i++) { if (obj_index[i].vnum >= bottom && obj_index[i].vnum <= top) { counter++; len += snprintf(buf + len, sizeof(buf) - len, "%s%4d%s) [%s%-5d%s] %s%-*s %s[%s]%s%s\r\n", QGRN, counter, QNRM, QGRN, obj_index[i].vnum, QNRM, QCYN, count_color_chars(obj_proto[i].short_description)+44, obj_proto[i].short_description, QYEL, item_types[obj_proto[i].obj_flags.type_flag], QNRM, obj_proto[i].proto_script ? " [TRIG]" : "" ); if (len > sizeof(buf)) break; } } if (counter == 0) send_to_char(ch, "None found.\r\n"); else page_string(ch->desc, buf, TRUE); }
void hcontrol_list_houses(struct char_data * ch) { int i, j; char *timestr, *temp; char built_on[128], last_pay[128], own_name[128]; if (!num_of_houses) { send_to_char("No houses have been defined.\r\n", ch); return; } strcpy(buf, "Address Atrium Build Date Guests Owner Last Paymt\r\n"); strcat(buf, "------- ------ ---------- ------ ------------ ----------\r\n"); for (i = 0; i < num_of_houses; i++) { if (house_control[i].built_on) { timestr = asctime(localtime(&(house_control[i].built_on))); *(timestr + 10) = 0; strcpy(built_on, timestr); } else strcpy(built_on, "Unknown"); if (house_control[i].last_payment) { timestr = asctime(localtime(&(house_control[i].last_payment))); *(timestr + 10) = 0; strcpy(last_pay, timestr); } else strcpy(last_pay, "None"); strcpy(own_name, NAME(house_control[i].owner)); sprintf(buf, "%s%7d %7d %-10s %2d %-12s %s\r\n", buf, house_control[i].vnum, house_control[i].atrium, built_on, house_control[i].num_of_guests, CAP(own_name), last_pay); if (house_control[i].num_of_guests) { strcat(buf, " Guests: "); for (j = 0; j < house_control[i].num_of_guests; j++) { sprintf(buf2, "%s ", NAME(house_control[i].guests[j])); strcat(buf, CAP(buf2)); } strcat(buf, "\r\n"); } } page_string(ch->desc, buf, 1); }
/** * Показ лога славы (show glory), отсортированного по убыванию даты, с возможностью фильтрациии. * Фильтры: show glory число|transfer|remove|hide */ void show_log(CHAR_DATA *ch , char const * const value) { if (glory_log.empty()) { send_to_char("Пусто, слава те господи!\r\n", ch); return; } int type = 0; int num = 0; std::string buffer; if (value && *value) buffer = value; if (CompareParam(buffer, "transfer")) type = TRANSFER_GLORY; else if (CompareParam(buffer, "remove")) type = REMOVE_GLORY; else if (CompareParam(buffer, "hide")) type = HIDE_GLORY; else { try { num = boost::lexical_cast<int>(buffer); } catch (boost::bad_lexical_cast &) { type = 0; num = 0; } } std::stringstream out; for (GloryLogType::reverse_iterator it = glory_log.rbegin(); it != glory_log.rend(); ++it) { if (type == it->second->type || (type == 0 && num == 0) || (type == 0 && num <= it->second->num)) { char time_buf[17]; strftime(time_buf, sizeof(time_buf), "%H:%M %d-%m-%Y", localtime(&it->first)); out << time_buf << " " << it->second->karma << "\r\n"; } } page_string(ch->desc, out.str()); }
static void show_messages(struct char_data *ch) { int i, half = MAX_MESSAGES / 2, count = 0; char buf[MAX_STRING_LENGTH]; int len; len = snprintf(buf, sizeof(buf), "\t1Message List:\tn \r\n"); for (i = 0; i < MAX_MESSAGES / 2; i++, half++) if (fight_messages[i].msg != NULL && len < sizeof(buf)) { count += fight_messages[i].number_of_attacks; len += snprintf(buf + len, sizeof(buf) - len, "%-2d) [%-3d] %d, %-18s%s", i, fight_messages[i].a_type, fight_messages[i].number_of_attacks, fight_messages[i].a_type < TOP_SPELL_DEFINE ? spell_info[fight_messages[i].a_type].name : "Unknown", half < MAX_MESSAGES && fight_messages[half].msg ? " " : "\r\n"); if (half < MAX_MESSAGES && fight_messages[half].msg) len += snprintf(buf + len, sizeof(buf) - len, "%-2d) [%-3d] %d, %-18s\r\n", half, fight_messages[half].a_type, fight_messages[half].number_of_attacks, fight_messages[half].a_type < TOP_SPELL_DEFINE ? spell_info[fight_messages[half].a_type].name : "Unknown"); } len += snprintf(buf + len, sizeof(buf) - len, "Total Messages: %d\r\n", count); page_string(ch->desc, buf, TRUE); }
/* List all mobiles in a zone. */ static void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin, mob_vnum vmax) { mob_rnum i; mob_vnum bottom, top; int counter = 0, len; char buf[MAX_STRING_LENGTH]; if (rnum != NOWHERE) { bottom = zone_table[rnum].bot; top = zone_table[rnum].top; } else { bottom = vmin; top = vmax; } len = strlcpy(buf, "Index VNum Mobile Name Level\r\n" "----- ------- -------------------------------------------- -----\r\n", sizeof(buf)); if (!top_of_mobt) return; for (i = 0; i <= top_of_mobt; i++) { if (mob_index[i].vnum >= bottom && mob_index[i].vnum <= top) { counter++; len += snprintf(buf + len, sizeof(buf) - len, "%s%4d%s) [%s%-5d%s] %s%-*s %s[%4d]%s%s\r\n", QGRN, counter, QNRM, QGRN, mob_index[i].vnum, QNRM, QCYN, count_color_chars(mob_proto[i].player.short_descr)+44, mob_proto[i].player.short_descr, QYEL, mob_proto[i].player.level, QNRM, mob_proto[i].proto_script ? " [TRIG]" : "" ); if (len > sizeof(buf)) break; } } if (counter == 0) send_to_char(ch, "None found.\r\n"); else page_string(ch->desc, buf, TRUE); }
int Board_show_board(int board_type, struct char_data * ch, char *arg) { int i; char tmp[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH]; if (!ch->desc) return 0; one_argument(arg, tmp); if (!*tmp || !isname(tmp, "board bulletin")) return 0; if (READ_LVL(board_type) != 0 && !COM_FLAGGED(ch, READ_LVL(board_type))) { send_to_char("You try but fail to understand the holy words.\r\n", ch); return 1; } act("$n studies the board.", TRUE, ch, 0, 0, TO_ROOM); strcpy(buf, "This is a bulletin board. Usage: READ/REMOVE <messg #>, WRITE <header>.\r\n" "You will need to look at the board to save your message.\r\n"); if (!num_of_msgs[board_type]) strcat(buf, "The board is empty.\r\n"); else { sprintf(buf + strlen(buf), "There are %d messages on the board.\r\n", num_of_msgs[board_type]); /* uncomment below if want most recent message at bottom */ /* for (i = 0; i < num_of_msgs[board_type]; i++) { */ for (i = num_of_msgs[board_type] - 1; i >= 0; i--) { if (MSG_HEADING(board_type, i)) sprintf(buf + strlen(buf), "%s%-2d%s : %s%s\r\n", CBWHT(ch, C_NRM), i + 1, CCCYN(ch, C_NRM), MSG_HEADING(board_type, i), CCNRM(ch, C_NRM)); else { stderr_log("SYSERR: The board is fubar'd."); send_to_char("Sorry, the board isn't working.\r\n", ch); return 1; } } } page_string(ch->desc, buf, 1); return 1; }
void perform_obj_name_list(struct char_data * ch, char *arg) { int num, found = 0, len = 0, tmp_len = 0; obj_vnum ov; char buf[MAX_STRING_LENGTH]; len = snprintf(buf, sizeof(buf), "Objects with the name '%s'\r\n" "Index VNum Num Object Name Object Type\r\n" "----- ------- ----- ------------------------------------------ ----------------\r\n", arg); for (num=0;num<=top_of_objt;num++) { if (is_name(arg, obj_proto[num].name)) { ov = obj_index[num].vnum; tmp_len = snprintf(buf+len, sizeof(buf)-len, "%s%4d%s) %s[%s%5d%s] %s(%s%3d%s)%s %-*s%s [%s]%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, QGRN, obj_index[num].number, QNRM, QCYN, 42+count_color_chars(obj_proto[num].short_description), obj_proto[num].short_description, QYEL, item_types[obj_proto[num].obj_flags.type_flag], QNRM, obj_proto[num].proto_script ? " [TRIG]" : ""); len += tmp_len; } } page_string(ch->desc, buf, TRUE); }
int Board_show_board(int board_type, struct char_data *ch) { int i; char buf[MAX_STRING_LENGTH]; if (!ch->desc) return 0; if (GET_LEVEL(ch) < READ_LVL(board_type)) { send_to_char("You try but fail to understand the holy words.\n\r", ch); return 1; } act("$n studies the board.", TRUE, ch, 0, 0, TO_ROOM); strcpy(buf, "This is a bulletin board. Usage: READ/ERASE <messg #>, WRITE <header>.\n\r"); if (!num_of_msgs[board_type]) strcat(buf, "The board is empty.\n\r"); else { sprintf(buf + strlen(buf), "There are %d messages on the board.\n\r", num_of_msgs[board_type]); for (i = 0; i < num_of_msgs[board_type]; i++) { if (MSG_HEADING(board_type, i)) sprintf(buf + strlen(buf), "%-2d : %s\n\r", i + 1, MSG_HEADING(board_type, i)); else { log("The board is fubar'd."); send_to_char("Sorry, the board isn't working.\n\r", ch); return 1; } } } page_string(ch->desc, buf, 1); return 1; }
/** * Searches for all uses of a craft and displays them. * * @param char_data *ch The player. * @param craft_vnum vnum The craft vnum. */ void olc_search_craft(char_data *ch, craft_vnum vnum) { char buf[MAX_STRING_LENGTH]; craft_data *craft = craft_proto(vnum); int size, found; if (!craft) { msg_to_char(ch, "There is no craft %d.\r\n", vnum); return; } found = 0; size = snprintf(buf, sizeof(buf), "Occurrences of craft %d (%s):\r\n", vnum, GET_CRAFT_NAME(craft)); // crafts are not found anywhere in the world yet if (found > 0) { size += snprintf(buf + size, sizeof(buf) - size, "%d location%s shown\r\n", found, PLURAL(found)); } else { size += snprintf(buf + size, sizeof(buf) - size, " none\r\n"); } page_string(ch->desc, buf, TRUE); }
void gen_board_show(struct creature *ch) { PGresult *res; int idx, count; res = sql_query ("select board, COUNT(*) from board_messages group by board order by count desc"); count = PQntuples(res); if (count == 0) { send_to_char(ch, "There are no messages on any board.\r\n"); return; } acc_string_clear(); acc_sprintf ("Board Count\r\n--------------------------\r\n"); for (idx = 0; idx < count; idx++) acc_sprintf("%-20s %5s\r\n", PQgetvalue(res, idx, 0), PQgetvalue(res, idx, 1)); page_string(ch->desc, acc_get_string()); }
void perform_obj_aff_list(struct char_data * ch, char *arg) { int num, i, apply, v1 = 0, found = 0, len = 0, tmp_len = 0; struct obj_list_item lst[MAX_OBJ_LIST]; obj_rnum r_num; obj_vnum ov; char buf[MAX_STRING_LENGTH]; for(i=0;i<MAX_OBJ_LIST;i++){ lst[i].vobj = NOTHING; lst[i].val = 0; } apply = atoi(arg); if (!(apply>0 && apply<NUM_APPLIES) ){ send_to_char(ch, "Not a valid affect"); return; } /* Special cases below */ else if ((apply == APPLY_CLASS) || /* olist affect 7 is Weapon Damage */ (apply == APPLY_LEVEL) ) { /* olist affect 8 is AC-Apply for Armor */ for (num=0;num<=top_of_objt;num++) { if ((apply == APPLY_CLASS && obj_proto[num].obj_flags.type_flag == ITEM_WEAPON) || (apply == APPLY_LEVEL && obj_proto[num].obj_flags.type_flag == ITEM_ARMOR) ) { ov = obj_index[num].vnum; if (apply == APPLY_CLASS) v1 = ((obj_proto[num].obj_flags.value[2]+1)*(obj_proto[num].obj_flags.value[1])/2); else v1 = (obj_proto[num].obj_flags.value[0]); if ((r_num = real_object(ov)) != NOTHING) add_to_obj_list(lst, MAX_OBJ_LIST, ov, v1); } } if (apply == APPLY_CLASS) len = snprintf(buf, sizeof(buf), "Highest average damage per hit for Weapons\r\n"); else if (apply == APPLY_LEVEL) len = snprintf(buf, sizeof(buf), "Highest AC Apply for Armor\r\n"); for(i=0;i<MAX_OBJ_LIST;i++){ if ((r_num = real_object(lst[i].vobj)) != NOTHING) { tmp_len = snprintf(buf+len, sizeof(buf)-len, "%s%3d%s) %s[%s%5d%s] %s%3d %s%-*s %s[%s]%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, lst[i].vobj, QCYN, QYEL, lst[i].val, QCYN, 42+count_color_chars(obj_proto[num].short_description), obj_proto[r_num].short_description, QYEL, item_types[obj_proto[num].obj_flags.type_flag], QNRM, obj_proto[num].proto_script ? " [TRIG]" : ""); len += tmp_len; } } page_string(ch->desc, buf, TRUE); return; /* End of special-case handling */ } /* Non-special cases, list objects by affect */ for (num = 0; num <= top_of_objt; num++){ for (i = 0; i < MAX_OBJ_AFFECT; i++){ if (obj_proto[num].affected[i].modifier) { if (obj_proto[num].affected[i].location == apply){ ov = obj_index[num].vnum; v1 = obj_proto[num].affected[i].modifier; if ((r_num = real_object(ov)) != NOTHING) add_to_obj_list(lst, MAX_OBJ_LIST, ov, v1); } } } } len = snprintf(buf, sizeof(buf), "Objects with highest %s affect\r\n", apply_types[(apply)]); for(i=0;i<MAX_OBJ_LIST;i++){ if ((r_num = real_object(lst[i].vobj)) != NOTHING) { tmp_len = snprintf(buf+len, sizeof(buf)-len, "%s%3d%s) %s[%s%8d%s] %s%3d %s%-*s %s[%s]%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, lst[i].vobj, QCYN, QYEL, lst[i].val, QCYN, 42+count_color_chars(obj_proto[num].short_description), obj_proto[r_num].short_description, QYEL, item_types[obj_proto[r_num].obj_flags.type_flag], QNRM, obj_proto[r_num].proto_script ? " [TRIG]" : ""); len += tmp_len; } } page_string(ch->desc, buf, TRUE); }
void perform_obj_type_list(struct char_data * ch, char *arg) { int num, itemtype, v1, v2, found = 0, len = 0, tmp_len = 0; obj_vnum ov; obj_rnum r_num; char buf[MAX_STRING_LENGTH]; itemtype = atoi(arg); len = snprintf(buf, sizeof(buf), "Listing all objects of type %s[%s]%s\r\n", QYEL, item_types[itemtype], QNRM); for(num=0;num<=top_of_objt;num++) { if(obj_proto[num].obj_flags.type_flag == itemtype) { if ((r_num = real_object(obj_index[num].vnum)) != NOTHING) { /* Seems silly? */ /* Set default vals, which may be changed below */ ov = obj_index[num].vnum; v1 = (obj_proto[num].obj_flags.value[0]); switch (itemtype) { case ITEM_LIGHT: v1 = (obj_proto[num].obj_flags.value[2]); if (v1 == -1) tmp_len = snprintf(buf+len, sizeof(buf)-len, "%s%3d%s) %s[%s%5d%s]%s INFINITE%s %s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QBRED, QCYN, obj_proto[r_num].short_description, QNRM); else tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%5d%s]%s (%-3dhrs) %s%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM); break; case ITEM_SCROLL: case ITEM_POTION: tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM); break; case ITEM_WAND: case ITEM_STAFF: v1 = (obj_proto[num].obj_flags.value[1]); v2 = (obj_proto[num].obj_flags.value[3]); tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dx%s) %s%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, skill_name(v2), QCYN, obj_proto[r_num].short_description, QNRM); break; case ITEM_WEAPON: v1 = ((obj_proto[num].obj_flags.value[2]+1)*(obj_proto[r_num].obj_flags.value[1])) / 2; tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%d Avg Dam) %s%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM); break; case ITEM_ARMOR: tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dAC) %s%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM); break; case ITEM_CONTAINER: tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (Max: %d) %s%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM); break; case ITEM_DRINKCON: case ITEM_FOUNTAIN: if (v1 != -1) tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (Max: %d) %s%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM); else tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %sINFINITE%s %s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QBRED, QCYN, obj_proto[r_num].short_description, QNRM); break; case ITEM_FOOD: v2 = (obj_proto[num].obj_flags.value[3]); if (v2 != 0) tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dhrs) %s%s %sPoisoned!%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QBGRN, QNRM); else tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dhrs) %s%s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM); break; case ITEM_MONEY: tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s (%s%d coins%s)\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM, QYEL, v1, QNRM); break; /* The 'normal' items - don't provide extra info */ case ITEM_TREASURE: case ITEM_TRASH: case ITEM_OTHER: case ITEM_WORN: case ITEM_NOTE: case ITEM_PEN: case ITEM_BOAT: case ITEM_KEY: tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s\r\n", QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM); break; default: send_to_char(ch, "Not a valid item type"); return; } if (len + tmp_len < sizeof(buf) - 1) len += tmp_len; else { buf[sizeof(buf) -1] = '\0'; break; } } } } page_string(ch->desc, buf, TRUE); }
void list_mob_zone (struct char_data *ch, int whichzone) { int i=0; int j=0; mob_vnum first_z_mob=0; /*vnum of first mob in zone list*/ mob_vnum last_z_mob=0; /*vnum of last mob in zone list */ int char_zone = ((GET_ROOM_VNUM(IN_ROOM(ch)))/100); /*initialize to current zone */ char *mbuf = get_buffer(MAX_STRING_LENGTH); mbuf[0]='\0'; if (whichzone > (-1)) char_zone = whichzone; /*see if specific zone was passed as arg*/ while (j!= char_zone) { first_z_mob++; j=(GET_MOB_VNUM(&mob_proto[i])/100); i++; /* * some zones have 100+ rooms but not 100+ items/mobs. * To find the needed mobs/objects, * search backwards for previous zone w/them. */ if (j>char_zone) { if (char_zone>0) { char_zone--; first_z_mob=0; i=0; j=0; } else { extended_mudlog(NRM, SYSL_BUGS, TRUE, "mlist looked for a zone < 0"); release_buffer(mbuf); return; } } } first_z_mob --; last_z_mob=first_z_mob; while (j == char_zone) { j=(GET_MOB_VNUM(&mob_proto[i])/100); last_z_mob++; i++; } if (first_z_mob<0) first_z_mob ++; for (i=first_z_mob;i<last_z_mob;i++) { sprintf(mbuf+strlen(mbuf),"[%5d] %-30s (difficulty %d)\r\n", GET_MOB_VNUM(&mob_proto[i]), mob_proto[i].player.short_descr, mob_proto[i].mob_specials.difficulty); } if (strlen(mbuf)<5) send_to_char ("There are no mobs in the zone you requested.\r\n",ch); else page_string (ch->desc,mbuf,1); release_buffer(mbuf); return; }
void list_object_zone (struct char_data *ch, int whichzone) { int i=0; int j=0; obj_vnum first_z_obj=0; /*vnum of first obj in zone list*/ obj_vnum last_z_obj=0; /*vnum of last obj in zone list */ int char_zone = ((GET_ROOM_VNUM(IN_ROOM(ch)))/100); /*initialize to current zone */ char *obuf = get_buffer(MAX_STRING_LENGTH); obuf[0]='\0'; if (whichzone > (-1)) char_zone = whichzone; /*see if specific zone was passed as arg*/ while (j!= char_zone) { first_z_obj++; j=(GET_OBJ_VNUM(&obj_proto[i])/100); i++; /* * some zones have 100+ rooms but not 100+ items/objs. * To find the needed objs/objects, * search backwards for previous zones w/them. */ if (j>char_zone) { if (char_zone>0) { char_zone--; first_z_obj=0; i=0; j=0; } else { extended_mudlog(NRM, SYSL_BUGS, TRUE, "olist looked for a zone < 0"); release_buffer(obuf); return; } } } first_z_obj --; last_z_obj=first_z_obj; while (j == char_zone) { j=(GET_OBJ_VNUM(&obj_proto[i])/100); last_z_obj++; i++; } if (first_z_obj<0) first_z_obj ++; for (i=first_z_obj;i<last_z_obj;i++) { sprintf(obuf+strlen(obuf),"[%5d] %-32s", GET_OBJ_VNUM(&obj_proto[i]), obj_proto[i].short_description); j=obj_proto[i].obj_flags.type_flag; sprintf(obuf+strlen(obuf)," %s ", item_types[(int)obj_proto[i].obj_flags.type_flag]); if ((j == ITEM_WORN) || (j== ITEM_ARMOR)) { sprintf(obuf+strlen(obuf)," (-%d AC 1) ",GET_OBJ_VAL(&obj_proto[i],0)); j=get_armor_ac (&obj_proto[i]); if (j!=0) sprintf(obuf + strlen(obuf), "(-%d AC 2)",j); } if (j==ITEM_WEAPON) { sprintf(obuf+strlen(obuf),"(Ave dam: %.1f) ", (((GET_OBJ_VAL(&obj_proto[i], 2) + 1) /2.0) * GET_OBJ_VAL(&obj_proto[i], 1))); j = get_weapon_dam(&obj_proto[i]); if (j!=0) sprintf(buf+strlen(buf), " +%d DAM ",j); } sprintbit(GET_OBJ_WEAR(&obj_proto[i]), wear_bits, obuf+strlen(obuf), sizeof(obuf)); sprintf(obuf+strlen(obuf),"\r\n"); } if (strlen(obuf)<5) send_to_char ("There are no objects in the zone you requested.\r\n",ch); else page_string (ch->desc,obuf,1); release_buffer(obuf); return; }
void list_room_zone (struct char_data *ch, int whichzone) { int i=0; int j=0; room_vnum first_z_room=0; /*vnum of first obj in zone list*/ room_vnum last_z_room=0; /*vnum of last obj in zone list */ int char_zone = ((GET_ROOM_VNUM(IN_ROOM(ch)))/100); /*initialize to current zone */ char *rbuf = get_buffer(MAX_STRING_LENGTH); rbuf[0]='\0'; if (whichzone > (-1)) char_zone = whichzone; /*see if specific zone was passed as arg*/ while (j!= char_zone) { first_z_room++; j=(world[i].number/100); i++; /* * some zones have 100+ rooms but not 100+ items/objs. * To find the needed objs/objects, * search backwards for previous zone. */ if (j>char_zone) { if (char_zone>0) { char_zone--; first_z_room=0; i=0; j=0; } else { extended_mudlog(NRM, SYSL_BUGS, TRUE, "rlist looked for a zone < 0"); release_buffer(rbuf); return; } } } first_z_room --; last_z_room=first_z_room; while (j == char_zone) { j=(world[i].number/100); last_z_room++; i++; } if (first_z_room<0) first_z_room ++; for (i=first_z_room;i<last_z_room;i++) { sprintf(rbuf+strlen(rbuf),"[%5d] %s\r\n", world[i].number, world[i].name); } if (strlen(rbuf)<5) send_to_char ("There are no rooms in the zone you requested.\r\n",ch); else page_string (ch->desc, rbuf, 1); release_buffer(rbuf); return; }