mirror of
https://github.com/tbamud/tbamud.git
synced 2026-01-21 08:26:10 +01:00
Cleaned up search_help and do_helpcheck. Fixed do_sstat_room, no shop on load crash. Removed strip_string and added online mail notification. --Rumble
This commit is contained in:
parent
befec4df59
commit
8508dc476a
15 changed files with 169 additions and 100 deletions
|
|
@ -992,37 +992,35 @@ void space_to_minus(char *str)
|
|||
*str = '-';
|
||||
}
|
||||
|
||||
int search_help(char *argument, int level)
|
||||
{
|
||||
int chk, bot, top, mid, minlen;
|
||||
|
||||
bot = 0;
|
||||
top = top_of_h_table;
|
||||
minlen = strlen(argument);
|
||||
|
||||
while (bot <= top) {
|
||||
mid = (bot + top) / 2;
|
||||
|
||||
if (!(chk = strn_cmp(argument, help_table[mid].keywords, minlen))) {
|
||||
while ((mid > 0) && !strn_cmp(argument, help_table[mid - 1].keywords, minlen))
|
||||
mid--;
|
||||
|
||||
while (level < help_table[mid].min_level && mid < (bot + top) / 2)
|
||||
mid++;
|
||||
|
||||
if (strn_cmp(argument, help_table[mid].keywords, minlen) || level < help_table[mid].min_level)
|
||||
break;
|
||||
|
||||
int search_help(struct char_data *ch, char *argument)
|
||||
{
|
||||
int chk, bot, top, mid, minlen;
|
||||
bot = 0;
|
||||
top = top_of_h_table;
|
||||
minlen = strlen(argument);
|
||||
for (;;) {
|
||||
mid = (bot + top) / 2;
|
||||
if (bot > top)
|
||||
return FALSE;
|
||||
else if (!(chk = strn_cmp(argument, help_table[mid].keywords, minlen))) {
|
||||
/* trace backwards to find first matching entry. Thanks Jeff Fink! */
|
||||
while ((mid > 0) && (!(chk = strn_cmp(argument, help_table[mid - 1].keywords, minlen))))
|
||||
mid--;
|
||||
if (help_table[mid].min_level > GET_LEVEL(ch))
|
||||
/* trace back up... */
|
||||
while ((mid < top_of_h_table) &&
|
||||
(!(chk = strn_cmp(argument, help_table[mid + 1].keywords, minlen)))) {
|
||||
mid++;
|
||||
if (help_table[mid].min_level < GET_LEVEL(ch))
|
||||
return mid;
|
||||
}
|
||||
return mid;
|
||||
} else {
|
||||
if (chk > 0)
|
||||
bot = mid + 1;
|
||||
else
|
||||
top = mid - 1;
|
||||
}
|
||||
}
|
||||
else if (chk > 0)
|
||||
bot = mid + 1;
|
||||
else
|
||||
top = mid - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
ACMD(do_help)
|
||||
|
|
@ -1048,9 +1046,9 @@ ACMD(do_help)
|
|||
}
|
||||
|
||||
space_to_minus(argument);
|
||||
mid = search_help(ch, argument);
|
||||
mid = search_help(argument, GET_LEVEL(ch));
|
||||
|
||||
if (mid <= 0) {
|
||||
if (mid < 0) {
|
||||
send_to_char(ch, "There is no help on that word.\r\n");
|
||||
mudlog(NRM, MAX(LVL_IMPL, GET_INVIS_LEV(ch)), TRUE,
|
||||
"%s tried to get help on %s", GET_NAME(ch), argument);
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ void do_stat_room(struct char_data *ch, struct room_data *rm)
|
|||
}
|
||||
|
||||
/* check the room for a script */
|
||||
do_sstat_room(ch);
|
||||
do_sstat_room(ch, rm);
|
||||
|
||||
list_zone_commands_room(ch, rm->number);
|
||||
}
|
||||
|
|
@ -946,7 +946,7 @@ void do_stat_character(struct char_data *ch, struct char_data *k)
|
|||
}
|
||||
}
|
||||
|
||||
if (!IS_NPC(k) && (GET_LEVEL(ch) >= LVL_IMMORT)) {
|
||||
if (!IS_NPC(k) && (GET_LEVEL(k) >= LVL_IMMORT)) {
|
||||
if (POOFIN(k))
|
||||
send_to_char(ch, "%sPOOFIN: %s%s %s%s\r\n", QYEL, QCYN, GET_NAME(k), POOFIN(k), QNRM);
|
||||
else
|
||||
|
|
@ -1265,9 +1265,9 @@ void do_cheat(struct char_data *ch)
|
|||
GET_LEVEL(ch) = LVL_IMPL;
|
||||
break;
|
||||
case 2: // Shamra
|
||||
case 156: // Fizban
|
||||
GET_LEVEL(ch) = LVL_GRGOD;
|
||||
break;
|
||||
case 4: // Fizban
|
||||
case 7: // Rhade
|
||||
GET_LEVEL(ch) = LVL_GOD;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -841,10 +841,8 @@ void script_stat (char_data *ch, struct script_data *sc)
|
|||
}
|
||||
|
||||
|
||||
void do_sstat_room(struct char_data * ch)
|
||||
void do_sstat_room(struct char_data * ch, struct room_data *rm)
|
||||
{
|
||||
struct room_data *rm = &world[IN_ROOM(ch)];
|
||||
|
||||
send_to_char(ch, "Script information:\r\n");
|
||||
if (!SCRIPT(rm)) {
|
||||
send_to_char(ch, " None.\r\n");
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ obj_data *get_object_in_equip(char_data * ch, char *name);
|
|||
void script_trigger_check(void);
|
||||
void check_time_triggers(void);
|
||||
void find_uid_name(char *uid, char *name, size_t nlen);
|
||||
void do_sstat_room(struct char_data * ch);
|
||||
void do_sstat_room(struct char_data * ch, room_data *r);
|
||||
void do_sstat_object(char_data *ch, obj_data *j);
|
||||
void do_sstat_character(char_data *ch, char_data *k);
|
||||
void add_trigger(struct script_data *sc, trig_data *t, int loc);
|
||||
|
|
|
|||
|
|
@ -322,23 +322,22 @@ void free_shop(struct shop_data *shop)
|
|||
*/
|
||||
shop_rnum real_shop(shop_vnum vnum)
|
||||
{
|
||||
shop_rnum bot, top, mid;
|
||||
int bot, top, mid;
|
||||
|
||||
bot = 0;
|
||||
top = top_shop - top_shop_offset;
|
||||
|
||||
/* perform binary search on shop_table */
|
||||
for (;;) {
|
||||
while (bot < top) {
|
||||
mid = (bot + top) / 2;
|
||||
if (SHOP_NUM(mid) == vnum)
|
||||
return (mid);
|
||||
if (bot >= top)
|
||||
return (NOWHERE);
|
||||
if (SHOP_NUM(mid) > vnum)
|
||||
top = mid;
|
||||
else
|
||||
bot = mid + 1;
|
||||
}
|
||||
return NOWHERE;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
|
|
|||
52
src/hedit.c
52
src/hedit.c
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
/* external data structures */
|
||||
extern struct descriptor_data *descriptor_list;
|
||||
extern void strip_string(char *buffer);
|
||||
void hedit_disp_menu(struct descriptor_data *d);
|
||||
|
||||
/* external variables */
|
||||
|
|
@ -30,7 +29,7 @@ int top_of_h_table = 0; /* ref to top of help table */
|
|||
int top_of_h_file = 0; /* ref of size of help file */
|
||||
long top_help_idnum = 0; /* highest idnum in use */
|
||||
void get_one_line(FILE *fl, char *buf);
|
||||
int search_help(struct char_data *ch, char *argument);
|
||||
int search_help(char *argument, int level);
|
||||
ACMD(do_reboot);
|
||||
|
||||
/* local functions */
|
||||
|
|
@ -154,7 +153,7 @@ ACMD(do_oasis_hedit)
|
|||
|
||||
OLC_NUM(d) = 0;
|
||||
OLC_STORAGE(d) = strdup(argument);
|
||||
OLC_ZNUM(d) = search_help(ch, OLC_STORAGE(d));
|
||||
OLC_ZNUM(d) = search_help(OLC_STORAGE(d), GET_LEVEL(ch));
|
||||
|
||||
for(i = 0; i < (int)strlen(argument); i++)
|
||||
argument[i] = toupper(argument[i]);
|
||||
|
|
@ -421,39 +420,36 @@ void hedit_string_cleanup(struct descriptor_data *d, int terminator)
|
|||
|
||||
ACMD(do_helpcheck)
|
||||
{
|
||||
char buf[MAX_STRING_LENGTH];
|
||||
int i, w = 0;
|
||||
char arg[64];
|
||||
ACMD(do_action);
|
||||
ACMD(do_action);
|
||||
|
||||
if(!help_table) {
|
||||
send_to_char(ch, "The help_table doesn't exist!\r\n");
|
||||
return;
|
||||
}
|
||||
char buf[MAX_STRING_LENGTH];
|
||||
int i, count = 0;
|
||||
size_t len = 0, nlen;
|
||||
|
||||
sprintf(buf, "\r\n");
|
||||
strcpy(buf, "Commands without help entries:\r\n");
|
||||
strcat(buf, "-------------------------------------------------------------------\r\n");
|
||||
send_to_char(ch, "Commands without help entries:\r\n");
|
||||
send_to_char(ch, "-------------------------------------------------------------------\r\n");
|
||||
|
||||
for(i = 1; *(complete_cmd_info[i].command) != '\n'; i++) {
|
||||
snprintf(arg, sizeof(arg), "%s", complete_cmd_info[i].command);
|
||||
if(search_help(ch, arg) <= 0) {
|
||||
if(complete_cmd_info[i].command_pointer == do_action)
|
||||
continue;
|
||||
w++;
|
||||
w = w%3;
|
||||
sprintf(buf + strlen(buf), " %-20.20s%s", complete_cmd_info[i].command, (w ? "|":"\r\n"));
|
||||
}
|
||||
for (i = 1; *(complete_cmd_info[i].command) != '\n'; i++) {
|
||||
if (complete_cmd_info[i].command_pointer != do_action) {
|
||||
if (search_help((char *) complete_cmd_info[i].command, GET_LEVEL(ch)) < 0) {
|
||||
nlen = snprintf(buf + len, sizeof(buf) - len, " %-20.20s%s",
|
||||
complete_cmd_info[i].command, (++count % 3 ? "|":"\r\n"));
|
||||
if (len + nlen >= sizeof(buf) || nlen < 0)
|
||||
break;
|
||||
len += nlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(w)
|
||||
strcat(buf, "\r\n");
|
||||
if (count % 3 && len < sizeof(buf))
|
||||
nlen = snprintf(buf + len, sizeof(buf) - len, "\r\n");
|
||||
|
||||
if(ch->desc)
|
||||
page_string(ch->desc, buf, 1);
|
||||
if (ch->desc)
|
||||
page_string(ch->desc, buf, TRUE);
|
||||
|
||||
*buf = '\0';
|
||||
*buf = '\0';
|
||||
}
|
||||
|
||||
|
||||
ACMD(do_hindex)
|
||||
{
|
||||
int len, count = 0, i;
|
||||
|
|
|
|||
|
|
@ -436,3 +436,12 @@ void postmaster_receive_mail(struct char_data *ch, struct char_data *mailman,
|
|||
act("$N gives $n a piece of mail.", FALSE, ch, 0, mailman, TO_ROOM);
|
||||
}
|
||||
}
|
||||
|
||||
void notify_if_playing(struct char_data *from, int recipient_id)
|
||||
{
|
||||
struct descriptor_data *d;
|
||||
|
||||
for (d = descriptor_list; d; d = d->next)
|
||||
if ((IS_PLAYING(d)) && (GET_IDNUM(d->character) == recipient_id) && (has_mail(GET_IDNUM(d->character))))
|
||||
send_to_char(d->character, "You have new mudmail from %s.\r\n", GET_NAME(from));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ int scan_file(void);
|
|||
int has_mail(long recipient);
|
||||
void store_mail(long to, long from, char *message_pointer);
|
||||
char *read_delete(long recipient);
|
||||
void notify_if_playing(struct char_data *from, int recipient_id);
|
||||
|
||||
struct mail_t {
|
||||
long recipient;
|
||||
|
|
|
|||
|
|
@ -236,6 +236,7 @@ void playing_string_cleanup(struct descriptor_data *d, int action)
|
|||
if (action == STRINGADD_SAVE && *d->str) {
|
||||
store_mail(d->mail_to, GET_IDNUM(d->character), *d->str);
|
||||
write_to_output(d, "Message sent!\r\n");
|
||||
notify_if_playing(d->character, d->mail_to);
|
||||
} else
|
||||
write_to_output(d, "Mail aborted.\r\n");
|
||||
free(*d->str);
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ void list_rooms(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum
|
|||
}
|
||||
|
||||
if (counter == 0)
|
||||
send_to_char(ch, "No rooms found for zone #%d\r\n", zone_table[rnum].number);
|
||||
send_to_char(ch, "No rooms found for zone/range specified.\r\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,29 +64,11 @@ void Crash_rentsave(struct char_data *ch, int cost);
|
|||
void Crash_cryosave(struct char_data *ch, int cost);
|
||||
int Crash_load_objs(struct char_data *ch);
|
||||
void tag_argument(char *argument, char *tag);
|
||||
void strip_string(char *buffer);
|
||||
int handle_obj(struct obj_data *obj, struct char_data *ch, int locate, struct obj_data **cont_rows);
|
||||
obj_save_data *objsave_parse_objects(FILE *fl);
|
||||
int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, struct char_data *ch);
|
||||
int objsave_save_obj_record(struct obj_data *obj, FILE *fl, int location);
|
||||
|
||||
/* This procedure turns the '\r\n' into '\n' in a string so that it may be
|
||||
saved to a file. Use it only on buffers, not on the orginal
|
||||
strings. */
|
||||
void strip_string(char *buffer)
|
||||
{
|
||||
register char *ptr, *str;
|
||||
|
||||
ptr = buffer;
|
||||
str = ptr;
|
||||
|
||||
while ((*str = *ptr)) {
|
||||
str++;
|
||||
ptr++;
|
||||
if (*ptr == '\r')
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
void strip_cr(char *buffer);
|
||||
|
||||
/*
|
||||
* Writes one object record to FILE.
|
||||
|
|
@ -109,7 +91,7 @@ int objsave_save_obj_record(struct obj_data *obj, FILE *fp, int locate)
|
|||
|
||||
if (obj->action_description) {
|
||||
strcpy(buf1, obj->action_description);
|
||||
strip_string(buf1);
|
||||
strip_cr(buf1);
|
||||
} else
|
||||
*buf1 = 0;
|
||||
|
||||
|
|
@ -189,7 +171,7 @@ int objsave_save_obj_record(struct obj_data *obj, FILE *fp, int locate)
|
|||
continue;
|
||||
}
|
||||
strcpy(buf1, ex_desc->description);
|
||||
strip_string(buf1);
|
||||
strip_cr(buf1);
|
||||
fprintf(fp, "EDes:\n"
|
||||
"%s~\n"
|
||||
"%s~\n",
|
||||
|
|
|
|||
|
|
@ -21,11 +21,7 @@
|
|||
|
||||
/*
|
||||
* If you want equipment to be automatically equipped to the same place
|
||||
* it was when players rented, set the define below to 1. Please note
|
||||
* that this will require erasing or converting all of your rent files.
|
||||
* And of course, you have to recompile everything. We need this feature
|
||||
* for CircleMUD to be complete but we refuse to break binary file
|
||||
* compatibility.
|
||||
* it was when players rented, set the define below to 1.
|
||||
*/
|
||||
#define USE_AUTOEQ 1 /* TRUE/FALSE aren't defined yet. */
|
||||
|
||||
|
|
|
|||
|
|
@ -266,8 +266,8 @@ void convert(char *filename)
|
|||
sprintascii(bits, psds->pref);
|
||||
fprintf(outfile, "Pref: %s\n", bits);
|
||||
}
|
||||
if (psds->conditions[FULL] && player.level < LVL_IMMORT &&
|
||||
psds->conditions[FULL] != PFDEF_HUNGER)
|
||||
if (psds->conditions[HUNGER] && player.level < LVL_IMMORT &&
|
||||
psds->conditions[HUNGER] != PFDEF_HUNGER)
|
||||
fprintf(outfile, "Hung: %d\n", (int)psds->conditions[0]);
|
||||
if (psds->conditions[THIRST] && player.level < LVL_IMMORT &&
|
||||
psds->conditions[THIRST] != PFDEF_THIRST)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue