Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text on scrolling banners disappears after saving the game #11258

Closed
deurklink opened this issue Apr 10, 2020 · 11 comments · Fixed by #11289
Closed

Text on scrolling banners disappears after saving the game #11258

deurklink opened this issue Apr 10, 2020 · 11 comments · Fixed by #11289
Labels
bug Something went wrong.

Comments

@deurklink
Copy link
Contributor

OS: Windows 10
Version: 0.2.5 - was already present in 0.2.4
Commit/Build: fdf9806

image

After saving, the banners in my megapark all lose their text. I also had this problem a few times but with the banners only keeping the first word or first character. I also saw this happen in some other parks.

  1. Open attached save file
  2. Change the banner text into something
  3. Save the game
  4. Reload, and watch the text on the banner disappear

Save game:

Deurklink MegaPark.zip

@deurklink
Copy link
Contributor Author

When i remove the banner and replace it with a new one, the problem is gone for the new banner. But I think at some point, the value for the banner gets overwritten somewhere and then the problem persists until I replace the banner again.

@AaronVanGeffen
Copy link
Member

AaronVanGeffen commented Apr 10, 2020

Had a quick look — here are only 84 banners in the park (out of 250), so it's not like the limit is being hit there. Interestingly, once the autosave kicks in, a lot of console messages appear:

WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string 'La' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string '' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string 'M' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string 'P' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string 'Disk-o' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string 'Jelly-Go' is too long for the S6 file format and has therefore been truncated.
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1629 (GetTruncatedRCT2String)]: The user string 'Canoe Rent' is too long for the S6 file format and has therefore been truncated.

So it looks like something may have corrupted the user string table.

@deurklink
Copy link
Contributor Author

I got rid of this problem by removing all the banners and replacing them with new ones. But then after a few days the problem came back. I don't know what causes it.

@janisozaur
Copy link
Member

Oh cool, it is not something odd with my own setup. I noticed this with recent replay parks as well. Sometimes the banner scrolled and other times it did not. A banner above the park entrance stopped scrolling in the main viewport, but was scrolling properly in the small one with park/ride details.

@duncanspumpkin duncanspumpkin added the bug Something went wrong. label Apr 11, 2020
@janisozaur
Copy link
Member

Regression from f539fdd

@janisozaur
Copy link
Member

