MCPcopy Index your code
hub / github.com/assaultcube/AC / loadmodel

Function loadmodel

source/src/rendermodel.cpp:366–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364bool silentmodelloaderror = false;
365
366model *loadmodel(const char *name, int i, bool trydl) // load model by name (optional) or from mapmodels[i]
367{
368 if(!name) // name == NULL -> get index i from mapmodels[]
369 {
370 if(!mapmodels.inrange(i)) return NULL;
371 mapmodelinfo &mmi = mapmodels[i];
372 if(mmi.m) return mmi.m; // mapmodels[i] was already loaded
373 name = mmi.name;
374 }
375 if(mdlnotfound.access(name)) return NULL; // already tried to find that earlier -> not available
376 model **mm = mdllookup.access(name);
377 model *m;
378 if(mm) m = *mm; // a model of that name is already loaded
379 else
380 {
381 pushscontext(IEXC_MDLCFG);
382 m = new md2(name); // try md2
383 loadingmodel = m;
384 loopi(MMA_NUM) DELSTRING(loadingattributes.n[i]);
385 if(!m->load()) // md2 didn't load
386 {
387 delete m;
388 m = new md3(name); // try md3
389 loadingmodel = m;
390 if(!m->load()) // md3 didn't load -> we don't have that model
391 {
392 delete m;
393 m = loadingmodel = NULL;
394 if(trydl && !strncmp(name, mmpath, strlen(mmpath))) requirepackage(PCK_MAPMODEL, name);
395 else
396 {
397 if(!silentmodelloaderror) conoutf("\f3failed to load model %s", name);
398 mdlnotfound.access(newstring(name), 0); // do not search for this name again
399 }
400 }
401 }
402 popscontext();
403 if(loadingmodel && m)
404 {
405 mdllookup.access(m->name(), m);
406 setmodelattributes(m->name(), loadingattributes);
407 if(m->shadowdist && !m->cullface)
408 {
409 conoutf("\f3mapmodel config error: disabling face culling in combination with shadows will cause visual errors (%s)", m->name());
410 flagmapconfigerror(LWW_MODELERR);
411 }
412 }
413 loadingmodel = NULL;
414 }
415 if(mapmodels.inrange(i) && !mapmodels[i].m) mapmodels[i].m = m;
416 return m;
417}
418
419void cleanupmodels()
420{

Callers 7

rendermodelFunction · 0.85
preload_playermodelsFunction · 0.85
loopiFunction · 0.85
preload_entmodelsFunction · 0.85
preload_mapmodelsFunction · 0.85
loopvFunction · 0.85
loopiFunction · 0.85

Calls 12

pushscontextFunction · 0.85
requirepackageFunction · 0.85
newstringFunction · 0.85
popscontextFunction · 0.85
setmodelattributesFunction · 0.85
flagmapconfigerrorFunction · 0.85
inrangeMethod · 0.80
accessMethod · 0.80
nameMethod · 0.80
loopiFunction · 0.70
conoutfFunction · 0.70
loadMethod · 0.45

Tested by

no test coverage detected