source: Daodan/src/Daodan_Config.c@ 868

Last change on this file since 868 was 843, checked in by alloc, 12 years ago

Daodan:

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