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

[Solved] Sending more tiles to client

Status
Not open for further replies.

Zero_master

New Member
Joined
Sep 13, 2013
Messages
33
Reaction score
2
Hello,

I'd like to send more tiles from my server to the otclient. From what I can see the server sends out 18, 8 on -x(or west) and 9 on +x(or east), by 14 tiles to the client by default. So far I'm happy with the layout in the file below (Example 1) however, when walking to the west the client has a small delay in loading the tiles. There is no problem with this when walking to the east though. (See example 2)

My question is - How can I make the server send more tiles to the client so it doesn't display the delay?

I've tried changing the several values in "FloorDescription" in the server source (protocol 9.6) with no results. I've also changed some values in the game_interface module.

Has anyone had experience with this before?


20zbhid.png
Example 1

a0dp4j.png
Example 2



Thanks for your time.


--------------------------------------------------------------------------------

Edit

Problem was solved thanks to help from Flatlander and Summ.

What we did to achieve the solution:

In the server files under Protocolgame.cpp

I replaced

PHP:
void ProtocolGame::AddMapDescription(NetworkMessage_ptr msg, const Position& pos)
{
  msg->AddByte(0x64);
  msg->AddPosition(player->getPosition());
  GetMapDescription(pos.x - 8, pos.y - 6, pos.z, 18, 14, msg);
}

with

PHP:
void ProtocolGame::AddMapDescription(NetworkMessage_ptr msg, const Position& pos)
{
  msg->AddByte(0x64);
  msg->AddPosition(player->getPosition());
  GetMapDescription(pos.x - 14, pos.y - 12, pos.z, 30, 26, msg);
}

As stated by Flatlander - the width and height of the map is x 2 that of the pos value PLUS 2.

I then replaced the appropriate values under "GetFloorDescription" and "AddMapDescription". Make sure you replace the current values with the ones you have set in "void ProtocolGame::AddMapDescription". You will be able to gauge what values need to replace the default values just by falling the trend. I also changed the values for the Spectators:

PHP:
       getSpectators(list, destPos, false, true, 18, 18 14, 14);

to

PHP:
       getSpectators(list, destPos, false, true, 30, 30, 26, 26);


In map.h

I replaced

PHP:
  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;

with

PHP:
  static const int32_t maxViewportX = 18; //min value: maxClientViewportX + 1
  static const int32_t maxViewportY = 18; //min value: maxClientViewportY + 1
  static const int32_t maxClientViewportX = 15;
  static const int32_t maxClientViewportY = 11;

That concludes the changes i made in the server files.

Now over to the client source files:

under map.cpp

PHP:
void Map::resetAwareRange()
{
  AwareRange range;
  range.left = 8;
  range.top = 6;
  range.bottom = 7;
  range.right = 9;
  setAwareRange(range);
}

was replaced with

PHP:
void Map::resetAwareRange()
{
  AwareRange range;
  range.left = 14;
  range.top = 12;
  range.bottom = 13;
  range.right = 15;
  setAwareRange(range);
}
 

Attachments

Last edited:
protocolgame.cpp under sendMoveCreature you need to change when a player walks, it updates the tiles farther away.
 
I can't seem to get this to change anything, does anyone know which function dictates how many tiles are sent to the client originally? 18 x 14 or 252 is the amount that is sent out when you login..
 
You have to change this in protocolgame.cpp.

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

This is the line you need to change:
GetMapDescription(pos.x - 8, pos.y - 6, pos.z, 18, 14, msg);

Currently set to get the top left corner of your screen (<^) and draw 18 tiles by 14 tiles(so 18 tiles east >> and 14 tiles south VV)
To fix this you will need to change the first 4 things to something like:
GetMapDescription(pos.x - 16, pos.y - 12, pos.z, 34, 26, msg);

REMEMBER you the 3rd and 4th entries MUST be 2 times the X or Y and then add 2.
For example:
Above I had pos.x - 16, multiply that by 2 is 32, add 2 and it is 34.
For Y I have 12, multiply by 2 is 24, add two is 26.
IF YOU DO NOT DO THIS, YOU WILL HAVE CONSTANT DEBUGS.[/PHP]
 
Hi again,

I've changed the following section

PHP:
void ProtocolGame::AddMapDescription(NetworkMessage_ptr msg, const Position& pos)
{
   msg->AddByte(0x64);
   msg->AddPosition(player->getPosition());
   GetMapDescription(pos.x - 10, pos.y - 8, pos.z, 22, 18, msg);
}

