Code: Select all
File Structures not needed, do searches for MSG_CHAT_YELL for almost everything
-----------------
mmo.h
Search for MSG_CHAT_YELL, and add line MSG_CHAT_UNITY
-----------------
message.cpp
Search for MSG_CHAT_YELL and find end of case before case MSG_CHAT_SERVMES Copy this to there:
case MSG_CHAT_UNITY:
{
zoneutils::ForEachZone([&packet, &extra](CZone* PZone)
{
PZone->ForEachChar([&packet, &extra](CCharEntity* PChar)
{
// don't push to sender
if (PChar->id != ref<uint32>((uint8*)extra->data(), 0))
{
CBasicPacket* newPacket = new CBasicPacket();
memcpy(*newPacket, packet->data(), std::min<size_t>(packet->size(), PACKET_SIZE));
PChar->pushPacket(newPacket);
}
});
});
break;
}
----------------
message_server.cpp
Search for MSG_CHAT_YELL
Add case below it:
case MSG_CHAT_UNITY:
{
const char* query = "SELECT zoneip, zoneport FROM zone_settings GROUP BY zoneip, zoneport;";
ret = Sql_Query(ChatSqlHandle, query);
ipstring = true;
break;
}
-----------------
packet_system.cpp
Search for MESSAGE_SAY
Replace with:
case MESSAGE_SAY:
{
int8 packetData[4]{};
ref<uint32>(packetData, 0) = PChar->id;
message::send(MSG_CHAT_UNITY, packetData, sizeof packetData, new CChatMessagePacket(PChar, MESSAGE_UNITY, (const char*)data[6]));
if (map_config.audit_chat == 1 && map_config.audit_yell == 1)
{
std::string qStr = ("INSERT into audit_chat (speaker,type,message,datetime) VALUES('");
qStr += (const char*)PChar->GetName();
qStr += "','SAY','";
qStr += escape((const char*)data[6]);
qStr += "',current_timestamp());";
const char * cC = qStr.c_str();
Sql_QueryStr(SqlHandle, cC);
}
}
break;
Bear in mind, to alleviate SOME issues, you could rename "UNITY" to "WORLDCHAT" to make life easier for yourself. I just used UNITY because of the end result. This also helps to avoid the double sends by borrowing from MSG_CHAT_YELL and just removing the check for zones to be okay.
Most people ask, why not just use Yell? Well, its because of chatmode. You cannot set chatmode to yell. You can set it to Unity, so down the road that might be possible (bear in mind I tried to make that work and it didn't show up properly).
Regardless, say worked well for us, but you can use anything, and make it appear to others as ANY type of chat, including "say", by just replacing MESSAGE_UNITY with MESSAGE_SAY in "packet_system" change. You can rename everything else from MSG_CHAT_UNITY to whatever you want, but simply make sure they are ALL named the same.
This does not require my chat colors mod, as it stands alone.
This all being said, ideally, you could also just modify yell completely, and remove the checks for zones to be approved by yell, or just adjust the zones themselves from SQL to allow yell in All zones to all zones. (Much safer option)