Browse Source

Fix GetQuestCompleteCount LUA crash since the quest never was in the player completed

Emagi 1 year ago
parent
commit
725a3f85d8
2 changed files with 6 additions and 4 deletions
  1. 5 3
      EQ2/source/WorldServer/Player.cpp
  2. 1 1
      EQ2/source/WorldServer/Player.h

+ 5 - 3
EQ2/source/WorldServer/Player.cpp

@@ -4193,11 +4193,11 @@ bool Player::WasSpawnRemoved(Spawn* spawn){
 	return wasRemoved;
 }
 
-void Player::RemoveSpawn(Spawn* spawn)
+void Player::RemoveSpawn(Spawn* spawn, bool delete_spawn)
 {
 	LogWrite(PLAYER__DEBUG, 3, "Player", "Remove Spawn '%s' (%u)", spawn->GetName(), spawn->GetID());
 
-	SetSpawnSentState(spawn, SpawnState::SPAWN_STATE_REMOVING);
+	SetSpawnSentState(spawn, delete_spawn ? SpawnState::SPAWN_STATE_REMOVING : SpawnState::SPAWN_STATE_REMOVING_SLEEP);
 	
 	info_mutex.writelock(__FUNCTION__, __LINE__);
 	vis_mutex.writelock(__FUNCTION__, __LINE__);
@@ -4782,7 +4782,9 @@ int32 Player::GetQuestCompletedCount(int32 quest_id) {
 	int32 count = 0;
 	MPlayerQuests.readlock(__FUNCTION__, __LINE__);
 	Quest* quest = GetCompletedQuest(quest_id);
-	count = quest->GetCompleteCount();
+	if(quest) {
+		count = quest->GetCompleteCount();
+	}
 	MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
 	return count;
 }

+ 1 - 1
EQ2/source/WorldServer/Player.h

@@ -638,7 +638,7 @@ public:
 	Spawn*	GetSpawnByIndex(int16 index);
 	int16	GetIndexForSpawn(Spawn* spawn);
 	bool	WasSpawnRemoved(Spawn* spawn);
-	void	RemoveSpawn(Spawn* spawn);
+	void	RemoveSpawn(Spawn* spawn, bool delete_spawn = true);
 	bool	ShouldSendSpawn(Spawn* spawn);
 	Client* client = 0;
 	void SetLevel(int16 level, bool setUpdateFlags = true);