Parcourir la source

Merge pull request #3750 from IvanSavenko/fix_quest_crash

Fix crash on accessing nullptr quest
Ivan Savenko il y a 1 an
Parent
commit
e1581087c3
1 fichiers modifiés avec 3 ajouts et 7 suppressions
  1. 3 7
      lib/networkPacks/NetPacksLib.cpp

+ 3 - 7
lib/networkPacks/NetPacksLib.cpp

@@ -1199,13 +1199,9 @@ void RemoveObject::applyGs(CGameState *gs)
 		gs->map->quests[quest->quest->qid] = nullptr;
 		for (auto &player : gs->players)
 		{
-			for (auto &q : player.second.quests)
-			{
-				if (q.obj == obj)
-				{
-					q.obj = nullptr;
-				}
-			}
+			vstd::erase_if(player.second.quests, [obj](const QuestInfo & q){
+				return q.obj == obj;
+			});
 		}
 	}