Browse Source

Better grid retrieval due to Y offset (WIP), fixed crash on maintained spell effects

Image 2 years ago
parent
commit
8bec33ebd9

+ 3 - 3
EQ2/source/WorldServer/SpellProcess.cpp

@@ -1936,7 +1936,7 @@ void SpellProcess::RemoveSpellTimersFromSpawn(Spawn* spawn, bool remove_all, boo
 				if (spawn->GetID() == spell->targets.at(i)){
 					if (spawn->IsEntity())
 						((Entity*)spawn)->RemoveSpellEffect(spell);
-					RemoveTargetFromSpell(spell, spawn);
+					RemoveTargetFromSpell(spell, spawn, remove_all);
 					break;
 				}
 			}
@@ -2626,14 +2626,14 @@ void SpellProcess::ClearSpellScriptTimerList() {
 	MSpellScriptTimers.releasewritelock(__FUNCTION__, __LINE__);
 }
 
-void SpellProcess::RemoveTargetFromSpell(LuaSpell* spell, Spawn* target){
+void SpellProcess::RemoveTargetFromSpell(LuaSpell* spell, Spawn* target, bool removeCaster){
 	if (!spell || !target)
 		return;
 
 	LogWrite(SPELL__DEBUG, 0, "Spell", "%s RemoveTargetFromSpell %s (%u).", spell->spell->GetName(), target->GetName(), target->GetID());
 	MRemoveTargetList.writelock(__FUNCTION__, __LINE__);
 
-	if(spell->caster && spell->caster == target)
+	if(removeCaster && spell->caster && spell->caster == target)
 		spell->caster = nullptr;
 
 	if (!remove_target_list[spell])

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

@@ -365,7 +365,7 @@ public:
 
 	MutexList<LuaSpell*>* GetActiveSpells() { return &active_spells; }
 
-	void RemoveTargetFromSpell(LuaSpell* spell, Spawn* target);
+	void RemoveTargetFromSpell(LuaSpell* spell, Spawn* target, bool remove_caster = false);
 	void CheckRemoveTargetFromSpell(LuaSpell* spell, bool allow_delete = true, bool removing_all_spells = false);
 
 	/// <summary>Adds a solo HO to the SpellProcess</summary>

+ 1 - 1
EQ2/source/WorldServer/Zone/SPGrid.cpp

@@ -342,7 +342,7 @@ int32 SPGrid::GetGridID(Spawn * spawn) {
 	// Create the starting point for the trace
 	float point[3];
 	point[0] = spawn->GetX();
-	point[1] = spawn->GetY() + 3.0f; // Small bump to make sure we are above ground when we do the trace
+	point[1] = spawn->GetY() + 3.0f + (float)(spawn->GetCollisionRadius()/32.0f); // Small bump to make sure we are above ground when we do the trace
 	point[2] = spawn->GetZ();
 
 	// Create the direction for the trace, as we want what

+ 2 - 2
EQ2/source/WorldServer/zoneserver.cpp

@@ -6869,9 +6869,9 @@ void ZoneServer::DismissAllPets() {
 	MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
 }
 
-void ZoneServer::RemoveTargetFromSpell(LuaSpell* spell, Spawn* target){
+void ZoneServer::RemoveTargetFromSpell(LuaSpell* spell, Spawn* target, bool remove_caster){
 	if (spellProcess)
-		spellProcess->RemoveTargetFromSpell(spell, target);
+		spellProcess->RemoveTargetFromSpell(spell, target, remove_caster);
 }
 
 void ZoneServer::ClearHate(Entity* entity) {

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

@@ -405,7 +405,7 @@ public:
 	void	SendUpdateTitles(Client *client, Title *suffix = 0, Title *prefix = 0);
 	void	SendUpdateTitles(Spawn *spawn, Title *suffix = 0, Title *prefix = 0);
 	
-	void    RemoveTargetFromSpell(LuaSpell* spell, Spawn* target);
+	void    RemoveTargetFromSpell(LuaSpell* spell, Spawn* target, bool remove_caster = false);
 
 	/// <summary>Set the rain levl in the zone</summary>
 	/// <param name='val'>Level of rain in the zone 0.0 - 1.1 (rain starts at 0.76)</param>