void do_remove(struct char_data *ch, char *argument, int cmd) { char arg1[MAX_STRING_LENGTH]; char buffer[MAX_STRING_LENGTH]; char buffer1[MAX_STRING_LENGTH]; struct obj_data *obj_object; struct char_data *tmp_char; int i, j; one_argument(argument, arg1); if (*arg1) { obj_object = get_object_in_equip_vis(ch, arg1, ch->equipment, &j); if (obj_object) { if (CAN_CARRY_N(ch) != IS_CARRYING_N(ch)) { obj_to_char(unequip_char(ch, j), ch); if (obj_object->obj_flags.type_flag == ITEM_LIGHT) if (obj_object->obj_flags.value[2]) world[ch->in_room].light--; act("You stop using $p.",FALSE,ch,obj_object,0,TO_CHAR); act("$n stops using $p.",TRUE,ch,obj_object,0,TO_ROOM); } else { send_to_char("You can't carry that many items.\n\r", ch); } } else { send_to_char("You are not using it.\n\r", ch); } } else { send_to_char("Remove what?\n\r", ch); } }
int generic_find(char *arg, int bitvector, struct char_data * ch, struct char_data ** tar_ch, struct obj_data ** tar_obj) { int o; //int i, found; char name[256]; *tar_ch = NULL; *tar_obj = NULL; one_argument(arg, name); if (!*name) return (0); if (IS_SET(bitvector, FIND_CHAR_ROOM)) { /* Find person in room */ if ((*tar_ch = get_char_vis(ch, name, FIND_CHAR_ROOM))) { return (FIND_CHAR_ROOM); } } if (IS_SET(bitvector, FIND_CHAR_WORLD)) { if ((*tar_ch = get_char_vis(ch, name, FIND_CHAR_WORLD))) { return (FIND_CHAR_WORLD); } } if (IS_SET(bitvector, FIND_OBJ_EQUIP)) { if ((*tar_obj = get_object_in_equip_vis(ch, name, ch->equipment, &o))) { return (FIND_OBJ_INV); } } if (IS_SET(bitvector, FIND_OBJ_INV)) { if ((*tar_obj = get_obj_in_list_vis(ch, name, ch->carrying))) { return (FIND_OBJ_INV); } } if (IS_SET(bitvector, FIND_OBJ_ROOM)) { if ((*tar_obj = get_obj_in_list_vis(ch, name, world[ch->in_room].contents))) { return (FIND_OBJ_ROOM); } } if (IS_SET(bitvector, FIND_OBJ_WORLD)) { if ((*tar_obj = get_obj_vis(ch, name))) { return (FIND_OBJ_WORLD); } } return (0); }
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 sleep = 1, deaf = 0; 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); // See comment below. //(char_data *)otokens[i] = find_invis ? get_char(name) : get_char_vis(ch, name, FIND_CHAR_ROOM); // I'm not sure why "otokens[i]" was cast to a char_data type. // Doing so caused GCC to complain, so I removed it. // Bran - '11 otokens[i] = find_invis ? get_char(name) : get_char_vis(ch, name, FIND_CHAR_ROOM); tokens[++i] = ++s; break; case '`': /* get obj_data, move to next token */ type[i] = *p; *s = '\0'; p = any_one_name(++p, name); //(obj_data *)otokens[i] = find_invis ? (obj = get_obj(name)) : otokens[i] = find_invis ? (obj = get_obj(name)) : ((obj = get_obj_in_list_vis(ch, name, world[IN_ROOM(ch)].contents)) ? obj : (obj = get_object_in_equip_vis(ch, name, ch->equipment, &tmp)) ? obj : (obj = get_obj_in_list_vis(ch, name, ch->carrying))); //if (find_invis) obj = get_obj_in_room(&world[IN_ROOM(ch)], name); //else if (!(obj = get_obj_in_list_vis(ch, name, world[IN_ROOM(ch)].contents))) ; //else if (!(obj = get_object_in_equip_vis(ch, name, &tmp, ch->equipment))); //else obj = get_obj_in_list_vis(ch, name, ch->carrying); //(obj_data *)otokens[i] = obj; // Once again I'm not sure why this was cast. // See comment above. 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)) sub_write_to_char(ch, tokens, otokens, type); if (IS_SET(targets, TO_ROOM)) for (to = world[ch->in_room].people; to; to = to->next_in_room) if (to != ch && SENDOK(to)) 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); /* 20-10-15 changed the following line due to compiler error (char_data *)otokens[i] = */ otokens[i] = find_invis ? get_char(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); /* 20-10-2015 updated following line due to compiler errors (obj_data *)otokens[i] = */ otokens[i] = (void*) find_invis ? (obj = get_obj(name)) : ((obj = get_obj_in_list_vis(ch, name, world[IN_ROOM(ch)].contents)) ? obj : (obj = get_object_in_equip_vis(ch, name, ch->equipment, &tmp)) ? obj : (obj = get_obj_in_list_vis(ch, name, ch->carrying))); /* 20-10-15 Updated the following line due to comp error (obj_data *)otokens[i] = obj; */ 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); }