Example #1
0
int			write_nbr(t_format format, long long nbr)
{
	char	*word;
	int		width;
	int		b;

	width = 0;
	b = 0;
	word = fill_word(format.type, nbr);
	b = no_print(format, word);
	if (format.type == 'p')
		word = p_precision(format, word, &width, &b);
	else
		word = add_precision(format, word, &width);
	width = 0;
	word = add_prenbr(format, word);
	if (format.flags != '-')
		word = add_width(format, (wchar_t *)word, &width);
	b == 0 ? ft_putstr(word) : 0;
	format.flags == '-' ? add_width(format, (wchar_t *)word, &width) : 0;
	b == 0 ? (width = width + ft_strlen(word)) : 0;
	if (b == 1 && width == 0)
		width = -1;
	word == NULL ? width = 0 : 0;
	word != NULL ? free(word) : 0;
	return (width);
}
Example #2
0
void
shuffle_word(char *word, int word_len)
{
    //char shuffle_buf[MAX_LENGTH]; //max word length, its defined in game_anagram.c file as 40, hard coding here
    char shuffle_buf[40];
    strcpy(shuffle_buf, word);
    int count = 0; //for the filled positions in the shuffle_buf    
    int shuffle_pos;
    fill_word(shuffle_buf, '.', word_len); //defined in game_anagram.c

    while(count <= word_len)
    {
        shuffle_pos = rand() % word_len;
        if(shuffle_buf[shuffle_pos] == '.')
        {
            shuffle_buf[shuffle_pos] = word[count];
            count++;
            if(count == word_len)
                break;
        }

    }
    strcpy(word, shuffle_buf);
    //printf("word is : %s\n", word);
    //printf("Shuffled word is : %s\n", shuffle_buf);
}
Example #3
0
void
argument_interpreter (char *argument, char *first_arg, char *second_arg)
{
	int look_at, found, begin;

	found = begin = 0;

	do
	{
		/* Find first non blank */
		for (; *(argument + begin) == ' '; begin++);

		/* Find length of first word */
		for (look_at = 0; *(argument + begin + look_at) > ' '; look_at++)

			/* Make all letters lower case,
			AND copy them to first_arg */
			*(first_arg + look_at) = tolower (*(argument + begin + look_at));

		*(first_arg + look_at) = '\0';
		begin += look_at;

	}
	while (fill_word (first_arg));

	do
	{
		/* Find first non blank */
		for (; *(argument + begin) == ' '; begin++);

		/* Find length of first word */
		for (look_at = 0; *(argument + begin + look_at) > ' '; look_at++)

			/* Make all letters lower case,
			AND copy them to second_arg */
			*(second_arg + look_at) = tolower (*(argument + begin + look_at));

		*(second_arg + look_at) = '\0';
		begin += look_at;

	}
	while (fill_word (second_arg));
}
Example #4
0
	/* this parses dimd 'packet' commands */
char *one_lc_dimd_argument(char *argument, char *first_arg)
{
  char *scan;
  
  do {
    while(isspace(*argument)) argument++;
    
    scan = first_arg;
    while(*argument && *argument != '^')
      *scan++ = LOWER(*argument), argument++;
    
    *scan = 0;
  }
  while (fill_word(first_arg));
  
  if (*argument=='^')
    argument++; 
  
  return(argument);
}
/**
* Checks for common mob problems and reports them to ch.
*
* @param char_data *mob The mob to audit.
* @param char_data *ch The person to report to.
* @return bool TRUE if any problems were reported; FALSE if all good.
*/
bool audit_mobile(char_data *mob, char_data *ch) {
	extern adv_data *get_adventure_for_vnum(rmt_vnum vnum);
	
	bool is_adventure = (get_adventure_for_vnum(GET_MOB_VNUM(mob)) != NULL);
	char temp[MAX_STRING_LENGTH], *ptr;
	bool problem = FALSE;

	if (!str_cmp(GET_PC_NAME(mob), "mobile new")) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Keywords not set");
		problem = TRUE;
	}
	
	ptr = GET_PC_NAME(mob);
	do {
		ptr = any_one_arg(ptr, temp);
		if (*temp && !str_str(GET_SHORT_DESC(mob), temp) && !str_str(GET_LONG_DESC(mob), temp)) {
			olc_audit_msg(ch, GET_MOB_VNUM(mob), "Keyword '%s' not found in strings", temp);
			problem = TRUE;
		}
	} while (*ptr);
	
	if (!str_cmp(GET_SHORT_DESC(mob), "a new mobile")) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Short desc not set");
		problem = TRUE;
	}
	any_one_arg(GET_SHORT_DESC(mob), temp);
	if ((fill_word(temp) || reserved_word(temp)) && isupper(*temp)) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Short desc capitalized");
		problem = TRUE;
	}
	if (ispunct(GET_SHORT_DESC(mob)[strlen(GET_SHORT_DESC(mob)) - 1])) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Short desc has punctuation");
		problem = TRUE;
	}
	
	ptr = GET_SHORT_DESC(mob);
	do {
		ptr = any_one_arg(ptr, temp);
		// remove trailing punctuation
		while (*temp && ispunct(temp[strlen(temp)-1])) {
			temp[strlen(temp)-1] = '\0';
		}
		if (*temp && !fill_word(temp) && !reserved_word(temp) && !isname(temp, GET_PC_NAME(mob))) {
			olc_audit_msg(ch, GET_MOB_VNUM(mob), "Suggested missing keyword '%s'", temp);
			problem = TRUE;
		}
	} while (*ptr);
	
	if (!str_cmp(GET_LONG_DESC(mob), "A new mobile is standing here.\r\n")) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Long desc not set");
		problem = TRUE;
	}
	if (!ispunct(GET_LONG_DESC(mob)[strlen(GET_LONG_DESC(mob)) - 3])) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Long desc missing punctuation");
		problem = TRUE;
	}
	if (islower(*GET_LONG_DESC(mob))) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Long desc not capitalized");
		problem = TRUE;
	}
	if (!is_adventure && GET_MAX_SCALE_LEVEL(mob) == 0) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "No maximum scale level on non-adventure mob");
		problem = TRUE;
	}
	if (MOB_ATTACK_TYPE(mob) == TYPE_RESERVED) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Invalid attack type");
		problem = TRUE;
	}
	if (MOB_FLAGGED(mob, MOB_ANIMAL) && !has_interaction(mob->interactions, INTERACT_SKIN)) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Animal has no skin");
		problem = TRUE;
	}
	if (MOB_FLAGGED(mob, MOB_ANIMAL) && !has_interaction(mob->interactions, INTERACT_BUTCHER)) {
		olc_audit_msg(ch, GET_MOB_VNUM(mob), "Animal can't be butchered");
		problem = TRUE;
	}
	
	return problem;
}