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

Operating theatre with exhausted but not leaving surgeon errors when patient enters - Not enough staff in operating theatre #1012

Closed
tobylane opened this Issue Mar 27, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@tobylane
Member

tobylane commented Mar 27, 2016

Describe the issue

Woman enters operating theatre unless exhausted surgeon is manually moved

Steps to Reproduce

  1. Load save game attached to this ticket
  2. Watch the black haired woman enter the operating theatre. Re-ordering the queue doesn't stop the error, but does give time for the extra staff member to leave.
  3. Reload the savegame and remove the exhausted surgeon before Jan 5th.

Save Game

http://cl.ly/1K0E2e1T2k3e

Expected Behaviour

Exhausted surgeon leaves
Patient changes and is operated on.

System Information

CorsixTH Version:
d1f9f9e (9 behind current head)
Operating System:
OS X 10.10.5
Theme Hospital Version:
CD

Gamelog.txt

---------------------------------------------------------------

Welcome to CorsixTH Trunk!

---------------------------------------------------------------

This window will display useful information if an error occurs.

---------------------------------------------------------------

Will not check for updates since this is the Trunk version.
Savegame version is 108 (Trunk), originally it was 108 (Trunk)
An error has occurred!
Almost anything can be the cause, but the detailed information below can help the developers find the source of the error.
Running: The timer handler.
A stack trace is included below, and the handler has been disconnected.
...sixTH.app/Contents/MacOS/Lua/rooms/operating_theatre.lua:272: Not enough staff in operating theatre
stack traceback:
    [C]: in function 'assert'
    ...sixTH.app/Contents/MacOS/Lua/rooms/operating_theatre.lua:272: in method 'commandEnteringPatient'
    ...ads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/room.lua:394: in method 'onHumanoidEnter'
    ...orsixTH.app/Contents/MacOS/Lua/humanoid_actions/walk.lua:356: in field 'on_next_tile_set'
    ...orsixTH.app/Contents/MacOS/Lua/humanoid_actions/walk.lua:150: in function <...orsixTH.app/Contents/MacOS/Lua/humanoid_actions/walk.lua:137>
    (...tail calls...)
    ...s/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/entity.lua:219: in method 'tick'
    ...ds/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/world.lua:1064: in method 'onTick'
    ...oads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/app.lua:979: in function <...oads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/app.lua:976>
    (...tail calls...)
    ...oads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/app.lua:880: in function <...oads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/app.lua:875>

Error in timer handler: 
...sixTH.app/Contents/MacOS/Lua/rooms/operating_theatre.lua:272: Not enough staff in operating theatre
stack traceback:
    [C]: in function 'assert'
    ...sixTH.app/Contents/MacOS/Lua/rooms/operating_theatre.lua:272: in method 'commandEnteringPatient'
    ...ads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/room.lua:394: in method 'onHumanoidEnter'
    ...orsixTH.app/Contents/MacOS/Lua/humanoid_actions/walk.lua:356: in field 'on_next_tile_set'
    ...orsixTH.app/Contents/MacOS/Lua/humanoid_actions/walk.lua:150: in function <...orsixTH.app/Contents/MacOS/Lua/humanoid_actions/walk.lua:137>
    (...tail calls...)
    ...s/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/entity.lua:219: in method 'tick'
    ...ds/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/world.lua:1064: in method 'onTick'
    ...oads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/app.lua:979: in function <...oads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/app.lua:976>
    (...tail calls...)
    ...oads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/app.lua:880: in function <...oads/gitCorsixTH/CorsixTH.app/Contents/MacOS/Lua/app.lua:875>
Warning: No event handler for timer
Recovering from error in timer handler...

Additional Info

This savegame was started, and this error happened on, unedited code but in between some changes in other areas have been experimented with.
The level of tiredness before going to staff room has been changed a lot in this level but not in the last few in-game years.

@tobylane tobylane changed the title from Operating theatre with exhausted but not leaving surgeon crashes when patient enters, error - Not enough staff in operating theatre to Operating theatre with exhausted but not leaving surgeon errors when patient enters - Not enough staff in operating theatre Mar 27, 2016

@mugmuggy

This comment has been minimized.

Show comment
Hide comment
@mugmuggy

mugmuggy Nov 3, 2017

Contributor

From what I can gather there is a race for the door with the arriving and leaving surgeon. Arriving gets there first and enters the room, never gowns up. The leaving surgeon has enqueued an immediate walk action in the room, circles back to the door and leaves. The state just so happens to allow a patient to enter.

