-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathfs.c
8101 lines (7317 loc) · 236 KB
/
fs.c
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
#include "quakedef.h"
#include "netinc.h"
//#define com_gamedir com__gamedir
#include <ctype.h>
#include <limits.h>
#include "fs.h"
#include "shader.h"
#ifdef _WIN32
#include "winquake.h"
#endif
#ifdef FTE_TARGET_WEB //for stuff that doesn't work right...
#define FORWEB(a,b) a
#else
#define FORWEB(a,b) b
#endif
#if !defined(HAVE_LEGACY) || !defined(HAVE_CLIENT)
#define ZFIXHACK
#elif defined(ANDROID) //on android, these numbers seem to be generating major weirdness, so disable these.
#define ZFIXHACK
#elif defined(FTE_TARGET_WEB) //on firefox (but not chrome or ie), these numbers seem to be generating major weirdness, so tone them down significantly by default.
#define ZFIXHACK "set r_polygonoffset_submodel_offset 1\nset r_polygonoffset_submodel_factor 0.05\n"
#else //many quake maps have hideous z-fighting. this provides a way to work around it, although the exact numbers are gpu and bitdepth dependant, and trying to fix it can actually break other things.
#define ZFIXHACK "set r_polygonoffset_submodel_offset 25\nset r_polygonoffset_submodel_factor 0.05\n"
#endif
/*ezquake cheats and compat*/
#define EZQUAKECOMPETITIVE "set ruleset_allow_fbmodels 1\nset sv_demoExtensions \"\"\n"
/*quake requires a few settings for compatibility*/
#define QRPCOMPAT "set cl_cursor_scale 0.2\nset cl_cursor_bias_x 7.5\nset cl_cursor_bias_y 0.8\n"
#define QUAKESPASMSUCKS "set mod_h2holey_bugged 1\n"
#define QUAKEOVERRIDES "set sv_listen_nq 2\n set v_gammainverted 1\nset cl_download_mapsrc \"https://maps.quakeworld.nu/all/\"\nset con_stayhidden 0\nset allow_download_pakcontents 2\nset allow_download_refpackages 0\nset r_meshpitch -1\nr_sprite_backfacing 1\nset sv_bigcoords \"\"\nmap_autoopenportals 1\n" "sv_port "STRINGIFY(PORT_QWSERVER)" "STRINGIFY(PORT_NQSERVER)"\n" ZFIXHACK EZQUAKECOMPETITIVE QUAKESPASMSUCKS
#define QCFG "//schemes quake qw\n" QUAKEOVERRIDES "set com_parseutf8 0\n" QRPCOMPAT
#define KEXCFG "//schemes quake_r2\n" QUAKEOVERRIDES "set com_parseutf8 1\nset campaign 0\nset net_enable_dtls 1\nset sv_mintic 0.016666667\nset sv_maxtic $sv_mintic\nset cl_netfps 60\n"
/*NetQuake reconfiguration, to make certain people feel more at home...*/
#define NQCFG "//disablehomedir 1\n//mainconfig ftenq\n" QCFG "cfg_save_auto 1\nset pm_bunnyfriction 1\nset sv_nqplayerphysics 1\nset cl_loopbackprotocol auto\ncl_sbar 1\nset plug_sbar 0\nset sv_port "STRINGIFY(PORT_NQSERVER)"\ncl_defaultport "STRINGIFY(PORT_NQSERVER)"\nset m_preset_chosen 1\nset vid_wait 1\nset cl_demoreel 1\n"
#define SPASMCFG NQCFG "fps_preset builtin_spasm\nset cl_demoreel 0\ncl_sbar 2\nset gl_load24bit 1\n"
#define FITZCFG NQCFG "fps_preset builtin_spasm\ncl_sbar 2\nset gl_load24bit 1\n"
#define TENEBRAECFG NQCFG "fps_preset builtin_tenebrae\n"
//nehahra has to be weird with its extra cvars, and buggy fullbrights.
#define NEHCFG QCFG "set nospr32 0\nset cutscene 1\nalias startmap_sp \"map nehstart\"\nr_fb_bmodels 0\nr_fb_models 0\n"
/*stuff that makes dp-only mods work a bit better*/
#define DPCOMPAT QCFG "gl_specular 1\nset _cl_playermodel \"\"\n set dpcompat_set 1\ndpcompat_console 1\nset dpcompat_corruptglobals 1\nset vid_pixelheight 1\nset dpcompat_set 1\nset dpcompat_console 1\nset r_particlesdesc effectinfo\n"
/*nexuiz/xonotic has a few quirks/annoyances...*/
#define NEXCFG DPCOMPAT "cl_loopbackprotocol dpp7\nset sv_listen_dp 1\nset sv_listen_qw 0\nset sv_listen_nq 0\nset dpcompat_nopreparse 1\nset sv_bigcoords 1\nset sv_maxairspeed \"30\"\nset sv_jumpvelocity 270\nset sv_mintic \"0.01\"\ncl_nolerp 0\n"
#define XONCFG NEXCFG "set qport $qport_\ncom_parseutf8 1\npr_fixbrokenqccarrays 2\nset pr_csqc_memsize 64m\nset pr_ssqc_memsize 96m\n"
/*some modern non-compat settings*/
#define DMFCFG "set com_parseutf8 1\npm_airstep 1\nsv_demoExtensions 1\n"
/*set some stuff so our regular qw client appears more like hexen2. sv_mintic must be 0.015 to 'fix' the ravenstaff so that its projectiles don't impact upon each other, or even 0.05 to exactly match the hardcoded assumptions in obj_push. There's maps that depend on a low framerate via waterjump framerate-dependance too.*/
#define HEX2CFG "//schemes hexen2\n" "set v_gammainverted 1\nset com_parseutf8 -1\nset gl_font gfx/hexen2\nset in_builtinkeymap 0\nset_calc cl_playerclass int (random * 5) + 1\nset cl_forwardspeed 200\nset cl_backspeed 200\ncl_sidespeed 225\nset sv_maxspeed 640\ncl_run 0\nset watervis 1\nset r_lavaalpha 1\nset r_lavastyle -2\nset r_wateralpha 0.5\nset sv_pupglow 1\ngl_shaftlight 0.5\nsv_mintic 0.05\nset r_meshpitch -1\nset r_meshroll -1\nr_sprite_backfacing 1\nset mod_warnmodels 0\nset cl_model_bobbing 1\nsv_sound_watersplash \"misc/hith2o.wav\"\nsv_sound_land \"fx/thngland.wav\"\nset sv_walkpitch 0\n"
/*yay q2!*/
#define Q2CFG "//schemes quake2\n" "set v_gammainverted 1\nset com_parseutf8 0\ncom_gamedirnativecode 1\nset sv_bigcoords 0\nsv_port "STRINGIFY(PORT_Q2SERVER)"\ncl_defaultport "STRINGIFY(PORT_Q2SERVER)"\n"
/*Q3's ui doesn't like empty model/headmodel/handicap cvars, even if the gamecode copes*/
#define Q3CFG "//schemes quake3\n" "set v_gammainverted 0\nset snd_ignorecueloops 1\nsetfl g_gametype 0 s\nset gl_clear 1\nset r_clearcolour 0 0 0\nset com_parseutf8 0\ngl_overbright "FORWEB("0","2")"\nseta model sarge\nseta headmodel sarge\nseta handicap 100\ncom_gamedirnativecode 1\nsv_port "STRINGIFY(PORT_Q3SERVER)"\ncl_defaultport "STRINGIFY(PORT_Q3SERVER)"\ncom_protocolversion 68\n"
//#define RMQCFG "sv_bigcoords 1\n"
#define HLCFG NULL
#ifndef UPDATEURL
#ifdef HAVE_SSL
#define UPDATEURL(g) "/downloadables.php?game=" #g
#else
#define UPDATEURL(g) NULL
#endif
#endif
#define QUAKEPROT "FTE-Quake DarkPlaces-Quake"
typedef struct {
const char *argname; //used if this was used as a parameter.
const char *exename; //used if the exe name contains this
const char *protocolname; //sent to the master server when this is the current gamemode (Typically set for DP compat).
const char *auniquefile[4]; //used if this file is relative from the gamedir. needs just one file
const char *customexec;
const char *dir[4];
const char *poshname; //Full name for the game.
const char *downloadsurl; //url to check for updates.
const char *needpackages; //package name(s) that are considered mandatory for this game to work.
const char *manifestfile; //contents of manifest file to use.
} gamemode_info_t;
static const gamemode_info_t gamemode_info[] = {
#ifdef GAME_SHORTNAME
#ifndef GAME_PROTOCOL
#define GAME_PROTOCOL DISTRIBUTION
#endif
#ifndef GAME_IDENTIFYINGFILES
#define GAME_IDENTIFYINGFILES NULL //
#endif
#ifndef GAME_DEFAULTCMDS
#define GAME_DEFAULTCMDS NULL //doesn't need anything
#endif
#ifndef GAME_BASEGAMES
#define GAME_BASEGAMES "data"
#endif
#ifndef GAME_FULLNAME
#define GAME_FULLNAME FULLENGINENAME
#endif
#ifndef GAME_MANIFESTUPDATE
#define GAME_MANIFESTUPDATE NULL
#endif
{"-"GAME_SHORTNAME, GAME_SHORTNAME, GAME_PROTOCOL, {GAME_IDENTIFYINGFILES}, GAME_DEFAULTCMDS, {GAME_BASEGAMES}, GAME_FULLNAME, NULL/*updateurl*/, NULL/*needpackages*/, GAME_MANIFESTUPDATE},
#endif
//note that there is no basic 'fte' gamemode, this is because we aim for network compatability. Darkplaces-Quake is the closest we get.
//this is to avoid having too many gamemodes anyway.
//mission packs should generally come after the main game to avoid prefering the main game. we violate this for hexen2 as the mission pack is mostly a superset.
//whereas the quake mission packs replace start.bsp making the original episodes unreachable.
//for quake, we also allow extracting all files from paks. some people think it loads faster that way or something.
#ifdef HAVE_LEGACY
//cmdline switch exename protocol name(dpmaster) identifying file exec dir1 dir2 dir3 dir(fte) full name
//use rerelease behaviours if we seem to be running from that dir.
{"-quake_rerel",NULL, "FTE-QuakeRerelease", {"QuakeEX.kpf"}, KEXCFG, {"id1", "*fte"}, "Quake Re-Release", UPDATEURL(Q1)},
//standard quake
{"-quake", "q1", QUAKEPROT, {"id1/pak0.pak","id1/quake.rc"},QCFG, {"id1", "qw", "*fte"}, "Quake", UPDATEURL(Q1)},
//alternative name, because fmf file install names are messy when a single name is used for registry install path.
{"-afterquake", NULL, "FTE-Quake", {"id1/pak0.pak", "id1/quake.rc"},QCFG, {"id1", "qw", "*fte"}, "AfterQuake", UPDATEURL(Q1), NULL},
//netquake-specific quake that avoids qw/ with its nquake fuckups, and disables nqisms
{"-netquake", NULL, QUAKEPROT, {"id1/pak0.pak","id1/quake.rc"},NQCFG, {"id1"}, "NetQuake", UPDATEURL(Q1)},
//common variant of fitzquake that includes its own special pak file in the basedir
{"-spasm", NULL, QUAKEPROT, {"quakespasm.pak"}, SPASMCFG,{"/id1"}, "FauxSpasm", UPDATEURL(Q1)},
//because we can. 'fps_preset spasm' is hopefully close enough...
{"-fitz", "nq", QUAKEPROT, {"id1/pak0.pak","id1/quake.rc"},FITZCFG,{"id1"}, "FauxFitz", UPDATEURL(Q1)},
//because we can
{"-tenebrae", NULL, QUAKEPROT, {"tenebrae/Pak0.pak","id1/quake.rc"},TENEBRAECFG,{"id1", "tenebrae"}, "FauxTenebrae", UPDATEURL(Q1)},
#if defined(Q2CLIENT) || defined(Q2SERVER)
//list quake2 before q1 missionpacks, to avoid confusion about rogue/pak0.pak
{"-quake2", "q2", "Quake2", {"baseq2/pak0.pak"}, Q2CFG, {"baseq2", "*fteq2"}, "Quake II", UPDATEURL(Q2)},
//mods of the above that should generally work.
{"-dday", "dday", "Quake2", {"dday/pak0.pak"}, Q2CFG, {"baseq2", "dday", "*fteq2"}, "D-Day: Normandy"},
#endif
//quake's mission packs technically have their own protocol (thanks to stat_items). copyrights mean its best to keep them separate, too.
{"-hipnotic", "hipnotic", "FTE-Hipnotic", {"hipnotic/pak0.pak","hipnotic/gfx.wad"},QCFG,{"id1" "qw", "hipnotic", "*fte"}, "Quake: Scourge of Armagon", UPDATEURL(Q1)},
{"-rogue", "rogue", "FTE-Rogue", {"rogue/pak0.pak","rogue/gfx.wad"},QCFG,{"id1", "qw", "rogue", "*fte"}, "Quake: Dissolution of Eternity", UPDATEURL(Q1)},
//various quake-dependant non-standalone mods that require hacks
//quoth needed an extra arg just to enable hipnotic hud drawing, it doesn't actually do anything weird, but most engines have a -quoth arg, so lets have one too.
{"-quoth", "quoth", "FTE-Quake", {"quoth/pak0.pak"}, QCFG, {"id1", "qw", "quoth", "*fte"}, "Quake: Quoth", UPDATEURL(Q1)},
{"-nehahra", "nehahra", "FTE-Quake", {"nehahra/pak0.pak"}, NEHCFG, {"id1", "qw", "nehahra", "*fte"}, "Quake: Seal Of Nehahra", UPDATEURL(Q1)},
//various quake-based standalone mods.
{"-librequake", "librequake","LibreQuake", {"lq1/pak0.pak","lq1/gfx.pk3","lq1/quake.rc"},QCFG, {"lq1"}, "LibreQuake", UPDATEURL(LQ)},
// {"-nexuiz", "nexuiz", "Nexuiz", {"nexuiz.exe"}, NEXCFG, {"data", "*ftedata"},"Nexuiz"},
// {"-xonotic", "xonotic", "Xonotic", {"data/xonotic-data.pk3dir",
// "data/xonotic-*data*.pk3"}, XONCFG, {"data", "*ftedata"},"Xonotic", UPDATEURL(Xonotic)},
// {"-spark", "spark", "Spark", {"base/src/progs.src",
// "base/qwprogs.dat",
// "base/pak0.pak"}, DMFCFG, {"base", }, "Spark"},
// {"-scouts", "scouts", "FTE-SJ", {"basesj/src/progs.src",
// "basesj/progs.dat",
// "basesj/pak0.pak"}, NULL, {"basesj", }, "Scouts Journey"},
// {"-rmq", "rmq", "RMQ", {NULL}, RMQCFG, {"id1", "qw", "rmq", "*fte" }, "Remake Quake"},
#ifdef HEXEN2
//hexen2's mission pack generally takes precedence if both are installed.
{"-portals", "h2mp", "FTE-H2MP", {"portals/hexen.rc",
"portals/pak3.pak"}, HEX2CFG,{"data1", "portals", "*fteh2"}, "Hexen II MP", UPDATEURL(H2)},
{"-hexen2", "hexen2", "FTE-Hexen2", {"data1/pak0.pak"}, HEX2CFG,{"data1", "*fteh2"}, "Hexen II", UPDATEURL(H2)},
#endif
#if defined(Q3CLIENT) || defined(Q3SERVER)
{"-quake3", "q3", "Quake3", {"baseq3/pak0.pk3"}, Q3CFG, {"baseq3", "*fteq3"}, "Quake III Arena", UPDATEURL(Q3), "fteplug_quake3"},
{"-quake3demo", "q3demo", "Quake3Demo", {"demoq3/pak0.pk3"}, Q3CFG, {"demoq3", "*fteq3"}, "Quake III Arena Demo", NULL, "fteplug_quake3"},
//the rest are not supported in any real way. maps-only mostly, if that
// {"-quake4", "q4", "FTE-Quake4", {"q4base/pak00.pk4"}, NULL, {"q4base", "*fteq4"}, "Quake 4"},
// {"-et", NULL, "FTE-EnemyTerritory", {"etmain/pak0.pk3"}, NULL, {"etmain", "*fteet"}, "Wolfenstein - Enemy Territory"},
// {"-jk2", "jk2", "FTE-JK2", {"base/assets0.pk3"}, NULL, {"base", "*ftejk2"}, "Jedi Knight II: Jedi Outcast"},
// {"-warsow", "warsow", "FTE-Warsow", {"basewsw/pak0.pk3"}, NULL, {"basewsw", "*ftewsw"}, "Warsow"},
#endif
#if !defined(QUAKETC) && !defined(MINIMAL)
// {"-doom", "doom", "FTE-Doom", {"doom.wad"}, NULL, {"*", "*ftedoom"},"Doom"},
// {"-doom2", "doom2", "FTE-Doom2", {"doom2.wad"}, NULL, {"*", "*ftedoom"},"Doom2"},
// {"-doom3", "doom3", "FTE-Doom3", {"doom3.wad"}, NULL, {"based3", "*ftedoom3"},"Doom3"},
//for the luls
// {"-diablo2", NULL, "FTE-Diablo2", {"d2music.mpq"}, NULL, {"*", "*fted2"}, "Diablo 2"},
#endif
/* maintained by FreeHL ~eukara */
{"-halflife", "halflife", "FTE-HalfLife", {"valve/liblist.gam"}, HLCFG, {"logos", "valve"}, "Half-Life", "https://www.frag-net.com/pkgs/list", "game_valve;fteplug_ffmpeg"},
#endif
{NULL}
};
void FS_BeginManifestUpdates(void);
static void QDECL fs_game_callback(cvar_t *var, char *oldvalue);
static void COM_InitHomedir(ftemanifest_t *man);
hashtable_t filesystemhash;
static qboolean com_fschanged = true, com_fsneedreload;
qboolean com_installer = false;
qboolean fs_readonly;
static searchpath_t *fs_allowfileuri;
int waitingformanifest;
static unsigned int fs_restarts;
void *fs_thread_mutex;
float fs_accessed_time; //timestamp of read (does not include flocates, which should normally happen via a cache).
static cvar_t com_fs_cache = CVARFD ("fs_cache", IFMINIMAL("2","1"), CVAR_ARCHIVE, "0: Do individual lookups.\n1: Scan all files for accelerated lookups. This provides a performance boost on windows and avoids case sensitivity issues on linux.\n2: like 1, but don't bother checking for external changes (avoiding the cost of rebuild the cache).");
static cvar_t fs_noreexec = CVARD ("fs_noreexec", "0", "Disables automatic re-execing configs on gamedir switches.\nThis means your cvar defaults etc may be from the wrong mod, and cfg_save will leave that stuff corrupted!");
static cvar_t cfg_reload_on_gamedir = CVAR ("cfg_reload_on_gamedir", "1");
static cvar_t fs_game = CVARAFCD ("fs_game"/*q3*/, "", "game"/*q2/qs*/, CVAR_NOSAVE|CVAR_NORESET, fs_game_callback, "Provided for Q2 compat. Contains the subdir of the current mod.");
static cvar_t fs_gamepath = CVARAFD ("fs_gamepath"/*q3ish*/, "", "fs_gamedir"/*q2*/, CVAR_NOUNSAFEEXPAND|CVAR_NOSET|CVAR_NOSAVE, "Provided for Q2/Q3 compat. System path of the active gamedir.");
static cvar_t fs_basepath = CVARAFD ("fs_basepath"/*q3*/, "", "fs_basedir"/*q2*/, CVAR_NOUNSAFEEXPAND|CVAR_NOSET|CVAR_NOSAVE, "Provided for Q2/Q3 compat. System path of the base directory.");
static cvar_t fs_homepath = CVARAFD ("fs_homepath"/*q3ish*/, "", "fs_homedir"/*q2ish*/, CVAR_NOUNSAFEEXPAND|CVAR_NOSET|CVAR_NOSAVE, "Provided for Q2/Q3 compat. System path of the base directory.");
static cvar_t dpcompat_ignoremodificationtimes = CVARAFD("fs_packageprioritisation", "1", "dpcompat_ignoremodificationtimes", CVAR_NOUNSAFEEXPAND|CVAR_NOSAVE, "Favours the package that is:\n0: Most recently modified\n1: Is alphabetically last (favour z over a, 9 over 0).");
#ifdef FTE_TARGET_WEB
cvar_t fs_dlURL = CVARAFD(/*ioq3*/"sv_dlURL", "", /*dp*/"sv_curl_defaulturl", CVAR_SERVERINFO|CVAR_NOSAVE, "Provides clients with an external url from which they can obtain pk3s/packages from an external http server instead of having to download over udp.");
#else
cvar_t fs_dlURL = CVARAFD(/*ioq3*/"sv_dlURL", "", /*dp*/"sv_curl_defaulturl", CVAR_SERVERINFO|CVAR_ARCHIVE, "Provides clients with an external url from which they can obtain pk3s/packages from an external http server instead of having to download over udp.");
#endif
int active_fs_cachetype;
static int fs_referencetype;
int fs_finds;
void COM_CheckRegistered (void);
void Mods_FlushModList(void);
static void FS_ReloadPackFilesFlags(unsigned int reloadflags);
static qboolean Sys_SteamHasFile(char *basepath, int basepathlen, char *steamdir, char *fname);
static void QDECL fs_game_callback(cvar_t *var, char *oldvalue)
{
static qboolean runaway = false;
char buf[MAX_OSPATH];
if (!strcmp(var->string, oldvalue))
return; //no change here.
if (runaway)
return; //ignore that
runaway = true;
Cmd_ExecuteString(va("gamedir %s\n", COM_QuotedString(var->string, buf, sizeof(buf), false)), RESTRICT_LOCAL);
runaway = false;
}
static struct
{
void *module;
const char *extension;
searchpathfuncs_t *(QDECL *OpenNew)(vfsfile_t *file, searchpathfuncs_t *parent, const char *filename, const char *desc, const char *prefix);
qboolean loadscan;
} searchpathformats[64];
int FS_RegisterFileSystemType(void *module, const char *extension, searchpathfuncs_t *(QDECL *OpenNew)(vfsfile_t *file, searchpathfuncs_t *parent, const char *filename, const char *desc, const char *prefix), qboolean loadscan)
{
unsigned int i;
for (i = 0; i < sizeof(searchpathformats)/sizeof(searchpathformats[0]); i++)
{
if (searchpathformats[i].extension && !strcmp(searchpathformats[i].extension, extension))
break; //extension match always replaces
if (!searchpathformats[i].extension && !searchpathformats[i].OpenNew)
break;
}
if (i == sizeof(searchpathformats)/sizeof(searchpathformats[0]))
return 0;
searchpathformats[i].module = module;
searchpathformats[i].extension = extension;
searchpathformats[i].OpenNew = OpenNew;
searchpathformats[i].loadscan = loadscan;
com_fschanged = true;
com_fsneedreload = true;
return i+1;
}
void FS_UnRegisterFileSystemType(int idx)
{
if ((unsigned int)(idx-1) >= sizeof(searchpathformats)/sizeof(searchpathformats[0]))
return;
searchpathformats[idx-1].OpenNew = NULL;
searchpathformats[idx-1].module = NULL;
com_fschanged = true;
com_fsneedreload = true;
//FS_Restart will be needed
}
void FS_UnRegisterFileSystemModule(void *module)
{
int i;
qboolean found = false;
if (!fs_thread_mutex || Sys_LockMutex(fs_thread_mutex))
{
for (i = 0; i < sizeof(searchpathformats)/sizeof(searchpathformats[0]); i++)
{
if (searchpathformats[i].module == module)
{
searchpathformats[i].extension = NULL;
searchpathformats[i].OpenNew = NULL;
searchpathformats[i].module = NULL;
found = true;
}
}
if (fs_thread_mutex)
{
Sys_UnlockMutex(fs_thread_mutex);
if (found)
{
Cmd_ExecuteString("fs_restart", RESTRICT_LOCAL);
}
}
}
}
char *VFS_GETS(vfsfile_t *vf, char *buffer, size_t buflen)
{
char in;
char *out = buffer;
size_t len;
if (buflen <= 1)
return NULL;
len = buflen-1;
while (len > 0)
{
if (VFS_READ(vf, &in, 1) != 1)
{
if (len == buflen-1)
return NULL;
*out = '\0';
return buffer;
}
if (in == '\n')
break;
*out++ = in;
len--;
}
*out = '\0';
//if there's a trailing \r, strip it.
if (out > buffer)
if (out[-1] == '\r')
out[-1] = 0;
return buffer;
}
void VARGS VFS_PRINTF(vfsfile_t *vf, const char *format, ...)
{
va_list argptr;
char string[1024];
va_start (argptr, format);
vsnprintf (string,sizeof(string)-1, format,argptr);
va_end (argptr);
VFS_PUTS(vf, string);
}
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT) && !defined(_XBOX)
//windows has a special helper function to handle legacy URIs.
#else
qboolean Sys_ResolveFileURL(const char *inurl, int inlen, char *out, int outlen)
{
const unsigned char *i = inurl, *inend = inurl+inlen;
unsigned char *o = out, *outend = out+outlen;
unsigned char hex;
//make sure its a file url...
if (inlen < 5 || strncmp(inurl, "file:", 5))
return false;
i += 5;
if (i+1 < inend && i[0] == '/' && i[1] == '/')
{ //has an authority field...
i+=2;
//except we don't support authorities other than ourself...
if (i >= inend || *i != '/')
return false; //must be an absolute path...
#ifdef _WIN32
i++; //on windows, (full)absolute paths start with a drive name...
#endif
}
else if (i < inend && i[0] == '/')
; // file:/foo (no authority)
else
return false;
//everything else must be percent-encoded
while (i < inend)
{
if (!*i || o == outend)
return false; //don't allow nulls...
else if (*i == '/' && i+1<inend && i[1] == '/')
return false; //two slashes is invalid (can be parent directory on some systems, or just buggy or weird)
else if (*i == '\\')
return false; //don't allow backslashes. they're meant to be percent-encoded anyway.
else if (*i == '%' && i+2<inend)
{
hex = 0;
if (i[1] >= 'A' && i[1] <= 'F')
hex += i[1]-'A'+10;
else if (i[1] >= 'a' && i[1] <= 'f')
hex += i[1]-'a'+10;
else if (i[1] >= '0' && i[1] <= '9')
hex += i[1]-'0';
else
{
*o++ = *i++;
continue;
}
hex <<= 4;
if (i[2] >= 'A' && i[2] <= 'F')
hex += i[2]-'A'+10;
else if (i[2] >= 'a' && i[2] <= 'f')
hex += i[2]-'a'+10;
else if (i[2] >= '0' && i[2] <= '9')
hex += i[2]-'0';
else
{
*o++ = *i++;
continue;
}
*o++ = hex;
i += 3;
}
else
*o++ = *i++;
}
if (o == outend)
return false;
*o = 0;
return true;
}
#endif
char gamedirfile[MAX_OSPATH];
static char pubgamedirfile[MAX_OSPATH]; //like gamedirfile, but not set to the fte-only paths
static searchpath_t *gameonly_homedir;
static searchpath_t *gameonly_gamedir;
char com_gamepath[MAX_OSPATH]; //c:\games\quake
char com_homepath[MAX_OSPATH]; //c:\users\foo\my docs\fte\quake
qboolean com_homepathenabled;
static qboolean com_homepathusable; //com_homepath is safe, even if not enabled.
//char com_configdir[MAX_OSPATH]; //homedir/fte/configs
int fs_hash_dups;
int fs_hash_files;
static const char *FS_GetCleanPath(const char *pattern, qboolean silent, char *outbuf, int outlen);
static void FS_RegisterDefaultFileSystems(void);
static void COM_CreatePath (char *path);
static ftemanifest_t *FS_ReadDefaultManifest(char *newbasedir, size_t newbasedirsize, qboolean fixedbasedir);
#define ENFORCEFOPENMODE(mode) {if (strcmp(mode, "r") && strcmp(mode, "w")/* && strcmp(mode, "rw")*/)Sys_Error("fs mode %s is not permitted here\n");}
//forget a manifest entirely.
void FS_Manifest_Free(ftemanifest_t *man)
{
int i, j;
if (!man)
return;
Z_Free(man->filename);
Z_Free(man->updateurl);
Z_Free(man->installation);
Z_Free(man->formalname);
#ifdef PACKAGEMANAGER
Z_Free(man->downloadsurl);
Z_Free(man->installupd);
#endif
Z_Free(man->mainconfig);
Z_Free(man->schemes);
Z_Free(man->protocolname);
Z_Free(man->eula);
Z_Free(man->defaultexec);
Z_Free(man->defaultoverrides);
Z_Free(man->basedir);
Z_Free(man->iconname);
for (i = 0; i < sizeof(man->gamepath) / sizeof(man->gamepath[0]); i++)
{
Z_Free(man->gamepath[i].path);
}
for (i = 0; i < sizeof(man->package) / sizeof(man->package[0]); i++)
{
Z_Free(man->package[i].path);
Z_Free(man->package[i].prefix);
Z_Free(man->package[i].condition);
Z_Free(man->package[i].sha512);
Z_Free(man->package[i].signature);
for (j = 0; j < sizeof(man->package[i].mirrors) / sizeof(man->package[i].mirrors[0]); j++)
Z_Free(man->package[i].mirrors[j]);
}
Z_Free(man);
}
//clone a manifest, so we can hack at it.
static ftemanifest_t *FS_Manifest_Clone(ftemanifest_t *oldm)
{
ftemanifest_t *newm;
int i, j;
newm = Z_Malloc(sizeof(*newm));
if (oldm->updateurl)
newm->updateurl = Z_StrDup(oldm->updateurl);
if (oldm->installation)
newm->installation = Z_StrDup(oldm->installation);
if (oldm->formalname)
newm->formalname = Z_StrDup(oldm->formalname);
#ifdef PACKAGEMANAGER
if (oldm->downloadsurl)
newm->downloadsurl = Z_StrDup(oldm->downloadsurl);
if (oldm->installupd)
newm->installupd = Z_StrDup(oldm->installupd);
#endif
if (oldm->schemes)
newm->schemes = Z_StrDup(oldm->schemes);
if (oldm->protocolname)
newm->protocolname = Z_StrDup(oldm->protocolname);
if (oldm->eula)
newm->eula = Z_StrDup(oldm->eula);
if (oldm->defaultexec)
newm->defaultexec = Z_StrDup(oldm->defaultexec);
if (oldm->defaultoverrides)
newm->defaultoverrides = Z_StrDup(oldm->defaultoverrides);
if (oldm->iconname)
newm->iconname = Z_StrDup(oldm->iconname);
if (oldm->basedir)
newm->basedir = Z_StrDup(oldm->basedir);
if (oldm->mainconfig)
newm->mainconfig = Z_StrDup(oldm->mainconfig);
newm->homedirtype = oldm->homedirtype;
for (i = 0; i < sizeof(newm->gamepath) / sizeof(newm->gamepath[0]); i++)
{
if (oldm->gamepath[i].path)
newm->gamepath[i].path = Z_StrDup(oldm->gamepath[i].path);
newm->gamepath[i].flags = oldm->gamepath[i].flags;
}
for (i = 0; i < sizeof(newm->package) / sizeof(newm->package[0]); i++)
{
newm->package[i].type = oldm->package[i].type;
newm->package[i].crc = oldm->package[i].crc;
newm->package[i].crcknown = oldm->package[i].crcknown;
if (oldm->package[i].path)
newm->package[i].path = Z_StrDup(oldm->package[i].path);
if (oldm->package[i].prefix)
newm->package[i].prefix = Z_StrDup(oldm->package[i].prefix);
if (oldm->package[i].condition)
newm->package[i].condition = Z_StrDup(oldm->package[i].condition);
if (oldm->package[i].sha512)
newm->package[i].sha512 = Z_StrDup(oldm->package[i].sha512);
if (oldm->package[i].signature)
newm->package[i].signature = Z_StrDup(oldm->package[i].signature);
newm->package[i].filesize = oldm->package[i].filesize;
for (j = 0; j < sizeof(newm->package[i].mirrors) / sizeof(newm->package[i].mirrors[0]); j++)
if (oldm->package[i].mirrors[j])
newm->package[i].mirrors[j] = Z_StrDup(oldm->package[i].mirrors[j]);
}
newm->security = oldm->security;
return newm;
}
static void FS_Manifest_Print(ftemanifest_t *man)
{
char buffer[65536];
int i, j;
if (man->updateurl)
Con_Printf("updateurl %s\n", COM_QuotedString(man->updateurl, buffer, sizeof(buffer), false));
if (man->eula)
Con_Printf("eula %s\n", COM_QuotedString(man->eula, buffer, sizeof(buffer), false));
if (man->installation)
Con_Printf("game %s\n", COM_QuotedString(man->installation, buffer, sizeof(buffer), false));
if (man->formalname)
Con_Printf("name %s\n", COM_QuotedString(man->formalname, buffer, sizeof(buffer), false));
if (man->mainconfig)
Con_Printf("mainconfig %s\n", COM_QuotedString(man->mainconfig, buffer, sizeof(buffer), false));
#ifdef PACKAGEMANAGER
if (man->downloadsurl)
Con_Printf("downloadsurl %s\n", COM_QuotedString(man->downloadsurl, buffer, sizeof(buffer), false));
if (man->installupd)
Con_Printf("install %s\n", COM_QuotedString(man->installupd, buffer, sizeof(buffer), false));
#endif
if (man->schemes)
Con_Printf("schemes %s\n", COM_QuotedString(man->schemes, buffer, sizeof(buffer), false));
if (man->protocolname)
Con_Printf("protocolname %s\n", COM_QuotedString(man->protocolname, buffer, sizeof(buffer), false));
if (man->defaultexec)
{
char *s = buffer, *e;
for (s = man->defaultexec; *s; s = e)
{
e = strchr(s, '\n');
if (e)
{
*e = 0;
Con_Printf("-%s\n", s);
*e++ = '\n';
}
else
{
Con_Printf("-%s\n", s);
e = s+strlen(s);
}
}
//Con_Printf("defaultexec %s\n", COM_QuotedString(man->defaultexec, buffer, sizeof(buffer), false));
}
if (man->defaultoverrides)
{
char *s = buffer, *e;
for (s = man->defaultoverrides; *s; s = e)
{
e = strchr(s, '\n');
if (e)
{
*e = 0;
Con_Printf("+%s\n", s);
*e++ = '\n';
}
else
{
Con_Printf("+%s\n", s);
e = s+strlen(s);
}
}
//Con_Printf("%s", man->defaultoverrides);
}
if (man->iconname)
Con_Printf("icon %s\n", COM_QuotedString(man->iconname, buffer, sizeof(buffer), false));
if (man->basedir)
Con_Printf("basedir %s\n", COM_QuotedString(man->basedir, buffer, sizeof(buffer), false));
for (i = 0; i < sizeof(man->gamepath) / sizeof(man->gamepath[0]); i++)
{
if (man->gamepath[i].path)
{
char *str = va("%s%s%s",
(man->gamepath[i].flags & GAMEDIR_QSHACK)?"/":"",
(man->gamepath[i].flags & GAMEDIR_PRIVATE)?"*":"",
man->gamepath[i].path);
if (man->gamepath[i].flags & GAMEDIR_BASEGAME)
Con_Printf("basegame %s\n", COM_QuotedString(str, buffer, sizeof(buffer), false));
else
Con_Printf("gamedir %s\n", COM_QuotedString(str, buffer, sizeof(buffer), false));
}
}
for (i = 0; i < sizeof(man->package) / sizeof(man->package[0]); i++)
{
if (man->package[i].path)
{
if (man->package[i].type == mdt_installation)
Con_Printf("library ");
else
Con_Printf("package ");
Con_Printf("%s", COM_QuotedString(man->package[i].path, buffer, sizeof(buffer), false));
if (man->package[i].prefix)
Con_Printf(" prefix %s", COM_QuotedString(man->package[i].prefix, buffer, sizeof(buffer), false));
if (man->package[i].condition)
Con_Printf(" condition %s", COM_QuotedString(man->package[i].condition, buffer, sizeof(buffer), false));
if (man->package[i].filesize)
Con_Printf(" filesize %"PRIuQOFS, man->package[i].filesize);
if (man->package[i].sha512)
Con_Printf(" sha512 %s", COM_QuotedString(man->package[i].sha512, buffer, sizeof(buffer), false));
if (man->package[i].signature)
Con_Printf(" signature %s", COM_QuotedString(man->package[i].signature, buffer, sizeof(buffer), false));
if (man->package[i].crcknown)
Con_Printf(" crc 0x%x", man->package[i].crc);
for (j = 0; j < sizeof(man->package[i].mirrors) / sizeof(man->package[i].mirrors[0]); j++)
if (man->package[i].mirrors[j])
Con_Printf(" %s", COM_QuotedString(man->package[i].mirrors[j], buffer, sizeof(buffer), false));
Con_Printf("\n");
}
}
}
//forget any mod dirs.
static void FS_Manifest_PurgeGamedirs(ftemanifest_t *man)
{
int i;
if (man->filename)
Z_Free(man->filename);
man->filename = NULL;
for (i = 0; i < sizeof(man->gamepath) / sizeof(man->gamepath[0]); i++)
{
if (man->gamepath[i].path && !(man->gamepath[i].flags&GAMEDIR_BASEGAME))
{
Z_Free(man->gamepath[i].path);
man->gamepath[i].path = NULL;
//FIXME: remove packages from the removed paths.
}
}
}
//create a new empty manifest with default values.
static ftemanifest_t *FS_Manifest_Create(const char *syspath, const char *basedir)
{
ftemanifest_t *man = Z_Malloc(sizeof(*man));
if (syspath)
{
char base[MAX_QPATH];
COM_FileBase(syspath, base, sizeof(base));
if (*base && Q_strcasecmp(base, "default"))
man->formalname = Z_StrDup(base);
}
#ifdef _DEBUG //FOR TEMPORARY TESTING ONLY.
// man->doinstall = true;
#endif
if (syspath)
man->filename = Z_StrDup(syspath); //this should be a system path.
if (basedir)
man->basedir = Z_StrDup(basedir); //this should be a system path.
#ifdef QUAKETC
man->mainconfig = Z_StrDup("config.cfg");
#else
man->mainconfig = Z_StrDup("fte.cfg");
#endif
return man;
}
static qboolean FS_Manifest_ParsePackage(ftemanifest_t *man, int packagetype)
{
//CMD [deparch] packagename qhash [archivedfilename] [prefix skip/this/] [mirror url] [[filesize foo] [sha512 hash] [signature "base64"]]
char *path = "";
unsigned int crc = 0;
qboolean crcknown = false;
char *legacyextractname = NULL;
char *condition = NULL;
char *prefix = NULL;
char *arch = NULL;
char *signature = NULL;
char *sha512 = NULL;
qofs_t filesize = 0;
unsigned int arg = 1;
unsigned int mirrors = 0;
char *mirror[countof(man->package[0].mirrors)];
size_t i, j;
char *a;
a = Cmd_Argv(0);
if (!Q_strcasecmp(a, "filedependancies") || !Q_strcasecmp(a, "archiveddependancies"))
arch = Cmd_Argv(arg++);
path = Cmd_Argv(arg++);
#ifdef HAVE_LEGACY
a = Cmd_Argv(arg);
if (!strcmp(a, "-"))
{
arg++;
}
else if (*a)
{
crc = strtoul(a, &a, 0);
if (!*a)
{
crcknown = true;
arg++;
}
}
if (!strncmp(Cmd_Argv(0), "archived", 8))
legacyextractname = Cmd_Argv(arg++);
#endif
while (arg < Cmd_Argc())
{
a = Cmd_Argv(arg++);
if (!strcmp(a, "crc"))
{
crcknown = true;
crc = strtoul(Cmd_Argv(arg++), NULL, 0);
}
else if (!strcmp(a, "condition"))
condition = Cmd_Argv(arg++);
else if (!strcmp(a, "prefix"))
prefix = Cmd_Argv(arg++);
else if (!strcmp(a, "arch"))
arch = Cmd_Argv(arg++);
else if (!strcmp(a, "signature"))
signature = Cmd_Argv(arg++);
else if (!strcmp(a, "sha512"))
sha512 = Cmd_Argv(arg++);
else if (!strcmp(a, "filesize")||!strcmp(a, "size"))
filesize = strtoull(Cmd_Argv(arg++), NULL, 0);
else if (!strcmp(a, "mirror"))
{
a = Cmd_Argv(arg++);
goto mirror; //oo evil.
}
else if (strchr(a, ':') || man->parsever < 1)
{
mirror:
if (mirrors == countof(mirror))
Con_Printf("too many mirrors for package %s\n", path);
else if (legacyextractname)
{
if (!strcmp(legacyextractname, "xz") || !strcmp(legacyextractname, "gz"))
mirror[mirrors++] = Z_StrDupf("%s:%s", legacyextractname, a);
else
mirror[mirrors++] = Z_StrDupf("unzip:%s,%s", legacyextractname, a);
}
else
mirror[mirrors++] = Z_StrDup(a);
}
else if (man->parsever <= MANIFEST_CURRENTVER)
Con_Printf("unknown mirror / property %s for package %s\n", a, path);
}
for (i = 0; i < countof(man->package); i++)
{
if (!man->package[i].path)
{
if (packagetype == mdt_singlepackage && (!strchr(path, '/') || strchr(path, ':') || strchr(path, '\\')))
{
Con_Printf("invalid package path specified in manifest (%s)\n", path);
break;
}
if (arch)
{
#ifdef PLATFORM
if (Q_strcasecmp(PLATFORM, arch))
#endif
break;
}
man->package[i].type = packagetype;
man->package[i].path = Z_StrDup(path);
man->package[i].prefix = prefix?Z_StrDup(prefix):NULL;
man->package[i].condition = condition?Z_StrDup(condition):NULL;
man->package[i].sha512 = sha512?Z_StrDup(sha512):NULL;
man->package[i].signature = signature?Z_StrDup(signature):NULL;
man->package[i].filesize = filesize;
man->package[i].crcknown = crcknown;
man->package[i].crc = crc;
for (j = 0; j < mirrors; j++)
man->package[i].mirrors[j] = mirror[j];
return true;
}
}
if (i == countof(man->package))
Con_Printf("Too many packages specified in manifest\n");
for (j = 0; j < mirrors; j++)
Z_Free(mirror[j]);
return false;
}
qboolean FS_GamedirIsOkay(const char *path)
{
char tmp[MAX_QPATH];
if (!*path || strchr(path, '\n') || strchr(path, '\r') || !strcmp(path, ".") || !strcmp(path, "..") || strchr(path, ':') || strchr(path, '/') || strchr(path, '\\') || strchr(path, '$'))
{
Con_Printf("Illegal path specified: %s\n", path);
return false;
}
//don't allow leading dots, hidden files are evil.
//don't allow complex paths. those are evil too.
if (!*path || *path == '.' || !strcmp(path, ".") || strstr(path, "..") || strstr(path, "/")
|| strstr(path, "\\") || strstr(path, ":") || strstr(path, "\""))
{
Con_Printf ("Gamedir should be a single filename, not \"%s\"\n", path);
return false;
}
//some gamedirs should never be used for actual games/mods. Reject them.
if (!Q_strncasecmp(path, "downloads", 9) || //QI stuff uses this for arbitrary downloads. it doesn't make sense as a gamedir.
!Q_strncasecmp(path, "docs", 4) || //don't pollute this
!Q_strncasecmp(path, "help", 4) || //don't pollute this
!Q_strncasecmp(path, "bin", 3) || //if scripts try executing stuff here then we want to make extra sure that we don't allow writing anything within it.
!Q_strncasecmp(path, "lib", 3)) //same deal
{
Con_Printf ("Gamedir should not be \"%s\"\n", path);
return false;
}
//this checks for system-specific entries.
if (!FS_GetCleanPath(path, true, tmp, sizeof(tmp)))
{
Con_Printf ("Gamedir should not be \"%s\"\n", path);
return false;
}
return true;
}
//parse Cmd_Argv tokens into the manifest.
static qboolean FS_Manifest_ParseTokens(ftemanifest_t *man)
{
qboolean result = true;
char *cmd = Cmd_Argv(0);
if (!*cmd)
return result;
if (*cmd == '*')
cmd++;
if (!Q_strcasecmp(cmd, "ftemanifestver") || !Q_strcasecmp(cmd, "ftemanifest"))
man->parsever = atoi(Cmd_Argv(1));
else if (!Q_strcasecmp(cmd, "minver"))
{
//ignore minimum versions for other engines.
if (!strcmp(Cmd_Argv(2), DISTRIBUTION))
man->minver = atoi(Cmd_Argv(3));
}
else if (!Q_strcasecmp(cmd, "maxver"))
{
//ignore minimum versions for other engines.
if (!strcmp(Cmd_Argv(2), DISTRIBUTION))
man->maxver = atoi(Cmd_Argv(3));
}
else if (!Q_strcasecmp(cmd, "game"))
{
Z_Free(man->installation);
man->installation = Z_StrDup(Cmd_Argv(1));
}
else if (!Q_strcasecmp(cmd, "name"))
{
Z_Free(man->formalname);
man->formalname = Z_StrDup(Cmd_Argv(1));
}
else if (!Q_strcasecmp(cmd, "eula"))
{
Z_Free(man->eula);
man->eula = Z_StrDup(Cmd_Argv(1));
}
#ifdef PACKAGEMANAGER
else if (!Q_strcasecmp(cmd, "downloadsurl"))
{
if (man->downloadsurl)
Z_StrCat(&man->downloadsurl, " ");
Z_StrCat(&man->downloadsurl, Cmd_Argv(1));
}
else if (!Q_strcasecmp(cmd, "install"))
{
if (man->installupd)
Z_StrCat(&man->installupd, va(";%s", Cmd_Argv(1)));
else
man->installupd = Z_StrDup(Cmd_Argv(1));
}
#endif
else if (!Q_strcasecmp(cmd, "schemes"))
{
int i;
Z_Free(man->schemes);
man->schemes = Z_StrDup(Cmd_Argv(1));
for (i = 2; i < Cmd_Argc(); i++)
Z_StrCat(&man->schemes, va(" %s", Cmd_Argv(i)));
}
else if (!Q_strcasecmp(cmd, "protocolname"))
{
Z_Free(man->protocolname);
man->protocolname = Z_StrDup(Cmd_Argv(1));
}
else if (!Q_strcasecmp(cmd, "mainconfig"))
{
Z_Free(man->mainconfig);
if (strcmp(".cfg", COM_GetFileExtension(Cmd_Argv(1),NULL)))
man->mainconfig = Z_StrDupf("%s.cfg", Cmd_Argv(1));
else
man->mainconfig = Z_StrDup(Cmd_Argv(1));
}
else if (!Q_strcasecmp(cmd, "defaultexec"))
{
Z_Free(man->defaultexec);
man->defaultexec = Z_StrDup(Cmd_Argv(1));
}
else if (!Q_strcasecmp(cmd, "-bind") || !Q_strcasecmp(cmd, "-set") || !Q_strcasecmp(cmd, "-seta") || !Q_strcasecmp(cmd, "-alias") || !Q_strncasecmp(cmd, "-", 1))
{
Z_StrCat(&man->defaultexec, va("%s %s\n", Cmd_Argv(0)+1, Cmd_Args()));