Remove references to old game command

This commit is contained in:
duncanspumpkin 2019-03-01 17:27:04 +00:00
parent bcced4016f
commit 29de97f5b1
5 changed files with 24 additions and 342 deletions

View File

@ -1277,7 +1277,7 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = {
nullptr,
nullptr,
nullptr,
game_command_place_footpath,
nullptr,
game_command_place_footpath_from_track,
nullptr,
game_command_change_surface_style,

View File

@ -35,7 +35,7 @@ enum GAME_COMMAND
GAME_COMMAND_REMOVE_SCENERY, // GA
GAME_COMMAND_PLACE_SCENERY, // GA
GAME_COMMAND_SET_WATER_HEIGHT, // GA
GAME_COMMAND_PLACE_PATH,
GAME_COMMAND_PLACE_PATH, // GA
GAME_COMMAND_PLACE_PATH_FROM_TRACK,
GAME_COMMAND_REMOVE_PATH,
GAME_COMMAND_CHANGE_SURFACE_STYLE,

View File

@ -240,8 +240,8 @@ private:
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
if (!entrancePath
&& !map_can_construct_with_clear_at(
_loc.x, _loc.y, zLow, zHigh, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &res->Cost,
crossingMode))
_loc.x, _loc.y, zLow, zHigh, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &res->Cost,
crossingMode))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_FOOTPATH_HERE, gGameCommandErrorText, gCommonFormatArgs);
}
@ -306,8 +306,8 @@ private:
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
if (!entrancePath
&& !map_can_construct_with_clear_at(
_loc.x, _loc.y, zLow, zHigh, &map_place_non_scenery_clear_func, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(), &res->Cost,
crossingMode))
_loc.x, _loc.y, zLow, zHigh, &map_place_non_scenery_clear_func, quarterTile,
GAME_COMMAND_FLAG_APPLY | GetFlags(), &res->Cost, crossingMode))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_FOOTPATH_HERE, gGameCommandErrorText, gCommonFormatArgs);
}
@ -434,4 +434,22 @@ private:
footpath_update_queue_chains();
map_invalidate_tile_full(_loc.x, _loc.y);
}
PathElement* map_get_footpath_element_slope(int32_t x, int32_t y, int32_t z, int32_t slope) const
{
TileElement* tileElement;
bool isSloped = slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
tileElement = map_get_first_element_at(x, y);
do
{
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->base_height == z
&& (tileElement->AsPath()->IsSloped() == isSloped)
&& (tileElement->AsPath()->GetSlopeDirection() == (slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)))
{
return tileElement->AsPath();
}
} while (!(tileElement++)->IsLastForTile());
return nullptr;
}
};

View File

