• 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!

tfs 1.5 cast system

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
978
Solutions
6
Reaction score
167
Location
Nowhere
have added your cast system into my tfs i can see character list
but i get error connection when i try to log in(10600)
despite the server show im logged in

GM Ratx has logged in.


finally logged in but cant enable cast i does not work when i type command !cast also if i try to log in to game with no password/account i get message invalidad account name

Lua:
void ProtocolLogin::onRecvFirstMessage(NetworkMessage& msg)
{
    if (g_game.getGameState() == GAME_STATE_SHUTDOWN) {
        disconnect();
        return;
    }

    msg.skipBytes(2); // client OS

    uint16_t version = msg.get<uint16_t>();
    msg.skipBytes(12);
    /*
     * Skipped bytes:
     * 4 bytes: protocolVersion
     * 12 bytes: dat, spr, pic signatures (4 bytes each)
     * 1 byte: 0
     */

    if (version <= 760) {
        disconnectClient(fmt::format("Only clients with protocol {:s} allowed!", CLIENT_VERSION_STR));
        return;
    }

    if (!Protocol::RSA_decrypt(msg)) {
        disconnect();
        return;
    }

    xtea::key key;
    key[0] = msg.get<uint32_t>();
    key[1] = msg.get<uint32_t>();
    key[2] = msg.get<uint32_t>();
    key[3] = msg.get<uint32_t>();
    enableXTEAEncryption();
    setXTEAKey(std::move(key));

    if (version < CLIENT_VERSION_MIN || version > CLIENT_VERSION_MAX) {
        disconnectClient(fmt::format("Only clients with protocol {:s} allowed!", CLIENT_VERSION_STR));
        return;
    }

    if (g_game.getGameState() == GAME_STATE_STARTUP) {
        disconnectClient("Gameworld is starting up. Please wait.");
        return;
    }

    if (g_game.getGameState() == GAME_STATE_MAINTAIN) {
        disconnectClient("Gameworld is under maintenance.\nPlease re-connect in a while.");
        return;
    }

    BanInfo banInfo;
    auto connection = getConnection();
    if (!connection) {
        return;
    }

    if (IOBan::isIpBanned(connection->getIP(), banInfo)) {
        if (banInfo.reason.empty()) {
            banInfo.reason = "(none)";
        }

        disconnectClient(fmt::format("Your IP has been banned until {:s} by {:s}.\n\nReason specified:\n{:s}", formatDateShort(banInfo.expiresAt), banInfo.bannedBy, banInfo.reason));
        return;
    }

    std::string accountName = msg.getString();
    if (accountName.empty()) {
        disconnectClient("Invalid account name.");
        return;
    }

    std::string password = msg.getString();
    if (password.empty()) {
        disconnectClient("Invalid password.");
        return;
    }

    // OTCv8 version detection
    uint16_t otclientV8 = 0;
    uint16_t otcV8StringLength = msg.get<uint16_t>();
    if (otcV8StringLength == 5 && msg.getString(5) == "OTCv8") {
        otclientV8 = msg.get<uint16_t>(); // 253, 260, 261, ...
    }

    auto thisPtr = std::static_pointer_cast<ProtocolLogin>(shared_from_this());

    if (password.empty())
    {
        if (!g_config.getBoolean(ConfigManager::ENABLE_LIVE_CASTING))
            disconnectClient("Cast System is disabled.");
        else
            g_dispatcher.addTask([thisPtr]() { thisPtr->getCastingStreamsList(); });
        return;
    }

    g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCharacterList, thisPtr, accountName, password)));
}
 
upup have made new changes now im getting msgs if no one is casting
Lua:
if (casts.size() == 0) {
    disconnectClient("There is no one live, try later.");
    return;
}
but i can't log in i get message password or account number is wrong

protocologin.cpp


