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

[Tutorial] Adding more tiles to game window - Updated 7/6/2018

f9837581339373f28662c756ad3b9eaf.png

https://gyazo.com/f9837581339373f28662c756ad3b9eaf

I get these errors

tfs 1.3
 
for otclient v8 use that better Extended map size - allows to send bigger map (requires changes from … · OTCv8/forgottenserver@8fc45c1 (https://github.com/OTCv8/forgottenserver/commit/8fc45c1e44e417de54460d08ebc555c88b412522)
then do this step
 
Also didnt work for me with TFS 1.3 + OTC 0.6.6... No errors at all, but window size wont increase. What am I doing wrong?
 
Last edited:
Also didnt work for me with TFS 1.3 + OTC 0.6.6... No errors at all, but window size wont increase. What am I doing wrong?
I have the same issue. Did I miss something? Using OTX 3.8 (based in TFS 1.2-1.3) and mehah otclient. The window size don't increase and but I think that the source edition did work, because I have the following:
creature_corner.png

Nevermind, this is solved but I couldn't find the post before
 
Last edited:
@ralke
In OTC, You need to increase the size of screen which is: gameMapPanel - in modules/game_interface/gameinterface.lua
look for function "updateStretchShrink" and try/experience with setVisibleDimension and other things.
 
@ralke
In OTC, You need to increase the size of screen which is: gameMapPanel - in modules/game_interface/gameinterface.lua
look for function "updateStretchShrink" and try/experience with setVisibleDimension and other things.
Ty @Fresh I make it work. For further viewers of this thread this set-up worked well for me

gameinterface.lua
Lua:
function setupViewMode(mode)
  if mode == currentViewMode then return end

  if currentViewMode == 2 then
    gameMapPanel:addAnchor(AnchorLeft, 'gameLeftPanel', AnchorRight)
    gameMapPanel:addAnchor(AnchorRight, 'gameRightPanel', AnchorLeft)
    gameMapPanel:addAnchor(AnchorBottom, 'gameBottomPanel', AnchorTop)
    gameRootPanel:addAnchor(AnchorTop, 'topMenu', AnchorBottom)
    gameLeftPanel:setOn(modules.client_options.getOption('showLeftPanel'))
    gameLeftPanel:setImageColor('white')
    gameRightPanel:setImageColor('white')
    gameLeftPanel:setMarginTop(0)
    gameRightPanel:setMarginTop(0)
    gameBottomPanel:setImageColor('white')
    modules.client_topmenu.getTopMenu():setImageColor('white')
    g_game.changeMapAwareRange(18, 14)
  end

  if mode == 0 then
    gameMapPanel:setKeepAspectRatio(true)
    gameMapPanel:setLimitVisibleRange(false)
    gameMapPanel:setZoom(12)
    gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
  elseif mode == 1 then
    gameMapPanel:setKeepAspectRatio(false)
    gameMapPanel:setLimitVisibleRange(true)
    gameMapPanel:setZoom(12)
    gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
  elseif mode == 2 then
    local limit = limitedZoom and not g_game.isGM()
    gameMapPanel:setLimitVisibleRange(limit)
    gameMapPanel:setZoom(12)
    gameMapPanel:setVisibleDimension({ width = 22, height = 11 })
    gameMapPanel:fill('parent')
    gameRootPanel:fill('parent')
    gameLeftPanel:setImageColor('alpha')
    gameRightPanel:setImageColor('alpha')
    gameLeftPanel:setMarginTop(modules.client_topmenu.getTopMenu()
      :getHeight() - gameLeftPanel:getPaddingTop())
    gameRightPanel:setMarginTop(modules.client_topmenu.getTopMenu()
      :getHeight() - gameRightPanel:getPaddingTop())
    gameLeftPanel:setOn(true)
    gameLeftPanel:setVisible(true)
    gameRightPanel:setOn(true)
    gameMapPanel:setOn(true)
    gameBottomPanel:setImageColor('#ffffff88')
    modules.client_topmenu.getTopMenu():setImageColor('#ffffff66')
    if not limit then
      g_game.changeMapAwareRange(24, 20)
    end
  end

  currentViewMode = mode
end

map.h
Code:
    public:
        static constexpr int32_t maxViewportX = 14; //min value: maxClientViewportX + 1
        static constexpr int32_t maxViewportY = 9; //min value: maxClientViewportY + 1
        static constexpr int32_t maxClientViewportX = 13;
        static constexpr int32_t maxClientViewportY = 8;

OTC map.h
Code:
void Map::resetAwareRange()
{
    AwareRange range;
    range.left = 13; //Change this to = maxClientViewportX
    range.top = 8; //Change this to = maxClientViewportY
    range.bottom = range.top + 1;
    range.right = range.left + 1;
    setAwareRange(range);
}
 
bump!

I've got an OTClient with the wider screen mod but I need someone to explain to me how can I mod and compile my OTserver .exe file, I have the source (is for version 8.6 TFS 0.4)
 
This is a tutorial showing how to add more tiles to the OTClient window. (Make the screen bigger)

Update:
in const.h
Code:
#define NETWORKMESSAGE_MAXSIZE 24590

I was notified increasing this number could resolve some issues.


This is actually a bigger problem than it should be, because TFS doesn't use maxViewPort everywhere it should. So lets change that first!

I will do this for TFS 1.0, since it is basically the same edits for TFS 0.3.6, and maybe i'll learn something doing it for TFS 1.0.

Most of our edits (almost all of them) will be in protocalgame.cpp

First we need to edit:
bool ProtocolGame::canSee(int32_t x, int32_t y, int32_t z) const
Change This:
Code:
  if ((x >= myPos.getX() - 8 + offsetz) && (x <= myPos.getX() + 9 + offsetz) &&
     (y >= myPos.getY() - 6 + offsetz) && (y <= myPos.getY() + 7 + offsetz)) {
To This:
Code:
  if ((x >= myPos.getX() - Map::maxClientViewportX + offsetz) && (x <= myPos.getX() + (Map::maxClientViewportX+1) + offsetz) &&
     (y >= myPos.getY() - Map::maxClientViewportY + offsetz) && (y <= myPos.getY() + (Map::maxClientViewportY+1) + offsetz)) {

Then in:
void ProtocolGame::sendMapDescription(const Position& pos)
Change This:
Code:
GetMapDescription(pos.x - 8, pos.y - 6, pos.z, 18, 14, msg);
To This:
Code:
GetMapDescription(pos.x - Map::maxClientViewportX, pos.y - Map::maxClientViewportY, pos.z, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, msg);

Then in:
void ProtocolGame::sendMoveCreature(const Creature* creature, const Position& newPos, int32_t newStackPos, const Position& oldPos, int32_t oldStackPos, bool teleport)
Change This:
Code:
if (oldPos.y > newPos.y) { // north, for old x
   msg.AddByte(0x65);
   GetMapDescription(oldPos.x - 8, newPos.y - 6, newPos.z, 18, 1, msg);
} else if (oldPos.y < newPos.y) { // south, for old x
   msg.AddByte(0x67);
   GetMapDescription(oldPos.x - 8, newPos.y + 7, newPos.z, 18, 1, msg);
}
if (oldPos.x < newPos.x) { // east, [with new y]
   msg.AddByte(0x66);
   GetMapDescription(newPos.x + 9, newPos.y - 6, newPos.z, 1, 14, msg);
} else if (oldPos.x > newPos.x) { // west, [with new y]
   msg.AddByte(0x68);
   GetMapDescription(newPos.x - 8, newPos.y - 6, newPos.z, 1, 14, msg);
}
To This:
Code:
if (oldPos.y > newPos.y) { // north, for old x
   msg.AddByte(0x65);
   GetMapDescription(oldPos.x - Map::maxClientViewportX, newPos.y - Map::maxClientViewportY, newPos.z, (Map::maxClientViewportX+1)*2, 1, msg);
} else if (oldPos.y < newPos.y) { // south, for old x
   msg.AddByte(0x67);
   GetMapDescription(oldPos.x - Map::maxClientViewportX, newPos.y + (Map::maxClientViewportY+1), newPos.z, (Map::maxClientViewportX+1)*2, 1, msg);
}
if (oldPos.x < newPos.x) { // east, [with new y]
   msg.AddByte(0x66);
   GetMapDescription(newPos.x + (Map::maxClientViewportX+1), newPos.y - Map::maxClientViewportY, newPos.z, 1, (Map::maxClientViewportY+1)*2, msg);
} else if (oldPos.x > newPos.x) { // west, [with new y]
   msg.AddByte(0x68);
   GetMapDescription(newPos.x - Map::maxClientViewportX, newPos.y - Map::maxClientViewportY, newPos.z, 1, (Map::maxClientViewportY+1)*2, msg);
}

Then in:
void ProtocolGame::MoveUpCreature(NetworkMessage& msg, const Creature* creature, const Position& newPos, const Position& oldPos)
Change This:
Code:
if (newPos.z == 7) {
   int32_t skip = -1;
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 5, 18, 14, 3, skip); //(floor 7 and 6 already set)
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 4, 18, 14, 4, skip);
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 3, 18, 14, 5, skip);
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 2, 18, 14, 6, skip);
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 1, 18, 14, 7, skip);
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 0, 18, 14, 8, skip);
To This:
Code:
if (newPos.z == 7) {
   int32_t skip = -1;
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, 5, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, 3, skip); //(floor 7 and 6 already set)
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, 4, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, 4, skip);
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, 3, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, 5, skip);
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, 2, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, 6, skip);
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, 1, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, 7, skip);
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, 0, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, 8, skip);

