MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / load

Method load

source/rooms/RoomManager.cpp:306–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306Room* RoomManager::load(GameMap* gameMap, std::istream& is)
307{
308 if(!is.good())
309 return nullptr;
310
311 std::vector<const RoomFactory*>& factories = getFactories();
312 std::string nextParam;
313 OD_ASSERT_TRUE(is >> nextParam);
314 const RoomFactory* factoryToUse = nullptr;
315 for(const RoomFactory* factory : factories)
316 {
317 if(factory == nullptr)
318 continue;
319
320 if(factory->getName().compare(nextParam) != 0)
321 continue;
322
323 factoryToUse = factory;
324 break;
325 }
326
327 if(factoryToUse == nullptr)
328 {
329 OD_LOG_ERR("Unknown room type=" + nextParam);
330 return nullptr;
331 }
332
333 Room* room = factoryToUse->getRoomFromStream(gameMap, is);
334 if(!room->importFromStream(is))
335 {
336 OD_LOG_ERR("Couldn't load creature room type=" + nextParam);
337 delete room;
338 return nullptr;
339 }
340
341 return room;
342}
343
344void RoomManager::dispose(const Room* room)
345{

Callers

nothing calls this directly

Calls 2

getRoomFromStreamMethod · 0.45
importFromStreamMethod · 0.45

Tested by

no test coverage detected