Code:
void ProtocolLogin::getCastingStreamsList()
{
    uint32_t serverIp = serverIPs[0].first;
    for (uint32_t i = 0; i < serverIPs.size(); i++) {
        if ((serverIPs[i].first & serverIPs[i].second) == (getConnection()->getIP() & serverIPs[i].second)) {
            serverIp = serverIPs[i].first;
            break;
        }
    }
    auto output = OutputMessagePool::getOutputMessage();

    const std::string& motd = g_config.getString(ConfigManager::MOTD);
    if (!motd.empty()) {
        output->addByte(0x14);

        std::ostringstream ss;
        ss << g_game.getMotdNum() << "\n" << motd;
        output->addString(ss.str());
    }

    output->addByte(0x64);

    const auto& casts = ProtocolGame::getLiveCasts();
    output->addByte(casts.size());

    if (casts.size() == 0) {
        disconnectClient("There is no one live, try later.");
        return;
    }

    for (const auto& cast : casts)
    {
        std::ostringstream entry;
        entry << cast.first->getName() << " [" << cast.second->getSpectatorCount() << (cast.second->isPasswordProtected() ? "*]" : "]");
        output->addString(entry.str());
        entry.str(std::string());
        output->addString("Lvl " + std::to_string(cast.first->getLevel()));
        output->add<uint32_t>(serverIp);
        output->add<uint16_t>(g_config.getNumber(ConfigManager::GAME_PORT));
    }

    output->add<uint16_t>(0);
    send(std::move(output));
    disconnect();
}




void ProtocolLogin::onRecvFirstMessage(NetworkMessage& msg)
{
    if (g_game.getGameState() == GAME_STATE_SHUTDOWN) {
        disconnect();
        return;
    }

    msg.skipBytes(2); // client OS

    /*uint16_t version =*/ msg.get<uint16_t>();
    msg.skipBytes(12);

    /*
     * Skipped bytes:
     * 4 bytes: protocolVersion
     * 12 bytes: dat, spr, pic signatures (4 bytes each)
     */

    if (!Protocol::RSA_decrypt(msg)) {
        disconnect();
        return;
    }

    //uint32_t key[4];
    xtea::key key;
    key[0] = msg.get<uint32_t>();
    key[1] = msg.get<uint32_t>();
    key[2] = msg.get<uint32_t>();
    key[3] = msg.get<uint32_t>();
    enableXTEAEncryption();
    setXTEAKey(std::move(key));
    //setXTEAKey(key);

    /*if (version < CLIENT_VERSION_MIN || version > CLIENT_VERSION_MAX) {
        //sendUpdateRequest();
        disconnectClient("Use Tibia 7.72 to login!");
        return;
    }*/

    if (g_game.getGameState() == GAME_STATE_STARTUP) {
        disconnectClient("Gameworld is starting up. Please wait.");
        return;
    }

    if (g_game.getGameState() == GAME_STATE_MAINTAIN) {
        disconnectClient("Gameworld is under maintenance.\nPlease re-connect in a while.");
        return;
    }

    BanInfo banInfo;
    auto connection = getConnection();
    if (!connection) {
        return;
    }

    if (IOBan::isIpBanned(connection->getIP(), banInfo)) {
        if (banInfo.reason.empty()) {
            banInfo.reason = "(none)";
        }

        std::ostringstream ss;
        ss << "Your IP has been banned until " << formatDateShort(banInfo.expiresAt) << " by " << banInfo.bannedBy << ".\n\nReason specified:\n" << banInfo.reason;
        disconnectClient(ss.str());
        return;
    }

    // Previous code... // was working
    //std::string accountName = msg.getString();
    //uint32_t accountName = msg.get<uint32_t>();
//    std::string password = msg.getString();

    //auto thisPtr = std::static_pointer_cast<ProtocolLogin>(shared_from_this());
    //uint32_t accountName = msg.get<uint32_t>(); //changed
    //std::string password = msg.getString();
    std::string password = msg.getString();
    std::string accountName = msg.getString();

    auto thisPtr = std::static_pointer_cast<ProtocolLogin>(shared_from_this());

    if (accountName.empty())
    {
        if (!g_config.getBoolean(ConfigManager::ENABLE_LIVE_CASTING))
            disconnectClient("Cast System is disabled.");
        else
            g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCastingStreamsList, thisPtr)));
        return;
    }
    //g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCharacterList, thisPtr, accountName, password)));
    g_dispatcher.addTask(createTask([thisPtr, accountName, password]() {
        thisPtr->getCharacterList(accountName, password);
        })); // was working
}

    //was working
    //if (!accountName)
    /*    if (!accountName.empty())
    {
        if (!g_config.getBoolean(ConfigManager::ENABLE_LIVE_CASTING))
            disconnectClient("Cast System is disabled.");
        else
            g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCastingStreamsList, thisPtr)));
        return;
    }
    g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCharacterList, thisPtr, accountName, password))); // original
    //g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCharacterList, thisPtr, std::placeholders::_1, std::placeholders::_2), accountName, password)); //proposal 1
    //g_dispatcher.addTask(createTask([thisPtr, accountName, password]() {
        //thisPtr->getCharacterList(accountName, password);
        //})); // was working
}*/

