5 #include <common/util.qh>
9 // ==========================
10 // Turret Config Generator
11 // ==========================
15 void T_Config_Queue(string setting)
17 if (TUR_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
18 config_queue[TUR_CONFIG_COUNT++] = setting;
21 void T_Config_Queue_Swap(float root, float child, entity pass)
23 string oldroot = config_queue[root];
24 config_queue[root] = config_queue[child];
25 config_queue[child] = oldroot;
28 float T_Config_Queue_Compare(float root, float child, entity pass)
32 for(i = 1; i <= 100; ++i)
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; }
44 void Dump_Turret_Settings()
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
51 for (int j = 0; j < MAX_CONFIG_SETTINGS; ++j)
52 config_queue[j] = string_null;
54 // step 2: build new queue
57 if (TUR_CONFIG_COUNT > MAX_CONFIG_SETTINGS - 1)
59 LOG_INFOF("\n^1Dumping aborted^7: hit MAX_CONFIG_SETTINGS (%d) limit\n\n", MAX_CONFIG_SETTINGS);
64 heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, NULL);
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");
73 LOG_INFOF("#%d: %s: %d settings...", i, it.turret_name, TUR_CONFIG_COUNT);
74 totalsettings += TUR_CONFIG_COUNT;
76 #undef TUR_CONFIG_WRITETOFILE
79 if (TUR_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1)
80 LOG_INFOF("Totals: %d turrets, %d settings", (REGISTRY_COUNT(Turrets) - 1), totalsettings);
82 // clear queue now that we're finished
84 for (int j = 0; j < MAX_CONFIG_SETTINGS; ++j)
85 config_queue[j] = string_null;