Skip to content

[RFC] Handle the impossibility of building a route during walk#3332

Open
ARGAMX wants to merge 3 commits into
CorsixTH:masterfrom
ARGAMX:handle-impossibility-of-building-route-during-walk
Open

[RFC] Handle the impossibility of building a route during walk#3332
ARGAMX wants to merge 3 commits into
CorsixTH:masterfrom
ARGAMX:handle-impossibility-of-building-route-during-walk

Conversation

@ARGAMX

@ARGAMX ARGAMX commented May 1, 2026

Copy link
Copy Markdown
Member

Fixes #3330

Describe what the proposed change does

  • If during the walk action target is not reachable anymore, don't discard the walk action.

@ARGAMX ARGAMX force-pushed the handle-impossibility-of-building-route-during-walk branch from 085afb9 to 8286498 Compare May 1, 2026 11:07
@ARGAMX ARGAMX added the PR:Bugfix PRs that fix things that shouldn't happen label May 5, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in 0.70.0 Release May 5, 2026
@ARGAMX ARGAMX requested review from lewri and tobylane May 5, 2026 17:57

@tobylane tobylane left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Picking up the doctor from any future action, eg desk or cabinet, crashes with the error

Error in buttonup handler:
.CorsixTH/CorsixTH/Lua/humanoid_actions/walk.lua:31: Invalid value for parameter 'x'
stack traceback:
[C]: in global 'assert'
CorsixTH/CorsixTH/Lua/humanoid_actions/walk.lua:31: in local 'constructor'
CorsixTH/CorsixTH/Lua/class.lua:74: in global 'WalkAction'
CorsixTH/CorsixTH/Lua/entities/humanoid.lua:873: in method 'walkTo'
CorsixTH/CorsixTH/Lua/rooms/gp.lua:55: in method 'doStaffUseCycle'
CorsixTH/CorsixTH/Lua/rooms/gp.lua:96: in method 'commandEnteringStaff'
CorsixTH/CorsixTH/Lua/room.lua:406: in method 'onHumanoidEnter'
CorsixTH/CorsixTH/Lua/humanoid_actions/pickup.lua:54: in local 'interrupt_handler'
CorsixTH/CorsixTH/Lua/entities/humanoid.lua:675: in method 'setNextAction'
CorsixTH/CorsixTH/Lua/dialogs/place_staff.lua:68: in method 'close'
CorsixTH/CorsixTH/Lua/dialogs/place_staff.lua:174: in method 'onMouseUp'
CorsixTH/CorsixTH/Lua/window.lua:1703: in field 'onMouseUp'
CorsixTH/CorsixTH/Lua/ui.lua:895: in function <CorsixTH/CorsixTH/Lua/ui.lua:882>
(...tail calls...)

Comment thread CorsixTH/Lua/entities/humanoid.lua Outdated
while queue[i] and queue[i].must_happen do
-- Skip over any actions which must happen,
-- except when adding PickupAction for stuck humanoid
while queue[i] and queue[i].must_happen and not pickup_stuck_humanoid do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is it structured this way? if not (class.. and ..stuck) then while loop end is clearer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why is it structured this way? if not (class.. and ..stuck) then while loop end is clearer.

Ok, I applied it. 👌

Comment thread CorsixTH/Lua/humanoid_action.lua Outdated
self.is_leaving = false -- Whether the humanoid is leaving.
self.no_truncate = false -- If set, disable shortening the action.
self.uninterruptible = false -- If true, can not be interrupted/cancelled by pickup.
self.stuck = false -- If true, humanoid had stuck during executing this action.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
self.stuck = false -- If true, humanoid had stuck during executing this action.
self.stuck = false -- If true, humanoid has become stuck during the execution of this action.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I applied it. 👌

@ARGAMX

ARGAMX commented May 8, 2026

Copy link
Copy Markdown
Member Author

Picking up the doctor from any future action, eg desk or cabinet, crashes with the error

I can't reproduce it.
Can you please describe it in more details and record a video?

But without canceling the pickup.
By canceling pick up we can put back doctor in the blocked area.
But since this is not allowed without debug enable, it is ok and I am aware of it.
Overall, the test case itself in 3330 is not valid, but it didn't matter for 826.

@ARGAMX ARGAMX force-pushed the handle-impossibility-of-building-route-during-walk branch from 5ea135c to 90c63dc Compare May 8, 2026 13:24
@lewri

lewri commented May 8, 2026

Copy link
Copy Markdown
Member

Picking up the doctor from any future action, eg desk or cabinet, crashes with the error

Error in buttonup handler:
.CorsixTH/CorsixTH/Lua/humanoid_actions/walk.lua:31: Invalid value for parameter 'x'
stack traceback:
[C]: in global 'assert'
CorsixTH/CorsixTH/Lua/humanoid_actions/walk.lua:31: in local 'constructor'
CorsixTH/CorsixTH/Lua/class.lua:74: in global 'WalkAction'
CorsixTH/CorsixTH/Lua/entities/humanoid.lua:873: in method 'walkTo'
CorsixTH/CorsixTH/Lua/rooms/gp.lua:55: in method 'doStaffUseCycle'
CorsixTH/CorsixTH/Lua/rooms/gp.lua:96: in method 'commandEnteringStaff'
CorsixTH/CorsixTH/Lua/room.lua:406: in method 'onHumanoidEnter'
CorsixTH/CorsixTH/Lua/humanoid_actions/pickup.lua:54: in local 'interrupt_handler'
CorsixTH/CorsixTH/Lua/entities/humanoid.lua:675: in method 'setNextAction'
CorsixTH/CorsixTH/Lua/dialogs/place_staff.lua:68: in method 'close'
CorsixTH/CorsixTH/Lua/dialogs/place_staff.lua:174: in method 'onMouseUp'
CorsixTH/CorsixTH/Lua/window.lua:1703: in field 'onMouseUp'
CorsixTH/CorsixTH/Lua/ui.lua:895: in function <CorsixTH/CorsixTH/Lua/ui.lua:882>
(...tail calls...)

Needs deeper insight, can we have the and/or reproduction steps please.

@tobylane

tobylane commented May 8, 2026

Copy link
Copy Markdown
Member

I had accidentally built the room slightly differently to the video in the linked issue. In this layout, it is possible to drop the doctor by the door inside the room, move the plant in line with the others as a wall, then attempt to drop the doctor on his current side of the plant wall, with access to the door but not the desk.

Screenshot 2026-05-08 at 21 54 01

Following the design of the video more closely as in the second image, I can't drop the doctor on his side of the plant wall, but if I press Esc there is a different crash as it can't put the doctor back where they were (in master it does the teleport as in the issue video).

Screenshot 2026-05-08 at 22 00 15

CorsixTH/CorsixTH/Lua/humanoid_actions/walk.lua:31: Invalid value for parameter 'x'
stack traceback:
[C]: in global 'assert'
CorsixTH/CorsixTH/Lua/humanoid_actions/walk.lua:31: in local 'constructor'
CorsixTH/CorsixTH/Lua/class.lua:74: in global 'WalkAction'
CorsixTH/CorsixTH/Lua/entities/humanoid.lua:873: in method 'walkTo'
CorsixTH/CorsixTH/Lua/rooms/gp.lua:55: in method 'doStaffUseCycle'
CorsixTH/CorsixTH/Lua/rooms/gp.lua:96: in method 'commandEnteringStaff'
CorsixTH/CorsixTH/Lua/room.lua:406: in method 'onHumanoidEnter'
CorsixTH/CorsixTH/Lua/humanoid_actions/pickup.lua:54: in local 'interrupt_handler'
CorsixTH/CorsixTH/Lua/entities/humanoid.lua:675: in method 'setNextAction'
CorsixTH/CorsixTH/Lua/dialogs/place_staff.lua:68: in method 'close'
CorsixTH/CorsixTH/Lua/ui.lua:1176: in field 'callback'
CorsixTH/CorsixTH/Lua/ui.lua:762: in field 'onKeyDown'

@ARGAMX

ARGAMX commented May 9, 2026

Copy link
Copy Markdown
Member Author

I had accidentally built the room slightly differently to the video in the linked issue. In this layout, it is possible to drop the doctor by the door inside the room, move the plant in line with the others as a wall, then attempt to drop the doctor on his current side of the plant wall, with access to the door but not the desk.

