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 |
|
13 |
#include "../Oni/Oni.h" |
14 |
|
15 |
typedef int (__cdecl *CHINESEPROC)(DWORD ThreadId); |
16 |
|
17 |
// Hooked WMrSlider_SetRange() in ONiOGU_Options_InitDialog. Disables a gamma |
18 |
// slider in windowed mode. |
19 |
static void ONICALL DD_ONiOGU_GammaSlider_SetRange(void* window, int min_value, int max_value) |
20 |
{ |
21 |
ConfigOption_t* co = DDrConfig_GetOptOfType("options.gamma", C_BOOL); |
22 |
WMrWindow_SetEnabled(window, M3gResolutionSwitch && co->value.intBoolVal); |
23 |
WMrSlider_SetRange(window, min_value, max_value); |
24 |
} |
25 |
|
26 |
void ONICALL DD_M3rDraw_BigBitmap(M3tTextureMap_Big* inBigBitmap, const M3tPointScreen* inDestPoint, UUtUns16 inWidth, UUtUns16 inHeight, UUtUns32 inShade, UUtUns16 inAlpha) /* 0 - M3cMaxAlpha */ |
27 |
{ |
28 |
UUtUns16 x; |
29 |
UUtUns16 y; |
30 |
|
31 |
UUtUns16 index; |
32 |
UUtUns16 remaining_width; |
33 |
UUtUns16 remaining_height; |
34 |
|
35 |
M3tPointScreen dest_point; |
36 |
dest_point.z = inDestPoint->z; |
37 |
dest_point.invW = inDestPoint->invW; |
38 |
|
39 |
index = 0; |
40 |
remaining_height = inHeight; |
41 |
dest_point.y = (UUtInt16)((UUtUns16)inDestPoint->y); |
42 |
for (y = 0; y < inBigBitmap->num_y; y++) |
43 |
{ |
44 |
remaining_width = inWidth; |
45 |
dest_point.x = (UUtInt16)((UUtUns16)inDestPoint->x); |
46 |
for (x = 0; x < inBigBitmap->num_x; x++) |
47 |
{ |
48 |
UUtUns16 width; |
49 |
UUtUns16 height; |
50 |
|
51 |
width = 256 < remaining_width ? 256 : remaining_width; |
52 |
height = 256 < remaining_height ? 256 : remaining_height; |
53 |
|
54 |
M3rDraw_Bitmap(inBigBitmap->textures[index], &dest_point, width, height, inShade, inAlpha); |
55 |
|
56 |
dest_point.x += 256; |
57 |
remaining_width -= 256; |
58 |
index++; |
59 |
} |
60 |
dest_point.y += 256; |
61 |
remaining_height -= 256; |
62 |
} |
63 |
} |
64 |
|
65 |
|
66 |
void ONICALL DDrShowResumeButton(void* window, int visibility) |
67 |
{ |
68 |
if (visibility) |
69 |
WMrWindow_SetLocation(window, 150, 350); |
70 |
WMrWindow_SetVisible(window, visibility); |
71 |
} |
72 |
|
73 |
|
74 |
/* Options always visible patch */ |
75 |
void ONICALL DDrShowOptionsButton(void* window, int visibility) |
76 |
{ |
77 |
WMrWindow_SetVisible(window, 1); |
78 |
} |
79 |
|
80 |
void ONICALL DDrGame_Init() |
81 |
{ |
82 |
ConfigOption_t* co = DDrConfig_GetOptOfType("options.usedaodanbsl", C_BOOL); |
83 |
if (co->value.intBoolVal) |
84 |
SLrDaodan_Initialize(); |
85 |
} |
86 |
|
87 |
|
88 |
//this was broken |
89 |
FILE** _UUgError_WarningFile = (FILE**)0x005711B4; |
90 |
FILE* ONICALL DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message) |
91 |
{ |
92 |
FILE *v4; // eax@1 |
93 |
FILE *result; // eax@4 |
94 |
char v6[512]; // [sp+0h] [bp-100h]@1 |
95 |
FILE* UUgError_WarningFile = *_UUgError_WarningFile; |
96 |
|
97 |
if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) { |
98 |
sprintf( |
99 |
v6, |
100 |
"Error %x reported from File: %s, Line: %d (message follows) \r\n%s", |
101 |
errornum, |
102 |
(const char*)filename, |
103 |
linenumber, |
104 |
(const char*)message); |
105 |
|
106 |
if ( UUgError_WarningFile |
107 |
|| (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) ) |
108 |
{ |
109 |
oni_fprintf(UUgError_WarningFile, "%s\r\n", v6); |
110 |
oni_fflush(UUgError_WarningFile); |
111 |
} |
112 |
} |
113 |
//oni_fprintf(stdout, v6); |
114 |
//sprintf(&v6, "%s", message); |
115 |
*_UUgError_WarningFile = UUgError_WarningFile; |
116 |
result = UUgError_WarningFile; |
117 |
return result; |
118 |
} |
119 |
|
120 |
_COrTextArea_Resize Oni_COrTextArea_Resize = (_COrTextArea_Resize)0; |
121 |
int16_t ONICALL DD_COrTextArea_Resize(void* inTextArea, UUtRect* inBounds, int16_t inNumTextEntries) { |
122 |
if (inTextArea == COgCommandLine) { |
123 |
inBounds->top -= 10; |
124 |
} else if (inTextArea == COgConsoleLines) { |
125 |
inBounds->bottom -= 10; |
126 |
} |
127 |
return Oni_COrTextArea_Resize(inTextArea, inBounds, inNumTextEntries); |
128 |
} |
129 |
|
130 |
#define IMcShade_Red (0xFFFF0000) |
131 |
#define IMcShade_Green (0xFF00FF00) |
132 |
#define IMcShade_Blue (0xFF0000FF) |
133 |
void ONICALL DD_OBJiTriggerVolume_Draw(OBJtObject* inObject, uint32_t inDrawFlags) |
134 |
{ |
135 |
UUtUns32 itr; |
136 |
OBJtOSD_All *inOSD = (OBJtOSD_All *) inObject->object_data; |
137 |
OBJtOSD_TriggerVolume *trigger_osd = &inOSD->osd.trigger_volume_osd; |
138 |
M3tPoint3D *points = trigger_osd->volume.worldPoints; |
139 |
UUtUns32 shade = 0xFFFFFF; |
140 |
|
141 |
if (!OBJgTriggerVolume_Visible) { |
142 |
return; |
143 |
} |
144 |
|
145 |
if (OBJrTriggerVolume_IntersectsCharacter(inObject, trigger_osd->team_mask, ONgGameState->PlayerCharacter)) { |
146 |
shade = IMcShade_Red; |
147 |
} |
148 |
else |
149 |
{ |
150 |
shade = IMcShade_Blue; |
151 |
} |
152 |
|
153 |
M3rGeom_Line_Light(points + 0, points + 1, shade); |
154 |
M3rGeom_Line_Light(points + 1, points + 3, shade); |
155 |
M3rGeom_Line_Light(points + 3, points + 2, shade); |
156 |
M3rGeom_Line_Light(points + 2, points + 0, shade); |
157 |
|
158 |
M3rGeom_Line_Light(points + 4, points + 5, shade); |
159 |
M3rGeom_Line_Light(points + 5, points + 7, shade); |
160 |
M3rGeom_Line_Light(points + 7, points + 6, shade); |
161 |
M3rGeom_Line_Light(points + 6, points + 4, shade); |
162 |
|
163 |
M3rGeom_Line_Light(points + 0, points + 4, shade); |
164 |
M3rGeom_Line_Light(points + 1, points + 5, shade); |
165 |
M3rGeom_Line_Light(points + 3, points + 7, shade); |
166 |
M3rGeom_Line_Light(points + 2, points + 6, shade); |
167 |
} |
168 |
|
169 |
_ONrMechanics_Register Oni_ONrMechanics_Register = (_ONrMechanics_Register)0; |
170 |
int16_t ONICALL DD_ONrMechanics_Register(uint32_t inObjectType, uint32_t inObjectTypeIndex, char* inGroupName, |
171 |
uint32_t inSizeInMemory, OBJtMethods* inObjectMethods, uint32_t inFlags, void* inMechanicsMethods) |
172 |
{ |
173 |
if (strcmp("Trigger Volume", inGroupName) == 0) { |
174 |
inObjectMethods->rDraw = DD_OBJiTriggerVolume_Draw; |
175 |
} |
176 |
return Oni_ONrMechanics_Register(inObjectType, inObjectTypeIndex, inGroupName, inSizeInMemory, inObjectMethods, inFlags, inMechanicsMethods); |
177 |
} |
178 |
|
179 |
_ONrGameState_HandleUtilityInput Oni_ONrGameState_HandleUtilityInput = (_ONrGameState_HandleUtilityInput)0; |
180 |
void ONICALL DD_ONrGameState_HandleUtilityInput(const void* inInput) |
181 |
{ |
182 |
Oni_ONrGameState_HandleUtilityInput(inInput); |
183 |
|
184 |
if (ONrDebugKey_WentDown(7)) { |
185 |
OBJgTriggerVolume_Visible = !OBJgTriggerVolume_Visible; |
186 |
} |
187 |
} |
188 |
|
189 |
|
190 |
int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output) |
191 |
{ |
192 |
//flags = (1 << 10); |
193 |
type = 1; |
194 |
//DDrPatch_Byte( 0x005EB83C + 3, 0xff ); |
195 |
DDrPatch_Int32((int*)(OniExe + 0x001EB83C), 0xFF000000 ); |
196 |
return M3rTextureMap_New(width, height, type, allocated, flags, name, output); |
197 |
} |
198 |
|
199 |
short DD_Patch_DebugNameShadeHack( Character* Char ) |
200 |
{ |
201 |
return TSrContext_SetShade(*(void**)(OniExe + 0x001EB844), ONrCharacter_GetHealthShade( Char->Health, Char->MaxHealth )); |
202 |
//return TSrContext_SetShade(*(void**)0x005EB844, 0xFFFFFFFF); |
203 |
} |
204 |
|
205 |
|
206 |
// Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the |
207 |
// Windows key but has the possible side effect of allowing the screensaver |
208 |
// to enable itself in-game. |
209 |
void DD_Patch_AltTab() |
210 |
{ |
211 |
// 0xC3 = ret, so makes those functions just have a "ret" instruction at their start |
212 |
DDrPatch_Byte ((char*)UUrPlatform_Initialize, 0xC3); |
213 |
DDrPatch_Byte ((char*)UUrPlatform_Terminate, 0xC3); |
214 |
} |
215 |
|
216 |
// Textures using ARGB8888 can be used |
217 |
void DD_Patch_ARGB8888() |
218 |
{ |
219 |
DDrPatch_Byte ((char*)(OniExe + 0x00135af0), 0x07); |
220 |
DDrPatch_Byte ((char*)(OniExe + 0x00135af4), 0x0B); |
221 |
} |
222 |
|
223 |
// Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting |
224 |
// instead of DirectDraw; patch ONiRunGame to use the same method to play |
225 |
// outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the |
226 |
// latter has problems on WINE). |
227 |
void DD_Patch_BinkPlay() |
228 |
{ |
229 |
// push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION. |
230 |
DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02); |
231 |
// call ONrMovie_Play_Hardware -> call ONrMovie_Play |
232 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play); |
233 |
} |
234 |
|
235 |
// Enables d_regen (unfinished) and prevents fly-in portraits from being |
236 |
// stretched when playing in widescreen resolutions. |
237 |
void DD_Patch_BSL() |
238 |
{ |
239 |
//Calculating the value of the needed offset is much more reliable when the compiler does it for you. |
240 |
|
241 |
//TODO: fix moonshadow. |
242 |
Character * Chr = 0; |
243 |
int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF; |
244 |
const unsigned char regen_patch[] = |
245 |
{0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP |
246 |
0x90, 0x90, // test al, al -> NOOP |
247 |
0x90, 0x90, // jz short loc_51BB98 -> NOOP |
248 |
0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8] |
249 |
// -> mov eax, [esi+Character.RegenHax] |
250 |
0x85, 0xC0, // test eax, eax |
251 |
0x74, 0x21 // jnz 0x21 -> jz 0x21 |
252 |
}; |
253 |
DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch); |
254 |
|
255 |
// Patches for existing BSL functions |
256 |
SLrDaodan_Patch(); |
257 |
} |
258 |
|
259 |
// Adds new cheat codes if cheattable is also enabled |
260 |
void DD_Patch_Cheater() |
261 |
{ |
262 |
DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater); |
263 |
DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590); |
264 |
#if 1 |
265 |
DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames); |
266 |
#endif |
267 |
DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad); |
268 |
} |
269 |
|
270 |
// Cheats always enabled |
271 |
void DD_Patch_CheatsEnabled() |
272 |
{ |
273 |
DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame); |
274 |
} |
275 |
|
276 |
// Use Daodan's own cheattable |
277 |
void DD_Patch_CheatTable() |
278 |
{ |
279 |
DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name); |
280 |
DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on); |
281 |
} |
282 |
|
283 |
// Load chinese font DLL if available |
284 |
void DD_Patch_Chinese() |
285 |
{ |
286 |
if (GetFileAttributes("xfhsm_oni.dll") != INVALID_FILE_ATTRIBUTES) |
287 |
{ |
288 |
HMODULE dll; |
289 |
DWORD err; |
290 |
|
291 |
STARTUPMESSAGE("Loading chinese DLL", 0); |
292 |
dll = LoadLibrary("xfhsm_oni.dll"); |
293 |
err = GetLastError(); |
294 |
if( dll ) |
295 |
{ |
296 |
void* proc = GetProcAddress( dll, "InstallHook" ); |
297 |
if(proc) |
298 |
{ |
299 |
((CHINESEPROC)proc)(GetCurrentThreadId()); |
300 |
} |
301 |
} else { |
302 |
char msg[100]; |
303 |
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL); |
304 |
STARTUPMESSAGE("Loading DLL failed with error %i: %s", err, msg); |
305 |
} |
306 |
} |
307 |
} |
308 |
|
309 |
// Limit cursor to Oni's window |
310 |
void DD_Patch_ClipCursor() |
311 |
{ |
312 |
// LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. |
313 |
DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); |
314 |
|
315 |
// LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. |
316 |
DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); |
317 |
|
318 |
// LIrTermiante: replace LIrPlatform_Terminate call with our hook. |
319 |
DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); |
320 |
} |
321 |
|
322 |
// Disables weapon cooldown exploit |
323 |
void DD_Patch_CooldownTimer() |
324 |
{ |
325 |
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 }; |
326 |
DDrPatch_Const ((char*)(OniExe + 0x0011a825), cooldown_patch); |
327 |
} |
328 |
|
329 |
// Daodan device mode enumeration function |
330 |
void DD_Patch_DaodanDisplayEnum() |
331 |
{ |
332 |
DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes); |
333 |
} |
334 |
|
335 |
// Adds new BSL functions |
336 |
void DD_Patch_DaodanInit() |
337 |
{ |
338 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init); |
339 |
} |
340 |
|
341 |
// Forced DirectInput (for Windows NT) |
342 |
void DD_Patch_DirectInput() |
343 |
{ |
344 |
DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb); |
345 |
} |
346 |
|
347 |
// Disable Oni's command line parser so it doesn't interfere with ours |
348 |
void DD_Patch_DisableCmdLine() |
349 |
{ |
350 |
// Replace start of OniParseCommandLine with XOR ax,ax; RET |
351 |
// DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366); |
352 |
// Replace start of OniParseCommandLine with XOR eax,eax; RET |
353 |
DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0x00c3c033); |
354 |
} |
355 |
|
356 |
// Font texture cache doubled |
357 |
void DD_Patch_FontTextureCache() |
358 |
{ |
359 |
DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20); |
360 |
DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40); |
361 |
} |
362 |
|
363 |
// Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own) |
364 |
void DD_Patch_GetCmdLine() |
365 |
{ |
366 |
DDrPatch_NOOP ((char*)(OniExe + 0x000d3280), 51); |
367 |
} |
368 |
|
369 |
// Allow HD screens with resolution < 1024*768 |
370 |
void DD_Patch_HDScreens_LowRes() |
371 |
{ |
372 |
DDrPatch_MakeJump((void*)M3rDraw_BigBitmap, (void*)DD_M3rDraw_BigBitmap); |
373 |
} |
374 |
|
375 |
void DD_Patch_HighresConsole() { |
376 |
Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize); |
377 |
} |
378 |
|
379 |
// Hackish fix for Konoko not kicking guns |
380 |
// Don't use this, it breaks stairs. |
381 |
void DD_Patch_KickGuns() |
382 |
{ |
383 |
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 }; |
384 |
DDrPatch_Const ((char*)(OniExe + 0x000dc420), kickgun_patch); |
385 |
} |
386 |
|
387 |
// Disable loading the vtuneapi.dll |
388 |
void DD_Patch_KillVTune() |
389 |
{ |
390 |
DDrPatch_Byte ((char*)(OniExe + 0x00026340), 0xC3); |
391 |
} |
392 |
|
393 |
// Now supports textures up to 512x512 |
394 |
void DD_Patch_LargeTextures() |
395 |
{ |
396 |
DDrPatch_Byte ((char*)(OniExe + 0x00005251), 0x10); |
397 |
} |
398 |
|
399 |
// Non-"_Final" levels are now valid |
400 |
void DD_Patch_LevelPlugins() |
401 |
{ |
402 |
DDrPatch_Byte ((char*)(OniExe + 0x000206a8), 0x01); |
403 |
} |
404 |
|
405 |
// Weapon on ground shown with name and magazine contents |
406 |
void DD_Patch_NewWeap() |
407 |
{ |
408 |
//Makes it always say "Received weapon_name." |
409 |
//Needs check for loc_4DFC66 |
410 |
//DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2); |
411 |
|
412 |
//Adds Weapon name and ammo meter to pickup autoprompt |
413 |
DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9); |
414 |
DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5); |
415 |
DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message); |
416 |
|
417 |
//Moves location of colors |
418 |
//DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors ); |
419 |
//DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors ); |
420 |
} |
421 |
|
422 |
// Disable Multi-byte character awareness patch (multiple language support) |
423 |
void DD_Patch_NoMultiByte() |
424 |
{ |
425 |
DDrPatch_Byte ((char*)(OniExe + 0x0002d8f8), 0xeb); |
426 |
DDrPatch_Byte ((char*)(OniExe + 0x0002d9ad), 0xeb); |
427 |
DDrPatch_Byte ((char*)(OniExe + 0x0002dbe2), 0xeb); |
428 |
DDrPatch_Byte ((char*)(OniExe + 0x0002dec3), 0xeb); |
429 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e2ab), 0xeb); |
430 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e2c4), 0xeb); |
431 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e379), 0xeb); |
432 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e48c), 0xeb); |
433 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e4d0), 0xeb); |
434 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e4f4), 0xeb); |
435 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e646), 0xeb); |
436 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e695), 0xeb); |
437 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e944), 0xeb); |
438 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e95d), 0xeb); |
439 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e98e), 0xeb); |
440 |
DDrPatch_Byte ((char*)(OniExe + 0x0002e9dc), 0xeb); |
441 |
} |
442 |
|
443 |
// Fix options not visible in main menu when a game was started |
444 |
void DD_Patch_OptionsVisible() |
445 |
{ |
446 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton); |
447 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton); |
448 |
} |
449 |
|
450 |
// Unlocks particle action disabling/enabling bits for all events. (Will be |
451 |
// controlled by a command line switch when I figure out how to do that without |
452 |
// Win32 hacks.) |
453 |
void DD_Patch_ParticleDisableBit() |
454 |
{ |
455 |
DDrPatch_Int16 ((short*)(OniExe + 0x001b184), 0x9090); |
456 |
} |
457 |
|
458 |
// Pathfinding grid cache size x8 |
459 |
void DD_Patch_PathFinding() |
460 |
{ |
461 |
const unsigned char pathfinding[2] = {0x90 , 0xE9 }; |
462 |
DDrPatch_Byte ((char*)(OniExe + 0x0010b03b), 0x20); |
463 |
DDrPatch_Byte ((char*)(OniExe + 0x0010b04c), 0x20); |
464 |
|
465 |
//other stuff |
466 |
DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding); |
467 |
} |
468 |
|
469 |
// Projectile awareness fixed |
470 |
void DD_Patch_ProjAware() |
471 |
{ |
472 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c07c), 0x6c); |
473 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c080), 0x70); |
474 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c084), 0x74); |
475 |
DDrPatch_Byte ((char*)(OniExe + 0x0009c110), 0x6c); |
476 |
} |
477 |
|
478 |
// Safe startup message printer |
479 |
void DD_Patch_SafePrintf() |
480 |
{ |
481 |
DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage); |
482 |
} |
483 |
|
484 |
// Show all (also enemies') lasersights |
485 |
void DD_Patch_ShowAllLasersights() |
486 |
{ |
487 |
DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 ); |
488 |
} |
489 |
|
490 |
void DD_Patch_ShowTriggerVolumes() |
491 |
{ |
492 |
Oni_ONrMechanics_Register = DDrPatch_MakeDetour((void*)ONrMechanics_Register, (void*)DD_ONrMechanics_Register); |
493 |
Oni_ONrGameState_HandleUtilityInput = DDrPatch_MakeDetour((void*)ONrGameState_HandleUtilityInput, (void*)DD_ONrGameState_HandleUtilityInput); |
494 |
} |
495 |
|
496 |
// Experiment with allowing enemies to be thrown over railings |
497 |
void DD_Patch_Throwtest() |
498 |
{ |
499 |
const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; |
500 |
DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch); |
501 |
} |
502 |
|
503 |
// DaodanGL with windowed mode support |
504 |
void DD_Patch_UseDaodanGL() |
505 |
{ |
506 |
// LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect. |
507 |
DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6); |
508 |
DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect); |
509 |
|
510 |
// UUrWindow_GetSize: GetWindowRect -> GetClientRect. |
511 |
DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6); |
512 |
DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect); |
513 |
|
514 |
// LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates. |
515 |
DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6); |
516 |
DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos); |
517 |
|
518 |
// LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates. |
519 |
DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6); |
520 |
DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos); |
521 |
|
522 |
// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. |
523 |
DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6); |
524 |
DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos); |
525 |
|
526 |
// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. |
527 |
DDrPatch_NOOP((char*) OniExe + 0x00003349, 6); |
528 |
DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos); |
529 |
|
530 |
// Replace ONrPlatformInitialize. |
531 |
DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize); |
532 |
|
533 |
// Replace gl_platform_initialize. |
534 |
DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize); |
535 |
|
536 |
// Replace gl_platform_dispose. |
537 |
DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose); |
538 |
} |
539 |
|
540 |
// Performance patch |
541 |
void DD_Patch_UseGetTickCount() |
542 |
{ |
543 |
DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High); |
544 |
DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency); |
545 |
DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths); |
546 |
} |
547 |
|
548 |
// Adds working function for existing BSL command wp_fadetime, sets fade time to 4800 |
549 |
void DD_Patch_WpFadetime() |
550 |
{ |
551 |
// Makes wp_fadetime actually have a function |
552 |
const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 }; |
553 |
DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch); |
554 |
DDrPatch_Byte ((char*)(OniExe + 0x0011a560), 0x31); |
555 |
|
556 |
// Sets the fadetime to 4800 by default |
557 |
DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0); |
558 |
} |
559 |
|
560 |
// Disable gamma slider in options in windowed mode |
561 |
void DD_Patch_GammaSlider() |
562 |
{ |
563 |
DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange); |
564 |
} |
565 |
|
566 |
// Fix the warning print method |
567 |
void DD_Patch_PrintWarning() |
568 |
{ |
569 |
DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning); |
570 |
} |
571 |
|
572 |
//Fix crappy ai2_shownames |
573 |
void DD_Patch_ShowNames() |
574 |
{ |
575 |
//Set distance above head to 4.0 |
576 |
DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8); |
577 |
//texture height |
578 |
DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F ); |
579 |
//texture width |
580 |
DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 ); |
581 |
|
582 |
/* |
583 |
// Crashes game. |
584 |
//Set the text color to whatever we like ;) |
585 |
DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 ); |
586 |
DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B ); |
587 |
DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE ); |
588 |
|
589 |
DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), DD_Patch_DebugNameShadeHack); |
590 |
|
591 |
//Make the background black for additive blending |
592 |
DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), DD_Patch_DebugNameTextureInit ); |
593 |
*/ |
594 |
} |
595 |
|
596 |
/* |
597 |
void DD_Patch_ShowTriggerVolumes() |
598 |
{ |
599 |
DDrPatch_Int32((int*)(OniExe + 0x000cc9bb+4), (uint32_t)DD_OBJiTriggerVolume_Draw); |
600 |
} |
601 |
|
602 |
void DD_Patch_ShowFlags() |
603 |
{ |
604 |
DDrPatch_Int32((int*)(OniExe + 0x000c4ed4+4), (uint32_t)DD_OBJiFlag_Draw); |
605 |
} |
606 |
*/ |
607 |
|
608 |
bool DD_Patch_Init() |
609 |
{ |
610 |
STARTUPMESSAGE("Patching engine", 0); |
611 |
|
612 |
if (DDrConfig_GetOptOfType("patches.alttab", C_BOOL)->value.intBoolVal) |
613 |
DD_Patch_AltTab(); |
614 |
|
615 |
if (DDrConfig_GetOptOfType("patches.argb8888", C_BOOL)->value.intBoolVal) |
616 |
DD_Patch_ARGB8888(); |
617 |
|
618 |
if (DDrConfig_GetOptOfType("patches.binkplay", C_BOOL)->value.intBoolVal) |
619 |
DD_Patch_BinkPlay(); |
620 |
|
621 |
if (DDrConfig_GetOptOfType("patches.bsl", C_BOOL)->value.intBoolVal) |
622 |
DD_Patch_BSL(); |
623 |
|
624 |
if (DDrConfig_GetOptOfType("patches.cheater", C_BOOL)->value.intBoolVal) |
625 |
DD_Patch_Cheater(); |
626 |
|
627 |
if (DDrConfig_GetOptOfType("patches.cheatsenabled", C_BOOL)->value.intBoolVal) |
628 |
DD_Patch_CheatsEnabled(); |
629 |
|
630 |
if (DDrConfig_GetOptOfType("patches.cheattable", C_BOOL)->value.intBoolVal) |
631 |
DD_Patch_CheatTable(); |
632 |
|
633 |
if (DDrConfig_GetOptOfType("patches.chinese", C_BOOL)->value.intBoolVal) |
634 |
DD_Patch_Chinese(); |
635 |
|
636 |
if (DDrConfig_GetOptOfType("patches.clipcursor", C_BOOL)->value.intBoolVal) |
637 |
DD_Patch_ClipCursor(); |
638 |
|
639 |
if (DDrConfig_GetOptOfType("patches.cooldowntimer", C_BOOL)->value.intBoolVal) |
640 |
DD_Patch_CooldownTimer(); |
641 |
|
642 |
if (DDrConfig_GetOptOfType("patches.daodandisplayenum", C_BOOL)->value.intBoolVal) |
643 |
DD_Patch_DaodanDisplayEnum(); |
644 |
|
645 |
if (DDrConfig_GetOptOfType("patches.directinput", C_BOOL)->value.intBoolVal) |
646 |
DD_Patch_DirectInput(); |
647 |
|
648 |
if (DDrConfig_GetOptOfType("patches.disablecmdline", C_BOOL)->value.intBoolVal) |
649 |
DD_Patch_DisableCmdLine(); |
650 |
|
651 |
if (DDrConfig_GetOptOfType("patches.fonttexturecache", C_BOOL)->value.intBoolVal) |
652 |
DD_Patch_FontTextureCache(); |
653 |
|
654 |
if (DDrConfig_GetOptOfType("patches.getcmdline", C_BOOL)->value.intBoolVal) |
655 |
DD_Patch_GetCmdLine(); |
656 |
|
657 |
if (DDrConfig_GetOptOfType("patches.hdscreens_lowres", C_BOOL)->value.intBoolVal) |
658 |
DD_Patch_HDScreens_LowRes(); |
659 |
|
660 |
if (DDrConfig_GetOptOfType("patches.highres_console", C_BOOL)->value.intBoolVal) |
661 |
DD_Patch_HighresConsole(); |
662 |
|
663 |
if (DDrConfig_GetOptOfType("patches.kickguns", C_BOOL)->value.intBoolVal) |
664 |
DD_Patch_KickGuns(); |
665 |
|
666 |
//if (patch_killvtune) |
667 |
// DD_Patch_KillVTune(); |
668 |
|
669 |
if (DDrConfig_GetOptOfType("patches.largetextures", C_BOOL)->value.intBoolVal) |
670 |
DD_Patch_LargeTextures(); |
671 |
|
672 |
if (DDrConfig_GetOptOfType("patches.levelplugins", C_BOOL)->value.intBoolVal) |
673 |
DD_Patch_LevelPlugins(); |
674 |
|
675 |
if (DDrConfig_GetOptOfType("patches.newweap", C_BOOL)->value.intBoolVal) |
676 |
DD_Patch_NewWeap(); |
677 |
|
678 |
if (DDrConfig_GetOptOfType("patches.nomultibyte", C_BOOL)->value.intBoolVal) |
679 |
DD_Patch_NoMultiByte(); |
680 |
|
681 |
if (DDrConfig_GetOptOfType("patches.optionsvisible", C_BOOL)->value.intBoolVal) |
682 |
DD_Patch_OptionsVisible(); |
683 |
|
684 |
if (DDrConfig_GetOptOfType("patches.particledisablebit", C_BOOL)->value.intBoolVal) |
685 |
DD_Patch_ParticleDisableBit(); |
686 |
|
687 |
if (DDrConfig_GetOptOfType("patches.pathfinding", C_BOOL)->value.intBoolVal) |
688 |
DD_Patch_PathFinding(); |
689 |
|
690 |
if (DDrConfig_GetOptOfType("patches.projaware", C_BOOL)->value.intBoolVal) |
691 |
DD_Patch_ProjAware(); |
692 |
|
693 |
if (DDrConfig_GetOptOfType("patches.safeprintf", C_BOOL)->value.intBoolVal) |
694 |
DD_Patch_SafePrintf(); |
695 |
|
696 |
if (DDrConfig_GetOptOfType("patches.showalllasersights", C_BOOL)->value.intBoolVal) |
697 |
DD_Patch_ShowAllLasersights(); |
698 |
|
699 |
if (DDrConfig_GetOptOfType("patches.showtriggervolumes", C_BOOL)->value.intBoolVal) |
700 |
DD_Patch_ShowTriggerVolumes(); |
701 |
|
702 |
if (DDrConfig_GetOptOfType("patches.throwtest", C_BOOL)->value.intBoolVal) |
703 |
DD_Patch_Throwtest(); |
704 |
|
705 |
if (DDrConfig_GetOptOfType("patches.usedaodangl", C_BOOL)->value.intBoolVal) |
706 |
DD_Patch_UseDaodanGL(); |
707 |
|
708 |
if (DDrConfig_GetOptOfType("patches.usegettickcount", C_BOOL)->value.intBoolVal) |
709 |
DD_Patch_UseGetTickCount(); |
710 |
|
711 |
if (DDrConfig_GetOptOfType("patches.wpfadetime", C_BOOL)->value.intBoolVal) |
712 |
DD_Patch_WpFadetime(); |
713 |
|
714 |
|
715 |
DD_Patch_DaodanInit(); |
716 |
|
717 |
DD_Patch_GammaSlider(); |
718 |
|
719 |
DD_Patch_PrintWarning(); |
720 |
|
721 |
DD_Patch_ShowNames(); |
722 |
|
723 |
return true; |
724 |
} |
725 |
|