X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fconfig.qc;h=8ecd190e320753a3f6a21af398df40ceb8721fb0;hp=68cac084649dba3baa49ae258a438d25313d5444;hb=7d7f95b29ff8d5bfd2ac3ce98d40ddacdb1f823c;hpb=26693a3ac060825ce6c7f170d4e65f7ac2a1fb25 diff --git a/qcsrc/common/turrets/config.qc b/qcsrc/common/turrets/config.qc index 68cac0846..8ecd190e3 100644 --- a/qcsrc/common/turrets/config.qc +++ b/qcsrc/common/turrets/config.qc @@ -1,13 +1,28 @@ #include "config.qh" +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include + #include "all.qh" +#endif + // ========================== // Turret Config Generator // ========================== +#ifdef SVQC + +void T_Config_Queue(string setting) +{ + if (TUR_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1) + config_queue[TUR_CONFIG_COUNT++] = setting; +} + void T_Config_Queue_Swap(float root, float child, entity pass) { - string oldroot = tur_config_queue[root]; - tur_config_queue[root] = tur_config_queue[child]; - tur_config_queue[child] = oldroot; + string oldroot = config_queue[root]; + config_queue[root] = config_queue[child]; + config_queue[child] = oldroot; } float T_Config_Queue_Compare(float root, float child, entity pass) @@ -16,8 +31,8 @@ float T_Config_Queue_Compare(float root, float child, entity pass) for(i = 1; i <= 100; ++i) { - r = str2chr(tur_config_queue[root], i); - c = str2chr(tur_config_queue[child], i); + r = str2chr(config_queue[root], i); + c = str2chr(config_queue[child], i); if(r == c) { continue; } else if(c > r) { return -1; } else { return 1; } @@ -28,35 +43,46 @@ float T_Config_Queue_Compare(float root, float child, entity pass) void Dump_Turret_Settings() { + #define TUR_CONFIG_WRITETOFILE(str) write_String_To_File(tur_config_file, str, tur_config_alsoprint) int totalsettings = 0; FOREACH(Turrets, it != TUR_Null, { // step 1: clear the queue TUR_CONFIG_COUNT = 0; - for(int j = 0; j <= MAX_TUR_CONFIG; ++j) - { tur_config_queue[j] = string_null; } + for (int j = 0; j < MAX_CONFIG_SETTINGS; ++j) + config_queue[j] = string_null; // step 2: build new queue it.tr_config(it); + if (TUR_CONFIG_COUNT > MAX_CONFIG_SETTINGS - 1) + { + LOG_INFOF("\n^1Dumping aborted^7: hit MAX_CONFIG_SETTINGS (%d) limit\n\n", MAX_CONFIG_SETTINGS); + break; + } + // step 3: sort queue heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, NULL); // step 4: write queue - TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name)) - for(int j = 0; j <= TUR_CONFIG_COUNT; ++j) - { TUR_CONFIG_WRITETOFILE(tur_config_queue[j]) } - TUR_CONFIG_WRITETOFILE("// }}}\n") + TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, it.turret_name)); + for (int j = 0; j < TUR_CONFIG_COUNT; ++j) + TUR_CONFIG_WRITETOFILE(config_queue[j]); + TUR_CONFIG_WRITETOFILE("// }}}\n"); // step 5: debug info - LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, it.turret_name, TUR_CONFIG_COUNT)); + LOG_INFOF("#%d: %s: %d settings...", i, it.turret_name, TUR_CONFIG_COUNT); totalsettings += TUR_CONFIG_COUNT; }); + #undef TUR_CONFIG_WRITETOFILE + + // extra information + if (TUR_CONFIG_COUNT <= MAX_CONFIG_SETTINGS - 1) + LOG_INFOF("Totals: %d turrets, %d settings", (REGISTRY_COUNT(Turrets) - 1), totalsettings); // clear queue now that we're finished TUR_CONFIG_COUNT = 0; - for(int j = 0; j <= MAX_TUR_CONFIG; ++j) - { tur_config_queue[j] = string_null; } - - // extra information - LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (Turrets_COUNT - 1), totalsettings)); + for (int j = 0; j < MAX_CONFIG_SETTINGS; ++j) + config_queue[j] = string_null; } + +#endif