Worldchat 2.0 (Hardcoded)

Post Reply
User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Worldchat 2.0 (Hardcoded)

Post by tagban » Thu Mar 03, 2016 9:34 am

This is largely wrongly coded, and because it modifies so much source it is likely to be broken, especially when DSP actually adds in Unity. I chose to use Unity because it stands out better than standard say. I have a very small server member base, so for me this is perfect, and it allows people to still have their own linkshells, and other things. For now this works, as I said, expect it to not work eventually. But I wanted to share anyway:

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)
Last edited by tagban on Sat Mar 31, 2018 1:26 pm, edited 3 times in total.

KOSMOS
Posts: 67
Joined: Thu Jan 29, 2015 10:36 pm

Re: Worldchat 2.0 (Hardcoded)

Post by KOSMOS » Tue Mar 22, 2016 8:42 pm

This is broken yeah? I can not find two of the files to even alter for this. mmo.h and message_server.cpp

Delaide
Posts: 478
Joined: Sat Jun 14, 2014 8:58 am

Re: Worldchat 2.0 (Hardcoded)

Post by Delaide » Tue Mar 22, 2016 9:01 pm

mmo.h: https://github.com/DarkstarProject/dark ... /mmo.h#L82
So, in your local pull, look under src/common/mmo.h and look at line 82.
Hit enter to add a new line and add MSG_CHAT_UNITY, so you get

Code: Select all

...
MSG_CHAT_YELL
MSG_CHAT_UNITY
...
message_server.cpp: https://github.com/DarkstarProject/dark ... r.cpp#L124
So, in your local pull, look under src/login/message_server.cpp and look at line 124
Follow directions found in Tagban's post.

Did you manage to find the appropriate stuff in message.cpp, packet_system.cpp, and chat_message.h?

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Worldchat 2.0 (Hardcoded)

Post by tagban » Tue Mar 22, 2016 10:27 pm

Works fine for me, I have latest pull as of this morning. It uses some files from Connect, not just game server.

KOSMOS
Posts: 67
Joined: Thu Jan 29, 2015 10:36 pm

Re: Worldchat 2.0 (Hardcoded)

Post by KOSMOS » Wed Mar 23, 2016 7:55 pm

Ahh ok I was not looking outside of map section. Thank you both of you for the fast response.

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Worldchat 2.0 (Hardcoded)

Post by tagban » Thu Dec 28, 2017 7:28 pm

I updated this due to recent updates it got broken, so re-borrowed YELL stuff modified to eliminate limits.

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Worldchat 2.0 (Hardcoded)

Post by tagban » Sat Mar 31, 2018 12:36 pm

Removed chat_message.h since MESSAGE_UNITY is now included in fresh pulls.

Post Reply