]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Registry: checksum
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 5 Nov 2015 22:37:51 +0000 (09:37 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 5 Nov 2015 22:37:51 +0000 (09:37 +1100)
qcsrc/lib/registry.qh

index 8da28619562ddcc8ac41be3bd6db98fa58837722..7ff94fbaae4acafa030259db706e0f07948dede1 100644 (file)
        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;                \
                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