• 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

[QUOTE = "Flatlander, post: 2198969, member: 30883"]
  • Void Mapa :: resetAwareRange ()
  • {
  • AwareRange gama;
  • Range.left = 8;
  • Range.top = 6;
  • Range.bottom = 7;
  • Range.right = 9;
  • SetAwareRange (intervalo);
  • }
[/CITAR]

Isso não existe no meu map.cpp
post what tfs are u using
 
sadasd.png


;/
 
@Flatlander

My default NETWORKMESSAGE_MAXSIZE is 24590
Using...
Code:
static constexpr int32_t maxViewportX = 21; //min value: maxClientViewportX + 1 //Original 11
        static constexpr int32_t maxViewportY = 21; //min value: maxClientViewportY + 1 // Original 11
        static constexpr int32_t maxClientViewportX = 19;                                 // Original 8
        static constexpr int32_t maxClientViewportY = 8;                                 // Original 6

Gives me blackscreen, so compile it with
Code:
NETWORKMESSAGE_MAXSIZE = 44590;

and then made it lower to 34590 and still works, but i have to ask.
Which size do you recommend?

Also, what does that size means?... Players online does something with it?
Or what affects to NETWORKMESSAGE_MAXSIZE?
 
@Flatlander

My default NETWORKMESSAGE_MAXSIZE is 24590
Using...
Code:
static constexpr int32_t maxViewportX = 21; //min value: maxClientViewportX + 1 //Original 11
        static constexpr int32_t maxViewportY = 21; //min value: maxClientViewportY + 1 // Original 11
        static constexpr int32_t maxClientViewportX = 19;                                 // Original 8
        static constexpr int32_t maxClientViewportY = 8;                                 // Original 6

Gives me blackscreen, so compile it with
Code:
NETWORKMESSAGE_MAXSIZE = 44590;

and then made it lower to 34590 and still works, but i have to ask.
Which size do you recommend?

Also, what does that size means?... Players online does something with it?
Or what affects to NETWORKMESSAGE_MAXSIZE?

NETWORKMESSAGE_MAXSIZE is the maximum size of a message TFS can send to the Client.

If you increase the size of the screen too much, the "login" and "teleport" messages will be too large. (They send every tile on the screen in one message).
Honestly you could make NETWORKMESSAGE_MAXSIZE = 10000000000000000000000000000000000000000000000000000000000000000000000000000; and it probably wouldn't cause any issues. It's just the maximum allowed message size.
 
@Flatlander I tried it on TFS 1.3 and it works great. The only thing missing is this:

Replace 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);

With this:
Code:
//moving down a floor makes us out of sync
//east
msg.addByte(0x66);
GetMapDescription(oldPos.x + Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z, 1, (Map::maxClientViewportY + 1) * 2, msg);

//south
msg.addByte(0x67);
GetMapDescription(oldPos.x - Map::maxClientViewportX, oldPos.y + Map::maxClientViewportY, newPos.z, (Map::maxClientViewportY + 1) * 2, 1, msg);
 
Last edited:
@Flatlander I tried it on TFS 1.3 and it works great. The only thing missing is this:

Replace 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);

With this:
Code:
//moving down a floor makes us out of sync
//east
msg.addByte(0x66);
GetMapDescription(oldPos.x + Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z, 1, (Map::maxClientViewportY + 1) * 2, msg);

//south
msg.addByte(0x67);
GetMapDescription(oldPos.x - Map::maxClientViewportX, oldPos.y + Map::maxClientViewportY, newPos.z, (Map::maxClientViewportY + 1) * 2, 1, msg);

How does this affects?
O follower the tutorial as it is and it's working just fine

Edit: Mr. Smartass, you got a 9 and a 8 and you replaced both with Map::maxClientViewportX, giving them the same value, instead of (Map::maxClientViewportX+1) to the "9"

Edit 2: @Flatlander i also need to understand, why theres values unmodified like the one Senzubean posted?
 
Last edited:
Adding a couple of extra tiles is great imo, but seeing servers with super many tiles just makes no sense imo. It adds nothing to the game and walking in caves for example becomes stupid, because often there's only around 5 or 6 squares where you can actually walk so then there's 10 tiles with just water/mountain/ or what have you that should fill the screen.
 
Screen_Shotft002.jpg


Error in Otclient

when I go down the rookgaard manure the client freezes, the bottom floor does not appear, and on the console of the otclient this error appears
Code:
ERROR: no thing at pos:32323 31794 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32324 31794 7, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: unable to remove creature
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32327 31782 6, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32327 31782 6, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32328 31782 6, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z
ERROR: no creature found to move
at:
    [C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:32329 31782 6, stackpos:1
at:
    [C++]: ?getMappedThing@ProtocolGame@@QAE?AV?$shared_object_ptr@VThing@@@stdext@@ABV?$shared_object_ptr@VInputMessage@@@3@@Z

my protocalgame.cpp
//////////////////////////////////////////////////////////////////////// // Ope - Pastebin.com

I suppose it is a mistake that monsters are poorly positioned on lower floors,
the floors 7,8,9 ... work ok
the underground floors do not

help!
 
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);

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);
}

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)
Screen_Shotft005.jpg

I did, but I can not use any item, shovel, rope, runes .. do you know what I should pack?
 
Well it sends more tiles, but you will have to choose what you want your zoom to be.

if you hold down CTRL and press = and - (Next to the backspace) you will zoom out and zoom in.

You can change stuff related to the zooming without editing source.

You do this in gameinterface.lua.

Hello @Flatlander ,

I've added some tiles to my client, but I have a question.

Is there a way to put my client as default with zoom out? Without having all the time I open the client click click on Ctrl -?
 
That's a copy-paste, just replace your gameinterface.lua with that

Thanks. But what I need it's , put default this viewmode. Everytime that I enter in my client, I need click 2x in CTRL -, to put this viewmode

bUdgkh93TEiMLw0OfJcmMA.png
 
When I climb on a ladder, this appears, and the account hangs forever.
Sorry for my English, I'm Brazilian. Help-me


Code:
    [C++]: Protocol::xteaDecrypt
ERROR: failed to decrypt message
at:
    [C++]: Protocol::internalRecvData
ERROR: invalid encrypted network message
at:
    [C++]: Protocol::xteaDecrypt
ERROR: failed to decrypt message
at:
 
Back
Top