• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Slavidodo casting-system channel issue

Addams

OTMadness.com OTSes Services
Staff member
Board Moderator
Joined
Sep 29, 2009
Messages
2,920
Solutions
342
Reaction score
1,688
Location
Egypt
I've been trying to implement different old cast systems to TFS 1.4.1 and every system has a few issues, I am debugging Slavi's now to see if I will find some crash issues.
I need help with something related to cast channel, I've been trying myself for 2+ days by now compiling and changing lines but not sure what could be the issue.
No errors/warns during compile, No errors in TFS console but there's an error on OTCv8 console here it is.
Code:
ERROR: ProtocolGame parse message exception (38 bytes, 3 unread, last opcode is 0xaa (170), prev opcode is 0xffffffff (-1)): unknown message mode 0
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 1098)
I can't write in Live cast channel, not with caster player or spectator both get the same error.
Here's the system link if someone can take a quick look.
Live casting system by slavidodo · Pull Request #2230 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/2230/files)
Edit:
I just wanted to mention that I've added this one too
based on @Itutorial 's changes by diff from this repo
and it still has the same channel writing issue somehow.
 
Last edited:
Solution
I have noticed something, not only caster/spectator messages are sending this error, but It's also messages sent by cast functions like this one.
C++:
bool ProtocolGame::banCastSpectator(std::string name)
{
    if (!castinfo.enabled) {
        return false;
    }

    for (auto spectator : castinfo.spectators) {
        if (spectator && strcasecmp(spectator->name.c_str(), name.c_str()) == 0) {
            sendChannelMessage("[Cast system]", spectator->name + " has been banned.", TALKTYPE_CHANNEL_R1, CHANNEL_CAST);
            castinfo.banList.insert(std::make_pair(spectator->name, spectator->getIP()));
            spectator->disconnect();
            return true;
        }
    }

    sendChannelMessage("[Cast system]", "There is no...
1 more addition that's what packet.log file looks like.
Code:
ProtocolGame parse message exception (57 bytes, 22 unread, last opcode is 0xaa (170), prev opcode is 0xffffffff (-1), proto: 1098): InputMessage eof reached 3c 00 50 1e 59 68 31 00 aa 01 00 00 00 08 00 41 72 63 68 6d 61 67 65 00 00 24 dc 03 f6 03 07 18 00 57 65 20 64 6f 6e 27 74 20 6c 69 6b 65 20 69 6e 74 72 75 64 65 72 73 21
 
I will post the changes I tried in the morning maybe someone points me in the right direction.
I've tried changing almost every sendChannelMessage to different Talktypes (Didn't work)
I've also tried removing bool broadcast = true option from sendChannelMessage function (Didn't work)
I've changed the channel id in const.h to different ones based on older cast systems out there to 40 and 0x10 (Didn't work)
 
Last edited:
I have noticed something, not only caster/spectator messages are sending this error, but It's also messages sent by cast functions like this one.
C++:
bool ProtocolGame::banCastSpectator(std::string name)
{
    if (!castinfo.enabled) {
        return false;
    }

    for (auto spectator : castinfo.spectators) {
        if (spectator && strcasecmp(spectator->name.c_str(), name.c_str()) == 0) {
            sendChannelMessage("[Cast system]", spectator->name + " has been banned.", TALKTYPE_CHANNEL_R1, CHANNEL_CAST);
            castinfo.banList.insert(std::make_pair(spectator->name, spectator->getIP()));
            spectator->disconnect();
            return true;
        }
    }

    sendChannelMessage("[Cast system]", "There is no spectator with that name.", TALKTYPE_CHANNEL_R1, CHANNEL_CAST);
    return false;
}
I tried the rest of TALKTYPE which was untested before and all of them showed the same error.
I also tried with guild MOTD and it showed the same error too.
I sent a message to different channels and it showed the same error, I just used this line.
C++:
player->sendChannelMessage("Test message", "Just some test message.", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD);
So a conclusion based on the above, It's not related to TALKTYPE and it's not related to channels.
I will recheck the function (Although I did before), and I will also write it here in case someone can look at it.
C++:
void ProtocolGameBase::sendChannelMessage(const std::string& author, const std::string& text, SpeakClasses type, uint16_t channel, bool broadcast)
{
    NetworkMessage msg;
    msg.addByte(0xAA);
    msg.add<uint32_t>(0x00);
    msg.addString(author);
    msg.add<uint16_t>(0x00);
    msg.addByte(type);
    msg.add<uint16_t>(channel);
    msg.addString(text);
    writeToOutputBuffer(msg, broadcast);
}
Note: I tried removing broadcast part before.
Edit: Got help by Nekiro, Just changed this msg.add<uint16_t>(0x00); to this msg.add<uint32_t>(0x00); on the function.
 
Last edited:
Solution
Back
Top