protcolgame.cpp
Code:
void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
{
    if (g_game.getGameState() == GAME_STATE_SHUTDOWN) {
        disconnect();
        return;
    }

    OperatingSystem_t operatingSystem = static_cast<OperatingSystem_t>(msg.get<uint16_t>());
    version = msg.get<uint16_t>();

    if (!Protocol::RSA_decrypt(msg)) {
        disconnect();
        return;
    }

    xtea::key key;
    key[0] = msg.get<uint32_t>();
    key[1] = msg.get<uint32_t>();
    key[2] = msg.get<uint32_t>();
    key[3] = msg.get<uint32_t>();
    enableXTEAEncryption();
    setXTEAKey(std::move(key));

    /*if (operatingSystem >= CLIENTOS_OTCLIENT_LINUX) {
        NetworkMessage opcodeMessage;
        opcodeMessage.addByte(0x32);
        opcodeMessage.addByte(0x00);
        opcodeMessage.add<uint16_t>(0x00);
        writeToOutputBuffer(opcodeMessage);
    }*/

    msg.skipBytes(1); // gamemaster flag

    //uint32_t accountName = msg.get<uint32_t>();
    std::string accountName = msg.getString();
    std::string characterName = msg.getString();
    std::string password = msg.getString();

    /*if (version < CLIENT_VERSION_MIN || version > CLIENT_VERSION_MAX) {
        //sendUpdateRequest();
        disconnectClient("Use Tibia 7.72 to login!");
        return;
    }*/

    if (g_game.getGameState() == GAME_STATE_STARTUP) {
        disconnectClient("Gameworld is starting up. Please wait.");
        return;
    }

    if (g_game.getGameState() == GAME_STATE_MAINTAIN) {
        disconnectClient("Gameworld is under maintenance. Please re-connect in a while.");
        return;
    }

    BanInfo banInfo;
    if (IOBan::isIpBanned(getIP(), banInfo)) {
        if (banInfo.reason.empty()) {
            banInfo.reason = "(none)";
        }

        std::ostringstream ss;
        ss << "Your IP has been banned until " << formatDateShort(banInfo.expiresAt) << " by " << banInfo.bannedBy << ".\n\nReason specified:\n" << banInfo.reason;
        disconnectClient(ss.str());
        return;
    }

    // OTCv8 version detection
    uint16_t otclientV8 = 0;
    uint16_t otcV8StringLength = msg.get<uint16_t>();
    if (otcV8StringLength == 5 && msg.getString(5) == "OTCv8") {
        otclientV8 = msg.get<uint16_t>(); // 253, 260, 261, ...
    }

    uint32_t accountId = IOLoginData::gameworldAuthentication(accountName, password, characterName);
    if (accountId == 0) {
        std::size_t pos = characterName.find("[");
        if (pos != std::string::npos) {
            pos -= 1;
        }
        g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::spectate, getThis(), characterName.substr(0, pos), password)));
    }
    else {
        Account account;
        if (accountId == 0) {
            disconnectClient("Account number or password is not correct.");
            return;
        }
        g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem)));
    }
}