And Change This:
Code:
else if (newPos.z > 7) {
   int32_t skip = -1;
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, oldPos.getZ() - 3, 18, 14, 3, skip);
To This:
Code:
else if (newPos.z > 7) {
   int32_t skip = -1;
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, oldPos.getZ() - 3, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, 3, skip);

And Change This:
Code:
//moving up a floor up makes us out of sync
//west
msg.AddByte(0x68);
GetMapDescription(oldPos.x - 8, oldPos.y - 5, newPos.z, 1, 14, msg);
//north
msg.AddByte(0x65);
GetMapDescription(oldPos.x - 8, oldPos.y - 6, newPos.z, 18, 1, msg);
To This:
Code:
//moving up a floor up makes us out of sync
//west
msg.AddByte(0x68);
GetMapDescription(oldPos.x - Map::maxClientViewportX, oldPos.y - (Map::maxClientViewportY-1), newPos.z, 1, (Map::maxClientViewportY+1)*2, msg);
//north
msg.AddByte(0x65);
GetMapDescription(oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z, (Map::maxClientViewportX+1)*2, 1, msg);

Then in:
void ProtocolGame::MoveDownCreature(NetworkMessage& msg, const Creature* creature, const Position& newPos, const Position& oldPos)
Change This:
Code:
//going from surface to underground
if (newPos.z == 8) {
   int32_t skip = -1;
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z, 18, 14, -1, skip);
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 1, 18, 14, -2, skip);
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 2, 18, 14, -3, skip);
To This:
Code:
//going from surface to underground
if (newPos.z == 8) {
   int32_t skip = -1;
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, -1, skip);
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z + 1, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, -2, skip);
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z + 2, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, -3, skip);

