Добавил shared_from_this как основной способ создать умный указатель на "себя". Добавил пример работы с ним
This commit is contained in:
@@ -46,13 +46,13 @@ std::shared_ptr<SaveMap> World::save()
|
||||
void World::load(std::shared_ptr<SaveMap> save)
|
||||
{
|
||||
std::vector<std::string> actors_IDs = save->GetVectorString("ActorsIDs");
|
||||
std::list<std::shared_ptr<Actor>> act = std::move(reinterpret_cast<std::list<std::shared_ptr<Actor>>&>(save->GetListObject("Actors")));
|
||||
std::list<std::shared_ptr<ISave>> act = save->GetListObject("Actors");
|
||||
|
||||
size_t i_id = 0;
|
||||
for (auto& i : act)
|
||||
{
|
||||
auto[it, flag] = actors_map.try_emplace(actors_IDs[i_id], i);
|
||||
it->second->world_ = this;
|
||||
auto[it, flag] = actors_map.try_emplace(actors_IDs[i_id], std::static_pointer_cast<Actor>(i));
|
||||
it->second->world_ = std::static_pointer_cast<World>(shared_from_this());
|
||||
it->second->name_ = it->first;
|
||||
i_id++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user