2 // ==========================
3 // Turret Config Generator
4 // ==========================
6 void T_Config_Queue_Swap(float root, float child, entity pass)
8 string oldroot = tur_config_queue[root];
9 tur_config_queue[root] = tur_config_queue[child];
10 tur_config_queue[child] = oldroot;
13 float T_Config_Queue_Compare(float root, float child, entity pass)
17 for(i = 1; i <= 100; ++i)
19 r = str2chr(tur_config_queue[root], i);
20 c = str2chr(tur_config_queue[child], i);
21 if(r == c) { continue; }
22 else if(c > r) { return -1; }
29 void Dump_Turret_Settings()
31 int totalsettings = 0;
32 FOREACH(Turrets, it != TUR_Null, {
33 // step 1: clear the queue
35 for(int j = 0; j <= MAX_TUR_CONFIG; ++j)
36 { tur_config_queue[j] = string_null; }
38 // step 2: build new queue
42 heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, NULL);
44 // step 4: write queue
45 TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name))
46 for(int j = 0; j <= TUR_CONFIG_COUNT; ++j)
47 { TUR_CONFIG_WRITETOFILE(tur_config_queue[j]) }
48 TUR_CONFIG_WRITETOFILE("// }}}\n")
51 LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.turret_name, TUR_CONFIG_COUNT));
52 totalsettings += TUR_CONFIG_COUNT;
55 // clear queue now that we're finished
57 for(int j = 0; j <= MAX_TUR_CONFIG; ++j)
58 { tur_config_queue[j] = string_null; }
61 LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (Turrets_COUNT - 1), totalsettings));