X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Feffects%2Feffectinfo.qc;h=1e23bb46fbf9943547b66d76a7f81939967f1917;hb=90d9f7c775306324957323d53d5a4ad995d999e3;hp=f6b82a622c0f3330efb5fadb758b7481ecc6551a;hpb=f1a87492d9fed27a64d0e99c068705aba5509f26;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/effects/effectinfo.qc b/qcsrc/common/effects/effectinfo.qc index f6b82a622..1e23bb46f 100644 --- a/qcsrc/common/effects/effectinfo.qc +++ b/qcsrc/common/effects/effectinfo.qc @@ -1,4 +1,7 @@ -#define EFFECTINFO_PARSER(on) \ +#if ENABLE_EFFECTINFO + +#include "effectinfo.qh" +#define EFFECTINFO_PARSER(on, MY) \ on(type, MY(type) \ ,{ demand(n == 1 && "type"); MY(type) = strzone(argv(1)); \ }, sprintf(" %s", (MY(type)) \ @@ -138,7 +141,7 @@ /**/ CLASS(EffectInfo, Object) - ATTRIB(EffectInfo, effectinfo_name, string, string_null) + ATTRIB(EffectInfo, effectinfo_name, string); CONSTRUCTOR(EffectInfo, string s) { CONSTRUCT(EffectInfo); this.effectinfo_name = s; @@ -193,11 +196,13 @@ CLASS(EffectInfo, Object) MY(velocityoffset, vector, '0 0 0') \ /**/ - #define MY(f, type, val) ATTRIB(EffectInfo, effectinfo_##f, type, val) + #define MY(f, type, val) ATTRIB(EffectInfo, effectinfo_##f, type, val); FIELDS(MY) #undef MY - METHOD(EffectInfo, describe, string(EffectInfo this)) { + METHOD(EffectInfo, describe, string(EffectInfo this)) + { + TC(EffectInfo, this); string s = sprintf("SUB(%s) {\n", this.effectinfo_name); #define str_bool(it) (it ? "true" : "false") #define str_float(it) ftos(it) @@ -206,15 +211,16 @@ CLASS(EffectInfo, Object) #define p(f, type, default) if (this.effectinfo_##f) { s = strcat(s, "\t", "MY("#f") = ", str_##type(this.effectinfo_##f), ";\n"); } FIELDS(p) #undef p - #undef MY return strcat(s, "}\n"); } - METHOD(EffectInfo, dump, string(EffectInfo this)) { + METHOD(EffectInfo, dump, string(EffectInfo this)) + { + TC(EffectInfo, this); string s = sprintf("effect %s\n", this.effectinfo_name); #define MY(f) this.effectinfo_##f #define p(k, isset, parse, unparse) if (isset) { s = strcat(s, "\t", #k, unparse, "\n"); } - EFFECTINFO_PARSER(p) + EFFECTINFO_PARSER(p, MY) #undef p #undef MY return s; @@ -224,8 +230,8 @@ CLASS(EffectInfo, Object) ENDCLASS(EffectInfo) CLASS(EffectInfoGroup, Object) - ATTRIBARRAY(EffectInfoGroup, children, EffectInfo, 16) - ATTRIB(EffectInfoGroup, children_count, int, 0) + ATTRIBARRAY(EffectInfoGroup, children, EffectInfo, 16); + ATTRIB(EffectInfoGroup, children_count, int, 0); ENDCLASS(EffectInfoGroup) void effectinfo_read() @@ -246,11 +252,11 @@ void effectinfo_read() switch (k) { #define MY(f) info.effectinfo_##f #define p(k, isset, parse, unparse) case #k: parse break; - EFFECTINFO_PARSER(p) + EFFECTINFO_PARSER(p, MY) #undef p #undef MY default: - LOG_WARNINGF("Unknown property '%s'\n", k); + LOG_WARNF("Unknown property '%s'", k); break; } } @@ -259,21 +265,19 @@ void effectinfo_read() void effectinfo_dump(int fh, bool alsoprint) { - #define WRITE(s) MACRO_BEGIN { \ - fputs(fh, s); \ - if (alsoprint) LOG_INFO(s); \ - } MACRO_END - WRITE("// ********************************************** //\n"); - WRITE("// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n"); - WRITE("// ** ** //\n"); - WRITE("// ** This file is automatically generated by ** //\n"); - WRITE("// ** code with the command 'dumpeffectinfo'. ** //\n"); - WRITE("// ** ** //\n"); - WRITE("// ** If you modify an effect, please ** //\n"); - WRITE("// ** regenerate this file with that command. ** //\n"); - WRITE("// ** ** //\n"); - WRITE("// ********************************************** //\n"); - WRITE("\n"); + #define WRITE(str) write_String_To_File(fh, str, alsoprint) + WRITE( + "// ********************************************** //\n" + "// ** WARNING - DO NOT MANUALLY EDIT THIS FILE ** //\n" + "// ** ** //\n" + "// ** This file is automatically generated by ** //\n" + "// ** code with the command 'dumpeffectinfo'. ** //\n" + "// ** ** //\n" + "// ** If you modify an effect, please ** //\n" + "// ** regenerate this file with that command. ** //\n" + "// ** ** //\n" + "// ********************************************** //\n" + "\n"); for (EffectInfo it = NULL; (it = findfloat(it, instanceOfEffectInfo, true)); ) { if (it.classname == "vtbl") continue; @@ -283,7 +287,7 @@ void effectinfo_dump(int fh, bool alsoprint) #undef WRITE } -GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt") +GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt", false) { switch (request) { case CMD_REQUEST_COMMAND: { @@ -299,20 +303,20 @@ GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt") int fh = fopen(filename, FILE_WRITE); if (fh >= 0) { effectinfo_dump(fh, alsoprint); - LOG_INFOF("Dumping effectinfo... File located at ^2data/data/%s^7.\n", filename); - LOG_INFOF("Reload with ^2cl_particles_reloadeffects data/%s^7.\n", filename); + LOG_INFOF("Dumping effectinfo... File located at ^2data/data/%s^7.", filename); + LOG_INFOF("Reload with ^2cl_particles_reloadeffects data/%s^7.", filename); fclose(fh); } else { - LOG_WARNINGF("Could not open file '%s'!\n", filename); + LOG_WARNF("Could not open file '%s'!", filename); } return; } default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpeffectinfo [filename]")); - LOG_INFO(" Where 'filename' is the file to write (default is effectinfo_dump.txt),\n"); - LOG_INFO(" if supplied with '-' output to console as well as default,\n"); - LOG_INFO(" if left blank, it will only write to default.\n"); + LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " dumpeffectinfo [filename]"); + LOG_HELP(" Where 'filename' is the file to write (default is effectinfo_dump.txt),"); + LOG_HELP(" if supplied with '-' output to console as well as default,"); + LOG_HELP(" if left blank, it will only write to default."); return; } } @@ -320,10 +324,11 @@ GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt") REGISTRY(EffectInfos, BITS(9)) -#define EffectInfos_from(i) _EffectInfos_from(i, NULL) REGISTER_REGISTRY(EffectInfos) + +REGISTRY_DEFINE_GET(EffectInfos, NULL) #define EFFECTINFO(name) \ - [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \ + ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \ REGISTER(EffectInfos, EFFECTINFO, name, m_id, NEW(EffectInfoGroup)) { \ effectinfo_##name(this, NULL); \ } @@ -331,9 +336,11 @@ REGISTER_REGISTRY(EffectInfos) #define MY(f) this.effectinfo_##f #define DEF(name) EFFECTINFO(name) #define SUB(name) \ - [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { parent = EFFECTINFO_##name; parent.children[parent.children_count++] = this = NEW(EffectInfo, #name); } \ - [[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) + ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { parent = EFFECTINFO_##name; parent.children[parent.children_count++] = this = NEW(EffectInfo, #name); } \ + ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) #include "effectinfo.inc" #undef MY #undef DEF #undef SUB + +#endif