void sub_write(char *arg, char_data *ch, byte find_invis, int targets) { char str[MAX_INPUT_LENGTH * 2]; char type[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH]; char *tokens[MAX_INPUT_LENGTH], *s, *p; void *otokens[MAX_INPUT_LENGTH]; char_data *to; obj_data *obj; int i; int to_sleeping = 1, is_spammy = 0; /* mainly for windows compiles */ if (!arg) return; tokens[0] = str; for (i = 0, p = arg, s = str; *p;) { switch (*p) { case '~': case '|': case '^': // case '&': // removed this because it conflicts with color codes case '*': { /* get char_data, move to next token */ type[i] = *p; *s = '\0'; p = any_one_name(++p, name); otokens[i] = find_invis ? get_char_in_room(IN_ROOM(ch), name) : get_char_room_vis(ch, name); tokens[++i] = ++s; break; } case '@': { /* get obj_data, move to next token */ type[i] = *p; *s = '\0'; p = any_one_name(++p, name); if (find_invis) obj = get_obj_in_room(IN_ROOM(ch), name); else if (!(obj = get_obj_in_list_vis(ch, name, ROOM_CONTENTS(IN_ROOM(ch))))) { // nothing } else if (!(obj = get_obj_in_equip_vis(ch, name, ch->equipment))) { // nothing } else { obj = get_obj_in_list_vis(ch, name, ch->carrying); } otokens[i] = obj; tokens[++i] = ++s; break; } case '\\': { p++; *s++ = *p++; break; } default: { *s++ = *p++; } } } *s = '\0'; tokens[++i] = NULL; if (IS_SET(targets, TO_CHAR) && SENDOK(ch) && (AWAKE(ch) || IS_SET(targets, TO_SLEEP))) sub_write_to_char(ch, tokens, otokens, type); if (IS_SET(targets, TO_ROOM)) { for (to = ROOM_PEOPLE(IN_ROOM(ch)); to; to = to->next_in_room) { if (to != ch && SENDOK(to) && (AWAKE(to) || IS_SET(targets, TO_SLEEP))) { sub_write_to_char(to, tokens, otokens, type); } } } }
void sub_write(char *arg, char_data *ch, byte find_invis, int targets) { char str[MAX_INPUT_LENGTH * 2]; char type[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH]; char *tokens[MAX_INPUT_LENGTH], *s, *p; void *otokens[MAX_INPUT_LENGTH]; char_data *to; obj_data *obj; int i, tmp; int to_sleeping = 1; /* mainly for windows compiles */ if (!arg) return; tokens[0] = str; for (i = 0, p = arg, s = str; *p;) { switch (*p) { case '~': case '|': case '^': case '&': case '*': /* get char_data, move to next token */ type[i] = *p; *s = '\0'; p = any_one_name(++p, name); otokens[i] = find_invis ? (void *)get_char_in_room(&world[IN_ROOM(ch)], name) : (void *)get_char_room_vis(ch, name, NULL); tokens[++i] = ++s; break; case '`': /* get obj_data, move to next token */ type[i] = *p; *s = '\0'; p = any_one_name(++p, name); if (find_invis) obj = get_obj_in_room(&world[IN_ROOM(ch)], name); else if (!(obj = get_obj_in_list_vis(ch, name, NULL, world[IN_ROOM(ch)].contents))) ; else if (!(obj = get_obj_in_equip_vis(ch, name, &tmp, ch->equipment))) ; else obj = get_obj_in_list_vis(ch, name, NULL, ch->carrying); otokens[i] = (void *)obj; tokens[++i] = ++s; break; case '\\': p++; *s++ = *p++; break; default: *s++ = *p++; } } *s = '\0'; tokens[++i] = NULL; if (IS_SET(targets, TO_CHAR) && SENDOK(ch)) sub_write_to_char(ch, tokens, otokens, type); if (IS_SET(targets, TO_ROOM)) for (to = world[IN_ROOM(ch)].people; to; to = to->next_in_room) if (to != ch && SENDOK(to)) sub_write_to_char(to, tokens, otokens, type); }