X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmodels%2Fmodel.qh;h=c6a1c2199b62b1c5a6ec305cbf81a28bbe3803e0;hb=2e60d4af0278db5d39618bf8fee353c220d90486;hp=91fb278ae0a5ec975c1580d4f7e023f8b96793e2;hpb=a47688cb559bcb2090d69a3a3c0c92d4d8fe02d5;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/models/model.qh b/qcsrc/common/models/model.qh index 91fb278ae..c6a1c2199 100644 --- a/qcsrc/common/models/model.qh +++ b/qcsrc/common/models/model.qh @@ -1,11 +1,9 @@ -#ifndef MODEL_H -#define MODEL_H - -#define setmodel(e, m) _setmodel((e), (m).model_str()) +#pragma once 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); @@ -16,12 +14,17 @@ CLASS(Model, Object) TC(Model, this); string s = this.model_str(); if (s != "" && s != "null" && !fexists(s)) { - LOG_WARNINGF("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) -#endif +#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