-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Player set/get cannotMove #2553
Conversation
Please don’t use _variables. Also this is really bad, because if you freeze player and he will continously spam movement it will kick him, because he will exceed the packet per second limit. (Happens because of sendCancelWalk) |
@nekiro I've removed
and
if it's only function variable? Plus, what does this have to do with the connection limits if they apply only to packets sent by player not by server? Isn't the same situation when the player is standing at the door of the house to which he can not enter and keeps the arrow down while still receiving the message "You are not invited."? |
Did you check if that happens before you wrote message? I'm convinced it will. |
@nekiro Nope, but I removed |
src/creature.h
Outdated
@@ -408,6 +408,14 @@ class Creature : virtual public Thing | |||
void setUseDefense(bool useDefense) { | |||
canUseDefense = useDefense; | |||
} | |||
void setNoMove(bool canNotMove) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canNotMove
isn't correct, cannot
is a single word.
by the way, I can't find cannotMove
in creature.h like you said is there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant field bool cannotMove = false;
Anyway, I've changed again function naming. How would you rate changes now?
I'd call the variable |
Ok @ranisalt, I've changed to set/get, how would you rate changes now? |
LGTM, though I'd like to hear more from @nekiro point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would really like to see how it behaves in-game, could you make a gif spamming move, when you are set to cannot move?
src/creature.cpp
Outdated
@@ -249,6 +249,11 @@ bool Creature::getNextStep(Direction& dir, uint32_t&) | |||
|
|||
void Creature::startAutoWalk(const std::forward_list<Direction>& listDir) | |||
{ | |||
if (getPlayer() && !getPlayer()->getCanMove()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Player* player = getPlayer();
if (player && player->getCanMove()) {
same with sendCancelWalk
void setCanMove(bool move) | ||
{ | ||
canMove = move; | ||
cancelNextWalk = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we set canMove to true, do we still cancelNextWalk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I too was wondering about cancelNextWalk always being set to true in this function. What is the reason for the code not being this or similar
cancelNextWalk = true; | |
cancelNextWalk = !move; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still curious about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is to fix desync issues mid-action, this is called to toggle the states, but no matter which direction it toggles to, you dont want to give the user half a sqm headstart as it may create odd client behavior. So even if you just got permission to walk, the character pos gets a cancel byte one last time to set the timings straight. (I might be wrong though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Znote but if player is already movement blocked then he cannot walk, so what desynchro?
I've just tested it and indeed it kicks the player because of the maxPacketsPerSecond setting |
Should a player be exempt from maxPacketsPerSecond kick when they are not able to walk? |
No, that shouldnt be done fully server side in the first place. |
We can't really do it client-side, so are we merging it as-is or adding some workaround? |
closes #775 if merged |
Do we even need it? I dont think thats something that should be in tfs repo as its mainly client sided. |
Many servers still use the Cipsoft client to play, so due to the fact that it is quite difficult to edit, in my opinion it is easier to "block" it server-side. edit: @EPuncker I've checked, that keeping arrow pushed it spams packets exactly the same way when player tries to enter house where's not invited to. |
@DSpeichert Is there anything else I need to change in my request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at canMove
and setMove
, I think it would be better to use terms such as:
isMovementBlocked
: true/false
setMovementBlocked
: true/false
That, IMHO, is less ambiguous.
void setCanMove(bool move) | ||
{ | ||
canMove = move; | ||
cancelNextWalk = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still curious about this.
This comment was marked as abuse.
This comment was marked as abuse.
@DSpeichert @nekiro Can you look at it in free time? I've committed changes you requested. |
I hope we could get this merged soon, from time to time people are always requesting this function on the forum, other than the two minor code styling that I requested, everything else seems fine, I'm using this in my test server for some time already |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending patch to PR @rookgaard has to merge: (in his repo) rookgaard#1
void setCanMove(bool move) | ||
{ | ||
canMove = move; | ||
cancelNextWalk = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is to fix desync issues mid-action, this is called to toggle the states, but no matter which direction it toggles to, you dont want to give the user half a sqm headstart as it may create odd client behavior. So even if you just got permission to walk, the character pos gets a cancel byte one last time to set the timings straight. (I might be wrong though).
Code style formatting fixes
Absolutely, lots of people has requested this. I also remember being rather desperate for someone to make something like this back in the day when I was hosting servers. This has been a frustration solved by uglier hacks all the time over the past 10 years. |
Is there anything I can do more on this PR @DSpeichert ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me there is just a small request, the addition of the entries in compat.lua for it to be compatible with the old version:
getCreatureNoMove(cid)
doCreatureSetNoMove(cid, block)
@EPuncker I've added functions to |
Hello. I would like to present another nice functionality which went lost in 0.X series - possibility to freeze/unfreeze player. It's nice to have feature which can be used in many quests or systems like transport by wagons.
Fixes #775