mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-20 13:33:02 +01:00
Remove and cleanup RCT2 string code
This commit is contained in:
@@ -40,7 +40,6 @@
|
||||
#include "object/Object.h"
|
||||
#include "object/ObjectList.h"
|
||||
#include "platform/Platform2.h"
|
||||
#include "rct1/RCT1.h"
|
||||
#include "ride/Ride.h"
|
||||
#include "ride/RideRatings.h"
|
||||
#include "ride/Station.h"
|
||||
@@ -326,42 +325,6 @@ static void load_landscape()
|
||||
context_open_intent(&intent);
|
||||
}
|
||||
|
||||
void utf8_to_rct2_self(char* buffer, size_t length)
|
||||
{
|
||||
auto temp = utf8_to_rct2(buffer);
|
||||
|
||||
size_t i = 0;
|
||||
const char* src = temp.data();
|
||||
char* dst = buffer;
|
||||
while (*src != 0 && i < length - 1)
|
||||
{
|
||||
if (*src == static_cast<char>(static_cast<uint8_t>(0xFF)))
|
||||
{
|
||||
if (i < length - 3)
|
||||
{
|
||||
*dst++ = *src++;
|
||||
*dst++ = *src++;
|
||||
*dst++ = *src++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dst++ = *src++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
do
|
||||
{
|
||||
*dst++ = '\0';
|
||||
i++;
|
||||
} while (i < length);
|
||||
}
|
||||
|
||||
void rct2_to_utf8_self(char* buffer, size_t length)
|
||||
{
|
||||
if (length > 0)
|
||||
@@ -371,37 +334,6 @@ void rct2_to_utf8_self(char* buffer, size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all the user strings and news item strings to UTF-8.
|
||||
*/
|
||||
void game_convert_strings_to_utf8()
|
||||
{
|
||||
// Scenario details
|
||||
gScenarioCompletedBy = rct2_to_utf8(gScenarioCompletedBy, RCT2LanguageId::EnglishUK);
|
||||
gScenarioName = rct2_to_utf8(gScenarioName, RCT2LanguageId::EnglishUK);
|
||||
gScenarioDetails = rct2_to_utf8(gScenarioDetails, RCT2LanguageId::EnglishUK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all the user strings and news item strings to RCT2 encoding.
|
||||
*/
|
||||
void game_convert_strings_to_rct2(RCT2::S6Data* s6)
|
||||
{
|
||||
// Scenario details
|
||||
utf8_to_rct2_self(s6->scenario_completed_name, sizeof(s6->scenario_completed_name));
|
||||
utf8_to_rct2_self(s6->scenario_name, sizeof(s6->scenario_name));
|
||||
utf8_to_rct2_self(s6->scenario_description, sizeof(s6->scenario_description));
|
||||
|
||||
// User strings
|
||||
for (auto* userString : s6->custom_strings)
|
||||
{
|
||||
if (!str_is_null_or_empty(userString))
|
||||
{
|
||||
utf8_to_rct2_self(userString, RCT12::Limits::MaxUserStringLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OpenRCT2 workaround to recalculate some values which are saved redundantly in the save to fix corrupted files.
|
||||
// For example recalculate guest count by looking at all the guests instead of trusting the value in the file.
|
||||
void game_fix_save_vars()
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
#include <string>
|
||||
|
||||
struct ParkLoadResult;
|
||||
namespace RCT2
|
||||
{
|
||||
struct S6Data;
|
||||
}
|
||||
|
||||
enum class GameCommand : int32_t
|
||||
{
|
||||
@@ -172,9 +168,6 @@ void save_game_as();
|
||||
void save_game_cmd(const utf8* name = nullptr);
|
||||
void save_game_with_name(const utf8* name);
|
||||
void game_autosave();
|
||||
void game_convert_strings_to_utf8();
|
||||
void game_convert_strings_to_rct2(RCT2::S6Data* s6);
|
||||
void utf8_to_rct2_self(char* buffer, size_t length);
|
||||
void rct2_to_utf8_self(char* buffer, size_t length);
|
||||
void game_fix_save_vars();
|
||||
void start_silent_record();
|
||||
|
||||
@@ -477,7 +477,7 @@ namespace RCT2
|
||||
|
||||
// Fix and set dynamic variables
|
||||
map_strip_ghost_flag_from_elements();
|
||||
game_convert_strings_to_utf8();
|
||||
ConvertScenarioStringsToUTF8();
|
||||
map_count_remaining_land_rights();
|
||||
determine_ride_entrance_and_exit_locations();
|
||||
|
||||
@@ -492,6 +492,14 @@ namespace RCT2
|
||||
ClearRestrictedScenery();
|
||||
}
|
||||
|
||||
void ConvertScenarioStringsToUTF8()
|
||||
{
|
||||
// Scenario details
|
||||
gScenarioCompletedBy = rct2_to_utf8(gScenarioCompletedBy, RCT2LanguageId::EnglishUK);
|
||||
gScenarioName = rct2_to_utf8(gScenarioName, RCT2LanguageId::EnglishUK);
|
||||
gScenarioDetails = rct2_to_utf8(gScenarioDetails, RCT2LanguageId::EnglishUK);
|
||||
}
|
||||
|
||||
void FixLandOwnership() const
|
||||
{
|
||||
if (String::Equals(_s6.scenario_filename, "Europe - European Cultural Festival.SC6"))
|
||||
|
||||
Reference in New Issue
Block a user