From: TimePath Date: Thu, 5 Nov 2015 22:37:51 +0000 (+1100) Subject: Registry: checksum X-Git-Tag: xonotic-v0.8.2~1702 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3a4736b83622fa4752e34fff6e966da05210c536;p=xonotic%2Fxonotic-data.pk3dir.git Registry: checksum --- diff --git a/qcsrc/lib/registry.qh b/qcsrc/lib/registry.qh index 8da286195..7ff94fbaa 100644 --- a/qcsrc/lib/registry.qh +++ b/qcsrc/lib/registry.qh @@ -11,7 +11,11 @@ const int id##_MAX = max; \ noref entity _##id[id##_MAX], id##_first, id##_last; \ int id##_COUNT; \ - entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _##id[i]; if (e) return e; } return null; } + entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _##id[i]; if (e) return e; } return null; } \ + REGISTRY_CHECK(id) + +/** registered item identifier */ +.string registered_id; /** * Register a new entity with a global constructor. @@ -44,6 +48,7 @@ if (array##_COUNT >= array##_MAX) LOG_FATALF("Registry capacity exceeded (%s)", ftos(array##_MAX)); \ entity this = inst; \ ns##_##id = this; \ + this.registered_id = #id; \ this.fld = array##_COUNT; \ _##array[array##_COUNT++] = this; \ if (!array##_first) array##_first = this; \ @@ -90,4 +95,15 @@ heapsort(id##_COUNT - (skip), _REGISTRY_SWAP_##id, _REGISTRY_CMP_##id, NULL); \ } +#define REGISTRY_CHECK(id) \ + STATIC_INIT_LATE(Registry_check_##id) \ + { \ + string algo = "SHA256"; \ + string join = ":"; \ + string s = ""; \ + FOREACH(id, true, LAMBDA(s = strcat(s, join, it.registered_id))); \ + s = substring(s, strlen(join), -1); \ + LOG_TRACEF(#id ": %s\n[%s]\n", digest_hex(algo, s), s); \ + } + #endif