Skip to content

Commit

Permalink
Add possibility of translating Fixt strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Edw590 committed May 16, 2024
1 parent b070b06 commit 3ce4904
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
27 changes: 23 additions & 4 deletions F1DPPatcher/FixtPatches/FixtPatches.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,38 @@
// specific language governing permissions and limitations
// under the License.

#include "../CLibs/stdlib.h"
#include "../CLibs/string.h"
#include "../Utils/EXEPatchUtils.h"
#include "FixtPatches.h"
#include "../Utils/IniUtils.h"
#include "../Utils/GlobalVars.h"

void initFixtPatches(void) {
char prop_value[MAX_PROP_VALUE_LEN];
struct FileInfo translation_ini_info_G;
memset(prop_value, 0, MAX_PROP_VALUE_LEN);
memset(&translation_ini_info_G, 0, sizeof(struct FileInfo));

getPropValueIni(MAIN_INI_SPEC_SEC_FIXT, "Main", "TranslationsINI", "TRANSLAT.INI", prop_value, &f1dpatch_ini_info_G);
// If it fails, the struct will have 0s and the file won't be read, so the default values will be used as Fixt does.
readFile(prop_value, &translation_ini_info_G);

char string1[100];
char string2[50];
char string3[50];

getPropValueIni(NULL, "Fixt", "String1", "not played because being", string1, &translation_ini_info_G);
getPropValueIni(NULL, "Fixt", "String2", "NOT", string2, &translation_ini_info_G);
getPropValueIni(NULL, "Fixt", "String3", "IS", string3, &translation_ini_info_G);

// strnpy() is being used instead of strcpy() because we don't want to copy the NULL character, so the number of
// characters to copy must be equal to the number of characters inside the quotation marks (which don't include the
// NULL one).
strncpy(getRealEXEAddr(0xF32FC), string1, strlen(string1));

strncpy(getRealEXEAddr(0xF32FC), "not played because being", 24);

strncpy(getRealEXEAddr(0xFC0CD), "NOT", 3);
strncpy(getRealEXEAddr(0xFC0F5), "IS", 2);
strncpy(getRealEXEAddr(0xFC0CD), string2, strlen(string2));
strncpy(getRealEXEAddr(0xFC0F5), string3, strlen(string3));

// No idea what this patch does
writeMem32EXE(0x22050, 0xC003C003u, true);
Expand Down
1 change: 1 addition & 0 deletions F1DPPatcher/Utils/IniUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define MAX_PROP_VALUE_LEN 900

#define MAIN_INI_SPEC_SEC_MAIN "F1DP-Main"
#define MAIN_INI_SPEC_SEC_FIXT "F1DP-Fixt"
#define MAIN_INI_SPEC_SEC_SFALL1 "F1DP-CraftySFall1"
#define MAIN_INI_SPEC_SEC_HIGHRES_PATCH "F1DP-HighResPatch"

Expand Down

0 comments on commit 3ce4904

Please sign in to comment.