source: Daodan/src/Daodan_Config.c@ 981

Last change on this file since 981 was 894, checked in by alloc, 11 years ago

Daodan 3.5: Fix displaying screens larger than screen res

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