• 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

I did all the code changes using Tfs 1.3 source, but when i try compile it display those errors:

'AddByte': is not a member of 'NetworkMessage' theforgottenserver c:\users\forgottenserver\src\protocolgame.cpp 2518

View attachment 33069

My protocolgame.cpp
/** * The Forgotten Server - a free and open-source MMORPG server emulator * - Pastebin.com

I appreciate some help, thank you.

Try addByte instead of AddByte
I remember somewhere used to be a error with capital letter... if you copy/paste it..
check the original files how it's written :)
 
Try addByte instead of AddByte
I remember somewhere used to be a error with capital letter... if you copy/paste it..
check the original files how it's written :)

I changed all AddByte to addByte and it worked, thank you Animera :)
 
I used clean tfs 1.3 build and clean otclient latest source, to test this tutorial to add more tiles to game window.

I was testing the fps performance with many monsters on screen with and without zoom, and i got those errors on otclient console and a huge fps drop;

ERROR: no thing at pos:31 70 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:30 70 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 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 creature found to move
at:
[C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:30 70 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 creature found to move
at:
[C++]: ?parseCreatureMove@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: no thing at pos:30 70 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:30 69 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:31 70 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


On tfs console display no errors, do someone else got it?
 
my bad its only happens on vievmode 0 changed mode to 1 and it works fine thanks
 
@Flatlander
I followed the tutorial to 100% on the main post, with exception of the TFS 0.3.6 stuffs because I use TFS 1.0 and my sources didn't have the functions for those anyway.
But other than that, I did everything exactly as it said.. (I even doubled the const.h value)

And it works prefect with default values..
but as soon as I increase how many tiles the screen should contain, it buggs out as hell..

This is my screen using default values:
nKN8zOi.png

src/client/map.cpp
C++:
void Map::resetAwareRange()
{
    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);
}

And here's my screen adding extra tiles:
sV7dsJL.png

src/client/map.cpp
C++:
void Map::resetAwareRange()
{
    AwareRange range;
    range.left = 9; //Change this to = maxClientViewportX
    range.top = 7; //Change this to = maxClientViewportY
    range.bottom = range.top+1;
    range.right = range.left+1;
    setAwareRange(range);
}

As you can see, it bugs out real good..
But pay attention, and you see that my screen doesn't go bigger at all, it stay same amount of tiles on width and height
(even when I resize the window).
So even if I did change it to be 9x7 in the sources, the client doesn't add the extra rows.

And this is very odd to me, I double checked with previous guys having similar issues, there entire game window buggs out..
But as they buggs out, they can still see the new size of the tiles anyway.. and I can't...

Anyone having any idea what's causing this?
Does/Did OTClient had any other places there you needed to change how many rows of tiles there should be?

Same here!
It only works with the default values (8 and 6)

Untitled.png
 
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

It would be better to actually change otland/forgottenserver (https://github.com/otland/forgottenserver/blob/bcb86eac0655c58b8dc9a35c652f8953a0edd033/src/monster.cpp#L83)

from
C:
return Creature::canSee(getPosition(), pos, 9, 9);
to
Code:
return Creature::canSee(getPosition(), pos, Map::maxViewportX, Map::maxViewportY);

so you don't conflict with otland/forgottenserver (https://github.com/otland/forgottenserver/blob/bcb86eac0655c58b8dc9a35c652f8953a0edd033/src/npc.cpp#L235)
 
Recently gave this tutorial another shot (had it working in the past).

Using latest TFS+OTClient clean sources, maxClientViewportX 16 and maxClientViewportY 10 I was getting errors/issues. From black screens, desync when moving floors underground, skills -1, on OTC console [C++]: ?parseCreatureMove@ProtocolGame and others...

I only managed to trigger those errors on one place of the map (not saying it only triggers there just couldn't find another place) This map has a big room full of items/monters/teleports (basically a test room I have with everything ingame for testing) Going there would make OTC console pop errors (sometimes it would desync/glitch) Logging out there and coming back on would show a black screen.

Using normal view (both with Tibia client and OTC) would work just fine but as soon as I extended the view bugs start again.

Tryed changing NETWORKMESSAGE_MAXSIZE to all kind of different values, did and redid the tutorial with clean sources/data folder/modules etc... several times, tested it on a different (clean) map to discard map bugs...


Found out that changing maxClientViewportY to 9 fixed it (x16, y9). Tryed to change to 8 but bugs started again. So I was wondering if maxClientViewportX/Y need to keep some ratio? Maybe this is the answer to some users having problems with this tutorial?
 
It would be better to actually change otland/forgottenserver (https://github.com/otland/forgottenserver/blob/bcb86eac0655c58b8dc9a35c652f8953a0edd033/src/monster.cpp#L83)

from
C:
return Creature::canSee(getPosition(), pos, 9, 9);
to
Code:
return Creature::canSee(getPosition(), pos, Map::maxViewportX, Map::maxViewportY);

so you don't conflict with otland/forgottenserver (https://github.com/otland/forgottenserver/blob/bcb86eac0655c58b8dc9a35c652f8953a0edd033/src/npc.cpp#L235)

Why exactly it conflicts? i haven't encountered any issues so far.. didn't knew npcs had can see too.. (thought creature is player/monster or npc)
 
I am using TFS 1.0 to the latest commit the OtClient.


I had to do this


and everywhere they were
Map::maxClientViewportX and Map::maxClientViewportY switched to Map::maxClientViewportX2 and Map::maxClientViewportY2

and in map.cpp



Thus apparently worked!
Worked for me as well!!, thanks a lot, I was figuring out the correct dimensions in order to avoid map loading bugs...
 
Sorry to relive the topic, however in some places the character hangs and only comes back if some ADM pull to another location. it's not an error on the map
 
Hi all im using Avesta 7.6 SVN 0.6.3 and im trying to add more tiles, I've compiled the sources with the new one codes making some changes about diferences between the codes, but I guess i made some mistakes because when I try to log in server crash and I dont get any error, just crash and bye.

I tryed all the solutions on this thread and nothing, If i share protocol file can someone help me??

thanks in advance!!
 
First thank you for this contribution but I'am facing a little issue the monster name appears when the monster is far from the screen with 4-5 Tiles
1567930705645.png
 
Honestly, the widescreen support is so damn amazing. I wish it could be set as a standard.. :(
You could just limit the range of runes so you cant shoot farther to east/west than north/south.
 
This is same thing as what's in the OP, just turned into diffs for my own sanity, in case I need to reference it later.


bool ProtocolGame::canSee(int32_t x, int32_t y, int32_t z) const
Diff:
-  if ((x >= myPos.getX() - 8 + offsetz) && (x <= myPos.getX() + 9 + offsetz) &&
-     (y >= myPos.getY() - 6 + offsetz) && (y <= myPos.getY() + 7 + offsetz)) {
+  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)) {


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


void ProtocolGame::sendMoveCreature(const Creature* creature, const Position& newPos, int32_t newStackPos, const Position& oldPos, int32_t oldStackPos, bool teleport)
Diff:
 if (oldPos.y > newPos.y) { // north, for old x
     msg.AddByte(0x65);
-    GetMapDescription(oldPos.x - 8, newPos.y - 6, newPos.z, 18, 1, msg);
+    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 - 8, newPos.y + 7, newPos.z, 18, 1, msg);
+    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 + 9, newPos.y - 6, newPos.z, 1, 14, msg);
+    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 - 8, newPos.y - 6, newPos.z, 1, 14, msg);
+    GetMapDescription(newPos.x - Map::maxClientViewportX, newPos.y - Map::maxClientViewportY, newPos.z, 1, (Map::maxClientViewportY+1)*2, msg);
 }


void ProtocolGame::MoveUpCreature(NetworkMessage& msg, const Creature* creature, const Position& newPos, const Position& oldPos)
Diff:
 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);
+    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);

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

Diff:
 //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);
+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 - 8, oldPos.y - 6, newPos.z, 18, 1, msg);
+GetMapDescription(oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z, (Map::maxClientViewportX+1)*2, 1, msg);


void ProtocolGame::MoveDownCreature(NetworkMessage& msg, const Creature* creature, const Position& newPos, const Position& oldPos)
Diff:
 //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);
+    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);

Diff:
 //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);
+    GetFloorDescription(msg, oldPos.x - Map::maxClientViewportX, oldPos.y - Map::maxClientViewportY, newPos.z + 2, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, -3, skip);

Diff:
 //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);
+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 - 8, oldPos.y + 7, newPos.z, 18, 1, msg);
+GetMapDescription(oldPos.x - Map::maxClientViewportX, oldPos.y + (Map::maxClientViewportY+1), newPos.z, ((Map::maxClientViewportX+1)*2), 1, msg);


0.3.6 only
Diff:
 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);
+  GetMapDescription(pos.x - Map::maxClientViewportX, pos.y - Map::maxClientViewportY, pos.z, (Map::maxClientViewportX+1)*2, (Map::maxClientViewportY+1)*2, msg);
 
i made it work creatures apear in battle, but mi client window still same size hmmm.
1589333649884.png
pretty sure im not configuring the ot client correctly
 

Attachments

Last edited:
i made it work creatures apear in battle, but mi client window still same size hmmm.
View attachment 45558
pretty sure im not configuring the ot client correctly
UPDATE:

Okay now its perfect size and zoom it works perfectly whit the server, but i want to know how to make it fully-streech, i attached mi gameinterface.lua in case someone want to help me.

No-fullscreen, game dosnt fully streech:
1589415250655.png
Fullscreen, dosnt fully streech:
1589415273434.png

Thank you.
 

Attachments

Back
Top