X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmodels%2Fmodel.qh;h=38aa4e33ada8d62930db4634610e5f2cb8610221;hb=e259123719e072470e8fd479ffaf4d33f02cea2e;hp=b4005b77775f421a5dec31469f2797dbfbf5c64f;hpb=3ae1efa7401791e42e3171f4db2cc2d38adde088;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/models/model.qh b/qcsrc/common/models/model.qh index b4005b777..38aa4e33a 100644 --- a/qcsrc/common/models/model.qh +++ b/qcsrc/common/models/model.qh @@ -1,25 +1,30 @@ -#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); this.model_str = path; } - METHOD(Model, model_precache, void(entity this)) { + METHOD(Model, model_precache, void(Model this)) + { + 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; } - LOG_TRACEF("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