Emagi před 1 rokem
rodič
revize
972c9b575c

+ 0 - 7
EQ2/source/WorldServer/SpellProcess.cpp

@@ -871,13 +871,6 @@ void SpellProcess::RemoveSpellFromQueue(Entity* caster, bool hostile_only) {
 	}
 }
 
-void SpellProcess::CheckSpellQueue(Entity* caster){
-	if(caster && caster->IsPlayer()){
-		if(spell_que.count(caster) > 0)
-			RemoveSpellFromQueue(spell_que.Get(caster), caster);	
-	}
-}
-
 bool SpellProcess::CheckSpellQueue(Spell* spell, Entity* caster){
 	if(caster->IsPlayer()){
 		bool add = true;

+ 0 - 4
EQ2/source/WorldServer/SpellProcess.h

@@ -295,10 +295,6 @@ public:
 	/// <param name='hostile_only'>Set to true to only remove hostile spells, default is false</param>
 	void RemoveSpellFromQueue(Entity* caster, bool hostile_only = false);
 
-	/// <summary>Clear the queue for the given caster</summary>
-	/// <param name='caster'>Entity to clear the queue for, is not player function does nothing</param>
-	void CheckSpellQueue(Entity* caster);
-
 	/// <summary>Check the given enities queue for the spell, if found remove, if not found add</summary>
 	/// <param name='spell'>Spell to check for</param>
 	/// <param name='caster'>Entity's queue to check, if not player function does nothing</param>

+ 44 - 16
EQ2/source/WorldServer/zoneserver.cpp

@@ -3842,31 +3842,49 @@ void ZoneServer::AddWidgetTimer(Spawn* widget, float time) {
 Spawn*	ZoneServer::GetSpawnGroup(int32 id){
 	Spawn* ret = 0;
 	Spawn* spawn = 0;
-	map<int32, Spawn*>::iterator itr;
-	MSpawnList.readlock(__FUNCTION__, __LINE__);
-	for (itr = spawn_list.begin(); itr != spawn_list.end(); itr++) {
-		spawn = itr->second;
-		if(spawn){
-			if(spawn->GetSpawnGroupID() == id){
-				ret = spawn;
-				break;
+	
+	if(id < 1)
+		return 0;
+	
+	if(quick_group_id_lookup.count(id) > 0)
+		ret = GetSpawnByID(quick_group_id_lookup.Get(id));
+	else{
+		map<int32, Spawn*>::iterator itr;
+		MSpawnList.readlock(__FUNCTION__, __LINE__);
+		for (itr = spawn_list.begin(); itr != spawn_list.end(); itr++) {
+			spawn = itr->second;
+			if(spawn){
+				if(spawn->GetSpawnGroupID() == id){
+					ret = spawn;
+					quick_group_id_lookup.Put(id, spawn->GetID());
+					break;
+				}
 			}
 		}
+		MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
 	}
-	MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
 	return ret;
 }
 
 Spawn* ZoneServer::GetSpawnByLocationID(int32 location_id) {
 	Spawn* ret = 0;
 	Spawn* current_spawn = 0;
-	map<int32, Spawn*>::iterator itr;
-	MSpawnList.readlock(__FUNCTION__, __LINE__);
-	for (itr = spawn_list.begin(); itr != spawn_list.end(); itr++) {
-		current_spawn = itr->second;
-		if (current_spawn && current_spawn->GetSpawnLocationID() == location_id) {
-			ret = current_spawn;
-			break;
+	
+	if(location_id < 1)
+		return 0;
+	
+	if(quick_location_id_lookup.count(location_id) > 0)
+		ret = GetSpawnByID(quick_location_id_lookup.Get(location_id));
+	else{
+		map<int32, Spawn*>::iterator itr;
+		MSpawnList.readlock(__FUNCTION__, __LINE__);
+		for (itr = spawn_list.begin(); itr != spawn_list.end(); itr++) {
+			current_spawn = itr->second;
+			if (current_spawn && current_spawn->GetSpawnLocationID() == location_id) {
+				ret = current_spawn;
+				quick_group_id_lookup.Put(location_id, ret->GetID());
+				break;
+			}
 		}
 	}
 	MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
@@ -3875,6 +3893,10 @@ Spawn* ZoneServer::GetSpawnByLocationID(int32 location_id) {
 
 Spawn*	ZoneServer::GetSpawnByDatabaseID(int32 id){
 	Spawn* ret = 0;
+	
+	if(id < 1)
+		return 0;
+	
 	if(quick_database_id_lookup.count(id) > 0)
 		ret = GetSpawnByID(quick_database_id_lookup.Get(id));
 	else{
@@ -6094,6 +6116,12 @@ void ZoneServer::RemoveSpawnSupportFunctions(Spawn* spawn, bool lock_spell_proce
 		if (!spawn->IsPlayer()) {
 			if(quick_database_id_lookup.count(spawn->GetDatabaseID()) > 0)
 				quick_database_id_lookup.erase(spawn->GetDatabaseID());
+			
+			if(spawn->GetSpawnLocationID() > 0 && quick_location_id_lookup.count(spawn->GetSpawnLocationID()) > 0 && quick_location_id_lookup.Get(spawn->GetSpawnLocationID()) == spawn->GetID())
+				quick_location_id_lookup.erase(spawn->GetSpawnLocationID());
+			
+			if(spawn->GetSpawnGroupID() > 0 && quick_group_id_lookup.count(spawn->GetSpawnGroupID()) > 0 && quick_group_id_lookup.Get(spawn->GetSpawnGroupID()) == spawn->GetID())
+				quick_group_id_lookup.erase(spawn->GetSpawnGroupID());
 		}
 
 		DeleteSpawnScriptTimers(spawn);

+ 2 - 0
EQ2/source/WorldServer/zoneserver.h

@@ -799,6 +799,8 @@ private:
 	MutexMap<int32, PlayerProximity*>				player_proximities;								// 1st int32 = spawn id
 	MutexMap<int32, Player*>						players_tracking;
 	MutexMap<int32, int32>							quick_database_id_lookup;						// 1st int32 = database id, 2nd int32 = spawn id
+	MutexMap<int32, int32>							quick_location_id_lookup;						// 1st int32 = location id, 2nd int32 = spawn id
+	MutexMap<int32, int32>							quick_group_id_lookup;							// 1st int32 = group id, 2nd int32 = spawn id
 	MutexMap<int32, int32>							respawn_timers;
 	map<Spawn*, int32>								spawn_delete_list;
 	MutexMap<int32, int32>							spawn_expire_timers;							// 1st int32 = spawn id