Skip to content

Commit

Permalink
Another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Oct 22, 2023
1 parent b04c7b8 commit bd3a8d6
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions scripts/ai/jobs/CpAIJob.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,37 +94,40 @@ function CpAIJob:start(farmId)
end

function CpAIJob:stop(aiMessage)
if self.isServer then
local vehicle = self.vehicleParameter:getVehicle()
vehicle:resetCpAllActiveInfoTexts()
local driveStrategy = vehicle:getCpDriveStrategy()
if not aiMessage then
self:debug("No valid ai message given!")
if driveStrategy then
driveStrategy:onFinished()
end
return
end
local releaseMessage, hasFinished, event, isOnlyShownOnPlayerStart =
g_infoTextManager:getInfoTextDataByAIMessage(aiMessage)
if releaseMessage then
self:debug("Stopped with release message %s", tostring(releaseMessage))
end
if not self.isServer then
CpAIJob:superClass().stop(self, aiMessage)
return
end
local vehicle = self.vehicleParameter:getVehicle()
vehicle:deleteAgent()
vehicle:aiJobFinished()
vehicle:resetCpAllActiveInfoTexts()
local driveStrategy = vehicle:getCpDriveStrategy()
if not aiMessage then
self:debug("No valid ai message given!")
if driveStrategy then
driveStrategy:onFinished(hasFinished)
driveStrategy:onFinished()
end
if releaseMessage and not vehicle:getIsControlled() and not isOnlyShownOnPlayerStart then
--- Only shows the info text, if the vehicle is not entered.
--- TODO: Add check if passing to ad is active maybe?
vehicle:setCpInfoTextActive(releaseMessage)
end
if event then
SpecializationUtil.raiseEvent(vehicle, event)
end
vehicle:deleteAgent()
vehicle:aiJobFinished()
CpAIJob:superClass().stop(self, aiMessage)
return
end
local releaseMessage, hasFinished, event, isOnlyShownOnPlayerStart =
g_infoTextManager:getInfoTextDataByAIMessage(aiMessage)
if releaseMessage then
self:debug("Stopped with release message %s", tostring(releaseMessage))
end
if releaseMessage and not vehicle:getIsControlled() and not isOnlyShownOnPlayerStart then
--- Only shows the info text, if the vehicle is not entered.
--- TODO: Add check if passing to ad is active maybe?
vehicle:setCpInfoTextActive(releaseMessage)
end
CpAIJob:superClass().stop(self, aiMessage)
if event then
SpecializationUtil.raiseEvent(vehicle, event)
end
if driveStrategy then
driveStrategy:onFinished(hasFinished)
end
end

--- Updates the parameter values.
Expand Down

0 comments on commit bd3a8d6

Please sign in to comment.