This is the output after compiling and logging in:

2ajs5uf.png


I'm using server 2.014, for client version 9.6

Thanks for helping out, really appreciate it..
 
Are you sure this is all you have changed? Or have you been trying to edit a lot of different things?

If you just logged on without moving at all, It looks like it is currently getting 13 tiles to the west instead of 10. and it doesn't look like the Y axis has changed at all.

Can you post me the following function as you have it?

PHP:
void ProtocolGame::GetMapDescription
 
It's strange, I've changed a few things but I always revert it after seeing no change

Here's what I have in that part

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

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

   if(skip >= 0)
   {
     msg->AddByte(skip);
     msg->AddByte(0xFF);
   }

That's without moving :)
 
Looks right, can you post me GetFloorDescription now?
 
This is what I have there

PHP:
void ProtocolGame::GetFloorDescription(NetworkMessage_ptr msg, int32_t x, int32_t y, int32_t z,
   int32_t width, int32_t height, int32_t offset, int32_t& skip)
{
   Tile* tile;
   for(int32_t nx = 0; nx < width; nx++)
   {
     for(int32_t ny = 0; ny < height; ny++)
     {
       tile = g_game.getTile(x + nx + offset, y + ny + offset, z);
       if(tile)
       {
         if(skip >= 0)
         {
           msg->AddByte(skip);
           msg->AddByte(0xFF);
         }
         skip = 0;
         GetTileDescription(tile, msg);
       }
       else
       {
         skip++;
         if(skip == 0xFF)
         {
           msg->AddByte(0xFF);
           msg->AddByte(0xFF);
           skip = -1;
         }
       }
     }
   }
}
 
Also looks right.
I wonder if there is a limit to how much information it can send or something.

If it isn't too much trouble, can you try the following 3 and post screen shots of how it looks when you log in (without moving)?

(Add this under AddMapDescription)
I am at work or i'd try it myself.

First Try:
GetMapDescription(pos.x - 4, pos.y - 3, pos.z, 10, 8, msg);
Then:
GetMapDescription(pos.x - 6, pos.y - 5, pos.z, 14, 12, msg);
Then:
GetMapDescription(pos.x - 9, pos.y - 7, pos.z, 20, 16, msg);

With these 3 examples we should be able to figure out what is happening.
 
Sure, not a problem

For

GetMapDescription(pos.x - 4, pos.y - 3, pos.z, 10, 8, msg);

We get this
vzx8gy.png


For

GetMapDescription(pos.x - 6, pos.y - 5, pos.z, 14, 12, msg);

We get
dpk84z.png


and for
GetMapDescription(pos.x - 9, pos.y - 7, pos.z, 20, 16, msg);

We get
2iroi0g.png


For every change I've just logged in and not moved at all.. it's interesting how the last one seems to be the only one out of place
 
What floor are you logging into (On the map)
What is your login position:
Example:
{x= 1000, y=1000, z=7}
 
And I assume the entire map is just those grey tiles? bigger than the screen just to test this?

Oh! And Try this :)
I am interested in seeing if it now draws to the South East rather than North West (which it should)

GetMapDescription(pos.x - 1, pos.y - 1, pos.z, 10, 10, msg);
 
Yup! It's just a huge testing area :)

Heres - GetMapDescription(pos.x - 1, pos.y - 1, pos.z, 10, 10, msg);
2zyy0s1.png
 
Do you have any grey tiles on higher or lower floors or something?
Make sure the ONLY mapping you have is on floor 7 (just to be sure we aren't seeing a floor higher or lower than you being drawn)
 
All tiles are on floor 7, have tried with a fresh map also just to be sure. I'm going to try with a fresh rebuild on a new download of the source - just changing the GetMapDescription(pos.x - 8, pos.y - 6, pos.z, 18, 14, msg); part.

Edit ~ tried with fresh source, still no luck

Very strange..
 
Ok, Also try replacing

GetMapDescription(pos.x - 10, pos.y - 8, pos.z, 10, 10, msg);

with

GetFloorDescription(msg, pos.x - 10, pos.y - 8, pos.z, 22, 18, 0, -1);

(The difference is, GetMapDescription draws multiple floors, and GetFloorDescription will just draw your current floor)
 
I'm getting the following error -

\protocolgame.cpp(3355): error C2664: 'ProtocolGame::GetFloorDescription' : cannot convert parameter 8 from 'int' to 'int32_t &'

nh17kj.png
 
Last edited:
Status
Not open for further replies.
Back
Top