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

C++ Increase Z view underground

BahamutxD

Jack of all trades, master of none
Joined
Jun 8, 2009
Messages
922
Solutions
19
Reaction score
512
Location
Spain
Hello,

I was trying to increase the view limit from +- 2 levels while underground.

The changes I made were.

Server (tfs 1.3)

Under bool Creature::canSee(const Position& myPos, const Position& pos, int32_t viewRangeX, int32_t viewRangeY)

booth under protocolgame.cpp and creature.cpp

Code:
    } 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;
        }
    }

to

Code:
    } else if (myPos.z >= 8) {
        //we are underground (8 -> 15)
        //view is +/- 2 from the floor we stand on
        if (Position::getDistanceZ(myPos, pos) > 4) {
            return false;
        }
    }

And in OTClient (latest)

In const.h

Code:
AWARE_UNDEGROUND_FLOOR_RANGE = 2,

to

Code:
AWARE_UNDEGROUND_FLOOR_RANGE = 4,

The thing works, can see +- floors (or so it seems) but the character movement bugs/desyncs just while being underground.

Any idea on what could be wrong or missing?
 
Last edited:
Solution
From the changes you provide you don't change critical part of server which send mapdata to client.
Protocolgame.cpp:
In:
Code:
void ProtocolGame::GetMapDescription(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height, NetworkMessage& msg)
Change:
Code:
if (z > 7) {
startz = z - 2;
endz = std::min<int32_t>(MAP_MAX_LAYERS - 1, z + 2);
zstep = 1;
}
To:
Code:
if (z > 7) {
startz = z - 4;
endz = std::min<int32_t>(MAP_MAX_LAYERS - 1, z + 4);
zstep = 1;
}
If you don't change this part you of course get desynchronized because client will try to get more data than actually server send.
Hello,

I was trying to increase the view limit from +- 2 levels while underground.

The changes I made were.

Server (tfs 1.3)

Under bool Creature::canSee(const Position& myPos, const Position& pos, int32_t viewRangeX, int32_t viewRangeY)

booth under protocolgame.cpp and creature.cpp

Code:
    } 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;
        }
    }

to

Code:
    } else if (myPos.z >= 8) {
        //we are underground (8 -> 15)
        //view is +/- 2 from the floor we stand on
        if (Position::getDistanceZ(myPos, pos) > 4) {
            return false;
        }
    }

And in OTClient (latest)

In const.h

Code:
AWARE_UNDEGROUND_FLOOR_RANGE = 2,

to

Code:
AWARE_UNDEGROUND_FLOOR_RANGE = 4,

The thing works, can see +- floors (or so it seems) but the character movement bugs/desyncs just while being underground.

Any idea on what could be wrong or missing?
Would love to do this as well. Any progress on getting it to work correctly?
 
Would love to do this as well. Any progress on getting it to work correctly?

No sorry, haven't worked much on it since that day.

Tryed many things but couldn't fix the unsync problems if I ever go back to this / fix it will post solution.
 
From the changes you provide you don't change critical part of server which send mapdata to client.
Protocolgame.cpp:
In:
Code:
void ProtocolGame::GetMapDescription(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height, NetworkMessage& msg)
Change:
Code:
if (z > 7) {
startz = z - 2;
endz = std::min<int32_t>(MAP_MAX_LAYERS - 1, z + 2);
zstep = 1;
}
To:
Code:
if (z > 7) {
startz = z - 4;
endz = std::min<int32_t>(MAP_MAX_LAYERS - 1, z + 4);
zstep = 1;
}
If you don't change this part you of course get desynchronized because client will try to get more data than actually server send.
 
Solution
From the changes you provide you don't change critical part of server which send mapdata to client.
Protocolgame.cpp:
In:
Code:
void ProtocolGame::GetMapDescription(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height, NetworkMessage& msg)
Change:
Code:
if (z > 7) {
startz = z - 2;
endz = std::min<int32_t>(MAP_MAX_LAYERS - 1, z + 2);
zstep = 1;
}
To:
Code:
if (z > 7) {
startz = z - 4;
endz = std::min<int32_t>(MAP_MAX_LAYERS - 1, z + 4);
zstep = 1;
}
If you don't change this part you of course get desynchronized because client will try to get more data than actually server send.
Works fine for me now. Thanks dude!
 
Thanks for the solution

H1vg7MF.jpg
 
Back
Top