[Patches] Custom patches: terminate string with '\0', new line with '\n'

This commit is contained in:
nastys
2020-05-28 23:12:02 +02:00
parent 5a7a69536a
commit 7225ccb589
2 changed files with 18 additions and 4 deletions
@@ -4,7 +4,7 @@ IGNORE
@1403BABEA:75 // ...enable it.
# Custom FREE PLAY text
1409F61F0:!My text
1409F61F0:!Miku\0
// Syntax:
// "#" console comment
@@ -12,5 +12,5 @@ IGNORE
// "@" omit patch console output
// ":" address:bytes (hex)
// " " byte byte
// ":!" address:!string
// ":!" address:!string ('\0' terminates the string, '\n' new line; both require PD Loader 2.1+)
// "IGNORE" skip patch file
+16 -2
View File
@@ -784,7 +784,7 @@ void ApplyPatches() {
for (std::filesystem::path p : std::filesystem::directory_iterator("../patches"))
{
std::string extension = std::filesystem::path(p).extension().string();
if ((extension == ".p" + std::to_string(game_version) || extension == ".P" + std::to_string(game_version))||(game_version == 710&&(extension == ".p" || extension == ".P")))
if (extension == ".p" || extension == ".P" || extension == ".p2" || extension == ".P2")
{
std::cout << "[Patches] Reading custom patch file: " << std::filesystem::path(p).filename().string() << std::endl;
ApplyCustomPatches(std::filesystem::path(p).wstring());
@@ -857,8 +857,22 @@ void ApplyCustomPatches(std::wstring CPATCH_FILE_STRING)
std::vector<std::string> fullColonSplit = SplitString(line, ":");
for (int i = 1; i < fullColonSplit[1].size(); i++)
{
if (echo) std::cout << fullColonSplit[1].at(i);
unsigned char byte_u = fullColonSplit[1].at(i);
if(byte_u=='\\' && i<fullColonSplit[1].size())
{
switch (fullColonSplit[1].at(i + 1))
{
case '0':
byte_u = '\0';
i++;
break;
case 'n':
byte_u = '\n';
i++;
break;
}
}
if (echo) std::cout << byte_u;
std::vector<uint8_t> patch = { byte_u };
InjectCode((void*)address, patch);
address++;