Room:getMissingStaff
if class.is(humanoid, Staff) and humanoid:fulfillsCriterion(attribute) and not humanoid:isLeaving() and not humanoid.fired then
humanoid.isLeaving() checks the first action item in the queue only, which is now the walk action for the leaving surgeon. So him being in the room, accounts for the need for the entering surgeon to not gown up.

For demonstration purposes as it's not the right way to go about it, replace humanoid:isLeaving() with humanoid:hasLeaveAction() will have the surgeon gown up, but no patients arrive. This is because hasLeaveAction() picks up the, walk/use_screen action for when the surgeon does actually leave and blocks further tests of Room:staffFitsInRoom(staff) from being effective.

As hasLeaveAction() isn't an option, I though maybe adding in a check for just going_to_staffroom instead would be sufficient
if class.is(humanoid, Staff) and humanoid:fulfillsCriterion(attribute) and not humanoid:isLeaving() and not humanoid.going_to_staffroom and not humanoid.fired then

This appears to work around this issue, but again, I don't quite know enough to ascertain if that is the case or best option.

Contributor

mugmuggy commented Nov 3, 2017

From what I can gather there is a race for the door with the arriving and leaving surgeon. Arriving gets there first and enters the room, never gowns up. The leaving surgeon has enqueued an immediate walk action in the room, circles back to the door and leaves. The state just so happens to allow a patient to enter.

Room:getMissingStaff
if class.is(humanoid, Staff) and humanoid:fulfillsCriterion(attribute) and not humanoid:isLeaving() and not humanoid.fired then
humanoid.isLeaving() checks the first action item in the queue only, which is now the walk action for the leaving surgeon. So him being in the room, accounts for the need for the entering surgeon to not gown up.

For demonstration purposes as it's not the right way to go about it, replace humanoid:isLeaving() with humanoid:hasLeaveAction() will have the surgeon gown up, but no patients arrive. This is because hasLeaveAction() picks up the, walk/use_screen action for when the surgeon does actually leave and blocks further tests of Room:staffFitsInRoom(staff) from being effective.

As hasLeaveAction() isn't an option, I though maybe adding in a check for just going_to_staffroom instead would be sufficient
if class.is(humanoid, Staff) and humanoid:fulfillsCriterion(attribute) and not humanoid:isLeaving() and not humanoid.going_to_staffroom and not humanoid.fired then

This appears to work around this issue, but again, I don't quite know enough to ascertain if that is the case or best option.

@TheCycoONE

This comment has been minimized.

Show comment
Hide comment
@TheCycoONE

TheCycoONE Nov 3, 2017

Member

I think the newly added walk action should have setIsLeaving(true), then the original check would have worked.

Member

TheCycoONE commented Nov 3, 2017

I think the newly added walk action should have setIsLeaving(true), then the original check would have worked.

@mugmuggy

This comment has been minimized.

Show comment
Hide comment
@mugmuggy

mugmuggy Nov 4, 2017

Contributor

I just hunted that down.

Changing

humanoid:queueAction(WalkAction(ix, iy):setMustHappen(true), idle_index - 1)

to
humanoid:queueAction(WalkAction(ix, iy):setMustHappen(true):setIsLeaving(humanoid:isLeaving()), idle_index - 1)

I believe that does the trick, I just don't know if it will break anything else.

Contributor

mugmuggy commented Nov 4, 2017

I just hunted that down.

Changing

humanoid:queueAction(WalkAction(ix, iy):setMustHappen(true), idle_index - 1)

to
humanoid:queueAction(WalkAction(ix, iy):setMustHappen(true):setIsLeaving(humanoid:isLeaving()), idle_index - 1)

I believe that does the trick, I just don't know if it will break anything else.

@TheCycoONE

This comment has been minimized.

Show comment
Hide comment
@TheCycoONE

TheCycoONE Nov 4, 2017

Member

Wow, plot thickens. Ok, I'll investigate later this weekend.

Member

TheCycoONE commented Nov 4, 2017

Wow, plot thickens. Ok, I'll investigate later this weekend.

mugmuggy added a commit to mugmuggy/CorsixTH that referenced this issue Sep 24, 2018

mugmuggy added a commit to mugmuggy/CorsixTH that referenced this issue Sep 25, 2018

@TheCycoONE TheCycoONE closed this Oct 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment