Skip to content

Fixed the issue where you had to warp to the collapse point every time you logged in in space. #323

Open
jionychiow wants to merge 10 commits intoEvEmu-Project:masterfrom
jionychiow:master
Open

Fixed the issue where you had to warp to the collapse point every time you logged in in space. #323
jionychiow wants to merge 10 commits intoEvEmu-Project:masterfrom
jionychiow:master

Conversation

@jionychiow
Copy link
Copy Markdown

@jionychiow jionychiow commented Jan 1, 2026

Save coordinates when logging out: In WarpOut(), get the current precise coordinates of the ship, and then call m_ship->SaveShip() to save them to the database.

Database saving mechanism: SaveShip() calls ItemDB::SaveItem(), which saves the coordinates (x, y, z) of the ship to the corresponding fields of the entity table.
Restore on next login: When the character logs in next time, the system will read the saved coordinates of the ship from the database instead of using the default point or random point.

Summary by Sourcery

Persist ship position on logout and use it to avoid unnecessary login warp when the ship is already near its saved location.

Enhancements:

  • Introduce a shared SaveLocationData helper to persist ship position, custom info, and offline state in a single place.
  • Adjust login warp logic to compare current and saved positions and skip warp when within a small distance threshold.
  • Use the ship's actual saved position instead of a random point as the login warp target and improve bubble/state handling when no warp is needed.
  • Guard ship logout calls to avoid null dereferences and add character location updates on logout for valid solar systems.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jan 1, 2026

Reviewer's Guide

Adds proper saving and restoring of precise ship coordinates on logout/login, refactors location persistence into a shared helper, and conditions login warp so players don’t get warped if they are already near their saved position.

Sequence diagram for logout/login ship position saving and conditional login warp

sequenceDiagram
    actor Player
    participant Client
    participant Ship
    participant ShipSE
    participant ItemDB

    rect rgb(230,230,250)
        Player->>Client: Request_logout
        Client->>Client: WarpOut()
        Client->>Client: SaveLocationData("Logout")
        alt ShipSE_available
            Client->>ShipSE: GetPosition()
            ShipSE-->>Client: GPoint
            Client->>Ship: SetPosition(GPoint)
        else ShipSE_null
            Client->>Ship: Use_current_ship_position
        end
        Client->>Ship: SaveShip()
        Ship->>ItemDB: SaveItem(x,y,z)
        ItemDB-->>Ship: Save_success
    end

    rect rgb(230,255,230)
        Player->>Client: Login_and_select_character
        Client->>Ship: position()
        Ship-->>Client: GPoint
        Client->>Client: Set m_loginWarpPoint
        Client->>Client: Set m_loginWarpRandomPoint_to_saved_position
        Client->>Client: MoveToLocation(locationID, m_loginWarpRandomPoint)

        Client->>Client: WarpIn()
        Client->>Client: UpdateBubble()
        Client->>Client: Compute_distance = |position - m_loginWarpPoint|
        alt distance > LOGIN_WARP_DISTANCE_THRESHOLD
            Client->>Client: SetStateTimer(0)
            Client->>Client: m_clientState = LoginWarp
        else distance <= LOGIN_WARP_DISTANCE_THRESHOLD
            Client->>Client: m_clientState = Idle
            Client->>Client: Clear m_loginWarpPoint and m_loginWarpRandomPoint
            Client->>Client: GetShipSE()
            Client-->>ShipSE: reference
            Client->>ShipSE: DestinyMgr().Stop()
            Client->>ShipSE: DestinyMgr().UnCloak()
            Client->>ShipSE: SysBubble().GetEntity(shipID)
            alt Ship_not_in_bubble
                Client->>ShipSE: SysBubble().Add(ShipSE)
            end
            Client->>ShipSE: SysBubble().SendAddBalls(ShipSE)
            Client->>Client: SetStateSent(false)
            Client->>ShipSE: DestinyMgr().SendSetState()
        end
    end
Loading

Class diagram for updated Client ship location and warp logic

classDiagram
    class Client {
        +double LOGIN_WARP_DISTANCE_THRESHOLD
        +GPoint m_loginWarpPoint
        +GPoint m_loginWarpRandomPoint
        +uint32 m_locationID
        +SystemData m_systemData
        +shared_ptr~Ship~ m_ship
        +ShipSE* pShipSE
        +void WarpIn()
        +void WarpOut()
        +void SaveLocationData(const char* customInfoPrefix)
        +bool SelectCharacter(int32 charID)
        +void MoveToLocation(uint32 location, const GPoint& pt)
        +void UpdateBubble()
        +void SetStateTimer(uint32 ms)
        +void SetStateSent(bool sent)
        +ShipSE* GetShipSE()
    }

    class Ship {
        +uint32 itemID
        +GPoint position
        +void SetPosition(GPoint pos)
        +GPoint position()
        +void SaveShip()
        +void SetCustomInfo(const char* info)
        +void SetFlag(uint32 flag)
    }

    class ShipSE {
        +uint32 GetID()
        +GPoint GetPosition()
        +DestinyMgr* DestinyMgr()
        +SysBubble* SysBubble()
    }

    class DestinyMgr {
        +void Stop()
        +void UnCloak()
        +void SendSetState()
    }

    class SysBubble {
        +Entity* GetEntity(uint32 id)
        +void Add(ShipSE* se)
        +void SendAddBalls(ShipSE* se)
    }

    class ItemDB {
        +void SaveItem(uint32 itemID, double x, double y, double z)
    }

    Client --> Ship : owns
    Client --> ShipSE : uses
    ShipSE --> DestinyMgr : uses
    ShipSE --> SysBubble : uses
    Ship ..> ItemDB : SaveShip() calls SaveItem()
    SysBubble --> ShipSE : manages
