--- /dev/null
+#ifndef MODELS_H
+#define MODELS_H
+
+#define setmodel(e, m) _setmodel((e), (m).model_str())
+
+void RegisterModels();
+const int MAX_MODELS = 128;
+entity MODELS[MAX_MODELS], MODELS_first, MODELS_last;
+int MODELS_COUNT;
+
+CLASS(Model, Object)
+ ATTRIB(Model, m_id, int, 0)
+ ATTRIB(Model, model_str, string(), func_null)
+ CONSTRUCTOR(Model, string() path)
+ {
+ CONSTRUCT(Model);
+ this.model_str = path;
+ }
+ METHOD(Model, model_precache, void(entity this)) {
+ string s = this.model_str();
+ int fh = fopen(s, FILE_READ);
+ if (fh >= 0) {
+ fclose(fh);
+ } else if (s && s != "" && s != "null") {
+ LOG_WARNINGF("Missing model: \"%s\"\n", s);
+ return;
+ }
+ LOG_TRACEF("precache_model(\"%s\")\n", s);
+ precache_model(s);
+ }
+ENDCLASS(Model)
+
+#define MODEL(name, path) \
+ string MDL_##name##_get() { return path; } \
+ REGISTER(RegisterModels, MDL, MODELS, MODELS_COUNT, name, m_id, NEW(Model, MDL_##name##_get))
+REGISTER_REGISTRY(RegisterModels)
+
+STATIC_INIT(RegisterModels_precache) {
+ FOREACH(MODELS, true, LAMBDA({
+ it.model_precache(it);
+ }));
+}
+
+MODEL(Null, "null");
+#include "models.inc"
+
+#endif