Skip to content
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

Core/RestState: Check area trigger radius instead of wrong 1.0f. #15052

Closed
wants to merge 1 commit into from
Closed

Conversation

robinsch
Copy link
Contributor

Will fix #15016.

@@ -7424,7 +7426,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
if (GetRestType() == REST_TYPE_IN_TAVERN) // Still inside a tavern or has recently left
{
// Remove rest state if we have recently left a tavern.
if (GetMapId() != GetInnPosMapId() || GetExactDist(GetInnPosX(), GetInnPosY(), GetInnPosZ()) > 1.0f)
if (GetMapId() != GetInnPosMapId() || GetExactDist(GetInnPosX(), GetInnPosY(), GetInnPosZ()) > (GetInnPosRadius() ? GetInnPosRadius() : 1.0f))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't try to convert a float to bool, use G3D::fuzzyEq() or similar to compare float

@Rochet2
Copy link
Contributor

Rochet2 commented Jul 11, 2015

This ignores the areatrigger box though if those are used for inns.

I would suggest this kind of fix https://gist.github.com/Rochet2/541bfecca1bfaa3b396d
It is not tested and doesnt work properly yet though due to timing with when the resting is checked upon leaving.

@robinsch
Copy link
Contributor Author

Yes there are a few.
Do you want to open a PR or should I change my PR and make you the author of the commit?

@Rochet2
Copy link
Contributor

Rochet2 commented Jul 11, 2015

The code really needs fixing the exploit mentioned earlier or something to make the update tick when the player goes outside of the inn.
Currently its all depending on the client sent data and even then if the delta is removed even, you can slowly walk and not lose the resting bonus.

You can basically just walk out slowly or not send the zone update to avoid both fixes.
The codes are good, but need something to trigger them when player actually leaves the inns and whatnot.

@robinsch
Copy link
Contributor Author

I think I already said it in previous PR, TC1 just calls UpdateZone on movementpackets. We could simply remove m_needsZoneUpdate, but performance wise this is not a good idea.

@jackpoz
Copy link
Contributor

jackpoz commented Jul 11, 2015

if the exploit exists in current code, it's ok to focus just on fixing the chair thing in this PR

@@ -1193,6 +1193,35 @@ bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const
return IsWithinLOS(ox, oy, oz);
}

bool WorldObject::IsWithinBox(const Position& center, float xradius, float yradius, float zradius) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this method does not access any WorldObject members you can move it to Position class

@robinsch
Copy link
Contributor Author

Used code from @Rochet2. Somehow if I squash commits the author is removed. 👎

@Rochet2
Copy link
Contributor

Rochet2 commented Jul 11, 2015

Well, if the current code is used, no one leaving the inn will have their rested removed.
If the current code without the additional delta (5 yard addition) is used, you can try to move really slow out of the inn and you will walk out with the rested bonus as well.

The old code worked so that almost always you are out of range with the 1.0f checking, but if it is corrected, the delays between client and server make it glitch more as you can just go out of the inn with the inn buff even when not hacking.

One of the few proper fixes that would fix the problems and the exploit would be to keep a timed event for the players with rested bonus of an inn triggered by an area trigger that would check if they are still in the inn.
But that would create additional overhead compared to how it works atm.

@Rochet2
Copy link
Contributor

Rochet2 commented Jul 11, 2015

Here is the proper edit that fixes both the exploit and the issue at hand.
But Im unsure if the timed checking is fine for you.
https://gist.github.com/Rochet2/541bfecca1bfaa3b396d
also moved the method shauren commented about to position class in this diff. (the current refactor in this PR is bad)

@ghost
Copy link

ghost commented Jul 12, 2015

@robinsch : to set Rochet2 as author, checkout your at branch, then open a git bash window & run:

git commit --amend --author="Rochet2 <rochet2@post.com>"

This will open the vi editor with the author info inserted. Use the command :w to save, :q to quit.
Exit git bash. In Git Extensions, open the commit window, tick [√] Amend commit, do commit + force push.

double sinVal = std::sin(rotation);
double cosVal = std::cos(rotation);

float BoxDistX = GetPositionX() - GetPositionX();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not make sense

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactor was bad.
Read #15052 (comment)
which contains the link to the code it should look like.
PR needs update.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see it. Inserted 31 lines too far down, should be between line 99 and 100 instead of 130-131.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see it. Inserted 31 lines too far down, should be between line 99 and 100 instead of 130-131.