Screenshot 2026-05-08 at 21 54 01 Following the design of the video more closely as in the second image, I can't drop the doctor on his side of the plant wall, but if I press Esc there is a different crash as it can't put the doctor back where they were (in master it does the teleport as in the issue video). Screenshot 2026-05-08 at 22 00 15 > CorsixTH/CorsixTH/Lua/humanoid_actions/walk.lua:31: Invalid value for parameter 'x' > stack traceback: > [C]: in global 'assert' > CorsixTH/CorsixTH/Lua/humanoid_actions/walk.lua:31: in local 'constructor' > CorsixTH/CorsixTH/Lua/class.lua:74: in global 'WalkAction' > CorsixTH/CorsixTH/Lua/entities/humanoid.lua:873: in method 'walkTo' > CorsixTH/CorsixTH/Lua/rooms/gp.lua:55: in method 'doStaffUseCycle' > CorsixTH/CorsixTH/Lua/rooms/gp.lua:96: in method 'commandEnteringStaff' > CorsixTH/CorsixTH/Lua/room.lua:406: in method 'onHumanoidEnter' > CorsixTH/CorsixTH/Lua/humanoid_actions/pickup.lua:54: in local 'interrupt_handler' > CorsixTH/CorsixTH/Lua/entities/humanoid.lua:675: in method 'setNextAction' > CorsixTH/CorsixTH/Lua/dialogs/place_staff.lua:68: in method 'close' > CorsixTH/CorsixTH/Lua/ui.lua:1176: in field 'callback' > CorsixTH/CorsixTH/Lua/ui.lua:762: in field 'onKeyDown'

Thanks.

I am still unable to reproduce the provided examples without enabling "COMPLETELY ALLOWED" mode.

Screenshot 2026-05-09 at 13 35 33

.

Screenshot 2026-05-09 at 13 37 57

.
But by enabling "COMPLETELY ALLOWED" mode we can generate a lot of various crashes.

But this PR doesn't have goal to fix them all.
This PR has a narrow goal of solving one specific case described in #3330.

Although the video in #3330 may be misleading because it has "COMPLETELY ALLOWED" enabled, I recorded it for a slightly different case and then was too lazy to record a new one more suitable for #3330.

Therefore, if you're testing something that falls outside the scope of "Steps to Reproduce" in #3330, you're essentially testing other situations whose solution is simply not within the goals of this PR.

The crash when pressing Esc would also be great if someone will fix it. I haven't set that goal yet. It happens because instead of having a list of objects and coordinates for a room, the room is re-searched them every time the humanoid needs to approach them.

Firstly, it slows down the game. Secondly, it causes crashes like these. While I generally consider the scenario invalid because it requires "COMPLETELY ALLOWED" to be enabled, I still believe the game shouldn't crash when pressing Esc. But not as a result of this certain PR.

@lewri

lewri commented May 21, 2026

Copy link
Copy Markdown
Member

Therefore, if you're testing something that falls outside the scope of "Steps to Reproduce" in #3330, you're essentially testing other situations whose solution is simply not within the goals of this PR.

I'd like to know more if Toby is saying this PR has introduced this bug or not

@tobylane

Copy link
Copy Markdown
Member

Yes, this PR adds a bug in completely allowed mode. If it's out of scope to fix it now, note it for later.

@ARGAMX

ARGAMX commented May 22, 2026

Copy link
Copy Markdown
Member Author

Yes, this PR adds a bug in completely allowed mode. If it's out of scope to fix it now, note it for later.

Can you please provide a detailed scenario that doesn't crash Lua in 0.69.2, but does crash Lua in this PR?

I still don't understand what specific bug this PR adds.

Otherwise, in my understanding, the point here is that this PR doesn't fix something that already was broken before.

@ARGAMX

ARGAMX commented May 28, 2026

Copy link
Copy Markdown
Member Author

Currently I'm plan to postponing this, skip 0.70.0, targeting this to 0.71.0.

But that doesn't mean this PR doesn't need an Approve. It still does.

Currently it's essentially been suspended allegedly due to some "bug", but still no concrete case has been given related to that "bug". 😜

@ARGAMX ARGAMX moved this from In Progress to Missed/Postponed in 0.70.0 Release May 28, 2026
@ARGAMX ARGAMX changed the title Handle the impossibility of building a route during walk [RFC] Handle the impossibility of building a route during walk May 28, 2026
@lewri lewri moved this to In Progress in 0.71.0 Release Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR:Bugfix PRs that fix things that shouldn't happen

Projects

Status: Missed/Postponed
Status: In Progress

Development

Successfully merging this pull request may close these issues.

Handle the impossibility of building a route

3 participants