PPGe: Remove ENTR hack, fix string concat.

Sanitize first, then concatenate.  This replicates the firmware behavior
nicely.
This commit is contained in:
Unknown W. Brackets 2021-03-29 00:21:26 -07:00
parent 5ef8762c32
commit fe83f21df5
2 changed files with 4 additions and 10 deletions

View file

@ -26,6 +26,7 @@
#include <thread>
#include "Common/Data/Text/I18n.h"
#include "Common/Data/Encoding/Utf8.h"
#include "Common/Thread/ThreadUtil.h"
#include "Common/File/FileUtil.h"
@ -541,7 +542,8 @@ void PSPSaveDialog::DisplaySaveDataInfo2(bool showNewData) {
s64 sizeK = data_size / 1024;
PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_LEFT, 0.5f);
std::string saveinfoTxt = StringFromFormat("%.128s\n%s %s\n%lld KB", save_title, date_year, hour_time, sizeK);
std::string title = SanitizeUTF8(std::string(save_title, strnlen(save_title, 128)));
std::string saveinfoTxt = StringFromFormat("%s\n%s %s\n%lld KB", title.c_str(), date_year, hour_time, sizeK);
PPGeDrawText(saveinfoTxt.c_str(), 8, 200, textStyle);
}

View file

@ -955,15 +955,7 @@ static void PPGeDecimateTextImages(int age) {
}
static std::string PPGeSanitizeText(const std::string &text) {
// Seen in Ratchet & Clank - Secret Agent. To match the output of the real thing, we have to remove
// both the overlong encoding and "ENTR", whatever that is. If we just let SanitizeUTF8 remove
// the overlong null, the rest of the string is missing in the bottom left corner (save size, etc).
// It doesn't seem to be using sceCcc.
// Note how the double "" is required in the middle of the string to end the \x80 constant (otherwise it takes E).
// This behavior doesn't replicate within other games, so it may be a game bug workaround.
std::string str = ReplaceAll(text, "\xC0\x80""ENTR", "");
// Then SanitizeUTF8 is needed to get rid of various other overlong encodings.
return SanitizeUTF8(str);
return SanitizeUTF8(text);
}
void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style) {