• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ Two-Handed stop working xD

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
549
Solutions
33
Reaction score
309
Location
Poland
GitHub
AscuasFunkeln
Hello, someone can help me?
Hah 0.3.6 V8 edited as hell, soo idk xD
Already i testing some stuff of my project and i see strange things, "two-handed" stop working xD
I already have add some more slots everything works perfect, but only "two-handed" dont work.
What i mean dont work, just server see this like "one-handed" and i can put whatever i want to other hand :o

Everything is ok with "two-handed" i compare it with basic source. Everything should work, but dont work.

I think there can be problem with switch two-handed from 12 to 17, anyway i replace it back to 12 and not work xD
C++:
#define ITEMS 11500
#define SLOTP_WHEREEVER 0xFFFFFFFF
#define SLOTP_HEAD 1 << 0
#define    SLOTP_NECKLACE 1 << 1
#define    SLOTP_BACKPACK 1 << 2
#define    SLOTP_ARMOR 1 << 3
#define    SLOTP_RIGHT 1 << 4
#define    SLOTP_LEFT 1 << 5
#define    SLOTP_LEGS 1 << 6
#define    SLOTP_FEET 1 << 7
#define    SLOTP_RING 1 << 8
#define    SLOTP_AMMO 1 << 9
#define    SLOTP_CAPE 1 << 10
#define    SLOTP_GLOVE 1 << 11
#define    SLOTP_EARRING 1 << 12
#define    SLOTP_BRACLET 1 << 13
#define    SLOTP_HALO 1 << 14
#define    SLOTP_PET 1 << 15
#define    SLOTP_DEPOT 1 << 16
#define    SLOTP_TWO_HAND 1 << 17
#define SLOTP_HAND SLOTP_LEFT | SLOTP_RIGHT

There u can see, everything is ok.

