MCPcopy Create free account
hub / github.com/TurningWheel/Barony / loadModels

Method loadModels

src/mod_tools.cpp:11535–11613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11533}
11534
11535void Mods::loadModels(int start, int end) {
11536 start = std::clamp(start, 0, (int)nummodels - 1);
11537 end = std::clamp(end, 0, (int)nummodels);
11538
11539 if ( start >= end ) {
11540 return;
11541 }
11542
11543 //messagePlayer(clientnum, Language::get(2354));
11544#ifndef EDITOR
11545 printlog(Language::get(2355), start, end);
11546#endif
11547
11548 loading = true;
11549 //createLoadingScreen(5);
11550 doLoadingScreen();
11551
11552 std::string modelsDirectory = PHYSFS_getRealDir("models/models.txt");
11553 modelsDirectory.append(PHYSFS_getDirSeparator()).append("models/models.txt");
11554 File* fp = openDataFile(modelsDirectory.c_str(), "rb");
11555 for ( int c = 0; !fp->eof(); c++ )
11556 {
11557 char name[128];
11558 fp->gets2(name, sizeof(name));
11559 if ( c >= start && c < end ) {
11560 if (polymodels[c].vao) {
11561 GL_CHECK_ERR(glDeleteVertexArrays(1, &polymodels[c].vao));
11562 }
11563 if (polymodels[c].positions) {
11564 GL_CHECK_ERR(glDeleteBuffers(1, &polymodels[c].positions));
11565 }
11566 if (polymodels[c].colors) {
11567 GL_CHECK_ERR(glDeleteBuffers(1, &polymodels[c].colors));
11568 }
11569 if (polymodels[c].normals) {
11570 GL_CHECK_ERR(glDeleteBuffers(1, &polymodels[c].normals));
11571 }
11572 }
11573 }
11574
11575 std::atomic_bool loading_done{ false };
11576 auto loading_task = std::async(std::launch::async, [&loading_done, start, end]() {
11577 std::string modelsDirectory = PHYSFS_getRealDir("models/models.txt");
11578 modelsDirectory.append(PHYSFS_getDirSeparator()).append("models/models.txt");
11579 File* fp = openDataFile(modelsDirectory.c_str(), "rb");
11580 for ( int c = 0; !fp->eof(); c++ )
11581 {
11582 char name[128];
11583 fp->gets2(name, sizeof(name));
11584 if ( c >= start && c < end )
11585 {
11586 if ( models[c] != NULL )
11587 {
11588 if ( models[c]->data )
11589 {
11590 free(models[c]->data);
11591 }
11592 free(models[c]);

Callers

nothing calls this directly

Calls 10

printlogFunction · 0.85
doLoadingScreenFunction · 0.85
openDataFileFunction · 0.85
loadVoxelFunction · 0.85
generatePolyModelsFunction · 0.85
generateVBOsFunction · 0.85
appendMethod · 0.80
c_strMethod · 0.80
eofMethod · 0.80
gets2Method · 0.80

Tested by

no test coverage detected