MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / loadMapNode

Method loadMapNode

radiantcore/map/MapResource.cpp:282–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282RootNodePtr MapResource::loadMapNode()
283{
284 RootNodePtr rootNode;
285
286 // Open a stream - will throw on failure
287 auto stream = openMapfileStream();
288
289 if (!stream || !stream->isOpen())
290 {
291 throw OperationException(_("Could not open map stream"));
292 }
293
294 try
295 {
296 // Get the mapformat
297 auto format = algorithm::determineMapFormat(stream->getStream(), _extension);
298
299 if (!format)
300 {
301 throw OperationException(_("Could not determine map format"));
302 }
303
304 // Instantiate a loader to process the map file stream
305 MapResourceLoader loader(stream->getStream(), *format);
306
307 // Load the root from the primary stream (throws on failure or cancel)
308 rootNode = loader.load();
309
310 if (rootNode)
311 {
312 rootNode->setName(_name);
313 }
314
315 // Check if an info file is supported by this map format
316 if (format->allowInfoFileCreation())
317 {
318 auto infoFileStream = openInfofileStream();
319
320 if (infoFileStream && infoFileStream->isOpen())
321 {
322 loader.loadInfoFile(infoFileStream->getStream(), rootNode);
323 }
324 }
325
326 refreshLastModifiedTime();
327 }
328 catch (const OperationException& ex)
329 {
330 // Re-throw the exception, prepending the map file path to the message (if not cancelled)
331 throw ex.operationCancelled() ? ex :
332 OperationException(fmt::format(_("Failure reading map file:\n{0}\n\n{1}"), getAbsoluteResourcePath(), ex.what()));
333 }
334
335 return rootNode;
336}
337
338stream::MapResourceStream::Ptr MapResource::openFileStream(const std::string& path)
339{

Callers

nothing calls this directly

Calls 11

OperationExceptionClass · 0.85
determineMapFormatFunction · 0.85
loadInfoFileMethod · 0.80
operationCancelledMethod · 0.80
whatMethod · 0.80
_Function · 0.50
formatFunction · 0.50
isOpenMethod · 0.45
loadMethod · 0.45
setNameMethod · 0.45
allowInfoFileCreationMethod · 0.45

Tested by

no test coverage detected