GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — UZDoom/src/gameconfigfile.cpp at trunk · UZDoom/UZDoom

Expand file tree

/

gameconfigfile.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
1159 lines (1036 loc) · 31 KB
/

gameconfigfile.cpp

Copy path

File metadata and controls

1159 lines (1036 loc) · 31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** gameconfigfile.cpp
**
** An .ini parser specifically for zdoom.ini
**
**---------------------------------------------------------------------------
**
** Copyright 1998-2016 Marisa Heit
** Copyright 2007-2016 Christoph Oelckers
** Copyright 2017-2025 GZDoom Maintainers and Contributors
** Copyright 2025-2026 UZDoom Maintainers and Contributors
**
** SPDX-License-Identifier: GPL-3.0-or-later
**
**---------------------------------------------------------------------------
**
** Code written prior to 2026 is also licensed under:
**
** SPDX-License-Identifier: BSD-3-Clause
**
**---------------------------------------------------------------------------
**
*/
#include <stdio.h>
#include "c_bind.h"
#include "c_cvars.h"
#include "c_dispatch.h"
#include "colorspace.h"
#include "cmdlib.h"
#include "d_main.h"
#include "doomstat.h"
#include "gameconfigfile.h"
#include "gi.h"
#include "i_specialpaths.h"
#include "m_argv.h"
#include "m_joy.h"
#include "m_misc.h"
#include "printf.h"
#include "v_font.h"
#include "v_video.h"
#include "version.h"
#include "zstring.h"
using Color::str;
#if !defined _MSC_VER && !defined __APPLE__
#include "i_system.h" // for SHARE_DIR
#endif // !_MSC_VER && !__APPLE__
EXTERN_CVAR (Bool, con_centernotify)
EXTERN_CVAR (Int, msg0color)
EXTERN_CVAR (Color, color)
EXTERN_CVAR (Float, dimamount)
EXTERN_CVAR (Int, msgmidcolor)
EXTERN_CVAR (Int, msgmidcolor2)
EXTERN_CVAR (Bool, snd_pitched)
EXTERN_CVAR (Color, am_wallcolor)
EXTERN_CVAR (Color, am_fdwallcolor)
EXTERN_CVAR (Color, am_cdwallcolor)
EXTERN_CVAR (Bool, wi_percents)
EXTERN_CVAR (Int, gl_texture_hqresizemode)
EXTERN_CVAR (Int, gl_texture_hqresizemult)
EXTERN_CVAR (Int, vid_preferbackend)
EXTERN_CVAR (Float, vid_scale_custompixelaspect)
EXTERN_CVAR (Bool, vid_scale_linear)
EXTERN_CVAR (Float, m_sensitivity_x)
EXTERN_CVAR (Float, m_sensitivity_y)
EXTERN_CVAR (Int, adl_volume_model)
EXTERN_CVAR (Int, adl_chan_alloc)
EXTERN_CVAR (Bool, adl_auto_arpeggio)
EXTERN_CVAR (Int, opn_volume_model)
EXTERN_CVAR (Int, opn_chan_alloc)
EXTERN_CVAR (Bool, opn_auto_arpeggio)
EXTERN_CVAR (Int, gl_texture_hqresize_targets)
EXTERN_CVAR (Int, wipetype)
EXTERN_CVAR (Bool, i_pauseinbackground)
EXTERN_CVAR (Bool, i_soundinbackground)
EXTERN_CVAR (Bool, i_is_new_release)
EXTERN_CVAR (String, language)
#ifdef HAS_UPDATER
EXTERN_CVAR(Int, updater_update_interval)
#endif
FARG(config, "Configuration", "Specifies an alternative configuration file to use.", "configfile",
"Causes " GAMENAME " to use an alternative configuration file. If configfile does not exist,"
" it will be created.");
#ifdef _WIN32
EXTERN_CVAR (Int, in_mouse)
#endif
enum ResetBinds
{
V226GamePad = 1 << 0,
V230Gamma = 1 << 1,
};
static TArray<FString> DefaultSearchPaths;
static void CollectDefaultSearchPaths()
{
if (DefaultSearchPaths.Size() > 0)
{
// already done
return;
}
#ifdef __APPLE__
FString user_docs, user_app_support, local_app_support;
M_GetMacSearchDirectories(user_docs, user_app_support, local_app_support);
#endif
#if defined(__HAIKU__) || ( defined(__unix__) && !defined(__APPLE__) )
# ifdef __HAIKU__
# define DEFAULT_SHARE_DIR "/boot/system/data"
# else
# define DEFAULT_SHARE_DIR "/usr/local/share"
# endif
bool shareDirChanged = 0 != strcmp(SHARE_DIR, DEFAULT_SHARE_DIR);
FString dataDir = GetDataPath();
#endif
#ifdef __APPLE__
DefaultSearchPaths.Push(user_docs);
DefaultSearchPaths.Push(user_app_support);
DefaultSearchPaths.Push(local_app_support);
DefaultSearchPaths.Push("$PROGDIR");
#elif !defined(__unix__) && !defined(__HAIKU__)
DefaultSearchPaths.Push("$HOME");
DefaultSearchPaths.Push("$PROGDIR");
#else
static FString GameDirs[] = {
"/games/" GAMENAMELOWERCASE,
"/games/doom",
"/doom"
};
DefaultSearchPaths.Push("$PROGDIR");
for (unsigned int i = 0; i < std::size(GameDirs); i++)
{
DefaultSearchPaths.Push(dataDir + GameDirs[i]);
DefaultSearchPaths.Push(SHARE_DIR + GameDirs[i]);
if (shareDirChanged)
{
DefaultSearchPaths.Push(DEFAULT_SHARE_DIR + GameDirs[i]);
}
# ifdef __HAIKU__
DefaultSearchPaths.Push("$HOME/config/data" + GameDirs[i]);
# else
DefaultSearchPaths.Push("/usr/share" + GameDirs[i]);
# endif
}
#endif
#ifdef DEFAULT_SHARE_DIR
# undef DEFAULT_SHARE_DIR
#endif
}
FGameConfigFile::FGameConfigFile ()
{
FString pathname;
OkayToWrite = false; // Do not allow saving of the config before DoGlobalSetup()
QueueWrite = false;
bModSetup = false;
bGameSetup = false;
bKeySetup = false;
bResetBindFlags = 0;
pathname = GetConfigPath (true);
ChangePathName (pathname.GetChars());
LoadConfigFile ();
// If zdoom.ini was read from the program directory, switch
// to the user directory now. If it was read from the user
// directory, this effectively does nothing.
pathname = GetConfigPath (false);
ChangePathName (pathname.GetChars());
CollectDefaultSearchPaths();
// LASTRUN < 227: convert GZDoom ini's by ensuring all
// system paths have the corresponding UZDoom version
// already present
GameLastRunVer = 0;
EngineLastRunVer = 0;
if (SetSection ("LastRun"))
{
const char *lastver = GetValueForKey ("Version");
if (lastver != NULL)
{
EngineLastRunVer = atof(lastver);
}
}
if (EngineLastRunVer < 227)
{
if (SetSection("IWADSearch.Directories"))
{
for (unsigned int i = 0; i < DefaultSearchPaths.Size(); i++)
{
EnsureValueForKey ("Path", DefaultSearchPaths[i].GetChars());
}
}
if (SetSection("FileSearch.Directories"))
{
for (unsigned int i = 0; i < DefaultSearchPaths.Size(); i++)
{
EnsureValueForKey ("Path", DefaultSearchPaths[i].GetChars());
}
}
if (SetSection("SoundfontSearch.Directories"))
{
for (unsigned int i = 0; i < DefaultSearchPaths.Size(); i++)
{
EnsureValueForKey ("Path", (DefaultSearchPaths[i] + "/soundfonts").GetChars());
EnsureValueForKey ("Path", (DefaultSearchPaths[i] + "/fm_banks").GetChars());
}
}
}
// Set default IWAD search paths if none present
if (!SetSection ("IWADSearch.Directories"))
{
SetSection ("IWADSearch.Directories", true);
SetValueForKey ("Path", ".", true);
SetValueForKey ("Path", "$DOOMWADDIR", true);
SetValueForKey ("PathList", "$DOOMWADPATH", true);
for (unsigned int i = 0; i < DefaultSearchPaths.Size(); i++)
{
SetValueForKey ("Path", DefaultSearchPaths[i].GetChars(), true);
}
}
// Set default search paths if none present
if (!SetSection ("FileSearch.Directories"))
{
SetSection ("FileSearch.Directories", true);
SetValueForKey ("Path", "$DOOMWADDIR", true);
SetValueForKey ("PathList", "$DOOMWADPATH", true);
for (unsigned int i = 0; i < DefaultSearchPaths.Size(); i++)
{
SetValueForKey ("Path", DefaultSearchPaths[i].GetChars(), true);
}
}
// Set default search paths if none present
if (!SetSection("SoundfontSearch.Directories"))
{
SetSection("SoundfontSearch.Directories", true);
for (unsigned int i = 0; i < DefaultSearchPaths.Size(); i++)
{
SetValueForKey ("Path", (DefaultSearchPaths[i] + "/soundfonts").GetChars(), true);
SetValueForKey ("Path", (DefaultSearchPaths[i] + "/fm_banks").GetChars(), true);
}
}
#ifdef _WIN32
#define PATHSEP_STR "semicolon"
#else
#define PATHSEP_STR "colon"
#endif
SetSectionNote("IWADSearch.Directories",
// Add environment variable documentation.
"\n#### Environment Variable Information ####"
"\n#"
"\n# . references the current directory that UZDoom is launched from within"
"\n# your terminal or console."
"\n#"
"\n# $DOOMWADDIR references a system environment variable of the same name"
"\n# that contains a search directory."
"\n#"
"\n# $DOOMWADPATH references a system environment variable of the same name"
"\n# whose value contains a " PATHSEP_STR " delimited list of searchable directories."
"\n# It's *similar* to $DOOMWADDIR, except that $DOOMWADPATH is a list of"
"\n# possible search directories."
"\n#"
"\n# $HOME references your system user directory."
"\n#"
"\n# $PROGDIR references the directory that the main binary is located."
"\n#"
"\n# For more information and examples of how to use environment variables,"
"\n# please see: https://zdoom.org/wiki/Configuration_file#Environment_Variables"
"\n#"
"\n####\n\n" // Add a final newline before going back to the original section header text.
// Finish environment variable documentation.
"# These are the directories to automatically search for IWADs.\n"
"# Each directory should be on a separate line, preceded by Path=\n");
SetSectionNote("FileSearch.Directories",
"# These are the directories to search for wads added with the -file\n"
"# command line parameter, if they cannot be found with the path as-is.\n"
"# Layout is the same as for IWADSearch.Directories\n");
SetSectionNote("SoundfontSearch.Directories",
"# These are the directories to search for soundfonts that let listed in the menu.\n"
"# Layout is the same as for IWADSearch.Directories\n");
#undef PATHSEP_STR
}
FGameConfigFile::~FGameConfigFile ()
{
}
void FGameConfigFile::WriteCommentHeader (FileWriter *file) const
{
file->Printf ("# This file was generated by " GAMENAME " %s on %s\n", GetVersionString(), myasctime());
}
void FGameConfigFile::DoAutoloadSetup (FIWadManager *iwad_man)
{
// Create auto-load sections, so users know what's available.
// Note that this totem pole is the reverse of the order that
// they will appear in the file.
if (EngineLastRunVer < 211)
{
RenameSection("Chex3.Autoload", "chex.chex3.Autoload");
RenameSection("Chex1.Autoload", "chex.chex1.Autoload");
RenameSection("HexenDK.Autoload", "hexen.deathkings.Autoload");
RenameSection("HereticSR.Autoload", "heretic.shadow.Autoload");
RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload");
RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload");
RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload");
RenameSection("Freedoom.Autoload", "doom.freedoom.Autoload");
RenameSection("DoomBFG.Autoload", "doom.id.doom1.bfg.Autoload");
RenameSection("DoomU.Autoload", "doom.id.doom1.ultimate.Autoload");
RenameSection("Doom1.Autoload", "doom.id.doom1.registered.Autoload");
RenameSection("TNT.Autoload", "doom.id.doom2.tnt.Autoload");
RenameSection("Plutonia.Autoload", "doom.id.doom2.plutonia.Autoload");
RenameSection("Doom2BFG.Autoload", "doom.id.doom2.bfg.Autoload");
RenameSection("Doom2.Autoload", "doom.id.doom2.commercial.Autoload");
}
else if (EngineLastRunVer < 218)
{
RenameSection("doom.doom1.bfg.Autoload", "doom.id.doom1.bfg.Autoload");
RenameSection("doom.doom1.ultimate.Autoload", "doom.id.doom1.ultimate.Autoload");
RenameSection("doom.doom1.registered.Autoload", "doom.id.doom1.registered.Autoload");
RenameSection("doom.doom2.tnt.Autoload", "doom.id.doom2.tnt.Autoload");
RenameSection("doom.doom2.plutonia.Autoload", "doom.id.doom2.plutonia.Autoload");
RenameSection("doom.doom2.bfg.Autoload", "doom.id.doom2.bfg.Autoload");
RenameSection("doom.doom2.commercial.Autoload", "doom.id.doom2.commercial.Autoload");
}
const FString *pAuto;
for (int num = 0; (pAuto = iwad_man->GetAutoname(num)) != NULL; num++)
{
if (!(iwad_man->GetIWadFlags(num) & GI_SHAREWARE)) // we do not want autoload sections for shareware IWADs (which may have an autoname for resource filtering)
{
FString workname = *pAuto;
while (workname.IsNotEmpty())
{
FString section = workname + ".Autoload";
CreateSectionAtStart(section.GetChars());
auto dotpos = workname.LastIndexOf('.');
if (dotpos < 0) break;
workname.Truncate(dotpos);
}
}
}
CreateSectionAtStart("Global.Autoload");
// The same goes for auto-exec files.
CreateStandardAutoExec("Chex.AutoExec", true);
CreateStandardAutoExec("Strife.AutoExec", true);
CreateStandardAutoExec("Hexen.AutoExec", true);
CreateStandardAutoExec("Heretic.AutoExec", true);
CreateStandardAutoExec("Doom.AutoExec", true);
// Move search paths back to the top.
MoveSectionToStart("SoundfontSearch.Directories");
MoveSectionToStart("FileSearch.Directories");
MoveSectionToStart("IWADSearch.Directories");
SetSectionNote("Doom.AutoExec",
"# Files to automatically execute when running the corresponding game.\n"
"# Each file should be on its own line, preceded by Path=\n\n");
SetSectionNote("Global.Autoload",
"# WAD files to always load. These are loaded after the IWAD but before\n"
"# any files added with -file. Place each file on its own line, preceded\n"
"# by Path=\n");
SetSectionNote("Doom.Autoload",
"# Wad files to automatically load depending on the game and IWAD you are\n"
"# playing. You may have have files that are loaded for all similar IWADs\n"
"# (the game) and files that are only loaded for particular IWADs. For example,\n"
"# any files listed under 'doom.Autoload' will be loaded for any version of Doom,\n"
"# but files listed under 'doom.id.doom2.Autoload' will only load when you are\n"
"# playing a Doom 2 based game (doom2.wad, tnt.wad or plutonia.wad), and files\n"
"# listed under 'doom.id.doom2.commercial.Autoload' only when playing doom2.wad.\n\n");
}
void FGameConfigFile::DoGlobalSetup ()
{
if (SetSection ("GlobalSettings.Unknown"))
{
ReadCVars (CVAR_GLOBALCONFIG);
}
if (SetSection ("GlobalSettings"))
{
ReadCVars (CVAR_GLOBALCONFIG);
}
if (SetSection ("LastRun"))
{
const char *lastRelease = GetValueForKey ("Release");
i_is_new_release = !lastRelease || strcmp(VERSIONSTR, lastRelease) != 0;
FBaseCVar *var;
if (EngineLastRunVer < 207)
{ // Now that snd_midiprecache works again, you probably don't want it on.
var = FindCVar ("snd_midiprecache", NULL);
if (var != NULL) var->ResetToDefault();
}
if (EngineLastRunVer < 208)
{ // Weapon sections are no longer used, so tidy up the config by deleting them.
const char *name;
size_t namelen;
bool more;
more = SetFirstSection();
while (more)
{
name = GetCurrentSection();
if (name != NULL &&
(namelen = strlen(name)) > 12 &&
strcmp(name + namelen - 12, ".WeaponSlots") == 0)
{
more = DeleteCurrentSection();
}
else
{
more = SetNextSection();
}
}
}
if (EngineLastRunVer < 209)
{
// menu dimming is now a gameinfo option so switch user override off
var = FindCVar ("dimamount", NULL);
if (var != NULL) var->ResetToDefault ();
}
if (EngineLastRunVer < 210)
{
if (SetSection ("Hexen.Bindings"))
{
// These 2 were misnamed in earlier versions
SetValueForKey ("6", "use ArtiPork");
SetValueForKey ("5", "use ArtiInvulnerability2");
}
}
if (EngineLastRunVer < 213)
{
var = FindCVar("snd_channels", NULL);
if (var != NULL)
{
// old settings were default 32, minimum 8, new settings are default 128, minimum 8.
UCVarValue v = var->GetGenericRep(CVAR_Int);
if (v.Int < 8) var->ResetToDefault();
}
}
if (EngineLastRunVer < 214)
{
var = FindCVar("hud_scale", NULL);
if (var != NULL) var->ResetToDefault();
var = FindCVar("st_scale", NULL);
if (var != NULL) var->ResetToDefault();
var = FindCVar("hud_althudscale", NULL);
if (var != NULL) var->ResetToDefault();
var = FindCVar("con_scale", NULL);
if (var != NULL) var->ResetToDefault();
var = FindCVar("con_scaletext", NULL);
if (var != NULL) var->ResetToDefault();
var = FindCVar("uiscale", NULL);
if (var != NULL) var->ResetToDefault();
}
if (EngineLastRunVer < 215)
{
// Previously a true/false boolean. Now an on/off/auto tri-state with auto as the default.
var = FindCVar("snd_hrtf", NULL);
if (var != NULL) var->ResetToDefault();
}
if (EngineLastRunVer < 216)
{
var = FindCVar("gl_texture_hqresize", NULL);
if (var != NULL)
{
auto v = var->GetGenericRep(CVAR_Int);
switch (v.Int)
{
case 1:
gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 2;
break;
case 2:
gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 3;
break;
case 3:
gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 4;
break;
case 4:
gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 2;
break;
case 5:
gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 3;
break;
case 6:
gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 4;
break;
case 7:
gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 2;
break;
case 8:
gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 3;
break;
case 9:
gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 4;
break;
case 10:
gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 2;
break;
case 11:
gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 3;
break;
case 12:
gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 4;
break;
case 18:
gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 5;
break;
case 19:
gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 6;
break;
case 13:
gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 2;
break;
case 14:
gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 3;
break;
case 15:
gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 4;
break;
case 16:
gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 5;
break;
case 17:
gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 6;
break;
case 20:
gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 2;
break;
case 21:
gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 3;
break;
case 22:
gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 4;
break;
case 23:
gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 5;
break;
case 24:
gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 6;
break;
case 0:
default:
gl_texture_hqresizemode = 0; gl_texture_hqresizemult = 1;
break;
}
}
}
if (EngineLastRunVer < 217)
{
var = FindCVar("vid_scalemode", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Int), newvalue;
if (v.Int == 3) // 640x400
{
newvalue.Int = 2;
var->SetGenericRep(newvalue, CVAR_Int);
}
if (v.Int == 2) // 320x200
{
newvalue.Int = 6;
var->SetGenericRep(newvalue, CVAR_Int);
}
}
}
if (EngineLastRunVer < 219)
{
// 2019-12-06 - polybackend merge
// migrate vid_enablevulkan to vid_preferbackend
var = FindCVar("vid_enablevulkan", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Int);
vid_preferbackend = v.Int;
}
// 2019-12-31 - r_videoscale.cpp changes
var = FindCVar("vid_scale_customstretched", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Bool);
if (v.Bool)
vid_scale_custompixelaspect = 1.2f;
else
vid_scale_custompixelaspect = 1.0f;
}
var = FindCVar("vid_scalemode", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Int), newvalue;
switch (v.Int)
{
case 1:
newvalue.Int = 0;
var->SetGenericRep(newvalue, CVAR_Int);
[[fallthrough]];
case 3:
case 4:
vid_scale_linear = true;
break;
default:
vid_scale_linear = false;
break;
}
}
}
if (EngineLastRunVer < 220)
{
var = FindCVar("Gamma", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Float);
vid_gamma = v.Float;
}
var = FindCVar("fullscreen", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Bool);
vid_fullscreen = v.Float;
}
}
if (EngineLastRunVer < 221)
{
// Transfer the messed up mouse scaling config to something sane and consistent.
#ifndef _WIN32
double xfact = 3, yfact = 2;
#else
double xfact = in_mouse == 1? 1.5 : 4, yfact = 1;
#endif
var = FindCVar("m_noprescale", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Bool);
if (v.Bool) xfact = yfact = 1;
}
var = FindCVar("mouse_sensitivity", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Float);
xfact *= v.Float;
yfact *= v.Float;
}
m_sensitivity_x = (float)xfact;
m_sensitivity_y = (float)yfact;
adl_volume_model = 0;
adl_chan_alloc = -1;
adl_auto_arpeggio = false;
opn_volume_model = 0;
opn_chan_alloc = -1;
opn_auto_arpeggio = false;
// if user originally wanted the in-game textures resized, set model skins to resize too
int old_targets = gl_texture_hqresize_targets;
old_targets |= (old_targets & 1) ? 8 : 0;
gl_texture_hqresize_targets = old_targets;
}
if (EngineLastRunVer < 222)
{
var = FindCVar("mod_dumb_mastervolume", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Float);
v.Float /= 4.f;
if (v.Float < 1.f) v.Float = 1.f;
}
}
if (EngineLastRunVer < 223)
{
// ooooh boy did i open a can of worms with this one.
i_pauseinbackground = !(i_soundinbackground);
}
if (EngineLastRunVer < 224)
{
var = FindCVar("m_sensitivity_x", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Float);
v.Float *= 0.5f;
var->SetGenericRep(v, CVAR_Float);
}
}
if (EngineLastRunVer < 225)
{
var = FindCVar("gl_lightmode", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Int);
v.Int = v.Int == 16 ? 2 : v.Int == 8 ? 1 : 0;
var->SetGenericRep(v, CVAR_Int);
}
}
if (EngineLastRunVer < 230) // UZDoom 5.0
{
// Reset brightness related settings, as the values all mean something different now
AddCommandString("vid_reset2defaults");
}
if (EngineLastRunVer < 231) // UZDoom 5.0
{
language = "auto";
}
#ifdef HAS_UPDATER
if (EngineLastRunVer < 232) // UZDoom 5.0
{
if (updater_update_interval == 2) updater_update_interval = 1;
}
#endif
if (EngineLastRunVer < 233) // UZDoom 5.0
{
var = FindCVar("ui_theme", NULL);
if (var != NULL)
{
if (var->GetGenericRep(CVAR_Int).Int == 2)
{ // for a while the engine defaulted to 2 (light), not auto
var->ResetToDefault();
}
}
}
if(EngineLastRunVer < 234)
{
// Native fullscreen is now enabled by default, this is only used for MacOS.
var = FindCVar("vid_nativefullscreen", NULL);
if(var != NULL)
{
var->SetGenericRep(1, CVAR_Bool);
}
}
}
OkayToWrite = true;
if(QueueWrite)
{
M_SaveDefaults(NULL);
QueueWrite = false;
}
}
void FGameConfigFile::DoGameSetup(FString section)
{
const char *key;
const char *value;
GameLastRunVer = 0;
if (SetSection (section + ".LastRun"))
{
const char *lastver = GetValueForKey ("Version");
if (lastver != NULL) GameLastRunVer = atof(lastver);
}
if (SetSection (section + ".UnknownConsoleVariables"))
{
ReadCVars (0);
}
if (SetSection (section + ".ConfigOnlyVariables"))
{
ReadCVars (0);
}
if (SetSection (section + ".ConsoleVariables"))
{
ReadCVars (0);
}
if (gameinfo.gametype & GAME_Raven)
{
SetRavenDefaults (gameinfo.gametype == GAME_Hexen);
}
if (gameinfo.gametype & GAME_Strife)
{
SetStrifeDefaults ();
}
// The NetServerInfo section will be read and override anything loaded
// here when it's determined that a netgame is being played.
if (SetSection (section + ".LocalServerInfo"))
{
ReadCVars (0);
}
if (SetSection (section + ".Player"))
{
ReadCVars (0);
}
if (SetSection (section + ".ConsoleAliases"))
{
const char *name = NULL;
while (NextInSection (key, value))
{
if (stricmp (key, "Name") == 0)
{
name = value;
}
else if (stricmp (key, "Command") == 0 && name != NULL)
{
C_SetAlias (name, value);
name = NULL;
}
}
}
bGameSetup = true;
}
// Moved from DoGameSetup so that it can happen after wads are loaded
void FGameConfigFile::DoKeySetup(FString section)
{
assert(bGameSetup);
constexpr int numbindings = 3;
static const struct { const char *label; FKeyBindings *bindings; } binders[numbindings] =
{
{ ".Bindings", &Bindings },
{ ".DoubleBindings", &DoubleBindings },
{ ".AutomapBindings", &AutomapBindings }
};
const char *key, *value;
C_SetDefaultBindings ();
for (int i = 0; i < numbindings; ++i)
{
if (SetSection(section + binders[i].label))
{
FKeyBindings *bindings = binders[i].bindings;
bindings->UnbindAll();
while (NextInSection(key, value))
{
bindings->DoBind(key, value);
}
}
}
if (GameLastRunVer < 1)
{
// Multiple gamepad reworks were done during
// this version. There is not any particularly
// good way to transfer older settings, so we
// are just going to reset them completely.
TArray<IJoystickConfig *> sticks;
I_GetJoysticks(sticks);
// Reset analog stick settings
for (int joy = 0; joy < sticks.SSize(); joy++)
{
sticks[joy]->Reset();
}
// Reset digital binds
TArray<int> keys_to_reset;
keys_to_reset.Reserve(NUM_AXIS_CODES);
for (int i = 0; i < NUM_AXIS_CODES; i++)
{
keys_to_reset[i] = KeyAxisMapping[i];
}
C_SetDefaultBindings(&keys_to_reset);
}
if (GameLastRunVer < 1)
{
// swap binds
Bindings.UnbindACommand("bumpgamma");
Bindings.DefaultBind("F11", "bumplight");
}
bKeySetup = true;
}
// Like DoGameSetup(), but for mod-specific cvars.
// Called after CVARINFO has been parsed.
void FGameConfigFile::DoModSetup(FString section)
{
if(SetSection(section + ".Player.Mod"))
{
ReadCVars(CVAR_MOD|CVAR_USERINFO|CVAR_IGNORE);
}
if(SetSection(section + ".LocalServerInfo.Mod"))
{
ReadCVars (CVAR_MOD|CVAR_SERVERINFO|CVAR_IGNORE);
}
if(SetSection(section + ".ConfigOnlyVariables.Mod"))
{
ReadCVars (CVAR_MOD|CVAR_CONFIG_ONLY|CVAR_IGNORE);
}
// Signal that these sections should be rewritten when saving the config.
bModSetup = true;
}
// Read cvars from a cvar section of the ini. Flags are the flags to give
// to newly-created cvars that were not already defined.
void FGameConfigFile::ReadCVars(uint32_t flags)
{
const char *key, *value;
FBaseCVar *cvar;
UCVarValue val;
flags |= CVAR_ARCHIVE|CVAR_UNSETTABLE|CVAR_AUTO;
while (NextInSection (key, value))
{
cvar = FindCVar (key, NULL);
if (cvar == NULL)
{
cvar = new FStringCVar (key, NULL, flags);
}
val.String = const_cast<char *>(value);
cvar->SetGenericRep (val, CVAR_String);
}
}
void FGameConfigFile::ArchiveGameData(FString section)
{
if(!bGameSetup) return;
SetSection (section + ".LastRun", true);
ClearCurrentSection ();
SetValueForKey ("Version", GAMELASTRUNVERSION);
SetSection (section + ".Player", true);
ClearCurrentSection ();
C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_USERINFO);
if (bModSetup)
{
SetSection (section + ".Player.Mod", true);
ClearCurrentSection ();
C_ArchiveCVars (this, CVAR_MOD|CVAR_ARCHIVE|CVAR_AUTO|CVAR_USERINFO);
}
SetSection (section + ".ConsoleVariables", true);
ClearCurrentSection ();
C_ArchiveCVars (this, CVAR_ARCHIVE);
// Do not overwrite the serverinfo section if playing a netgame, and
// this machine was not the initial host.
if (!netgame || consoleplayer == 0)
{
SetSection (section + (netgame ? ".NetServerInfo" : ".LocalServerInfo"), true);
ClearCurrentSection ();
C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_SERVERINFO);
if (bModSetup)
{
SetSection (section + (netgame ? ".NetServerInfo.Mod" : ".LocalServerInfo.Mod"), true);
ClearCurrentSection ();
C_ArchiveCVars (this, CVAR_MOD|CVAR_ARCHIVE|CVAR_AUTO|CVAR_SERVERINFO);
}
}
SetSection (section + ".ConfigOnlyVariables", true);
ClearCurrentSection ();
C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_AUTO|CVAR_CONFIG_ONLY);
if (bModSetup)
View remainder of file in raw view
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.