2014-08-20 23:48:36 +02:00
|
|
|
/*****************************************************************************
|
2024-12-31 20:30:04 +01:00
|
|
|
* Copyright (c) 2014-2025 OpenRCT2 developers
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-05-04 19:24:41 +02:00
|
|
|
*****************************************************************************/
|
2014-08-20 23:48:36 +02:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
#include "Staff.h"
|
|
|
|
|
|
2017-04-01 19:50:07 +01:00
|
|
|
#include "../Context.h"
|
2024-07-09 16:23:31 +02:00
|
|
|
#include "../Diagnostic.h"
|
2017-11-30 18:17:06 +01:00
|
|
|
#include "../Game.h"
|
2023-12-28 00:53:43 +02:00
|
|
|
#include "../GameState.h"
|
2017-12-12 14:52:57 +01:00
|
|
|
#include "../Input.h"
|
2020-12-09 23:39:10 -07:00
|
|
|
#include "../actions/StaffSetOrdersAction.h"
|
2025-02-17 07:24:03 -05:00
|
|
|
#include "../audio/Audio.h"
|
2021-11-25 23:25:04 -08:00
|
|
|
#include "../core/DataSerialiser.h"
|
2024-12-15 17:39:52 +01:00
|
|
|
#include "../core/EnumUtils.hpp"
|
2025-03-01 17:32:32 +01:00
|
|
|
#include "../entity/EntityList.h"
|
2021-11-24 16:58:01 +02:00
|
|
|
#include "../entity/EntityRegistry.h"
|
2018-01-05 23:45:53 +00:00
|
|
|
#include "../interface/Viewport.h"
|
2018-01-06 18:32:25 +01:00
|
|
|
#include "../localisation/StringIds.h"
|
2017-10-06 22:37:06 +02:00
|
|
|
#include "../management/Finance.h"
|
2025-02-24 04:43:06 -05:00
|
|
|
#include "../network/Network.h"
|
2023-02-15 21:35:16 +00:00
|
|
|
#include "../object/ObjectEntryManager.h"
|
2024-11-25 23:32:16 +09:00
|
|
|
#include "../object/ObjectLimits.h"
|
2018-01-02 20:36:42 +01:00
|
|
|
#include "../object/ObjectList.h"
|
2018-12-11 23:31:06 +00:00
|
|
|
#include "../object/ObjectManager.h"
|
2023-05-09 21:08:25 +02:00
|
|
|
#include "../object/PathAdditionEntry.h"
|
2024-12-23 12:21:04 +01:00
|
|
|
#include "../object/PeepAnimationsObject.h"
|
2023-01-27 19:44:58 +00:00
|
|
|
#include "../object/SceneryGroupEntry.h"
|
2023-01-25 19:25:33 +00:00
|
|
|
#include "../object/SmallSceneryEntry.h"
|
2018-12-11 23:31:06 +00:00
|
|
|
#include "../object/TerrainSurfaceObject.h"
|
2018-05-31 23:16:53 +01:00
|
|
|
#include "../paint/tile_element/Paint.TileElement.h"
|
2021-11-25 23:47:24 +02:00
|
|
|
#include "../peep/GuestPathfinding.h"
|
2018-06-22 23:04:19 +02:00
|
|
|
#include "../ride/RideData.h"
|
|
|
|
|
#include "../ride/Station.h"
|
|
|
|
|
#include "../ride/Track.h"
|
2021-05-29 06:01:32 +01:00
|
|
|
#include "../ride/Vehicle.h"
|
2025-02-02 17:44:12 -03:00
|
|
|
#include "../util/Util.h"
|
2020-12-09 23:39:10 -07:00
|
|
|
#include "../windows/Intent.h"
|
2017-12-14 10:34:12 +01:00
|
|
|
#include "../world/Entrance.h"
|
2018-01-11 10:59:26 +01:00
|
|
|
#include "../world/Footpath.h"
|
|
|
|
|
#include "../world/Scenery.h"
|
2024-10-03 12:42:53 +02:00
|
|
|
#include "../world/tile_element/EntranceElement.h"
|
2024-10-15 22:02:31 +02:00
|
|
|
#include "../world/tile_element/PathElement.h"
|
2024-05-02 23:31:01 +02:00
|
|
|
#include "../world/tile_element/Slope.h"
|
2024-10-15 22:02:31 +02:00
|
|
|
#include "../world/tile_element/SmallSceneryElement.h"
|
|
|
|
|
#include "../world/tile_element/SurfaceElement.h"
|
2024-10-14 14:26:10 +02:00
|
|
|
#include "../world/tile_element/TrackElement.h"
|
2022-03-08 00:14:52 +00:00
|
|
|
#include "PatrolArea.h"
|
2017-10-13 10:06:36 +02:00
|
|
|
#include "Peep.h"
|
2014-08-20 23:48:36 +02:00
|
|
|
|
2024-07-09 16:43:03 +02:00
|
|
|
#include <cassert>
|
2018-11-21 23:16:04 +01:00
|
|
|
#include <iterator>
|
2018-08-12 12:50:40 +01:00
|
|
|
|
2023-12-28 00:53:43 +02:00
|
|
|
using namespace OpenRCT2;
|
|
|
|
|
|
2024-10-29 16:54:01 +01:00
|
|
|
template<>
|
|
|
|
|
bool EntityBase::Is<Staff>() const
|
2020-06-10 17:54:34 +01:00
|
|
|
{
|
2021-03-17 08:04:41 +00:00
|
|
|
return Type == EntityType::Staff;
|
2020-06-10 17:54:34 +01:00
|
|
|
}
|
|
|
|
|
|
2014-11-02 01:41:00 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C0905
|
|
|
|
|
*/
|
2020-03-07 23:07:47 +01:00
|
|
|
bool Staff::IsLocationInPatrol(const CoordsXY& loc) const
|
2014-11-02 01:41:00 +00:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Check if location is in the park
|
2022-10-12 06:35:20 +01:00
|
|
|
if (!MapIsLocationOwnedOrHasRights(loc))
|
2018-02-01 17:40:12 +01:00
|
|
|
return false;
|
2014-11-02 01:41:00 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Check if staff has patrol area
|
2021-09-19 08:28:25 +01:00
|
|
|
if (!HasPatrolArea())
|
2018-02-01 17:40:12 +01:00
|
|
|
return true;
|
2014-11-02 01:41:00 +00:00
|
|
|
|
2020-03-07 23:07:47 +01:00
|
|
|
return IsPatrolAreaSet(loc);
|
2016-01-26 20:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
// Check whether the location x,y is inside and on the edge of the
|
|
|
|
|
// patrol zone for mechanic.
|
|
|
|
|
bool Staff::IsLocationOnPatrolEdge(const CoordsXY& loc) const
|
2017-06-29 20:34:37 +02:00
|
|
|
{
|
2018-06-22 23:04:19 +02:00
|
|
|
bool onZoneEdge = false;
|
2020-09-27 20:07:09 -04:00
|
|
|
for (uint8_t neighbourDir = 0; !onZoneEdge && neighbourDir <= 7; neighbourDir++)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-06-21 16:41:18 -03:00
|
|
|
auto neighbourPos = loc + CoordsDirectionDelta[neighbourDir];
|
2020-09-27 20:07:09 -04:00
|
|
|
onZoneEdge = !IsLocationInPatrol(neighbourPos);
|
2017-06-29 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
return onZoneEdge;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
bool Staff::CanIgnoreWideFlag(const CoordsXYZ& staffPos, TileElement* path) const
|
2017-06-29 20:34:37 +02:00
|
|
|
{
|
|
|
|
|
/* Wide flags can potentially wall off parts of a staff patrol zone
|
|
|
|
|
* for the heuristic search.
|
|
|
|
|
* This function provide doors through such "walls" by defining
|
|
|
|
|
* the conditions under which staff can ignore the wide path flag. */
|
|
|
|
|
/* Staff can ignore the wide flag on a path on the edge of the patrol
|
|
|
|
|
* zone based on its adjacent tiles that are also in the patrol zone
|
|
|
|
|
* but not on the patrol zone edge:
|
|
|
|
|
* Basic points of interest are:
|
|
|
|
|
* - how many such tiles there are;
|
|
|
|
|
* - whether there are connected paths on those tiles;
|
2018-01-28 19:31:51 +01:00
|
|
|
* - whether the connected paths have the wide flag set.
|
2017-06-29 20:34:37 +02:00
|
|
|
* If there are no such tiles, the path is a concave corner of
|
|
|
|
|
* the patrol zone and the wide flag can be ignored.
|
|
|
|
|
* If there is one such tile, the path is on a straight side of the
|
|
|
|
|
* patrol zone. If this one tile is either a connected wide path or
|
|
|
|
|
* not a connected path, the wide flag can be ignored.
|
|
|
|
|
* If there are two such tiles, the path is a convex corner of the
|
|
|
|
|
* patrol zone. If at most one of these tiles is a connected path or
|
|
|
|
|
* both of these tiles are connected wide paths, the wide flag can be
|
|
|
|
|
* ignored. */
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!IsLocationOnPatrolEdge(staffPos))
|
2017-06-29 20:34:37 +02:00
|
|
|
{
|
2018-01-28 19:31:51 +01:00
|
|
|
return false;
|
2017-06-29 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check the connected adjacent paths that are also inside the patrol
|
|
|
|
|
* zone but are not on the patrol zone edge have the wide flag set. */
|
2018-06-22 23:04:19 +02:00
|
|
|
uint8_t total = 0;
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t pathcount = 0;
|
|
|
|
|
uint8_t widecount = 0;
|
2025-01-19 16:59:45 +01:00
|
|
|
for (Direction adjac_dir : kAllDirections)
|
2017-06-29 20:34:37 +02:00
|
|
|
{
|
2020-06-21 22:25:22 -03:00
|
|
|
auto adjacPos = staffPos + CoordsXYZ{ CoordsDirectionDelta[adjac_dir].x, CoordsDirectionDelta[adjac_dir].y, 0 };
|
2017-06-29 20:34:37 +02:00
|
|
|
|
|
|
|
|
/* Ignore adjacent tiles outside the patrol zone. */
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!IsLocationInPatrol(adjacPos))
|
2017-06-29 20:34:37 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Ignore adjacent tiles on the patrol zone edge. */
|
2020-09-27 20:07:09 -04:00
|
|
|
if (IsLocationOnPatrolEdge(adjacPos))
|
2017-06-29 20:34:37 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Adjacent tile is inside the patrol zone but not on the
|
|
|
|
|
* patrol zone edge. */
|
|
|
|
|
total++;
|
|
|
|
|
|
|
|
|
|
/* Check if path has an edge in adjac_dir */
|
2018-10-05 13:11:44 +02:00
|
|
|
if (!(path->AsPath()->GetEdges() & (1u << adjac_dir)))
|
2017-06-29 20:34:37 +02:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-16 16:17:35 +02:00
|
|
|
if (path->AsPath()->IsSloped())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2018-10-04 15:07:48 +02:00
|
|
|
if (path->AsPath()->GetSlopeDirection() == adjac_dir)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2024-08-16 23:18:33 +02:00
|
|
|
adjacPos.z += kPathHeightStep;
|
2017-06-29 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Search through all adjacent map elements */
|
2022-10-11 19:39:24 +01:00
|
|
|
TileElement* test_element = MapGetFirstElementAt(adjacPos);
|
2019-10-09 11:02:21 -03:00
|
|
|
if (test_element == nullptr)
|
|
|
|
|
return false;
|
2018-06-22 23:04:19 +02:00
|
|
|
bool pathfound = false;
|
|
|
|
|
bool widefound = false;
|
2017-10-13 10:06:36 +02:00
|
|
|
do
|
|
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
if (test_element->GetType() != TileElementType::Path)
|
2017-06-29 20:34:37 +02:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* test_element is a path */
|
2024-09-30 13:24:04 +03:00
|
|
|
const auto* adjacentPathElement = test_element->AsPath();
|
|
|
|
|
if (!FootpathIsZAndDirectionValid(*adjacentPathElement, adjacPos.z / kCoordsZStep, adjac_dir))
|
2017-10-13 10:06:36 +02:00
|
|
|
continue;
|
2017-06-29 20:34:37 +02:00
|
|
|
|
|
|
|
|
/* test_element is a connected path */
|
|
|
|
|
if (!pathfound)
|
|
|
|
|
{
|
|
|
|
|
pathfound = true;
|
|
|
|
|
pathcount++;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-30 13:24:04 +03:00
|
|
|
if (adjacentPathElement->IsWide())
|
2017-06-29 20:34:37 +02:00
|
|
|
{
|
|
|
|
|
if (!widefound)
|
|
|
|
|
{
|
|
|
|
|
widefound = true;
|
|
|
|
|
widecount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(test_element++)->IsLastForTile());
|
2017-06-29 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (total)
|
|
|
|
|
{
|
2018-06-22 23:04:19 +02:00
|
|
|
case 0: /* Concave corner */
|
2018-01-28 19:31:51 +01:00
|
|
|
return true;
|
2018-06-22 23:04:19 +02:00
|
|
|
case 1: /* Straight side */
|
|
|
|
|
case 2: /* Convex corner */
|
|
|
|
|
if (pathcount <= total - 1 || widecount == total)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-06-29 20:34:37 +02:00
|
|
|
}
|
2018-01-28 19:31:51 +01:00
|
|
|
|
|
|
|
|
return false;
|
2017-06-29 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-26 20:54:17 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C095B
|
|
|
|
|
* returns 0xF if not in a valid patrol area
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
uint8_t Staff::GetValidPatrolDirections(const CoordsXY& loc) const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t directions = 0;
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2024-07-26 18:23:25 +10:00
|
|
|
if (IsLocationInPatrol({ loc.x - kCoordsXYStep, loc.y }))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
directions |= (1 << 0);
|
|
|
|
|
}
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2024-07-26 18:23:25 +10:00
|
|
|
if (IsLocationInPatrol({ loc.x, loc.y + kCoordsXYStep }))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
directions |= (1 << 1);
|
|
|
|
|
}
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2024-07-26 18:23:25 +10:00
|
|
|
if (IsLocationInPatrol({ loc.x + kCoordsXYStep, loc.y }))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
directions |= (1 << 2);
|
|
|
|
|
}
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2024-07-26 18:23:25 +10:00
|
|
|
if (IsLocationInPatrol({ loc.x, loc.y - kCoordsXYStep }))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
directions |= (1 << 3);
|
|
|
|
|
}
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2017-10-13 10:06:36 +02:00
|
|
|
if (directions == 0)
|
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
directions = 0xF;
|
|
|
|
|
}
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
return directions;
|
2015-03-31 02:48:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C1955
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
void Staff::ResetStats()
|
2015-03-31 02:48:26 +01:00
|
|
|
{
|
2021-03-16 11:18:06 +00:00
|
|
|
for (auto peep : EntityList<Staff>())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2023-04-02 10:25:41 +02:00
|
|
|
peep->SetHireDate(GetDate().GetMonthsElapsed());
|
2020-05-30 19:44:49 -03:00
|
|
|
peep->StaffLawnsMown = 0;
|
2020-05-30 19:42:13 -03:00
|
|
|
peep->StaffRidesFixed = 0;
|
2020-05-30 19:39:21 -03:00
|
|
|
peep->StaffGardensWatered = 0;
|
2020-05-30 19:35:08 -03:00
|
|
|
peep->StaffRidesInspected = 0;
|
2020-05-30 19:31:48 -03:00
|
|
|
peep->StaffLitterSwept = 0;
|
2021-03-14 21:18:35 +09:00
|
|
|
peep->StaffVandalsStopped = 0;
|
2020-05-30 19:28:33 -03:00
|
|
|
peep->StaffBinsEmptied = 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-06-18 15:10:53 +02:00
|
|
|
}
|
2015-07-13 19:51:46 +01:00
|
|
|
|
2020-02-13 10:25:42 +01:00
|
|
|
bool Staff::IsPatrolAreaSet(const CoordsXY& coords) const
|
2019-12-31 10:10:40 +01:00
|
|
|
{
|
2021-10-27 21:19:10 +01:00
|
|
|
if (PatrolInfo != nullptr)
|
|
|
|
|
{
|
2022-03-02 00:44:11 +00:00
|
|
|
return PatrolInfo->Get(coords);
|
2021-10-27 21:19:10 +01:00
|
|
|
}
|
|
|
|
|
return false;
|
2019-12-31 10:10:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-19 08:28:25 +01:00
|
|
|
void Staff::SetPatrolArea(const CoordsXY& coords, bool value)
|
2016-09-10 15:17:18 +01:00
|
|
|
{
|
2021-10-27 21:19:10 +01:00
|
|
|
if (PatrolInfo == nullptr)
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
PatrolInfo = new PatrolArea();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-02 00:44:11 +00:00
|
|
|
|
|
|
|
|
PatrolInfo->Set(coords, value);
|
2016-09-10 15:17:18 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-08 00:24:37 +00:00
|
|
|
void Staff::SetPatrolArea(const MapRange& range, bool value)
|
|
|
|
|
{
|
2024-07-26 18:23:25 +10:00
|
|
|
for (int32_t yy = range.GetTop(); yy <= range.GetBottom(); yy += kCoordsXYStep)
|
2022-03-08 00:24:37 +00:00
|
|
|
{
|
2024-07-26 18:23:25 +10:00
|
|
|
for (int32_t xx = range.GetLeft(); xx <= range.GetRight(); xx += kCoordsXYStep)
|
2022-03-08 00:24:37 +00:00
|
|
|
{
|
|
|
|
|
SetPatrolArea({ xx, yy }, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-19 08:28:25 +01:00
|
|
|
void Staff::ClearPatrolArea()
|
2016-09-10 15:17:18 +01:00
|
|
|
{
|
2021-10-27 21:19:10 +01:00
|
|
|
delete PatrolInfo;
|
|
|
|
|
PatrolInfo = nullptr;
|
2016-09-10 15:17:18 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-19 08:28:25 +01:00
|
|
|
bool Staff::HasPatrolArea() const
|
|
|
|
|
{
|
2022-03-02 00:44:11 +00:00
|
|
|
return PatrolInfo == nullptr ? false : !PatrolInfo->IsEmpty();
|
2021-09-19 08:28:25 +01:00
|
|
|
}
|
|
|
|
|
|
2016-02-03 12:41:34 +00:00
|
|
|
/**
|
2016-11-13 20:17:49 +01:00
|
|
|
*
|
2016-02-03 12:41:34 +00:00
|
|
|
* rct2: 0x006BFBE8
|
2016-11-13 20:17:49 +01:00
|
|
|
*
|
2025-03-25 17:42:20 +01:00
|
|
|
* Returns kInvalidDirection when no nearby litter or unpathable litter
|
2016-02-03 12:41:34 +00:00
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
Direction Staff::HandymanDirectionToNearestLitter() const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-04-21 16:45:48 +03:00
|
|
|
// Maximum manhattan distance that litter can be for a handyman to seek to it
|
|
|
|
|
constexpr auto kTileRadius = 3;
|
|
|
|
|
constexpr auto kLookupRadius = kCoordsXYStep * kTileRadius;
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2025-04-21 16:45:48 +03:00
|
|
|
auto nearestLitterDist = std::numeric_limits<int32_t>::max();
|
|
|
|
|
Litter* nearestLitter = nullptr;
|
|
|
|
|
|
|
|
|
|
for (int32_t tileX = x - kLookupRadius; tileX <= x + kLookupRadius; tileX += kCoordsXYStep)
|
|
|
|
|
{
|
|
|
|
|
for (int32_t tileY = y - kLookupRadius; tileY <= y + kLookupRadius; tileY += kCoordsXYStep)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-04-21 16:45:48 +03:00
|
|
|
for (auto* litter : EntityTileList<Litter>({ tileX, tileY }))
|
|
|
|
|
{
|
|
|
|
|
// Calculate Manhattan distance with z-weighting
|
|
|
|
|
uint16_t distance = std::abs(litter->x - x) + std::abs(litter->y - y) + std::abs(litter->z - z) * 4;
|
|
|
|
|
|
|
|
|
|
if (distance < nearestLitterDist)
|
|
|
|
|
{
|
|
|
|
|
nearestLitterDist = distance;
|
|
|
|
|
nearestLitter = litter;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2025-04-21 16:45:48 +03:00
|
|
|
if (nearestLitterDist > kLookupRadius || nearestLitter == nullptr)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2019-12-24 17:54:06 -03:00
|
|
|
auto litterTile = CoordsXY{ nearestLitter->x, nearestLitter->y }.ToTileStart();
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!IsLocationInPatrol(litterTile))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
Direction nextDirection = DirectionFromTo(CoordsXY(x, y), litterTile.ToTileCentre());
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
CoordsXY nextTile = litterTile.ToTileStart() - CoordsDirectionDelta[nextDirection];
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2024-07-26 18:23:25 +10:00
|
|
|
int16_t nextZ = ((z + kCoordsZStep) & 0xFFF0) / kCoordsZStep;
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
TileElement* tileElement = MapGetFirstElementAt(nextTile);
|
2019-10-09 11:02:21 -03:00
|
|
|
if (tileElement == nullptr)
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2017-10-13 10:06:36 +02:00
|
|
|
do
|
|
|
|
|
{
|
2023-01-19 20:36:30 +01:00
|
|
|
if (tileElement->BaseHeight != nextZ)
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() == TileElementType::Entrance || tileElement->GetType() == TileElementType::Track)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(tileElement++)->IsLastForTile());
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
nextTile = CoordsXY(x, y).ToTileStart() + CoordsDirectionDelta[nextDirection];
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
tileElement = MapGetFirstElementAt(nextTile);
|
2019-10-09 11:02:21 -03:00
|
|
|
if (tileElement == nullptr)
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2017-10-13 10:06:36 +02:00
|
|
|
do
|
|
|
|
|
{
|
2023-01-19 20:36:30 +01:00
|
|
|
if (tileElement->BaseHeight != nextZ)
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() == TileElementType::Entrance || tileElement->GetType() == TileElementType::Track)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(tileElement++)->IsLastForTile());
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
return nextDirection;
|
2016-02-03 12:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-26 20:54:17 +00:00
|
|
|
/**
|
2016-02-03 18:17:30 +00:00
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF931
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
uint8_t Staff::HandymanDirectionToUncutGrass(uint8_t valid_directions) const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!(GetNextIsSurface()))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2022-10-11 19:39:24 +01:00
|
|
|
auto surfaceElement = MapGetSurfaceElementAt(NextLoc);
|
2019-10-08 08:45:30 -03:00
|
|
|
if (surfaceElement == nullptr)
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2016-02-03 18:17:30 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (NextLoc.z != surfaceElement->GetBaseZ())
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2016-02-03 18:17:30 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (GetNextIsSloped())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-01-22 17:16:55 +01:00
|
|
|
if (surfaceElement->GetSlope() != kPathSlopeToLandSlope[GetNextDirection()])
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2024-05-02 23:31:01 +02:00
|
|
|
else if (surfaceElement->GetSlope() != kTileSlopeFlat)
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-03 18:17:30 +00:00
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
uint8_t chosenDirection = ScenarioRand() & 0x3;
|
2018-06-20 17:28:51 +02:00
|
|
|
for (uint8_t i = 0; i < 4; ++i, ++chosenDirection)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
chosenDirection &= 0x3;
|
2016-02-03 18:17:30 +00:00
|
|
|
|
2017-10-13 10:06:36 +02:00
|
|
|
if (!(valid_directions & (1 << chosenDirection)))
|
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
2016-02-03 18:17:30 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
CoordsXY chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[chosenDirection];
|
2016-02-03 18:17:30 +00:00
|
|
|
|
2022-10-12 06:35:20 +01:00
|
|
|
if (!MapIsLocationValid(chosenTile))
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
2016-02-03 18:17:30 +00:00
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
auto surfaceElement = MapGetSurfaceElementAt(chosenTile);
|
2018-12-11 23:31:06 +00:00
|
|
|
if (surfaceElement != nullptr)
|
|
|
|
|
{
|
2024-07-26 18:23:25 +10:00
|
|
|
if (std::abs(surfaceElement->GetBaseZ() - NextLoc.z) <= 2 * kCoordsZStep)
|
2018-12-11 23:31:06 +00:00
|
|
|
{
|
|
|
|
|
if (surfaceElement->CanGrassGrow() && (surfaceElement->GetGrassLength() & 0x7) >= GRASS_LENGTH_CLEAR_1)
|
|
|
|
|
{
|
|
|
|
|
return chosenDirection;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2025-03-25 17:42:20 +01:00
|
|
|
return kInvalidDirection;
|
2016-02-03 18:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-03 19:14:33 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BFD9C
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
Direction Staff::HandymanDirectionRandSurface(uint8_t validDirections) const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2024-07-01 17:29:08 +02:00
|
|
|
Direction newDirection = ScenarioRand() % kNumOrthogonalDirections;
|
|
|
|
|
for (int32_t i = 0; i < kNumOrthogonalDirections; ++i, ++newDirection)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2024-07-01 17:29:08 +02:00
|
|
|
newDirection %= kNumOrthogonalDirections;
|
2020-03-07 23:07:47 +01:00
|
|
|
if (!(validDirections & (1 << newDirection)))
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2020-03-07 23:07:47 +01:00
|
|
|
CoordsXY chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[newDirection];
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2022-10-12 06:35:20 +01:00
|
|
|
if (MapSurfaceIsBlocked(chosenTile))
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// If it tries all directions this is required
|
|
|
|
|
// to make it back to the first direction and
|
|
|
|
|
// override validDirections
|
2024-07-01 17:29:08 +02:00
|
|
|
newDirection %= kNumOrthogonalDirections;
|
2020-03-07 23:07:47 +01:00
|
|
|
return newDirection;
|
2016-02-03 19:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-03 18:17:30 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BFBA8
|
|
|
|
|
*/
|
2020-03-07 23:07:47 +01:00
|
|
|
bool Staff::DoHandymanPathFinding()
|
2016-03-24 23:47:15 +00:00
|
|
|
{
|
2020-05-31 17:21:06 -03:00
|
|
|
StaffMowingTimeout++;
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2025-03-25 17:42:20 +01:00
|
|
|
Direction litterDirection = kInvalidDirection;
|
2020-09-27 20:07:09 -04:00
|
|
|
uint8_t validDirections = GetValidPatrolDirections(NextLoc);
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2025-03-20 19:47:53 +01:00
|
|
|
if ((StaffOrders & STAFF_ORDERS_SWEEPING) && ((getGameState().currentTicks + Id.ToUnderlying()) & 0xFFF) > 110)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
litterDirection = HandymanDirectionToNearestLitter();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2025-03-25 17:42:20 +01:00
|
|
|
Direction newDirection = kInvalidDirection;
|
|
|
|
|
if (litterDirection == kInvalidDirection && (StaffOrders & STAFF_ORDERS_MOWING) && StaffMowingTimeout >= 12)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
newDirection = HandymanDirectionToUncutGrass(validDirections);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-03 18:17:30 +00:00
|
|
|
|
2025-03-25 17:42:20 +01:00
|
|
|
if (newDirection == kInvalidDirection)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-03-07 23:07:47 +01:00
|
|
|
if (GetNextIsSurface())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-03-07 23:07:47 +01:00
|
|
|
newDirection = HandymanDirectionRandSurface(validDirections);
|
2017-10-13 10:06:36 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-10-12 06:35:20 +01:00
|
|
|
auto* pathElement = MapGetPathElementAt(TileCoordsXYZ{ NextLoc });
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2019-08-13 19:17:15 +01:00
|
|
|
if (pathElement == nullptr)
|
2018-02-01 17:40:12 +01:00
|
|
|
return true;
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2019-08-13 19:17:15 +01:00
|
|
|
uint8_t pathDirections = (pathElement->GetEdges() & validDirections) & 0xF;
|
2017-10-13 10:06:36 +02:00
|
|
|
if (pathDirections == 0)
|
|
|
|
|
{
|
2020-03-07 23:07:47 +01:00
|
|
|
newDirection = HandymanDirectionRandSurface(validDirections);
|
2017-10-13 10:06:36 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
bool chooseRandom = true;
|
2025-03-25 17:42:20 +01:00
|
|
|
if (litterDirection != kInvalidDirection && pathDirections & (1 << litterDirection))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-07-08 20:48:08 +02:00
|
|
|
/// Check whether path is a queue path and connected to a ride
|
2022-01-19 18:24:23 +02:00
|
|
|
bool connectedQueue = (pathElement->IsQueue() && !pathElement->GetRideIndex().IsNull());
|
2020-07-08 20:48:08 +02:00
|
|
|
/// When in a queue path make the probability of following litter much lower (10% instead of 90%)
|
|
|
|
|
/// as handymen often get stuck when there is litter on a normal path next to a queue they are in
|
|
|
|
|
uint32_t chooseRandomProbability = connectedQueue ? 0xE666 : 0x1999;
|
2023-01-17 20:46:55 +01:00
|
|
|
if ((ScenarioRand() & 0xFFFF) >= chooseRandomProbability)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
chooseRandom = false;
|
2020-03-07 23:07:47 +01:00
|
|
|
newDirection = litterDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2017-10-13 10:06:36 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-10-04 20:12:38 +01:00
|
|
|
pathDirections &= ~(1 << DirectionReverse(PeepDirection));
|
2017-10-13 10:06:36 +02:00
|
|
|
if (pathDirections == 0)
|
|
|
|
|
{
|
2022-10-04 20:12:38 +01:00
|
|
|
pathDirections |= 1 << DirectionReverse(PeepDirection);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2019-04-20 20:39:47 +02:00
|
|
|
if (chooseRandom)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
newDirection = ScenarioRand() & 3;
|
2020-03-07 23:07:47 +01:00
|
|
|
} while ((pathDirections & (1 << newDirection)) == 0);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
// newDirection can only contain a cardinal direction at this point, no diagonals
|
2022-10-04 20:12:38 +01:00
|
|
|
assert(DirectionValid(newDirection));
|
2016-02-14 21:36:31 +01:00
|
|
|
|
2020-03-07 23:07:47 +01:00
|
|
|
CoordsXY chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[newDirection];
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2022-10-12 06:35:20 +01:00
|
|
|
while (!MapIsLocationValid(chosenTile))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-03-07 23:07:47 +01:00
|
|
|
newDirection = HandymanDirectionRandSurface(validDirections);
|
|
|
|
|
chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[newDirection];
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-03 19:14:33 +00:00
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
PeepDirection = newDirection;
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(chosenTile + CoordsXY{ 16, 16 }, 3);
|
2020-09-28 20:51:49 +02:00
|
|
|
if (State == PeepState::Queuing)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
DestinationTolerance = (ScenarioRand() & 7) + 2;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-02-01 17:40:12 +01:00
|
|
|
return false;
|
2016-01-26 20:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
Direction Staff::DirectionSurface(Direction initialDirection) const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t direction = initialDirection;
|
|
|
|
|
for (int32_t i = 0; i < 3; ++i)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Looks left and right from initial direction
|
2017-10-13 10:06:36 +02:00
|
|
|
switch (i)
|
|
|
|
|
{
|
2018-06-22 23:04:19 +02:00
|
|
|
case 1:
|
|
|
|
|
direction++;
|
2023-01-17 20:46:55 +01:00
|
|
|
if (ScenarioRand() & 1)
|
2018-06-22 23:04:19 +02:00
|
|
|
{
|
|
|
|
|
direction -= 2;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2017-06-06 23:24:18 +02:00
|
|
|
direction -= 2;
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-04 18:54:27 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
direction &= 3;
|
2016-02-04 18:54:27 +00:00
|
|
|
|
2025-01-19 16:59:45 +01:00
|
|
|
if (WallInTheWay({ NextLoc, NextLoc.z, NextLoc.z + kPeepClearanceHeight }, direction))
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
2016-02-04 18:54:27 +00:00
|
|
|
|
2025-01-19 16:59:45 +01:00
|
|
|
if (WallInTheWay({ NextLoc, NextLoc.z, NextLoc.z + kPeepClearanceHeight }, DirectionReverse(direction)))
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
2016-02-04 18:54:27 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
CoordsXY chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[direction];
|
2016-02-04 18:54:27 +00:00
|
|
|
|
2022-10-12 06:35:20 +01:00
|
|
|
if (!MapSurfaceIsBlocked(chosenTile))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
return direction;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return initialDirection;
|
2016-02-04 18:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-09 17:53:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BFF45
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
Direction Staff::MechanicDirectionSurface() const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
Direction direction = ScenarioRand() & 3;
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2023-01-17 01:32:54 +01:00
|
|
|
auto ride = GetRide(CurrentRide);
|
2023-01-17 20:46:55 +01:00
|
|
|
if (ride != nullptr && (State == PeepState::Answering || State == PeepState::HeadingToInspection) && (ScenarioRand() & 1))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
auto location = ride->getStation(CurrentRideStation).Exit;
|
2021-09-09 01:48:53 +02:00
|
|
|
if (location.IsNull())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
location = ride->getStation(CurrentRideStation).Entrance;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
direction = DirectionFromTo(CoordsXY(x, y), location.ToCoordsXY());
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
return DirectionSurface(direction);
|
2016-02-09 17:53:24 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-06 10:34:40 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C02D1
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
Direction Staff::MechanicDirectionPathRand(uint8_t pathDirections) const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
if (ScenarioRand() & 1)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
if (pathDirections & (1 << PeepDirection))
|
|
|
|
|
return PeepDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Modified from original to spam scenario_rand less
|
2023-01-17 20:46:55 +01:00
|
|
|
uint8_t direction = ScenarioRand() & 3;
|
2018-06-20 17:28:51 +02:00
|
|
|
for (int32_t i = 0; i < 4; ++i, ++direction)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
direction &= 3;
|
|
|
|
|
if (pathDirections & (1 << direction))
|
|
|
|
|
return direction;
|
|
|
|
|
}
|
|
|
|
|
// This will never happen as pathDirections always has a bit set.
|
2020-09-27 20:07:09 -04:00
|
|
|
return PeepDirection;
|
2016-02-06 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C0121
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
Direction Staff::MechanicDirectionPath(uint8_t validDirections, PathElement* pathElement)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2024-07-28 18:44:59 +02:00
|
|
|
uint32_t pathDirections = pathElement->GetEdges();
|
2017-06-06 23:24:18 +02:00
|
|
|
pathDirections &= validDirections;
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2017-10-13 10:06:36 +02:00
|
|
|
if (pathDirections == 0)
|
|
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
return MechanicDirectionSurface();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Check if this is dead end - i.e. only way out is the reverse direction.
|
2022-10-04 20:12:38 +01:00
|
|
|
pathDirections &= ~(1 << DirectionReverse(PeepDirection));
|
2017-10-13 10:06:36 +02:00
|
|
|
if (pathDirections == 0)
|
|
|
|
|
{
|
2022-10-04 20:12:38 +01:00
|
|
|
pathDirections |= (1 << DirectionReverse(PeepDirection));
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2024-10-29 11:08:39 +01:00
|
|
|
Direction direction = Numerics::bitScanForward(pathDirections);
|
2017-06-06 23:24:18 +02:00
|
|
|
pathDirections &= ~(1 << direction);
|
2017-10-13 10:06:36 +02:00
|
|
|
if (pathDirections == 0)
|
|
|
|
|
{
|
2020-09-28 20:51:49 +02:00
|
|
|
if (State != PeepState::Answering && State != PeepState::HeadingToInspection)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
return direction;
|
|
|
|
|
}
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (SubState != 2)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
return direction;
|
|
|
|
|
}
|
2020-09-27 20:07:09 -04:00
|
|
|
SubState = 3;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
pathDirections |= (1 << direction);
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Mechanic is heading to ride (either broken down or for inspection).
|
2023-01-17 01:32:54 +01:00
|
|
|
auto ride = GetRide(CurrentRide);
|
2020-09-28 20:51:49 +02:00
|
|
|
if (ride != nullptr && (State == PeepState::Answering || State == PeepState::HeadingToInspection))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
/* Find location of the exit for the target ride station
|
|
|
|
|
* or if the ride has no exit, the entrance. */
|
2025-03-09 00:26:25 +01:00
|
|
|
TileCoordsXYZD location = ride->getStation(CurrentRideStation).Exit;
|
2021-09-09 01:48:53 +02:00
|
|
|
if (location.IsNull())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
location = ride->getStation(CurrentRideStation).Entrance;
|
2018-02-19 13:12:33 +01:00
|
|
|
|
|
|
|
|
// If no entrance is present either. This is an incorrect state.
|
2021-09-09 01:48:53 +02:00
|
|
|
if (location.IsNull())
|
2018-02-19 13:12:33 +01:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
return MechanicDirectionPathRand(pathDirections);
|
2018-02-19 13:12:33 +01:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2024-02-22 21:52:01 +02:00
|
|
|
const auto goalPos = TileCoordsXYZ{ location };
|
2024-09-30 13:24:04 +03:00
|
|
|
Direction pathfindDirection = PathFinding::ChooseDirection(
|
|
|
|
|
TileCoordsXYZ{ NextLoc }, goalPos, *this, false, RideId::GetNull());
|
2025-03-25 17:42:20 +01:00
|
|
|
if (pathfindDirection == kInvalidDirection)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
/* Heuristic search failed for all directions.
|
2020-05-31 17:42:49 -03:00
|
|
|
* Reset the PathfindGoal - this means that the PathfindHistory
|
2022-05-14 15:28:24 -04:00
|
|
|
* will be reset in the next call to GuestPathfinding::ChooseDirection().
|
2017-06-06 23:24:18 +02:00
|
|
|
* This lets the heuristic search "try again" in case the player has
|
|
|
|
|
* edited the path layout or the mechanic was already stuck in the
|
|
|
|
|
* save game (e.g. with a worse version of the pathfinding). */
|
2020-09-27 20:07:09 -04:00
|
|
|
ResetPathfindGoal();
|
|
|
|
|
return MechanicDirectionPathRand(pathDirections);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
return pathfindDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-09-27 20:07:09 -04:00
|
|
|
return MechanicDirectionPathRand(pathDirections);
|
2016-02-06 10:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 18:54:27 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BFF2C
|
|
|
|
|
*/
|
2020-03-07 23:07:47 +01:00
|
|
|
bool Staff::DoMechanicPathFinding()
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
uint8_t validDirections = GetValidPatrolDirections(NextLoc);
|
2025-03-25 17:42:20 +01:00
|
|
|
Direction newDirection = kInvalidDirection;
|
2020-03-07 23:07:47 +01:00
|
|
|
if (GetNextIsSurface())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
newDirection = MechanicDirectionSurface();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2017-10-13 10:06:36 +02:00
|
|
|
else
|
|
|
|
|
{
|
2022-10-12 06:35:20 +01:00
|
|
|
auto* pathElement = MapGetPathElementAt(TileCoordsXYZ{ NextLoc });
|
2018-01-04 06:58:44 +01:00
|
|
|
if (pathElement == nullptr)
|
2018-02-01 17:40:12 +01:00
|
|
|
return true;
|
2016-02-04 18:54:27 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
newDirection = MechanicDirectionPath(validDirections, pathElement);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-04 18:54:27 +00:00
|
|
|
|
2018-04-18 19:34:34 +01:00
|
|
|
// countof(CoordsDirectionDelta)
|
2022-10-04 20:12:38 +01:00
|
|
|
assert(DirectionValid(newDirection));
|
2016-02-14 21:36:31 +01:00
|
|
|
|
2020-03-07 23:07:47 +01:00
|
|
|
CoordsXY chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[newDirection];
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2022-10-12 06:35:20 +01:00
|
|
|
while (!MapIsLocationValid(chosenTile))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
newDirection = MechanicDirectionSurface();
|
2020-03-07 23:07:47 +01:00
|
|
|
chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[newDirection];
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-06 10:34:40 +00:00
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
PeepDirection = newDirection;
|
2023-01-17 20:46:55 +01:00
|
|
|
auto tolerance = (ScenarioRand() & 7) + 2;
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(chosenTile + CoordsXY{ 16, 16 }, tolerance);
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2018-02-01 17:40:12 +01:00
|
|
|
return false;
|
2016-02-04 18:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-09 17:53:24 +00:00
|
|
|
/**
|
2017-10-13 10:06:36 +02:00
|
|
|
*
|
|
|
|
|
* rct2: 0x006C050B
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
Direction Staff::DirectionPath(uint8_t validDirections, PathElement* pathElement) const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2024-07-28 18:44:59 +02:00
|
|
|
uint32_t pathDirections = pathElement->GetEdges();
|
2020-09-28 20:51:49 +02:00
|
|
|
if (State != PeepState::Answering && State != PeepState::HeadingToInspection)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
pathDirections &= validDirections;
|
|
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2017-10-13 10:06:36 +02:00
|
|
|
if (pathDirections == 0)
|
|
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
return DirectionSurface(ScenarioRand() & 3);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2024-07-28 18:44:59 +02:00
|
|
|
pathDirections &= ~(1u << DirectionReverse(PeepDirection));
|
2017-10-13 10:06:36 +02:00
|
|
|
if (pathDirections == 0)
|
|
|
|
|
{
|
2024-07-28 18:44:59 +02:00
|
|
|
pathDirections |= (1u << DirectionReverse(PeepDirection));
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2024-10-29 11:08:39 +01:00
|
|
|
Direction direction = Numerics::bitScanForward(pathDirections);
|
2020-09-27 20:07:09 -04:00
|
|
|
// If this is the only direction they can go, then go
|
2024-07-28 18:44:59 +02:00
|
|
|
if (pathDirections == (1u << direction))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
return direction;
|
|
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
direction = ScenarioRand() & 3;
|
2024-07-01 17:29:08 +02:00
|
|
|
for (uint8_t i = 0; i < kNumOrthogonalDirections; ++i, direction = DirectionNext(direction))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2024-07-28 18:44:59 +02:00
|
|
|
if (pathDirections & (1u << direction))
|
2017-06-06 23:24:18 +02:00
|
|
|
return direction;
|
|
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// This will never happen as pathDirections will always have a bit set
|
|
|
|
|
return direction;
|
2016-02-09 17:53:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C0351
|
|
|
|
|
*/
|
2020-03-07 23:07:47 +01:00
|
|
|
bool Staff::DoMiscPathFinding()
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
uint8_t validDirections = GetValidPatrolDirections(NextLoc);
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2025-03-25 17:42:20 +01:00
|
|
|
Direction newDirection = kInvalidDirection;
|
2020-03-07 23:07:47 +01:00
|
|
|
if (GetNextIsSurface())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
newDirection = DirectionSurface(ScenarioRand() & 3);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2017-10-13 10:06:36 +02:00
|
|
|
else
|
|
|
|
|
{
|
2022-10-12 06:35:20 +01:00
|
|
|
auto* pathElement = MapGetPathElementAt(TileCoordsXYZ{ NextLoc });
|
2018-01-04 06:58:44 +01:00
|
|
|
if (pathElement == nullptr)
|
2018-02-01 17:40:12 +01:00
|
|
|
return true;
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
newDirection = DirectionPath(validDirections, pathElement);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2020-03-07 23:07:47 +01:00
|
|
|
CoordsXY chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[newDirection];
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2022-10-12 06:35:20 +01:00
|
|
|
while (!MapIsLocationValid(chosenTile))
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
newDirection = DirectionSurface(ScenarioRand() & 3);
|
2020-03-07 23:07:47 +01:00
|
|
|
chosenTile = CoordsXY{ NextLoc } + CoordsDirectionDelta[newDirection];
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
PeepDirection = newDirection;
|
2023-01-17 20:46:55 +01:00
|
|
|
auto tolerance = (ScenarioRand() & 7) + 2;
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(chosenTile + CoordsXY{ 16, 16 }, tolerance);
|
2016-02-09 17:53:24 +00:00
|
|
|
|
2018-02-01 17:40:12 +01:00
|
|
|
return false;
|
2016-02-09 17:53:24 +00:00
|
|
|
}
|
|
|
|
|
|
2022-09-24 07:44:19 +02:00
|
|
|
bool Staff::IsMechanicHeadingToFixRideBlockingPath()
|
|
|
|
|
{
|
2022-09-30 20:00:59 +02:00
|
|
|
if (!IsMechanic())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
auto tileCoords = TileCoordsXYZ(CoordsXYZ{ GetDestination(), NextLoc.z });
|
|
|
|
|
auto trackElement = MapGetFirstTileElementWithBaseHeightBetween<TrackElement>(
|
2024-08-16 23:18:33 +02:00
|
|
|
{ tileCoords, tileCoords.z + kPathHeightStep });
|
2022-09-30 20:00:59 +02:00
|
|
|
if (trackElement == nullptr)
|
|
|
|
|
return false;
|
|
|
|
|
|
2023-01-17 01:32:54 +01:00
|
|
|
auto ride = GetRide(trackElement->GetRideIndex());
|
2022-12-13 21:46:53 +01:00
|
|
|
if (ride == nullptr)
|
|
|
|
|
return false;
|
|
|
|
|
|
2023-04-02 17:57:59 +02:00
|
|
|
return ride->id == CurrentRide;
|
2022-09-24 07:44:19 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-09 18:17:37 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C086D
|
|
|
|
|
*/
|
2020-09-08 15:49:09 -04:00
|
|
|
void Staff::EntertainerUpdateNearbyPeeps() const
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-04-21 20:09:30 +03:00
|
|
|
// Iterate over tiles within a 3-tile radius (96 units)
|
|
|
|
|
constexpr auto kTileRadius = 3;
|
|
|
|
|
constexpr auto kLookupRadius = kCoordsXYStep * kTileRadius;
|
|
|
|
|
|
|
|
|
|
for (int32_t tileX = x - kLookupRadius; tileX <= x + kLookupRadius; tileX += kCoordsXYStep)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-04-21 20:09:30 +03:00
|
|
|
for (int32_t tileY = y - kLookupRadius; tileY <= y + kLookupRadius; tileY += kCoordsXYStep)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2025-04-21 20:09:30 +03:00
|
|
|
for (auto* guest : EntityTileList<Guest>({ tileX, tileY }))
|
|
|
|
|
{
|
|
|
|
|
if (guest->x == kLocationNull)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
int16_t z_dist = std::abs(z - guest->z);
|
2025-07-15 12:02:37 +02:00
|
|
|
if (z_dist > kTileRadius / 2)
|
2025-04-21 20:09:30 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
int16_t x_dist = std::abs(x - guest->x);
|
|
|
|
|
int16_t y_dist = std::abs(y - guest->y);
|
|
|
|
|
|
|
|
|
|
if (x_dist > kLookupRadius)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (y_dist > kLookupRadius)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (guest->State == PeepState::Walking)
|
|
|
|
|
{
|
|
|
|
|
guest->HappinessTarget = std::min(guest->HappinessTarget + 4, kPeepMaxHappiness);
|
|
|
|
|
}
|
|
|
|
|
else if (guest->State == PeepState::Queuing)
|
|
|
|
|
{
|
|
|
|
|
guest->TimeInQueue = std::max(0, guest->TimeInQueue - 200);
|
|
|
|
|
guest->HappinessTarget = std::min(guest->HappinessTarget + 3, kPeepMaxHappiness);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-02-09 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C05AE
|
|
|
|
|
*/
|
2020-03-07 23:07:47 +01:00
|
|
|
bool Staff::DoEntertainerPathFinding()
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
if (((ScenarioRand() & 0xFFFF) <= 0x4000) && IsActionInterruptable())
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2023-01-17 20:46:55 +01:00
|
|
|
Action = (ScenarioRand() & 1) ? PeepActionType::Wave2 : PeepActionType::Joy;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2016-02-09 18:17:37 +00:00
|
|
|
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2020-09-08 15:49:09 -04:00
|
|
|
EntertainerUpdateNearbyPeeps();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-02-09 18:17:37 +00:00
|
|
|
|
2020-03-07 23:07:47 +01:00
|
|
|
return DoMiscPathFinding();
|
2016-02-09 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-26 20:54:17 +00:00
|
|
|
/**
|
2016-02-03 18:17:30 +00:00
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF926
|
|
|
|
|
*/
|
2020-03-07 23:07:47 +01:00
|
|
|
bool Staff::DoPathFinding()
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-08-16 18:20:00 -04:00
|
|
|
switch (AssignedStaffType)
|
2017-10-13 10:06:36 +02:00
|
|
|
{
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Handyman:
|
2020-03-07 23:07:47 +01:00
|
|
|
return DoHandymanPathFinding();
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Mechanic:
|
2020-03-07 23:07:47 +01:00
|
|
|
return DoMechanicPathFinding();
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Security:
|
2020-03-07 23:07:47 +01:00
|
|
|
return DoMiscPathFinding();
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Entertainer:
|
2020-03-07 23:07:47 +01:00
|
|
|
return DoEntertainerPathFinding();
|
2016-01-26 20:54:17 +00:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
return 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-26 20:54:17 +00:00
|
|
|
}
|
2016-04-28 20:09:05 +02:00
|
|
|
|
2020-10-12 20:36:38 -04:00
|
|
|
void Staff::SetHireDate(int32_t hireDate)
|
|
|
|
|
{
|
|
|
|
|
HireDate = hireDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t Staff::GetHireDate() const
|
|
|
|
|
{
|
|
|
|
|
return HireDate;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 21:16:36 +00:00
|
|
|
colour_t StaffGetColour(StaffType staffType)
|
2016-09-10 15:17:18 +01:00
|
|
|
{
|
2025-03-20 19:47:53 +01:00
|
|
|
const auto& gameState = getGameState();
|
2017-10-13 10:06:36 +02:00
|
|
|
switch (staffType)
|
|
|
|
|
{
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Handyman:
|
2025-03-20 19:47:53 +01:00
|
|
|
return gameState.staffHandymanColour;
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Mechanic:
|
2025-03-20 19:47:53 +01:00
|
|
|
return gameState.staffMechanicColour;
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Security:
|
2025-03-20 19:47:53 +01:00
|
|
|
return gameState.staffSecurityColour;
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Entertainer:
|
2018-06-22 23:04:19 +02:00
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
return 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-09-10 15:17:18 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-19 15:58:04 -08:00
|
|
|
GameActions::Result StaffSetColour(StaffType staffType, colour_t value)
|
2016-09-10 15:17:18 +01:00
|
|
|
{
|
2025-03-20 19:47:53 +01:00
|
|
|
auto& gameState = getGameState();
|
2017-10-13 10:06:36 +02:00
|
|
|
switch (staffType)
|
|
|
|
|
{
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Handyman:
|
2025-03-20 19:47:53 +01:00
|
|
|
gameState.staffHandymanColour = value;
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Mechanic:
|
2025-03-20 19:47:53 +01:00
|
|
|
gameState.staffMechanicColour = value;
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2020-08-16 18:25:32 -04:00
|
|
|
case StaffType::Security:
|
2025-03-20 19:47:53 +01:00
|
|
|
gameState.staffSecurityColour = value;
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
2024-02-19 15:58:04 -08:00
|
|
|
return GameActions::Result(
|
|
|
|
|
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_ACTION_INVALID_FOR_THAT_STAFF_TYPE);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2024-02-19 15:58:04 -08:00
|
|
|
return GameActions::Result();
|
2016-09-10 15:17:18 +01:00
|
|
|
}
|
2017-01-24 13:05:02 +00:00
|
|
|
|
2018-04-02 18:00:36 +01:00
|
|
|
/** rct2: 0x009929C8 */
|
2025-01-19 16:59:45 +01:00
|
|
|
static constexpr CoordsXY kMowingWaypoints[] = {
|
2018-04-02 18:00:36 +01:00
|
|
|
{ 28, 28 }, { 28, 4 }, { 20, 4 }, { 20, 28 }, { 12, 28 }, { 12, 4 }, { 4, 4 }, { 4, 28 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF567
|
|
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::UpdateMowing()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
if (!CheckForPath())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(); loc.has_value())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2022-10-12 06:35:20 +01:00
|
|
|
int16_t checkZ = TileElementHeight(*loc);
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), checkZ });
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 23:47:45 -03:00
|
|
|
Var37++;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-06-08 23:47:45 -03:00
|
|
|
if (Var37 == 1)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
SwitchToSpecialSprite(2);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-19 16:59:45 +01:00
|
|
|
if (Var37 == std::size(kMowingWaypoints))
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2018-04-02 18:18:15 +01:00
|
|
|
StateReset();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-19 16:59:45 +01:00
|
|
|
auto destination = kMowingWaypoints[Var37] + NextLoc;
|
2021-02-10 20:47:11 +02:00
|
|
|
SetDestination(destination);
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-06-08 23:47:45 -03:00
|
|
|
if (Var37 != 7)
|
2018-04-02 18:00:36 +01:00
|
|
|
continue;
|
|
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
auto surfaceElement = MapGetSurfaceElementAt(NextLoc);
|
2018-12-11 23:31:06 +00:00
|
|
|
if (surfaceElement != nullptr && surfaceElement->CanGrassGrow())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2018-12-11 23:31:06 +00:00
|
|
|
surfaceElement->SetGrassLength(GRASS_LENGTH_MOWED);
|
2022-10-12 13:14:45 +01:00
|
|
|
MapInvalidateTileZoom0({ NextLoc, surfaceElement->GetBaseZ(), surfaceElement->GetBaseZ() + 16 });
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
2025-02-02 17:44:12 -03:00
|
|
|
StaffLawnsMown = AddClamp(StaffLawnsMown, 1u);
|
2020-06-08 22:25:54 -03:00
|
|
|
WindowInvalidateFlags |= PEEP_INVALIDATE_STAFF_STATS;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF7E6
|
|
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::UpdateWatering()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-05-31 17:21:06 -03:00
|
|
|
StaffMowingTimeout = 0;
|
2020-06-14 02:31:08 -03:00
|
|
|
if (SubState == 0)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
if (!CheckForPath())
|
|
|
|
|
return;
|
|
|
|
|
|
2025-03-20 18:48:26 +02:00
|
|
|
const auto [pathingResult, _] = PerformNextAction();
|
2018-04-02 18:00:36 +01:00
|
|
|
if (!(pathingResult & PATHING_DESTINATION_REACHED))
|
|
|
|
|
return;
|
|
|
|
|
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = (Var37 & 3) << 3;
|
2020-09-30 18:19:10 -03:00
|
|
|
Action = PeepActionType::StaffWatering;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 1;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
2020-06-14 02:31:08 -03:00
|
|
|
else if (SubState == 1)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2021-05-11 10:15:02 +03:00
|
|
|
if (!IsActionWalking())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2019-08-15 18:32:19 +01:00
|
|
|
UpdateAction();
|
2019-08-21 12:31:05 +02:00
|
|
|
Invalidate();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 23:47:45 -03:00
|
|
|
auto actionLoc = CoordsXY{ NextLoc } + CoordsDirectionDelta[Var37];
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
TileElement* tile_element = MapGetFirstElementAt(actionLoc);
|
2019-10-09 11:02:21 -03:00
|
|
|
if (tile_element == nullptr)
|
|
|
|
|
return;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tile_element->GetType() != TileElementType::SmallScenery)
|
2018-04-02 18:00:36 +01:00
|
|
|
continue;
|
|
|
|
|
|
2024-07-26 18:23:25 +10:00
|
|
|
if (abs(NextLoc.z - tile_element->GetBaseZ()) > 4 * kCoordsZStep)
|
2018-04-02 18:00:36 +01:00
|
|
|
continue;
|
|
|
|
|
|
2022-01-01 15:07:55 +01:00
|
|
|
const auto* sceneryEntry = tile_element->AsSmallScenery()->GetEntry();
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2022-01-01 15:07:55 +01:00
|
|
|
if (sceneryEntry == nullptr || !sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_CAN_BE_WATERED))
|
2018-04-02 18:00:36 +01:00
|
|
|
continue;
|
|
|
|
|
|
2018-09-13 17:26:36 +02:00
|
|
|
tile_element->AsSmallScenery()->SetAge(0);
|
2022-10-12 13:14:45 +01:00
|
|
|
MapInvalidateTileZoom0({ actionLoc, tile_element->GetBaseZ(), tile_element->GetClearanceZ() });
|
2025-02-02 17:44:12 -03:00
|
|
|
StaffGardensWatered = AddClamp(StaffGardensWatered, 1u);
|
2020-06-08 22:25:54 -03:00
|
|
|
WindowInvalidateFlags |= PEEP_INVALIDATE_STAFF_STATS;
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(tile_element++)->IsLastForTile());
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2018-04-02 18:18:15 +01:00
|
|
|
StateReset();
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF6C9
|
|
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::UpdateEmptyingBin()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-05-31 17:21:06 -03:00
|
|
|
StaffMowingTimeout = 0;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
if (SubState == 0)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
if (!CheckForPath())
|
|
|
|
|
return;
|
2019-08-15 20:16:13 +02:00
|
|
|
|
2025-03-20 18:48:26 +02:00
|
|
|
const auto [pathingResult, _] = PerformNextAction();
|
2018-04-02 18:00:36 +01:00
|
|
|
if (!(pathingResult & PATHING_DESTINATION_REACHED))
|
|
|
|
|
return;
|
|
|
|
|
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = (Var37 & 3) << 3;
|
2020-09-30 18:19:10 -03:00
|
|
|
Action = PeepActionType::StaffEmptyBin;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 1;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
2020-06-14 02:31:08 -03:00
|
|
|
else if (SubState == 1)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2021-05-11 10:15:02 +03:00
|
|
|
if (IsActionWalking())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2018-04-02 18:18:15 +01:00
|
|
|
StateReset();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 18:32:19 +01:00
|
|
|
UpdateAction();
|
2019-08-21 12:31:05 +02:00
|
|
|
Invalidate();
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2024-09-22 16:12:04 +02:00
|
|
|
if (AnimationFrameNum != 11)
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
TileElement* tile_element = MapGetFirstElementAt(NextLoc);
|
2019-10-09 11:02:21 -03:00
|
|
|
if (tile_element == nullptr)
|
|
|
|
|
return;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
|
|
|
|
for (;; tile_element++)
|
|
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tile_element->GetType() == TileElementType::Path)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-02-11 22:01:14 +00:00
|
|
|
if (NextLoc.z == tile_element->GetBaseZ())
|
2018-04-02 18:00:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2018-05-24 11:44:53 +02:00
|
|
|
if ((tile_element)->IsLastForTile())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2018-04-02 18:18:15 +01:00
|
|
|
StateReset();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-16 17:08:15 +02:00
|
|
|
if (!tile_element->AsPath()->HasAddition())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2018-04-02 18:18:15 +01:00
|
|
|
StateReset();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 21:23:00 +01:00
|
|
|
auto* pathAddEntry = tile_element->AsPath()->GetAdditionEntry();
|
2023-05-09 21:08:25 +02:00
|
|
|
if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN) || tile_element->AsPath()->IsBroken()
|
2018-09-16 16:46:23 +02:00
|
|
|
|| tile_element->AsPath()->AdditionIsGhost())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2018-04-02 18:18:15 +01:00
|
|
|
StateReset();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 23:47:45 -03:00
|
|
|
uint8_t additionStatus = tile_element->AsPath()->GetAdditionStatus() | ((3 << Var37) << Var37);
|
2018-10-05 12:49:26 +02:00
|
|
|
tile_element->AsPath()->SetAdditionStatus(additionStatus);
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2022-10-12 13:14:45 +01:00
|
|
|
MapInvalidateTileZoom0({ NextLoc, tile_element->GetBaseZ(), tile_element->GetClearanceZ() });
|
2025-02-02 17:44:12 -03:00
|
|
|
StaffBinsEmptied = AddClamp(StaffBinsEmptied, 1u);
|
2020-06-08 22:25:54 -03:00
|
|
|
WindowInvalidateFlags |= PEEP_INVALIDATE_STAFF_STATS;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x6BF641
|
|
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::UpdateSweeping()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-05-31 17:21:06 -03:00
|
|
|
StaffMowingTimeout = 0;
|
2018-04-02 18:00:36 +01:00
|
|
|
if (!CheckForPath())
|
|
|
|
|
return;
|
|
|
|
|
|
2024-09-22 16:12:04 +02:00
|
|
|
if (Action == PeepActionType::StaffSweep && AnimationFrameNum == 8)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
// Remove sick at this location
|
2021-09-28 03:16:04 +03:00
|
|
|
Litter::RemoveAt(GetLocation());
|
2025-02-02 17:44:12 -03:00
|
|
|
StaffLitterSwept = AddClamp(StaffLitterSwept, 1u);
|
2020-06-08 22:25:54 -03:00
|
|
|
WindowInvalidateFlags |= PEEP_INVALIDATE_STAFF_STATS;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(); loc.has_value())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2019-08-15 18:32:19 +01:00
|
|
|
int16_t actionZ = GetZOnSlope((*loc).x, (*loc).y);
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), actionZ });
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 23:47:45 -03:00
|
|
|
Var37++;
|
|
|
|
|
if (Var37 != 2)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-30 18:19:10 -03:00
|
|
|
Action = PeepActionType::StaffSweep;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2018-04-02 18:18:15 +01:00
|
|
|
StateReset();
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C16D7
|
|
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::UpdateHeadingToInspect()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2023-01-17 01:32:54 +01:00
|
|
|
auto ride = GetRide(CurrentRide);
|
2019-08-08 22:58:56 +01:00
|
|
|
if (ride == nullptr)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-09 00:26:25 +01:00
|
|
|
if (ride->getStation(CurrentRideStation).Exit.IsNull())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
ride->lifecycleFlags &= ~RIDE_LIFECYCLE_DUE_INSPECTION;
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-09 00:26:25 +01:00
|
|
|
if (ride->mechanicStatus != RIDE_MECHANIC_STATUS_HEADING || !(ride->lifecycleFlags & RIDE_LIFECYCLE_DUE_INSPECTION))
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
if (SubState == 0)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-06-06 11:24:29 -03:00
|
|
|
MechanicTimeSinceCall = 0;
|
2020-09-16 20:22:36 -04:00
|
|
|
ResetPathfindGoal();
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 2;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
if (SubState <= 3)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-06-06 11:24:29 -03:00
|
|
|
MechanicTimeSinceCall++;
|
|
|
|
|
if (MechanicTimeSinceCall > 2500)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
if (ride->lifecycleFlags & RIDE_LIFECYCLE_DUE_INSPECTION && ride->mechanicStatus == RIDE_MECHANIC_STATUS_HEADING)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
ride->mechanicStatus = RIDE_MECHANIC_STATUS_CALLING;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CheckForPath())
|
|
|
|
|
return;
|
|
|
|
|
|
2022-10-09 11:01:10 +02:00
|
|
|
if (ShouldWaitForLevelCrossing() && !IsMechanicHeadingToFixRideBlockingPath())
|
2022-09-24 07:44:19 +02:00
|
|
|
return;
|
|
|
|
|
|
2025-03-20 18:48:26 +02:00
|
|
|
const auto [pathingResult, rideEntranceExitElement] = PerformNextAction();
|
2018-04-02 18:00:36 +01:00
|
|
|
if (!(pathingResult & PATHING_RIDE_EXIT) && !(pathingResult & PATHING_RIDE_ENTRANCE))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-07 22:21:53 -03:00
|
|
|
if (CurrentRide != rideEntranceExitElement->AsEntrance()->GetRideIndex())
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
2022-01-26 13:28:19 +01:00
|
|
|
StationIndex exitIndex = rideEntranceExitElement->AsEntrance()->GetStationIndex();
|
|
|
|
|
if (CurrentRideStation != exitIndex)
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (pathingResult & PATHING_RIDE_ENTRANCE)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
if (!ride->getStation(exitIndex).Exit.IsNull())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
PeepDirection = rideEntranceExitElement->GetDirection();
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2021-02-20 13:49:50 +02:00
|
|
|
auto newDestination = CoordsXY{ 16, 16 } + NextLoc + (DirectionOffsets[PeepDirection] * 53);
|
|
|
|
|
SetDestination(newDestination, 2);
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = PeepDirection << 3;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2023-01-19 20:36:30 +01:00
|
|
|
z = rideEntranceExitElement->BaseHeight * 4;
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 4;
|
|
|
|
|
// Falls through into SubState 4
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-20 13:49:50 +02:00
|
|
|
int16_t delta_y = abs(GetLocation().y - GetDestination().y);
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(); loc.has_value())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
auto newZ = ride->getStation(CurrentRideStation).GetBaseZ();
|
2019-08-15 18:32:19 +01:00
|
|
|
if (delta_y < 20)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
newZ += ride->getRideTypeDescriptor().Heights.PlatformHeight;
|
2019-08-15 18:32:19 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), newZ });
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Inspecting);
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 0;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C0CB8
|
|
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::UpdateAnswering()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2023-01-17 01:32:54 +01:00
|
|
|
auto ride = GetRide(CurrentRide);
|
2025-03-09 00:26:25 +01:00
|
|
|
if (ride == nullptr || ride->mechanicStatus != RIDE_MECHANIC_STATUS_HEADING)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
if (SubState == 0)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-30 18:19:10 -03:00
|
|
|
Action = PeepActionType::StaffAnswerCall;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 1;
|
2023-01-17 21:16:36 +00:00
|
|
|
PeepWindowStateUpdate(this);
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
if (SubState == 1)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2021-05-11 10:15:02 +03:00
|
|
|
if (IsActionWalking())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 2;
|
2023-01-17 21:16:36 +00:00
|
|
|
PeepWindowStateUpdate(this);
|
2020-06-06 11:24:29 -03:00
|
|
|
MechanicTimeSinceCall = 0;
|
2020-09-16 20:22:36 -04:00
|
|
|
ResetPathfindGoal();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2019-08-15 18:32:19 +01:00
|
|
|
UpdateAction();
|
2019-08-21 12:31:05 +02:00
|
|
|
Invalidate();
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
if (SubState <= 3)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-06-06 11:24:29 -03:00
|
|
|
MechanicTimeSinceCall++;
|
|
|
|
|
if (MechanicTimeSinceCall > 2500)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
ride->mechanicStatus = RIDE_MECHANIC_STATUS_CALLING;
|
|
|
|
|
ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_MAINTENANCE;
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CheckForPath())
|
|
|
|
|
return;
|
|
|
|
|
|
2022-10-09 11:01:10 +02:00
|
|
|
if (ShouldWaitForLevelCrossing() && !IsMechanicHeadingToFixRideBlockingPath())
|
2022-09-24 07:44:19 +02:00
|
|
|
return;
|
|
|
|
|
|
2025-03-20 18:48:26 +02:00
|
|
|
const auto [pathingResult, rideEntranceExitElement] = PerformNextAction();
|
2018-04-02 18:00:36 +01:00
|
|
|
if (!(pathingResult & PATHING_RIDE_EXIT) && !(pathingResult & PATHING_RIDE_ENTRANCE))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-12-03 23:45:43 +01:00
|
|
|
|
2020-06-07 22:21:53 -03:00
|
|
|
if (CurrentRide != rideEntranceExitElement->AsEntrance()->GetRideIndex())
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
2022-01-26 13:28:19 +01:00
|
|
|
StationIndex exitIndex = rideEntranceExitElement->AsEntrance()->GetStationIndex();
|
|
|
|
|
if (CurrentRideStation != exitIndex)
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (pathingResult & PATHING_RIDE_ENTRANCE)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
if (!ride->getStation(exitIndex).Exit.IsNull())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
PeepDirection = rideEntranceExitElement->GetDirection();
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
int32_t destX = NextLoc.x + 16 + DirectionOffsets[PeepDirection].x * 53;
|
|
|
|
|
int32_t destY = NextLoc.y + 16 + DirectionOffsets[PeepDirection].y * 53;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination({ destX, destY }, 2);
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = PeepDirection << 3;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2023-01-19 20:36:30 +01:00
|
|
|
z = rideEntranceExitElement->BaseHeight * 4;
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 4;
|
|
|
|
|
// Falls through into SubState 4
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-10 20:47:11 +02:00
|
|
|
int16_t delta_y = abs(y - GetDestination().y);
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(); loc.has_value())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
auto newZ = ride->getStation(CurrentRideStation).GetBaseZ();
|
2019-08-15 18:32:19 +01:00
|
|
|
if (delta_y < 20)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
newZ += ride->getRideTypeDescriptor().Heights.PlatformHeight;
|
2019-08-15 18:32:19 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), newZ });
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Fixing);
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = 0;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** rct2: 0x00992A5C */
|
2025-01-19 16:59:45 +01:00
|
|
|
static constexpr CoordsXY kWateringUseOffsets[] = {
|
2018-04-02 18:00:36 +01:00
|
|
|
{ 3, 16 }, { 16, 29 }, { 29, 16 }, { 16, 3 }, { 3, 29 }, { 29, 29 }, { 29, 3 }, { 3, 3 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF483
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
bool Staff::UpdatePatrollingFindWatering()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!(StaffOrders & STAFF_ORDERS_WATER_FLOWERS))
|
|
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
uint8_t chosen_position = ScenarioRand() & 7;
|
2018-06-20 17:28:51 +02:00
|
|
|
for (int32_t i = 0; i < 8; ++i, ++chosen_position)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
chosen_position &= 7;
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
auto chosenLoc = CoordsXY{ NextLoc } + CoordsDirectionDelta[chosen_position];
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
TileElement* tile_element = MapGetFirstElementAt(chosenLoc);
|
2018-04-02 18:00:36 +01:00
|
|
|
|
|
|
|
|
// This seems to happen in some SV4 files.
|
|
|
|
|
if (tile_element == nullptr)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tile_element->GetType() != TileElementType::SmallScenery)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
auto z_diff = abs(NextLoc.z - tile_element->GetBaseZ());
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2024-07-26 18:23:25 +10:00
|
|
|
if (z_diff >= 4 * kCoordsZStep)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-04 02:14:41 +01:00
|
|
|
auto* sceneryEntry = tile_element->AsSmallScenery()->GetEntry();
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2021-10-01 21:50:05 +02:00
|
|
|
if (sceneryEntry == nullptr || !sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_CAN_BE_WATERED))
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-01 12:00:32 +02:00
|
|
|
if (tile_element->AsSmallScenery()->GetAge() < kSceneryWitherAgeThreshold2)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
if (chosen_position >= 4)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-01 12:00:32 +02:00
|
|
|
if (tile_element->AsSmallScenery()->GetAge() < kSceneryWitherAgeThreshold1)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Watering);
|
2020-09-27 20:07:09 -04:00
|
|
|
Var37 = chosen_position;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
SubState = 0;
|
2025-01-19 16:59:45 +01:00
|
|
|
auto destination = kWateringUseOffsets[chosen_position] + GetLocation().ToTileStart();
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(destination, 3);
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
return true;
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(tile_element++)->IsLastForTile());
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF3A1
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
bool Staff::UpdatePatrollingFindBin()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!(StaffOrders & STAFF_ORDERS_EMPTY_BINS))
|
|
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (GetNextIsSurface())
|
|
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
TileElement* tileElement = MapGetFirstElementAt(NextLoc);
|
2018-05-24 11:44:53 +02:00
|
|
|
if (tileElement == nullptr)
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2018-05-24 11:44:53 +02:00
|
|
|
for (;; tileElement++)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() == TileElementType::Path && (tileElement->GetBaseZ() == NextLoc.z))
|
2018-04-02 18:00:36 +01:00
|
|
|
break;
|
|
|
|
|
|
2018-05-24 11:44:53 +02:00
|
|
|
if (tileElement->IsLastForTile())
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
2018-09-16 17:08:15 +02:00
|
|
|
if (!tileElement->AsPath()->HasAddition())
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2021-06-03 21:23:00 +01:00
|
|
|
auto* pathAddEntry = tileElement->AsPath()->GetAdditionEntry();
|
|
|
|
|
if (pathAddEntry == nullptr)
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2023-05-09 21:08:25 +02:00
|
|
|
if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN))
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2019-02-26 09:29:25 +00:00
|
|
|
if (tileElement->AsPath()->IsBroken())
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2018-09-16 16:46:23 +02:00
|
|
|
if (tileElement->AsPath()->AdditionIsGhost())
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2018-10-05 13:11:44 +02:00
|
|
|
uint8_t bin_positions = tileElement->AsPath()->GetEdges();
|
2018-10-05 12:49:26 +02:00
|
|
|
uint8_t bin_quantity = tileElement->AsPath()->GetAdditionStatus();
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t chosen_position = 0;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
|
|
|
|
for (; chosen_position < 4; ++chosen_position)
|
|
|
|
|
{
|
|
|
|
|
if (!(bin_positions & 1) && !(bin_quantity & 3))
|
|
|
|
|
break;
|
|
|
|
|
bin_positions >>= 1;
|
|
|
|
|
bin_quantity >>= 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chosen_position == 4)
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
Var37 = chosen_position;
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::EmptyingBin);
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
SubState = 0;
|
2021-02-10 20:47:11 +02:00
|
|
|
auto destination = BinUseOffsets[chosen_position] + GetLocation().ToTileStart();
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(destination, 3);
|
2020-09-27 20:07:09 -04:00
|
|
|
return true;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF322
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
bool Staff::UpdatePatrollingFindGrass()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!(StaffOrders & STAFF_ORDERS_MOWING))
|
|
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (StaffMowingTimeout < 12)
|
|
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!(GetNextIsSurface()))
|
|
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
auto surfaceElement = MapGetSurfaceElementAt(NextLoc);
|
2018-12-11 23:31:06 +00:00
|
|
|
if (surfaceElement != nullptr && surfaceElement->CanGrassGrow())
|
|
|
|
|
{
|
|
|
|
|
if ((surfaceElement->GetGrassLength() & 0x7) >= GRASS_LENGTH_CLEAR_1)
|
|
|
|
|
{
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Mowing);
|
2020-09-27 20:07:09 -04:00
|
|
|
Var37 = 0;
|
2018-12-11 23:31:06 +00:00
|
|
|
// Original code used .y for both x and y. Changed to .x to make more sense (both x and y are 28)
|
2021-02-10 20:47:11 +02:00
|
|
|
|
2025-01-19 16:59:45 +01:00
|
|
|
auto destination = kMowingWaypoints[0] + NextLoc;
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(destination, 3);
|
2020-09-27 20:07:09 -04:00
|
|
|
return true;
|
2018-12-11 23:31:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF295
|
|
|
|
|
*/
|
2020-09-27 20:07:09 -04:00
|
|
|
bool Staff::UpdatePatrollingFindSweeping()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
if (!(StaffOrders & STAFF_ORDERS_SWEEPING))
|
|
|
|
|
return false;
|
|
|
|
|
auto quad = EntityTileList<Litter>({ x, y });
|
2020-06-08 20:13:50 +01:00
|
|
|
for (auto litter : quad)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-09-27 20:07:09 -04:00
|
|
|
uint16_t z_diff = abs(z - litter->z);
|
2018-04-02 18:00:36 +01:00
|
|
|
|
|
|
|
|
if (z_diff >= 16)
|
|
|
|
|
continue;
|
|
|
|
|
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Sweeping);
|
2020-06-06 11:32:37 +01:00
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
Var37 = 0;
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(litter->GetLocation(), 5);
|
2020-09-27 20:07:09 -04:00
|
|
|
return true;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
return false;
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
|
|
|
|
|
2025-07-15 12:02:37 +02:00
|
|
|
bool Staff::SecurityGuardPathIsCrowded() const
|
|
|
|
|
{
|
|
|
|
|
// Iterate over tiles within a 3-tile radius (96 units)
|
|
|
|
|
constexpr auto kTileRadius = 3;
|
|
|
|
|
constexpr auto kLookupRadius = kCoordsXYStep * kTileRadius;
|
|
|
|
|
constexpr auto kSecurityPathCrowdedThreshold = 20;
|
|
|
|
|
|
|
|
|
|
int16_t guestCount = 0;
|
|
|
|
|
|
|
|
|
|
for (int32_t tileX = x - kLookupRadius; tileX <= x + kLookupRadius; tileX += kCoordsXYStep)
|
|
|
|
|
{
|
|
|
|
|
for (int32_t tileY = y - kLookupRadius; tileY <= y + kLookupRadius; tileY += kCoordsXYStep)
|
|
|
|
|
{
|
|
|
|
|
for (auto* guest : EntityTileList<Guest>({ tileX, tileY }))
|
|
|
|
|
{
|
|
|
|
|
if (guest->x == kLocationNull)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
int16_t zDist = std::abs(z - guest->z);
|
|
|
|
|
if (zDist > kTileRadius / 2)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
int16_t xDist = std::abs(x - guest->x);
|
|
|
|
|
if (xDist > kLookupRadius)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
int16_t yDist = std::abs(y - guest->y);
|
|
|
|
|
if (yDist > kLookupRadius)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!guest->IsActionWalking())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
guestCount++;
|
|
|
|
|
if (guestCount >= kSecurityPathCrowdedThreshold)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::Tick128UpdateStaff()
|
2018-04-04 00:14:29 +02:00
|
|
|
{
|
2020-08-16 18:25:32 -04:00
|
|
|
if (AssignedStaffType != StaffType::Security)
|
2018-04-04 00:14:29 +02:00
|
|
|
return;
|
|
|
|
|
|
2025-07-15 12:02:37 +02:00
|
|
|
// Alternate between walking animations based on crowd size
|
|
|
|
|
auto newAnimationGroup = PeepAnimationGroup::Normal;
|
|
|
|
|
if (State == PeepState::Patrolling && SecurityGuardPathIsCrowded())
|
|
|
|
|
newAnimationGroup = PeepAnimationGroup::Alternate;
|
2018-04-04 00:14:29 +02:00
|
|
|
|
2024-09-22 16:54:33 +02:00
|
|
|
if (AnimationGroup == newAnimationGroup)
|
2018-04-04 00:14:29 +02:00
|
|
|
return;
|
|
|
|
|
|
2024-09-22 16:54:33 +02:00
|
|
|
AnimationGroup = newAnimationGroup;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2024-09-22 16:10:04 +02:00
|
|
|
WalkingAnimationFrameNum = 0;
|
2021-05-11 09:44:41 +03:00
|
|
|
if (Action < PeepActionType::Idle)
|
|
|
|
|
Action = PeepActionType::Walking;
|
2018-04-04 00:14:29 +02:00
|
|
|
|
2024-12-23 12:21:04 +01:00
|
|
|
auto& objManager = GetContext()->GetObjectManager();
|
|
|
|
|
auto* animObj = objManager.GetLoadedObject<PeepAnimationsObject>(AnimationObjectIndex);
|
|
|
|
|
|
2025-07-15 12:02:37 +02:00
|
|
|
// NB: security staff have two animations groups: one regular, and one slow-walking
|
2020-05-31 17:45:52 -03:00
|
|
|
PeepFlags &= ~PEEP_FLAGS_SLOW_WALK;
|
2024-12-23 12:21:04 +01:00
|
|
|
if (animObj->IsSlowWalking(newAnimationGroup))
|
2018-04-04 00:14:29 +02:00
|
|
|
{
|
2020-05-31 17:45:52 -03:00
|
|
|
PeepFlags |= PEEP_FLAGS_SLOW_WALK;
|
2018-04-04 00:14:29 +02:00
|
|
|
}
|
|
|
|
|
|
2024-09-22 16:08:58 +02:00
|
|
|
AnimationType = PeepAnimationType::Invalid;
|
|
|
|
|
UpdateCurrentAnimationType();
|
2018-04-04 00:14:29 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-28 19:28:58 +00:00
|
|
|
bool Staff::IsMechanic() const
|
2018-04-26 17:15:29 +02:00
|
|
|
{
|
2021-02-21 12:23:31 +00:00
|
|
|
return AssignedStaffType == StaffType::Mechanic;
|
2018-04-26 17:15:29 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-21 17:15:38 +03:00
|
|
|
void Staff::Update()
|
|
|
|
|
{
|
|
|
|
|
if (PeepFlags & PEEP_FLAGS_POSITION_FROZEN)
|
|
|
|
|
{
|
|
|
|
|
if (!(PeepFlags & PEEP_FLAGS_ANIMATION_FROZEN))
|
|
|
|
|
{
|
|
|
|
|
// This is circumventing other logic, so only update every few ticks
|
|
|
|
|
if ((getGameState().currentTicks & 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (IsActionWalking())
|
|
|
|
|
UpdateWalkingAnimation();
|
|
|
|
|
else
|
|
|
|
|
UpdateActionAnimation();
|
|
|
|
|
Invalidate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (PeepFlags & PEEP_FLAGS_ANIMATION_FROZEN)
|
|
|
|
|
{
|
|
|
|
|
// Animation is frozen while position is not. This allows a peep to walk
|
|
|
|
|
// around without its sprite being updated, which looks very glitchy.
|
|
|
|
|
// We'll just remove the flag and continue as normal, in this case.
|
|
|
|
|
PeepFlags &= ~PEEP_FLAGS_ANIMATION_FROZEN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Walking speed logic
|
2025-05-21 17:28:05 +03:00
|
|
|
const auto stepsToTake = GetStepsToTake();
|
|
|
|
|
const auto carryCheck = StepProgress + stepsToTake;
|
2025-05-21 17:15:38 +03:00
|
|
|
StepProgress = carryCheck;
|
2025-05-21 17:28:05 +03:00
|
|
|
|
2025-05-21 17:15:38 +03:00
|
|
|
if (carryCheck <= 255)
|
|
|
|
|
{
|
2025-05-21 17:23:30 +03:00
|
|
|
// No-op: Keep replay working for now, can be eliminate with a replay update.
|
2025-05-21 17:15:38 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Loc68FD2F
|
|
|
|
|
switch (State)
|
|
|
|
|
{
|
|
|
|
|
case PeepState::Falling:
|
|
|
|
|
UpdateFalling();
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::One:
|
|
|
|
|
Update1();
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::OnRide:
|
|
|
|
|
// No action
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::Picked:
|
|
|
|
|
UpdatePicked();
|
|
|
|
|
break;
|
2025-05-21 17:32:35 +03:00
|
|
|
case PeepState::Patrolling:
|
|
|
|
|
UpdatePatrolling();
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::Mowing:
|
|
|
|
|
UpdateMowing();
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::Sweeping:
|
|
|
|
|
UpdateSweeping();
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::Answering:
|
|
|
|
|
UpdateAnswering();
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::Fixing:
|
|
|
|
|
UpdateFixing(stepsToTake);
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::Inspecting:
|
|
|
|
|
UpdateFixing(stepsToTake);
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::EmptyingBin:
|
|
|
|
|
UpdateEmptyingBin();
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::Watering:
|
|
|
|
|
UpdateWatering();
|
|
|
|
|
break;
|
|
|
|
|
case PeepState::HeadingToInspection:
|
|
|
|
|
UpdateHeadingToInspect();
|
|
|
|
|
break;
|
2025-05-21 17:15:38 +03:00
|
|
|
default:
|
2025-05-21 17:32:35 +03:00
|
|
|
// TODO reset to default state
|
|
|
|
|
assert(false);
|
2025-05-21 17:15:38 +03:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-02 18:00:36 +01:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006BF1FD
|
|
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::UpdatePatrolling()
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
|
|
|
|
if (!CheckForPath())
|
|
|
|
|
return;
|
|
|
|
|
|
2022-10-09 11:01:10 +02:00
|
|
|
if (ShouldWaitForLevelCrossing() && !IsMechanicHeadingToFixRideBlockingPath())
|
2022-09-24 07:44:19 +02:00
|
|
|
return;
|
|
|
|
|
|
2025-03-20 18:48:26 +02:00
|
|
|
const auto [pathingResult, _] = PerformNextAction();
|
2018-04-02 18:00:36 +01:00
|
|
|
if (!(pathingResult & PATHING_DESTINATION_REACHED))
|
|
|
|
|
return;
|
|
|
|
|
|
2018-04-04 18:50:07 +01:00
|
|
|
if (GetNextIsSurface())
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2022-10-11 19:39:24 +01:00
|
|
|
auto surfaceElement = MapGetSurfaceElementAt(NextLoc);
|
2018-04-02 18:00:36 +01:00
|
|
|
|
2019-08-11 09:06:04 +01:00
|
|
|
if (surfaceElement != nullptr)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2019-08-11 09:06:04 +01:00
|
|
|
int32_t water_height = surfaceElement->GetWaterHeight();
|
2020-01-19 16:12:48 +01:00
|
|
|
if (water_height > 0)
|
2018-04-02 18:00:36 +01:00
|
|
|
{
|
2020-05-11 12:36:45 +02:00
|
|
|
MoveTo({ x, y, water_height });
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-16 18:25:32 -04:00
|
|
|
if (AssignedStaffType != StaffType::Handyman)
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (UpdatePatrollingFindSweeping())
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (UpdatePatrollingFindGrass())
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
if (UpdatePatrollingFindBin())
|
2018-04-02 18:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
2020-09-27 20:07:09 -04:00
|
|
|
UpdatePatrollingFindWatering();
|
2018-04-02 18:00:36 +01:00
|
|
|
}
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-04-06 14:27:22 +02:00
|
|
|
enum
|
|
|
|
|
{
|
2018-06-22 23:04:19 +02:00
|
|
|
PEEP_FIXING_ENTER_STATION = 0,
|
|
|
|
|
PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE = 1,
|
2018-04-06 14:27:22 +02:00
|
|
|
PEEP_FIXING_FIX_VEHICLE_CLOSED_RESTRAINTS = 2,
|
2018-06-22 23:04:19 +02:00
|
|
|
PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS = 3,
|
|
|
|
|
PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS = 4,
|
|
|
|
|
PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS = 5,
|
|
|
|
|
PEEP_FIXING_FIX_VEHICLE_MALFUNCTION = 6,
|
|
|
|
|
PEEP_FIXING_MOVE_TO_STATION_END = 7,
|
|
|
|
|
PEEP_FIXING_FIX_STATION_END = 8,
|
|
|
|
|
PEEP_FIXING_MOVE_TO_STATION_START = 9,
|
|
|
|
|
PEEP_FIXING_FIX_STATION_START = 10,
|
|
|
|
|
PEEP_FIXING_FIX_STATION_BRAKES = 11,
|
|
|
|
|
PEEP_FIXING_MOVE_TO_STATION_EXIT = 12,
|
|
|
|
|
PEEP_FIXING_FINISH_FIX_OR_INSPECT = 13,
|
|
|
|
|
PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT = 14,
|
2018-04-03 17:46:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-06 14:27:22 +02:00
|
|
|
* FixingSubstatesForBreakdown[] defines the applicable peep sub_states for
|
2025-03-09 00:26:25 +01:00
|
|
|
* mechanics fixing a ride. The array is indexed by breakdownReason:
|
2018-04-03 17:46:08 +01:00
|
|
|
* - indexes 0-7 are the 8 breakdown reasons (see BREAKDOWN_* in Ride.h)
|
|
|
|
|
* when fixing a broken down ride;
|
|
|
|
|
* - index 8 is for inspecting a ride.
|
|
|
|
|
*/
|
2018-07-11 00:49:11 +02:00
|
|
|
// clang-format off
|
2023-06-24 11:45:26 +02:00
|
|
|
static constexpr uint32_t FixingSubstatesForBreakdown[9] = {
|
2018-06-22 23:04:19 +02:00
|
|
|
( // BREAKDOWN_SAFETY_CUT_OUT
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_END) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_STATION_END) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_START) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_STATION_START) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
|
|
|
|
),
|
2018-06-22 23:04:19 +02:00
|
|
|
( // BREAKDOWN_RESTRAINTS_STUCK_CLOSED
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_VEHICLE_CLOSED_RESTRAINTS) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
|
|
|
|
),
|
2018-06-22 23:04:19 +02:00
|
|
|
( // BREAKDOWN_RESTRAINTS_STUCK_OPEN
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
|
|
|
|
),
|
2018-06-22 23:04:19 +02:00
|
|
|
( // BREAKDOWN_DOORS_STUCK_CLOSED
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
|
|
|
|
),
|
2018-06-22 23:04:19 +02:00
|
|
|
( // BREAKDOWN_DOORS_STUCK_OPEN
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
|
|
|
|
),
|
2018-06-22 23:04:19 +02:00
|
|
|
( // BREAKDOWN_VEHICLE_MALFUNCTION
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_VEHICLE_MALFUNCTION) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
|
|
|
|
),
|
2018-06-22 23:04:19 +02:00
|
|
|
( // BREAKDOWN_BRAKES_FAILURE
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_START) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_STATION_BRAKES) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
|
|
|
|
),
|
2018-06-22 23:04:19 +02:00
|
|
|
( // BREAKDOWN_CONTROL_FAILURE
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_END) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_STATION_END) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_START) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_STATION_START) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
|
|
|
|
),
|
2018-06-22 23:04:19 +02:00
|
|
|
( // INSPECTION
|
2018-07-11 00:49:11 +02:00
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_END) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_STATION_END) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_START) |
|
|
|
|
|
(1 << PEEP_FIXING_FIX_STATION_START) |
|
|
|
|
|
(1 << PEEP_FIXING_MOVE_TO_STATION_EXIT) |
|
|
|
|
|
(1 << PEEP_FIXING_FINISH_FIX_OR_INSPECT) |
|
|
|
|
|
(1 << PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT)
|
2021-10-17 15:31:56 +02:00
|
|
|
),
|
2018-04-03 17:46:08 +01:00
|
|
|
};
|
2018-07-11 00:49:11 +02:00
|
|
|
// clang-format on
|
2018-04-03 17:46:08 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x006C0E8B
|
|
|
|
|
* Also used by inspecting.
|
|
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
void Staff::UpdateFixing(int32_t steps)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2023-01-17 01:32:54 +01:00
|
|
|
auto ride = GetRide(CurrentRide);
|
2019-08-08 22:58:56 +01:00
|
|
|
if (ride == nullptr)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-03 17:46:08 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool progressToNextSubstate = true;
|
2018-06-22 23:04:19 +02:00
|
|
|
bool firstRun = true;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2020-09-28 20:51:49 +02:00
|
|
|
if ((State == PeepState::Inspecting)
|
2025-03-09 00:26:25 +01:00
|
|
|
&& (ride->lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)))
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
// Ride has broken down since Mechanic was called to inspect it.
|
|
|
|
|
// Mechanic identifies the breakdown and switches to fixing it.
|
2020-09-28 20:51:49 +02:00
|
|
|
State = PeepState::Fixing;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (progressToNextSubstate)
|
|
|
|
|
{
|
2020-06-14 02:31:08 -03:00
|
|
|
switch (SubState)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_ENTER_STATION:
|
2020-06-14 02:31:08 -03:00
|
|
|
NextFlags &= ~PEEP_NEXT_FLAG_IS_SLOPED;
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingEnterStation(*ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_MOVE_TO_BROKEN_DOWN_VEHICLE:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingMoveToBrokenDownVehicle(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_FIX_VEHICLE_CLOSED_RESTRAINTS:
|
|
|
|
|
case PEEP_FIXING_FIX_VEHICLE_CLOSED_DOORS:
|
|
|
|
|
case PEEP_FIXING_FIX_VEHICLE_OPEN_RESTRAINTS:
|
|
|
|
|
case PEEP_FIXING_FIX_VEHICLE_OPEN_DOORS:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingFixVehicle(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_FIX_VEHICLE_MALFUNCTION:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingFixVehicleMalfunction(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_MOVE_TO_STATION_END:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingMoveToStationEnd(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_FIX_STATION_END:
|
|
|
|
|
progressToNextSubstate = UpdateFixingFixStationEnd(firstRun);
|
|
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_MOVE_TO_STATION_START:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingMoveToStationStart(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_FIX_STATION_START:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingFixStationStart(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_FIX_STATION_BRAKES:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingFixStationBrakes(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_MOVE_TO_STATION_EXIT:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingMoveToStationExit(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_FINISH_FIX_OR_INSPECT:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingFinishFixOrInspect(firstRun, steps, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
case PEEP_FIXING_LEAVE_BY_ENTRANCE_EXIT:
|
2023-01-07 14:02:18 +01:00
|
|
|
progressToNextSubstate = UpdateFixingLeaveByEntranceExit(firstRun, *ride);
|
2018-06-22 23:04:19 +02:00
|
|
|
break;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2018-06-22 23:04:19 +02:00
|
|
|
default:
|
2023-01-17 13:24:51 +01:00
|
|
|
LOG_ERROR("Invalid substate");
|
2018-06-22 23:04:19 +02:00
|
|
|
progressToNextSubstate = false;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
firstRun = false;
|
|
|
|
|
|
|
|
|
|
if (!progressToNextSubstate)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
int32_t subState = SubState;
|
2018-06-20 17:28:51 +02:00
|
|
|
uint32_t sub_state_sequence_mask = FixingSubstatesForBreakdown[8];
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2020-09-28 20:51:49 +02:00
|
|
|
if (State != PeepState::Inspecting)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
sub_state_sequence_mask = FixingSubstatesForBreakdown[ride->breakdownReasonPending];
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
subState++;
|
|
|
|
|
} while ((sub_state_sequence_mask & (1 << subState)) == 0);
|
|
|
|
|
|
2020-06-14 02:31:08 -03:00
|
|
|
SubState = subState & 0xFF;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C0EEC
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: enter_station - applies to fixing all break down reasons and ride inspections.
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingEnterStation(Ride& ride) const
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
ride.mechanicStatus = RIDE_MECHANIC_STATUS_FIXING;
|
|
|
|
|
ride.windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_MAINTENANCE;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C0F09
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: move_to_broken_down_vehicle - applies to fixing all vehicle specific breakdown reasons
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, const Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2023-01-17 01:32:54 +01:00
|
|
|
Vehicle* vehicle = RideGetBrokenVehicle(ride);
|
2018-04-03 17:46:08 +01:00
|
|
|
if (vehicle == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
2019-02-25 17:58:22 +00:00
|
|
|
if (vehicle->IsHead())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-22 11:33:55 +01:00
|
|
|
auto trackType = vehicle->GetTrackType();
|
2023-01-17 01:32:54 +01:00
|
|
|
if (TrackTypeIsStation(trackType))
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-31 07:48:27 +01:00
|
|
|
vehicle = GetEntity<Vehicle>(vehicle->prev_vehicle_on_ride);
|
|
|
|
|
if (vehicle == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
CoordsXY offset = DirectionOffsets[PeepDirection];
|
2021-02-10 20:47:11 +02:00
|
|
|
auto destination = (offset * -12) + vehicle->GetLocation();
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(destination, 2);
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(); loc.has_value())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), z });
|
2018-04-03 17:46:08 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C0FD3
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: fix_vehicle - applies to fixing vehicle with:
|
2018-04-03 17:46:08 +01:00
|
|
|
* 1. restraints stuck closed,
|
|
|
|
|
* 2. doors stuck closed,
|
|
|
|
|
* 3. restrains stuck open,
|
|
|
|
|
* 4. doors stuck open.
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingFixVehicle(bool firstRun, const Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = PeepDirection << 3;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2023-01-17 20:46:55 +01:00
|
|
|
Action = (ScenarioRand() & 1) ? PeepActionType::StaffFix2 : PeepActionType::StaffFix;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-11 10:15:02 +03:00
|
|
|
if (IsActionWalking())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-06 14:27:22 +02:00
|
|
|
UpdateAction();
|
2019-08-21 12:31:05 +02:00
|
|
|
Invalidate();
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2020-09-30 18:19:10 -03:00
|
|
|
uint8_t actionFrame = (Action == PeepActionType::StaffFix) ? 0x25 : 0x50;
|
2024-09-22 16:12:04 +02:00
|
|
|
if (AnimationFrameNum != actionFrame)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 01:32:54 +01:00
|
|
|
Vehicle* vehicle = RideGetBrokenVehicle(ride);
|
2018-04-03 17:46:08 +01:00
|
|
|
if (vehicle == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-12 14:32:16 -08:00
|
|
|
vehicle->ClearFlag(VehicleFlags::CarIsBroken);
|
2018-04-03 17:46:08 +01:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C107B
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: fix_vehicle_malfunction - applies fixing to vehicle malfunction.
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingFixVehicleMalfunction(bool firstRun, const Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = PeepDirection << 3;
|
2020-09-30 18:19:10 -03:00
|
|
|
Action = PeepActionType::StaffFix3;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-11 10:15:02 +03:00
|
|
|
if (IsActionWalking())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-06 14:27:22 +02:00
|
|
|
UpdateAction();
|
2019-08-21 12:31:05 +02:00
|
|
|
Invalidate();
|
|
|
|
|
|
2024-09-22 16:12:04 +02:00
|
|
|
if (AnimationFrameNum != 0x65)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 01:32:54 +01:00
|
|
|
Vehicle* vehicle = RideGetBrokenVehicle(ride);
|
2018-04-03 17:46:08 +01:00
|
|
|
if (vehicle == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-12 14:32:16 -08:00
|
|
|
vehicle->ClearFlag(VehicleFlags::TrainIsBroken);
|
2018-04-03 17:46:08 +01:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** rct2: 0x00992A3C */
|
2025-01-19 16:59:45 +01:00
|
|
|
static constexpr CoordsXY kStationFixingOffsets[] = {
|
2018-04-03 17:46:08 +01:00
|
|
|
{ -12, 0 },
|
|
|
|
|
{ 0, 12 },
|
|
|
|
|
{ 12, 0 },
|
|
|
|
|
{ 0, -12 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C1114
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: move_to_station_end - applies to fixing station specific breakdowns: safety cut-out, control failure,
|
2018-06-22 23:04:19 +02:00
|
|
|
* inspection.
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingMoveToStationEnd(bool firstRun, const Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation)
|
|
|
|
|
|| !ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack))
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-09 00:26:25 +01:00
|
|
|
auto stationPos = ride.getStation(CurrentRideStation).GetStart();
|
2021-09-09 01:48:53 +02:00
|
|
|
if (stationPos.IsNull())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 13:14:45 +01:00
|
|
|
auto tileElement = MapGetTrackElementAt(stationPos);
|
2018-04-03 17:46:08 +01:00
|
|
|
if (tileElement == nullptr)
|
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
LOG_ERROR("Couldn't find tile_element");
|
2018-04-03 17:46:08 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-14 11:14:19 +02:00
|
|
|
int32_t trackDirection = tileElement->GetDirection();
|
2025-01-19 16:59:45 +01:00
|
|
|
CoordsXY offset = kStationFixingOffsets[trackDirection];
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2019-12-23 09:08:46 -03:00
|
|
|
stationPos.x += 16 + offset.x;
|
2018-04-03 17:46:08 +01:00
|
|
|
if (offset.x == 0)
|
|
|
|
|
{
|
2021-02-10 20:47:11 +02:00
|
|
|
stationPos.x = GetDestination().x;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2019-12-23 09:08:46 -03:00
|
|
|
stationPos.y += 16 + offset.y;
|
2018-04-03 17:46:08 +01:00
|
|
|
if (offset.y == 0)
|
|
|
|
|
{
|
2021-02-10 20:47:11 +02:00
|
|
|
stationPos.y = GetDestination().y;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(stationPos, 2);
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(); loc.has_value())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), z });
|
2019-08-15 18:32:19 +01:00
|
|
|
return false;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-15 18:32:19 +01:00
|
|
|
return true;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C11F5
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: fix_station_end - applies to fixing station specific breakdowns: safety cut-out, control failure,
|
2018-06-22 23:04:19 +02:00
|
|
|
* inspection.
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2019-02-28 19:28:58 +00:00
|
|
|
bool Staff::UpdateFixingFixStationEnd(bool firstRun)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = PeepDirection << 3;
|
2024-09-22 16:18:41 +02:00
|
|
|
Action = PeepActionType::StaffCheckBoard;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-11 10:15:02 +03:00
|
|
|
if (IsActionWalking())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-06 14:27:22 +02:00
|
|
|
UpdateAction();
|
2019-08-21 12:31:05 +02:00
|
|
|
Invalidate();
|
2018-04-03 17:46:08 +01:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C1239
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: move_to_station_start
|
2018-04-03 17:46:08 +01:00
|
|
|
* 1. applies to fixing station specific breakdowns: safety cut-out, control failure,
|
|
|
|
|
* 2. applies to fixing brake failure,
|
|
|
|
|
* 3. applies to inspection.
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingMoveToStationStart(bool firstRun, const Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation)
|
|
|
|
|
|| !ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack))
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-09 00:26:25 +01:00
|
|
|
auto stationPosition = ride.getStation(CurrentRideStation).GetStart();
|
2021-09-09 01:48:53 +02:00
|
|
|
if (stationPosition.IsNull())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CoordsXYE input;
|
2019-12-27 15:57:40 +01:00
|
|
|
input.x = stationPosition.x;
|
|
|
|
|
input.y = stationPosition.y;
|
2022-10-12 13:14:45 +01:00
|
|
|
input.element = MapGetTrackElementAtFromRide({ input.x, input.y, stationPosition.z }, CurrentRide);
|
2018-04-03 17:46:08 +01:00
|
|
|
if (input.element == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 21:38:26 +01:00
|
|
|
Direction stationDirection = 0;
|
2023-01-20 20:58:55 +00:00
|
|
|
TrackBeginEnd trackBeginEnd;
|
2023-01-17 01:32:54 +01:00
|
|
|
while (TrackBlockGetPrevious(input, &trackBeginEnd))
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2020-06-05 22:55:15 +02:00
|
|
|
if (trackBeginEnd.begin_element->AsTrack()->IsStation())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2018-06-22 23:04:19 +02:00
|
|
|
input.x = trackBeginEnd.begin_x;
|
|
|
|
|
input.y = trackBeginEnd.begin_y;
|
2018-04-03 17:46:08 +01:00
|
|
|
input.element = trackBeginEnd.begin_element;
|
|
|
|
|
|
2018-09-14 11:14:19 +02:00
|
|
|
stationDirection = trackBeginEnd.begin_element->GetDirection();
|
2018-04-03 17:46:08 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 19:05:14 +01:00
|
|
|
// Loc6C12ED:
|
2021-02-10 20:47:11 +02:00
|
|
|
auto destination = CoordsXY{ input.x + 16, input.y + 16 };
|
2025-01-19 16:59:45 +01:00
|
|
|
auto offset = kStationFixingOffsets[stationDirection];
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2021-02-10 20:47:11 +02:00
|
|
|
destination.x -= offset.x;
|
2018-04-03 17:46:08 +01:00
|
|
|
if (offset.x == 0)
|
|
|
|
|
{
|
2021-02-10 20:47:11 +02:00
|
|
|
destination.x = GetDestination().x;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-10 20:47:11 +02:00
|
|
|
destination.y -= offset.y;
|
2018-04-03 17:46:08 +01:00
|
|
|
if (offset.y == 0)
|
|
|
|
|
{
|
2021-02-10 20:47:11 +02:00
|
|
|
destination.y = GetDestination().y;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(destination, 2);
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(); loc.has_value())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), z });
|
2019-08-15 18:32:19 +01:00
|
|
|
return false;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-15 18:32:19 +01:00
|
|
|
return true;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C1368
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: fix_station_start
|
2018-04-03 17:46:08 +01:00
|
|
|
* 1. applies to fixing station specific breakdowns: safety cut-out, control failure,
|
|
|
|
|
* 2. applies to inspection.
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingFixStationStart(bool firstRun, const Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation)
|
|
|
|
|
|| !ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack))
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = PeepDirection << 3;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2020-09-30 18:19:10 -03:00
|
|
|
Action = PeepActionType::StaffFix;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-11 10:15:02 +03:00
|
|
|
if (IsActionWalking())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-06 14:27:22 +02:00
|
|
|
UpdateAction();
|
2018-04-03 17:46:08 +01:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C13CE
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: fix_station_brakes - applies to fixing brake failure
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingFixStationBrakes(bool firstRun, Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = PeepDirection << 3;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2020-09-30 18:19:10 -03:00
|
|
|
Action = PeepActionType::StaffFixGround;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-11 10:15:02 +03:00
|
|
|
if (IsActionWalking())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-06 14:27:22 +02:00
|
|
|
UpdateAction();
|
2019-08-21 12:31:05 +02:00
|
|
|
Invalidate();
|
|
|
|
|
|
2024-09-22 16:12:04 +02:00
|
|
|
if (AnimationFrameNum == 0x28)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
ride.mechanicStatus = RIDE_MECHANIC_STATUS_HAS_FIXED_STATION_BRAKES;
|
|
|
|
|
ride.windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_MAINTENANCE;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2024-09-22 16:12:04 +02:00
|
|
|
if (AnimationFrameNum == 0x13 || AnimationFrameNum == 0x19 || AnimationFrameNum == 0x1F || AnimationFrameNum == 0x25
|
|
|
|
|
|| AnimationFrameNum == 0x2B)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2021-09-28 03:16:04 +03:00
|
|
|
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::MechanicFix, GetLocation());
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C1474
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: move_to_station_exit - applies to fixing all failures & inspections
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingMoveToStationExit(bool firstRun, const Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
auto stationPosition = ride.getStation(CurrentRideStation).Exit.ToCoordsXY();
|
2021-09-09 01:48:53 +02:00
|
|
|
if (stationPosition.IsNull())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
stationPosition = ride.getStation(CurrentRideStation).Entrance.ToCoordsXY();
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2021-09-09 01:48:53 +02:00
|
|
|
if (stationPosition.IsNull())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-13 12:03:43 +01:00
|
|
|
stationPosition = stationPosition.ToTileCentre();
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
CoordsXY stationPlatformDirection = DirectionOffsets[PeepDirection];
|
2020-03-13 12:03:43 +01:00
|
|
|
stationPosition.x += stationPlatformDirection.x * 20;
|
|
|
|
|
stationPosition.y += stationPlatformDirection.y * 20;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(stationPosition, 2);
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(); loc.has_value())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), z });
|
2019-08-15 18:32:19 +01:00
|
|
|
return false;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
|
|
|
return true;
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C1504
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: finish_fix_or_inspect - applies to fixing all failures & inspections
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2020-09-28 20:51:49 +02:00
|
|
|
if (State == PeepState::Inspecting)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2020-06-07 22:21:53 -03:00
|
|
|
UpdateRideInspected(CurrentRide);
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2025-02-02 17:44:12 -03:00
|
|
|
StaffRidesInspected = AddClamp(StaffRidesInspected, 1u);
|
2020-06-08 22:25:54 -03:00
|
|
|
WindowInvalidateFlags |= RIDE_INVALIDATE_RIDE_INCOME | RIDE_INVALIDATE_RIDE_LIST;
|
2025-03-09 00:26:25 +01:00
|
|
|
ride.mechanicStatus = RIDE_MECHANIC_STATUS_UNDEFINED;
|
2018-04-03 17:46:08 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-02 17:44:12 -03:00
|
|
|
StaffRidesFixed = AddClamp(StaffRidesFixed, 1u);
|
2020-06-08 22:25:54 -03:00
|
|
|
WindowInvalidateFlags |= RIDE_INVALIDATE_RIDE_INCOME | RIDE_INVALIDATE_RIDE_LIST;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2023-04-07 22:46:25 +03:00
|
|
|
Orientation = PeepDirection << 3;
|
2020-09-30 18:19:10 -03:00
|
|
|
Action = PeepActionType::StaffAnswerCall2;
|
2024-09-22 16:12:04 +02:00
|
|
|
AnimationFrameNum = 0;
|
2024-09-22 16:13:49 +02:00
|
|
|
AnimationImageIdOffset = 0;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2024-09-22 16:08:58 +02:00
|
|
|
UpdateCurrentAnimationType();
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-11 10:15:02 +03:00
|
|
|
if (!IsActionWalking())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2018-04-06 14:27:22 +02:00
|
|
|
UpdateAction();
|
2019-08-21 12:31:05 +02:00
|
|
|
Invalidate();
|
2018-04-03 17:46:08 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 01:32:54 +01:00
|
|
|
RideFixBreakdown(ride, steps);
|
2025-03-09 00:26:25 +01:00
|
|
|
ride.mechanicStatus = RIDE_MECHANIC_STATUS_UNDEFINED;
|
2018-04-03 17:46:08 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x006C157E
|
2020-06-14 02:31:08 -03:00
|
|
|
* fixing SubState: leave_by_entrance_exit - applies to fixing all failures & inspections
|
2018-04-06 14:27:22 +02:00
|
|
|
* - see FixingSubstatesForBreakdown[]
|
2018-04-03 17:46:08 +01:00
|
|
|
*/
|
2023-01-07 14:02:18 +01:00
|
|
|
bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, const Ride& ride)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
|
|
|
|
if (!firstRun)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
auto exitPosition = ride.getStation(CurrentRideStation).Exit.ToCoordsXY();
|
2021-09-09 01:48:53 +02:00
|
|
|
if (exitPosition.IsNull())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
exitPosition = ride.getStation(CurrentRideStation).Entrance.ToCoordsXY();
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2021-09-09 01:48:53 +02:00
|
|
|
if (exitPosition.IsNull())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-03 17:46:08 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-13 12:03:43 +01:00
|
|
|
exitPosition = exitPosition.ToTileCentre();
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2020-06-06 11:12:11 -03:00
|
|
|
CoordsXY ebx_direction = DirectionOffsets[PeepDirection];
|
2020-03-13 12:03:43 +01:00
|
|
|
exitPosition.x -= ebx_direction.x * 19;
|
|
|
|
|
exitPosition.y -= ebx_direction.y * 19;
|
2018-04-03 17:46:08 +01:00
|
|
|
|
2021-02-10 21:18:27 +02:00
|
|
|
SetDestination(exitPosition, 2);
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-15 18:32:19 +01:00
|
|
|
int16_t xy_distance;
|
2021-09-13 19:47:13 +03:00
|
|
|
if (auto loc = UpdateAction(xy_distance); loc.has_value())
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
auto stationHeight = ride.getStation(CurrentRideStation).GetBaseZ();
|
2019-08-15 18:32:19 +01:00
|
|
|
if (xy_distance >= 16)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
stationHeight += ride.getRideTypeDescriptor().Heights.PlatformHeight;
|
2019-08-15 18:32:19 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-13 19:47:13 +03:00
|
|
|
MoveTo({ loc.value(), stationHeight });
|
2018-04-03 17:46:08 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2020-09-28 20:51:49 +02:00
|
|
|
SetState(PeepState::Falling);
|
2018-04-03 17:46:08 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* rct2: 0x6B7588
|
|
|
|
|
*/
|
2022-01-19 15:17:11 +02:00
|
|
|
void Staff::UpdateRideInspected(RideId rideIndex)
|
2018-04-03 17:46:08 +01:00
|
|
|
{
|
2023-01-17 01:32:54 +01:00
|
|
|
auto ride = GetRide(rideIndex);
|
2019-08-08 22:58:56 +01:00
|
|
|
if (ride != nullptr)
|
|
|
|
|
{
|
2025-03-09 00:26:25 +01:00
|
|
|
ride->lifecycleFlags &= ~RIDE_LIFECYCLE_DUE_INSPECTION;
|
|
|
|
|
ride->reliability += ((100 - ride->reliabilityPercentage) / 4) * (ScenarioRand() & 0xFF);
|
|
|
|
|
ride->lastInspection = 0;
|
|
|
|
|
ride->windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_MAINTENANCE | RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST;
|
2019-08-08 22:58:56 +01:00
|
|
|
}
|
2018-04-03 17:46:08 +01:00
|
|
|
}
|
2021-01-25 21:57:06 +00:00
|
|
|
|
2023-03-02 22:55:42 +01:00
|
|
|
money64 GetStaffWage(StaffType type)
|
2021-01-25 21:57:06 +00:00
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case StaffType::Handyman:
|
2021-02-28 20:44:47 -07:00
|
|
|
return 50.00_GBP;
|
2021-01-25 21:57:06 +00:00
|
|
|
case StaffType::Mechanic:
|
2021-02-28 20:44:47 -07:00
|
|
|
return 80.00_GBP;
|
2021-01-25 21:57:06 +00:00
|
|
|
case StaffType::Security:
|
2021-02-28 20:44:47 -07:00
|
|
|
return 60.00_GBP;
|
2021-01-25 21:57:06 +00:00
|
|
|
case StaffType::Entertainer:
|
2021-02-28 20:44:47 -07:00
|
|
|
return 55.00_GBP;
|
2021-01-25 21:57:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-11-25 23:25:04 -08:00
|
|
|
|
|
|
|
|
void Staff::Serialise(DataSerialiser& stream)
|
|
|
|
|
{
|
|
|
|
|
Peep::Serialise(stream);
|
|
|
|
|
stream << AssignedStaffType;
|
|
|
|
|
stream << MechanicTimeSinceCall;
|
|
|
|
|
stream << HireDate;
|
|
|
|
|
stream << StaffOrders;
|
|
|
|
|
stream << StaffMowingTimeout;
|
|
|
|
|
stream << StaffLawnsMown;
|
|
|
|
|
stream << StaffGardensWatered;
|
|
|
|
|
stream << StaffLitterSwept;
|
|
|
|
|
stream << StaffBinsEmptied;
|
|
|
|
|
}
|