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

Editing Floor View with Storage 0.4

1579091

New Member
Joined
Jul 18, 2012
Messages
14
Reaction score
0
Hey there! Firstly sorry for my bad english...

So.. I'm looking for a system that verify the player storage.. and when return 1, will change the Floor View:

if player is on 7 floor and storage = 1, then he will see only what is in floor 7...
if player is on 6 floor and storage = 1, then he will see only what is in floor 7 and 6..
if player is on 5 floor and storage = 1, then he will see what is in floor 7, 6 and 5...

I developed a solution that i can verify the storage in GetMapDescription, and GetFloorDescription... using a new param (bool storageDynamic), so i can use:
if (storageDynamic){
... code here ...
}

I'm sending that storage in sendMoveCreature, MoveUpCreature, MoveDownCreature and sendAddCreature... if need to send in other tell me...

Code:
void ProtocolGame::GetMapDescription(int32_t x, int32_t y, int32_t z,
    int32_t width, int32_t height, OutputMessage_ptr msg, bool storageDynamic)
{
    int32_t skip = -1, startz, endz, zstep = 0;
    if(z > 7)
    {
        startz = z - 2;
        endz = std::min((int32_t)MAP_MAX_LAYERS - 1, z + 2);
        zstep = 1;
    }
    else
    {     
        startz = 7;
        endz = 0;
        zstep = -1;
    }

    /*if(storageDynamic){
       ... this checks for players that have the storage
     }*/

    for(int32_t nz = startz; nz != endz + zstep; nz += zstep)
        GetFloorDescription(msg, x, y, nz, width, height, z - nz, skip, storageDynamic);
  

    if(skip >= 0)
    {
        msg->addByte(skip);
        msg->addByte(0xFF);
        //cc += skip;
    }
}


Code:
void ProtocolGame::GetFloorDescription(OutputMessage_ptr msg, int32_t x, int32_t y, int32_t z,
        int32_t width, int32_t height, int32_t offset, int32_t& skip, bool storageDynamic)
{
    Tile* tile = NULL;
    for(int32_t nx = 0; nx < width; ++nx)
    {
        for(int32_t ny = 0; ny < height; ++ny)
        {
            if((tile = g_game.getTile(Position(x + nx + offset, y + ny + offset, z))))
            {
                if(skip >= 0)
                {
                    msg->addByte(skip);
                    msg->addByte(0xFF);
                }

                skip = 0;
                GetTileDescription(tile, msg);
            }
            else if(++skip == 0xFF)
            {
                msg->addByte(0xFF);
                msg->addByte(0xFF);
                skip = -1;
            }
        }
    }
}

Code:
void ProtocolGame::AddMapDescription(OutputMessage_ptr msg, const Position& pos, bool storageDynamic)
{
    msg->addByte(0x64);
    msg->addPosition(player->getPosition());
    GetMapDescription(pos.x - 8, pos.y - 6, pos.z, 18, 14, msg, storageDynamic);
}
 

Similar threads

Back
Top