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

Implement login warp-in and improve translocate commands #294

Merged

Conversation

charles-m-knox
Copy link

@charles-m-knox charles-m-knox commented Sep 17, 2024

This pull request brings in the following changes:

  1. An implementation of login warp-in from 0.5 AU
  2. Improvements to the translocate command (menus in space now work for belts/planets/etc)

Details about the first change: Login warp-in

I tried to leave good comments in the code to describe everything that went into this, but I'll provide a bit of an explanation here as well.

Currently (before this PR), the behavior on in-space login that I see is that the universe is just a black void, or sometimes is an unpopulated and inaccessible solar system.

I was able to verify that the client is actually just out of sync with the server - you can actually just call /sendstate right after you log in, and the client is now synchronized with the server and you can do regular things.

/sendstate essentially uses UpdateBubble() to synchronize the client & server. I used this logic as the foundation for fixing the login warp functionality.

As explained in the code, the new login warp cloaks and moves the player to a position 0.5 AU away from their last logout position. UpdateBubble() is called so that a bubble is created before the player's upcoming warp vector gets established.

The client's state is set to Login and, on the next server tick, the actual Destiny WarpTo method gets called, they're uncloaked, and many Beyonce player commands are restricted until the warp is completed. This prevents the user from aborting the warp preemptively, which is consistent with expected behavior.

Finally, once the warp completes, the player's LoginWarp state is cleared out and they can use their ship again.

To test this out, simply:

  • log out in space and verify that you spawn 0.5 AU away from your previous point, cloaked.
  • try frantically to move in a direction, stop the ship, warp, dock, etc while establishing the login warp vector and confirm you do not succeed.
  • log out when docked and confirm that you are still docked when you log back in.

Known issues:

The only expected issue I ran into at this time is that sometimes the player's position isn't preserved on log out, so you might end up 0.5 AU away from 0.5 AU away from your original point. This is out of scope for this pull request, because the logout code isn't fully fleshed out, and it's probably related to that.


Details about the second change: Translocate improvements

I found that when translocating via the solar system menu to e.g. an asteroid belt or planet, the command failed due to an invalid lookup (the code isn't there yet).

To make it work, I implemented database queries against the mapDenormalize table to resolve celestials and use their spatial coordinates for translocation. It's not perfect - it will teleport you to the center of planets and moons (can be fixed later easily, I suspect) - but it's good enough for now. It also may not behave perfectly with existing translocation command permutations (fleet, other players, etc), but the number of testing permutations is significant enough such that I cannot realistically test them all.

I bundled in the translocation command fixes with the warp-on-login changes because if you translocate in the middle of a login warp bubble before it collapses, the "warp complete" event never triggers, and thus the newly added login warp state values are never reset - meaning you will never be able to do anything with your ship for the whole client session (probably). This is an edge case that can only ever happen due to a translocation command.

Another edge case: If you translocate to a solar system (typically doable from the star map), translocating to 0,0,0 was buggy, so instead I query for the celestial that has the smallest x value for simplicity.

To test this:

  • right click in space -> translocate to a belt, planet, moon, or other non-station celestial and verify that it works
  • same thing, but with a station
  • open the star map and translocate to a system. Confirm that you are translocated to the celestial that has the lowest x value and not the star.

Thanks for reading/reviewing!

Summary by Sourcery

Introduce a login warp-in feature that synchronizes the client and server upon player login, moving the player to a safe distance and restricting actions until warp completion. Enhance the translocate command to work with celestial objects by resolving their spatial coordinates, improving the overall user experience when navigating through space.

New Features:

  • Implement login warp-in functionality that moves players to a position 0.5 AU away from their last logout position, cloaked, and restricts certain actions until the warp is completed.

Enhancements:

  • Improve the translocate command to support menus in space for belts, planets, and other celestial objects by implementing database queries to resolve spatial coordinates.

Copy link

sourcery-ai bot commented Sep 17, 2024

Reviewer's Guide by Sourcery

This pull request implements login warp-in functionality and improves the translocate command. The login warp-in feature moves players to a position 0.5 AU away from their last logout position upon login, while the translocate improvements allow for teleportation to various celestial objects in the solar system.

File-Level Changes

Change Details Files
Implemented login warp-in functionality
  • Added new client state 'LoginWarp' to handle the login warp process
  • Created WarpIn() method to initiate the login warp
  • Implemented IsLoginWarping() and SetLoginWarpComplete() methods to manage the login warp state
  • Modified SelectCharacter() method to set up login warp parameters
  • Updated ProcessClient() to handle the LoginWarp state
  • Added checks in various ship movement commands to prevent actions during login warp
src/eve-server/Client.cpp
src/eve-server/Client.h
src/eve-server/system/DestinyManager.cpp
src/eve-server/system/DestinyManager.h
src/eve-server/ship/BeyonceService.cpp
src/eve-common/EVE_Player.h
Improved translocate command functionality
  • Added support for translocating to celestial objects like asteroid belts, planets, and moons
  • Implemented database queries to resolve celestial coordinates for translocation
  • Updated translocation logic to handle solar system translocation
  • Added error handling for invalid translocation targets
src/eve-server/admin/SystemCommands.cpp
Refactored and improved code structure
  • Created UpdateBubble() function to synchronize player position and ensure bubble existence
  • Moved common code to UpdateBubble() function for reusability
  • Added AbortIfLoginWarping() method to prevent actions during login warp
  • Updated various ship movement commands to use AbortIfLoginWarping()
src/eve-server/Client.cpp
src/eve-server/admin/SystemCommands.cpp
src/eve-server/system/DestinyManager.cpp
src/eve-server/system/DestinyManager.h
src/eve-server/ship/BeyonceService.cpp

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @charles-m-knox - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -50,6 +52,36 @@ PyResult Command_translocate(Client* pClient, CommandDB* db, EVEServiceManager &
return Command_tr(pClient,db,services,args);
}

// `UpdateBubble` is a reusable function that synchronizes the player's position
// and ensures that their bubble exists.
static PyResult UpdateBubble(Client *pClient) {
Copy link

Choose a reason for hiding this comment

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

suggestion: Evaluate the usage context of UpdateBubble

While the refactoring is good, consider if this function should be a member of the Client class instead of a static function in SystemCommands.cpp. This could improve encapsulation and make the code more maintainable.

PyResult Client::UpdateBubble() {
    if (!IsInSpace())
        throw CustomError("You're not in space.");

@jdhirst
Copy link
Contributor

jdhirst commented Sep 17, 2024

lgtm, love to see the work on Destiny! 🚀

@jdhirst jdhirst merged commit 3d61603 into EvEmu-Project:staging Sep 17, 2024
2 checks passed
@charles-m-knox charles-m-knox deleted the implement-login-warp-in branch September 17, 2024 05:26
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.

2 participants