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

onStepOut FIXED #4650

Merged
merged 1 commit into from
Apr 13, 2024
Merged

onStepOut FIXED #4650

merged 1 commit into from
Apr 13, 2024

Conversation

MillhioreBT
Copy link
Contributor

Pull Request Prelude

  • I have followed [proper The Forgotten Server code styling][code].
  • I have read and understood the [contribution guidelines][cont] before making this PR.
  • I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.

Changes Proposed

Currently, there is a scenario where an onStepOut event moves the creature. So, when the creature is removed, the event is triggered, and immediately the onStepOut event will try to move the creature. However, when the creature is removed from the tile, the onStepOut event will call the Map::moveCreature method, which will try to remove the creature from the tile again and also attempt to update the new tile. This results in unexpected behavior and can lead to any undefined behavior, typically a crash.

This fixes the problem by ignoring the movements... perhaps more checks are needed?

Steps to reproduce the problem:

Connect any player.
Place the character on top of anything that triggers the onStepOut event.
Test onStepOut event:

local leave = MoveEvent()

function leave.onStepOut(creature, item, pos, fromPosition)
    local player = creature:getPlayer()
    if player then player:teleportTo(player:getTown():getTemplePosition()) end
    return true
end

leave:aid(3000)
leave:register()

local talkAction = TalkAction("!test")

function talkAction.onSay(player, words, param, type)
    player:remove()
    return false
end

--talkAction:accountType(ACCOUNT_TYPE_GOD)
--talkAction:access(true)
--talkAction:separator(" ")
talkAction:register()
  • You can use the !test command to delete or simply logout.
  • Next you could find a crash server or bugged client

Issues addressed: Nothing!

@ranisalt
Copy link
Member

So this will trigger only if the onStepOut event also moves the player to a different location?

@MillhioreBT
Copy link
Contributor Author

So this will trigger only if the onStepOut event also moves the player to a different location?

That is correct, although it can also happen with creatures in general, not only with players.

@MillhioreBT MillhioreBT merged commit a4471ed into otland:master Apr 13, 2024
19 checks passed
@MillhioreBT MillhioreBT deleted the fix_remove_onStepOut branch April 13, 2024 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants