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

Fix: Position missing update and LandblockId db object fix #243

Merged
merged 3 commits into from
Apr 18, 2017

Conversation

fantoms
Copy link
Contributor

@fantoms fantoms commented Apr 16, 2017

This code was created to address issue #242.

-Fixed bugs in LandblockId in position and server now resets the position if missing.
-Added checks to prevent a missing location from crashing the server.
-Removed unnecessary lastportal recall position save, this is set on demand, this also prevents invalid data from entering the database.

Please give this a test by deleting a previously created character's position location (position type 1) and then try logging in, you should be at the current starting dungeon.

{
// load the default position
Position newCharacterPosition = CharacterPositionExtensions.StartingPosition(character.Id);
Position newRecallPosition = CharacterPositionExtensions.InvalidPosition(character.Id, PositionType.LastPortal);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be set on demand in the future, when the character uses a portal.

@@ -97,8 +107,7 @@ public Position InFrontOf(double distanceInFront = 3.0f)

public Position(uint characterId, PositionType type, uint newCell, float newPositionX, float newPositionY, float newPositionZ, float newRotationX, float newRotationY, float newRotationZ, float newRotationW)
{
LandblockId = new LandblockId(Cell);

LandblockId = new LandblockId(newCell);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug fix: this was saving the previous value as the LandblockId.

@@ -277,8 +277,28 @@ public bool IsNameAvailable(string name)

// Loads the positions into the player object and resets the landlock id
LoadCharacterPositions(c);
c.Location = c.Positions[PositionType.Location];
c.Location.LandblockId = new LandblockId(c.Location.Cell);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line is no longer necessary to set LandblockId, as the position's LandblockId should now be set when changing the Cell or LandblockId of the Position.

else if (c.Positions.ContainsKey(PositionType.Sanctuary))
c.Location = c.Positions[PositionType.Sanctuary];

// Check to see if the database position is valid
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fully see that this is unnecessary, but prevents an imaginary scenario where the position has become 0 for xyz coordinates and the landblock is invalid. This may happen if someone uses the reset-pos command to set location as an invalid position.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do X/Y/Z really matter? Just seems like unnecessary overhead. Will also likely cause problems in dungeons that go outside the bounds of "normal" X/Y/Z values of the open world.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only real case this check prevents is in where someone has used @reset-pos 1 and their location has become invalid.

I will remove this check and the database debugging command as well, too try and prevent attempt at preventing invalid locations.

fantoms added a commit to fantoms/ACE that referenced this pull request Apr 17, 2017
{
get
{
return new LandblockId(Cell);
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't feel helpful. Essentially re-allocating a new LandblockId every time it is accessed. I agree the section below in the constructor was a bug, but I don't see the bug in this part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do see how creating a new object every time will be inefficient, so I will work to create private accessed variable, instead.

else if (c.Positions.ContainsKey(PositionType.Sanctuary))
c.Location = c.Positions[PositionType.Sanctuary];

// Check to see if the database position is valid
Copy link
Contributor

Choose a reason for hiding this comment

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

Do X/Y/Z really matter? Just seems like unnecessary overhead. Will also likely cause problems in dungeons that go outside the bounds of "normal" X/Y/Z values of the open world.

@fantoms fantoms force-pushed the fix-PosisitionMissing branch 3 times, most recently from 7fafda5 to cef5fb3 Compare April 17, 2017 22:53
…ic to

character database, converted getpositions to dictionary.

* Updated comments and variable name, attempting too avoid confusion
@fantoms
Copy link
Contributor Author

fantoms commented Apr 18, 2017

I've made changes to each of the commented sections - the code is now ready for another review.

@Mogwai-TheFurry Mogwai-TheFurry merged commit 7198ccb into ACEmulator:master Apr 18, 2017
@fantoms fantoms mentioned this pull request Apr 21, 2017
@fantoms fantoms deleted the fix-PosisitionMissing branch May 23, 2017 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants