3
0
mirror of https://github.com/CrazyRedMachine/popnhax.git synced 2024-12-17 23:55:51 +01:00

--no-omni, cleanup

This commit is contained in:
CrazyRedMachine 2023-07-10 21:35:09 +02:00
parent 2127e8c928
commit 5ede5a3692
6 changed files with 100 additions and 120 deletions

View File

@ -79,9 +79,9 @@
<disable_redirection __type="bool">0</disable_redirection>
<!-- Translation -->
<!-- Disable string replacements from .dict file -->
<!-- Disable .dict string replacements and .ips patches -->
<disable_translation __type="bool">0</disable_translation>
<!-- Dump applied translations in dict_applied.txt (requires translation) -->
<dump_dict __type="bool">0</dump_dict>
<!-- Dump applied translations and dll runtime data to help debug translation -->
<translation_debug __type="bool">0</translation_debug>
</popnhax>

View File

@ -111,7 +111,8 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, audio_source_f
"/popnhax/audio_source_fix")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, unset_volume,
"/popnhax/unset_volume")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, event_mode, "/popnhax/event_mode")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, event_mode,
"/popnhax/event_mode")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, remove_timer,
"/popnhax/remove_timer")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, freeze_timer,
@ -2911,16 +2912,13 @@ static bool patch_practice_mode()
return true;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH: {
g_log_fp = fopen("popnhax.log", "w");
if (g_log_fp == NULL)
{
g_log_fp = stderr;
LOG("cannot open popnhax.log for write, output to stderr\n");
LOG("cannot open popnhax.log for write, output to stderr only\n");
}
LOG("popnhax: Initializing\n");
if (MH_Initialize() != MH_OK) {
@ -2930,6 +2928,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
bool force_trans_debug = false;
bool force_no_omni = false;
LPWSTR *szArglist;
int nArgs;
@ -2960,6 +2959,11 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
LOG("--translation-debug: turning on translation-related dumps\n");
force_trans_debug = true;
}
else if ( wcscmp(szArglist[i], L"--no-omni") == 0 )
{
LOG("--no-omni: force disable patch_db\n");
force_no_omni = true;
}
}
LocalFree(szArglist);
@ -2986,13 +2990,16 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
if (force_trans_debug)
config.translation_debug = true;
if (force_no_omni)
config.patch_db = false;
if (!config.disable_multiboot)
{
/* automatically force datecode based on dll name when applicable (e.g. popn22_2022061300.dll and no force_datecode) */
if ( (strlen(g_game_dll_fn) == 21)
&& (config.force_datecode[0] == '\0') )
{
LOG("popnhax: multiboot autotune activated (custom game dll, default xml, force_datecode off)\n");
LOG("popnhax: multiboot autotune activated (custom game dll, force_datecode off)\n");
memcpy(config.force_datecode, g_game_dll_fn+7, 10);
LOG("popnhax: multiboot: auto set datecode to %s\n", config.force_datecode);
if (config.force_unlock_deco && ( strcmp(config.force_datecode, "2022061300") > 0) )

View File

@ -81,23 +81,6 @@ bool patch_sjis(const char *dllFilename, const char *find, uint8_t find_size, in
return true;
}
FILE* _translation_open_dict(char *foldername, bool *ips)
{
*ips = true;
char dict_filepath[64];
sprintf(dict_filepath, "%s%s%s", "data_mods\\", foldername, "\\popn22.ips");
FILE *file = fopen(dict_filepath, "rb");
if (file != NULL)
{
return file;
}
*ips = false;
sprintf(dict_filepath, "%s%s%s", "data_mods\\", foldername, "\\popn22.dict");
file = fopen(dict_filepath, "rb");
return file;
}
#define RELOC_HIGHLOW 0x3
static void perform_reloc(char *data, int32_t delta, uint32_t ext_base, uint32_t ext_delta)
{
@ -450,11 +433,6 @@ static bool patch_translation_dict(const char *dllFilename, const char *folderna
#undef STATE_TRANSLATION
}
/*
*/
bool patch_translate(const char *dllFilename, const char *folder, bool debug)
{
bool ips_done = false;

View File

@ -3,8 +3,6 @@
#include <stdint.h>
FILE* _translation_open_dict(char *foldername, bool *ips);
bool patch_translate(const char *dllFilename, const char *folder, bool debug);
#endif

View File

@ -9,7 +9,7 @@
extern FILE *g_log_fp;
#define LOG(...) do { \
if (g_log_fp != stderr) { \
if (g_log_fp != NULL) { \
fprintf(g_log_fp, __VA_ARGS__); \
fflush(g_log_fp);\
}\

View File

@ -54,16 +54,14 @@ int _search(unsigned char *haystack, size_t haystack_size, const unsigned char *
j--;
if (j < 0) {
//printf("\n pattern occurs at shift = %d", s);
//s += (s + needle_size < haystack_size) ? needle_size - badchar[txt[s + needle_size]] : 1;
if (debug)
if (debug)
LOG("found string at offset %llx!\n", orig_offset +s);
return orig_offset + s;
}
else
{
s += max(1, j - badchar[(int)haystack[orig_offset + s + j]]);
if (debug)
if (debug)
LOG("mismatch at pos %d, new offset %llx\n\n", j, orig_offset+s);
}
}
@ -74,5 +72,4 @@ if (debug)
int search(char *haystack, size_t haystack_size, const char *needle, size_t needle_size, size_t orig_offset) {
int res = _search((unsigned char*) haystack, haystack_size, (const unsigned char *)needle, needle_size, orig_offset, 0);
return res;
}