edubart / otclient

An alternative tibia client for otserv written in C++11 and Lua, made with a modular system that uses lua scripts for ingame interface and functionality, making otclient flexible and easy to customize
Other
652 stars 399 forks source link

Minimap drawing issue (multi-floor) #343

Open LordHepipud opened 11 years ago

LordHepipud commented 11 years ago

The minimap is somehow drawing all floors while walking around instead of the current one only. This means players can find hidden holes or anything else by simply switching the viewing floor on the minimap.

Tried to implement a quick patch for that:

minimap.cpp, bottom: Add


//PhiadariaSoft Mod: Minimap drawing fix
#include "game.h"

minimap.cpp: Change


void Minimap::updateTile(const Position& pos, const TilePtr& tile)

for


void Minimap::updateTile(const Position& pos, const TilePtr& tile)
{
    //PhiadariaSoft Mod: Minimap drawing fix
    LocalPlayerPtr localPlayer = g_game.getLocalPlayer();
    if(!localPlayer || localPlayer->getPosition().z != pos.z) {
        return;
    }
    MinimapTile minimapTile;
    if(tile) {
        minimapTile.color = tile->getMinimapColorByte();
        minimapTile.flags |= MinimapTileWasSeen;
        if(!tile->isWalkable(true))
            minimapTile.flags |= MinimapTileNotWalkable;
        if(!tile->isPathable())
            minimapTile.flags |= MinimapTileNotPathable;
        minimapTile.speed = std::min((int)std::ceil(tile->getGroundSpeed() / 10.0f), 255);
    }

    if(minimapTile != MinimapTile()) {
        MinimapBlock& block = getBlock(pos);
        Point offsetPos = getBlockOffset(Point(pos.x, pos.y));
        block.updateTile(pos.x - offsetPos.x, pos.y - offsetPos.y, minimapTile);
        block.justSaw();
    }
}

Problem that now remains: If a player is changing the floor up/down the minimap is not updating this region until the player enters it again without a floor change.

Example: Player is walking up some stairs -> minimap for the seen block is not updated correctly. If the player now continues walking and enters the specific area again by walking, the minimap is updated correctly again.

Any idea on how to fix that? Any further idea to fix this little problem with the minimap without using the player position like I did?

LordHepipud commented 10 years ago

Made a pull request for this: #572

diath commented 10 years ago

Well, other floors are being sent to the client depending on the floor you're currently at, so I don't see anything wrong with taking the advantage of it and drawing the minimap ahead. Although I can see why some people wouldn't want that, good suggestion with the toggle.

LordHepipud commented 10 years ago

The problem at some point is that when you are walking around on floor 7, the server will send data from floors below as well. This makes it - from my point of view - way to easy to locate secret spots for example. Up to that players will get to know about all path, secret hideouts and so on, on all upper floors from ground floor to the top floor.

As I know some player might like that, I have made this patch optional with a compiler flag. If not compiled that way, the current handling will be used.

BenDol commented 10 years ago

Will review this later today.

iryont commented 10 years ago

The server will never send any tiles below ground floor if your current z position is below or equal to 7 (therefore the character itself is above or the same level as ground floor).

This is a technical limitation of Tibia client, not to mention the fact that OTServ won't do that.

LordHepipud commented 10 years ago

The server is actually sending floors below to keep track for possible creatures below ensuing you get to know about them moving from floor 8 to 7. Anyway - even when beeing on underground or on floors above 7 - OTClient will wrongly draw all send tiles from server to the minimap, which he shouldn't in my oppinion. The minimap should only display tiles inside the current view ignoring everything on different floors.

BenDol commented 10 years ago

It does in fact send +- tiles.

iryont commented 10 years ago

It does not.

Tibia holds 2016 tiles for total of 8 floors (z modulo 8). If you are above ground you receive all floors between 0-7 floors (8 floors in total) and it would be impossible to receive one more floor (in this case floor 8 which is underground) simple because it would override one normal floor due to modulo calculation.

There are several packets to remove creature when moving from floor 7 to 8 and to add when moving from floor 8 to 7.

No more than 8 floors can be sent at the same time.

LordHepipud commented 10 years ago

This might be the case for newer Tibia versions - no idea about that. On old clients you received the lower floors as well. It could be that it was changed due to the fact that people used a floor inspector to get to know about creatures beeing placed on lower floors or to map areas which weren't accessable. Anyway - still the handling of OTClient to draw minimaps entirely based on received tiles is wrong :p

iryont commented 10 years ago

I agree. However, I'm going to use that on my server (draw all tiles for mini-map). The reason for that is because I either do that, or allow cheaters to gain advantage over fair players. Sooner or later there will be someone gaining advantage using X-Ray hacks.

Anyway, regarding old clients - my server is based on 7.72 protocol and the Tibia client here can only handle 2016 tiles (8 floors).

LordHepipud commented 10 years ago

Patched my server from 7.6 to 7.72 and now custom - always had the part with lower floors in it and everything worked - even the real Tibia Client which is very untable in case not beeing used correctly ;) As I mentioned before I understand that some people will want to allow this feature - for that reason I Implemented a new flag EXPLORATION_MODE which has to be enabled in order to make my patch working.

iryont commented 10 years ago

Tibia client will work just fine with such thing. However, one floor will be lost (8 mod 8 = 0, so the highest floor will be lost and replaced with floor 8).

Perhaps your server was based on very old OTServ code.

BenDol commented 10 years ago

Common servers like shadowcores still sends this information. Its still in the latest server protocols.

iryont commented 10 years ago

There is a quite long distance between 7.72 and 10.50+ versions.

Perhaps CipSoft finally changed that. I'm not really up to date with current Tibia versions.