gameworldauth iologindata.cpp
Code:
uint32_t IOLoginData::gameworldAuthentication(const std::string& accountName, const std::string& password, std::string& characterName)
{
    Database& db = Database::getInstance();

    DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `password` FROM `accounts` WHERE `name` = {:s}", db.escapeString(accountName)));
    if (!result) {
        return 0;
    }

    if (transformToSHA1(password) != result->getString("password")) {
        return 0;
    }

    uint32_t accountId = result->getNumber<uint32_t>("id");

    result = db.storeQuery(fmt::format("SELECT `name` FROM `players` WHERE `name` = {:s} AND `account_id` = {:d} AND `deletion` = 0", db.escapeString(characterName), accountId));
    if (!result) {
        return 0;
    }

    characterName = result->getString("name");
    return accountId;
}
 
EDIT FINALLY LOGGED IN AND cast seems to be working but can't move and everything looks fucked up
Lua:
    [C++]: ?setTileDescription@ProtocolGame@@QAEHABV?$shared_object_ptr@VInputMessage@@@stdext@@VPosition@@@Z
ERROR: ProtocolGame parse message exception (1901 bytes, 410 unread, last opcode is 0xff (255), prev opcode is 0x64 (100)): unhandled opcode 255
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
WARNING: HTTP error: resolve error (Host desconocido) - http://************/images/137.png
ERROR: no thing at pos:32572 32123 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32573 32123 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32573 32124 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32573 32125 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32574 32125 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32573 32125 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32572 32125 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32573 32125 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32574 32125 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
Post automatically merged:

Post automatically merged:

might it be related to this?
Lua:
void ProtocolGame::parseSpectatorPacket(NetworkMessage& msg)
{
    if (!acceptPackets || g_game.getGameState() == GAME_STATE_SHUTDOWN || msg.getLength() <= 0) {
        return;
    }

    if (getThis() == nullptr) {
        return;
    }

    uint8_t recvbyte = msg.getByte();

    if (!player) {
        if (recvbyte == 0x0F) {
            disconnect();
        }
        return;
    }

    if (player->isRemoved() || player->getHealth() <= 0) {
        disconnect();
        return;
    }
    for (auto& info : spectInfo) {
        if (info.liveName == spect->getLiveCastName() && info.spectIp == convertIPToString(spect->getIP()) && info.spectBan) {
            disconnect();
            disconnectClient("You are banned from this live!");
            return;
        }
    }

    //std::cout << "Recvbyte CastSystem: 0x" << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(recvbyte) << std::endl;

    switch (recvbyte)
    {
    case 0x14: g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::spectatelogout, getThis()))); break;
    case !0x1E: g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendPing, getThis()))); break;
    case 0x1D: disconnect(); break;
        //case 0x1D: g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendPingBack, getThis()))); break;
    case 0x64:
    case 0x65:
    case 0x66:
    case 0x67:
    case 0x68:
    case 0x6A:
    case 0x6B:
    case 0x6C:
    case 0x6D: g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendCancelWalk, getThis()))); break;
    case 0x96: parseSpectatorSay(msg); break;
    case 0x99: g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::spectatelogout, getThis()))); break;
        /*
            case 0x6F:
            case 0x70: g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::nextSpectator, getThis())));
            case 0x71:
            case 0x72:
        */
    default:
        break;
    }

    if (msg.isOverrun()) {
        disconnect();
    }
}
Post automatically merged:

log in cast.png
 
Last edited:
Back
Top