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