Welcome to the Builder Academy

Question where command overflows

More
02 Jul 2016 12:10 #6055 by JTP
where command overflows was created by JTP
Hey

Immortal where overflows if there are to many mobs. How can i prevent that ?

3.64

Please Log in or Create an account to join the conversation.

More
02 Jul 2016 22:10 #6067 by krell
Replied by krell on topic where command overflows
How can I reproduce this? I've tried "where warrior" and "where sword" and excess entries just scrolled off of the screen. Do you get an error message? Is it just logged or is it printed to the terminal as well? I'm running v3.67 btw so the code might be fixed against what you're seeing.

Please Log in or Create an account to join the conversation.

More
02 Jul 2016 22:29 #6068 by JTP
Replied by JTP on topic where command overflows
i aparently have alot of guards so try that

It shows about 200-220 then cuts the list and writes overflow...and show stat then says 1 overflow

Please Log in or Create an account to join the conversation.

More
02 Jul 2016 23:09 #6070 by WhiskyTest
Replied by WhiskyTest on topic where command overflows
act.informative.c
in perform_immort_where()
at around line #1651 delete this block of code:
Code:
for (i = character_list; i; i = i->next) if (CAN_SEE(ch, i) && IN_ROOM(i) != NOWHERE && isname(arg, i->player.name)) { found = 1; - send_to_char(ch, "M%3d. %-25s%s - [%5d] %-25s%s", ++num, GET_NAME(i), QNRM, - GET_ROOM_VNUM(IN_ROOM(i)), world[IN_ROOM(i)].name, QNRM); - if (SCRIPT(i) && TRIGGERS(SCRIPT(i))) { - if (!TRIGGERS(SCRIPT(i))->next) - send_to_char(ch, "[T%d] ", GET_TRIG_VNUM(TRIGGERS(SCRIPT(i)))); - else - send_to_char(ch, "[TRIGS] "); - } - send_to_char(ch, "%s\r\n", QNRM); - }

and replace with this:
Code:
for (i = character_list; i; i = i->next) if (CAN_SEE(ch, i) && IN_ROOM(i) != NOWHERE && isname(arg, i->player.name)) { found = 1; + snprintf(buf1, sizeof(buf1), "M%3d. %-25s%s - [%5d] %-25s%s\r\n", ++num, GET_NAME(i), QNRM, + GET_ROOM_VNUM(IN_ROOM(i)), world[IN_ROOM(i)].name, QNRM); + strcat(buf, buf1); + } + page_string(ch->desc, buf, 0); for (num = 0, k = object_list; k; k = k->next)
you lose the triggers and quest information, but I'm sure if required you can add it in - I personally didn't need it so just left it out


you can use the page_string() function in other places where you start seeing overflows too

Please Log in or Create an account to join the conversation.

More
02 Jul 2016 23:17 #6071 by krell
Replied by krell on topic where command overflows
Oh yeah, I see now that it did that with "where sword" as well. The code for immortal where is in act.informative.c. It looks like the number of items is larger than the buffer pointer can hold. Should some bounds checking be employed to prevent the overflow from happening in the first place, I wonder.

Code:
static void perform_immort_where(struct char_data *ch, char *arg) { struct char_data *i; struct obj_data *k; struct descriptor_data *d; int num = 0, found = 0; if (!*arg) { 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, "%-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, "%-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 { for (i = character_list; i; i = i->next) if (CAN_SEE(ch, i) && IN_ROOM(i) != NOWHERE && isname(arg, i->player.name)) { found = 1; send_to_char(ch, "M%3d. %-25s%s - [%5d] %-25s%s", ++num, GET_NAME(i), QNRM, GET_ROOM_VNUM(IN_ROOM(i)), world[IN_ROOM(i)].name, QNRM); if (SCRIPT(i) && TRIGGERS(SCRIPT(i))) { if (!TRIGGERS(SCRIPT(i))->next) send_to_char(ch, "[T%d] ", GET_TRIG_VNUM(TRIGGERS(SCRIPT(i)))); else send_to_char(ch, "[TRIGS] "); } send_to_char(ch, "%s\r\n", QNRM); } for (num = 0, k = object_list; k; k = k->next) if (CAN_SEE_OBJ(ch, k) && isname(arg, k->name)) { found = 1; print_object_location(++num, k, ch, TRUE); } if (!found) send_to_char(ch, "Couldn't find any such thing.\r\n"); } }

Please Log in or Create an account to join the conversation.

More
02 Jul 2016 23:32 #6072 by krell
Replied by krell on topic where command overflows
Never mind, I see WhiskeyTest beat me to it. XD

Please Log in or Create an account to join the conversation.

Time to create page: 0.296 seconds