Skip to content

Commit

Permalink
Remove queued StaffRise messages
Browse files Browse the repository at this point in the history
On sack and death
  • Loading branch information
lewri committed Apr 8, 2024
1 parent 3bb1100 commit f1ec6ec
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions CorsixTH/Lua/entities/humanoids/staff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ function Staff:checkIfWaitedTooLong()
break
end
end
--If the hospital policy is set to automatically grant wage increases, grant the requested raise
--instead of firing the staff member
-- If the hospital policy is set to automatically grant wage increases, grant
-- the requested raise instead of firing the staff member
if self.hospital.policies.grant_wage_increase then
local amount = math.floor(math.max(self.profile.wage * 1.1, (self.profile:getFairWage(self.world) + self.profile.wage) / 2) - self.profile.wage)
self.quitting_in = nil
Expand All @@ -193,12 +193,12 @@ function Staff:checkIfWaitedTooLong()
return
end

-- Plays the sack sound, but maybe it's good that you hear a staff member leaving?
-- else: The staff member is sacked
if staff_rise_window then
staff_rise_window:fireStaff()
else
self:fire()
return
end
self:fire()
end
end
end
Expand Down Expand Up @@ -234,6 +234,11 @@ function Staff:isResting()
end
end

--! Destroys any raise request window that may be queued
function Staff:removeQueuedStaffMessage()
self.hospital:removeMessage(self)
end

-- Immediately terminate the staff member's employment.
function Staff:fire()
if self.fired then
Expand All @@ -245,6 +250,7 @@ function Staff:fire()
if staff_window and staff_window.staff == self then
staff_window:close()
end
self:removeQueuedStaffMessage()
self.hospital:spendMoney(self.profile.wage, _S.transactions.severance .. ": "
.. self.profile:getFullName())
self.world.ui:playSound("sack.wav")
Expand All @@ -266,6 +272,8 @@ function Staff:fire()
end

function Staff:die()
-- Dismiss any queued staff raise requests
self:removeQueuedStaffMessage()
-- Update the staff management screen (if present) accordingly
local window = self.world.ui:getWindow(UIStaffManagement)
if window then
Expand Down

0 comments on commit f1ec6ec

Please sign in to comment.