• 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 problem with effect 255+

Liryk

New Member
Joined
Jun 20, 2018
Messages
42
Reaction score
1
Hey OTClient can't display effect with id 255 or higher. How can I remedy this?
 
It's easy. More then 255 effects are not supported by any real tibia client, but OTClient already has this feature!

It's not only client problem! Server must also send effects with higher IDs (normal server sends uint8 [also known as 'byte'] = values 0 - 255)!
In case of newest TFS, code that sends that uint8 is here:
otland/forgottenserver
You need some C++ programmer to change it to uint16 (in few places in engine).

OTClient is compatible with all popular tibia versions. There is a script that check what 'features' were available in X version of tibia:
edubart/otclient

As 255+ effects were not available in any tibia version. There is no code that enables it.
You must add after:
Code:
m_features.reset();
This line:
Code:
enableFeature(Otc::GameMagicEffectU16);

And there is a code that 'parse' packet from server:
edubart/otclient
Code:
void ProtocolGame::parseMagicEffect(const InputMessagePtr& msg)
{
    Position pos = getPosition(msg);
    int effectId;
    if(g_game.getFeature(Otc::GameMagicEffectU16))
        effectId = msg->getU16(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE!
    else
        effectId = msg->getU8();

    if(!g_things.isValidDatId(effectId, ThingCategoryEffect)) {
        g_logger.traceError(stdext::format("invalid effect id %d", effectId));
        return;
    }

    EffectPtr effect = EffectPtr(new Effect());
    effect->setId(effectId);
    g_map.addThing(effect, pos);
}
With enabled feature 'GameMagicEffectU16', it reads 'short/uint16' from server packet (up to 65535 effects).
If you enable it in client and not modify server, it may block all effects or crash client!
 
It's easy. More then 255 effects are not supported by any real tibia client, but OTClient already has this feature!

It's not only client problem! Server must also send effects with higher IDs (normal server sends uint8 [also known as 'byte'] = values 0 - 255)!
In case of newest TFS, code that sends that uint8 is here:
otland/forgottenserver
You need some C++ programmer to change it to uint16 (in few places in engine).

OTClient is compatible with all popular tibia versions. There is a script that check what 'features' were available in X version of tibia:
edubart/otclient

As 255+ effects were not available in any tibia version. There is no code that enables it.
You must add after:
Code:
m_features.reset();
This line:
Code:
enableFeature(Otc::GameMagicEffectU16);

And there is a code that 'parse' packet from server:
edubart/otclient
Code:
void ProtocolGame::parseMagicEffect(const InputMessagePtr& msg)
{
    Position pos = getPosition(msg);
    int effectId;
    if(g_game.getFeature(Otc::GameMagicEffectU16))
        effectId = msg->getU16(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE!
    else
        effectId = msg->getU8();

    if(!g_things.isValidDatId(effectId, ThingCategoryEffect)) {
        g_logger.traceError(stdext::format("invalid effect id %d", effectId));
        return;
    }

    EffectPtr effect = EffectPtr(new Effect());
    effect->setId(effectId);
    g_map.addThing(effect, pos);
}
With enabled feature 'GameMagicEffectU16', it reads 'short/uint16' from server packet (up to 65535 effects).
If you enable it in client and not modify server, it may block all effects or crash client!


I changed in server side all uint8_t to uint16_t in " addMagicEffect " and " sendMagicEffect" i compile tfs and change otclient and compile too but when i enter game any effect do not display
 
I changed in server side all uint8_t to uint16_t in " addMagicEffect " and " sendMagicEffect" i compile tfs and change otclient and compile too but when i enter game any effect do not display
Now you can only add some 'std::cout' to parse/show effect code in OTClient. You must check if OTClient gets 255+ values from server.
 
Back
Top