From: TimePath Date: Sun, 24 Jul 2016 05:55:38 +0000 (+1000) Subject: Registry: add reload method X-Git-Tag: xonotic-v0.8.2~700^2~40 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ac93b7ad17fccae6c8674ab2981fc8b81847ffa4;p=xonotic%2Fxonotic-data.pk3dir.git Registry: add reload method --- diff --git a/qcsrc/lib/registry.qh b/qcsrc/lib/registry.qh index 7ce923c53..5f2f58516 100644 --- a/qcsrc/lib/registry.qh +++ b/qcsrc/lib/registry.qh @@ -71,10 +71,13 @@ REGISTRY(Registries, BITS(8)) REGISTER_INIT(id) {} \ void Register_##id() \ { \ - if (registry##_COUNT >= registry##_MAX) LOG_FATALF("Registry capacity exceeded (%d)", registry##_MAX); \ - entity this = id = inst; \ - this.registered_id = #id; \ - REGISTRY_PUSH(registry, fld, this); \ + entity this = id; \ + if (this == NULL) { \ + if (registry##_COUNT >= registry##_MAX) LOG_FATALF("Registry capacity exceeded (%d)", registry##_MAX); \ + this = id = inst; \ + this.registered_id = #id; \ + REGISTRY_PUSH(registry, fld, this); \ + } \ Register_##id##_init(this); \ } \ ACCUMULATE_FUNCTION(_Register##registry, Register_##id) \ @@ -180,5 +183,9 @@ void Registry_send(string id, string hash); CLASS(id##Registry, Object) \ ATTRIB(id##Registry, m_name, string, str) \ ATTRIB(id##Registry, REGISTRY_NEXT, entity, id##_first) \ + METHOD(id##Registry, m_reload, void()); \ ENDCLASS(id##Registry) \ - REGISTER(Registries, REGISTRY, id, m_id, NEW(id##Registry)); + REGISTER(Registries, REGISTRY, id, m_id, NEW(id##Registry)); \ + METHOD(id##Registry, m_reload, void()) { \ + Register##id(); \ + }