]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/models/model.qh
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / models / model.qh
index 1610240a79f88c98a5ad65c3f02ed7222254b3bb..38aa4e33ada8d62930db4634610e5f2cb8610221 100644 (file)
@@ -1,10 +1,9 @@
 #pragma once
 
-#define setmodel(e, m) _setmodel((e), (m).model_str())
-
 CLASS(Model, Object)
-    ATTRIB(Model, m_id, int, 0)
-    ATTRIB(Model, model_str, string(), func_null)
+    ATTRIB(Model, m_id, int, 0);
+    ATTRIB(Model, model_str, string());
+    ATTRIB(Model, model_str_, string);
     CONSTRUCTOR(Model, string() path)
     {
         CONSTRUCT(Model);
@@ -15,10 +14,17 @@ CLASS(Model, Object)
         TC(Model, this);
         string s = this.model_str();
         if (s != "" && s != "null" && !fexists(s)) {
-            LOG_WARNF("Missing model: \"%s\"\n", s);
+            LOG_WARNF("Missing model: \"%s\"", s);
             return;
         }
-        profile(sprintf("precache_model(\"%s\")\n", s));
+        profile(sprintf("precache_model(\"%s\")", s));
         precache_model(s);
+        strcpy(this.model_str_, s);
     }
 ENDCLASS(Model)
+
+#define setmodel(this, m) MACRO_BEGIN \
+    Model _setmodel_model = (m); \
+    string _setmodel_cached = _setmodel_model.model_str_; \
+    _setmodel((this), _setmodel_cached ? _setmodel_cached : _setmodel_model.model_str()); \
+MACRO_END