@ -110,39 +110,6 @@ static bool entrance_has_direction(TileElement* tileElement, int32_t direction)
return entrance_get_directions(tileElement) & (1 << (direction & 3));
}
/**
*
* rct2: 0x006A65AD
*/
static void automatically_set_peep_spawn(CoordsXYZ location)
{
uint8_t direction = 0;
if (location.x != 32)
{
direction++;
if (location.y != gMapSizeUnits - 32)
{
direction++;
if (location.x != gMapSizeUnits - 32)
{
direction++;
if (location.y != 32)
return;
}
}
}
if (gPeepSpawns.size() == 0)
{
gPeepSpawns.emplace_back();
}
PeepSpawn* peepSpawn = &gPeepSpawns[0];
peepSpawn->x = location.x + (word_981D6C[direction].x * 15) + 16;
peepSpawn->y = location.y + (word_981D6C[direction].y * 15) + 16;
peepSpawn->direction = direction;
peepSpawn->z = location.z;
}
TileElement* map_get_footpath_element(int32_t x, int32_t y, int32_t z)
{
TileElement* tileElement;
@ -157,285 +124,11 @@ TileElement* map_get_footpath_element(int32_t x, int32_t y, int32_t z)
return nullptr;
}
PathElement* map_get_footpath_element_slope(int32_t x, int32_t y, int32_t z, int32_t slope)
{
TileElement* tileElement;
bool isSloped = slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
tileElement = map_get_first_element_at(x, y);
do
{
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->base_height == z
&& (tileElement->AsPath()->IsSloped() == isSloped)
&& (tileElement->AsPath()->GetSlopeDirection() == (slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)))
{
return tileElement->AsPath();
}
} while (!(tileElement++)->IsLastForTile());
return nullptr;
}
static void loc_6A6620(int32_t flags, int32_t x, int32_t y, TileElement* tileElement)
{
if (tileElement->AsPath()->IsSloped() && !(flags & GAME_COMMAND_FLAG_GHOST))
{
int32_t direction = tileElement->AsPath()->GetSlopeDirection();
int32_t z = tileElement->base_height;
wall_remove_intersecting_walls(x, y, z, z + 6, direction_reverse(direction));
wall_remove_intersecting_walls(x, y, z, z + 6, direction);
// Removing walls may have made the pointer invalid, so find it again
tileElement = map_get_footpath_element(x / 32, y / 32, z);
}
if (!(flags & GAME_COMMAND_FLAG_PATH_SCENERY))
footpath_connect_edges(x, y, tileElement, flags);
footpath_update_queue_chains();
map_invalidate_tile_full(x, y);
}
/** rct2: 0x0098D7EC */
static constexpr const QuarterTile SlopedFootpathQuarterTiles[] = {
{ 0b1111, 0b1100 }, { 0b1111, 0b1001 }, { 0b1111, 0b0011 }, { 0b1111, 0b0110 }
};
static money32 footpath_element_insert(
int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t flags, uint8_t pathItemType)
{
TileElement* tileElement;
EntranceElement* entranceElement;
int32_t zHigh;
bool entrancePath = false, entranceIsSamePath = false;
if (!map_check_free_elements_and_reorganise(1))
return MONEY32_UNDEFINED;
if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST)))
footpath_remove_litter(x, y, gCommandPosition.z);
// loc_6A649D:
gFootpathPrice += MONEY(12, 00);
QuarterTile quarterTile{ 0b1111, 0 };
zHigh = z + 4;
if (slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = SlopedFootpathQuarterTiles[slope & TILE_ELEMENT_DIRECTION_MASK];
zHigh += 2;
}
entranceElement = map_get_park_entrance_element_at(x, y, z, false);
// Make sure the entrance part is the middle
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
{
entrancePath = true;
// Make the price the same as replacing a path
if (entranceElement->GetPathType() == (type & 0xF))
entranceIsSamePath = true;
else
gFootpathPrice -= MONEY(6, 00);
}
// Do not attempt to build a crossing with a queue or a sloped.
uint8_t crossingMode = (type & FOOTPATH_ELEMENT_INSERT_QUEUE) || (slope != TILE_ELEMENT_SLOPE_FLAT)
? CREATE_CROSSING_MODE_NONE
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
if (!entrancePath
&& !map_can_construct_with_clear_at(
x, y, z, zHigh, &map_place_non_scenery_clear_func, quarterTile, flags, &gFootpathPrice, crossingMode))
return MONEY32_UNDEFINED;
gFootpathGroundFlags = gMapGroundFlags;
if (!gCheatsDisableClearanceChecks && (gMapGroundFlags & ELEMENT_IS_UNDERWATER))
{
gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER;
return MONEY32_UNDEFINED;
}
tileElement = map_get_surface_element_at({ x, y });
if (tileElement == nullptr)
{
return MONEY32_UNDEFINED;
}
int32_t supportHeight = z - tileElement->base_height;
gFootpathPrice += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / 2) * MONEY(5, 00);
if (flags & GAME_COMMAND_FLAG_APPLY)
{
if (entrancePath)
{
if (!(flags & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath)
{
// Set the path type but make sure it's not a queue as that will not show up
entranceElement->SetPathType(type & 0x7F);
map_invalidate_tile_full(x, y);
}
}
else
{
tileElement = tile_element_insert(x / 32, y / 32, z, 0x0F);
assert(tileElement != nullptr);
tileElement->SetType(TILE_ELEMENT_TYPE_PATH);
PathElement* pathElement = tileElement->AsPath();
pathElement->clearance_height = z + 4 + ((slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) ? 2 : 0);
pathElement->SetPathEntryIndex(type);
pathElement->SetSlopeDirection(slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
if (slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
pathElement->SetSloped(true);
if (type & FOOTPATH_ELEMENT_INSERT_QUEUE)
pathElement->SetIsQueue(true);
pathElement->SetAddition(pathItemType);
pathElement->SetRideIndex(RIDE_ID_NULL);
pathElement->SetAdditionStatus(255);
pathElement->SetIsBroken(false);
if (flags & GAME_COMMAND_FLAG_GHOST)
pathElement->SetGhost(true);
footpath_queue_chain_reset();
if (!(flags & GAME_COMMAND_FLAG_PATH_SCENERY))
footpath_remove_edges_at(x, y, tileElement);
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !(flags & GAME_COMMAND_FLAG_GHOST))
automatically_set_peep_spawn({ x, y, tileElement->base_height * 8 });
loc_6A6620(flags, x, y, tileElement);
}
}
// Prevent the place sound from being spammed
if (entranceIsSamePath)
gFootpathPrice = 0;
return gParkFlags & PARK_FLAGS_NO_MONEY ? 0 : gFootpathPrice;
}
static money32 footpath_element_update(
int32_t x, int32_t y, TileElement* tileElement, int32_t type, int32_t flags, uint8_t pathItemType)
{
const int32_t newFootpathType = (type & (FOOTPATH_PROPERTIES_TYPE_MASK >> 4));
const bool newPathIsQueue = ((type >> 7) == 1);
if (tileElement->AsPath()->GetPathEntryIndex() != newFootpathType || tileElement->AsPath()->IsQueue() != newPathIsQueue)
{
gFootpathPrice += MONEY(6, 00);
}
else if (pathItemType != 0)
{
Guard::Assert(false, "No longer in use. Use FootpathScenery{Place/Remove}Action.");
}
if (flags & GAME_COMMAND_FLAG_4)
return MONEY32_UNDEFINED;
if (flags & GAME_COMMAND_FLAG_APPLY)
{
footpath_queue_chain_reset();
if (!(flags & GAME_COMMAND_FLAG_PATH_SCENERY))
footpath_remove_edges_at(x, y, tileElement);
tileElement->AsPath()->SetPathEntryIndex(type);
if (type & (1 << 7))
tileElement->AsPath()->SetIsQueue(true);
else
tileElement->AsPath()->SetIsQueue(false);
tileElement->AsPath()->SetAddition(pathItemType);
tileElement->AsPath()->SetIsBroken(false);
loc_6A6620(flags, x, y, tileElement);
}
return gParkFlags & PARK_FLAGS_NO_MONEY ? 0 : gFootpathPrice;
}
static money32 footpath_place_real(
int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t flags, uint8_t pathItemType, bool clearDirection,
int32_t direction)
{
TileElement* tileElement;
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
gCommandPosition.x = x + 16;
gCommandPosition.y = y + 16;
gCommandPosition.z = z * 8;
if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode)
{
gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
return MONEY32_UNDEFINED;
}
if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_GHOST))
footpath_interrupt_peeps(x, y, z * 8);
gFootpathPrice = 0;
gFootpathGroundFlags = 0;
if (map_is_edge({ x, y }))
{
gGameCommandErrorText = STR_OFF_EDGE_OF_MAP;
return MONEY32_UNDEFINED;
}
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(x, y, z * 8))
return MONEY32_UNDEFINED;
if (slope & SLOPE_IS_IRREGULAR_FLAG)
{
gGameCommandErrorText = STR_LAND_SLOPE_UNSUITABLE;
return MONEY32_UNDEFINED;
}
if (z < 2)
{
gGameCommandErrorText = STR_TOO_LOW;
return MONEY32_UNDEFINED;
}
if (z > 248)
{
gGameCommandErrorText = STR_TOO_HIGH;
return MONEY32_UNDEFINED;
}
// Force ride construction to recheck area
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_RECHECK;
if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST))
{
LocationXYZ16 coord;
coord.x = x + 16;
coord.y = y + 16;
coord.z = tile_element_height(coord.x, coord.y);
network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord);
if (clearDirection && !gCheatsDisableClearanceChecks)
{
direction = direction & 0xF;
// It is possible, let's remove walls between the old and new piece of path
wall_remove_intersecting_walls(
x, y, z, z + 4 + ((slope & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK) ? 2 : 0), direction_reverse(direction));
wall_remove_intersecting_walls(
x - CoordsDirectionDelta[direction].x, y - CoordsDirectionDelta[direction].y, z, z + 4, direction);
}
}
footpath_provisional_remove();
tileElement = (TileElement*)map_get_footpath_element_slope((x / 32), (y / 32), z, slope);
if (tileElement == nullptr)
{
return footpath_element_insert(type, x, y, z, slope, flags, pathItemType);
}
else
{
return footpath_element_update(x, y, tileElement, type, flags, pathItemType);
}
}
/**
*
* rct2: 0x006BA23E
@ -455,18 +148,6 @@ void remove_banners_at_element(int32_t x, int32_t y, TileElement* tileElement)
}
}
/**
*
* rct2: 0x006A61DE
*/
void game_command_place_footpath(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, int32_t* edi, int32_t* ebp)
{
*ebx = footpath_place_real(
(*edx >> 8) & 0xFF, *eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, (*ebx >> 8) & 0xFF, *ebx & 0xFF, *edi & 0xFF,
(*ebp & FOOTPATH_CLEAR_DIRECTIONAL) >> 8, *ebp & 0xFF);
}
static money32 footpath_place_from_track(
int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t edges, int32_t flags)
{
@ -632,18 +313,6 @@ void game_command_place_footpath_from_track(
(*ebx >> 8) & 0xF, *ebx & 0xFF);
}
money32 footpath_place(int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t flags)
{
return game_do_command(x, (slope << 8) | flags, y, (type << 8) | z, GAME_COMMAND_PLACE_PATH, 0, 0);
}
money32 footpath_place_remove_intersecting(
int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t flags, int32_t direction)
{
return game_do_command(
x, (slope << 8) | flags, y, (type << 8) | z, GAME_COMMAND_PLACE_PATH, 0, FOOTPATH_CLEAR_DIRECTIONAL | direction);
}
money32 footpath_remove(int32_t x, int32_t y, int32_t z, int32_t flags)
{
auto action = FootpathRemoveAction(x, y, z);

View File

@ -173,15 +173,10 @@ TileElement* map_get_footpath_element(int32_t x, int32_t y, int32_t z);
struct PathElement;
PathElement* map_get_footpath_element_slope(int32_t x, int32_t y, int32_t z, int32_t slope);
void footpath_interrupt_peeps(int32_t x, int32_t y, int32_t z);
void game_command_place_footpath(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
void game_command_place_footpath_from_track(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
void game_command_remove_footpath(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
money32 footpath_place(int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t flags);
money32 footpath_place_remove_intersecting(
int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t flags, int32_t direction);
money32 footpath_remove(int32_t x, int32_t y, int32_t z, int32_t flags);
money32 footpath_provisional_set(int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope);
void footpath_provisional_remove();