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: fix 'magnetic furniture' bug #2340

Merged
merged 15 commits into from
Feb 14, 2025
Merged

fix: fix 'magnetic furniture' bug #2340

merged 15 commits into from
Feb 14, 2025

Conversation

Pospelove
Copy link
Contributor

@Pospelove Pospelove commented Feb 14, 2025

Important

Fixes 'magnetic furniture' bug by adding delay and disable event handling in remoteServer.ts, MpActor.cpp, and MpObjectReference.cpp.

  • Behavior:
    • Introduces delaySeconds in remoteServer.ts for handling furniture activation with a delay of 1.0 seconds.
    • Adds DisableEventSink to MpActor and MpObjectReference to handle disable events before disabling an actor or object.
  • Classes and Functions:
    • MpActor and MpObjectReference now have AddEventSink and RemoveEventSink for DisableEventSink.
    • MpActor::Disable() and MpObjectReference::Disable() now trigger BeforeDisable() on all registered DisableEventSink instances.
  • Misc:
    • Adds logging for delay in remoteServer.ts to trace activation message sending.

This description was created by Ellipsis for 07f9b88. It will automatically update as commits are pushed.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to ce03a4e in 1 minute and 39 seconds

More details
  • Looked at 27 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1568
  • Draft comment:
    Consider verifying that 'loader' is defined before use, and also check that base.rec is not nullptr before calling GetType(). This prevents potential crashes if LookupById returns a null record.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1568
  • Draft comment:
    The new FURN-specific condition (returning false) is a logical change—double-check that this behavior is intended when the object’s type is 'FURN' and the activator is an actor.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1605
  • Draft comment:
    Log messages refer to 'ProcessActivate' even though they are in CheckIfObjectCanStartOccupyThis. Consider using the correct function name for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None

Workflow ID: wflow_oeKDXWAq3nbWzSmh


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 23ad5c3 in 1 minute and 16 seconds

More details
  • Looked at 47 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1139
  • Draft comment:
    Enabling std::terminate() can be drastic. Confirm that aborting is desired in production.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 40% <= threshold 50%
    The comment is asking the PR author to confirm their intention regarding the use of std::terminate(). This violates the rule against asking for confirmation of intention. However, it does highlight a potentially significant issue with using std::terminate() in production, which could be useful for the author to consider. The comment could be rephrased to suggest considering the implications of using std::terminate() without directly asking for confirmation.
2. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1605
  • Draft comment:
    Log message formatting changed—ensure consistency and clarity remain.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
3. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1784
  • Draft comment:
    JSON initializer formatting modified; verify that the message format and concatenation are as intended.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1141
  • Draft comment:
    Ensure std::terminate() is the intended error handling here; abrupt termination may be too harsh. Consider if throwing an exception or a graceful shutdown is more appropriate.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
5. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1608
  • Draft comment:
    Verify that the revised spdlog message formatting meets the project’s style guidelines for consistent log output.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
6. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1788
  • Draft comment:
    The JSON construction for the inventory update has been reformatted. Confirm that the functional behavior remains unchanged.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None

Workflow ID: wflow_krVIg1UuwePXS4F2


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Skipped PR review on deea7dc because no changed files had a supported extension. If you think this was in error, please contact us and we'll fix it right away.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on a45548a in 38 seconds

More details
  • Looked at 18 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1787
  • Draft comment:
    Cosmetic JSON formatting adjustment in SendInventoryUpdate; no functional change.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1788
  • Draft comment:
    Good reformatting of the JSON initialization. Just ensure that concatenating Networking::MinPacketId with the JSON dump produces the intended message format.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None

Workflow ID: wflow_tC2h98oF67cVidGP


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@Pospelove Pospelove changed the title Update MpObjectReference.cpp fix: fix 'magnetic furniture' bug Feb 14, 2025
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on f8d75d8 in 1 minute and 2 seconds

