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