olist <objname> and page_string bug fix

This commit is contained in:
JamDog
2010-12-08 21:18:54 +00:00
parent d2b4faf1c9
commit d38117ead2
3 changed files with 157 additions and 99 deletions

View File

@@ -35,6 +35,9 @@ export (QQ's a zone into a tarball)
Xlist (mlist, olist, rlist, zlist, slist, tlist, qlist) Xlist (mlist, olist, rlist, zlist, slist, tlist, qlist)
(lots of major bugfixes too) (lots of major bugfixes too)
@ @
[Dec 08 2010] - Jamdog
Added olist <name>
page_string now uses player's screen width and correctly parses ANSI color codes
[Dec 07 2010] - Jamdog [Dec 07 2010] - Jamdog
Fixed erroneous SYSERR report and incorrect contant in new house system (thanks Vatiken) Fixed erroneous SYSERR report and incorrect contant in new house system (thanks Vatiken)
Buildwalk now allows builder to specify default sector type (thanks Mirad) Buildwalk now allows builder to specify default sector type (thanks Mirad)

View File

@@ -373,7 +373,9 @@ ACMD(do_skillset)
* page has been reached. Return NULL if this is the last page of the string. */ * page has been reached. Return NULL if this is the last page of the string. */
static char *next_page(char *str, struct char_data *ch) static char *next_page(char *str, struct char_data *ch)
{ {
int col = 1, line = 1; int col = 1, line = 1, count, pw;
pw = (GET_SCREEN_WIDTH(ch) >= 40 && GET_SCREEN_WIDTH(ch) <= 250) ? GET_SCREEN_WIDTH(ch) : PAGE_WIDTH;
for (;; str++) { for (;; str++) {
/* If end of string, return NULL. */ /* If end of string, return NULL. */
@@ -384,8 +386,9 @@ static char *next_page(char *str, struct char_data *ch)
else if (line > (GET_PAGE_LENGTH(ch) - (PRF_FLAGGED(ch, PRF_COMPACT) ? 1 : 2))) else if (line > (GET_PAGE_LENGTH(ch) - (PRF_FLAGGED(ch, PRF_COMPACT) ? 1 : 2)))
return (str); return (str);
/* Check for the begining of an ANSI color code block. */ /* Check for the beginning of an ANSI color code block. */
else if (*str == '\x1B') else if (*str == '\x1B') /* Jump to the end of the ANSI code, or max 9 chars */
for (count=0; *str != 'm' && count < 9; count++)
str++; str++;
else if (*str == '@') { else if (*str == '@') {
@@ -404,7 +407,7 @@ static char *next_page(char *str, struct char_data *ch)
/* We need to check here and see if we are over the page width, and if /* We need to check here and see if we are over the page width, and if
* so, compensate by going to the begining of the next line. */ * so, compensate by going to the begining of the next line. */
else if (col++ > PAGE_WIDTH) { else if (col++ > pw) {
col = 1; col = 1;
line++; line++;
} }

View File

@@ -128,82 +128,87 @@ void add_to_obj_list(struct obj_list_item *lst, int num_items, obj_vnum nvo, int
void perform_obj_type_list(struct char_data * ch, char *arg) void perform_obj_type_list(struct char_data * ch, char *arg)
{ {
int num, itemtype, v1, v2, found = 0; int num, itemtype, v1, v2, found = 0, len = 0, tmp_len = 0;
obj_vnum ov; obj_vnum ov;
obj_rnum r_num; obj_rnum r_num;
char buf[MAX_STRING_LENGTH];
itemtype = atoi(arg); 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++) { for(num=0;num<=top_of_objt;num++) {
if(obj_proto[num].obj_flags.type_flag == itemtype) { if(obj_proto[num].obj_flags.type_flag == itemtype) {
if ((r_num = real_object(obj_index[num].vnum)) != NOTHING) { /* Seems silly? */ if ((r_num = real_object(obj_index[num].vnum)) != NOTHING) { /* Seems silly? */
/* Set default vals, which may be changed below */ /* Set default vals, which may be changed below */
ov = obj_index[num].vnum; ov = obj_index[num].vnum;
v1 = (obj_proto[num].obj_flags.value[0]); v1 = (obj_proto[num].obj_flags.value[0]);
switch (itemtype) { switch (itemtype) {
case ITEM_LIGHT: case ITEM_LIGHT:
v1 = (obj_proto[num].obj_flags.value[2]); v1 = (obj_proto[num].obj_flags.value[2]);
if (v1 == -1) if (v1 == -1)
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s INFINITE%s %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len, "%s%3d%s) %s[%s%5d%s]%s INFINITE%s %s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QBRED, QNRM, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QBRED, QCYN, obj_proto[r_num].short_description, QNRM);
else else
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s (%-3dhrs) %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%5d%s]%s (%-3dhrs) %s%s%s\r\n",
QNRM,++found, QCYN, QYEL, ov, QCYN, QNRM, v1, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
case ITEM_SCROLL: case ITEM_SCROLL:
case ITEM_POTION: case ITEM_POTION:
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
case ITEM_WAND: case ITEM_WAND:
case ITEM_STAFF: case ITEM_STAFF:
v1 = (obj_proto[num].obj_flags.value[1]); v1 = (obj_proto[num].obj_flags.value[1]);
v2 = (obj_proto[num].obj_flags.value[3]); v2 = (obj_proto[num].obj_flags.value[3]);
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s (%dx%s) %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dx%s) %s%s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, v1, skill_name(v2), obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, skill_name(v2), QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
case ITEM_WEAPON: case ITEM_WEAPON:
v1 = ((obj_proto[num].obj_flags.value[2]+1)*(obj_proto[r_num].obj_flags.value[1])) / 2; v1 = ((obj_proto[num].obj_flags.value[2]+1)*(obj_proto[r_num].obj_flags.value[1])) / 2;
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s (%d Avg Dam) %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%d Avg Dam) %s%s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, v1, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
case ITEM_ARMOR: case ITEM_ARMOR:
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s (%dAC) %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dAC) %s%s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, v1, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
case ITEM_CONTAINER: case ITEM_CONTAINER:
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s (Max: %d) %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (Max: %d) %s%s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, v1, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
case ITEM_DRINKCON: case ITEM_DRINKCON:
case ITEM_FOUNTAIN: case ITEM_FOUNTAIN:
if (v1 != -1) if (v1 != -1)
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s (Max: %d) %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (Max: %d) %s%s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, v1, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
else else
send_to_char(ch,"%s%3d. %s[%s%8d%s] %sINFINITE%s %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %sINFINITE%s %s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QBRED, QNRM, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QBRED, QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
case ITEM_FOOD: case ITEM_FOOD:
v2 = (obj_proto[num].obj_flags.value[3]); v2 = (obj_proto[num].obj_flags.value[3]);
if (v2 != 0) if (v2 != 0)
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s (%dhrs) %s %sPoisoned!%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dhrs) %s%s %sPoisoned!%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, v1, obj_proto[r_num].short_description, QBGRN, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QBGRN, QNRM);
else else
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s (%dhrs) %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s]%s (%dhrs) %s%s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, v1, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, QNRM, v1, QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
case ITEM_MONEY: case ITEM_MONEY:
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s %s%s (%s%d coins%s)\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s (%s%d coins%s)\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, obj_proto[r_num].short_description, QNRM, QYEL, v1, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM, QYEL, v1, QNRM);
break; break;
/* The 'normal' items - don't provide extra info */ /* The 'normal' items - don't provide extra info */
@@ -215,19 +220,19 @@ void perform_obj_type_list(struct char_data * ch, char *arg)
case ITEM_PEN: case ITEM_PEN:
case ITEM_BOAT: case ITEM_BOAT:
case ITEM_KEY: case ITEM_KEY:
send_to_char(ch,"%s%3d. %s[%s%8d%s]%s %s%s\r\n", tmp_len = snprintf(buf+len, sizeof(buf)-len,"%s%3d%s) %s[%s%8d%s] %s%s\r\n",
QNRM, ++found, QCYN, QYEL, ov, QCYN, QNRM, obj_proto[r_num].short_description, QNRM); QGRN, ++found, QNRM, QCYN, QYEL, ov, QCYN, obj_proto[r_num].short_description, QNRM);
break; break;
default: default:
send_to_char(ch, "Not a valid item type"); send_to_char(ch, "Not a valid item type");
return; return;
}
len += tmp_len;
} }
} }
} }
} page_string(ch->desc, buf, TRUE);
return;
} }
void perform_obj_aff_list(struct char_data * ch, char *arg) void perform_obj_aff_list(struct char_data * ch, char *arg)
@@ -268,9 +273,12 @@ void perform_obj_aff_list(struct char_data * ch, char *arg)
for(i=0;i<MAX_OBJ_LIST;i++){ for(i=0;i<MAX_OBJ_LIST;i++){
if ((r_num = real_object(lst[i].vobj)) != NOTHING) { if ((r_num = real_object(lst[i].vobj)) != NOTHING) {
tmp_len = snprintf(buf+len, sizeof(buf)-len, "%s%3d. %s[%s%8d%s] %s%3d %s%s%s\r\n", 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",
QNRM, ++found, QCYN, QYEL, lst[i].vobj, QCYN, QGRN, ++found, QNRM, QCYN, QYEL, lst[i].vobj, QCYN,
QYEL, lst[i].val, QNRM, obj_proto[r_num].short_description, QNRM); 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; len += tmp_len;
} }
} }
@@ -294,15 +302,42 @@ void perform_obj_aff_list(struct char_data * ch, char *arg)
len = snprintf(buf, sizeof(buf), "Objects with highest %s affect\r\n", apply_types[(apply)]); len = snprintf(buf, sizeof(buf), "Objects with highest %s affect\r\n", apply_types[(apply)]);
for(i=0;i<MAX_OBJ_LIST;i++){ for(i=0;i<MAX_OBJ_LIST;i++){
if ((r_num = real_object(lst[i].vobj)) != NOTHING) { if ((r_num = real_object(lst[i].vobj)) != NOTHING) {
tmp_len = snprintf(buf+len, sizeof(buf)-len, "%s%3d. %s[%s%8d%s] %s%3d %s%s%s\r\n", 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",
QNRM, ++found, QCYN, QYEL, lst[i].vobj, QCYN, QGRN, ++found, QNRM, QCYN, QYEL, lst[i].vobj, QCYN,
QYEL, lst[i].val, QNRM, obj_proto[r_num].short_description, QNRM); 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; len += tmp_len;
} }
} }
page_string(ch->desc, buf, TRUE); page_string(ch->desc, buf, TRUE);
} }
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);
}
/* Ingame Commands */ /* Ingame Commands */
ACMD(do_oasis_list) ACMD(do_oasis_list)
{ {
@@ -345,7 +380,15 @@ ACMD(do_oasis_list)
two_arguments(argument, arg, arg2); two_arguments(argument, arg, arg2);
if (is_abbrev(arg, "level") || is_abbrev(arg, "flags")) { if (is_abbrev(arg, "help")) {
send_to_char(ch, "Usage: %smlist <zone>%s - List mobiles in a zone\r\n", QYEL, QNRM);
send_to_char(ch, " %smlist <vnum> <vnum>%s - List a range of mobiles by vnum\r\n", QYEL, QNRM);
send_to_char(ch, " %smlist level <num>%s - List all mobiles of a specified level\r\n", QYEL, QNRM);
send_to_char(ch, " %smlist flags <num>%s - List all mobiles with flag set\r\n", QYEL, QNRM, MAX_OBJ_LIST);
send_to_char(ch, "Just type %smlist flags%s to view available options.\r\n", QYEL, QNRM, QYEL, QNRM);
return;
}
else if (is_abbrev(arg, "level") || is_abbrev(arg, "flags")) {
int i; int i;
if (!*arg2) { if (!*arg2) {
@@ -372,7 +415,16 @@ ACMD(do_oasis_list)
case SCMD_OASIS_OLIST: case SCMD_OASIS_OLIST:
two_arguments(argument, arg, arg2); two_arguments(argument, arg, arg2);
if (is_abbrev(arg, "type") || is_abbrev(arg, "affect")) { if (is_abbrev(arg, "help")) {
send_to_char(ch, "Usage: %solist <zone>%s - List objects in a zone\r\n", QYEL, QNRM);
send_to_char(ch, " %solist <vnum> <vnum>%s - List a range of objects by vnum\r\n", QYEL, QNRM);
send_to_char(ch, " %solist <name>%s - List all named objects with count\r\n", QYEL, QNRM);
send_to_char(ch, " %solist type <num>%s - List all objects of a specified type\r\n", QYEL, QNRM);
send_to_char(ch, " %solist affect <num>%s - List top %d objects with affect\r\n", QYEL, QNRM, MAX_OBJ_LIST);
send_to_char(ch, "Just type %solist affect%s or %solist type%s to view available options\r\n", QYEL, QNRM, QYEL, QNRM);
return;
}
else if (is_abbrev(arg, "type") || is_abbrev(arg, "affect")) {
if (is_abbrev(arg, "type")) { if (is_abbrev(arg, "type")) {
if (!*arg2) { if (!*arg2) {
send_to_char(ch, "Which object type do you want to list?\r\n"); send_to_char(ch, "Which object type do you want to list?\r\n");
@@ -383,8 +435,7 @@ ACMD(do_oasis_list)
} }
send_to_char(ch, "\r\n"); send_to_char(ch, "\r\n");
send_to_char(ch, "Usage: %solist type <num>%s\r\n", QYEL, QNRM); send_to_char(ch, "Usage: %solist type <num>%s\r\n", QYEL, QNRM);
send_to_char(ch, " %solist affect <num>%s\r\n", QYEL, QNRM); send_to_char(ch, "Displays objects of the selected type.\r\n");
send_to_char(ch, "Displays objects of the selected type, or top 100 with the selected affect.\r\n\r\n");
return; return;
} }
@@ -403,14 +454,15 @@ ACMD(do_oasis_list)
if (!((i+1)%4)) send_to_char(ch, "\r\n"); if (!((i+1)%4)) send_to_char(ch, "\r\n");
} }
send_to_char(ch, "\r\n"); send_to_char(ch, "\r\n");
send_to_char(ch, "Usage: %solist type <num>%s\r\n", QYEL, QNRM); send_to_char(ch, "Usage: %solist affect <num>%s\r\n", QYEL, QNRM);
send_to_char(ch, " %solist affect <num>%s\r\n", QYEL, QNRM); send_to_char(ch, "Displays top %d objects, in order, with the selected affect.\r\n", MAX_OBJ_LIST);
send_to_char(ch, "Displays objects of the selected type, or top 100 with the selected affect.\r\n\r\n");
return; return;
} }
perform_obj_aff_list(ch, arg2); perform_obj_aff_list(ch, arg2);
} }
} else if (*arg && !isdigit(*arg)) {
perform_obj_name_list(ch, arg);
} else } else
list_objects(ch, rzone, vmin, vmax); list_objects(ch, rzone, vmin, vmax);
break; break;