More details
  • Looked at 31 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. skymp5-client/src/services/services/remoteServer.ts:189
  • Draft comment:
    Consider renaming 'onOpenContainerMesage' to 'onOpenContainerMessage' for consistency.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. skymp5-client/src/services/services/remoteServer.ts:217
  • Draft comment:
    Ensure that delaySeconds default (-1.0) is never used unintentionally; it's safe here, but adding a comment can prevent misuse in future modifications.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. skymp5-client/src/services/services/remoteServer.ts:187
  • Draft comment:
    Initializing delaySeconds to -1.0 may be confusing. Since it's always set in the if/else, consider initializing it to a neutral positive value or adding a comment explaining the negative default.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
4. skymp5-client/src/services/services/remoteServer.ts:223
  • Draft comment:
    The log message label 'onOpenContainerMesage' contains a typo. Consider correcting it to 'onOpenContainerMessage' for consistency.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None

Workflow ID: wflow_zbb9UKxwtV5RxYpG


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e0958af in 51 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. skymp5-client/src/services/services/remoteServer.ts:224
  • Draft comment:
    Consider using a template literal for the log message to ensure consistent spacing.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
2. skymp5-client/src/services/services/remoteServer.ts:224
  • Draft comment:
    Minor logging formatting adjustment. Note that 'onOpenContainerMesage' remains misspelled; consider renaming it to 'onOpenContainerMessage' for clarity.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_NzDoE0erXjgEPKb3


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on c9a7af0 in 44 seconds

More details
  • Looked at 18 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1838
  • Draft comment:
    Reformatted JSON initialization improves clarity; no logic change.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1838
  • Draft comment:
    The JSON initialization is reformatted for readability without changing logic. Please clarify in a comment how this change fixes the 'magnetic furniture' bug.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    The comment is asking for clarification on how a specific change fixes a bug. This is asking the PR author to explain their change, which violates the rule against asking for explanations or confirmations of intent. Therefore, this comment should not be approved.

Workflow ID: wflow_9nbNOAGNYYFLXyys


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 9676234 in 2 minutes and 30 seconds

More details
  • Looked at 232 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpActor.cpp:374
  • Draft comment:
    Good addition: calling BeforeDisable on all disable event sinks before disabling the actor helps resolve the magnetic furniture issue by ensuring proper cleanup of occupant references.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1500
  • Draft comment:
    Ensure that removal of both occupant destroy and disable sinks is handled consistently. The new disable logic seems to mirror the destroy sink, which is good for avoiding lingering occupant pointers (addressing magnetic furniture).
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
3. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1570
  • Draft comment:
    In ProcessActivateSecond for FURN type, only the destroy sink is removed. Consider also removing occupantDisableSink before resetting the occupant to ensure full cleanup and avoid stale event sinks that may cause 'magnetic furniture' behavior.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
4. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:113
  • Draft comment:
    Good addition of OccupantDisableEventSink. Ensure that in every state transition (activation, disable, destroy) both event sinks (destroy and disable) are removed to prevent lingering callbacks or memory leaks.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
5. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1350
  • Draft comment:
    ProcessActivateNormal is very complex with multiple type‐specific branches. Consider refactoring it into smaller helper functions (e.g. separate handlers for CONT, FURN, ACTI) to improve readability and maintainability.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1177
  • Draft comment:
    In ApplyChangeForm, calling std::terminate() when setProperty has been invoked is rather drastic. Consider a more graceful error handling or clearer messaging to avoid unexpected termination in production.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:1762
  • Draft comment:
    The hardcoded filtering of non-SweetPie scripts in InitScripts may not be robust. Consider making such script filtering configurable to better accommodate different server setups.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_bpjbHWXSWVtydad4


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -82,7 +84,17 @@ class MpActor : public MpObjectReference
};

void AddEventSink(std::shared_ptr<DestroyEventSink> sink);
Copy link

Choose a reason for hiding this comment

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

The overloaded AddEventSink/RemoveEventSink for DestroyEventSink and DisableEventSink are ambiguous. Consider renaming them (e.g. AddDestroyEventSink/AddDisableEventSink) for clarity.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 4de75e9 in 35 seconds

More details
  • Looked at 12 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpObjectReference.h:42
  • Draft comment:
    Verify that the new forward declaration for OccupantDisableEventSink is necessary and ensure its corresponding header is included where needed.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
