1 |
#include <windows.h> |
2 |
#include <string.h> |
3 |
|
4 |
#include "Daodan_Cheater.h" |
5 |
#include "Daodan_Config.h" |
6 |
#include "Daodan_Patch.h" |
7 |
#include "Daodan_Utility.h" |
8 |
|
9 |
#include "Oni_Symbols.h" |
10 |
|
11 |
#include "Inifile_Reader.h" |
12 |
|
13 |
bool patch_alttab = true; |
14 |
bool patch_argb8888 = true; |
15 |
bool patch_binkplay = true; |
16 |
bool patch_bsl = true; |
17 |
bool patch_cheater = true; |
18 |
bool patch_cheatsenabled = true; |
19 |
bool patch_cheattable = true; |
20 |
bool patch_clipcursor = true; |
21 |
bool patch_cooldowntimer = true; |
22 |
bool patch_daodandisplayenum = true; |
23 |
bool patch_directinput = true; |
24 |
bool patch_disablecmdline = true; |
25 |
bool patch_flatline = true; |
26 |
bool patch_fonttexturecache = true; |
27 |
bool patch_getcmdline = true; |
28 |
bool patch_hdscreens_lowres = true; |
29 |
bool patch_highres_console = true; |
30 |
bool patch_kickguns = false; |
31 |
bool patch_killvtune = true; |
32 |
bool patch_largetextures = true; |
33 |
bool patch_levelplugins = true; |
34 |
bool patch_newweapon = true; |
35 |
bool patch_nomultibyte = true; |
36 |
bool patch_optionsvisible = true; |
37 |
bool patch_particledisablebit = false; |
38 |
bool patch_pathfinding = true; |
39 |
bool patch_projaware = true; |
40 |
bool patch_safeprintf = true; |
41 |
bool patch_showalllasersights = false; |
42 |
bool patch_throwtest = false; |
43 |
bool patch_usedaodangl = true; |
44 |
bool patch_usegettickcount = true; |
45 |
bool patch_wpfadetime = true; |
46 |
|
47 |
bool opt_border = true; |
48 |
bool opt_gamma = true; |
49 |
bool opt_topmost = false; |
50 |
bool opt_usedaodanbsl = true; |
51 |
|
52 |
bool patch_chinese = true; |
53 |
|
54 |
|
55 |
enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section; |
56 |
|
57 |
bool DDrIniCallback(char* section, bool newsection, char* name, char* value) |
58 |
{ |
59 |
if (newsection) |
60 |
{ |
61 |
if (!_stricmp(section, "options")) |
62 |
ini_section = s_options; |
63 |
else if (!_stricmp(section, "patch")) |
64 |
ini_section = s_patch; |
65 |
else if (!_stricmp(section, "bsl")) |
66 |
ini_section = s_bsl; |
67 |
else if (!_stricmp(section, "language")) |
68 |
ini_section = s_language; |
69 |
else |
70 |
{ |
71 |
ini_section = s_unknown; |
72 |
DDrStartupMessage("Daodan: Unrecognised ini section \"%s\"", section); |
73 |
} |
74 |
} |
75 |
|
76 |
switch (ini_section) |
77 |
{ |
78 |
case s_options: |
79 |
if (!_stricmp(name, "border")) |
80 |
opt_border = !_stricmp(inifile_cleanstr(value), "true"); |
81 |
else if (!_stricmp(name, "debug")) |
82 |
AKgDebug_DebugMaps = !_stricmp(inifile_cleanstr(value), "true"); |
83 |
else if (!_stricmp(name, "debugfiles")) |
84 |
BFgDebugFileEnable = !_stricmp(inifile_cleanstr(value), "true"); |
85 |
else if (!_stricmp(name, "findsounds")) |
86 |
SSgSearchOnDisk = !_stricmp(inifile_cleanstr(value), "true"); |
87 |
else if (!_stricmp(name, "gamma")) |
88 |
opt_gamma = !_stricmp(inifile_cleanstr(value), "true"); |
89 |
else if (!_stricmp(name, "ignore_private_data")) |
90 |
opt_ignore_private_data = !_stricmp(inifile_cleanstr(value), "true"); |
91 |
else if (!_stricmp(name, "nomultibyte")) |
92 |
patch_nomultibyte = !_stricmp(inifile_cleanstr(value), "true"); |
93 |
else if (!_stricmp(name, "sound")) |
94 |
opt_sound = !_stricmp(inifile_cleanstr(value), "true"); |
95 |
else if (!_stricmp(name, "switch")) |
96 |
M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true"); |
97 |
else if (!_stricmp(name, "topmost")) |
98 |
opt_topmost = !_stricmp(inifile_cleanstr(value), "true"); |
99 |
else if (!_stricmp(name, "usedaodanbsl")) |
100 |
opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true"); |
101 |
else |
102 |
DDrStartupMessage("Daodan: Unrecognised ini option \"%s\"", name); |
103 |
break; |
104 |
case s_patch: |
105 |
if (!_stricmp(name, "alttab")) |
106 |
patch_alttab = !_stricmp(inifile_cleanstr(value), "true"); |
107 |
else if (!_stricmp(name, "argb8888")) |
108 |
patch_argb8888 = !_stricmp(inifile_cleanstr(value), "true"); |
109 |
else if (!_stricmp(name, "binkplay")) |
110 |
patch_binkplay = !_stricmp(inifile_cleanstr(value), "true"); |
111 |
else if (!_stricmp(name, "bsl")) |
112 |
patch_bsl = !_stricmp(inifile_cleanstr(value), "true"); |
113 |
else if (!_stricmp(name, "cheater")) |
114 |
patch_cheater = !_stricmp(inifile_cleanstr(value), "true"); |
115 |
else if (!_stricmp(name, "cheatsenabled")) |
116 |
patch_cheatsenabled = !_stricmp(inifile_cleanstr(value), "true"); |
117 |
else if (!_stricmp(name, "cheattable")) |
118 |
patch_cheattable = !_stricmp(inifile_cleanstr(value), "true"); |
119 |
else if (!_stricmp(name, "clipcursor")) |
120 |
patch_clipcursor = !_stricmp(inifile_cleanstr(value), "true"); |
121 |
else if (!_stricmp(name, "cooldowntimer")) |
122 |
patch_cooldowntimer = !_stricmp(inifile_cleanstr(value), "true"); |
123 |
else if (!_stricmp(name, "daodandisplayenum")) |
124 |
patch_daodandisplayenum = !_stricmp(inifile_cleanstr(value), "true"); |
125 |
else if (!_stricmp(name, "directinput")) |
126 |
patch_directinput = !_stricmp(inifile_cleanstr(value), "true"); |
127 |
else if (!_stricmp(name, "disablecmdline")) |
128 |
patch_disablecmdline = !_stricmp(inifile_cleanstr(value), "true"); |
129 |
else if (!_stricmp(name, "flatline")) |
130 |
patch_flatline = !_stricmp(inifile_cleanstr(value), "true"); |
131 |
else if (!_stricmp(name, "fonttexturecache")) |
132 |
patch_fonttexturecache = !_stricmp(inifile_cleanstr(value), "true"); |
133 |
else if (!_stricmp(name, "getcmdline")) |
134 |
patch_getcmdline = !_stricmp(inifile_cleanstr(value), "true"); |
135 |
else if (!_stricmp(name, "hdscreens_lowres")) |
136 |
patch_hdscreens_lowres = !_stricmp(inifile_cleanstr(value), "true"); |
137 |
else if (!_stricmp(name, "highres_console")) |
138 |
patch_highres_console = !_stricmp(inifile_cleanstr(value), "true"); |
139 |
else if (!_stricmp(name, "kickguns")) |
140 |
patch_kickguns = !_stricmp(inifile_cleanstr(value), "true"); |
141 |
else if (!_stricmp(name, "killvtune")) |
142 |
patch_killvtune = !_stricmp(inifile_cleanstr(value), "true"); |
143 |
else if (!_stricmp(name, "largetextures")) |
144 |
patch_largetextures = !_stricmp(inifile_cleanstr(value), "true"); |
145 |
else if (!_stricmp(name, "levelplugins")) |
146 |
patch_levelplugins = !_stricmp(inifile_cleanstr(value), "true"); |
147 |
else if (!_stricmp(name, "nomultibyte")) |
148 |
patch_nomultibyte = !_stricmp(inifile_cleanstr(value), "true"); |
149 |
else if (!_stricmp(name, "newweap")) |
150 |
patch_newweapon = !_stricmp(inifile_cleanstr(value), "true"); |
151 |
else if (!_stricmp(name, "optionsvisible")) |
152 |
patch_optionsvisible = !_stricmp(inifile_cleanstr(value), "true"); |
153 |
else if (!_stricmp(name, "particledisablebit")) |
154 |
patch_particledisablebit = !_stricmp(inifile_cleanstr(value), "true"); |
155 |
else if (!_stricmp(name, "pathfinding")) |
156 |
patch_pathfinding = !_stricmp(inifile_cleanstr(value), "true"); |
157 |
else if (!_stricmp(name, "projaware")) |
158 |
patch_projaware = !_stricmp(inifile_cleanstr(value), "true"); |
159 |
else if (!_stricmp(name, "safeprintf")) |
160 |
patch_safeprintf = !_stricmp(inifile_cleanstr(value), "true"); |
161 |
else if (!_stricmp(name, "showalllasersights")) |
162 |
patch_showalllasersights = !_stricmp(inifile_cleanstr(value), "true"); |
163 |
else if (!_stricmp(name, "throwtest")) |
164 |
patch_throwtest = !_stricmp(inifile_cleanstr(value), "true"); |
165 |
else if (!_stricmp(name, "usedaodangl")) |
166 |
patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true"); |
167 |
else if (!_stricmp(name, "usegettickcount")) |
168 |
patch_usegettickcount = !_stricmp(inifile_cleanstr(value), "true"); |
169 |
else if (!_stricmp(name, "wpfadetime")) |
170 |
patch_wpfadetime = !_stricmp(inifile_cleanstr(value), "true"); |
171 |
else |
172 |
DDrStartupMessage("Daodan: Unrecognised ini patch \"%s\"", name); |
173 |
break; |
174 |
case s_language: |
175 |
if (!_stricmp(name, "chinese")) |
176 |
patch_chinese = !_stricmp(inifile_cleanstr(value), "true"); |
177 |
else if (!_stricmp(name, "blam")) |
178 |
DDrPatch__strdup((int*)(OniExe + 0x0010fb73), value); |
179 |
else if (!_stricmp(name, "damn")) |
180 |
DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value); |
181 |
else if (!_stricmp(name, "savepoint")) |
182 |
{ |
183 |
char* str = _strdup(value); |
184 |
DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str); |
185 |
DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str); |
186 |
} |
187 |
else if (!_stricmp(name, "syndicatewarehouse")) |
188 |
{ |
189 |
char* str = _strdup(value); |
190 |
DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str); |
191 |
DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str); |
192 |
} |
193 |
else if (!_stricmp(name, "shapeshifter_on")) |
194 |
DDr_CheatTable[0].message_on = _strdup(value); |
195 |
else if (!_stricmp(name, "shapeshifter_off")) |
196 |
DDr_CheatTable[0].message_off = _strdup(value); |
197 |
else if (!_stricmp(name, "liveforever_on")) |
198 |
DDr_CheatTable[1].message_on = _strdup(value); |
199 |
else if (!_stricmp(name, "liveforever_off")) |
200 |
DDr_CheatTable[1].message_off = _strdup(value); |
201 |
else if (!_stricmp(name, "touchofdeath_on")) |
202 |
DDr_CheatTable[2].message_on = _strdup(value); |
203 |
else if (!_stricmp(name, "touchofdeath_off")) |
204 |
DDr_CheatTable[2].message_off = _strdup(value); |
205 |
else if (!_stricmp(name, "canttouchthis_on")) |
206 |
DDr_CheatTable[3].message_on = _strdup(value); |
207 |
else if (!_stricmp(name, "canttouchthis_off")) |
208 |
DDr_CheatTable[3].message_off = _strdup(value); |
209 |
else if (!_stricmp(name, "fatloot_on")) |
210 |
DDr_CheatTable[4].message_on = _strdup(value); |
211 |
else if (!_stricmp(name, "glassworld_on")) |
212 |
DDr_CheatTable[5].message_on = _strdup(value); |
213 |
else if (!_stricmp(name, "glassworld_off")) |
214 |
DDr_CheatTable[5].message_off = _strdup(value); |
215 |
else if (!_stricmp(name, "winlevel_on")) |
216 |
DDr_CheatTable[6].message_on = _strdup(value); |
217 |
else if (!_stricmp(name, "loselevel_on")) |
218 |
DDr_CheatTable[7].message_on = _strdup(value); |
219 |
else if (!_stricmp(name, "bighead_on")) |
220 |
DDr_CheatTable[8].message_on = _strdup(value); |
221 |
else if (!_stricmp(name, "bighead_off")) |
222 |
DDr_CheatTable[8].message_off = _strdup(value); |
223 |
else if (!_stricmp(name, "minime_on")) |
224 |
DDr_CheatTable[9].message_on = _strdup(value); |
225 |
else if (!_stricmp(name, "minime_off")) |
226 |
DDr_CheatTable[9].message_off = _strdup(value); |
227 |
else if (!_stricmp(name, "superammo_on")) |
228 |
DDr_CheatTable[10].message_on = _strdup(value); |
229 |
else if (!_stricmp(name, "superammo_off")) |
230 |
DDr_CheatTable[10].message_off = _strdup(value); |
231 |
else if (!_stricmp(name, "devmode_on")) |
232 |
{ |
233 |
char* str = _strdup(value); |
234 |
DDr_CheatTable[11].message_on = str; |
235 |
DDr_CheatTable[cheat_x].message_on = str; |
236 |
} |
237 |
else if (!_stricmp(name, "devmode_off")) |
238 |
{ |
239 |
char* str = _strdup(value); |
240 |
DDr_CheatTable[11].message_off = str; |
241 |
DDr_CheatTable[cheat_x].message_off = str; |
242 |
} |
243 |
else if (!_stricmp(name, "reservoirdogs_on")) |
244 |
DDr_CheatTable[12].message_on = _strdup(value); |
245 |
else if (!_stricmp(name, "reservoirdogs_off")) |
246 |
DDr_CheatTable[12].message_off = _strdup(value); |
247 |
else if (!_stricmp(name, "roughjustice_on")) |
248 |
DDr_CheatTable[13].message_on = _strdup(value); |
249 |
else if (!_stricmp(name, "roughjustice_off")) |
250 |
DDr_CheatTable[13].message_off = _strdup(value); |
251 |
else if (!_stricmp(name, "chenille_on")) |
252 |
DDr_CheatTable[14].message_on = _strdup(value); |
253 |
else if (!_stricmp(name, "chenille_off")) |
254 |
DDr_CheatTable[14].message_off = _strdup(value); |
255 |
else if (!_stricmp(name, "behemoth_on")) |
256 |
DDr_CheatTable[15].message_on = _strdup(value); |
257 |
else if (!_stricmp(name, "behemoth_off")) |
258 |
DDr_CheatTable[15].message_off = _strdup(value); |
259 |
else if (!_stricmp(name, "elderrune_on")) |
260 |
DDr_CheatTable[16].message_on = _strdup(value); |
261 |
else if (!_stricmp(name, "elderrune_off")) |
262 |
DDr_CheatTable[16].message_off = _strdup(value); |
263 |
else if (!_stricmp(name, "moonshadow_on")) |
264 |
DDr_CheatTable[17].message_on = _strdup(value); |
265 |
else if (!_stricmp(name, "moonshadow_off")) |
266 |
DDr_CheatTable[17].message_off = _strdup(value); |
267 |
else if (!_stricmp(name, "munitionfrenzy_on")) |
268 |
DDr_CheatTable[18].message_on = _strdup(value); |
269 |
else if (!_stricmp(name, "fistsoflegend_on")) |
270 |
DDr_CheatTable[19].message_on = _strdup(value); |
271 |
else if (!_stricmp(name, "fistsoflegend_off")) |
272 |
DDr_CheatTable[19].message_off = _strdup(value); |
273 |
else if (!_stricmp(name, "killmequick_on")) |
274 |
DDr_CheatTable[20].message_on = _strdup(value); |
275 |
else if (!_stricmp(name, "killmequick_off")) |
276 |
DDr_CheatTable[20].message_off = _strdup(value); |
277 |
else if (!_stricmp(name, "carousel_on")) |
278 |
DDr_CheatTable[21].message_on = _strdup(value); |
279 |
else if (!_stricmp(name, "carousel_off")) |
280 |
DDr_CheatTable[21].message_off = _strdup(value); |
281 |
else |
282 |
DDrStartupMessage("Daodan: Unrecognised ini language item \"%s\"", name); |
283 |
break; |
284 |
case s_bsl: |
285 |
default: |
286 |
break; |
287 |
} |
288 |
|
289 |
return true; |
290 |
} |
291 |
|
292 |
void DDrConfig(int argc, char* argv[]) |
293 |
{ |
294 |
int i; |
295 |
char* section; |
296 |
char* option; |
297 |
bool falseoption; |
298 |
|
299 |
|
300 |
// Tell Oni to not load non levelX_final-files by default: |
301 |
opt_ignore_private_data = false; |
302 |
|
303 |
// Enable sound by default: |
304 |
opt_sound = true; |
305 |
|
306 |
|
307 |
if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES) |
308 |
{ |
309 |
FILE* fp; |
310 |
DDrStartupMessage("Daodan: daodan.ini doesn't exist, creating"); |
311 |
fp = fopen("daodan.ini", "w"); |
312 |
if (fp) |
313 |
{ |
314 |
fputs("[Options]\n", fp); |
315 |
fputs("[Patch]\n", fp); |
316 |
fputs("[BSL]\n", fp); |
317 |
fputs("[Language]\n", fp); |
318 |
fclose(fp); |
319 |
} |
320 |
} |
321 |
|
322 |
DDrStartupMessage("Daodan: Parsing daodan.ini..."); |
323 |
if (!inifile_read("daodan.ini", DDrIniCallback)) |
324 |
DDrStartupMessage("Daodan: Error reading daodan.ini, check your syntax!"); |
325 |
DDrStartupMessage("Daodan: Finished parsing"); |
326 |
|
327 |
|
328 |
|
329 |
DDrStartupMessage("Daodan: Parsing command line..."); |
330 |
for (i = 1; i < argc; i ++) |
331 |
{ |
332 |
if (argv[i][0] == '-') |
333 |
{ |
334 |
section = argv[i] + 1; |
335 |
if ((option = strchr(argv[i], '.'))) |
336 |
{ |
337 |
*option = '\0'; |
338 |
falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] == 'o' || option[2] == 'O'); |
339 |
if (i < (argc - 1) && argv[i + 1][0] != '-') |
340 |
DDrIniCallback(section, true, option + 1, argv[++i]); |
341 |
else |
342 |
DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true")); |
343 |
*option = '.'; |
344 |
} |
345 |
else |
346 |
{ |
347 |
falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] == 'o' || section[1] == 'O'); |
348 |
ini_section = s_options; |
349 |
if (i < (argc - 1) && argv[i + 1][0] != '-') |
350 |
DDrIniCallback(NULL, false, section, argv[++i]); |
351 |
else |
352 |
DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true")); |
353 |
} |
354 |
} |
355 |
else |
356 |
{ |
357 |
DDrStartupMessage("Daodan: Parse error \"%s\"", argv[i]); |
358 |
break; |
359 |
} |
360 |
} |
361 |
DDrStartupMessage("Daodan: Finished parsing"); |
362 |
} |
363 |
|