示例#1
0
char *clean_word(char *word){
	char *cpy = malloc(strlen(word)+1);
	strncpy(cpy, word, strlen(word)+1);
	cpy = lowercase(cpy);
	cpy = strip_punct(cpy);
	return cpy;
}
示例#2
0
char *emote_processor( CHAR_DATA *ch, char *argument, bool fPemote, bool fSemote,
  CHAR_DATA *vch )
{
  static char buf[MAX_STRING_LENGTH];
  CHAR_DATA *wch;
  OBJ_DATA *obj;
  bool fBegin = TRUE, fPoss = FALSE;
  char word[MAX_INPUT_LENGTH];
  char *pin = argument;

  for ( pin = argument; *pin != '\0'; pin++ ) {
    if ( *pin == '@' ) {
	fBegin = FALSE;
	break;
    }
  }

  pin = argument;
  buf[0] = '\0';

  /* If no @, copy emoter's short desc. */
  if (fBegin) {
    //    if (vch == ch) {
    //      strcat(buf, (fPemote ? "your" : "you"));
    //    } else {
      strcpy(buf, person(vch, ch));
      if ( fPemote ) {
	if ( buf[strlen(buf)-1] == 's' )
	  strcat( buf, "'" );
	else
	  strcat( buf, "'s" );
	//      }
	//    }
      }  
      strcat( buf, " " );
  }

  while ( *pin != '\0' ) {
    fPoss = FALSE;
    switch( *pin ) {
    default:
      one_emote_argument( pin, word );
      strcat( buf, word );
      pin = pin + (strlen( word ) - 1);
      break;
      
    case ' ':
      strcat( buf, " " );
      break;
      
    case '@':
      if (vch == ch) {
	strcat(buf, (fPemote ? "your" : "you"));
      } else {
	strcat(buf, person(vch, ch));
	if ( fPemote )
	  strcat( buf, (buf[strlen(buf)-1] == 's') ? "'" : "'s");
      }
      break;
      
    case '%':
      fPoss = TRUE;
    case '~':
      one_emote_argument( &pin[1], word );	      
      if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) {
	if (can_see_obj(vch, obj)) {
	  strcat( buf, obj->short_descr );
	  if ( fPoss ) {
	    if ( word[strlen(word) - 1] == 's' )
	      strcat( buf, "'" );
	    else
	      strcat( buf, "'s" );
	  }
	} else
	  strcat( buf, (fPoss ? "something's" : "something"));
      } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) {
	if (fSemote) 
	  wch->leader = ch;
	if (vch == wch) {
	  strcat(buf, (fPoss ? "your" : "you"));
	} else {
	  strcat(buf, person(vch, wch));
	  if (fPoss) {
	    if ( buf[strlen(buf)-1] == 's' )
	      strcat( buf, "'" );
	    else
	      strcat( buf, "'s" );
	  }
	}
      } else {
	sprintf( buf, "%s is not here.\n\r", word );
	send_to_char( buf, ch );
	return NULL;
      }
      
      pin = pin + strlen( word );
      fPoss = FALSE;
      break;
      
      /* %m  him/her */
    case '!':
      one_emote_argument( &pin[1], word);
      if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) {
	strcat(buf, ((can_see_obj(vch, obj)) ? "it" : "something"));
      } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) {
	if (fSemote)
	  wch->leader = ch;
	strcat(buf, ((vch == wch) ? "you" : him_her[wch->sex]));
      } else {
        sprintf( buf, "%s is not here.\n\r", word );
        send_to_char( buf, ch );
        return NULL;
      }

      pin = pin + strlen( word );
      break;
	
	/* %s  his/her */
    case '^':
      one_emote_argument( &pin[1], word);
      if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) {
        strcat(buf, ((can_see_obj(vch, obj)) ? "its" : "something's"));
      } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) {
        if (fSemote)
          wch->leader = ch;
        strcat(buf, ((vch == wch) ? "your" : his_her[wch->sex]));
      } else {
        sprintf( buf, "%s is not here.\n\r", word );
        send_to_char( buf, ch );
        return NULL;
      }

      pin = pin + strlen( word );
      break;
      
      /* %s  he/she */
    case '#':
      one_emote_argument( &pin[1], word);
      if ((obj = get_obj_here(ch, strip_punct(word))) != NULL) {
        strcat(buf, ((can_see_obj(vch, obj)) ? "it" : "something"));
      } else if ((wch = get_char_room(ch, strip_punct(word))) != NULL) {
        if (fSemote)
          wch->leader = ch;
        strcat(buf, ((vch == wch) ? "you" : he_she[wch->sex]));
      } else {
        sprintf( buf, "%s is not here.\n\r", word );
        send_to_char( buf, ch );
        return NULL;
      }
      
      pin = pin + strlen( word );
      break;
    }
    
    pin++;
  }

  strcat( strip_punct(buf), ".\n\r" );
  buf[0] = UPPER( buf[0] );
  return buf;
}