From 143364cbc9c377784ff9112faef12bc1ebe08f1a Mon Sep 17 00:00:00 2001 From: JamDog Date: Sun, 5 Dec 2010 16:28:00 +0000 Subject: [PATCH] zlist update and a few bug fixes --- changelog | 6 +++ src/act.informative.c | 13 ++++-- src/act.wizard.c | 2 +- src/dg_variables.c | 1 + src/handler.c | 2 +- src/house.c | 2 + src/interpreter.c | 29 ++++++++++--- src/oasis_list.c | 95 ++++++++++++++++++++++++++----------------- src/shop.c | 1 + 9 files changed, 104 insertions(+), 47 deletions(-) diff --git a/changelog b/changelog index 393901d..9583a38 100644 --- a/changelog +++ b/changelog @@ -35,6 +35,12 @@ export (QQ's a zone into a tarball) Xlist (mlist, olist, rlist, zlist, slist, tlist, qlist) (lots of major bugfixes too) @ +[Dec 05 2010] - Jamdog + Bug-Fix: 'Did you mean' now only shows commands you have access to (thanks Welcor) + Bug-Fix: Fixed crash bug introduced by new house system when saving house contents + Scan command now tells you when nothing is nearby (thanks Mirad) + zlist command can now list by builder, like show zones + zlist now uses page_string (thanks Mirad) [Dec 02 2010] - Jamdog Bug-Fix: identify command in shops was listing incorrect buy price (thanks Kam) Added %actor.admlevel% and %actor.admlevel()% to dg-scripts diff --git a/src/act.informative.c b/src/act.informative.c index e1418fe..673d0c6 100644 --- a/src/act.informative.c +++ b/src/act.informative.c @@ -2670,6 +2670,7 @@ distance, int door) ACMD(do_scan) { int door; + bool found=FALSE; int range; int maxrange = 3; @@ -2692,15 +2693,21 @@ ACMD(do_scan) send_to_char(ch, "%s: It's too dark to see, but you can hear shuffling.\r\n", dirs[door]); else send_to_char(ch, "%s: It is too dark to see anything.\r\n", dirs[door]); - } else { - if (world[scanned_room].people) + found=TRUE; + } else { + if (world[scanned_room].people) { list_scanned_chars(world[scanned_room].people, ch, range - 1, door); - } + found=TRUE; + } + } } // end of if else break; } // end of range scanned_room = IN_ROOM(ch); } // end of directions + if (!found) { + send_to_char(ch, "You don't see aanything nearby!\r\n"); + } } // end of do_scan diff --git a/src/act.wizard.c b/src/act.wizard.c index 73bc96e..e6c6053 100644 --- a/src/act.wizard.c +++ b/src/act.wizard.c @@ -1568,7 +1568,6 @@ void set_default_admin_privs(struct char_data *ch, bool keep_old) SET_BIT_AR(ADM_FLAGS(ch), ADM_TELLALL); SET_BIT_AR(ADM_FLAGS(ch), ADM_EATANYTHING); SET_BIT_AR(ADM_FLAGS(ch), ADM_BUILD); - SET_BIT_AR(ADM_FLAGS(ch), ADM_MONEY); case ADMLVL_GOD: SET_BIT_AR(ADM_FLAGS(ch), ADM_WALKANYWHERE); SET_BIT_AR(ADM_FLAGS(ch), ADM_NOKEYS); SET_BIT_AR(ADM_FLAGS(ch), ADM_SEEINV); @@ -1577,6 +1576,7 @@ void set_default_admin_privs(struct char_data *ch, bool keep_old) SET_BIT_AR(ADM_FLAGS(ch), ADM_ALLSHOPS); SET_BIT_AR(ADM_FLAGS(ch), ADM_SEESECRET); SET_BIT_AR(ADM_FLAGS(ch), ADM_NOSTEAL); + SET_BIT_AR(ADM_FLAGS(ch), ADM_MONEY); case ADMLVL_IMMORT: SET_BIT_AR(ADM_FLAGS(ch), ADM_KNOWWEATHER); SET_BIT_AR(ADM_FLAGS(ch), ADM_SETQP); SET_BIT_AR(ADM_FLAGS(ch), ADM_NOPOISON); diff --git a/src/dg_variables.c b/src/dg_variables.c index ae0b493..b9f81a6 100644 --- a/src/dg_variables.c +++ b/src/dg_variables.c @@ -24,6 +24,7 @@ #include "oasis.h" #include "class.h" #include "quest.h" +#include "act.h" /* Utility functions */ diff --git a/src/handler.c b/src/handler.c index de708c6..aa23a6f 100644 --- a/src/handler.c +++ b/src/handler.c @@ -49,7 +49,7 @@ int is_name(const char *str, const char *namelist) { const char *curname, *curstr; - if (!*str || !*namelist || !str || !namelist) + if (!str || !namelist || !*str || !*namelist) return (0); curname = namelist; diff --git a/src/house.c b/src/house.c index c69132d..35e4e89 100644 --- a/src/house.c +++ b/src/house.c @@ -104,6 +104,8 @@ int House_save(struct obj_data *obj, FILE *fp) int result; room_vnum rv; + if (!obj) return(1); + rv = world[(IN_ROOM(obj))].number; hse = find_house(rv); diff --git a/src/interpreter.c b/src/interpreter.c index 9f8db76..347511f 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -482,6 +482,22 @@ void sort_commands(void) qsort(cmd_sort_info + 1, num_of_cmds - 2, sizeof(int), sort_commands_helper); } +/* Returns TRUE if 'ch' has sufficient access to use the command 'cmd' */ +bool can_use_command(struct char_data *ch, int cmd) +{ + if (complete_cmd_info[cmd].admin_flag == ADM_NONE && + complete_cmd_info[cmd].minimum_admlevel == ADMLVL_MORTAL && + GET_LEVEL(ch) >= complete_cmd_info[cmd].minimum_level) + return TRUE; + + if (complete_cmd_info[cmd].admin_flag == ADM_NONE && GET_ADMLEVEL(ch) >= complete_cmd_info[cmd].minimum_admlevel) + return TRUE; + + if (complete_cmd_info[cmd].admin_flag != ADM_NONE && ADM_FLAGGED(ch, complete_cmd_info[cmd].admin_flag)) + return TRUE; + + return FALSE; +} /* This is the actual command interpreter called from game_loop() in comm.c * It makes sure you are the proper level and position to execute the command, @@ -567,12 +583,15 @@ void command_interpreter(struct char_data *ch, char *argument) if ( (levenshtein_distance(arg, cmd_info[cmd].command) <= 2) && (cmd_info[cmd].minimum_level >= 0) ) { - if (!found) - { - send_to_char(ch, "\r\nDid you mean:\r\n"); - found = 1; + /* Does this person have access to this command? */ + if (can_use_command(ch, cmd)) { + if (!found) + { + send_to_char(ch, "\r\nDid you mean:\r\n"); + found = 1; + } + send_to_char(ch, " %s\r\n", cmd_info[cmd].command); } - send_to_char(ch, " %s\r\n", cmd_info[cmd].command); } } } diff --git a/src/oasis_list.c b/src/oasis_list.c index 4e4d886..fd366a6 100644 --- a/src/oasis_list.c +++ b/src/oasis_list.c @@ -22,6 +22,7 @@ #include "constants.h" #include "dg_scripts.h" #include "quest.h" +#include "modify.h" /* local functions */ static void list_triggers(struct char_data *ch, zone_rnum rnum, trig_vnum vmin, trig_vnum vmax); @@ -29,7 +30,7 @@ static void list_rooms(struct char_data *ch , zone_rnum rnum, room_vnum vmin, r static void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin , mob_vnum vmax ); static void list_objects(struct char_data *ch, zone_rnum rnum, obj_vnum vmin , obj_vnum vmax ); static void list_shops(struct char_data *ch , zone_rnum rnum, shop_vnum vmin, shop_vnum vmax); -static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax); +static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax, char *name); void perform_mob_flag_list(struct char_data * ch, char *arg) { @@ -102,6 +103,7 @@ ACMD(do_oasis_list) char smin[MAX_INPUT_LENGTH]; char smax[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; + bool use_name = FALSE; two_arguments(argument, smin, smax); @@ -110,7 +112,10 @@ ACMD(do_oasis_list) } else if (!*smax) { rzone = real_zone(atoi(smin)); - if (rzone == NOWHERE) { + if ((rzone == NOWHERE || rzone == 0) && subcmd == SCMD_OASIS_ZLIST && !isdigit(*smin)) { + /* Must be zlist, with builder name as arg */ + use_name = TRUE; + } else if (rzone == NOWHERE) { send_to_char(ch, "Sorry, there's no zone with that number\r\n"); return; } @@ -130,40 +135,42 @@ ACMD(do_oasis_list) two_arguments(argument, arg, arg2); - if (is_abbrev(arg, "level") || is_abbrev(arg, "flags")) { + if (is_abbrev(arg, "level") || is_abbrev(arg, "flags")) { + int i; - int i; + if (!*arg2) { + send_to_char(ch, "Which mobile flag or level do you want to list?\r\n"); + for (i=0; i%s\r\n", CCYEL(ch, C_NRM), CCNRM(ch, C_NRM)); + send_to_char(ch, " %smlist level %s\r\n", CCYEL(ch, C_NRM), CCNRM(ch, C_NRM)); + send_to_char(ch, "Displays mobs with the selected flag, or at the selected level\r\n\r\n"); - if (!*arg2) { - send_to_char(ch, "Which mobile flag or level do you want to list?\r\n"); - for (i=0; i%s\r\n", CCYEL(ch, C_NRM), CCNRM(ch, C_NRM)); - send_to_char(ch, " %smlist level %s\r\n", CCYEL(ch, C_NRM), CCNRM(ch, C_NRM)); - send_to_char(ch, "Displays mobs with the selected flag, or at the selected level\r\n\r\n"); - - return; - } - if (is_abbrev(arg, "level")) - perform_mob_level_list(ch, arg2); - else - perform_mob_flag_list(ch, arg2); - } else - list_mobiles(ch, rzone, vmin, vmax); break; + return; + } + if (is_abbrev(arg, "level")) + perform_mob_level_list(ch, arg2); + else + perform_mob_flag_list(ch, arg2); + } else + list_mobiles(ch, rzone, vmin, vmax); + break; case SCMD_OASIS_OLIST: list_objects(ch, rzone, vmin, vmax); break; case SCMD_OASIS_RLIST: list_rooms(ch, rzone, vmin, vmax); break; case SCMD_OASIS_TLIST: list_triggers(ch, rzone, vmin, vmax); break; case SCMD_OASIS_SLIST: list_shops(ch, rzone, vmin, vmax); break; case SCMD_OASIS_QLIST: list_quests(ch, rzone, vmin, vmax); break; case SCMD_OASIS_ZLIST: - if (!*smin) - list_zones(ch, NOWHERE, 0, zone_table[top_of_zone_table].number); - else - list_zones(ch, rzone, vmin, vmax); + if (!*smin) /* No args - list all zones */ + list_zones(ch, NOWHERE, 0, zone_table[top_of_zone_table].number, NULL); + else if (use_name) /* Builder name as arg */ + list_zones(ch, NOWHERE, 0, zone_table[top_of_zone_table].number, smin); + else /* Numerical args */ + list_zones(ch, rzone, vmin, vmax, NULL); break; default: send_to_char(ch, "You can't list that!\r\n"); @@ -402,22 +409,30 @@ static void list_shops(struct char_data *ch, zone_rnum rnum, shop_vnum vmin, sho } /* 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) +static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax, char *name) { - int counter = 0; + 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 { - bottom = vmin; - top = vmax; + } 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 */ } - send_to_char(ch, + len = snprintf(buf, sizeof(buf), "VNum Zone Name Builder(s)\r\n" "----- ------------------------------ --------------------------------------\r\n"); @@ -426,15 +441,21 @@ static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zon for (i = 0; i <= top_of_zone_table; i++) { if (zone_table[i].number >= bottom && zone_table[i].number <= top) { - send_to_char(ch, "[%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); + tmp_len = 0; + 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); } /* Prints all of the zone information for the selected zone. */ diff --git a/src/shop.c b/src/shop.c index 782a507..ba051e8 100644 --- a/src/shop.c +++ b/src/shop.c @@ -26,6 +26,7 @@ #include "act.h" #include "modify.h" #include "spells.h" /* for skill_name() */ +#include "screen.h" /* Global variables definitions used externally */ /* Constant list for printing out who we sell to */