Browse Source

Added disable_sounds on Spawn to disable any custom sounds (for now disables mariner_bell)

This will fix #131 requirement.  disable_sounds will be made to more globally disable a spawns sounds that might otherwise be defaults.

We can either later on decide to use the widget open/close sound or maybe have another sound file field that allows a different value than mariner bell.

This update also allows signs to check expansion flags and fixes widgets pulling the wrong field
Image 3 years ago
parent
commit
a3d1f915c5

+ 1 - 0
EQ2/source/WorldServer/NPC.cpp

@@ -92,6 +92,7 @@ NPC::NPC(NPC* old_npc){
 		SetPower(GetTotalPower());
 		ChangePrimaryWeapon();
 		ChangeSecondaryWeapon();
+		SetSoundsDisabled(old_npc->IsSoundsDisabled());
 	}
 }
 

+ 1 - 0
EQ2/source/WorldServer/Object.cpp

@@ -87,5 +87,6 @@ Object*	Object::Copy(){
 	new_spawn->SetQuestsRequired(GetQuestsRequired());
 	new_spawn->SetTransporterID(GetTransporterID());
 	new_spawn->SetDeviceID(GetDeviceID());
+	new_spawn->SetSoundsDisabled(IsSoundsDisabled());
 	return new_spawn;
 }

+ 1 - 0
EQ2/source/WorldServer/Sign.cpp

@@ -145,6 +145,7 @@ Sign* Sign::Copy(){
 	new_spawn->SetIncludeHeading(include_heading);
 	new_spawn->SetIncludeLocation(include_location);
 	new_spawn->SetTransporterID(GetTransporterID());
+	new_spawn->SetSoundsDisabled(IsSoundsDisabled());
 	return new_spawn;
 }
 

+ 1 - 0
EQ2/source/WorldServer/Spawn.cpp

@@ -106,6 +106,7 @@ Spawn::Spawn(){
 	has_spawn_proximities = false;
 	pickup_item_id = 0;
 	pickup_unique_item_id = 0;
+	disable_sounds = false;
 }
 
 Spawn::~Spawn(){

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

@@ -1059,6 +1059,9 @@ public:
 
 	int32	GetPickupItemID() { return pickup_item_id; }
 	int32	GetPickupUniqueItemID() { return pickup_unique_item_id; }
+
+	bool	IsSoundsDisabled() { return disable_sounds; }
+	void	SetSoundsDisabled(bool val) { disable_sounds = val; }
 protected:
 
 	bool	send_spawn_changes;
@@ -1140,6 +1143,8 @@ private:
 	int16 m_spawnAnimLeeway;
 
 	Mutex m_Update;
+
+	bool disable_sounds;
 };
 
 #endif

+ 1 - 0
EQ2/source/WorldServer/Widget.cpp

@@ -160,6 +160,7 @@ Widget*	Widget::Copy(){
 	new_spawn->SetOpenX(GetOpenX());
 	new_spawn->SetOpenZ(GetOpenZ());
 	new_spawn->SetMultiFloorLift(multi_floor_lift);
+	new_spawn->SetSoundsDisabled(IsSoundsDisabled());
 	return new_spawn;
 }
 

