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

Compiling C++ Player Walktrough player in pz ( ERROR )

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,249
Solutions
71
Reaction score
621
Location
Hell
TFS 0.4
REV: 3777
V: 8.6

I am trying to enable Player-walktrough-player in pz zone using my old modified function of "canWalkThrough". I did solve the problem before, but I can currently not remember how I did it since i haven't saved those files.
however the problem is (original post):
I was trying to fix player walktrough in pz, and it did work for a moment but i noticed a "bug".
First when two players are on screen, in pz, they can walk trough eachother just fine, except if one is standing on a depot-tile. However. When players go off screen (can't see eachother) and come back. They can't walk trough eachother. I asked cykotitan he mentioned that "sendCreatureImpassable" isn't called whenever necessary, and because of that the client is not able to determine if creature is walkable or not.

The solution that I had found was :
However; I've managed to solve this by calling ..
C++:
g_game.updateCreatureImpassable(this);
.. in player.cpp inside "onWalk","addExperience","removeExperience","canWalktrough"

I did the same. The only problem at the moment is that if i use g_game.updateCreatureImpassable(this); in canWalkThrough
I get the following error:

player.cpp:857:42: error: invalid conversion from ‘const Creature*’ to ‘Creature*’ [-fpermissive]

Why does it even think that (this) is a const Creature* obj ?
 
The error is saying you can't assign/pass a constant pointer to a non constant pointer.

const is a value that isn't meant to change by passing that value to a non-constant value you are running the risk of changing it and because it is a pointer it is likely to change.
 
The error is saying you can't assign/pass a constant pointer to a non constant pointer.

const is a value that isn't meant to change by passing that value to a non-constant value you are running the risk of changing it and because it is a pointer it is likely to change.

Thanks captain obvious, I am well aware of what const is. What I don't understand is why the Player object itself is counted as const Creature*. Doesn't this refer to the Player itself?

@Znote @Gesior.pl HAAAAAALP
 
Last edited:
What I don't understand is why the Player object itself is counted as const Creature*. Doesn't this refer to the Player itself?
"canWalkthrough" function is const function so "this" will be const, you don't want to change any data from object if the function is only to check some conditions right? Anyway using "g_game.updateCreatureImpassable(this); " inside "canWalkThrough" most likely will crash your server because update should check conditions from "canWalkThrough" which results in never ending loop so you will run out of stack memory.
You should consider using "g_game.updateCreatureImpassable(this);" only inside "addExperience", "removeExperience", "onChangeZone" in player.cpp or if you have other conditions to walk through players inside functions that have these conditions because something like "onWalk" will only make unnecessary spam(I know it's only 16 bajts of network but still there's xtea encryption which will take unnecessary resources when players move).
 
"canWalkthrough" function is const function so "this" will be const, you don't want to change any data from object if the function is only to check some conditions right? Anyway using "g_game.updateCreatureImpassable(this); " inside "canWalkThrough" most likely will crash your server because update should check conditions from "canWalkThrough" which results in never ending loop so you will run out of stack memory.
You should consider using "g_game.updateCreatureImpassable(this);" only inside "addExperience", "removeExperience", "onChangeZone" in player.cpp or if you have other conditions to walk through players inside functions that have these conditions because something like "onWalk" will only make unnecessary spam(I know it's only 16 bajts of network but still there's xtea encryption which will take unnecessary resources when players move).

That was helpful thank you :D

but there's another issue; Sometimes it lets me walk through players who stand on tile 11062 which I have added in the cpp function canWalkThrough.

EDIT: Let's say there's a player standing on tile width id 11062. The first time I am not allowed to walk through them. But if I push them off that tile and then when they get back on that tile. I can walk through them.

EDIT 2: It works now- that issue was because I forgot to add 11063 (when someone is on 11062)
 
Last edited:
Back
Top