And Change This:
Code:
//going further down
else if (newPos.z > oldPos.z && newPos.z > 8 && newPos.z < 14) {
   int32_t skip = -1;
   GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 2, 18, 14, -3, skip);
To This:
Code:
//going further down
else if (newPos.z > oldPos.z && newPos.z > 8 && newPos.z < 14) {
   int32_t skip = -1;
   GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z + 2, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, -3, skip);

And right below that change this:
Code:
//moving down a floor makes us out of sync
//east
msg.addByte(0x66);
GetMapDescription(oldPos.x + 9, oldPos.y - 7, newPos.z, 1, 14, msg);
//south
msg.addByte(0x67);
GetMapDescription(oldPos.x - 8, oldPos.y + 7, newPos.z, 18, 1, msg);
To This:
Code:
//moving down a floor makes us out of sync
//east
msg.addByte(0x66);
GetMapDescription(oldPos.x + Map::maxClientViewportX+1, oldPos.y - (Map::maxClientViewportY+1), newPos.z, 1, ((Map::maxClientViewportY+1)*2), msg);
//south
msg.addByte(0x67);
GetMapDescription(oldPos.x - Map::maxClientViewportX, oldPos.y + (Map::maxClientViewportY+1), newPos.z, ((Map::maxClientViewportX+1)*2), 1, msg);
If you are using 0.3.6 then you will also need to change this:
Code:
void ProtocolGame::AddMapDescription(NetworkMessage_ptr msg, const Position& pos)
{
  msg->put<char>(0x64);
  msg->putPosition(player->getPosition());
  GetMapDescription(pos.x - 8, pos.y - 6, pos.z, 18, 14, msg);
}
To This:
Code:
void ProtocolGame::AddMapDescription(NetworkMessage_ptr msg, const Position& pos)
{
  msg->put<char>(0x64);
  msg->putPosition(player->getPosition());
  GetMapDescription(pos.x - Map::maxClientViewportX, pos.y - Map::maxClientViewportY, pos.z, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, msg);
}

And I think that is all for protocolgame.cpp.

Now in map.h you can change these numbers to whatever you desire:
Code:
  static const int32_t maxViewportX = 11; //min value: maxClientViewportX + 1
  static const int32_t maxViewportY = 11; //min value: maxClientViewportY + 1
  static const int32_t maxClientViewportX = 8;
  static const int32_t maxClientViewportY = 6;

Generally:
The maxClientViewport is how far the client can see.
and maxViewport is how far monsters see.