+ 40 - 6
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -881,7 +881,7 @@ void WorldDatabase::LoadNPCs(ZoneServer* zone){
 	NPC* npc = 0;
 	int32 id = 0;
 	int32 total = 0;
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT,"SELECT npc.spawn_id, s.name, npc.min_level, npc.max_level, npc.enc_level, s.race, s.model_type, npc.class_, npc.gender, s.command_primary, s.command_secondary, s.show_name, npc.min_group_size, npc.max_group_size, npc.hair_type_id, npc.facial_hair_type_id, npc.wing_type_id, npc.chest_type_id, npc.legs_type_id, npc.soga_hair_type_id, npc.soga_facial_hair_type_id, s.attackable, s.show_level, s.targetable, s.show_command_icon, s.display_hand_icon, s.hp, s.power, s.size, s.collision_radius, npc.action_state, s.visual_state, npc.mood_state, npc.initial_state, npc.activity_status, s.faction_id, s.sub_title, s.merchant_id, s.merchant_type, s.size_offset, npc.attack_type, npc.ai_strategy+0, npc.spell_list_id, npc.secondary_spell_list_id, npc.skill_list_id, npc.secondary_skill_list_id, npc.equipment_list_id, npc.str, npc.sta, npc.wis, npc.intel, npc.agi, npc.heat, npc.cold, npc.magic, npc.mental, npc.divine, npc.disease, npc.poison, npc.aggro_radius, npc.cast_percentage, npc.randomize, npc.soga_model_type, npc.heroic_flag, npc.alignment, npc.elemental, npc.arcane, npc.noxious, s.savagery, s.dissonance, npc.hide_hood, npc.emote_state, s.prefix, s.suffix, s.last_name, s.expansion_flag\n"
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT,"SELECT npc.spawn_id, s.name, npc.min_level, npc.max_level, npc.enc_level, s.race, s.model_type, npc.class_, npc.gender, s.command_primary, s.command_secondary, s.show_name, npc.min_group_size, npc.max_group_size, npc.hair_type_id, npc.facial_hair_type_id, npc.wing_type_id, npc.chest_type_id, npc.legs_type_id, npc.soga_hair_type_id, npc.soga_facial_hair_type_id, s.attackable, s.show_level, s.targetable, s.show_command_icon, s.display_hand_icon, s.hp, s.power, s.size, s.collision_radius, npc.action_state, s.visual_state, npc.mood_state, npc.initial_state, npc.activity_status, s.faction_id, s.sub_title, s.merchant_id, s.merchant_type, s.size_offset, npc.attack_type, npc.ai_strategy+0, npc.spell_list_id, npc.secondary_spell_list_id, npc.skill_list_id, npc.secondary_skill_list_id, npc.equipment_list_id, npc.str, npc.sta, npc.wis, npc.intel, npc.agi, npc.heat, npc.cold, npc.magic, npc.mental, npc.divine, npc.disease, npc.poison, npc.aggro_radius, npc.cast_percentage, npc.randomize, npc.soga_model_type, npc.heroic_flag, npc.alignment, npc.elemental, npc.arcane, npc.noxious, s.savagery, s.dissonance, npc.hide_hood, npc.emote_state, s.prefix, s.suffix, s.last_name, s.expansion_flag, s.disable_sounds\n"
 													"FROM spawn s\n"
 													"INNER JOIN spawn_npcs npc\n"
 													"ON s.id = npc.spawn_id\n"
@@ -1022,6 +1022,11 @@ void WorldDatabase::LoadNPCs(ZoneServer* zone){
 		npc->SetSuffixTitle(row[73]);
 		npc->SetLastName(row[74]);
 
+		// xpack value handled at top at position 75
+
+		int8 disableSounds = atoul(row[76]);
+		npc->SetSoundsDisabled(disableSounds);
+
 		zone->AddNPC(id, npc);
 		total++;
 		LogWrite(NPC__DEBUG, 5, "NPC", "---Loading NPC: '%s' (%u)", npc->appearance.name, id);
@@ -1040,7 +1045,7 @@ void WorldDatabase::LoadSigns(ZoneServer* zone){
 	Sign* sign = 0;
 	int32 id = 0;
 	int32 total = 0;
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT ss.spawn_id, s.name, s.model_type, s.size, s.show_command_icon, ss.widget_id, ss.widget_x, ss.widget_y, ss.widget_z, s.command_primary, s.command_secondary, s.collision_radius, ss.icon, ss.type, ss.title, ss.description, ss.sign_distance, ss.zone_id, ss.zone_x, ss.zone_y, ss.zone_z, ss.zone_heading, ss.include_heading, ss.include_location, s.transport_id, s.size_offset, s.display_hand_icon, s.visual_state\n"
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT ss.spawn_id, s.name, s.model_type, s.size, s.show_command_icon, ss.widget_id, ss.widget_x, ss.widget_y, ss.widget_z, s.command_primary, s.command_secondary, s.collision_radius, ss.icon, ss.type, ss.title, ss.description, ss.sign_distance, ss.zone_id, ss.zone_x, ss.zone_y, ss.zone_z, ss.zone_heading, ss.include_heading, ss.include_location, s.transport_id, s.size_offset, s.display_hand_icon, s.visual_state, s.expansion_flag, s.disable_sounds\n"
 												  "FROM spawn s\n"
 												  "INNER JOIN spawn_signs ss\n"
 												  "ON s.id = ss.spawn_id\n"
@@ -1053,6 +1058,10 @@ void WorldDatabase::LoadSigns(ZoneServer* zone){
 												  zone->GetZoneID());
 
 	while(result && (row = mysql_fetch_row(result))){
+		int32 signXpackFlag = atoul(row[28]);
+		if (!CheckExpansionFlags(zone, signXpackFlag))
+			continue;
+
 		id = atoul(row[0]);
 		if(zone->GetSign(id, true))
 			continue;
@@ -1098,6 +1107,12 @@ void WorldDatabase::LoadSigns(ZoneServer* zone){
 		sign->SetSizeOffset(atoi(row[25]));
 		sign->appearance.display_hand_icon = atoi(row[26]);
 		sign->SetVisualState(atoi(row[27]));
+
+		// xpack value handled at top at position 28
+
+		int8 disableSounds = atoul(row[29]);
+		sign->SetSoundsDisabled(disableSounds);
+
 		zone->AddSign(id, sign);
 		total++;
 
@@ -1113,7 +1128,7 @@ void WorldDatabase::LoadWidgets(ZoneServer* zone){
 	Widget* widget = 0;
 	int32 id = 0;
 	int32 total = 0;
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT sw.spawn_id, s.name, s.model_type, s.size, s.show_command_icon, sw.widget_id, sw.widget_x, sw.widget_y, sw.widget_z, s.command_primary, s.command_secondary, s.collision_radius, sw.include_heading, sw.include_location, sw.icon, sw.type, sw.open_heading, sw.open_y, sw.action_spawn_id, sw.open_sound_file, sw.close_sound_file, sw.open_duration, sw.closed_heading, sw.linked_spawn_id, sw.close_y, s.transport_id, s.size_offset, sw.house_id, sw.open_x, sw.open_z, sw.close_x, sw.close_z, s.display_hand_icon, s.expansion_flag\n"
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT sw.spawn_id, s.name, s.model_type, s.size, s.show_command_icon, sw.widget_id, sw.widget_x, sw.widget_y, sw.widget_z, s.command_primary, s.command_secondary, s.collision_radius, sw.include_heading, sw.include_location, sw.icon, sw.type, sw.open_heading, sw.open_y, sw.action_spawn_id, sw.open_sound_file, sw.close_sound_file, sw.open_duration, sw.closed_heading, sw.linked_spawn_id, sw.close_y, s.transport_id, s.size_offset, sw.house_id, sw.open_x, sw.open_z, sw.close_x, sw.close_z, s.display_hand_icon, s.expansion_flag, s.disable_sounds\n"
 												  "FROM spawn s\n"
 												  "INNER JOIN spawn_widgets sw\n"
 												  "ON s.id = sw.spawn_id\n"
@@ -1125,7 +1140,7 @@ void WorldDatabase::LoadWidgets(ZoneServer* zone){
 												  "GROUP BY s.id",
 												  zone->GetZoneID());
 	while(result && (row = mysql_fetch_row(result))){
-		int32 widgetXpackFlag = atoul(row[32]);
+		int32 widgetXpackFlag = atoul(row[33]);
 		if (!CheckExpansionFlags(zone, widgetXpackFlag))
 			continue;
 
@@ -1189,6 +1204,12 @@ void WorldDatabase::LoadWidgets(ZoneServer* zone){
 		widget->SetCloseX(atof(row[30]));
 		widget->SetCloseZ(atof(row[31]));
 		widget->appearance.display_hand_icon = atoi(row[32]);
+
+		// xpack value handled at top at position 33
+
+		int8 disableSounds = atoul(row[34]);
+		widget->SetSoundsDisabled(disableSounds);
+
 		zone->AddWidget(id, widget);
 		total++;
 
@@ -1204,7 +1225,7 @@ void WorldDatabase::LoadObjects(ZoneServer* zone){
 	Object* object = 0;
 	int32 id = 0;
 	int32 total = 0;
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT so.spawn_id, s.name, s.race, s.model_type, s.command_primary, s.command_secondary, s.targetable, s.size, s.show_name, s.visual_state, s.attackable, s.show_level, s.show_command_icon, s.display_hand_icon, s.faction_id, s.collision_radius, s.transport_id, s.size_offset, so.device_id, s.expansion_flag\n"
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT so.spawn_id, s.name, s.race, s.model_type, s.command_primary, s.command_secondary, s.targetable, s.size, s.show_name, s.visual_state, s.attackable, s.show_level, s.show_command_icon, s.display_hand_icon, s.faction_id, s.collision_radius, s.transport_id, s.size_offset, so.device_id, s.expansion_flag, s.disable_sounds\n"
 												  "FROM spawn s\n"
 												  "INNER JOIN spawn_objects so\n"
 												  "ON s.id = so.spawn_id\n"
@@ -1253,6 +1274,12 @@ void WorldDatabase::LoadObjects(ZoneServer* zone){
 		object->SetTransporterID(atoul(row[16]));
 		object->SetSizeOffset(atoi(row[17]));
 		object->SetDeviceID(atoi(row[18]));
+
+		// xpack value handled at top at position 19
+
+		int8 disableSounds = atoul(row[20]);
+		object->SetSoundsDisabled(disableSounds);
+
 		zone->AddObject(id, object);
 		total++;
 
@@ -1268,7 +1295,7 @@ void WorldDatabase::LoadGroundSpawns(ZoneServer* zone){
 	GroundSpawn* spawn = 0;
 	int32 id = 0;
 	int32 total = 0;
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT sg.spawn_id, s.name, s.race, s.model_type, s.command_primary, s.command_secondary, s.targetable, s.size, s.show_name, s.visual_state, s.attackable, s.show_level, s.show_command_icon, s.display_hand_icon, s.faction_id, s.collision_radius, sg.number_harvests, sg.num_attempts_per_harvest, sg.groundspawn_id, sg.collection_skill, s.size_offset, s.expansion_flag\n"
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT sg.spawn_id, s.name, s.race, s.model_type, s.command_primary, s.command_secondary, s.targetable, s.size, s.show_name, s.visual_state, s.attackable, s.show_level, s.show_command_icon, s.display_hand_icon, s.faction_id, s.collision_radius, sg.number_harvests, sg.num_attempts_per_harvest, sg.groundspawn_id, sg.collection_skill, s.size_offset, s.expansion_flag, s.disable_sounds\n"
 												  "FROM spawn s\n"
 												  "INNER JOIN spawn_ground sg\n"
 												  "ON s.id = sg.spawn_id\n"
@@ -1320,6 +1347,12 @@ void WorldDatabase::LoadGroundSpawns(ZoneServer* zone){
 		spawn->SetGroundSpawnEntryID(atoul(row[18]));
 		spawn->SetCollectionSkill(row[19]);
 		spawn->SetSizeOffset(atoi(row[20]));
+
+		// xpack value handled at top at position 21
+
+		int8 disableSounds = atoul(row[22]);
+		spawn->SetSoundsDisabled(disableSounds);
+
 		zone->AddGroundSpawn(id, spawn);
 		total++;
 		LogWrite(GROUNDSPAWN__DEBUG, 5, "GSpawn", "---Loading GroundSpawn: '%s' (%u)", spawn->appearance.name, id);
@@ -6091,6 +6124,7 @@ bool WorldDatabase::LoadGroundSpawn(ZoneServer* zone, int32 spawn_id) {
 		spawn->SetGroundSpawnEntryID(result.GetInt32(18));
 		spawn->SetCollectionSkill(result.GetString(19));
 		spawn->SetSizeOffset(result.GetInt8(20));
+
 		zone->AddGroundSpawn(id, spawn);
 
 		if (!zone->GetGroundSpawnEntries(spawn->GetGroundSpawnEntryID()))

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

@@ -7061,7 +7061,8 @@ void Client::ProcessTeleport(Spawn* spawn, vector<TransportDestination*>* destin
 			SimpleMessage(CHANNEL_COLOR_YELLOW, destination->message.c_str());
 	}
 	else if (transport_list.size() > 0) {
-		PlaySound("mariner_bell");
+		if (!spawn->IsSoundsDisabled())
+			PlaySound("mariner_bell");
 
 		PacketStruct* packet = configReader.getStruct("WS_TeleportList", GetVersion());
 		if (packet) {