MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / loadFromFileServer

Method loadFromFileServer

engine/Poseidon/World/Model/ModelCache.cpp:111–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111std::shared_ptr<Poseidon::Model::Model> ModelCache::loadFromFileServer(const std::string& filePath)
112{
113 QIFStream f;
114 GFileServer->Open(f, filePath.c_str());
115 if (f.fail())
116 return nullptr;
117
118 const char* data = f.act();
119 int dataSize = f.rest();
120 if (dataSize < 8)
121 return nullptr;
122
123 char sig[5] = {};
124 memcpy(sig, data, 4);
125 std::string signature(sig);
126
127 auto model = std::make_shared<Poseidon::Model::Model>();
128 try
129 {
130 if (signature == "ODOL")
131 *model = Poseidon::Asset::Formats::ODOLLoader::loadFromBuffer(data, dataSize, filePath);
132 else if (signature == "MLOD")
133 *model = Poseidon::Asset::Formats::MLODLoader::loadFromBuffer(data, dataSize, filePath);
134 else
135 return nullptr;
136 }
137 catch (...)
138 {
139 return nullptr;
140 }
141
142 if (!model->compile() || !model->isCompiled())
143 return nullptr;
144
145 return model;
146}
147
148bool ModelCache::isLoaded(const std::string& filePath) const
149{

Callers

nothing calls this directly

Calls 6

actMethod · 0.80
restMethod · 0.80
compileMethod · 0.80
isCompiledMethod · 0.80
OpenMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected