فهرست منبع

Merge branch 'master' of http://cutpon.com:3000/devn00b/EQ2EMu

LethalEncounter 4 سال پیش
والد
کامیت
274ec84b47

+ 210 - 0
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -10492,6 +10492,8 @@ int EQ2Emu_lua_GetSpell(lua_State* state) {
 
 		lua_spell->spell = new Spell(spell);
 
+		lua_interface->AddCustomSpell(lua_spell);
+
 		lua_interface->SetSpellValue(state, lua_spell);
 		return 1;
 	}
@@ -10545,7 +10547,215 @@ int EQ2Emu_lua_SetSpellData(lua_State* state) {
 	return valSet;
 }
 
+int EQ2Emu_lua_SetSpellDataIndex(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	LuaSpell* spell = lua_interface->GetSpell(state);
+	int8 idx = lua_interface->GetInt32Value(state, 2);
+
+	if (!spell) {
+		lua_interface->LogError("%s: Spell not given in SetSpellDataIndex!", lua_interface->GetScriptName(state));
+		return 0;
+	}
+	if (!spell->spell || !spell->spell->GetSpellData()) {
+		lua_interface->LogError("%s: Inner Spell or SpellData not given in SetSpellDataIndex!", lua_interface->GetScriptName(state));
+		return 0;
+	}
+
+	if (spell->spell->lua_data.size() <= idx)
+	{
+		lua_interface->LogError("%s: lua_data size %i <= %i (idx passed) SetSpellDataIndex!", lua_interface->GetScriptName(state), spell->spell->lua_data.size(), idx);
+		return 0;
+	}
+
+	bool setVal = true;
+
+	LUAData* data = spell->spell->lua_data[idx];
+
+	switch (data->type)
+	{
+	case 0:
+	{
+		sint32 value = lua_interface->GetSInt32Value(state, 3);
+		sint32 value2 = lua_interface->GetSInt32Value(state, 4);
+		data->int_value = value;
+		data->int_value2 = value2;
+		break;
+	}
+	case 1:
+	{
+		float value = lua_interface->GetFloatValue(state, 3);
+		float value2 = lua_interface->GetFloatValue(state, 4);
+		data->float_value = value;
+		data->float_value2 = value2;
+		break;
+	}
+	case 2:
+	{
+		bool value = lua_interface->GetBooleanValue(state, 3);
+		data->bool_value = value;
+		break;
+	}
+	case 3:
+	{
+		string value = lua_interface->GetStringValue(state, 3);
+		string value2 = lua_interface->GetStringValue(state, 4);
+		data->string_value = value;
+		data->string_value2 = value2;
+		break;
+	}
+	default:
+		setVal = false;
+	}
+
+	return setVal;
+}
+
+
+int EQ2Emu_lua_GetSpellDataIndex(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	LuaSpell* spell = lua_interface->GetSpell(state);
+	int8 idx = lua_interface->GetInt32Value(state, 2);
+	bool secondfield = lua_interface->GetBooleanValue(state, 3);
+
+	if (!spell) {
+		lua_interface->LogError("%s: Spell not given in GetSpellDataIndex!", lua_interface->GetScriptName(state));
+		return 0;
+	}
+	if (!spell->spell || !spell->spell->GetSpellData()) {
+		lua_interface->LogError("%s: Inner Spell or SpellData not given in GetSpellDataIndex!", lua_interface->GetScriptName(state));
+		return 0;
+	}
+
+	if (spell->spell->lua_data.size() <= idx)
+	{
+		lua_interface->LogError("%s: lua_data size %i <= %i (idx passed) GetSpellDataIndex!", lua_interface->GetScriptName(state), spell->spell->lua_data.size(), idx);
+		return 0;
+	}
+
+	bool setVal = true;
+
+	LUAData* data = spell->spell->lua_data[idx];
+
+	switch (data->type)
+	{
+	case 0:
+	{
+		if(!secondfield)
+			lua_interface->SetSInt32Value(state, data->int_value);
+		else
+			lua_interface->SetSInt32Value(state, data->int_value2);
+		break;
+	}
+	case 1:
+	{
+		if (!secondfield)
+			lua_interface->SetFloatValue(state, data->float_value);
+		else
+			lua_interface->SetFloatValue(state, data->float_value2);
+		break;
+	}
+	case 2:
+	{
+		lua_interface->SetBooleanValue(state, data->bool_value);
+		break;
+	}
+	case 3:
+	{
+		if (!secondfield)
+			lua_interface->SetStringValue(state, data->string_value.c_str());
+		else
+			lua_interface->SetStringValue(state, data->string_value2.c_str());
+		break;
+	}
+	default:
+		setVal = false;
+	}
+
+	return setVal;
+}
+
+
+int EQ2Emu_lua_SetSpellDisplayEffect(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	LuaSpell* spell = lua_interface->GetSpell(state);
+	int8 idx = lua_interface->GetInt32Value(state, 2);
+	string field = lua_interface->GetStringValue(state, 3);
+
+	boost::to_lower(field);
+
+	if (!spell) {
+		lua_interface->LogError("%s: Spell not given in SetSpellDisplayEffect!", lua_interface->GetScriptName(state));
+		return 0;
+	}
+	if (!spell->spell || !spell->spell->GetSpellData()) {
+		lua_interface->LogError("%s: Inner Spell or SpellData not given in SetSpellDisplayEffect!", lua_interface->GetScriptName(state));
+		return 0;
+	}
+
+	if (spell->spell->effects.size() <= idx)
+	{
+		lua_interface->LogError("%s: lua_data size %i <= %i (idx passed) SetSpellDisplayEffect!", lua_interface->GetScriptName(state), spell->spell->lua_data.size(), idx);
+		return 0;
+	}
+
+	// do we need to lock? eh probably not this should only be used before use of the custom spell
+	SpellDisplayEffect* effect = spell->spell->effects[idx];
+
+	if (field == "description")
+		effect->description = string(lua_interface->GetStringValue(state, 4));
+	else if (field == "bullet")
+		effect->subbullet = lua_interface->GetInt8Value(state, 4);
+	else if (field == "percentage")
+		effect->percentage = lua_interface->GetInt8Value(state, 4);
+	else // no match
+		return 0;
+
+
+	return 1;
+}
+
+int EQ2Emu_lua_GetSpellDisplayEffect(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	LuaSpell* spell = lua_interface->GetSpell(state);
+	int8 idx = lua_interface->GetInt32Value(state, 2);
+	string field = lua_interface->GetStringValue(state, 3);
+
+	boost::to_lower(field);
+
+	if (!spell) {
+		lua_interface->LogError("%s: Spell not given in GetSpellDisplayEffect!", lua_interface->GetScriptName(state));
+		return 0;
+	}
+	if (!spell->spell || !spell->spell->GetSpellData()) {
+		lua_interface->LogError("%s: Inner Spell or SpellData not given in GetSpellDisplayEffect!", lua_interface->GetScriptName(state));
+		return 0;
+	}
+
+	if (spell->spell->effects.size() <= idx)
+	{
+		lua_interface->LogError("%s: lua_data size %i <= %i (idx passed) GetSpellDisplayEffect!", lua_interface->GetScriptName(state), spell->spell->lua_data.size(), idx);
+		return 0;
+	}
+
+	// do we need to lock? eh probably not this should only be used before use of the custom spell
+	SpellDisplayEffect* effect = spell->spell->effects[idx];
+
+	if (field == "description")
+		lua_interface->SetStringValue(state, effect->description.c_str());
+	else if (field == "bullet")
+		lua_interface->SetInt32Value(state, effect->subbullet);
+	else if (field == "percentage")
+		lua_interface->SetInt32Value(state, effect->percentage);
+	else // no match
+		return 0;
+
 
+	return 1;
+}
 int EQ2Emu_lua_CastCustomSpell(lua_State* state) {
 	if (!lua_interface)
 		return 0;

+ 6 - 0
EQ2/source/WorldServer/LuaFunctions.h

@@ -484,4 +484,10 @@ int EQ2Emu_lua_GetSpell(lua_State* state);
 int EQ2Emu_lua_GetSpellData(lua_State* state);
 int EQ2Emu_lua_SetSpellData(lua_State* state);
 int EQ2Emu_lua_CastCustomSpell(lua_State* state);
+
+int EQ2Emu_lua_SetSpellDataIndex(lua_State* state);
+int EQ2Emu_lua_GetSpellDataIndex(lua_State* state);
+
+int EQ2Emu_lua_SetSpellDisplayEffect(lua_State* state);
+int EQ2Emu_lua_GetSpellDisplayEffect(lua_State* state);
 #endif

+ 60 - 3
EQ2/source/WorldServer/LuaInterface.cpp

@@ -47,6 +47,8 @@ LuaInterface::LuaInterface() {
 	MLUAUserData.SetName("LuaInterface::MLUAUserData");
 	MLUAMain.SetName("LuaInterface::MLUAMain");
 	MItemScripts.SetName("LuaInterface::MItemScripts");
+	MSpellDelete.SetName("LuaInterface::MSpellDelete");
+	MCustomSpell.SetName("LuaInterface::MCustomSpell");
 	user_data_timer = new Timer(20000);
 	user_data_timer->Start();
 	spell_delete_timer = new Timer(5000);
@@ -475,7 +477,7 @@ bool LuaInterface::LoadZoneScript(string name) {
 	return LoadZoneScript(name.c_str());
 }
 
-void LuaInterface::AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast, const char* function, SpellScriptTimer* timer) {
+void LuaInterface::AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast, const char* function, SpellScriptTimer* timer, bool passLuaSpell) {
 	if (function)
 		lua_getglobal(spell->state, function);
 	else if (precast)
@@ -485,6 +487,9 @@ void LuaInterface::AddSpawnPointers(LuaSpell* spell, bool first_cast, bool preca
 	else
 		lua_getglobal(spell->state, "tick");
 
+	if(passLuaSpell)
+		SetSpellValue(spell->state, spell);
+
 	Spawn* temp_spawn = 0;
 	if (timer && timer->caster && spell->caster)
 		temp_spawn = spell->caster->GetZone()->GetSpawnByID(timer->caster);
@@ -636,7 +641,8 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
 		MSpells.lock();
 		current_spells[spell->state] = spell;
 		MSpells.unlock();
-		lua_pcall(spell->state, 3, 0, 0);
+		lua_pcall(spell->state, 3, 0, 0); 
+		ResetFunctionStack(spell->state);
 	}
 
 	spell->MSpellTargets.readlock(__FUNCTION__, __LINE__);
@@ -755,6 +761,7 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
 	lua_register(state, "Say", EQ2Emu_lua_Say);
 	lua_register(state, "SayOOC", EQ2Emu_lua_SayOOC);
 	lua_register(state, "Emote", EQ2Emu_lua_Emote);
+	lua_register(state, "MovementLoopAddLocation", EQ2Emu_lua_MovementLoopAdd); // do not remove this function, it is already heavily used by the content team
 	lua_register(state, "MovementLoopAdd", EQ2Emu_lua_MovementLoopAdd);
 	lua_register(state, "GetCurrentZoneSafeLocation", EQ2Emu_lua_GetCurrentZoneSafeLocation);
 	lua_register(state, "AddTimer", EQ2Emu_lua_AddTimer);
@@ -1106,6 +1113,12 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
 	lua_register(state, "GetSpellData", EQ2Emu_lua_GetSpellData);
 	lua_register(state, "SetSpellData", EQ2Emu_lua_SetSpellData);
 	lua_register(state, "CastCustomSpell", EQ2Emu_lua_CastCustomSpell);
+
+	lua_register(state, "SetSpellDataIndex", EQ2Emu_lua_SetSpellDataIndex);
+	lua_register(state, "GetSpellDataIndex", EQ2Emu_lua_GetSpellDataIndex);
+
+	lua_register(state, "SetSpellDisplayEffect", EQ2Emu_lua_SetSpellDisplayEffect);
+	lua_register(state, "GetSpellDisplayEffect", EQ2Emu_lua_GetSpellDisplayEffect);
 }
 
 void LuaInterface::LogError(const char* error, ...)  {
@@ -1150,7 +1163,10 @@ void LuaInterface::DeletePendingSpells(bool all) {
 			spells_pending_delete.erase(spell);
 
 			if (spell->spell->IsCopiedSpell())
+			{
+				RemoveCustomSpell(spell->spell->GetSpellID());
 				safe_delete(spell->spell);
+			}
 
 			safe_delete(spell);
 		}
@@ -1706,7 +1722,6 @@ bool LuaInterface::RunItemScript(string script_name, const char* function_name,
 			return false;
 		}
 		lua_getglobal(state, function_name);
-		lua_getglobal(state, function_name);
 		if (!lua_isfunction(state, lua_gettop(state))){
 			lua_pop(state, 1);
 			mutex->releasereadlock(__FUNCTION__);
@@ -1853,6 +1868,48 @@ void LuaInterface::AddPendingSpellDelete(LuaSpell* spell) {
 	MSpellDelete.unlock();
 }
 
+void LuaInterface::AddCustomSpell(LuaSpell* spell)
+{
+	MCustomSpell.writelock();
+	custom_spells[spell->spell->GetSpellID()] = spell;
+	MCustomSpell.releasewritelock();
+}
+
+void LuaInterface::RemoveCustomSpell(int32 id)
+{
+	MCustomSpell.writelock();
+	map<int32, LuaSpell*>::iterator itr = custom_spells.find(id);
+	if (itr != custom_spells.end())
+	{
+		custom_spells.erase(itr);
+		custom_free_spell_ids.push_front(id);
+	}
+	MCustomSpell.releasewritelock();
+}
+
+// prior to calling FindCustomSpell you should call FindCustomSpellLock and after FindCustomSpellUnlock
+LuaSpell* LuaInterface::FindCustomSpell(int32 id)
+{
+	LuaSpell* spell = 0;
+	map<int32, LuaSpell*>::iterator itr = custom_spells.find(id);
+	if (itr != custom_spells.end())
+		spell = itr->second;
+	return spell;
+}
+
+int32 LuaInterface::GetFreeCustomSpellID()
+{ 
+	int32 id = 0;
+	MCustomSpell.writelock();
+	if (!custom_free_spell_ids.empty())
+	{
+		id = custom_free_spell_ids.front();
+		custom_free_spell_ids.pop_front();
+	}
+	MCustomSpell.releasewritelock();
+	return id;
+}
+
 LUAUserData::LUAUserData(){
 	correctly_initialized = false;
 	quest = 0;

+ 14 - 1
EQ2/source/WorldServer/LuaInterface.h

@@ -222,7 +222,7 @@ public:
 	void			SetConversationValue(lua_State* state, vector<ConversationOption>* conversation);
 	void			SetOptionWindowValue(lua_State* state, vector<OptionWindowOption>* optionWindow);
 
-	void			AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast = false, const char* function = 0, SpellScriptTimer* timer = 0);
+	void			AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast = false, const char* function = 0, SpellScriptTimer* timer = 0, bool passLuaSpell=false);
 	LuaSpell*		GetCurrentSpell(lua_State* state);
 	bool			CallSpellProcess(LuaSpell* spell, int8 num_parameters);
 	LuaSpell*		GetSpell(const char* name);
@@ -271,6 +271,15 @@ public:
 	void			SetSpawnScriptsReloading(bool val) { spawn_scripts_reloading = val; }
 
 	void			AddPendingSpellDelete(LuaSpell* spell);
+
+	void			AddCustomSpell(LuaSpell* spell);
+	void			RemoveCustomSpell(int32 id);
+
+	void			FindCustomSpellLock() { MCustomSpell.readlock(); }
+	void			FindCustomSpellUnlock() { MCustomSpell.releasereadlock(); }
+	LuaSpell*		FindCustomSpell(int32 id);
+
+	int32			GetFreeCustomSpellID();
 private:
 	bool			shutting_down;
 	bool			spawn_scripts_reloading;
@@ -292,6 +301,9 @@ private:
 	map<string, map<lua_State*, bool> > spawn_scripts;
 	map<string, map<lua_State*, bool> > zone_scripts;
 
+	map<int32, LuaSpell*> custom_spells;
+	std::deque<int32> custom_free_spell_ids;
+
 	map<lua_State*, string> item_inverse_scripts;
 	map<lua_State*, string> spawn_inverse_scripts;
 	map<lua_State*, string> zone_inverse_scripts;
@@ -309,5 +321,6 @@ private:
 	Mutex			MLUAUserData;
 	Mutex			MLUAMain;
 	Mutex			MSpellDelete;
+	Mutex			MCustomSpell;
 };
 #endif

+ 48 - 1
EQ2/source/WorldServer/SpellProcess.cpp

@@ -475,6 +475,28 @@ bool SpellProcess::CastInstant(Spell* spell, Entity* caster, Entity* target, boo
 	lua_spell->initial_target = target->GetID();
 	GetSpellTargets(lua_spell);
 
+	if (!lua_spell->spell->IsCopiedSpell())
+	{
+		lua_getglobal(lua_spell->state, "customspell");
+		if (lua_isfunction(lua_spell->state, lua_gettop(lua_spell->state))) {
+			lua_pop(lua_spell->state, 1);
+			Spell* tmpSpell = lua_spell->spell;
+			lua_spell->spell = new Spell(lua_spell->spell);
+			lua_interface->AddCustomSpell(lua_spell);
+			lua_interface->AddSpawnPointers(lua_spell, false, false, "customspell",0,true);
+			if (lua_pcall(lua_spell->state, 3, 3, 0) != 0) {
+				lua_interface->RemoveCustomSpell(lua_spell->spell->GetSpellID());
+				lua_interface->ResetFunctionStack(lua_spell->state);
+				safe_delete(lua_spell->spell);
+				lua_spell->spell = tmpSpell;
+			}
+			else
+				lua_interface->ResetFunctionStack(lua_spell->state);
+		}
+		else
+			lua_interface->ResetFunctionStack(lua_spell->state);
+	}
+
 	caster->GetZone()->SendCastSpellPacket(lua_spell, caster);
 
 	if (!remove)
@@ -787,7 +809,6 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
 {
 	if((customSpell != 0 || spell != 0) && caster)
 	{
-
 		Client* client = 0;
 		//int16 version = 0;
 
@@ -823,6 +844,7 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
 
 		lua_spell->caster = caster;
 		lua_spell->spell = spell;
+
 		int32 target_id = target->GetID();
 		lua_spell->initial_target = target_id;
 
@@ -852,6 +874,28 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
 			//version = client->GetVersion();
 		}
 
+		if (!customSpell && !lua_spell->spell->IsCopiedSpell())
+		{
+			lua_getglobal(lua_spell->state, "customspell");
+			if (lua_isfunction(lua_spell->state, lua_gettop(lua_spell->state))) {
+				lua_pop(lua_spell->state, 1);
+				Spell* tmpSpell = lua_spell->spell;
+				lua_spell->spell = new Spell(lua_spell->spell);
+				lua_interface->AddCustomSpell(lua_spell);
+				lua_interface->AddSpawnPointers(lua_spell, false, false, "customspell", 0, true);
+				if (lua_pcall(lua_spell->state, 3, 3, 0) != 0) {
+					lua_interface->RemoveCustomSpell(lua_spell->spell->GetSpellID());
+					lua_interface->ResetFunctionStack(lua_spell->state);
+					safe_delete(lua_spell->spell);
+					lua_spell->spell = tmpSpell;
+				}
+				else
+					lua_interface->ResetFunctionStack(lua_spell->state);
+			}
+			else
+				lua_interface->ResetFunctionStack(lua_spell->state);
+		}
+
 		//If this spell is the toggle cast type and is being toggled off, do this now
 		if (spell->GetSpellData()->cast_type == SPELL_CAST_TYPE_TOGGLE)
 		{
@@ -2446,7 +2490,10 @@ void SpellProcess::DeleteSpell(LuaSpell* spell)
 	RemoveSpellFromQueue(spell->spell, spell->caster);
 
 	if (spell->spell->IsCopiedSpell())
+	{
+		lua_interface->RemoveCustomSpell(spell->spell->GetSpellID());
 		safe_delete(spell->spell);
+	}
 
 	safe_delete(spell);
 }

+ 69 - 2
EQ2/source/WorldServer/Spells.cpp

@@ -52,6 +52,15 @@ Spell::Spell(Spell* host_spell)
 
 	if (host_spell->GetSpellData())
 	{
+		// try inheriting an existing custom spell id, otherwise obtain the new highest number on the spell list
+		int32 tmpid = lua_interface->GetFreeCustomSpellID();
+		if (tmpid)
+			spell->id = tmpid;
+		else
+		{
+			spell->id = master_spell_list.GetNewMaxSpellID();
+		}
+
 		spell->affect_only_group_members = host_spell->GetSpellData()->affect_only_group_members;
 		spell->call_frequency = host_spell->GetSpellData()->call_frequency;
 		spell->can_effect_raid = host_spell->GetSpellData()->can_effect_raid;
@@ -88,8 +97,6 @@ Spell::Spell(Spell* host_spell)
 
 		spell->icon_heroic_op = host_spell->GetSpellData()->icon_heroic_op;
 
-		spell->id = host_spell->GetSpellData()->id;
-
 		spell->incurable = host_spell->GetSpellData()->incurable;
 		spell->interruptable = host_spell->GetSpellData()->interruptable;
 		spell->is_aa = host_spell->GetSpellData()->is_aa;
@@ -2096,6 +2103,7 @@ bool Spell::ScribeAllowed(Player* player){
 }
 
 MasterSpellList::MasterSpellList(){
+	max_spell_id = 0;
 	MMasterSpellList.SetName("MasterSpellList::MMasterSpellList");
 }
 
@@ -2122,6 +2130,10 @@ void MasterSpellList::AddSpell(int32 id, int8 tier, Spell* spell){
 	spell_list[id][tier] = spell;
 	spell_name_map[spell->GetName()] = spell;
 	spell_soecrc_map[spell->GetSpellData()->soe_spell_crc] = spell;
+
+	if (id > max_spell_id)
+		max_spell_id = id;
+
 	MMasterSpellList.unlock();
 }
 
@@ -2147,12 +2159,50 @@ Spell* MasterSpellList::GetSpellByCRC(int32 spell_crc){
 
 EQ2Packet* MasterSpellList::GetSpellPacket(int32 id, int8 tier, Client* client, bool display, int8 packet_type){
 	Spell* spell = GetSpell(id, tier);
+
+	// if we can't find it on the master spell list, see if it is a custom spell
+	if (!spell)
+	{
+		lua_interface->FindCustomSpellLock();
+		LuaSpell* tmpSpell = lua_interface->FindCustomSpell(id);
+		EQ2Packet* pack = 0;
+		if (tmpSpell)
+		{
+			spell = tmpSpell->spell;
+			pack = spell->SerializeSpell(client, display, packet_type);
+		}
+
+		lua_interface->FindCustomSpellUnlock();
+		return pack;
+	}
+
 	if(spell)
 		return spell->SerializeSpell(client, display, packet_type);
 	return 0;
 }
 EQ2Packet* MasterSpellList::GetAASpellPacket(int32 id, int8 tier, Client* client, bool display, int8 packet_type) {
 	Spell* spell = GetSpell(id, (tier == 0 ? 1 : tier));
+
+	// if we can't find it on the master spell list, see if it is a custom spell
+	if (!spell)
+	{
+		lua_interface->FindCustomSpellLock();
+		LuaSpell* tmpSpell = lua_interface->FindCustomSpell(id);
+		EQ2Packet* pack = 0;
+		if (tmpSpell)
+		{
+			spell = tmpSpell->spell;
+			// TODO: this isn't a tested thing yet... need to add custom spells to alt advancement?
+			AltAdvanceData* data = master_aa_list.GetAltAdvancement(id);
+
+			if(data)
+				pack = spell->SerializeAASpell(client, tier, data, display, false, packet_type);
+		}
+
+		lua_interface->FindCustomSpellUnlock();
+		return pack;
+	}
+
 	//Spell* spell2= GetSpell(id, (tier +1));
 	AltAdvanceData* data = master_aa_list.GetAltAdvancement(id);
 	if (spell)
@@ -2162,6 +2212,23 @@ EQ2Packet* MasterSpellList::GetAASpellPacket(int32 id, int8 tier, Client* client
 
 EQ2Packet* MasterSpellList::GetSpecialSpellPacket(int32 id, int8 tier, Client* client, bool display, int8 packet_type){
 	Spell* spell = GetSpell(id, tier);
+
+	// if we can't find it on the master spell list, see if it is a custom spell
+	if (!spell)
+	{
+		lua_interface->FindCustomSpellLock();
+		LuaSpell* tmpSpell = lua_interface->FindCustomSpell(id);
+		EQ2Packet* pack = 0;
+		if (tmpSpell)
+		{
+			spell = tmpSpell->spell;
+			pack = spell->SerializeSpecialSpell(client, display, packet_type, 0x81);
+		}
+
+		lua_interface->FindCustomSpellUnlock();
+		return pack;
+	}
+
 	if(spell)
 		return spell->SerializeSpecialSpell(client, display, packet_type, 0x81);
 	return 0;

+ 9 - 0
EQ2/source/WorldServer/Spells.h

@@ -388,6 +388,14 @@ public:
 	/// <param name='error_value'>Value for the error</param>
 	void AddSpellError(int16 version, int8 error_index, int16 error_value);
 
+	int32 GetNewMaxSpellID() { 
+		int32 id = 0;
+		MMasterSpellList.lock();
+		max_spell_id++;
+		id = max_spell_id;
+		MMasterSpellList.unlock();
+		return id; 
+	}
 private:
 	/// <summary>Helper function that gets the closest version in the spell_errors map that is less then or equal to the given version</summary>
 	/// <param name='version'>Client version</param>
@@ -395,6 +403,7 @@ private:
 	int16 GetClosestVersion(int16 version);
 	// map <version, map<error_index, error_value> >
 	map<int16, map<int8, int16> > spell_errors;
+	int32 max_spell_id;
 };
 #endif
 

+ 39 - 4
EQ2/source/WorldServer/client.cpp

@@ -2503,8 +2503,20 @@ void Client::HandleExamineInfoRequest(EQApplicationPacket* app) {
 			trait_display = false;
 		}
 
+		// if we can't find it on the master spell list, see if it is a custom spell
+		if (!spell)
+		{
+			lua_interface->FindCustomSpellLock();
+			LuaSpell* tmpSpell = lua_interface->FindCustomSpell(id);
+			if (tmpSpell)
+				spell = tmpSpell->spell;
+			lua_interface->FindCustomSpellUnlock();
+		}
+
 		if (spell && sent_spell_details.count(id) == 0) {
-			sent_spell_details[id] = true;
+			if (!spell->IsCopiedSpell())
+				sent_spell_details[id] = true;
+
 			EQ2Packet* app = spell->SerializeSpell(this, display, trait_display);
 			//DumpPacket(app);
 			QueuePacket(app);
@@ -2619,8 +2631,21 @@ void Client::HandleExamineInfoRequest(EQApplicationPacket* app) {
 		if (effect) {
 			int8 tier = effect->tier;
 			Spell* spell = master_spell_list.GetSpell(id, tier);
+
+			// if we can't find it on the master spell list, see if it is a custom spell
+			if (!spell)
+			{
+				lua_interface->FindCustomSpellLock();
+				LuaSpell* tmpSpell = lua_interface->FindCustomSpell(id);
+				EQ2Packet* pack = 0;
+				if (tmpSpell)
+					spell = tmpSpell->spell;
+				lua_interface->FindCustomSpellUnlock();
+			}
+
 			if (spell && sent_spell_details.count(id) == 0) {
-				sent_spell_details[id] = true;
+				if (!spell->IsCopiedSpell())
+					sent_spell_details[id] = true;
 				int8 type = 0;
 				if (version <= 283)
 					type = 1;
@@ -2663,6 +2688,15 @@ void Client::HandleExamineInfoRequest(EQApplicationPacket* app) {
 		if (!spell)
 			spell = master_spell_list.GetSpell(id, 1);
 
+		if (!spell)
+		{
+			lua_interface->FindCustomSpellLock();
+			LuaSpell* tmpSpell = lua_interface->FindCustomSpell(id);
+			if (tmpSpell)
+				spell = tmpSpell->spell;
+			lua_interface->FindCustomSpellUnlock();
+		}
+
 		if (!spell)
 		{
 			LogWrite(WORLD__ERROR, 0, "WORLD", "FAILED Examine Info Request-> Spell ID: %u, tier: %i", id, tier);
@@ -2670,7 +2704,8 @@ void Client::HandleExamineInfoRequest(EQApplicationPacket* app) {
 		}
 
 		//if (spell && sent_spell_details.count(spell->GetSpellID()) == 0) {
-		sent_spell_details[spell->GetSpellID()] = true;
+		if (!spell->IsCopiedSpell())
+			sent_spell_details[spell->GetSpellID()] = true;
 		//	EQ2Packet* app = spell->SerializeAASpell(this,tier, data, false, GetItemPacketType(GetVersion()), 0x04);
 		EQ2Packet* app = master_spell_list.GetAASpellPacket(id, tier, this, false, 0x4F);//0x45 change version to match client
 		/////////////////////////////////////////GetAASpellPacket(int32 id, int8 tier, Client* client, bool display, int8 packet_type) {
@@ -3002,7 +3037,7 @@ void ClientList::Process() {
 	for (client_iter = client_list.begin(); client_iter != client_list.end(); client_iter++) {
 		client = *client_iter;
 		// have a sanity check because the client list can sometimes obtain null client pointers
-		if (!client || (!client->Process() || client->remove_from_list)) {
+		if (!client || client->remove_from_list || (!client->Process())) { // if we should be removing from list, don't process any further
 			erase_iter = client_iter;
 			break;
 		}

+ 2 - 2
EQ2/source/common/version.h

@@ -38,9 +38,9 @@
 #endif
 
 #if defined(LOGIN)
-#define CURRENT_VERSION	"0.8.1-virgo2"
+#define CURRENT_VERSION	"0.8.1-libra1"
 #elif defined(WORLD)
-#define CURRENT_VERSION	"0.8.1-virgo2"
+#define CURRENT_VERSION	"0.8.1-libra1"
 #else
 #define CURRENT_VERSION	"0.7.3-dev"
 #endif