Ejemplo n.º 1
0
/**
 *
 *  rct2: 0x006C421D
 */
rct_string_id user_string_allocate(int base, const utf8 *text)
{
	int highBits = (base & 0x7F) << 9;
	bool allowDuplicates = base & 0x80;

	if (!allowDuplicates && user_string_exists(text)) {
		RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CHOSEN_NAME_IN_USE_ALREADY;
		return 0;
	}

	char *userString = gUserStrings;
	for (int i = 0; i < MAX_USER_STRINGS; i++, userString += USER_STRING_MAX_LENGTH) {
		if (userString[0] != 0)
			continue;

		safe_strncpy(userString, text, USER_STRING_MAX_LENGTH - 1);
		return 0x8000 + (i | highBits);
	}
	RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_TOO_MANY_NAMES_DEFINED;
	return 0;
}
Ejemplo n.º 2
0
/**
 *
 *  rct2: 0x006C421D
 */
rct_string_id user_string_allocate(sint32 base, const utf8 *text)
{
    sint32 highBits = (base & 0x7F) << 9;
    bool allowDuplicates = base & USER_STRING_DUPLICATION_PERMITTED;

    if (!allowDuplicates && user_string_exists(text)) {
        gGameCommandErrorText = STR_CHOSEN_NAME_IN_USE_ALREADY;
        return 0;
    }

    for (sint32 i = 0; i < MAX_USER_STRINGS; i++)
    {
        char * userString = gUserStrings[i];

        if (userString[0] != 0)
            continue;

        safe_strcpy(userString, text, USER_STRING_MAX_LENGTH);
        return USER_STRING_START + (i | highBits);
    }
    gGameCommandErrorText = STR_TOO_MANY_NAMES_DEFINED;
    return 0;
}