]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/config.qc
Update default video settings
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / config.qc
1 #include "config.qh"
2 #if defined(CSQC)
3 #elif defined(MENUQC)
4 #elif defined(SVQC)
5         #include <common/util.qh>
6         #include "all.qh"
7 #endif
8
9 // ==========================
10 //  Turret Config Generator
11 // ==========================
12
13 #ifdef SVQC
14
15 void T_Config_Queue(string setting)
16 {
17         if (TUR_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
18                 config_queue[TUR_CONFIG_COUNT++] = setting;
19 }
20
21 void T_Config_Queue_Swap(float root, float child, entity pass)
22 {
23         string oldroot = config_queue[root];
24         config_queue[root] = config_queue[child];
25         config_queue[child] = oldroot;
26 }
27
28 float T_Config_Queue_Compare(float root, float child, entity pass)
29 {
30         float i, r, c;
31
32         for(i = 1; i <= 100; ++i)
33         {
34                 r = str2chr(config_queue[root], i);
35                 c = str2chr(config_queue[child], i);
36                 if(r == c) { continue; }
37                 else if(c > r) { return -1; }
38                 else { return 1; }
39         }
40
41         return 0;
42 }
43
44 void Dump_Turret_Settings()
45 {
46         #define TUR_CONFIG_WRITETOFILE(str) write_String_To_File(tur_config_file, str, tur_config_alsoprint)
47         int totalsettings = 0;
48         FOREACH(Turrets, it != TUR_Null, {
49                 // step 1: clear the queue
50                 TUR_CONFIG_COUNT = 0;
51                 for (int j = 0; j < MAX_CONFIG_SETTINGS; ++j)
52                         config_queue[j] = string_null;
53
54                 // step 2: build new queue
55                 it.tr_config(it);
56
57                 if (TUR_CONFIG_COUNT > MAX_CONFIG_SETTINGS - 1)
58                 {
59                         LOG_INFOF("\n^1Dumping aborted^7: hit MAX_CONFIG_SETTINGS (%d) limit\n\n", MAX_CONFIG_SETTINGS);
60                         break;
61                 }
62
63                 // step 3: sort queue
64                 heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, NULL);
65
66                 // step 4: write queue
67                 TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name));
68                 for (int j = 0; j < TUR_CONFIG_COUNT; ++j)
69                         TUR_CONFIG_WRITETOFILE(config_queue[j]);
70                 TUR_CONFIG_WRITETOFILE("// }}}\n");
71
72                 // step 5: debug info
73                 LOG_INFOF("#%d: %s: %d settings...", i, it.turret_name, TUR_CONFIG_COUNT);
74                 totalsettings += TUR_CONFIG_COUNT;
75         });
76         #undef TUR_CONFIG_WRITETOFILE
77
78         // extra information
79         if (TUR_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
80                 LOG_INFOF("Totals: %d turrets, %d settings", (Turrets_COUNT - 1), totalsettings);
81
82         // clear queue now that we're finished
83         TUR_CONFIG_COUNT = 0;
84         for (int j = 0; j < MAX_CONFIG_SETTINGS; ++j)
85                 config_queue[j] = string_null;
86 }
87
88 #endif