mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 11:33:03 +01:00
Introduce methods from NSF
These methods still call the same legacy functionality for now
This commit is contained in:
@@ -530,7 +530,7 @@ void window_staff_overview_mousedown(rct_window* w, rct_widgetindex widgetIndex,
|
||||
}
|
||||
|
||||
// Disable clear patrol area if no area is set.
|
||||
if (gStaffModes[peep->StaffId] != StaffMode::Patrol)
|
||||
if (!peep->HasPatrolArea())
|
||||
{
|
||||
Dropdown::SetDisabled(1, true);
|
||||
}
|
||||
@@ -568,12 +568,8 @@ void window_staff_overview_dropdown(rct_window* w, rct_widgetindex widgetIndex,
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int32_t i = 0; i < STAFF_PATROL_AREA_SIZE; i++)
|
||||
{
|
||||
gStaffPatrolAreas[peep->StaffId * STAFF_PATROL_AREA_SIZE + i] = 0;
|
||||
}
|
||||
assert(gStaffModes[peep->StaffId] == StaffMode::Patrol);
|
||||
gStaffModes[peep->StaffId] = StaffMode::Walk;
|
||||
// TODO: THIS SHOULD BE NETWORKED
|
||||
peep->ClearPatrolArea();
|
||||
|
||||
gfx_invalidate_screen();
|
||||
staff_update_greyed_patrol_areas();
|
||||
|
||||
@@ -414,7 +414,7 @@ public:
|
||||
DrawTextEllipsised(&dpi, { actionOffset, y }, actionColumnSize, format, ft);
|
||||
|
||||
// True if a patrol path is set for the worker
|
||||
if (gStaffModes[peep->StaffId] == StaffMode::Patrol)
|
||||
if (peep->HasPatrolArea())
|
||||
{
|
||||
gfx_draw_sprite(&dpi, ImageId(SPR_STAFF_PATROL_PATH), { nameColumnSize + 5, y });
|
||||
}
|
||||
@@ -566,7 +566,7 @@ private:
|
||||
|
||||
if (isPatrolAreaSet)
|
||||
{
|
||||
if (gStaffModes[peep->StaffId] != StaffMode::Patrol)
|
||||
if (!peep->HasPatrolArea())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -63,14 +63,13 @@ GameActions::Result::Ptr StaffSetPatrolAreaAction::Execute() const
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_NONE);
|
||||
}
|
||||
|
||||
int32_t patrolOffset = staff->StaffId * STAFF_PATROL_AREA_SIZE;
|
||||
|
||||
staff_toggle_patrol_area(staff->StaffId, _loc);
|
||||
staff->TogglePatrolArea(_loc);
|
||||
|
||||
bool isPatrolling = false;
|
||||
for (int32_t i = 0; i < 128; i++)
|
||||
const auto peepOffset = staff->StaffId * STAFF_PATROL_AREA_SIZE;
|
||||
for (int32_t i = peepOffset; i < peepOffset + STAFF_PATROL_AREA_SIZE; i++)
|
||||
{
|
||||
if (gStaffPatrolAreas[patrolOffset + i])
|
||||
if (gStaffPatrolAreas[i] != 0)
|
||||
{
|
||||
isPatrolling = true;
|
||||
break;
|
||||
|
||||
@@ -881,6 +881,11 @@ public:
|
||||
static void ResetStats();
|
||||
void Serialise(DataSerialiser& stream);
|
||||
|
||||
void ClearPatrolArea();
|
||||
void TogglePatrolArea(const CoordsXY& coords);
|
||||
void SetPatrolArea(const CoordsXY& coords, bool value);
|
||||
bool HasPatrolArea() const;
|
||||
|
||||
private:
|
||||
void UpdatePatrolling();
|
||||
void UpdateMowing();
|
||||
|
||||
@@ -174,7 +174,7 @@ bool Staff::IsLocationInPatrol(const CoordsXY& loc) const
|
||||
return false;
|
||||
|
||||
// Check if staff has patrol area
|
||||
if (gStaffModes[StaffId] != StaffMode::Patrol)
|
||||
if (!HasPatrolArea())
|
||||
return true;
|
||||
|
||||
return IsPatrolAreaSet(loc);
|
||||
@@ -392,9 +392,9 @@ bool staff_is_patrol_area_set_for_type(StaffType type, const CoordsXY& coords)
|
||||
return staff_is_patrol_area_set(STAFF_MAX_COUNT + static_cast<uint8_t>(type), coords);
|
||||
}
|
||||
|
||||
void staff_set_patrol_area(int32_t staffIndex, const CoordsXY& coords, bool value)
|
||||
void Staff::SetPatrolArea(const CoordsXY& coords, bool value)
|
||||
{
|
||||
int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE;
|
||||
int32_t peepOffset = StaffId * STAFF_PATROL_AREA_SIZE;
|
||||
auto [offset, bitIndex] = getPatrolAreaOffsetIndex(coords);
|
||||
uint32_t* addr = &gStaffPatrolAreas[peepOffset + offset];
|
||||
if (value)
|
||||
@@ -407,13 +407,38 @@ void staff_set_patrol_area(int32_t staffIndex, const CoordsXY& coords, bool valu
|
||||
}
|
||||
}
|
||||
|
||||
void staff_toggle_patrol_area(int32_t staffIndex, const CoordsXY& coords)
|
||||
void Staff::ClearPatrolArea()
|
||||
{
|
||||
int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE;
|
||||
const auto peepOffset = StaffId * STAFF_PATROL_AREA_SIZE;
|
||||
std::fill_n(&gStaffPatrolAreas[peepOffset], STAFF_PATROL_AREA_SIZE, 0);
|
||||
gStaffModes[StaffId] = StaffMode::Walk;
|
||||
}
|
||||
|
||||
void Staff::TogglePatrolArea(const CoordsXY& coords)
|
||||
{
|
||||
int32_t peepOffset = StaffId * STAFF_PATROL_AREA_SIZE;
|
||||
auto [offset, bitIndex] = getPatrolAreaOffsetIndex(coords);
|
||||
gStaffPatrolAreas[peepOffset + offset] ^= (1 << bitIndex);
|
||||
}
|
||||
|
||||
bool Staff::HasPatrolArea() const
|
||||
{
|
||||
if (gStaffModes[StaffId] != StaffMode::Patrol)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto peepOffset = StaffId * STAFF_PATROL_AREA_SIZE;
|
||||
for (int32_t i = peepOffset; i < peepOffset + STAFF_PATROL_AREA_SIZE; i++)
|
||||
{
|
||||
if (gStaffPatrolAreas[i] != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006BFBE8
|
||||
|
||||
@@ -65,8 +65,6 @@ void staff_set_name(uint16_t spriteIndex, const char* name);
|
||||
bool staff_hire_new_member(StaffType staffType, EntertainerCostume entertainerType);
|
||||
void staff_update_greyed_patrol_areas();
|
||||
bool staff_is_patrol_area_set_for_type(StaffType type, const CoordsXY& coords);
|
||||
void staff_set_patrol_area(int32_t staffIndex, const CoordsXY& coords, bool value);
|
||||
void staff_toggle_patrol_area(int32_t staffIndex, const CoordsXY& coords);
|
||||
colour_t staff_get_colour(StaffType staffType);
|
||||
bool staff_set_colour(StaffType staffType, colour_t value);
|
||||
uint32_t staff_get_available_entertainer_costumes();
|
||||
|
||||
@@ -1293,7 +1293,7 @@ namespace RCT1
|
||||
x <<= 7;
|
||||
int32_t y = val & 0x3E0;
|
||||
y <<= 2;
|
||||
staff_set_patrol_area(staffmember->StaffId, { x, y }, true);
|
||||
staffmember->SetPatrolArea({ x, y }, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user