1 |
#include <windows.h> |
2 |
|
3 |
#include "../Daodan.h" |
4 |
#include "../Daodan_BSL.h" |
5 |
#include "../Daodan_Cheater.h" |
6 |
#include "../Daodan_Config.h" |
7 |
#include "../Daodan_GL.h" |
8 |
#include "../Daodan_Patch.h" |
9 |
#include "../Daodan_Persistence.h" |
10 |
#include "../Daodan_Utility.h" |
11 |
#include "../Daodan_Win32.h" |
12 |
#include "../flatline/Flatline_BSL.h" |
13 |
#include "../flatline/Flatline_Hooks.h" |
14 |
#include "../Oni.h" |
15 |
|
16 |
typedef int (__cdecl *CHINESEPROC)(DWORD ThreadId); |
17 |
|
18 |
// Hooked WMrSlider_SetRange() in ONiOGU_Options_InitDialog. Disables a gamma |
19 |
// slider in windowed mode. |
20 |
static void ONICALL DD_ONiOGU_GammaSlider_SetRange(WMtWindow* window, int min_value, int max_value) |
21 |
{ |
22 |
WMrWindow_SetEnabled(window, M3gResolutionSwitch && opt_gamma); |
23 |
WMrSlider_SetRange(window, min_value, max_value); |
24 |
} |
25 |
|
26 |
void ONICALL DDrShowResumeButton(WMtWindow* window, int visibility) |
27 |
{ |
28 |
if (visibility) |
29 |
WMrWindow_SetLocation(window, 150, 350); |
30 |
WMrWindow_SetVisible(window, visibility); |
31 |
} |
32 |
|
33 |
|
34 |
/* Options always visible patch */ |
35 |
void ONICALL DDrShowOptionsButton(WMtWindow* window, int visibility) |
36 |
{ |
37 |
WMrWindow_SetVisible(window, 1); |
38 |
} |
39 |
|
40 |
void ONICALL DDrGame_Init() |
41 |
{ |
42 |
if (opt_usedaodanbsl) |
43 |
SLrDaodan_Initialize(); |
44 |
if (patch_flatline) |
45 |
SLrFlatline_Initialize(); |
46 |
} |
47 |
|
48 |
|
49 |
//this was broken |
50 |
FILE** _UUgError_WarningFile = (FILE**)0x005711B4; |
51 |
FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message) |
52 |
{ |
53 |
|
54 |
FILE *v4; // eax@1 |
55 |
FILE *result; // eax@4 |
56 |
char v6[512]; // [sp+0h] [bp-100h]@1 |
57 |
FILE* UUgError_WarningFile = *_UUgError_WarningFile; |
58 |
|
59 |
if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) { |
60 |
sprintf( |
61 |
v6, |
62 |
"Error %x reported from File: %s, Line: %d (message follows) \r\n%s", |
63 |
errornum, |
64 |
(const char*)filename, |
65 |
linenumber, |
66 |
(const char*)message); |
67 |
|
68 |
if ( UUgError_WarningFile |
69 |
|| (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) ) |
70 |
{ |
71 |
oni_fprintf(UUgError_WarningFile, "%s\r\n", v6); |
72 |
oni_fflush(UUgError_WarningFile); |
73 |
} |
74 |
} |
75 |
//oni_fprintf(stdout, v6); |
76 |
//sprintf(&v6, "%s", message); |
77 |
*_UUgError_WarningFile = UUgError_WarningFile; |
78 |
result = UUgError_WarningFile; |
79 |
return result; |
80 |
} |
81 |
|
82 |
|
83 |
int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output) |
84 |
{ |
85 |
//flags = (1 << 10); |
86 |
type = 1; |
87 |
//DDrPatch_Byte( 0x005EB83C + 3, 0xff ); |
88 |
DDrPatch_Int32((int*)(OniExe + 0x001EB83C), 0xFF000000 ); |
89 |
return M3rTextureMap_New(width, height, type, allocated, flags, name, output); |
90 |
} |
91 |
|
92 |
short DD_Patch_DebugNameShadeHack( Character* Char ) |
93 |
{ |
94 |
return TSrContext_SetShade(*(void**)(OniExe + 0x001EB844), ONrCharacter_GetHealthShade( Char->Health, Char->MaxHealth )); |
95 |
//return TSrContext_SetShade(*(void**)0x005EB844, 0xFFFFFFFF); |
96 |
} |
97 |
|
98 |
|
99 |
// Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the |
100 |
// Windows key but has the possible side effect of allowing the screensaver |
101 |
// to enable itself in-game. |
102 |
void DD_Patch_AltTab() |
103 |
{ |
104 |
// 0xC3 = ret, so makes those functions just have a "ret" instruction at their start |
105 |
DDrPatch_Byte ((char*)UUrPlatform_Initialize, 0xC3); |
106 |
DDrPatch_Byte ((char*)UUrPlatform_Terminate, 0xC3); |
107 |
} |
108 |
|
109 |
// Textures using ARGB8888 can be used |
110 |
void DD_Patch_ARGB8888() |
111 |
{ |
112 |
DDrPatch_Byte ((char*)(OniExe + 0x00135af0), 0x07); |
113 |
DDrPatch_Byte ((char*)(OniExe + 0x00135af4), 0x0B); |
114 |
} |
115 |
|
116 |
// Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting |
117 |
// instead of DirectDraw; patch ONiRunGame to use the same method to play |
118 |
// outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the |
119 |
// latter has problems on WINE). |
120 |
void DD_Patch_BinkPlay() |
121 |
{ |
122 |
// push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION. |
123 |
DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02); |
124 |
// call ONrMovie_Play_Hardware -> call ONrMovie_Play |
125 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play); |
126 |
} |
127 |
|
128 |
// Enables d_regen (unfinished) and prevents fly-in portraits from being |
129 |
// stretched when playing in widescreen resolutions. |
130 |
void DD_Patch_BSL() |
131 |
{ |
132 |
//Calculating the value of the needed offset is much more reliable when the compiler does it for you. |
133 |
|
134 |
//TODO: fix moonshadow. |
135 |
Character * Chr = 0; |
136 |
int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF; |
137 |
const unsigned char regen_patch[] = |
138 |
{0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP |
139 |
0x90, 0x90, // test al, al -> NOOP |
140 |
0x90, 0x90, // jz short loc_51BB98 -> NOOP |
141 |
0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8] |
142 |
// -> mov eax, [esi+Character.RegenHax] |
143 |
0x85, 0xC0, // test eax, eax |
144 |
0x74, 0x21 // jnz 0x21 -> jz 0x21 |
145 |
}; |
146 |
DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch); |
147 |
|
148 |
// Patches for existing BSL functions |
149 |
SLrDaodan_Patch(); |
150 |
} |
151 |
|
152 |
// Adds new cheat codes if cheattable is also enabled |
153 |
void DD_Patch_Cheater() |
154 |
{ |
155 |
DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater); |
156 |
DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590); |
157 |
#if 1 |
158 |
DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames); |
159 |
#endif |
160 |
DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad); |
161 |
} |
162 |
|
163 |
// Cheats always enabled |
164 |
void DD_Patch_CheatsEnabled() |
165 |
{ |
166 |
DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame); |
167 |
} |
168 |
|
169 |
// Use Daodan's own cheattable |
170 |
void DD_Patch_CheatTable() |
171 |
{ |
172 |
DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name); |
173 |
DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on); |
174 |
} |
175 |
|
176 |
// Load chinese font DLL if available |
177 |
void DD_Patch_Chinese() |
178 |
{ |
179 |
if (GetFileAttributes("xfhsm_oni.dll") != INVALID_FILE_ATTRIBUTES) |
180 |
{ |
181 |
HMODULE dll; |
182 |
DWORD err; |
183 |
|
184 |
DDrStartupMessage("Daodan: Loading chinese DLL"); |
185 |
dll = LoadLibrary("xfhsm_oni.dll"); |
186 |
err = GetLastError(); |
187 |
if( dll ) |
188 |
{ |
189 |
void* proc = GetProcAddress( dll, "InstallHook" ); |
190 |
if(proc) |
191 |
{ |
192 |
((CHINESEPROC)proc)(GetCurrentThreadId()); |
193 |
} |
194 |
} else { |
195 |
char msg[100]; |
196 |
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL); |
197 |
DDrStartupMessage("Daodan: Loading DLL failed with error %i: %s", err, msg); |
198 |
} |
199 |
} |
200 |
} |
201 |
|
202 |
// Limit cursor to Oni's window |
203 |
void DD_Patch_ClipCursor() |
204 |
{ |
205 |
// LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. |
206 |
DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); |
207 |
|
208 |
// LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. |
209 |
DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); |
210 |
|
211 |
// LIrTermiante: replace LIrPlatform_Terminate call with our hook. |
212 |
DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); |
213 |
} |
214 |
|
215 |
// Disables weapon cooldown exploit |
216 |
void DD_Patch_CooldownTimer() |
217 |
{ |
218 |
const unsigned char cooldown_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; |
219 |
DDrPatch_Const ((char*)(OniExe + 0x0011a825), cooldown_patch); |
220 |
} |
221 |
|
222 |
// Daodan device mode enumeration function |
223 |
void DD_Patch_DaodanDisplayEnum() |
224 |
{ |
225 |
DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes); |
226 |
} |
227 |
|
228 |
// Adds new BSL functions if usedaodanbsl is enabled |
229 |
void DD_Patch_DaodanInit() |
230 |
{ |
231 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init); |
232 |
} |
233 |
|
234 |
// Forced DirectInput (for Windows NT) |
235 |
void DD_Patch_DirectInput() |
236 |
{ |
237 |
DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb); |
238 |
} |
239 |
|
240 |
// Disable Oni's command line parser so it doesn't interfere with ours |
241 |
void DD_Patch_DisableCmdLine() |
242 |
{ |
243 |
DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366); |
244 |
} |
245 |
|
246 |
// Enable flatline multiplayer code |
247 |
void DD_Patch_Flatline() |
248 |
{ |
249 |
DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 ); |
250 |
DDrPatch_MakeCall((void*)(OniExe + 0x000E17F6), FLrHook_Lasers ); |
251 |
|
252 |
|
253 |
//Flatline related stuff |
254 |
DDrPatch_MakeCall((void*)(OniExe + 0x000FBCEA), DDrText_Hook); |
255 |
|
256 |
DDrPatch_Int32((int*)(OniExe + 0x000B24D2), FLrSpawnHack); |
257 |
|
258 |
DDrPatch_NOOP((char*)(OniExe + 0x000C26CB), 6); |
259 |
|
260 |
DDrPatch_MakeCall((void*)(OniExe + 0x000C26CB), FLrHook_DoorOpen); |
261 |
DDrPatch_MakeCall((void*)(OniExe + 0x000EE3CF), FLrHook_ConsoleActivate); |
262 |
} |
263 |
|
264 |
// Font texture cache doubled |
265 |
void DD_Patch_FontTextureCache() |
266 |
{ |
267 |
DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20); |
268 |
DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40); |
269 |
} |
270 |
|
271 |
// Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own) |
272 |
void DD_Patch_GetCmdLine() |
273 |
{ |
274 |
DDrPatch_NOOP ((char*)(OniExe + 0x000d3280), 51); |
275 |
} |
276 |
|
277 |
// Hackish fix for Konoko not kicking guns |
278 |
// Don't use this, it breaks stairs. |
279 |
void DD_Patch_KickGuns() |
280 |
{ |
281 |
const unsigned char kickgun_patch[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0xC7, 0x05, 0x1C, 0xC9, 0x5E, 0x00, 0x70, 0xB8, 0x43, 0x00, 0xC7, 0x05, 0x20, 0xC9, 0x5E, 0x00, 0x20, 0xBE, 0x43 }; |
282 |
DDrPatch_Const ((char*)(OniExe + 0x000dc420), kickgun_patch); |
283 |
} |
284 |
|
285 |
// Disable loading the vtuneapi.dll |
286 |
void DD_Patch_KillVTune() |
287 |
{ |
288 |
DDrPatch_Byte ((char*)(OniExe + 0x00026340), 0xC3); |
289 |
} |
290 |
|
291 |
// Now supports textures up to 512x512 |
292 |
void DD_Patch_LargeTextures() |
293 |
{ |
294 |
DDrPatch_Byte ((char*)(OniExe + 0x00005251), 0x10); |
295 |
} |
296 |
|
297 |
// Non-"_Final" levels are now valid |
298 |
void DD_Patch_LevelPlugins() |
299 |
{ |
300 |
DDrPatch_Byte ((char*)(OniExe + 0x000206a8), 0x01); |
301 |
} |
302 |
|
303 |
// Weapon on ground shown with name and magazine contents |
304 |
void DD_Patch_NewWeap() |
305 |
{ |
306 |
//Makes it always say "Received weapon_name." |
307 |
//Needs check for loc_4DFC66 |
308 |
//DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2); |
309 |
|
310 |
//Adds Weapon name and ammo meter to pickup autoprompt |
311 |
DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9); |
312 |
DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5); |
313 |
DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message); |
314 |
|
315 |
//Moves location of colors |
316 |
//DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors ); |
317 |
//DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors ); |
318 |
} |
319 |
|
320 |
// Disable Multi-byte character awareness patch (multiple language support) |
321 |
void DD_Patch_NoMultiByte() |
322 |
{ |
323 |
DDrPatch_Byte ((char*)(OniExe + 0x0002d8f8), 0xeb); |
324 |
DDrPatch_Byte ((char*)(OniExe + 0x0002d9ad), 0xeb); |
325 |
DDrPatch_Byte ((char*)(OniExe + 0x0002dbe2), 0xeb); |
326 |
DDrPatch_Byte ((char*)(OniExe + 0x0002dec3), 0xeb); |
327 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e2ab), 0xeb); |
328 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e2c4), 0xeb); |
329 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e379), 0xeb); |
330 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e48c), 0xeb); |
331 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e4d0), 0xeb); |
332 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e4f4), 0xeb); |
333 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e646), 0xeb); |
334 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e695), 0xeb); |
335 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e944), 0xeb); |
336 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e95d), 0xeb); |
337 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e98e), 0xeb); |
338 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e9dc), 0xeb); |
339 |
} |
340 |
|
341 |
// Fix options not visible in main menu when a game was started |
342 |
void DD_Patch_OptionsVisible() |
343 |
{ |
344 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton); |
345 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton); |
346 |
} |
347 |
|
348 |
// Unlocks particle action disabling/enabling bits for all events. (Will be |
349 |
// controlled by a command line switch when I figure out how to do that without |
350 |
// Win32 hacks.) |
351 |
void DD_Patch_ParticleDisableBit() |
352 |
{ |
353 |
DDrPatch_Int16 ((short*)(OniExe + 0x001b184), 0x9090); |
354 |
} |
355 |
|
356 |
// Pathfinding grid cache size x8 |
357 |
void DD_Patch_PathFinding() |
358 |
{ |
359 |
const unsigned char pathfinding[2] = {0x90 , 0xE9 }; |
360 |
DDrPatch_Byte ((char*)(OniExe + 0x0010b03b), 0x20); |
361 |
DDrPatch_Byte ((char*)(OniExe + 0x0010b04c), 0x20); |
362 |
|
363 |
//other stuff |
364 |
DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding); |
365 |
} |
366 |
|
367 |
// Projectile awareness fixed |
368 |
void DD_Patch_ProjAware() |
369 |
{ |
370 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c07c), 0x6c); |
371 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c080), 0x70); |
372 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c084), 0x74); |
373 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c110), 0x6c); |
374 |
} |
375 |
|
376 |
// Safe startup message printer |
377 |
void DD_Patch_SafePrintf() |
378 |
{ |
379 |
DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage); |
380 |
} |
381 |
|
382 |
// Experiment with allowing enemies to be thrown over railings |
383 |
void DD_Patch_Throwtest() |
384 |
{ |
385 |
const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; |
386 |
DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch); |
387 |
} |
388 |
|
389 |
// DaodanGL with windowed mode support |
390 |
void DD_Patch_UseDaodanGL() |
391 |
{ |
392 |
// LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect. |
393 |
DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6); |
394 |
DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect); |
395 |
|
396 |
// UUrWindow_GetSize: GetWindowRect -> GetClientRect. |
397 |
DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6); |
398 |
DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect); |
399 |
|
400 |
// LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates. |
401 |
DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6); |
402 |
DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos); |
403 |
|
404 |
// LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates. |
405 |
DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6); |
406 |
DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos); |
407 |
|
408 |
// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. |
409 |
DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6); |
410 |
DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos); |
411 |
|
412 |
// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. |
413 |
DDrPatch_NOOP((char*) OniExe + 0x00003349, 6); |
414 |
DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos); |
415 |
|
416 |
// Replace ONrPlatformInitialize. |
417 |
DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize); |
418 |
|
419 |
// Replace gl_platform_initialize. |
420 |
DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize); |
421 |
|
422 |
// Replace gl_platform_dispose. |
423 |
DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose); |
424 |
} |
425 |
|
426 |
// Performance patch |
427 |
void DD_Patch_UseGetTickCount() |
428 |
{ |
429 |
DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High); |
430 |
DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency); |
431 |
DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths); |
432 |
} |
433 |
|
434 |
// Adds working function for existing BSL command wp_fadetime, sets fade time to 4800 |
435 |
void DD_Patch_WpFadetime() |
436 |
{ |
437 |
// Makes wp_fadetime actually have a function |
438 |
const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 }; |
439 |
DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch); |
440 |
DDrPatch_Byte ((char*)(OniExe + 0x0011a560), 0x31); |
441 |
|
442 |
// Sets the fadetime to 4800 by default |
443 |
DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0); |
444 |
} |
445 |
|
446 |
// Disable gamma slider in options in windowed mode |
447 |
void DD_Patch_GammaSlider() |
448 |
{ |
449 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange); |
450 |
} |
451 |
|
452 |
// Fix the warning print method |
453 |
void DD_Patch_PrintWarning() |
454 |
{ |
455 |
DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning); |
456 |
} |
457 |
|
458 |
//Fix crappy ai2_shownames |
459 |
void DD_Patch_ShowNames() |
460 |
{ |
461 |
//Set distance above head to 4.0 |
462 |
DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8); |
463 |
//texture height |
464 |
DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F ); |
465 |
//texture width |
466 |
DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 ); |
467 |
|
468 |
/* |
469 |
// Crashes game. |
470 |
//Set the text color to whatever we like ;) |
471 |
DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 ); |
472 |
DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B ); |
473 |
DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE ); |
474 |
|
475 |
DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), DD_Patch_DebugNameShadeHack); |
476 |
|
477 |
//Make the background black for additive blending |
478 |
DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), DD_Patch_DebugNameTextureInit ); |
479 |
*/ |
480 |
} |
481 |
|
482 |
bool DD_Patch_Init() |
483 |
{ |
484 |
DDrStartupMessage("Daodan: Patching engine"); |
485 |
|
486 |
if (patch_alttab) |
487 |
DD_Patch_AltTab(); |
488 |
|
489 |
if (patch_argb8888) |
490 |
DD_Patch_ARGB8888(); |
491 |
|
492 |
if (patch_binkplay) |
493 |
DD_Patch_BinkPlay(); |
494 |
|
495 |
if (patch_bsl) |
496 |
DD_Patch_BSL(); |
497 |
|
498 |
if (patch_cheater) |
499 |
DD_Patch_Cheater(); |
500 |
|
501 |
if (patch_cheatsenabled) |
502 |
DD_Patch_CheatsEnabled(); |
503 |
|
504 |
if (patch_cheattable) |
505 |
DD_Patch_CheatTable(); |
506 |
|
507 |
if (patch_chinese) |
508 |
DD_Patch_Chinese(); |
509 |
|
510 |
if (patch_clipcursor) |
511 |
DD_Patch_ClipCursor(); |
512 |
|
513 |
if (patch_cooldowntimer) |
514 |
DD_Patch_CooldownTimer(); |
515 |
|
516 |
if (patch_daodandisplayenum) |
517 |
DD_Patch_DaodanDisplayEnum(); |
518 |
|
519 |
if (patch_directinput) |
520 |
DD_Patch_DirectInput(); |
521 |
|
522 |
if (patch_disablecmdline) |
523 |
DD_Patch_DisableCmdLine(); |
524 |
|
525 |
if (patch_fonttexturecache) |
526 |
DD_Patch_FontTextureCache(); |
527 |
|
528 |
if (patch_getcmdline) |
529 |
DD_Patch_GetCmdLine(); |
530 |
|
531 |
if (patch_kickguns) |
532 |
DD_Patch_KickGuns(); |
533 |
|
534 |
//if (patch_killvtune) |
535 |
// DD_Patch_KillVTune(); |
536 |
|
537 |
if (patch_largetextures) |
538 |
DD_Patch_LargeTextures(); |
539 |
|
540 |
if (patch_levelplugins) |
541 |
DD_Patch_LevelPlugins(); |
542 |
|
543 |
if (patch_newweapon) |
544 |
DD_Patch_NewWeap(); |
545 |
|
546 |
if (patch_nomultibyte) |
547 |
DD_Patch_NoMultiByte(); |
548 |
|
549 |
if(patch_optionsvisible) |
550 |
DD_Patch_OptionsVisible(); |
551 |
|
552 |
if (patch_particledisablebit) |
553 |
DD_Patch_ParticleDisableBit(); |
554 |
|
555 |
if (patch_pathfinding) |
556 |
DD_Patch_PathFinding(); |
557 |
|
558 |
if (patch_projaware) |
559 |
DD_Patch_ProjAware(); |
560 |
|
561 |
if (patch_safeprintf) |
562 |
DD_Patch_SafePrintf(); |
563 |
|
564 |
if (patch_throwtest) |
565 |
DD_Patch_Throwtest(); |
566 |
|
567 |
if (patch_usedaodangl) |
568 |
DD_Patch_UseDaodanGL(); |
569 |
|
570 |
if (patch_usegettickcount) |
571 |
DD_Patch_UseGetTickCount(); |
572 |
|
573 |
if (patch_wpfadetime) |
574 |
DD_Patch_WpFadetime(); |
575 |
|
576 |
|
577 |
DD_Patch_DaodanInit(); |
578 |
|
579 |
DD_Patch_GammaSlider(); |
580 |
|
581 |
DD_Patch_PrintWarning(); |
582 |
|
583 |
|
584 |
DD_Patch_ShowNames(); |
585 |
|
586 |
if (patch_flatline) |
587 |
DD_Patch_Flatline(); |
588 |
|
589 |
return true; |
590 |
} |
591 |
|