C++:
ReturnValue Player::__queryAdd(int32_t index, const Thing* thing, uint32_t count, uint32_t flags) const
{
    const Item* item = thing->getItem();
    if(!item)
        return RET_NOTPOSSIBLE;

    bool childIsOwner = ((flags & FLAG_CHILDISOWNER) == FLAG_CHILDISOWNER), skipLimit = ((flags & FLAG_NOLIMIT) == FLAG_NOLIMIT);
    if(childIsOwner)
    {
        //a child container is querying the player, just check if enough capacity
        if(skipLimit || hasCapacity(item, count))
            return RET_NOERROR;

        return RET_NOTENOUGHCAPACITY;
    }

    if(!item->isPickupable())
        return RET_CANNOTPICKUP;

    ReturnValue ret = RET_NOERROR;
    if((item->getSlotPosition() & SLOTP_HEAD) || (item->getSlotPosition() & SLOTP_NECKLACE) ||
        (item->getSlotPosition() & SLOTP_BACKPACK) || (item->getSlotPosition() & SLOTP_ARMOR) ||
        (item->getSlotPosition() & SLOTP_LEGS) || (item->getSlotPosition() & SLOTP_FEET) ||
        (item->getSlotPosition() & SLOTP_RING) || (item->getSlotPosition() & SLOTP_CAPE) ||
        (item->getSlotPosition() & SLOTP_GLOVE) || (item->getSlotPosition() & SLOTP_EARRING) ||
        (item->getSlotPosition() & SLOTP_BRACLET) || (item->getSlotPosition() & SLOTP_HALO) ||
        (item->getSlotPosition() & SLOTP_PET))
        ret = RET_CANNOTBEDRESSED;
    else if(item->getSlotPosition() & SLOTP_TWO_HAND)
        ret = RET_PUTTHISOBJECTINBOTHHANDS;
    else if((item->getSlotPosition() & SLOTP_RIGHT) || (item->getSlotPosition() & SLOTP_LEFT))
        ret = RET_PUTTHISOBJECTINYOURHAND;

    switch(index)
    {
        case SLOT_HEAD:
            if(item->getSlotPosition() & SLOTP_HEAD)
                ret = RET_NOERROR;
            break;
        case SLOT_NECKLACE:
            if(item->getSlotPosition() & SLOTP_NECKLACE)
                ret = RET_NOERROR;
            break;
        case SLOT_BACKPACK:
            if(item->getSlotPosition() & SLOTP_BACKPACK)
                ret = RET_NOERROR;
            break;
        case SLOT_ARMOR:
            if(item->getSlotPosition() & SLOTP_ARMOR)
                ret = RET_NOERROR;
            break;
        case SLOT_RIGHT:
            if(item->getSlotPosition() & SLOTP_RIGHT)
            {
                //check if we already carry an item in the other hand
                if(item->getSlotPosition() & SLOTP_TWO_HAND)
                {
                    if(inventory[SLOT_LEFT] && inventory[SLOT_LEFT] != item)
                        ret = RET_BOTHHANDSNEEDTOBEFREE;
                    else
                        ret = RET_NOERROR;
                }
                else if(inventory[SLOT_LEFT])
                {
                    const Item* leftItem = inventory[SLOT_LEFT];
                    WeaponType_t type = item->getWeaponType(), leftType = leftItem->getWeaponType();
                    if(leftItem->getSlotPosition() & SLOTP_TWO_HAND)
                        ret = RET_DROPTWOHANDEDITEM;
                    else if(item == leftItem && count == item->getItemCount())
                        ret = RET_NOERROR;
                    else if(leftType == WEAPON_SHIELD && type == WEAPON_SHIELD)
                        ret = RET_CANONLYUSEONESHIELD;
                    else if(!leftItem->isWeapon() || !item->isWeapon() ||
                        leftType == WEAPON_SHIELD || leftType == WEAPON_AMMO
                        || type == WEAPON_SHIELD || type == WEAPON_AMMO)
                        ret = RET_NOERROR;
                    else
                        ret = RET_CANONLYUSEONEWEAPON;
                }
                else
                    ret = RET_NOERROR;
            }
            break;
        case SLOT_LEFT:
            if(item->getSlotPosition() & SLOTP_LEFT)
            {
                //check if we already carry an item in the other hand
                if(item->getSlotPosition() & SLOTP_TWO_HAND)
                {
                    if(inventory[SLOT_RIGHT] && inventory[SLOT_RIGHT] != item)
                        ret = RET_BOTHHANDSNEEDTOBEFREE;
                    else
                        ret = RET_NOERROR;
                }
                else if(inventory[SLOT_RIGHT])
                {
                    const Item* rightItem = inventory[SLOT_RIGHT];
                    WeaponType_t type = item->getWeaponType(), rightType = rightItem->getWeaponType();
                    if(rightItem->getSlotPosition() & SLOTP_TWO_HAND)
                        ret = RET_DROPTWOHANDEDITEM;
                    else if(item == rightItem && count == item->getItemCount())
                        ret = RET_NOERROR;
                    else if(rightType == WEAPON_SHIELD && type == WEAPON_SHIELD)
                        ret = RET_CANONLYUSEONESHIELD;
                    else if(!rightItem->isWeapon() || !item->isWeapon() ||
                        rightType == WEAPON_SHIELD || rightType == WEAPON_AMMO
                        || type == WEAPON_SHIELD || type == WEAPON_AMMO)
                        ret = RET_NOERROR;
                    else
                        ret = RET_CANONLYUSEONEWEAPON;
                }
                else
                    ret = RET_NOERROR;
            }
            break;
        case SLOT_LEGS:
            if(item->getSlotPosition() & SLOTP_LEGS)
                ret = RET_NOERROR;
            break;
        case SLOT_FEET:
            if(item->getSlotPosition() & SLOTP_FEET)
                ret = RET_NOERROR;
            break;
        case SLOT_RING:
            if(item->getSlotPosition() & SLOTP_RING)
                ret = RET_NOERROR;
            break;
        case SLOT_AMMO:
            if(item->getSlotPosition() & SLOTP_AMMO)
                ret = RET_NOERROR;
            break;
        case SLOT_CAPE:
            if(item->getSlotPosition() & SLOTP_CAPE)
                ret = RET_NOERROR;
            break;
        case SLOT_GLOVE:
            if(item->getSlotPosition() & SLOTP_GLOVE)
                ret = RET_NOERROR;
            break;
        case SLOT_EARRING:
            if(item->getSlotPosition() & SLOTP_EARRING)
                ret = RET_NOERROR;
            break;
        case SLOT_BRACLET:
            if(item->getSlotPosition() & SLOTP_BRACLET)
                ret = RET_NOERROR;
            break;
        case SLOT_HALO:
            if(item->getSlotPosition() & SLOTP_HALO)
                ret = RET_NOERROR;
            break;
        case SLOT_PET:
            if(item->getSlotPosition() & SLOTP_PET)
                ret = RET_NOERROR;
            break;
        case SLOT_WHEREEVER:
        case -1:
            ret = RET_NOTENOUGHROOM;
            break;
        default:
            ret = RET_NOTPOSSIBLE;
            break;
    }

Every index in player.cpp ilogindata etc. add, replace, block etc. is move from 11 to 17 (6 new slots)

All slots work perfectly basic and new ones, just this fk two-handed, have no idea what is wrong :|
Any suggestions?
 
why are you swapping the slot position from it's normal position, why not just add your custom ones after that instead?
 
why are you swapping the slot position from it's normal position, why not just add your custom ones after that instead?
This cause me otclient problems, depot and two-handed are only defined in items.h as 11 and 12, skip this number like ammo=10, next cape=13 made errors, also cape=11 dont link with server xD

@edit
Yupp the problem is here items.h I see there is hidden define of two-handed but where?
Original In items.h is definied as 1 << 11 (Its shifted by -1) then its 12. So if this must be 12, then somewhere its defined as 12, but where? :eek:
 
Last edited:

Similar threads

Replies
0
Views
184
Back
Top