From c486097e8145a525ac32fa9b1a7a8bf76caa7b2b Mon Sep 17 00:00:00 2001 From: Rumble Date: Tue, 27 May 2008 19:39:32 +0000 Subject: [PATCH] [May 27 2008] - Rumble Fixed list_obj_to_char from only checking invisibility on first object of the same vnum. (thanks Laoris) Added object stacking when looking at a character's inventory. (thanks Jamdog) [May 22 2008] - Rumble Added zone name to where command. (thanks Jamdog) [May 21 2008] - Rumble Rewrite of void script_vlog to prevent possible crash bug on some OS's. (thanks Jamdog) --- changelog | 7 +++ src/act.informative.c | 101 ++++++++++++++++++++++++------------------ src/dg_scripts.c | 32 +++++++------ 3 files changed, 79 insertions(+), 61 deletions(-) diff --git a/changelog b/changelog index d9e0256..fb9793e 100644 --- a/changelog +++ b/changelog @@ -3,6 +3,13 @@ help, find any bugs, or have ideas for improvement please stop by TBA at telnet://tbamud.com:9091 or email rumble@tbamud.com --Rumble tbaMUD 3.56 +[May 27 2008] - Rumble + Fixed list_obj_to_char from only checking invisibility on first object of the same vnum. (thanks Laoris) + Added object stacking when looking at a character's inventory. (thanks Jamdog) +[May 22 2008] - Rumble + Added zone name to where command. (thanks Jamdog) +[May 21 2008] - Rumble + Rewrite of void script_vlog to prevent possible crash bug on some OS's. (thanks Jamdog) [May 17 2008] - Rumble Fixed a possible crash bug in qedit. (thanks Jamdog) Bug fix: Page command was paging when the character was not found and sending a NOPERSON message when he was found. diff --git a/src/act.informative.c b/src/act.informative.c index 7160fc0..6e62b15 100644 --- a/src/act.informative.c +++ b/src/act.informative.c @@ -170,37 +170,53 @@ static void show_obj_modifiers(struct obj_data *obj, struct char_data *ch) send_to_char(ch, " ..It emits a faint humming sound!"); } -static void list_obj_to_char(struct obj_data *list, struct char_data *ch, int mode, int show) -{ - struct obj_data *i, *j; - bool found; - int num; +static void list_obj_to_char(struct obj_data *list, struct char_data *ch, int mode, int show) +{ + struct obj_data *i, *j, *display; + bool found; + int num; - found = FALSE; + found = FALSE; - for (i = list; i; i = i->next_content) { - num = 0; - for (j = list; j != i; j = j->next_content) - if (!strcmp(j->short_description, i->short_description) && (!strcmp(j->name, i->name))) - break; - if (j != i) - continue; - for (j = i; j; j = j->next_content) - if (!strcmp(j->short_description, i->short_description) && (!strcmp(j->name, i->name))) - num++; - if (CAN_SEE_OBJ(ch, i) && (*i->description != '.' || (IS_NPC(ch) || PRF_FLAGGED(ch, PRF_HOLYLIGHT)))) { + /* Loop through the list of objects */ + for (i = list; i; i = i->next_content) { + num = 0; + + /* Check the list to see if we've already counted this object */ + for (j = list; j != i; j = j->next_content) + if ((j->short_description == i->short_description && j->name == i->name) || + (!strcmp(j->short_description, i->short_description) && !strcmp(j->name, i->name))) + break; /* found a matching object */ + if (j != i) + continue; /* we counted object i earlier in the list */ + + /* Count matching objects, including this one */ + for (display = j = i; j; j = j->next_content) + /* This if-clause should be exactly the same as the one in the loop above */ + if ((j->short_description == i->short_description && j->name == i->name) || + (!strcmp(j->short_description, i->short_description) && !strcmp(j->name, i->name))) + if (CAN_SEE_OBJ(ch, j)) { + ++num; + /* If the original item can't be seen, switch it for this one */ + if (display == i && !CAN_SEE_OBJ(ch, display)) + display = j; + } + + /* When looking in room, hide objects starting with '.', except for holylight */ + if (num > 0 && (mode != SHOW_OBJ_LONG || *display->description != '.' || + (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_HOLYLIGHT)))) { if (mode == SHOW_OBJ_LONG) - send_to_char(ch, "%s", CCGRN(ch, C_NRM)); - if (num != 1) - send_to_char(ch, "(%2i) ", num); - show_obj_to_char(i, ch, mode); - send_to_char(ch, "%s", CCNRM(ch, C_NRM)); - found = TRUE; - } - } - if (!found && show) - send_to_char(ch, " Nothing.\r\n"); -} + send_to_char(ch, "%s", CCGRN(ch, C_NRM)); + if (num != 1) + send_to_char(ch, "(%2i) ", num); + show_obj_to_char(display, ch, mode); + send_to_char(ch, "%s", CCNRM(ch, C_NRM)); + found = TRUE; + } + } + if (!found && show) + send_to_char(ch, " Nothing.\r\n"); +} static void diag_char_to_char(struct char_data *i, struct char_data *ch) { @@ -261,18 +277,9 @@ static void look_at_char(struct char_data *i, struct char_data *ch) show_obj_to_char(GET_EQ(i, j), ch, SHOW_OBJ_SHORT); } } - if (ch != i && (IS_THIEF(ch) || GET_LEVEL(ch) >= LVL_IMMORT)) { - found = FALSE; - act("\r\nYou attempt to peek at $s inventory:", FALSE, i, 0, ch, TO_VICT); - for (tmp_obj = i->carrying; tmp_obj; tmp_obj = tmp_obj->next_content) { - if (CAN_SEE_OBJ(ch, tmp_obj) && (rand_number(0, 20) < GET_LEVEL(ch))) { - show_obj_to_char(tmp_obj, ch, SHOW_OBJ_SHORT); - found = TRUE; - } - } - - if (!found) - send_to_char(ch, "You can't see anything.\r\n"); + if (ch != i && (IS_THIEF(ch) || GET_LEVEL(ch) >= LVL_IMMORT)) { + act("\r\nYou attempt to peek at $s inventory:", FALSE, i, 0, ch, TO_VICT); + list_obj_to_char(i->carrying, ch, SHOW_OBJ_SHORT, TRUE); } } @@ -1521,9 +1528,11 @@ static void perform_mortal_where(struct char_data *ch, char *arg) { struct char_data *i; struct descriptor_data *d; + int j; if (!*arg) { - send_to_char(ch, "Players in your Zone\r\n--------------------\r\n"); + j = world[(IN_ROOM(ch))].zone; + send_to_char(ch, "Players in %s@n.\r\n--------------------\r\n", zone_table[j].name); for (d = descriptor_list; d; d = d->next) { if (STATE(d) != CON_PLAYING || d->character == ch) continue; @@ -1587,17 +1596,21 @@ static void perform_immort_where(struct char_data *ch, char *arg) int num = 0, found = 0; if (!*arg) { - send_to_char(ch, "Players\r\n-------\r\n"); + send_to_char(ch, "Players Room Location Zone\r\n"); + send_to_char(ch, "-------- ------- ------------------------------ -------------------\r\n"); for (d = descriptor_list; d; d = d->next) if (IS_PLAYING(d)) { i = (d->original ? d->original : d->character); if (i && CAN_SEE(ch, i) && (IN_ROOM(i) != NOWHERE)) { if (d->original) - send_to_char(ch, "%-20s%s - [%5d] %s%s (in %s%s)\r\n", + send_to_char(ch, "%-8s%s - [%5d] %s%s (in %s%s)\r\n", GET_NAME(i), QNRM, GET_ROOM_VNUM(IN_ROOM(d->character)), world[IN_ROOM(d->character)].name, QNRM, GET_NAME(d->character), QNRM); else - send_to_char(ch, "%-20s%s - [%5d] %s%s\r\n", GET_NAME(i), QNRM, GET_ROOM_VNUM(IN_ROOM(i)), world[IN_ROOM(i)].name, QNRM); + send_to_char(ch, "%-8s%s %s[%s%5d%s]%s %-*s%s %s%s\r\n", GET_NAME(i), QNRM, + QCYN, QYEL, GET_ROOM_VNUM(IN_ROOM(i)), QCYN, QNRM, + 30+count_color_chars(world[IN_ROOM(i)].name), world[IN_ROOM(i)].name, QNRM, + zone_table[(world[IN_ROOM(i)].zone)].name, QNRM); } } } else { diff --git a/src/dg_scripts.c b/src/dg_scripts.c index 0655261..c1d7d8f 100644 --- a/src/dg_scripts.c +++ b/src/dg_scripts.c @@ -1290,26 +1290,24 @@ void script_vlog(const char *format, va_list args) char output[MAX_STRING_LENGTH]; struct descriptor_data *i; - snprintf(output, sizeof(output), "SCRIPT ERR: %s", format); + /* parse the args, making the error message */ + vsnprintf(output, sizeof(output) - 2, format, args); - basic_mud_vlog(output, args); + /* Save to the syslog file */ + basic_mud_log("SCRIPT ERROR: %s", output); - /* the rest is mostly a rip from basic_mud_log() */ - strcpy(output, "[ "); /* strcpy: OK */ - vsnprintf(output + 2, sizeof(output) - 6, format, args); - strcat(output, " ]\r\n"); /* strcat: OK */ + /* And send to imms */ + for (i = descriptor_list; i; i = i->next) { + if (STATE(i) != CON_PLAYING || IS_NPC(i->character)) /* switch */ + continue; + if (GET_LEVEL(i->character) < LVL_BUILDER) + continue; + if (PLR_FLAGGED(i->character, PLR_WRITING)) + continue; + if (NRM > (PRF_FLAGGED(i->character, PRF_LOG1) ? 1 : 0) + (PRF_FLAGGED(i->character, PRF_LOG2) ? 2 : 0)) + continue; - for (i = descriptor_list; i; i = i->next) { - if (STATE(i) != CON_PLAYING || IS_NPC(i->character)) /* switch */ - continue; - if (GET_LEVEL(i->character) < LVL_BUILDER) - continue; - if (PLR_FLAGGED(i->character, PLR_WRITING)) - continue; - if (NRM > (PRF_FLAGGED(i->character, PRF_LOG1) ? 1 : 0) + (PRF_FLAGGED(i->character, PRF_LOG2) ? 2 : 0)) - continue; - - send_to_char(i->character, "%s%s%s", CCGRN(i->character, C_NRM), output, CCNRM(i->character, C_NRM)); + send_to_char(i->character, "%s[ %s ]%s\r\n", CCGRN(i->character, C_NRM), output, CCNRM(i->character, C_NRM)); } }