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

controller bug bot protected #1001

Open
2 of 5 tasks
InnerCircleTFS opened this issue Dec 22, 2024 · 4 comments
Open
2 of 5 tasks

controller bug bot protected #1001

InnerCircleTFS opened this issue Dec 22, 2024 · 4 comments
Labels
Priority: Low Minor impact Status: Pending Test This PR or Issue requires more testing Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@InnerCircleTFS
Copy link
Contributor

InnerCircleTFS commented Dec 22, 2024

Priority

Low

Area

  • Data
  • Source
  • Docker
  • Other

What happened?

I was testing how to create modules with a controller and noticed that there is an error if I create the exact same module with a controller or in the traditional way. Only with the controller do I get this error: ERROR: caught a lua call to a bot protected game function, the call was cancelled. In the traditional way, I don't get this error.
Example:

traditional:

function init()
    connect(g_game, {
        onGameStart = online,
    })
    if g_game.isOnline() then
        online()
    end
end

function online()
  print("game_botProtectBugTraditional")
  print("[Traditional]call init g_game.setFightMode(1)")
  g_game.setFightMode(1)
  print("[Traditional]call terminate g_game.setFightMode(1)")
end

function terminate()
  disconnect(g_game, {
      onGameStart = online
  })
end
Module
  name: game_botProtectBugTraditional
  sandboxed: true
  scripts: [ game_botProtectBugTraditional ]
  @onLoad: init()
  @onUnload: terminate()

Controller:

controllerProtectBug = Controller:new()

function controllerProtectBug:onInit()

end

function controllerProtectBug:onGameStart()
  print("game_botProtectBugController")
  print("[Controller] call init g_game.setFightMode(1)")
  g_game.setFightMode(1)
  print("[Controller] call terminate g_game.setFightMode(1)")
end

function controllerProtectBug:onTerminate()
end
Module
  name: game_botProtectBugController
  scripts: [ game_botProtectBugController ]
  sandboxed: true
  @onLoad: controllerProtectBug:init()
  @onUnload: controllerProtectBug:terminate()

output: on onGameStart

output print traditional:

game_botProtectBugTraditional

[Traditional]call init g_game.setFightMode(1)

[Traditional]call terminate g_game.setFightMode(1)

output print Controller

game_botProtectBugController

[Controller] call init g_game.setFightMode(1)

ERROR: caught a lua call to a bot protected game function, the call was cancelled
stack traceback:
    [builtin#142]: at 0x7ff64c44dc30
    [C]: in function 'setFightMode'
    ...botProtectBugController/game_botProtectBugController.lua:11: in function '__onGameStart'
    /modulelib/controller.lua:10: in function </modulelib/controller.lua:9>
    
[Controller] call terminate g_game.setFightMode(1)

What OS are you seeing the problem on?

Windows

Code of Conduct

  • I agree to follow this project's Code of Conduct
@InnerCircleTFS InnerCircleTFS added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Dec 22, 2024
@github-actions github-actions bot added Priority: Low Minor impact Status: Pending Test This PR or Issue requires more testing labels Dec 22, 2024
@mehah
Copy link
Owner

mehah commented Dec 24, 2024

it must be because gamestart is executed inside an addEvent.

self:__onGameStart()

@InnerCircleTFS
Copy link
Contributor Author

InnerCircleTFS commented Dec 24, 2024

@mehah I found an error in game_inventory; it doesn't save the last saved PVP because this is missing.

(reference release 3.5)
gamestart

    local player = g_game.getLocalPlayer()
    if player then
        local char = g_game.getCharacterName()

        local lastCombatControls = g_settings.getNode('LastCombatControls')

        if not table.empty(lastCombatControls) then
            if lastCombatControls[char] then
                g_game.setFightMode(lastCombatControls[char].fightMode)
                g_game.setChaseMode(lastCombatControls[char].chaseMode)
                g_game.setSafeFight(lastCombatControls[char].safeFight)
                if lastCombatControls[char].pvpMode then
                    g_game.setPVPMode(lastCombatControls[char].pvpMode)
                end
            end
        end

GameEnd

    local lastCombatControls = g_settings.getNode('LastCombatControls')
    if not lastCombatControls then
        lastCombatControls = {}
    end

    local player = g_game.getLocalPlayer()
    if player then
        local char = g_game.getCharacterName()
        lastCombatControls[char] = {
            fightMode = g_game.getFightMode(),
            chaseMode = g_game.getChaseMode(),
            safeFight = g_game.isSafeFight()
        }

        if g_game.getFeature(GamePVPMode) then
            lastCombatControls[char].pvpMode = g_game.getPVPMode()
        end

        -- save last combat control settings
        g_settings.setNode('LastCombatControls', lastCombatControls)
    end

If I try to add it, the bot protection triggers because module written in the controller.

@mehah
Copy link
Owner

mehah commented Dec 24, 2024

@InnerCircleTFS
I honestly no longer see the need for bot_protection in the source code, depending on me, I think we could remove this from the project.

@tomasz1337
Copy link

@InnerCircleTFS I honestly no longer see the need for bot_protection in the source code, depending on me, I think we could remove this from the project.

+1 People can disable/remove it themselves ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Low Minor impact Status: Pending Test This PR or Issue requires more testing Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

3 participants