static std::string GetTruncatedRCT2String(const std::string_view& src)
{
auto rct2encoded = utf8_to_rct2(src);
if (rct2encoded.size() > RCT12_USER_STRING_MAX_LENGTH - 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());

auto rct2encoded = utf8_to_rct2("dfgdfgdfg");
// rct2encoded = { 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x02ffffff96, 0x0264, 0x0266, 0x0267, 0x0264, 0x0266, 0x0267, 0x0264, 0x0266, 0x0267 };

Also it seems that parks once broken stay broken and exhibit the problem slightly different.

@Richard-L
Copy link

I can confirm the same problem on:

OpenRCT2, v0.2.5-127-g0cbd70029 (0cbd700 on develop) provided by GitHub
Windows (x86-64)

It appears the problem has to do with how many times you save? I had 5 or so banners in my park each dating from different days. The "older" banners in the park showed the problem first: the fragments are cut off from the end of the text. So for example a banner was:

"You're my end and my beginning"

And after a number of saves I noticed it had become:

"You're my end an"

Initially started editing them and filled in the desired full string again, but the truncation continued to happen. Eventually the "younger" banners showed the problem too. The only temporary fix is to replace them as Deurklink mentioned, so you'll have a couple of saves where things are fine.

@Richard-L
Copy link

Another observation as I am reporting a banner related issue:

If the default "Sign" string is not changed, even one save, close, and re-open of OpenRCT2 and the park, seems to remove the banner's content entirely.

@janisozaur
Copy link
Member

Ah, well, it only gets encoded this way because the original is also odd:

ct2encoded.size() = 38

encoded = 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0xffffff96 0x73 0x64 0x66 0x73 0x64 0x66 0x73 
src = 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0xffffffc2 0xffffff96 0x73 0x64 0x66 0x73 0x64 0x66 0x73 
WARNING[../src/openrct2/rct2/S6Exporter.cpp:1296 (GetTruncatedRCT2String)]: The user string 'sdfsdfs' is too long for the S6 file format and has therefore been truncated.
diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp
index 6b2ab8328..68be57c6e 100644
--- a/src/openrct2/rct2/S6Exporter.cpp
+++ b/src/openrct2/rct2/S6Exporter.cpp
@@ -1283,6 +1283,16 @@ static std::string GetTruncatedRCT2String(const std::string_view& src)
     auto rct2encoded = utf8_to_rct2(src);
     if (rct2encoded.size() > RCT12_USER_STRING_MAX_LENGTH - 1)
     {
+        printf("rct2encoded.size() = %zu\n", rct2encoded.size());
+        printf("\nencoded = ");
+        for (size_t i = 0; i < rct2encoded.size(); i++) {
+            printf("0x%02x ", rct2encoded[i]);
+        }
+        printf("\nsrc = ");
+        for (size_t i = 0; i < src.size(); i++) {
+            printf("0x%02x ", src[i]);
+        }
+        printf("\n");
         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(RCT12_USER_STRING_MAX_LENGTH - 1);

In previous comment (#11258 (comment)) I misplaced %: it was printf("0x02%x " instead of printf("0x%02x ", hence the odd 0x02 prefix.

@janisozaur
Copy link
Member

The odd chars are colour codes, introduced in af5daae

RCT12::RemoveFormatCodes:

std::string RCT12::RemoveFormatCodes(const std::string_view& s)
{
constexpr auto RCT12_MULTIBYTE_PREFIX = (char)(uint8_t)0xFF;
std::string result;
result.reserve(s.size());
// Append each character that is not a format code
for (size_t i = 0; i < s.size(); i++)
{
auto c = s[i];
if (c == '\0')
{
break;
}
else if (c == RCT12_MULTIBYTE_PREFIX)
{
// Multi-byte, assume not a format code
result.push_back(c);
if (i + 1 < s.size())
{
result.push_back(s[i + 1]);
}
if (i + 2 < s.size())
{
result.push_back(s[i + 2]);
}
i += 2;
}
else if (!utf8_is_format_code(c))
{
result.push_back(c);
}
}
return result;
}
introduced in that commit doesn't really remove said format codes, I haven't yet checked why.

Saving such park will prepend the user string with format code over and over again never to remove them, eventually pushing out the actual data out of the buffer. The format codes are not displayed in the console and thus such bogus messages.

@brenoguim
Copy link
Contributor

brenoguim commented Apr 13, 2020

The function is expecting RCT12 string, but using utf8_is_format_code to check for the format code. Perhaps that is the problem?

I was also playing with this issue. I changed the caller to this:

std::string GetUserString(rct_string_id stringId)
{
        const auto originalStringC = _s6.custom_strings[(stringId - USER_STRING_START) % 1024];
        std::string_view originalString(originalStringC, USER_STRING_MAX_LENGTH);

        auto asUtf8 = rct2_to_utf8(originalString, RCT2_LANGUAGE_ID_ENGLISH_UK);

        auto buf = std::make_unique<char[]>(asUtf8.size()+1);
        std::strcpy(buf.get(), asUtf8.data());

        utf8_remove_format_codes(buf.get(), /*allow color*/false);

        return buf.get();
}

seems to work, but I'm still green in the codebase. So take it with grains of salt :)

Gymnasiast added a commit that referenced this issue Apr 17, 2020
- Feature: [#10925] Show hovered values on finance charts.
- Feature: [#11013] Ctrl+C copies input dialog text to clipboard.
- Feature: [#11218] load_park command for console
- Feature: [#11272] Option for toggling notifications for 'Ride casualties' and 'Stuck or stalled vehicles'.
- Feature: [#11281] add_news_item command for console
- Feature: [#11300] Add powered launch and reverse incline launched shuttle mode to the Stand-Up Roller Coaster (for RCT1 parity).
- Fix: [#475] Water sides drawn incorrectly (original bug).
- Fix: [#6123, #7907, #9472, #11028] Cannot build some track designs with 4 stations (original bug).
- Fix: [#6238] Invalid tile elem iteration in Guest::UpdateUsingBin
- Fix: [#7094] Back wall edge texture in water missing.
- Fix: [#9719] Hacked walls in RCT1 saves are imported incorrectly.
- Fix: [#10372, #10509, #10806] Lift base sections incorrectly exporting, causing various lift related bugs.
- Fix: [#10928] File browser's date column is too narrow.
- Fix: [#10951, #11160] Attempting to place park entrances creates ghost entrances in random locations.
- Fix: [#11005] Company value overflows.
- Fix: [#11027] Third color on walls becomes black when saving.
- Fix: [#11063] Scrolling position persists when switching tabs in the scenery window.
- Fix: [#11106] Crash on getting invalid vehicle index.
- Fix: [#11126] Cannot place Frightmare track design.
- Fix: [#11208] Cannot export parks with RCT2 DLC objects.
- Fix: [#11230] Seat Rotation not imported correctly for hacked rides.
- Fix: [#11225] Replay manager cannot handle track designs.
- Fix: [#11246] Fix Various Import/Export issues with Boat locations, balloon frame number.
- Fix: [#11258] Properly remove format codes from imported strings.
- Fix: [#11286] Fix banner tooltip colour.
- Fix: Small red gardens in RCT1 saves are imported in the wrong colour.
- Improved: [#11157] Slimmer virtual floor lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something went wrong.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants