Browse Source

fix for chest_traps not existing in DB

Image 4 years ago
parent
commit
16814d1787
2 changed files with 25 additions and 19 deletions
  1. 5 2
      EQ2/source/WorldServer/Zone/ChestTrap.cpp
  2. 20 17
      EQ2/source/WorldServer/client.cpp

+ 5 - 2
EQ2/source/WorldServer/Zone/ChestTrap.cpp

@@ -47,10 +47,10 @@ bool ChestTrapList::GetNextTrap(int32 zoneid, int32 chest_difficulty, ChestTrap:
 	ChestTrapList* zoneTrapList = GetChestListByZone(zoneid);
 	ChestTrapList* zoneDifficultyTrapList = zoneTrapList->GetChestListByDifficulty(chest_difficulty);
 
-	zoneTrapList->GetNextChestTrap(cti);
+	bool ret = zoneTrapList->GetNextChestTrap(cti);
 	MChestListsInUse.releasewritelock(__FUNCTION__, __LINE__);
 
-	return true;
+	return ret;
 }
 
 void ChestTrapList::Clear() {
@@ -71,6 +71,9 @@ bool ChestTrapList::GetNextChestTrap(ChestTrap::ChestTrapInfo* cti) {
 	else
 		MChestTrapList.releasereadlock(__FUNCTION__, __LINE__);
 
+	if (cycleItr == chesttrap_list.end())
+		return false;
+
 	MChestTrapList.writelock(__FUNCTION__, __LINE__);
 	ChestTrap* trap = cycleItr->second;
 

+ 20 - 17
EQ2/source/WorldServer/client.cpp

@@ -4066,32 +4066,35 @@ void Client::OpenChest(Entity* entity, bool attemptDisarm)
 	{
 		ChestTrap::ChestTrapInfo nextTrap;
 		
-		chest_trap_list.GetNextTrap(GetCurrentZone()->GetZoneID(), chest_difficulty, &nextTrap);
+		bool ret = chest_trap_list.GetNextTrap(GetCurrentZone()->GetZoneID(), chest_difficulty, &nextTrap);
 
 		Skill* disarmSkill = GetPlayer()->GetSkillByName("Disarm Trap", false);
 		firstChestOpen = true;
 		entity->SetTrapTriggered(true);
-		if (disarmSkill && attemptDisarm)
+		if (ret)
 		{
-			if (disarmSkill->CheckDisarmSkill(entity->GetLevel(), chest_difficulty) < 1)
+			if (disarmSkill && attemptDisarm)
 			{
-				CastGroupOrSelf(entity, nextTrap.spell_id, nextTrap.spell_tier, 
-					rule_manager.GetGlobalRule(R_Loot, ChestTriggerRadiusGroup)->GetFloat());
-				Message(CHANNEL_COLOR_WHITE, "You trigger the trap on %s!", modelName.c_str());
+				if (disarmSkill->CheckDisarmSkill(entity->GetLevel(), chest_difficulty) < 1)
+				{
+					CastGroupOrSelf(entity, nextTrap.spell_id, nextTrap.spell_tier,
+						rule_manager.GetGlobalRule(R_Loot, ChestTriggerRadiusGroup)->GetFloat());
+					Message(CHANNEL_COLOR_WHITE, "You trigger the trap on %s!", modelName.c_str());
+				}
+				else
+				{
+					Message(CHANNEL_COLOR_WHITE, "You disarm the trap on %s", modelName.c_str());
+				}
+
+				// despite fail/succeed we should always try to increase skill if disarm is available
+				GetPlayer()->GetSkillByName("Disarm Trap", true);
 			}
-			else
+			else // no disarm skill, always fail
 			{
-				Message(CHANNEL_COLOR_WHITE, "You disarm the trap on %s", modelName.c_str());
+				CastGroupOrSelf(entity, nextTrap.spell_id, nextTrap.spell_tier,
+					rule_manager.GetGlobalRule(R_Loot, ChestTriggerRadiusGroup)->GetFloat());
+				Message(CHANNEL_COLOR_WHITE, "You trigger the trap on %s!", modelName.c_str());
 			}
-
-			// despite fail/succeed we should always try to increase skill if disarm is available
-			GetPlayer()->GetSkillByName("Disarm Trap", true);
-		}
-		else // no disarm skill, always fail
-		{
-			CastGroupOrSelf(entity, nextTrap.spell_id, nextTrap.spell_tier, 
-				rule_manager.GetGlobalRule(R_Loot, ChestTriggerRadiusGroup)->GetFloat());
-			Message(CHANNEL_COLOR_WHITE, "You trigger the trap on %s!", modelName.c_str());
 		}
 	}
 	else if(!entity->HasTrapTriggered())