]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/models/model.qh
Merge branch 'master' into Lyberta/TeamplayOverhaul
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / models / model.qh
1 #pragma once
2
3 CLASS(Model, Object)
4     ATTRIB(Model, m_id, int, 0);
5     ATTRIB(Model, model_str, string());
6     ATTRIB(Model, model_str_, string);
7     CONSTRUCTOR(Model, string() path)
8     {
9         CONSTRUCT(Model);
10         this.model_str = path;
11     }
12     METHOD(Model, model_precache, void(Model this))
13     {
14         TC(Model, this);
15         string s = this.model_str();
16         if (s != "" && s != "null" && !fexists(s)) {
17             LOG_WARNF("Missing model: \"%s\"", s);
18             return;
19         }
20         profile(sprintf("precache_model(\"%s\")", s));
21         precache_model(s);
22         strcpy(this.model_str_, s);
23     }
24 ENDCLASS(Model)
25
26 #define setmodel(this, m) MACRO_BEGIN \
27     Model _setmodel_model = (m); \
28     string _setmodel_cached = _setmodel_model.model_str_; \
29     _setmodel((this), _setmodel_cached ? _setmodel_cached : _setmodel_model.model_str()); \
30 MACRO_END