Loading

File-Level Changes

Change Details Files
Condition login warp-in on distance between current and saved ship position to avoid unnecessary warps.
  • Introduce LOGIN_WARP_DISTANCE_THRESHOLD constant to define when a login warp is needed
  • In WarpIn(), compare current ship position with m_loginWarpPoint and only set client state to LoginWarp when distance exceeds the threshold
  • If already at the saved position, set client state to Idle, clear login warp points, and ensure the ship is properly added to the bubble and its state is sent to the client
src/eve-server/Client.cpp
Use saved ship position directly on login instead of randomizing a new warp-in point.
  • Initialize m_loginWarpRandomPoint from the ship’s current/saved position instead of randomizing a point on a sphere
  • Move the client to the stored location with MoveToLocation using this precise point
src/eve-server/Client.cpp
Centralize saving of ship location and related custom info into a reusable helper used on logout/warp-out.
  • Add Client::SaveLocationData() to capture ship position from the ship entity if available, log it, update the ship object, and persist it via SaveShip()
  • Within SaveLocationData(), optionally set custom info and offline flag based on a provided prefix and pod status
src/eve-server/Client.cpp
src/eve-server/Client.h
Update logout flow to persist character and ship location safely and avoid duplicate or unsafe operations.
  • In Client destructor, when logging out, update character location when the current location is a solar system using SetLocation
  • Guard m_ship->LogOut() with a null check and clarify via comments that position is already saved by WarpOut/SaveLocationData
  • Refactor WarpOut() to call SaveLocationData("Logout") instead of duplicating position/custom-info logic and only destroy the ship entity if both pShipSE and m_ship are valid
src/eve-server/Client.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@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 - I've left some high level feedback:

  • In SaveLocationData, pShipSE is used without being passed in or clearly initialized within the function, which makes the helper brittle and hard to reason about; consider passing the ship entity explicitly or retrieving it inside the function in a well-defined way instead of relying on an external pointer.
  • The new SaveLocationData helper both updates ship position and sets logout-related flags/custom info; if you intend to reuse this method in non-logout flows, consider separating pure position persistence from logout/offline flag handling to avoid unintended side effects in future callers.
  • In WarpIn, when skipping the login warp you call both SysBubble()->Add(se) and SysBubble()->SendAddBalls(se); if Add already triggers the broadcast, this may result in duplicate add-ball notifications, so it might be worth confirming and consolidating to a single code path for adding and broadcasting.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `SaveLocationData`, `pShipSE` is used without being passed in or clearly initialized within the function, which makes the helper brittle and hard to reason about; consider passing the ship entity explicitly or retrieving it inside the function in a well-defined way instead of relying on an external pointer.
- The new `SaveLocationData` helper both updates ship position and sets logout-related flags/custom info; if you intend to reuse this method in non-logout flows, consider separating pure position persistence from logout/offline flag handling to avoid unintended side effects in future callers.
- In `WarpIn`, when skipping the login warp you call both `SysBubble()->Add(se)` and `SysBubble()->SendAddBalls(se)`; if `Add` already triggers the broadcast, this may result in duplicate add-ball notifications, so it might be worth confirming and consolidating to a single code path for adding and broadcasting.

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 and I'll use the feedback to improve your reviews.

File: src/eve-server/Client.cpp
- Problem: The server mistakenly set the "structureid" field when the player docked at the traditional space station, causing the client to think the player was inside the structure rather than the traditional space station.
- Fix: Replace pSession->SetInt("structureid", stationID) with pSession->Clear("structureid") (twice)
### 2. Missing Method in StructureDirectoryService
File:
- src/eve-server/structuredirectory/StructureDirectoryService.h
- src/eve-server/structuredirectory/StructureDirectoryService.cpp
- Issue: The client called the GetStructuresInSystem and GetStructureMapData methods, but the server did not implement them.
- Fix: Added the declaration and implementation of the GetStructuresInSystem and GetStructureMapData methods, and returned an empty list.
### 3. Incorrect Return Format of AchievementTrackerMgrService
File: src/eve-server/achievementtracker/AchievementTrackerMgrService.cpp
- Problem: Returning an empty dictionary causes a KeyError on the client side.
- Fix: Modified to return a dictionary structure containing completedDict and eventDict.
- Problem: The GetMySkillHandler returns a tuple (RemoteObject, None), but the client expects to directly obtain the RemoteObject.
- Fix: Modified to directly return the bound object instead of calling MachoBindObject.
### 5. LSCProxyService JoinChannels Returns None
File: src/eve-server/lscproxy/LSCProxyService.cpp
- Question: JoinChannels returns None, causing a TypeError in the client.
- Fix: Modified to return an empty list instead.
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.

1 participant