Browse Source

Fix #450 can restrict SpellDamage by race id and type
Fix #172 lock spelleffects until removal in group

Emagi 1 year ago
parent
commit
f52276b263

+ 6 - 2
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -1851,7 +1851,9 @@ int EQ2Emu_lua_SpellDamage(lua_State* state) {
 
 					if (race_req.size() > 0) {
 						for (int8 i = 0; i < race_req.size(); i++) {
-							if (target->GetLuaRaceId() == race_req[i]) {
+						if(race_req[i] == target->GetRace() ||
+							race_req[i] == race_types_list.GetRaceType(target->GetModelType()) ||
+							race_req[i] == race_types_list.GetRaceBaseType(target->GetModelType())) {
 								race_match = true;
 							}
 						}
@@ -1872,7 +1874,9 @@ int EQ2Emu_lua_SpellDamage(lua_State* state) {
 			//check class and race/faction here
 			if (race_req.size() > 0) {
 				for (int8 i = 0; i < race_req.size(); i++) {
-					if (target->GetLuaRaceId() == race_req[i]) {
+					if(race_req[i] == target->GetRace() ||
+						race_req[i] == race_types_list.GetRaceType(target->GetModelType()) ||
+						race_req[i] == race_types_list.GetRaceBaseType(target->GetModelType())) {
 						race_match = true;
 					}
 				}

+ 1 - 2
EQ2/source/WorldServer/Player.cpp

@@ -6852,8 +6852,7 @@ NPC* Player::InstantiateSpiritShard(float origX, float origY, float origZ, float
 		npc->appearance.race = GetRace();
 		npc->appearance.gender = GetGender();
 		npc->appearance.adventure_class = GetAdventureClass();
-		 
-		//npc->appearance.lua_race_id = result.GetInt16(74);
+		
 		npc->appearance.model_type = GetModelType();
 		npc->appearance.soga_model_type = GetSogaModelType();
 		npc->appearance.display_name = 1;

+ 13 - 2
EQ2/source/WorldServer/PlayerGroups.cpp

@@ -466,9 +466,14 @@ void PlayerGroupManager::RemoveGroupBuffs(int32 group_id, Client* client) {
 	if (group && client) {
 		/* first remove all spell effects this group member has on them from other group members */
 		player = client->GetPlayer();
-		se = player->GetSpellEffects();
+		bool recoup_lock = true;
 		for (int i = 0; i < NUM_SPELL_EFFECTS; i++) {
-			if (se[i].spell_id != 0xFFFFFFFF) {
+			if(recoup_lock) {
+				player->GetSpellEffectMutex()->readlock(__FUNCTION__, __LINE__);
+				recoup_lock = false;
+				se = player->GetSpellEffects();
+			}
+			if (se && se[i].spell_id != 0xFFFFFFFF) {
 				//If the client is the caster, don't remove the spell
 				if (se[i].caster == player)
 					continue;
@@ -478,6 +483,9 @@ void PlayerGroupManager::RemoveGroupBuffs(int32 group_id, Client* client) {
 				/* is this a friendly group spell? */
 				if (spell && spell->GetSpellData()->group_spell && spell->GetSpellData()->friendly_spell) {
 
+					player->GetSpellEffectMutex()->releasereadlock(__FUNCTION__, __LINE__);
+					recoup_lock = true;
+					// we have to remove our spell effect mutex lock since RemoveSpellEffect needs a write lock to remove it
 					//Remove all group buffs not cast by this player
 					player->RemoveSpellEffect(luaspell);
 					player->RemoveSpellBonus(luaspell);
@@ -501,6 +509,9 @@ void PlayerGroupManager::RemoveGroupBuffs(int32 group_id, Client* client) {
 				}
 			}
 		}
+		if(!recoup_lock) { // we previously set a readlock that we now release
+			player->GetSpellEffectMutex()->releasereadlock(__FUNCTION__, __LINE__);
+		}
 		packet = client->GetPlayer()->GetSkills()->GetSkillPacket(client->GetVersion());
 		if (packet)
 			client->QueuePacket(packet);

+ 0 - 3
EQ2/source/WorldServer/Spawn.h

@@ -726,9 +726,6 @@ public:
 	int8 GetRace(){
 		return appearance.race;
 	}
-	int8 GetLuaRaceId() {
-		return appearance.lua_race_id;
-	}
 	int32 GetSize(){
 		return size;
 	}

+ 0 - 10
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -972,12 +972,6 @@ void WorldDatabase::LoadNPCs(ZoneServer* zone){
 		npc->appearance.level =		atoi(row[2]);
 		npc->appearance.encounter_level = atoi(row[4]);
 		npc->appearance.race = atoi(row[5]);
-		//npc->appearance.lua_race_id = atoi(row[75]);
-		//devn00b: this never gets used..and is set correctly below...removing.
-		/*if (atoi(row[74]) > 0) {
-			int16 xxx = atoi(row[75]);
-			int8 yyy = 0;
-		}*/
 		npc->appearance.model_type = atoi(row[6]);
 		npc->appearance.soga_model_type = atoi(row[62]);
 		npc->appearance.adventure_class = atoi(row[7]);
@@ -1140,8 +1134,6 @@ void WorldDatabase::LoadSpiritShards(ZoneServer* zone){
 		shard->appearance.race = atoul(row[3]);
 		shard->appearance.gender = atoul(row[4]);
 		shard->appearance.adventure_class = atoul(row[5]);
-		 
-		//shard->appearance.lua_race_id = result.GetInt16(74);
 		shard->appearance.model_type = atoul(row[6]);
 		shard->appearance.soga_model_type = atoul(row[7]);
 		shard->appearance.display_name = 1;
@@ -6746,8 +6738,6 @@ bool WorldDatabase::LoadNPC(ZoneServer* zone, int32 spawn_id) {
 		npc->appearance.level =		result.GetInt8(2);
 		npc->appearance.encounter_level = result.GetInt8(4);
 		npc->appearance.race = result.GetInt8(5);
-		 
-		//npc->appearance.lua_race_id = result.GetInt16(74);
 		npc->appearance.model_type = result.GetInt16(6);
 		npc->appearance.soga_model_type = result.GetInt16(62);
 		npc->appearance.adventure_class = result.GetInt8(7);