huntd/message.c
/*
 * Handle mangling of old messages when new identical ones come along.
 */
Handle mangling of old messages when new identical ones come along.
Handle mangling of old messages when new identical ones come along .
static int
repeat_mangle(PLAYER *pp, char *copy, char *prev)
{
	int	len = strlen(copy);
	int	prev_len = strlen(prev);
	char	*new;
	if (prev_len == len) {
		new = realloc(prev, (len + 5 + 1) * sizeof(char));
		if (!new) {
			logit(LOG_ERR, "realloc");
			return TRUE;
		}
		prev = pp->p_message_buf[pp->p_message_buf_num - 1] = new;
		prev[len+0] = ' ';
		prev[len+1] = '[';
		prev[len+2] = 'x';
		prev[len+3] = '2';
		prev[len+4] = ']';
		prev[len+5] = '\0';
		return TRUE;
	}
	else {
		int	rep;
		if (sscanf(prev+len, " [x%d]", &rep) == 1) {
			rep++;
			if (3 <= rep <= 9)
				*(prev+len+3) = '0' + rep;
			else
				*(prev+len+3) = '*';
			return TRUE;
		}
	}
	return FALSE;
}
static int repeat_mangle ( PLAYER * pp , char * copy , char * prev ) { int len = strlen ( copy ) ; int prev_len = strlen ( prev ) ; char * new ; if ( prev_len == len ) { new = realloc ( prev , ( len + 5 + 1 ) * sizeof ( char ) ) ; if ( ! new ) { logit ( LOG_ERR , " " ) ; return TRUE ; } prev = pp -> p_message_buf [ pp -> p_message_buf_num - 1 ] = new ; prev [ len + 0 ] = ' ' ; prev [ len + 1 ] = ' ' ; prev [ len + 2 ] = ' ' ; prev [ len + 3 ] = ' ' ; prev [ len + 4 ] = ' ' ; prev [ len + 5 ] = ' \0 ' ; return TRUE ; } else { int rep ; if ( sscanf ( prev + len , " " , & rep ) == 1 ) { rep ++ ; if ( 3 <= rep <= 9 ) * ( prev + len + 3 ) = ' ' + rep ; else * ( prev + len + 3 ) = ' ' ; return TRUE ; } } return FALSE ; }
Handle mangling of old messages when new identical ones come along.
Handle mangling of old messages when new identical ones come along .
/* Is identical to previous. Add ' [x2]' to the end and we're
		 * done */ /* increment the count */ /* one digit max */