Browse Source

Fixed HandleTellClient. Fixing 'You tell you' bug

Gitea 2 years ago
parent
commit
0335c9768d

+ 5 - 60
EQ2/source/WorldServer/World.cpp

@@ -442,27 +442,6 @@ bool ZoneList::HandleGlobalChatMessage(Client* from, char* to, int16 channel, co
 		LogWrite(WORLD__ERROR, 0, "World", "HandleGlobalChatMessage() called with an invalid client");
 		return false;
 	}
-//Devnoob: commented this out because it always results in "You Tell you: 'xyz'"...code was implemented to permit tells between client versions. Replaced with original version.
-//Todo: Fix it :P
-/*	if(channel == CHANNEL_PRIVATE_TELL){
-		Client* find_client = zone_list.GetClientByCharName(to);
-		if(!find_client || find_client->GetPlayer()->IsIgnored(from->GetPlayer()->GetName()))
-			return false;
-		else if(find_client == from)
-		{
-			from->Message(CHANNEL_COLOR_RED,"You must be very lonely...(ERROR: Cannot send tell to self)");
-		}
-		else
-		{
-			find_client->HandleTellMessage(from, message);
-			from->HandleTellMessage(from, message);			
-			if (find_client->GetPlayer()->get_character_flag(CF_AFK)) {
-				find_client->HandleTellMessage(find_client, find_client->GetPlayer()->GetAwayMessage().c_str());
-				from->HandleTellMessage(find_client, find_client->GetPlayer()->GetAwayMessage().c_str());
-			}
-		}
-	}*/
-
 	if(channel == CHANNEL_PRIVATE_TELL){
 		Client* find_client = zone_list.GetClientByCharName(to);
 		if(!find_client || find_client->GetPlayer()->IsIgnored(from->GetPlayer()->GetName()))
@@ -473,46 +452,12 @@ bool ZoneList::HandleGlobalChatMessage(Client* from, char* to, int16 channel, co
 		}
 		else
 		{
-			PacketStruct* packet = configReader.getStruct("WS_HearChat", from->GetVersion());
-			if(packet){
-				packet->setMediumStringByName("from", from->GetPlayer()->GetName());
-				packet->setMediumStringByName("to", find_client->GetPlayer()->GetName());
-				packet->setDataByName("channel", CHANNEL_PRIVATE_TELL);
-				packet->setDataByName("from_spawn_id", 0xFFFFFFFF);
-				packet->setDataByName("to_spawn_id", 0xFFFFFFFF);
-				packet->setDataByName("unknown2", 1, 1);
-				packet->setDataByName("show_bubble", 1);
-				packet->setDataByName("understood", 1);
-				packet->setDataByName("time", 2); 
-				packet->setMediumStringByName("message", message);
-				if(channel_name)
-					packet->setMediumStringByName("channel_name", channel_name);
-				EQ2Packet* outpacket = packet->serialize();
-				//DumpPacket(outpacket);
-				find_client->QueuePacket(outpacket->Copy());
-				from->QueuePacket(outpacket);
-				safe_delete(packet);
-			}
+			const char* whoto = find_client->GetPlayer()->GetName();
+			find_client->HandleTellMessage(from, message, whoto);
+			from->HandleTellMessage(from, message, whoto);
 			if (find_client->GetPlayer()->get_character_flag(CF_AFK)) {
-				PacketStruct* packet2 = configReader.getStruct("WS_HearChat", from->GetVersion());
-				if (packet2) {
-					packet2->setMediumStringByName("from", find_client->GetPlayer()->GetName());
-					packet2->setMediumStringByName("to", from->GetPlayer()->GetName());
-					packet2->setDataByName("channel", CHANNEL_PRIVATE_TELL);
-					packet2->setDataByName("from_spawn_id", 0xFFFFFFFF);
-					packet2->setDataByName("to_spawn_id", 0xFFFFFFFF);
-					packet2->setDataByName("unknown2", 1, 1);
-					packet2->setDataByName("show_bubble", 1);
-					packet2->setDataByName("understood", 1);
-					packet2->setDataByName("time", 2);
-					packet2->setMediumStringByName("message", find_client->GetPlayer()->GetAwayMessage().c_str());
-					if (channel_name)
-						packet2->setMediumStringByName("channel_name", channel_name);
-					EQ2Packet* outpacket = packet2->serialize();
-					from->QueuePacket(outpacket->Copy());
-					find_client->QueuePacket(outpacket);
-					safe_delete(packet2);
-				}
+				find_client->HandleTellMessage(find_client, find_client->GetPlayer()->GetAwayMessage().c_str(),whoto);
+				from->HandleTellMessage(find_client, find_client->GetPlayer()->GetAwayMessage().c_str(),whoto);
 			}
 		}
 	}

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

@@ -3621,13 +3621,13 @@ int8 Client::GetMessageChannelColor(int8 channel_type) {
 	return channel_type;
 }
 
-void Client::HandleTellMessage(Client* from, const char* message) {
+void Client::HandleTellMessage(Client* from, const char* message, const char* to=NULL) {
 	if (!from || GetPlayer()->IsIgnored(from->GetPlayer()->GetName()))
 		return;
 	PacketStruct* packet = configReader.getStruct("WS_HearChat", GetVersion());
 	if (packet) {
 		packet->setDataByName("from", from->GetPlayer()->GetName());
-		packet->setDataByName("to", GetPlayer()->GetName());
+		packet->setDataByName("to", to);
 		packet->setDataByName("channel", GetMessageChannelColor(CHANNEL_PRIVATE_TELL));
 		packet->setDataByName("from_spawn_id", 0xFFFFFFFF);
 		packet->setDataByName("to_spawn_id", 0xFFFFFFFF);
@@ -10775,4 +10775,4 @@ void Client::SetPlayer(Player* new_player) {
 
 	player = new_player;
 	player->SetClient(this);
-}
+}

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

@@ -159,7 +159,7 @@ public:
 	void	QueuePacket(EQ2Packet* app, bool attemptedCombine=false);
 	void	SendLoginInfo();
 	int8	GetMessageChannelColor(int8 channel_type);
-	void	HandleTellMessage(Client* from, const char* message);
+	void	HandleTellMessage(Client* from, const char* message, const char* to);
 	void	SimpleMessage(int8 color, const char* message);
 	void	Message(int8 type, const char* message, ...);
 	void	SendSpellUpdate(Spell* spell, bool add_silently = false, bool add_to_hotbar = true);