-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Move player movement code into Player class #7220
Conversation
src/network/serverpackethandler.cpp
Outdated
player->control.sneak = (keyPressed & 64); | ||
player->control.LMB = (keyPressed & 128); | ||
player->control.RMB = (keyPressed & 256); | ||
player->m_control.up = (keyPressed & 1); |
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.
m_*
class member variables are supposed to be private
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.
Oh, that explains why it didn't have the m_
before – I could change it back (it's just confusing with the step
and move
parameters), or remove the const
from the (pre-existing) accessor?
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.
Since it has multiple variables .. -> key_controls
?
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.
Technically it's keys, mouse, and joystick 😉
I'll try it with a private member and a non-const accessor-by-reference, sec…
d8f5760
to
6e7831f
Compare
5e519e7
to
5b8b873
Compare
Yes good :] |
I am not sure how making the game unplayable for many people can be a good thing. IMO it just makes them more likely to use unofficial clients. |
I agree, the current code is a nasty hardcoded hack though, it's good that it goes but it certainly needs a replacement. However, a per-player optional stepheight of 1.1 (either chosen by server or server allows each player to choose) is already possible using player object properties, it could be lua code added to builtin or done another way. I won't let 0.5.0 go out without autojump. The issue for this is #6183 |
@stujones11 : please take a look at PR #7228 as a suggestion for replacing the Android step height hack. |
7cd4c0c
to
db796a8
Compare
I've reenabled the Android step height hack! 😱 There's another PR, #7228 , which replaces the step height hack with a real autojump. Originally, the plan was to merge that one, then this (and then adjust the original server side movement, #6219 , and then start on my actual plans for player movement). But then I might as well just not touch the step height hack here, so that this PR can be merged immediately without any change in behaviour. |
db796a8
to
273ba7d
Compare
Rebased again, mainly incorporating changes from #7243 . Could you please reconsider the "WIP" label? I consider this PR finished and mergeable, even if it does not directly add a feature or fix a bug. |
273ba7d
to
f96195c
Compare
src/player.h
Outdated
{} | ||
void step(float dtime, const PlayerControl &control, | ||
const PlayerSettings &player_settings, Environment *env, | ||
std::vector<CollisionInfo> *player_collisions = NULL); |
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.
The code doesn't seem to account for player_collisions == NULL
at all, why does it default to this?
also: should be nullptr
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.
Not sure, I'll need to check.
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.
Got it: the Player::step
function does not care about the CollisionInfo
, but this is used as a parameter when calling Player::move
. This function does account for a null pointer.
Please keep in mind that all this PR is trying to do is lift the existing code and algorithms from LocalPlayer
to Player
. So answering for, or even changing, the existing movement code and call chain is outside of the scope of this PR.
f96195c
to
5633391
Compare
Oops; I just noticed several requested changes – sorry, @sfan5 , I must have missed the notifications :-( I'll get on these over the next few days, I hope. |
5633391
to
ded2688
Compare
This allows running the same code on the server, for example for server-side movement checks.
ded2688
to
6bc2437
Compare
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 don't remember if I'd tested this at the time of my last review, code looks good to me either way.
rebase needed |
Bump for review attention, this is a high priority issue as it leads to #6219 |
What should I expect while testing this? There should be no difference in test results whatsoever, right? |
@@ -406,7 +406,8 @@ void Client::step(float dtime) | |||
// Control local player (0ms) | |||
LocalPlayer *player = m_env.getLocalPlayer(); | |||
assert(player); | |||
player->applyControl(dtime, &m_env); | |||
player->applyControl(dtime, player->getPlayerControl(), |
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.
why we pass already owned objects to the player class ?
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.
It's been a while, but some of these things are because the same code (the same methods) need to be called on the server and the client side, where different things are available.
Or it really is unnecessary, but I'll need to get into the code again first.
Hi, sorry, I had just about abandoned this PR; it's a deep change for no visible benefit, after all. No, there should be no changes in tests or behaviour (that I'm aware of). As a reminder, the goal of this PR is just to make the player movement code available to the server, so that some kind of server-side movement check or replay can be developed. My first attempt was all in one branch, which got out of hand as other work was done on the movement code. Rebasing will take some time, I fear, but I'll pick it up again. Maintainers can edit, or anyone else can just grab the code and run with it, it's all good. |
I'd like to see indication of potential approval from a second core dev before you are required to rebase. |
Thought so, but just wanted to confirm. I've tested this PR, and I did not notice any oddities or glitches. I ran around and flew around for around 5 minutes each, and didn't encounter any issues. I guess this PR works. :) 👍 |
0e3b135
to
39c54e1
Compare
This is necessary for #6219 @bendeutsch i seem to have marked all your PRs as 'adoption needed' but cannot remember why, is it the case that you are not interested in working on them? (which is fine by the way). |
@bendeutsch Please work on this, it has one approval and would be a very nice addition |
This allows running the same code on the server, for example for server-side movement checks.
This set of changes is actually a large part of pull request #6219 , "server side movement". But this pull request does not contain any of the network code or server-side checking or reconciliation. All it does is move the main movement methods from
LocalPlayer
toPlayer
(and thusRemotePlayer
), without changing any functionality.There are just two points that are not "pure" in this sense:
control
has been changed tom_control
, to avoid overshadowing by a function parameter of this name