Example #1
0
void format_string_part(char **dest, rct_string_id format, char **args)
{
	if (format < 0x8000) {
		// Language string
		format_string_part_from_raw(dest, get_string(format), args);
	} else if (format < 0x9000) {
		// Custom string
		format -= 0x8000;
		// args += (format & 0xC00) >> 9;
		format &= ~0xC00;
		strcpy(*dest, RCT2_ADDRESS(0x135A8F4 + (format * 32), char));
		*dest = strchr(*dest, 0) + 1;
	} else if (format < 0xE000) {
Example #2
0
void format_string_part(utf8 **dest, rct_string_id format, char **args)
{
	if (format == STR_NONE) {
		**dest = 0;
	} else if (format < 0x8000) {
		// Language string
		format_string_part_from_raw(dest, language_get_string(format), args);
	} else if (format < 0x9000) {
		// Custom string
		format -= 0x8000;

		// Bits 10, 11 represent number of bytes to pop off arguments
		*args += (format & 0xC00) >> 9;
		format &= ~0xC00;

		strcpy(*dest, RCT2_ADDRESS(0x135A8F4 + (format * 32), char));
		*dest = strchr(*dest, 0) + 1;
	} else if (format < 0xE000) {
Example #3
0
void format_string_code(unsigned char format_code, char **dest, char **args)
{
	int value;

	switch (format_code) {
	case FORMAT_COMMA32:
		// Pop argument
		value = *((sint32*)*args);
		*args += 4;

		format_comma_separated_integer(dest, value);
		break;
	case FORMAT_INT32:
		// Pop argument
		value = *((sint32*)*args);
		*args += 4;

		format_integer(dest, value);
		break;
	case FORMAT_COMMA2DP32:
		// Pop argument
		value = *((sint32*)*args);
		*args += 4;

		format_comma_separated_fixed_2dp(dest, value);
		break;
	case FORMAT_COMMA16:
		// Pop argument
		value = *((sint16*)*args);
		*args += 2;

		format_comma_separated_integer(dest, value);
		break;
	case FORMAT_UINT16:
		// Pop argument
		value = *((uint16*)*args);
		*args += 2;

		format_integer(dest, value);
		break;
	case FORMAT_CURRENCY2DP:
		// Pop argument
		value = *((sint32*)*args);
		*args += 4;

		format_currency_2dp(dest, value);
		break;
	case FORMAT_CURRENCY:
		// Pop argument
		value = *((sint32*)*args);
		*args += 4;

		format_currency(dest, value);
		break;
	case FORMAT_STRINGID:
	case FORMAT_STRINGID2:
		// Pop argument
		value = *((uint16*)*args);
		*args += 2;

		format_string_part(dest, value, args);
		(*dest)--;
		break;
	case FORMAT_STRING:
		// Pop argument
		value = *((uint32*)*args);
		*args += 4;

		strcpy(*dest, (char*)value);
		*dest += strlen(*dest);
		break;
	case FORMAT_MONTHYEAR:
		// Pop argument
		value = *((uint16*)*args);
		*args += 2;

		uint16 dateArgs[] = { date_get_month(value), date_get_year(value) + 1 };
		uint16 *dateArgs2 = dateArgs;
		char formatString[] = "?, Year ?";
		formatString[0] = FORMAT_MONTH;
		formatString[8] = FORMAT_COMMA16;
		format_string_part_from_raw(dest, formatString, (char**)&dateArgs2);
		(*dest)--;
		break;
	case FORMAT_MONTH:
		// Pop argument
		value = *((uint16*)*args);
		*args += 2;

		strcpy(*dest, get_string(STR_MONTH_MARCH + date_get_month(value)));
		*dest += strlen(*dest);
		break;
	case FORMAT_VELOCITY:
		// Pop argument
		value = *((sint16*)*args);
		*args += 2;

		if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8)) {
			format_comma_separated_integer(dest, mph_to_kmph(value));
			strcat(*dest, "kmh");
			*dest += strlen(*dest);
		} else {
			format_comma_separated_integer(dest, value);
			strcat(*dest, "mph");
			*dest += strlen(*dest);
		}
		break;
	case FORMAT_POP16:
		*args += 2;
		break;
	case FORMAT_PUSH16:
		*args -= 2;
		break;
	case FORMAT_DURATION:
		// Pop argument
		value = *((uint16*)*args);
		*args += 2;

		if (value / 60 > 0) {
			format_integer(dest, value / 60);
			strcpy(*dest, value / 60 == 1 ? "min:" : "mins:");
			*dest += strlen(*dest);
		}

		format_integer(dest, value % 60);
		strcpy(*dest, value % 60 == 1 ? "sec:" : "secs:");
		*dest += strlen(*dest);
		break;
	case FORMAT_REALTIME:
		// Pop argument
		value = *((uint16*)*args);
		*args += 2;

		if (value / 60 > 0) {
			format_integer(dest, value / 60);
			strcpy(*dest, value / 60 == 1 ? "hour:" : "hours:");
			*dest += strlen(*dest);
		}

		format_integer(dest, value % 60);
		strcpy(*dest, value % 60 == 1 ? "min:" : "mins:");
		*dest += strlen(*dest);
		break;
	case FORMAT_LENGTH:
		// Pop argument
		value = *((sint16*)*args);
		*args += 2;

		if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8)) {
			format_comma_separated_integer(dest, value);
			strcat(*dest, "m");
			*dest += strlen(*dest);
		} else {
			format_comma_separated_integer(dest, metres_to_feet(value));
			strcat(*dest, "ft");
			*dest += strlen(*dest);
		}
		break;
	case FORMAT_SPRITE:
		// Pop argument
		value = *((uint32*)*args);
		*args += 4;

		*(*dest)++ = 23;
		*((uint32*)(*dest)) = value;
		*dest += 4;
		break;
	}
}