2. skymp5-server/cpp/server_guest_lib/MpObjectReference.h:41
  • Draft comment:
    Added forward declaration for OccupantDisableEventSink for friend usage. Ensure proper header inclusion to avoid circular deps.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 20% <= threshold 50%
    The comment is informative and suggests ensuring proper header inclusion to avoid circular dependencies. It doesn't provide a specific code suggestion or ask for a specific test to be written. It also doesn't confirm if a change is intentional or suggest a refactor. Therefore, it seems to violate the rules.

Workflow ID: wflow_KRQEAOPYsALwhylN


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 0ea8782 in 58 seconds

More details
  • Looked at 27 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpActor.cpp:507
  • Draft comment:
    Renamed 'RemoveAllEventSink' to 'RemoveEventSink' for consistency.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. skymp5-server/cpp/server_guest_lib/MpActor.h:84
  • Draft comment:
    Renamed 'RemoveAllEventSink' to 'RemoveEventSink' for DestroyEventSink to match implementation.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is purely informative, stating that a rename was done to match the implementation. It doesn't provide any actionable feedback or suggestions for improvement. According to the rules, purely informative comments should be removed.
3. skymp5-server/cpp/server_guest_lib/MpActor.cpp:510
  • Draft comment:
    Renamed RemoveAllDestroyEventSinks to RemoveEventSink to reflect that only a single sink is removed.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is purely informative, explaining a change in the name of a function. It does not provide any actionable feedback or suggestions for improvement. According to the rules, purely informative comments should be removed.
4. skymp5-server/cpp/server_guest_lib/MpActor.h:85
  • Draft comment:
    Updated declaration: Rename RemoveAllEventSink to RemoveEventSink for consistency with implementation.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_oLJ74WEQw10S5jj6


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 07f9b88 in 2 minutes and 5 seconds

More details
  • Looked at 19 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpActor.cpp:518
  • Draft comment:
    The event sink type is changed from DestroyEventSink to DisableEventSink. Consider renaming the method (e.g. AddDisableEventSink) for clarity, as the name no longer reflects the type.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The suggestion to rename the method seems reasonable at first glance since it would make the method name more specific to its parameter type. However, looking more carefully:
  1. There are two overloaded AddEventSink methods, each taking a different event sink type
  2. The overloading pattern is consistent and follows standard C++ practices
  3. The parameter types clearly indicate which sink is being added
  4. Renaming just one overload would make the API less consistent
    The comment may be missing that this is an intentional overloading pattern where the parameter type provides sufficient clarity. Having differently named methods for each sink type could actually make the API more confusing.
    The current overloaded method names follow good C++ practices where the parameter types differentiate the methods. Renaming would break this pattern and could make the API less consistent.
    The comment should be deleted as it suggests breaking a valid method overloading pattern that already provides sufficient clarity through parameter types.
2. skymp5-server/cpp/server_guest_lib/MpActor.cpp:523
  • Draft comment:
    Similarly, the removal method is updated to use DisableEventSink. For consistency and clarity, consider renaming it (e.g. RemoveDisableEventSink).
  • Reason this comment was not posted:
    Marked as duplicate.
3. skymp5-server/cpp/server_guest_lib/MpActor.cpp:517
  • Draft comment:
    Changed AddEventSink to take DisableEventSink instead of DestroyEventSink. Verify that all call sites now create/expect DisableEventSink.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    The comment is asking the PR author to verify that all call sites now create/expect DisableEventSink, which is against the rules as it asks for confirmation of intention and verification. It does not provide a specific suggestion or point out a specific issue.
4. skymp5-server/cpp/server_guest_lib/MpActor.cpp:523
  • Draft comment:
    Modified RemoveEventSink to operate on DisableEventSink. Ensure consistent usage across the codebase.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_KsQL6016Z0OBsA3n


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@Pospelove Pospelove merged commit 80d87a9 into main Feb 14, 2025
17 checks passed
@Pospelove Pospelove deleted the Pospelove-patch-4 branch February 14, 2025 21:45
@Pospelove
Copy link
Contributor Author

I carefully tested. Please Revert if neeed

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.

1 participant