--- Daodan/src/Daodan.c 2009/06/06 01:30:13 339 +++ Daodan/src/Daodan.c 2009/06/09 12:00:41 346 @@ -1,3 +1,5 @@ +#include + #include "Daodan.h" #include "Daodan_Patch.h" #include "Daodan_Utility.h" @@ -13,11 +15,15 @@ #include "oni_gl.h" #include "daodan_gl.h" +#include "inifile.h" + HMODULE DDrDLLModule; HMODULE DDrONiModule; bool DDrPatch_Init() { + DDrStartupMessage("patching engine"); + // Font texture cache doubled DDrPatch_Byte (OniExe + 0x00020ea7, 0x20); DDrPatch_Byte (OniExe + 0x00020f4a, 0x40); @@ -93,8 +99,69 @@ bool DDrPatch_Init() return true; } +enum {s_unknown, s_language} ini_section; + +bool DDrIniCallback(char* section, bool newsection, char* name, char* value) +{ + if (newsection) + { + if (!stricmp(section, "language")) + ini_section = s_language; + else + { + ini_section = s_unknown; + DDrStartupMessage("unrecognised ini section \"%s\"", section); + } + } + + switch (ini_section) + { + case s_language: + if (!stricmp(name, "savepoint")) + { + DDrPatch_StrDup(OniExe + 0x000fd730, value); + DDrPatch_StrDup(OniExe + 0x000fd738, value); + } + else if (!stricmp(name, "syndicatewarehouse")) + { + DDrPatch_StrDup(OniExe + 0x000fd71a, value); + DDrPatch_StrDup(OniExe + 0x0010ef75, value); + } + else if (!stricmp(name, "blam")) + DDrPatch_StrDup(OniExe + 0x0010fb73, value); + else + DDrStartupMessage("unrecognised language item \"%s\"", name); + break; + default: + break; + } + + return true; +} + +void DDrConfig() +{ + if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES) + { + DDrStartupMessage("daodan.ini doesn't exist, creating"); + FILE* fp = fopen("daodan.ini", "w"); + if (fp) + { + fputs("[Options]\n", fp); + fclose(fp); + } + } + + DDrStartupMessage("parsing daodan.ini..."); + if (!inifile_read("daodan.ini", DDrIniCallback)) + DDrStartupMessage("error reading daodan.ini, check your syntax!"); + DDrStartupMessage("finished parsing"); +} + void __cdecl DDrMain(int argc, char* argv[]) { + DDrStartupMessage("daodan attached!"); + DDrConfig(); DDrPatch_Init(); // Safe startup message printer @@ -115,7 +182,7 @@ void __cdecl DDrMain(int argc, char* arg // DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize); // DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize); -// init_daodan_gl(); + init_daodan_gl(); ONiMain(argc, argv); }