mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-22 07:13:07 +01:00
Remove now-unused RCT2 export functions
This commit is contained in:
committed by
GitHub
parent
8d7413f934
commit
4e17bb54b4
@@ -82,36 +82,6 @@ static std::string DecodeToMultiByte(std::string_view src)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Encodes a UTF-8 string as an RCT2 string.
|
|
||||||
*/
|
|
||||||
static std::string Encode(const std::string& src)
|
|
||||||
{
|
|
||||||
std::string dst;
|
|
||||||
const utf8* ch = src.data();
|
|
||||||
int32_t codepoint;
|
|
||||||
while ((codepoint = utf8_get_next(ch, &ch)) != 0)
|
|
||||||
{
|
|
||||||
codepoint = encoding_convert_unicode_to_rct2(codepoint);
|
|
||||||
if (codepoint <= std::numeric_limits<uint8_t>::max())
|
|
||||||
{
|
|
||||||
dst.push_back(codepoint);
|
|
||||||
}
|
|
||||||
else if (codepoint <= std::numeric_limits<uint16_t>::max())
|
|
||||||
{
|
|
||||||
dst.push_back(static_cast<char>(static_cast<uint8_t>(0xFF)));
|
|
||||||
dst.push_back((codepoint >> 8) & 0xFF);
|
|
||||||
dst.push_back(codepoint & 0xFF);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// RCT2 strings do not support code points greater than 65535, replace them with '?'
|
|
||||||
dst.push_back('?');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t GetCodePageForRCT2Language(RCT2LanguageId languageId)
|
static int32_t GetCodePageForRCT2Language(RCT2LanguageId languageId)
|
||||||
{
|
{
|
||||||
switch (languageId)
|
switch (languageId)
|
||||||
@@ -153,11 +123,3 @@ std::string rct2_to_utf8(std::string_view src, RCT2LanguageId languageId)
|
|||||||
auto decoded = DecodeToMultiByte(src);
|
auto decoded = DecodeToMultiByte(src);
|
||||||
return String::Convert(decoded, codePage, CODE_PAGE::CP_UTF8);
|
return String::Convert(decoded, codePage, CODE_PAGE::CP_UTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string utf8_to_rct2(std::string_view src)
|
|
||||||
{
|
|
||||||
// NOTE: This is only used for SC6 / SV6 files which don't store the language identifier
|
|
||||||
// because of this, we can only store in RCT2's CP_1252 format. We can preserve some
|
|
||||||
// unicode characters, but only those between 256 and 65535.
|
|
||||||
return Encode(std::string(src));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ int32_t utf8_get_codepoint_length(char32_t codepoint);
|
|||||||
int32_t utf8_length(const utf8* text);
|
int32_t utf8_length(const utf8* text);
|
||||||
|
|
||||||
std::string rct2_to_utf8(std::string_view src, RCT2LanguageId languageId);
|
std::string rct2_to_utf8(std::string_view src, RCT2LanguageId languageId);
|
||||||
std::string utf8_to_rct2(std::string_view src);
|
|
||||||
bool language_get_localised_scenario_strings(const utf8* scenarioFilename, rct_string_id* outStringIds);
|
bool language_get_localised_scenario_strings(const utf8* scenarioFilename, rct_string_id* outStringIds);
|
||||||
void language_free_object_string(rct_string_id stringId);
|
void language_free_object_string(rct_string_id stringId);
|
||||||
rct_string_id language_allocate_object_string(const std::string& target);
|
rct_string_id language_allocate_object_string(const std::string& target);
|
||||||
|
|||||||
@@ -487,14 +487,6 @@ ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex i
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT12ObjectEntryIndex OpenRCT2EntryIndexToRCTEntryIndex(const ObjectEntryIndex index)
|
|
||||||
{
|
|
||||||
if (index == OBJECT_ENTRY_INDEX_NULL)
|
|
||||||
return RCT12_OBJECT_ENTRY_INDEX_NULL;
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId)
|
ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId)
|
||||||
{
|
{
|
||||||
if (rideId == RCT12_RIDE_ID_NULL)
|
if (rideId == RCT12_RIDE_ID_NULL)
|
||||||
@@ -503,14 +495,6 @@ ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId)
|
|||||||
return static_cast<ride_id_t>(rideId);
|
return static_cast<ride_id_t>(rideId);
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT12RideId OpenRCT2RideIdToRCT12RideId(const ride_id_t rideId)
|
|
||||||
{
|
|
||||||
if (rideId == RIDE_ID_NULL)
|
|
||||||
return RCT12_RIDE_ID_NULL;
|
|
||||||
|
|
||||||
return static_cast<RCT12RideId>(rideId);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool RCT12IsFormatChar(codepoint_t c)
|
static bool RCT12IsFormatChar(codepoint_t c)
|
||||||
{
|
{
|
||||||
if (c >= RCT2_STRING_FORMAT_ARG_START && c <= RCT2_STRING_FORMAT_ARG_END)
|
if (c >= RCT2_STRING_FORMAT_ARG_START && c <= RCT2_STRING_FORMAT_ARG_END)
|
||||||
@@ -623,47 +607,6 @@ static FormatToken GetFormatTokenFromRCT12Code(codepoint_t codepoint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static codepoint_t GetRCT12CodeFromFormatToken(FormatToken token)
|
|
||||||
{
|
|
||||||
switch (token)
|
|
||||||
{
|
|
||||||
case FormatToken::Newline:
|
|
||||||
return RCT12FormatCode::Newline;
|
|
||||||
case FormatToken::NewlineSmall:
|
|
||||||
return RCT12FormatCode::NewlineSmall;
|
|
||||||
case FormatToken::ColourBlack:
|
|
||||||
return RCT12FormatCode::ColourBlack;
|
|
||||||
case FormatToken::ColourGrey:
|
|
||||||
return RCT12FormatCode::ColourGrey;
|
|
||||||
case FormatToken::ColourWhite:
|
|
||||||
return RCT12FormatCode::ColourWhite;
|
|
||||||
case FormatToken::ColourRed:
|
|
||||||
return RCT12FormatCode::ColourRed;
|
|
||||||
case FormatToken::ColourGreen:
|
|
||||||
return RCT12FormatCode::ColourGreen;
|
|
||||||
case FormatToken::ColourYellow:
|
|
||||||
return RCT12FormatCode::ColourYellow;
|
|
||||||
case FormatToken::ColourTopaz:
|
|
||||||
return RCT12FormatCode::ColourTopaz;
|
|
||||||
case FormatToken::ColourCeladon:
|
|
||||||
return RCT12FormatCode::ColourCeladon;
|
|
||||||
case FormatToken::ColourBabyBlue:
|
|
||||||
return RCT12FormatCode::ColourBabyBlue;
|
|
||||||
case FormatToken::ColourPaleLavender:
|
|
||||||
return RCT12FormatCode::ColourPaleLavender;
|
|
||||||
case FormatToken::ColourPaleGold:
|
|
||||||
return RCT12FormatCode::ColourPaleGold;
|
|
||||||
case FormatToken::ColourLightPink:
|
|
||||||
return RCT12FormatCode::ColourLightPink;
|
|
||||||
case FormatToken::ColourPearlAqua:
|
|
||||||
return RCT12FormatCode::ColourPearlAqua;
|
|
||||||
case FormatToken::ColourPaleSilver:
|
|
||||||
return RCT12FormatCode::ColourPaleSilver;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ConvertFormattedStringToOpenRCT2(std::string_view buffer)
|
std::string ConvertFormattedStringToOpenRCT2(std::string_view buffer)
|
||||||
{
|
{
|
||||||
auto nullTerminator = buffer.find('\0');
|
auto nullTerminator = buffer.find('\0');
|
||||||
@@ -690,61 +633,6 @@ std::string ConvertFormattedStringToOpenRCT2(std::string_view buffer)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ConvertFormattedStringToRCT2(std::string_view buffer, size_t maxLength)
|
|
||||||
{
|
|
||||||
std::string result;
|
|
||||||
FmtString fmt(buffer);
|
|
||||||
for (const auto& token : fmt)
|
|
||||||
{
|
|
||||||
if (token.IsLiteral())
|
|
||||||
{
|
|
||||||
result += token.text;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto codepoint = GetRCT12CodeFromFormatToken(token.kind);
|
|
||||||
if (codepoint == 0)
|
|
||||||
{
|
|
||||||
result += token.text;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String::AppendCodepoint(result, codepoint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return GetTruncatedRCT2String(result, maxLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GetTruncatedRCT2String(std::string_view src, size_t maxLength)
|
|
||||||
{
|
|
||||||
auto rct2encoded = utf8_to_rct2(src);
|
|
||||||
if (rct2encoded.size() > maxLength - 1)
|
|
||||||
{
|
|
||||||
log_warning(
|
|
||||||
"The user string '%s' is too long for the S6 file format and has therefore been truncated.",
|
|
||||||
std::string(src).c_str());
|
|
||||||
|
|
||||||
rct2encoded.resize(maxLength - 1);
|
|
||||||
for (size_t i = 0; i < rct2encoded.size(); i++)
|
|
||||||
{
|
|
||||||
if (rct2encoded[i] == static_cast<char>(static_cast<uint8_t>(0xFF)))
|
|
||||||
{
|
|
||||||
if (i > maxLength - 4)
|
|
||||||
{
|
|
||||||
// This codepoint was truncated, remove codepoint altogether
|
|
||||||
rct2encoded.resize(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip the next two bytes which represent the unicode character
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rct2encoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
track_type_t RCT12FlatTrackTypeToOpenRCT2(RCT12TrackType origTrackType)
|
track_type_t RCT12FlatTrackTypeToOpenRCT2(RCT12TrackType origTrackType)
|
||||||
{
|
{
|
||||||
switch (origTrackType)
|
switch (origTrackType)
|
||||||
@@ -906,14 +794,6 @@ money64 RCT12CompletedCompanyValueToOpenRCT2(money32 origValue)
|
|||||||
return ToMoney64(origValue);
|
return ToMoney64(origValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
money32 OpenRCT2CompletedCompanyValueToRCT12(money64 origValue)
|
|
||||||
{
|
|
||||||
if (origValue == COMPANY_VALUE_ON_FAILED_OBJECTIVE)
|
|
||||||
return RCT12_COMPANY_VALUE_ON_FAILED_OBJECTIVE;
|
|
||||||
|
|
||||||
return ToMoney32(origValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResearchItem RCT12ResearchItem::ToResearchItem() const
|
ResearchItem RCT12ResearchItem::ToResearchItem() const
|
||||||
{
|
{
|
||||||
auto newResearchItem = ResearchItem();
|
auto newResearchItem = ResearchItem();
|
||||||
|
|||||||
@@ -847,14 +847,10 @@ assert_struct_size(RCT12ResearchItem, 5);
|
|||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex index);
|
ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex index);
|
||||||
RCT12ObjectEntryIndex OpenRCT2EntryIndexToRCTEntryIndex(const ObjectEntryIndex index);
|
|
||||||
ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId);
|
ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId);
|
||||||
RCT12RideId OpenRCT2RideIdToRCT12RideId(const ride_id_t rideId);
|
|
||||||
bool IsLikelyUTF8(std::string_view s);
|
bool IsLikelyUTF8(std::string_view s);
|
||||||
std::string RCT12RemoveFormattingUTF8(std::string_view s);
|
std::string RCT12RemoveFormattingUTF8(std::string_view s);
|
||||||
std::string ConvertFormattedStringToOpenRCT2(std::string_view buffer);
|
std::string ConvertFormattedStringToOpenRCT2(std::string_view buffer);
|
||||||
std::string ConvertFormattedStringToRCT2(std::string_view buffer, size_t maxLength);
|
|
||||||
std::string GetTruncatedRCT2String(std::string_view src, size_t maxLength);
|
|
||||||
track_type_t RCT12FlatTrackTypeToOpenRCT2(RCT12TrackType origTrackType);
|
track_type_t RCT12FlatTrackTypeToOpenRCT2(RCT12TrackType origTrackType);
|
||||||
RCT12TrackType OpenRCT2FlatTrackTypeToRCT12(track_type_t origTrackType);
|
RCT12TrackType OpenRCT2FlatTrackTypeToRCT12(track_type_t origTrackType);
|
||||||
std::string_view GetStationIdentifierFromStyle(uint8_t style);
|
std::string_view GetStationIdentifierFromStyle(uint8_t style);
|
||||||
@@ -865,7 +861,6 @@ void AppendRequiredObjects(ObjectList& objectList, ObjectType objectType, const
|
|||||||
static constexpr money32 RCT12_COMPANY_VALUE_ON_FAILED_OBJECTIVE = 0x80000001;
|
static constexpr money32 RCT12_COMPANY_VALUE_ON_FAILED_OBJECTIVE = 0x80000001;
|
||||||
|
|
||||||
money64 RCT12CompletedCompanyValueToOpenRCT2(money32 origValue);
|
money64 RCT12CompletedCompanyValueToOpenRCT2(money32 origValue);
|
||||||
money32 OpenRCT2CompletedCompanyValueToRCT12(money64 origValue);
|
|
||||||
|
|
||||||
template<typename T> std::vector<uint16_t> RCT12GetRideTypesBeenOn(T* srcPeep)
|
template<typename T> std::vector<uint16_t> RCT12GetRideTypesBeenOn(T* srcPeep)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,31 +61,3 @@ TEST_F(Localisation, RCT2_to_UTF8_ZH_TW_PREMATURE_END)
|
|||||||
auto actual = rct2_to_utf8(input, RCT2LanguageId::ChineseTraditional);
|
auto actual = rct2_to_utf8(input, RCT2LanguageId::ChineseTraditional);
|
||||||
ASSERT_EQ(expected, actual);
|
ASSERT_EQ(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Tests for utf8_to_rct2
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
TEST_F(Localisation, UTF8_to_RCT2_Basic)
|
|
||||||
{
|
|
||||||
auto input = u8"à l'époque était";
|
|
||||||
auto expected = StringFromHex("e0206c27e9706f71756520e974616974");
|
|
||||||
auto actual = utf8_to_rct2(input);
|
|
||||||
ASSERT_EQ(expected, actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Localisation, UTF8_to_RCT2_ChineseTraditional)
|
|
||||||
{
|
|
||||||
auto input = u8"$: 快速的棕色狐狸";
|
|
||||||
auto expected = StringFromHex("243a20ff5febff901fff7684ff68d5ff8272ff72d0ff72f8");
|
|
||||||
auto actual = utf8_to_rct2(input);
|
|
||||||
ASSERT_EQ(expected, actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(Localisation, UTF8_to_RCT2_PL)
|
|
||||||
{
|
|
||||||
auto input = u8"Górska Dołki Tęczowy";
|
|
||||||
auto expected = StringFromHex("47F372736b6120446ff76b692054e6637a6f7779");
|
|
||||||
auto actual = utf8_to_rct2(input);
|
|
||||||
ASSERT_EQ(expected, actual);
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user