コード例 #1
0
ファイル: dg_comm.c プロジェクト: Calebros/aol
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);
}
コード例 #2
0
ファイル: dg_comm.c プロジェクト: matthewbode/mg2
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);
}
コード例 #3
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;
	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);
			}
		}
	}
}
コード例 #4
0
ファイル: dg_comm.c プロジェクト: DavidCRouse/tbamud
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);
}