2 // ==========================
3 // Turret Config Generator
4 // ==========================
8 void T_Config_Queue_Swap(float root, float child, entity pass)
10 string oldroot = config_queue[root];
11 config_queue[root] = config_queue[child];
12 config_queue[child] = oldroot;
15 float T_Config_Queue_Compare(float root, float child, entity pass)
19 for(i = 1; i <= 100; ++i)
21 r = str2chr(config_queue[root], i);
22 c = str2chr(config_queue[child], i);
23 if(r == c) { continue; }
24 else if(c > r) { return -1; }
31 void Dump_Turret_Settings()
33 int totalsettings = 0;
34 FOREACH(Turrets, it != TUR_Null, {
35 // step 1: clear the queue
37 for(int j = 0; j <= MAX_CONFIG_SETTINGS; ++j)
38 config_queue[j] = string_null;
40 // step 2: build new queue
44 heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, NULL);
46 // step 4: write queue
47 TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name))
48 for(int j = 0; j <= TUR_CONFIG_COUNT; ++j)
49 TUR_CONFIG_WRITETOFILE(config_queue[j])
50 TUR_CONFIG_WRITETOFILE("// }}}\n")
53 LOG_INFOF("#%d: %s: %d settings...", i, it.turret_name, TUR_CONFIG_COUNT);
54 totalsettings += TUR_CONFIG_COUNT;
57 // clear queue now that we're finished
59 for(int j = 0; j <= MAX_CONFIG_SETTINGS; ++j)
60 config_queue[j] = string_null;
63 LOG_INFOF("Totals: %d turrets, %d settings", (Turrets_COUNT - 1), totalsettings);