int find_skill_num(char *name) { int skindex, ok; char *temp, *temp2; char first[256], first2[256], tempbuf[256]; for (skindex = 1; skindex <= TOP_SPELL_DEFINE; skindex++) { if (is_abbrev(name, spell_info[skindex].name)) return (skindex); ok = TRUE; strlcpy(tempbuf, spell_info[skindex].name, sizeof(tempbuf)); /* strlcpy: OK */ temp = any_one_arg(tempbuf, first); temp2 = any_one_arg(name, first2); while (*first && *first2 && ok) { if (!is_abbrev(first2, first)) ok = FALSE; temp = any_one_arg(temp, first); temp2 = any_one_arg(temp2, first2); } if (ok && !*first2) return (skindex); } return (-1); }
/* Поиск номера способности по имени */ int find_feat_num(char *name) { int index, ok; char const *temp, *temp2; char first[256], first2[256]; for (index = 1; index < MAX_FEATS; index++) { if (is_abbrev(name, feat_info[index].name)) return (index); ok = TRUE; /* It won't be changed, but other uses of this function elsewhere may. */ temp = any_one_arg(feat_info[index].name, first); temp2 = any_one_arg(name, first2); while (*first && *first2 && ok) { if (!is_abbrev(first2, first)) ok = FALSE; temp = any_one_arg(temp, first); temp2 = any_one_arg(temp2, first2); } if (ok && !*first2) return (index); } return (-1); }
int find_skill_num(char *name) { int index, ok; char *temp, *temp2; char first[256], first2[256]; for (index = 1; index <= TOP_SPELL_DEFINE; index++) { if (is_abbrev(name, spell_info[index].name)) return (index); ok = TRUE; /* It won't be changed, but other uses of this function elsewhere may. */ temp = any_one_arg((char *)spell_info[index].name, first); temp2 = any_one_arg(name, first2); while (*first && *first2 && ok) { if (!is_abbrev(first2, first)) ok = FALSE; temp = any_one_arg(temp, first); temp2 = any_one_arg(temp2, first2); } if (ok && !*first2) return (index); } return (-1); }
int find_spell_num(char *name) { int ok; char *temp, *temp2; char first[256], first2[256]; struct spell_info_type *sptr; for (sptr = spell_info; sptr; sptr = sptr->next) { if (sptr->number == 0) continue; if (is_abbrev(name, sptr->name)) return (sptr->number); ok = TRUE; /* It won't be changed, but other uses of this function elsewhere may. */ temp = any_one_arg(sptr->name, first); temp2 = any_one_arg(name, first2); while (*first && *first2 && ok) { if (!is_abbrev(first2, first)) ok = FALSE; temp = any_one_arg(temp, first); temp2 = any_one_arg(temp2, first2); } if (ok && !*first2) return (sptr->number); } return (-1); }
void do_drestrict(struct char_data *ch, char *argument, int cmd) { char buf[MAX_INPUT_LENGTH]; int i, mud; if (IS_SET(ch->pc->plr, PLR_NODIMD)) { msg("Your DIMD privileges were taken away!", ch); return; }; argument = one_argument(argument, buf); if ((mud=getmud(ch, buf, FALSE))==UNDEFINED) return; while(isspace(*argument)) argument++; if (is_abbrev(argument, "refuse")) { SET_BIT(muds[mud].flags, DD_REFUSE); sprintf(buf, "Now refusing new connections with %s.", muds[mud].formalname); msg(buf, ch); DIMDLOG(buf); return; }; if (is_abbrev(argument, "accept")) { REMOVE_BIT(muds[mud].flags, DD_REFUSE); sprintf(buf, "Now accepting new connections with %s.", muds[mud].formalname); msg(buf, ch); DIMDLOG(buf); return; }; i = atoi(argument); muds[mud].min_level = i; sprintf(buf, "Setting %s's DIMD incoming level to %d.", muds[mud].formalname, i); msg(buf, ch); sprintf(buf, "%s set %s's DIMD incoming level to %d.", PER(ch), muds[mud].formalname, i); DIMDLOG(buf); }
ExitDirection parse_dir(char *dir) { int i; for (i = 0; i<= 5; i++) if (is_abbrev(dir, exits[i]) ) return static_cast<ExitDirection>(i); return ED_UNKNOWN; }
int parse_char_class(char *arg) { int j; for (j = 0; j < TOP_CLASS; j++) if (is_abbrev(arg, class_names[j])) return j; return (-1); }
int get_highlight_codes(struct session *ses, char *string, char *result) { int cnt; *result = 0; if (*string == '<') { substitute(ses, string, result, SUB_COL); return TRUE; } while (*string) { if (isalpha((int) *string)) { for (cnt = 0 ; *color_table[cnt].name ; cnt++) { if (is_abbrev(color_table[cnt].name, string)) { substitute(ses, color_table[cnt].code, result, SUB_COL); result += strlen(result); break; } } if (*color_table[cnt].name == 0) { return FALSE; } string += strlen(color_table[cnt].name); } switch (*string) { case ' ': case ',': string++; break; case 0: return TRUE; default: return FALSE; } } return TRUE; }
static void set_dyntext(struct creature *ch, dynamic_text_file * dyntext, char *argument) { char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; int lev; two_arguments(argument, arg1, arg2); if (!*arg1 || !*arg2) { send_to_char(ch, "Dynedit set requires more arguments.\r\n"); show_dynedit_options(ch); return; } if (is_abbrev(arg1, "level")) { lev = atoi(arg2); if (lev > GET_LEVEL(ch)) { send_to_char(ch, "Let's not set it above your own level, shall we?\r\n"); return; } dyntext->level = lev; send_to_char(ch, "Level set.\r\n"); } else { send_to_char(ch, "Dynedit set valid arguments: level.\r\n"); return; } if (save_dyntext_control(dyntext)) send_to_char(ch, "An error occurred while saving the control file.\r\n"); else send_to_char(ch, "Control file saved.\r\n"); }
int isname(const char *str, const char *namelist) { char *newlist; char *curtok; if (!str || !*str || !namelist || !*namelist) return 0; if (!strcmp(str, namelist)) /* the easy way */ return 1; newlist = strdup(namelist); /* make a copy since strtok 'modifies' strings */ for(curtok = strtok(newlist, WHITESPACE); curtok; curtok = strtok(NULL, WHITESPACE)) if(curtok && is_abbrev(str, curtok)) { /* Don't allow abbreviated numbers. - Sryth */ if (isdigit(*str) && (atoi(str) != atoi(curtok))) return 0; free(newlist); return 1; } free(newlist); return 0; }
/* Display a nicely formatted map with a legend */ void perform_map( struct char_data *ch, char *argument, bool worldmap ) { int size = DEFAULT_MAP_SIZE; int centre, x, y, min, max; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH], buf1[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH]; int count = 0; int ew_size=0, ns_size=0; int mapshape = MAP_CIRCLE; two_arguments( argument, arg1 , arg2 ); if(*arg1) { size = atoi(arg1); } if (*arg2) { if (is_abbrev(arg2, "normal")) worldmap=FALSE; else if (is_abbrev(arg2, "world")) worldmap=TRUE; else { send_to_char(ch, "Usage: \tymap <distance> [ normal | world ]\tn"); return; } } if(size<0) { size = -size; mapshape = MAP_RECTANGLE; } size = URANGE(1,size,MAX_MAP_SIZE); centre = MAX_MAP/2; if(worldmap) { min = centre - 2*size; max = centre + 2*size; } else { min = centre - size; max = centre + size; } /* Blank the map */ for (x = 0; x < MAX_MAP; ++x) for (y = 0; y < MAX_MAP; ++y) map[x][y]= (!(y%2) && !worldmap) ? DOOR_NONE : SECT_EMPTY; /* starts the mapping with the centre room */ MapArea(IN_ROOM(ch), ch, centre, centre, min, max, ns_size/2, ew_size/2, worldmap); /* marks the center, where ch is */ map[centre][centre] = SECT_HERE; /* Feel free to put your own MUD name or header in here */ send_to_char(ch, " \tb--\tB= \tCLuminari Map System \tB=\tb--\tn\r\n" "\tD .-.__--.,--.__.-.\tn\r\n" ); count += sprintf(buf + count, "\tn\tn\tn%s Up\\\\", door_info[NUM_DOOR_TYPES + DOOR_UP].disp); count += sprintf(buf + count, "\tn\tn\tn%s Down\\\\", door_info[NUM_DOOR_TYPES + DOOR_DOWN].disp); count += sprintf(buf + count, "\tn%s You\\\\", map_info[SECT_HERE].disp); count += sprintf(buf + count, "\tn%s Inside\\\\", map_info[SECT_INSIDE].disp); count += sprintf(buf + count, "\tn%s City\\\\", map_info[SECT_CITY].disp); count += sprintf(buf + count, "\tn%s Field\\\\", map_info[SECT_FIELD].disp); count += sprintf(buf + count, "\tn%s Forest\\\\", map_info[SECT_FOREST].disp); count += sprintf(buf + count, "\tn%s Hills\\\\", map_info[SECT_HILLS].disp); count += sprintf(buf + count, "\tn%s Mountain\\\\", map_info[SECT_MOUNTAIN].disp); count += sprintf(buf + count, "\tn%s Water\\\\", map_info[SECT_WATER_SWIM].disp); count += sprintf(buf + count, "\tn%s Deep Water\\\\", map_info[SECT_WATER_NOSWIM].disp); count += sprintf(buf + count, "\tn%s Air\\\\", map_info[SECT_FLYING].disp); count += sprintf(buf + count, "\tn%s Underwater\\\\", map_info[SECT_UNDERWATER].disp); count += sprintf(buf + count, "\tn%s Zone Entry\\\\", map_info[SECT_ZONE_START].disp); count += sprintf(buf + count, "\tn%s Road N-S\\\\", map_info[SECT_ROAD_NS].disp); count += sprintf(buf + count, "\tn%s Road E-W\\\\", map_info[SECT_ROAD_EW].disp); count += sprintf(buf + count, "\tn%s Intersect\\\\", map_info[SECT_ROAD_INT].disp); count += sprintf(buf + count, "\tn%s Desert\\\\", map_info[SECT_DESERT].disp); count += sprintf(buf + count, "\tn%s Ocean\\\\", map_info[SECT_OCEAN].disp); count += sprintf(buf + count, "\tn%s Marsh\\\\", map_info[SECT_MARSHLAND].disp); count += sprintf(buf + count, "\tn%s High Mount\\\\", map_info[SECT_HIGH_MOUNTAIN].disp); count += sprintf(buf + count, "\tn%s Planes\\\\", map_info[SECT_PLANES].disp); strcpy(buf, strfrmt(buf, LEGEND_WIDTH, CANVAS_HEIGHT + 2, FALSE, TRUE, TRUE)); /* Start with an empty column */ strcpy(buf1, strfrmt("",0, CANVAS_HEIGHT + 2, FALSE, FALSE, TRUE)); /* Paste the legend */ strcpy(buf2, strpaste(buf1, buf, "\tD | \tn")); /* Set up the map */ memset(buf, ' ', CANVAS_WIDTH); count = (CANVAS_WIDTH); if(worldmap) count += sprintf(buf + count , "\r\n%s", WorldMap(centre, size, mapshape, MAP_NORMAL)); else count += sprintf(buf + count , "\r\n%s", StringMap(centre, size)); memset(buf + count, ' ', CANVAS_WIDTH); strcpy(buf + count + CANVAS_WIDTH, "\r\n"); /* Paste it on */ strcpy(buf2, strpaste(buf2, buf, "\tD | \tn")); /* Paste on the right border */ strcpy(buf2, strpaste(buf2, buf1, " ")); /* Print it all out */ send_to_char(ch, "%s", buf2); send_to_char(ch, "\tD `.-.__--.,-.__.-.-'\tn\r\n"); return; }
void command_interpreter (CHAR_DATA * ch, char *argument) { char buf[MAX_STRING_LENGTH]; char *command_args, *p, *social_args; int cmd_level = 0; int i = 0, echo = 1; AFFECTED_TYPE *craft_affect = NULL; AFFECTED_TYPE *af; ALIAS_DATA *alias; extern int second_affect_active; if (!ch) return; *buf = '\0'; p = argument; while (*p == ' ') p++; if (strchr (p, '%')) { send_to_char ("Input with the '%' character is not permitted.\n", ch); return; } if (strchr (p, '#') && IS_MORTAL (ch) && strncmp (p, "ge", 2) != 0 && strncmp (p, "buy", 3) != 0) { send_to_char ("Input with the '#' character is not permitted.\n", ch); return; } if (IS_MORTAL (ch) && strchr (p, '$')) { send_to_char ("Input with the '$' character is not permitted.\n", ch); return; } std::multimap<int, room_prog>::iterator it; if (IS_NPC(ch)) it = mob_prog_list.find(ch->mob->nVirtual); if (IS_NPC(ch) && !get_second_affect (ch, SA_DOANYWAY, 0) && it != mob_prog_list.end()) { if (m_prog(ch, p)) { return; } } std::pair<std::multimap<int, room_prog>::iterator, std::multimap<int, room_prog>::iterator> pair; if (ch->right_hand && !get_second_affect (ch, SA_DOANYWAY, 0)) { pair = obj_prog_list.equal_range(ch->right_hand->nVirtual); for (it = pair.first; it != pair.second; it++) { if (it->second.type != 1 && it->second.type != 3 && it->second.type != 5) continue; if (o_prog(ch, p, it->second)) return; } } if (ch->left_hand && !get_second_affect (ch, SA_DOANYWAY, 0)) { pair = obj_prog_list.equal_range(ch->left_hand->nVirtual); for (it = pair.first; it != pair.second; it++) { if (it->second.type != 1 && it->second.type != 3 && it->second.type != 5) continue; if (o_prog(ch, p, it->second)) return; } } for (OBJ_DATA *tobj = ch->equip; tobj; tobj = tobj->next_content) { if (get_second_affect (ch, SA_DOANYWAY, 0)) break; pair = obj_prog_list.equal_range(tobj->nVirtual); for (it = pair.first; it != pair.second; it++) { if (it->second.type != 2 && it->second.type != 3 && it->second.type != 5) continue; if (o_prog(ch, p, it->second)) return; } } /* this is where it crashes on the hour - Grommit */ if (!ch->room ) { std::ostringstream stream; stream << "Error in command_interpreter:commands.cpp. Command \"" << argument << "\" called by \"" << ch->tname << "\" with null room. Previously in " << (ch->last_room) << " entering null room from the " << (dirs[ch->from_dir]) << "."; system_log(stream.str().c_str(),true); return; } /* end grommit diagnostics to avoid segfaulting on the below for loop */ for (OBJ_DATA *tobj = ch->room->contents; tobj; tobj = tobj->next_content) { if (get_second_affect (ch, SA_DOANYWAY, 0)) break; pair = obj_prog_list.equal_range(tobj->nVirtual); for (it = pair.first; it != pair.second; it++) { if (it->second.type != 4 && it->second.type != 5) continue; if (o_prog(ch, p, it->second)) return; } } for (CHAR_DATA *temp_char = ch->room->people; temp_char; temp_char = temp_char->next_in_room) { if (get_second_affect (ch, SA_DOANYWAY, 0)) break; if (temp_char == ch) continue; if (!IS_NPC(temp_char)) continue; pair = mob_prog_list.equal_range(temp_char->mob->nVirtual); for (it = pair.first; it != pair.second; ++it) { if (m_prog(ch, p, it->second)) return; } } if (ch->room && ch->room->prg && !get_second_affect(ch, SA_DOANYWAY, 0) && r_program (ch, p)) { if (!IS_NPC (ch) || (ch->desc && (ch->pc && str_cmp (ch->pc->account_name, "Guest")))) { player_log (ch, "[RPROG]", p); } if (!IS_SET (commands[i].flags, C_NWT)) show_to_watchers (ch, argument); return; } if (get_second_affect(ch, SA_DOANYWAY, 0)) remove_second_affect(get_second_affect(ch, SA_DOANYWAY, 0)); if (!IS_MORTAL (ch) && !str_cmp (argument, "sho wl")) { send_to_char ("Heh heh. Glad I added in this check, aren't we? No shouting for you.\n", ch); return; } if (ch->desc) { last_descriptor = ch->desc; sprintf (full_last_command, "Last Command Issued, by %s [%d]: %s", ch->tname, ch->in_room, argument); sprintf (last_command, "%s", argument); } social_args = argument; command_args = one_argument (argument, buf); if (!*buf) return; while (*command_args == ' ') command_args++; if (ch->pc && !GET_FLAG (ch, FLAG_ALIASING)) { if ((alias = is_alias (ch, buf))) { ch->flags |= FLAG_ALIASING; while (alias) { command_interpreter (ch, alias->line); if (ch->deleted) return; alias = alias->next_line; } ch->flags &= ~FLAG_ALIASING; return; } } for (i = 1; *commands[i].command; i++) if (is_abbrev (buf, commands[i].command)) break; if ((craft_affect = is_craft_command (ch, argument))) i = 0; if (IS_SET (commands[i].flags, C_IMP)) { cmd_level = 6; } else if (IS_SET (commands[i].flags, C_LV5)) { cmd_level = 5; } else if (IS_SET (commands[i].flags, C_LV4)) { cmd_level = 4; } else if (IS_SET (commands[i].flags, C_LV3)) { cmd_level = 3; } else if (IS_SET (commands[i].flags, C_LV2)) { cmd_level = 2; } else if (IS_SET (commands[i].flags, C_LV1)) { cmd_level = 1; } if (IS_SET (commands[i].flags, C_GDE) && (IS_NPC (ch) || (!ch->pc->is_guide && !ch->pc->level))) { send_to_char ("Eh?\n\r", ch); return; } /* Need to pass the CHAR_DATA pointer for the person who made the command and modify the following line to test the commanding char's trust against the trust level for the command. - Methuselah */ if ((!*commands[i].command) || (cmd_level > GET_TRUST (ch))) { if (!social (ch, argument)) { echo = number (1, 9); if (echo == 1) send_to_char ("Eh?\n\r", ch); else if (echo == 2) send_to_char ("Huh?\n\r", ch); else if (echo == 3) send_to_char ("I'm afraid that just isn't possible...\n\r", ch); else if (echo == 4) send_to_char ("I don't recognize that command.\n\r", ch); else if (echo == 5) send_to_char ("What?\n\r", ch); else if (echo == 6) send_to_char ("Perhaps you should try typing it a different way?\n\r", ch); else if (echo == 7) send_to_char ("Try checking your typing - I don't recognize it.\n\r", ch); else if (echo == 8) send_to_char ("That isn't a recognized command, craft, or social.\n\r", ch); else send_to_char ("Hmm?\n\r", ch); } else { if (!IS_SET (commands[i].flags, C_NWT)) show_to_watchers (ch, argument); } return; } if (ch->stun) { send_to_char ("You're still reeling.\n", ch); return; } if (ch->roundtime) { sprintf (buf, "You'll need to wait another %d seconds.\n", ch->roundtime); send_to_char (buf, ch); return; } if (IS_SET (commands[i].flags, C_WLK) && (ch->moves || GET_FLAG (ch, FLAG_LEAVING) || GET_FLAG (ch, FLAG_ENTERING))) { send_to_char ("Stop traveling first.\n\r", ch); return; } if (IS_SET (commands[i].flags, C_MNT) && IS_RIDER (ch)) { send_to_char ("Get off your mount first.\n", ch); return; } if (commands[i].min_position > GET_POS (ch)) { switch (GET_POS (ch)) { case DEAD: if (IS_MORTAL (ch)) { send_to_char ("You are dead. You can't do that.\n\r", ch); return; } case UNCON: case MORT: send_to_char ("You're seriously wounded and unconscious.\n\r", ch); return; case STUN: send_to_char ("You're too stunned to do that.\n\r", ch); return; case SLEEP: send_to_char ("You can't do that while sleeping.\n\r", ch); return; case REST: send_to_char ("You can't do that while lying down.\n\r", ch); return; case SIT: send_to_char ("You can't do that while sitting.\n\r", ch); return; case FIGHT: send_to_char ("No way! You are fighting for your life!\n\r", ch); return; } return; } if (!IS_NPC (ch) && ch->pc->create_state == STATE_DIED && !IS_SET (commands[i].flags, C_DOA)) { send_to_char ("You can't do that when you're dead.\n\r", ch); return; } if (!IS_SET (commands[i].flags, C_BLD) && is_blind (ch)) { if (get_equip (ch, WEAR_BLINDFOLD)) send_to_char ("You can't do that while blindfolded.\n\r", ch); else send_to_char ("You can't do that while blind.\n\r", ch); return; } if ((af = get_affect (ch, MAGIC_AFFECT_PARALYSIS)) && !IS_SET (commands[i].flags, C_PAR) && IS_MORTAL (ch)) { send_to_char ("You can't move.\n", ch); return; } if (IS_SUBDUEE (ch) && !IS_SET (commands[i].flags, C_SUB) && !cmd_level) { act ("$N won't let you.", false, ch, 0, ch->subdue, TO_CHAR); return; } /* Most commands break delays */ if (ch->delay && !IS_SET (commands[i].flags, C_DEL)) break_delay (ch); /* Send this command to the log */ if (!second_affect_active && (!IS_NPC (ch) || ch->desc)) { if (IS_SET (commands[i].flags, C_NLG)) ; else if (i > 0) { /* Log craft commands separately. */ if (!str_cmp (commands[i].command, ".")) player_log (ch, "say", command_args); else if (!str_cmp (commands[i].command, ",")) player_log (ch, "emote", command_args); else if (!str_cmp (commands[i].command, ":")) player_log (ch, "emote", command_args); else if (!str_cmp (commands[i].command, ";")) player_log (ch, "wiznet", command_args); else player_log (ch, commands[i].command, command_args); } } if (IS_MORTAL (ch) && get_affect (ch, MAGIC_HIDDEN) && !IS_SET (commands[i].flags, C_HID) && skill_level (ch, SKILL_SNEAK, 0) < number (1, MAX(100, skill_level(ch, SKILL_SNEAK, 0))) && would_reveal (ch)) { remove_affect_type (ch, MAGIC_HIDDEN); act ("$n reveals $mself.", true, ch, 0, 0, TO_ROOM | _ACT_FORMAT); act ("Your actions have compromised your concealment.", true, ch, 0, 0, TO_CHAR); } /* Execute command */ if (!IS_SET (commands[i].flags, C_NWT)) show_to_watchers (ch, social_args); if (!i) /* craft_command */ craft_command (ch, command_args, craft_affect); else (*commands[i].proc) (ch, command_args, 0); last_descriptor = NULL; }
int social (CHAR_DATA * ch, char *argument) { char buf[MAX_INPUT_LENGTH]; SOCIAL_DATA *action; CHAR_DATA *victim; int i; argument = one_argument (argument, buf); if (ch->room->nVirtual == AMPITHEATRE && IS_MORTAL (ch)) { if (!get_obj_in_list_num (VNUM_SPEAKER_TOKEN, ch->right_hand) && !get_obj_in_list_num (VNUM_SPEAKER_TOKEN, ch->left_hand)) { send_to_char ("You decide against making a commotion. PETITION to request to speak.\n", ch); return 0; } } for (i = 0; i < list_top; i++) { if (is_abbrev (buf, social_messages[i].social_command)) break; } if (i == list_top) return 0; action = &social_messages[i]; if (action->char_found) one_argument (argument, buf); else *buf = '\0'; if (!*buf) { send_to_char (action->char_no_arg, ch); send_to_char ("\n\r", ch); if (action->others_no_arg) act (action->others_no_arg, action->hide, ch, 0, 0, TO_ROOM); return 1; } if (!(victim = get_char_room_vis (ch, buf))) { send_to_char (action->not_found, ch); send_to_char ("\n\r", ch); } else if (victim == ch) { send_to_char (action->char_auto, ch); send_to_char ("\n\r", ch); if (action->others_auto) act (action->others_auto, action->hide, ch, 0, 0, TO_ROOM); } else if (GET_POS (victim) < action->min_victim_position) act ("$N is not in a proper position for that.", false, ch, 0, victim, TO_CHAR); else { if (action->char_found) act (action->char_found, 0, ch, 0, victim, TO_CHAR); if (action->others_found) act (action->others_found, action->hide, ch, 0, victim, TO_NOTVICT); if (action->vict_found) act (action->vict_found, action->hide, ch, 0, victim, TO_VICT); } return 1; }
static int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname) { int door; if (*dir) { /* a direction was specified */ if ((door = search_block(dir, dirs, FALSE)) == -1) { /* Partial Match */ if ((door = search_block(dir, autoexits, FALSE)) == -1) { /* Check 'short' dirs too */ send_to_char(ch, "That's not a direction.\r\n"); return (-1); } } if (EXIT(ch, door)) { /* Braces added according to indent. -gg */ if (EXIT(ch, door)->keyword) { if (is_name(type, EXIT(ch, door)->keyword)) return (door); else { send_to_char(ch, "I see no %s there.\r\n", type); return (-1); } } else return (door); } else { send_to_char(ch, "I really don't see how you can %s anything there.\r\n", cmdname); return (-1); } } else { /* try to locate the keyword */ if (!*type) { send_to_char(ch, "What is it you want to %s?\r\n", cmdname); return (-1); } for (door = 0; door < DIR_COUNT; door++) { if (EXIT(ch, door)) { if (EXIT(ch, door)->keyword) { if (isname(type, EXIT(ch, door)->keyword)) { if ((!IS_NPC(ch)) && (!PRF_FLAGGED(ch, PRF_AUTODOOR))) return door; else if (is_abbrev(cmdname, "open")) { if (IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED)) return door; else if (IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED)) return door; } else if ((is_abbrev(cmdname, "close")) && (!(IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED))) ) return door; else if ((is_abbrev(cmdname, "lock")) && (!(IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED))) ) return door; else if ((is_abbrev(cmdname, "unlock")) && (IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED)) ) return door; else if ((is_abbrev(cmdname, "pick")) && (IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED)) ) return door; } } } } if ((!IS_NPC(ch)) && (!PRF_FLAGGED(ch, PRF_AUTODOOR))) send_to_char(ch, "There doesn't seem to be %s %s here.\r\n", AN(type), type); else if (is_abbrev(cmdname, "open")) send_to_char(ch, "There doesn't seem to be %s %s that can be opened.\r\n", AN(type), type); else if (is_abbrev(cmdname, "close")) send_to_char(ch, "There doesn't seem to be %s %s that can be closed.\r\n", AN(type), type); else if (is_abbrev(cmdname, "lock")) send_to_char(ch, "There doesn't seem to be %s %s that can be locked.\r\n", AN(type), type); else if (is_abbrev(cmdname, "unlock")) send_to_char(ch, "There doesn't seem to be %s %s that can be unlocked.\r\n", AN(type), type); else send_to_char(ch, "There doesn't seem to be %s %s that can be picked.\r\n", AN(type), type); return (-1); } }
static void show_dyntext(struct creature *ch, dynamic_text_file * dyntext, char *argument) { int i; if (dyntext) { if (!*argument) { send_to_char(ch, "DYNTEXT: filename: '%s'\r\n" " last: %s (%d) @ %s\r" " level: %d\r\n" " lock: %s (%d)\r\n" " old: %-3s (Len: %zd)\r\n" " new: %-3s (Len: %zd)\r\n", dyntext->filename, player_name_by_idnum(dyntext->last_edit[0].idnum), dyntext->last_edit[0].idnum, ctime(&(dyntext->last_edit[0].tEdit)), dyntext->level, player_name_by_idnum(dyntext->lock), dyntext->lock, YESNO(dyntext->buffer), dyntext->buffer ? strlen(dyntext->buffer) : 0, YESNO(dyntext->tmp_buffer), dyntext->tmp_buffer ? strlen(dyntext->tmp_buffer) : 0); return; } // there was an argument, parse it if (is_abbrev(argument, "old")) { if (!dyntext->buffer) { send_to_char(ch, "There is no old text buffer.\r\n"); } else { page_string(ch->desc, dyntext->buffer); } } else if (is_abbrev(argument, "new")) { if (!dyntext->tmp_buffer) { send_to_char(ch, "There is no new text buffer.\r\n"); } else { page_string(ch->desc, dyntext->tmp_buffer); } } else if (is_abbrev(argument, "perms")) { send_to_char(ch, "Permissions defined:\r\n"); for (i = 0; i < DYN_TEXT_PERM_SIZE; i++) { send_to_char(ch, "%3d.] (%5d) %s\r\n", i, dyntext->perms[i], player_name_by_idnum(dyntext->perms[i])); } } else if (is_abbrev(argument, "last")) { send_to_char(ch, "Last edits:\r\n"); for (i = 0; i < DYN_TEXT_HIST_SIZE; i++) { send_to_char(ch, "%3d.] (%5d) %30s @ %s\r", i, dyntext->last_edit[i].idnum, player_name_by_idnum(dyntext->last_edit[i].idnum), ctime(&(dyntext->last_edit[i].tEdit))); } } else { send_to_char(ch, "Unknown argument for show.\r\n"); show_dynedit_options(ch); } return; } send_to_char(ch, "DYNTEXT LIST:\r\n"); for (dyntext = dyntext_list; dyntext; dyntext = dyntext->next) send_to_char(ch, "%s\r\n", dyntext->filename); }
int parse_player_class(char *arg) { skip_spaces(&arg); if (is_abbrev(arg, "magic user") || is_abbrev(arg, "mage")) return CLASS_MAGIC_USER; else if (is_abbrev(arg, "cleric")) return CLASS_CLERIC; else if (is_abbrev(arg, "barbarian")) return CLASS_BARB; else if (is_abbrev(arg, "thief")) return CLASS_THIEF; else if (is_abbrev(arg, "knight")) return CLASS_KNIGHT; else if (is_abbrev(arg, "ranger")) return CLASS_RANGER; else if (is_abbrev(arg, "monk")) return CLASS_MONK; else if (is_abbrev(arg, "cyborg") || is_abbrev(arg, "borg")) return CLASS_CYBORG; else if (is_abbrev(arg, "psionic") || is_abbrev(arg, "psychic")) return CLASS_PSIONIC; else if (is_abbrev(arg, "physic") || is_abbrev(arg, "physicist")) return CLASS_PHYSIC; else if (is_abbrev(arg, "monk")) return CLASS_MONK; else if (is_abbrev(arg, "mercenary")) return CLASS_MERCENARY; else if (is_abbrev(arg, "bard")) return CLASS_BARD; return CLASS_UNDEFINED; }