Then under map.cpp in the OTClient:
Change these:
Code:
void Map::resetAwareRange()
{
   AwareRange range;
   range.left = 8;
   range.top = 6;
   range.bottom = 7;
   range.right = 9;
   setAwareRange(range);
}
To This:
Code:
{
   AwareRange range;
   range.left = 8; //Change this to = maxClientViewportX
   range.top = 6; //Change this to = maxClientViewportY
   range.bottom = range.top+1;
   range.right = range.left+1;
   setAwareRange(range);
}

If you extended your game-window and need creatures to "act" to you with the new distance, @Animera helped with code for that.
[Tutorial] Adding more tiles to game window - Updated 6/23/16

I think this should all work, if you have any issues PLEASE post them so I can correct problems with this tutorial.

If you have errors, please post both your protocolgame.cpp from TFS and map.cpp from OTClient. (So I can make sure you did it right before I look into it myself)

I'm really starting to have mental issues cuz of this, please try and solve it! Thanks in advance.
 
Solution:


//Creature.CPP


Change this:
Code:
bool Creature::canSee(const Position& myPos, const Position& pos, int32_t viewRangeX, int32_t viewRangeY)
{
   if (myPos.z <= 7) {
       //we are on ground level or above (7 -> 0)
       //view is from 7 -> 0
       if (pos.z > 7) {
           return false;
       }
   } else if (myPos.z >= 8) {
       //we are underground (8 -> 15)
       //view is +/- 2 from the floor we stand on
       if (Position::getDistanceZ(myPos, pos) > 2) {
           return false;
       }
   }

   const int_fast32_t offsetz = myPos.getZ() - pos.getZ();
   return (pos.getX() >= myPos.getX() - viewRangeX + offsetz) && (pos.getX() <= myPos.getX() + viewRangeX + offsetz)
       && (pos.getY() >= myPos.getY() - viewRangeY + offsetz) && (pos.getY() <= myPos.getY() + viewRangeY + offsetz);
}
To this:
Code:
bool Creature::canSee(const Position& myPos, const Position& pos, int32_t viewRangeX, int32_t viewRangeY)
{
   if (myPos.z <= 7) {
       //we are on ground level or above (7 -> 0)
       //view is from 7 -> 0
       if (pos.z > 7) {
           return false;
       }
   } else if (myPos.z >= 8) {
       //we are underground (8 -> 15)
       //view is +/- 2 from the floor we stand on
       if (Position::getDistanceZ(myPos, pos) > 2) {
           return false;
       }
   }

   const int_fast32_t offsetz = myPos.getZ() - pos.getZ();
   return (pos.getX() >= myPos.getX() - Map::maxViewportX + offsetz) && (pos.getX() <= myPos.getX() + Map::maxViewportX + offsetz)
       && (pos.getY() >= myPos.getY() - Map::maxViewportY + offsetz) && (pos.getY() <= myPos.getY() + Map::maxViewportY + offsetz);
}

That's all folks! [Tested it and worked properly on TFS 1.3, Cannot guarantee anything for other distro's]


Animera
necrobump, not sure if anybody has mentioned this, but:

in monster.cpp
instead of:
C++:
bool Monster::canSee(const Position& pos) const
{
    return Creature::canSee(getPosition(), pos, 9, 9);
}

change to:
C++:
bool Monster::canSee(const Position& pos) const
{
    return Creature::canSee(getPosition(), pos, Map::maxViewportX+1, Map::maxViewportX+1);
}

It will be consistent with previous mechanics and work properly. Otherwise, it will also affect NPCs behavior.
 

Check if XTEA is the same inside your TFS protocolgame.cpp and OTClient protocolgame.cpp.
Code:
    [C++]: Protocol::xteaDecrypt
ERROR: failed to decrypt message

If anybody gets this issue, remember to change NETWORKMESSAGE_MAXSIZE as Flatlander pointed out. If I'm correct, this should be amount of bytes being delivered on each packet, and I'm sure everyone doesn't have 25kbps connection anymore.
 
necrobump, not sure if anybody has mentioned this, but:

in monster.cpp
instead of:
C++:
bool Monster::canSee(const Position& pos) const
{
    return Creature::canSee(getPosition(), pos, 9, 9);
}

change to:
C++:
bool Monster::canSee(const Position& pos) const
{
    return Creature::canSee(getPosition(), pos, Map::maxViewportX+1, Map::maxViewportX+1);
}

It will be consistent with previous mechanics and work properly. Otherwise, it will also affect NPCs behavior.

This is mentioned here but it is still a good reminder ^^
Maybe can be a good idea to modify the original post with this information for further views.
 
Back
Top