I dont think the actual position matters that much .. unlike the correctness of the actual code.

@Rochet2
Copy link
Contributor

Rochet2 commented Jul 14, 2015

👍 Didnt even notice this was updated

@jackpoz
Copy link
Contributor

jackpoz commented Aug 10, 2015

is this PR ready to be merged ? both the exploits and the bugs are fixed ?

@Rochet2
Copy link
Contributor

Rochet2 commented Aug 10, 2015

is this PR ready to be merged ? both the exploits and the bugs are fixed ?

It is not!
The PR is like the code here

Here is the proper edit that fixes both the exploit and the issue at hand.
But Im unsure if the timed checking is fine for you.
https://gist.github.com/Rochet2/541bfecca1bfaa3b396d

But after a closer look its missing this vital part: https://gist.github.com/Rochet2/541bfecca1bfaa3b396d#file-innsfix-diff-L73-L83
And Im not sure how you would prefer to handle that.

I tested the code in the gist and as said it fixes both exploits. Exploits being players able to walk out slowly and the relying on client sent data. The exploits are fixed by the code in player::update function. It also fixes the original issue ofcourse.

However the PR does not resolve the issue of using client sent data for any other piece of code than inn resting.
Here is the comment I originally made about that zoneupdate exploit that uses client data:
#15041 (comment)

The exploit I mentioned comes from the fact that client data is relied on.
If the client does not send CMSG_ZONEUPDATE opcode, he can keep the resting status outside of an inn and walk around as long as he wont change the area (EG he can keep it anywhere in ewlynn fores as long as he got it from goldshire (within ewlynn)). Changing area or zone doesnt matter.

Probably should create a separate issue for that exploit as it doesnt consern the inns anymore after this PR, but I have no other known things it could affect atm.

@robinsch
Copy link
Contributor Author

Exploit was also possible before so I think it's fine to merge.

@jackpoz
Copy link
Contributor

jackpoz commented Aug 10, 2015

@Rochet2 so it makes more sense to close this PR and open on with your diff

Rochet2 added a commit to Rochet2/TrinityCore that referenced this pull request Aug 10, 2015
@jackpoz jackpoz closed this Aug 10, 2015
jackpoz pushed a commit to jackpoz/TrinityCore that referenced this pull request Aug 10, 2015
Carbenium pushed a commit that referenced this pull request Sep 24, 2015
Closes #15016
Closes #15052

Signed-off-by: jackpoz <giacomopoz@gmail.com>
(cherry picked from commit 12931f4)

Conflicts:
	src/server/game/Entities/Player/Player.h
	src/server/game/Handlers/MiscHandler.cpp
@ghost
Copy link

ghost commented Sep 26, 2015

I wonder what is wrong with the goldshire lion's inn area trigger. even with that commit it doesn't seem to add the resting state. the trigger itself is also very far under the ground so dunno if the trigger there is even triggered or so.

@Rochet2
Copy link
Contributor

Rochet2 commented Sep 26, 2015

I wonder what is wrong with the goldshire lion's inn area trigger. even with that commit it doesn't seem to add the resting state. the trigger itself is also very far under the ground so dunno if the trigger there is even triggered or so.

Can not reproduce on facb656. Have you made any edits to the areatrigger or smart scripts tables?
What TC version do you have? Can you be more specific about the conditions you are testing with? (race or character etc)
http://prntscr.com/8knuqr

@ghost
Copy link

ghost commented Sep 26, 2015

nvm. forgot to change the worldserver after the compile. seems to be fine

@ghost
Copy link

ghost commented Sep 26, 2015

BUT I found another issue. If you stand on the wooden parts of the Inn the rest state is there but when you walk down on the brick floor there near the cozy fire the rest state disappears

@Rochet2
Copy link
Contributor

Rochet2 commented Sep 27, 2015

If you stand on the wooden parts of the Inn the rest state is there but when you walk down on the brick floor there near the cozy fire the rest state disappears

Can not reproduce on facb656.
However I walked through the whole house and around it and since the areatrigger seems to be round and the house is a rectangle if watched from above, the rest state is active if you are outside: http://prntscr.com/8kyd00 and it is not active if you are at the furthest corner of the building: http://prntscr.com/8kydfq
Dont know how it behaved/behaves on retail though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants