Code: Select all
void Scene::insertObject(MWWorld::Ptr ptr, Ptr::CellStore* cell)
{
ptr.mCell = cell;
mRendering.addObject(ptr);
MWWorld::Class::get(ptr).insertObject(ptr, *mPhysics);
MWWorld::Class::get(ptr).enable(ptr);
std::string type = ptr.getTypeName();
// insert into the correct CellRefList
if (type == typeid(ESM::Potion).name())
cell->potions.list.push_back( *ptr.get<ESM::Potion>() );
else if (type == typeid(ESM::Apparatus).name())
cell->appas.list.push_back( *ptr.get<ESM::Apparatus>() );
else if (type == typeid(ESM::Armor).name())
cell->armors.list.push_back( *ptr.get<ESM::Armor>() );
else if (type == typeid(ESM::Book).name())
cell->books.list.push_back( *ptr.get<ESM::Book>() );
else if (type == typeid(ESM::Clothing).name())
cell->clothes.list.push_back( *ptr.get<ESM::Clothing>() );
else if (type == typeid(ESM::Ingredient).name())
cell->ingreds.list.push_back( *ptr.get<ESM::Ingredient>() );
else if (type == typeid(ESM::Light).name())
cell->lights.list.push_back( *ptr.get<ESM::Light>() );
else if (type == typeid(ESM::Tool).name())
cell->lockpicks.list.push_back( *ptr.get<ESM::Tool>() );
else if (type == typeid(ESM::Repair).name())
cell->repairs.list.push_back( *ptr.get<ESM::Repair>() );
else if (type == typeid(ESM::Probe).name())
cell->probes.list.push_back( *ptr.get<ESM::Probe>() );
else if (type == typeid(ESM::Weapon).name())
cell->weapons.list.push_back( *ptr.get<ESM::Weapon>() );
else if (type == typeid(ESM::Miscellaneous).name())
cell->miscItems.list.push_back( *ptr.get<ESM::Miscellaneous>() );
else
throw std::runtime_error("Trying to insert object of unhandled type");
}