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 #define TUR_CONFIG_WRITETOFILE(str) write_String_To_File(tur_config_file, str, tur_config_alsoprint)
34 int totalsettings = 0;
35 FOREACH(Turrets, it != TUR_Null, {
36 // step 1: clear the queue
38 for(int j = 0; j <= MAX_CONFIG_SETTINGS; ++j)
39 config_queue[j] = string_null;
41 // step 2: build new queue
45 heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, NULL);
47 // step 4: write queue
48 TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name));
49 for(int j = 0; j <= TUR_CONFIG_COUNT; ++j)
50 TUR_CONFIG_WRITETOFILE(config_queue[j]);
51 TUR_CONFIG_WRITETOFILE("// }}}\n");
54 LOG_INFOF("#%d: %s: %d settings...", i, it.turret_name, TUR_CONFIG_COUNT);
55 totalsettings += TUR_CONFIG_COUNT;
57 #undef TUR_CONFIG_WRITETOFILE
59 // clear queue now that we're finished
61 for(int j = 0; j <= MAX_CONFIG_SETTINGS; ++j)
62 config_queue[j] = string_null;
65 LOG_INFOF("Totals: %d turrets, %d settings", (Turrets_COUNT - 1), totalsettings);