blackdtools / Blackd-Proxy-CLASSIC

Blackd Proxy CLASSIC
MIT License
9 stars 7 forks source link

protocol violation on tibia 7.6 with tileID_ladderToUp #20

Open divinity76 opened 9 years ago

divinity76 commented 9 years ago

in tibia 7.6 , when trying to use tileID_ladderToUp=9C 07 on position x: 1835 y: 2090 z: 13 BlackD Proxy cavebot will send: 82 2B 07 2A 08 0D 9C 07 02 00 Tibia client will send (clicking manually): 82 2B 07 2A 08 0D 9C 07 01 00 this should be fixed. should also investigate if the proxy is violating the protocol in the same way in RL tibia, because if it is, this is probably something that Cipsoft could detect (and mark you as a cheater for deletion~)

i would also guess that the proxy is doing the same mistake in the closely related versions, 770, 772, 780, etc, but i haven't checked.

what does this byte mean anyway? stackpos maybe?

divinity76 commented 9 years ago

a quickfix: in modCavebot -> Public Sub PerformUseItem

find:

  Next SS
  b1 = Matrix(ydif, xdif, z, idConnection).s(SOPT).t1
  b2 = Matrix(ydif, xdif, z, idConnection).s(SOPT).t2

after that, add

  If (TibiaVersionLong = 760) Then
  SS = SS - 1
  End If

and i still don't know if other version than 760, or more importantly, RL tibia, is affected. i also don't know why this happens, or how to "properly" fix it.

blackdtools commented 9 years ago

Cipsoft had zero cavebot checks in Tibia 7.6 so it was not a real problem by that time. Anyways that is surely only a problem with the way that Blackd Proxy determines the top item in Tibia 7.6.

Tibia have changed his logic about that complex part a lot of times during his evolution. I am sure I am using the right logic in latest Tibia version. However I believe you are right and I was doing something wrong in Tibia 7.6. You should have a look on the S byte (stack position) of the function that builds that cheat packet. Then you should rewrite that function to build in a correct way to match Tibia 7.6 protocol. That special logic should only be used in Tibia 7.6 below protocol. Add condition tibiaversionlong =760 You should also test that it build correct packet in several scenarios: nothing in ladder, 1 item in ladder, 3 items in ladder, 11 items in ladder. The S byte will probably change depending that. Just get some gold coins and trash items and and build a trash of stack to do tests there.

blackdtools commented 9 years ago

After you do the tests I told you please confirm me if it works and I will add code to public version. However I am afraid we will require a more complex function.

divinity76 commented 9 years ago

dammit, yeah you're right. i tested the code a few other places, and it doesn't work. x.x

for instance GAMECLIENT1>( hex ) 0A 00 82start B8 07x 8A 02y 08z 49b1 07b2 04ss 00 ^ BlackD use... GAMECLIENT1>( hex ) 0A 00 82start B8 07x 8A 02y 08z 9Cb1 07b2 02ss 00 ^ client manual use

Nrated commented 8 years ago

Permament items placed there with map editor are always on first stacks so in this case ground = 01, and ladder = 02 or something like that... ; d Ofc I'm talking about tibia 7.6 ; p You just need to read from Matrix and Loop through stacks to find Ladder. I don't know if it has some kind of special property but you can always make a list of "ladder" items and Loop will search for it on the stack I'll give you an example with ladder items stored in listbox

ladderID = 0
ydif = yPosOfLadder - myY(idConnection)
xdif = xPosOfLadder - myX(idConnection)
For sPos = 1 To 5 'damn I don't remember if stackPos starts at 0 or 1 :confused:
    tileID = GetTheLong(Matrix(ydif, xdif, myz(idConnection), idConnection).s(sPos).t1, Matrix(ydif, xdif, myz(idConnection), idConnection).s(sPos).t2)
    For i = 0 To List1.ListCount
        If tileID = List1.List(i)
            ladderID = tileID
            Exit For
        End If
    Next i
    If ladderID <> 0 Then
        'we have found ladder and right stack
                stackPos = sPos
        Exit For
    End If
Next sPos

I'm not sure how ladder works though. Thats just an example You can elimiate inside For if there's only 1 type of ladders Im in work right now so I can't test this thing by myself

divinity76 commented 8 years ago

well, there's at least 1 id, "tileID_ladderToUp", but since there exist at least 4 types of ladder ids in tibia 7.6, that's not enough (there's ladder facing south, north, east, and west)

im pretty sure it starts at 1 though, judging by this 7.6 otserv source code

int32_t Tile::getThingCount() const
{
    return (uint32_t) 1 + (splash ? 1 : 0) + topItems.size() +  creatures.size() + downItems.size();
}
Thing* Tile::getThingByStackPos(int32_t pos) // << pos here comes from the client, its the 2nd-to-last byte in the use package
{
    if (pos == 0)
        return ground;

    pos--;

    if (splash)
    {
        if (pos == 0)
            return splash;
        //return NULL;
        pos--;
    }

    if ((unsigned) pos < topItems.size())
        return topItems[pos];

    pos -= (uint32_t)topItems.size();

    if ((unsigned) pos < creatures.size())
        return creatures[pos];

    pos -= (uint32_t)creatures.size();

    if ((unsigned) pos < downItems.size())
        return downItems[pos];

    return NULL;
}
blackdtools commented 8 years ago

I noticed that fact later Tibia versions and I handled it as a list in config.ini, but I didn't know it was already a list since 7.6. I guess the tile reader of 7.6 should be updated to handle a list of tiles too.