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

OTClient - What is it capable of? How does it work?

BenGarrison

New Member
Joined
Dec 16, 2019
Messages
1
Reaction score
0
I have been following the OTS Guide to the point of the page about connecting to your server. I have compiled both TFS and the OTC without any issues. I have my server running, and have created an account and character through ZnoteAAC. I noticed a client version dropdown menu when opening up the client, does this mean that this standalone client is capable of running all of those tibia clients straight out of the box? I looked through the source code and noticed things such as the stamina system being implemented, something earlier tibia clients did not have. If I were to choose a client version before the stamina system was implemented, will OTC automatically know that things such as stamina, mounts, stackable runes does not apply to the chosen client version, and omit those features automatically upon login? How does it work server side? The database has tables and columns pertaining to new additions that may not have been in earlier tibia releases. When using an older client, do these fields just get filled with a null value? What happens when I connect to my server with client version 8.6 one day, 7.4 the day after, and then version 10.99 (recompiling the server in between version changes to allow a different client)? Does the database get wiped each time? I ask these things because I've never actually been able to connect to my server through OTClient.

When I fired up the client for the first time, I changed the dropdown menu to client version 740. Upon logging in, the client told me that it failed to load Tibia.dat and Tibia.spr from the directory /things/740. I assume that spr files are just the sprites, but what's contained in the dat files? What does the game use .dat files for? I went to otservlist to download the 7.4 client so that I could get the two files that I needed and placed them in data/things/740. I did the same and created new folders for other clients, such as 860. Once that issue was resolved, and the game could find the 7.4's spr and dat files, the client told me that only clients with protocol 10.98 are allowed. I went to the server's src directory and changed lines 27-29 of definitions.h to
C++:
static constexpr auto CLIENT_VERSION_MIN = 740;
static constexpr auto CLIENT_VERSION_MAX = 740;
static constexpr auto CLIENT_VERSION_STR = "7.4";
Is this all you would need to change in order for your game to run the 7.4 version of tibia? What happens when I set the version minimum to version 7.4, but the max to 10.98? Anyways, I recompiled the server and tried logging in again. I set the client to version 740 in the dropdown menu and log in. Now it tells me that only clients with protocol 7.4 are allowed. From the server's protocollogin.cpp line 141 located in the src directory
C++:
if (version <= 760) {
        std::ostringstream ss;
        ss << "Only clients with protocol " << CLIENT_VERSION_STR << " allowed!";
        disconnectClient(ss.str(), version);
        return;
}
It seems as if it is hardcoded to never allow any client which is version 7.6 or below. Why is it such? Does The Forgotten Server not support client version 7.6 and below? If so, what is the point of the OTClient supporting it? To use it with other servers that do support 7.6 and below? I recompiled the server to version 8.6 and tried logging in with the corresponding client version. This time I got an "invalid authentification token" message. I followed a solution from this thread, commenting out lines 57-67 & lines 207-214 of the server's protocollogin.cpp.
C++:
/**if (!account.key.empty()) {
        if (token.empty() || !(token == generateToken(account.key, ticks) || token == generateToken(account.key, ticks - 1) || token == generateToken(account.key, ticks + 1))) {
            output->addByte(0x0D);
            output->addByte(0);
            send(output);
            disconnect();
            return;
        }
        output->addByte(0x0C);
        output->addByte(0);
    }**/
C++:
/**msg.skipBytes((msg.getLength() - 128) - msg.getBufferPosition());
    if (!Protocol::RSA_decrypt(msg)) {
        disconnectClient("Invalid authentification token.", version);
        return;
    }
    
    std::string authToken = msg.getString();**/
Recompiling causes an error about the variable authToken being not declared.
Code:
/home/qwerty/Downloads/forgottenserver/src/protocollogin.cpp:217:110: error: ‘authToken’ was not declared in this scope
  g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCharacterList, thisPtr, accountName, password, authToken, version)));
I removed the comment from line 217 which initialized the authToken variable and recompiled the server successfully. Logging in again it tells me "connecting to login server", but it never actually does. There's an error outputted to the terminal from OTClient
Code:
ERROR: protected lua call failed: LUA ERROR:
C++ call failed: InputMessage eof reached
stack traceback:
    [C]: ?
    [C]: in function 'getString'
    /gamelib/protocollogin.lua:229: in function 'parseCharacterList'
    /gamelib/protocollogin.lua:166: in function </gamelib/protocollogin.lua:148>
The offending lines from otclient/modules/protocollogin.lua are character.name = msg:getString() and self:parseCharacterList(msg)

At this point I gave up on 8.6 as well and tried the latest version whose tibia.dat and tibia.spr I could download from otservlist.org, version 10.96. I recompile the server to version 10.96 and login with the client. Everything works fine and I'm in the game. The client complains about ERROR: ProtocolGame parse message exception (4805 bytes unread, last opcode is 0, prev opcode is 160): unhandled opcode 0 but the game keeps running fine for the most part. What gives? Is OTClient made only to run the latest version of Tibia? I'm familiar with GNU/Linux, programming, and databases, so you don't need to explain it in simple terms if you don't want to.
 
Back
Top