From d79a0fca8f1b873ec528104ae7ae0803a68ff415 Mon Sep 17 00:00:00 2001 From: TimePath Date: Mon, 17 Aug 2015 16:38:53 +1000 Subject: [PATCH] Reflectively list entity fields as description for unknown entities in developer mode --- qcsrc/common/oo.qh | 11 ++++++++++- qcsrc/menu/xonotic/datasource.qc | 2 +- qcsrc/menu/xonotic/dialog_media_guide.qc | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/qcsrc/common/oo.qh b/qcsrc/common/oo.qh index 01c9db9154..5f990ff84a 100644 --- a/qcsrc/common/oo.qh +++ b/qcsrc/common/oo.qh @@ -118,7 +118,16 @@ STATIC_INIT(RegisterClasses) { RegisterClasses(); } #define _vtbl NULL CLASS(Object, ); METHOD(Object, describe, string(entity this)) - string Object_describe(entity this) { return _("No description"); } + string Object_describe(entity this) { + string s = _("No description"); + if (cvar("developer")) { + for (int i = 0, n = numentityfields(); i < n; ++i) { + string value = getentityfieldstring(i, this); + if (value != "") s = sprintf("%s\n%s = %s", s, entityfieldname(i), value); + } + } + return s; + } METHOD(Object, display, void(entity this, void(string name, string icon) returns)) void Object_display(entity this, void(string name, string icon) returns) { returns(sprintf("entity %i", this), "nopreview_menuskin"); } ENDCLASS(Object) diff --git a/qcsrc/menu/xonotic/datasource.qc b/qcsrc/menu/xonotic/datasource.qc index f0db56eb7a..3c484e3ceb 100644 --- a/qcsrc/menu/xonotic/datasource.qc +++ b/qcsrc/menu/xonotic/datasource.qc @@ -16,7 +16,7 @@ CLASS(DataSource, Object) entity DataSource_true; entity DataSource_false; INIT_STATIC(DataSource) { - DataSource_true = new(dummy); + DataSource_true = NEW(Object); DataSource_false = NULL; } ENDCLASS(DataSource) diff --git a/qcsrc/menu/xonotic/dialog_media_guide.qc b/qcsrc/menu/xonotic/dialog_media_guide.qc index 3c2fb8acd3..d4b9354046 100644 --- a/qcsrc/menu/xonotic/dialog_media_guide.qc +++ b/qcsrc/menu/xonotic/dialog_media_guide.qc @@ -34,6 +34,7 @@ CLASS(DebugSource, DataSource) for (entity it = NULL; (it = nextent(it)); ) { if (!it.instanceOfObject) continue; if (it.instanceOfItem) continue; + if (it.classname == "Object") continue; if (it.classname == "vtbl") continue; if (!tail) { tail = head = it; -- 2.39.2