1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 13:03:11 +01:00

Remove uses of GET_PEEP macro and replace with GetEntity (#12467)

* Use TryGetEntity and GetEntity instead of macro

* Use GetEntity for ui guest window

* Remove final GET_PEEP macro uses

* Fix remaining issues
This commit is contained in:
Duncan
2020-07-26 17:42:02 +01:00
committed by GitHub
parent ba10b84789
commit 8a378ad236
26 changed files with 501 additions and 273 deletions

View File

@@ -469,12 +469,14 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv)
int_val[0] = console_parse_int(argv[2], &int_valid[0]);
int_val[1] = console_parse_int(argv[3], &int_valid[1]);
if (int_valid[0] && int_valid[1] && ((GET_PEEP(int_val[0])) != nullptr))
if (int_valid[0] && int_valid[1])
{
Peep* peep = GET_PEEP(int_val[0]);
peep->Energy = int_val[1];
peep->EnergyTarget = int_val[1];
Peep* peep = GetEntity<Peep>(int_val[0]);
if (peep != nullptr)
{
peep->Energy = int_val[1];
peep->EnergyTarget = int_val[1];
}
}
}
else if (argv[1] == "costume")
@@ -483,16 +485,18 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv)
bool int_valid[2] = { false };
int_val[0] = console_parse_int(argv[2], &int_valid[0]);
int_val[1] = console_parse_int(argv[3], &int_valid[1]);
Peep* peep = nullptr;
if (!int_valid[0])
{
console.WriteLineError("Invalid staff ID");
return 1;
}
peep = GET_PEEP(int_val[0]);
bool is_entertainer = peep != nullptr && peep->AssignedPeepType == PeepType::Staff
&& peep->StaffType == STAFF_TYPE_ENTERTAINER;
if (!is_entertainer)
auto staff = GetEntity<Staff>(int_val[0]);
if (staff == nullptr)
{
console.WriteLineError("Invalid staff ID");
return 1;
}
if (staff->StaffType != STAFF_TYPE_ENTERTAINER)
{
console.WriteLineError("Specified staff is not entertainer");
return 1;