From d84fb5655bf17b112b6b75c0099e2932dfd01ccf Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Wed, 31 Dec 2014 17:18:28 +0000 Subject: [PATCH 08/14] change VoxelWorld & WorldAdditions --- src/coaster.cpp | 8 ++++---- src/fence_build.cpp | 4 ++-- src/map.cpp | 6 +++--- src/map.h | 46 ++++++++++++++++++---------------------------- src/path.cpp | 40 ++++++++++++++++------------------------ src/path_build.cpp | 24 ++++++++++++------------ src/path_finding.cpp | 6 +++--- src/people.cpp | 2 +- src/person.cpp | 22 +++++++++++----------- src/ride_gui.cpp | 6 +++--- src/ride_type.cpp | 4 ++-- src/terraform.cpp | 2 +- src/track_piece.cpp | 2 +- src/viewport.cpp | 2 +- 14 files changed, 78 insertions(+), 96 deletions(-) diff --git a/src/coaster.cpp b/src/coaster.cpp index 5e3b7bb..cf2c079 100644 --- a/src/coaster.cpp +++ b/src/coaster.cpp @@ -258,7 +258,7 @@ void DisplayCoasterCar::Set(int16 xvoxel, int16 yvoxel, int8 zvoxel, int16 xpos, if (this->yaw != 0xff && change_voxel) { /* Valid data, and changing voxel -> remove self from the old voxel. */ this->MarkDirty(); - Voxel *v = _world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false); + Voxel *v = _world.GetCreateVoxel(this->vox_pos, false); this->RemoveSelf(v); } @@ -279,7 +279,7 @@ void DisplayCoasterCar::Set(int16 xvoxel, int16 yvoxel, int8 zvoxel, int16 xpos, this->MarkDirty(); // Voxel or orientation has changed, repaint the possibly new voxel. if (change_voxel) { // With a really new voxel, also add self to the new voxel. - Voxel *v = _world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false); + Voxel *v = _world.GetCreateVoxel(this->vox_pos, false); this->AddSelf(v); } } @@ -791,7 +791,7 @@ void CoasterInstance::PlaceTrackPieceInAdditions(const PositionedTrackPiece &pla const CoasterType *ct = this->GetCoasterType(); const TrackVoxel *tvx = placed.piece->track_voxels; for (int i = 0; i < placed.piece->voxel_count; i++) { - Voxel *vx = _additions.GetCreateVoxel(placed.base_voxel.x + tvx->dx, placed.base_voxel.y + tvx->dy, placed.base_voxel.z + tvx->dz, true); + Voxel *vx = _additions.GetCreateVoxel(XYZPoint16(placed.base_voxel.x + tvx->dx, placed.base_voxel.y + tvx->dy, placed.base_voxel.z + tvx->dz), true); // assert(vx->CanPlaceInstance()): Checked by this->CanBePlaced(). vx->SetInstance(ride_number); vx->SetInstanceData(ct->GetTrackVoxelIndex(tvx)); @@ -807,7 +807,7 @@ void CoasterInstance::RemoveTrackPieceInAdditions(const PositionedTrackPiece &pl { const TrackVoxel *tvx = placed.piece->track_voxels; for (int i = 0; i < placed.piece->voxel_count; i++) { - Voxel *vx = _additions.GetCreateVoxel(placed.base_voxel.x + tvx->dx, placed.base_voxel.y + tvx->dy, placed.base_voxel.z + tvx->dz, false); + Voxel *vx = _additions.GetCreateVoxel(XYZPoint16(placed.base_voxel.x + tvx->dx, placed.base_voxel.y + tvx->dy, placed.base_voxel.z + tvx->dz), false); assert(vx->GetInstance() == (SmallRideInstance)this->GetIndex()); vx->SetInstance(SRI_FREE); vx->SetInstanceData(0); // Not really needed. diff --git a/src/fence_build.cpp b/src/fence_build.cpp index fe2de15..7e5849d 100644 --- a/src/fence_build.cpp +++ b/src/fence_build.cpp @@ -73,7 +73,7 @@ void FenceBuildManager::SetCursors() FinderData fdata(CS_GROUND_EDGE, FW_EDGE); if (vp->ComputeCursorPosition(&fdata) != CS_NONE && fdata.cursor >= CUR_TYPE_EDGE_NE && fdata.cursor <= CUR_TYPE_EDGE_NW) { TileEdge edge = (TileEdge)((uint8)fdata.cursor - (uint8)CUR_TYPE_EDGE_NE); - const Voxel *v = _world.GetVoxel(fdata.voxel_pos.x, fdata.voxel_pos.y, fdata.voxel_pos.z); + const Voxel *v = _world.GetVoxel(fdata.voxel_pos); assert(v != nullptr); TileSlope slope = ExpandTileSlope(v->GetGroundSlope()); /* @@ -85,7 +85,7 @@ void FenceBuildManager::SetCursors() int32 extra_z = 0; if ((slope & TSB_TOP) == 0 && IsRaisedEdge(edge, slope)) { extra_z = 1; - v = _world.GetCreateVoxel(fdata.voxel_pos.x, fdata.voxel_pos.y, fdata.voxel_pos.z + extra_z, true); + v = _world.GetCreateVoxel(XYZPoint16(fdata.voxel_pos.x, fdata.voxel_pos.y, fdata.voxel_pos.z + extra_z), true); assert(v != nullptr); } const SpriteStorage *ss = _sprite_manager.GetSprites(vp->tile_width); diff --git a/src/map.cpp b/src/map.cpp index e96a2d5..5b3ebf1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -125,7 +125,7 @@ VoxelObject::~VoxelObject() { if (this->added) { this->MarkDirty(); - Voxel *v = _world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false); + Voxel *v = _world.GetCreateVoxel(this->vox_pos, false); this->RemoveSelf(v); } } @@ -286,7 +286,7 @@ void VoxelWorld::SetWorldSize(uint16 xs, uint16 ys) static void AddFoundations(VoxelWorld *world, uint16 xpos, uint16 ypos, int16 z, uint8 bits) { for (int16 zpos = 0; zpos < z; zpos++) { - Voxel *v = world->GetCreateVoxel(xpos, ypos, zpos, true); + Voxel *v = world->GetCreateVoxel(XYZPoint16(xpos, ypos, zpos), true); if (v->GetFoundationType() == FDT_INVALID) { v->SetFoundationType(FDT_GROUND); v->SetFoundationSlope(bits); @@ -304,7 +304,7 @@ void VoxelWorld::MakeFlatWorld(int16 z) { for (uint16 xpos = 0; xpos < this->x_size; xpos++) { for (uint16 ypos = 0; ypos < this->y_size; ypos++) { - Voxel *v = this->GetCreateVoxel(xpos, ypos, z, true); + Voxel *v = this->GetCreateVoxel(XYZPoint16(xpos, ypos, z), true); v->SetFoundationType(FDT_INVALID); v->SetGroundType(GTP_GRASS0); v->SetGroundSlope(ImplodeTileSlope(SL_FLAT)); diff --git a/src/map.h b/src/map.h index fe0fb6a..c1fdaa9 100644 --- a/src/map.h +++ b/src/map.h @@ -510,27 +510,23 @@ public: /** * Get a voxel in the world by voxel coordinate. - * @param x X coordinate of the voxel. - * @param y Y coordinate of the voxel. - * @param z Z coordinate of the voxel. + * @param vox Coordinate of the voxel. * @return Address of the voxel (if it exists). */ - inline const Voxel *GetVoxel(uint16 x, uint16 y, int16 z) const + inline const Voxel *GetVoxel(const XYZPoint16 &vox) const { - return this->GetStack(x, y)->Get(z); + return this->GetStack(vox.x, vox.y)->Get(vox.z); } /** * Get a voxel in the world by voxel coordinate. - * @param x X coordinate of the voxel. - * @param y Y coordinate of the voxel. - * @param z Z coordinate of the voxel. + * @param vox Coordinate of the voxel. * @param create If the requested voxel does not exist, try to create it. * @return Address of the voxel (if it exists or could be created). */ - inline Voxel *GetCreateVoxel(uint16 x, uint16 y, int16 z, bool create) + inline Voxel *GetCreateVoxel(const XYZPoint16 &vox, bool create) { - return this->GetModifyStack(x, y)->GetCreate(z, create); + return this->GetModifyStack(vox.x, vox.y)->GetCreate(vox.z, create); } /** @@ -553,17 +549,15 @@ public: /** * Does the provided voxel exist in the world? - * @param x X coordinate of the voxel. - * @param y Y coordinate of the voxel. - * @param z Z coordinate of the voxel. + * @param vox Coordinate of the voxel. * @return Whether a voxel with content exists at the given position. */ - inline bool VoxelExists(int16 x, int16 y, int16 z) const + inline bool VoxelExists(const XYZPoint16 &vox) const { - if (x < 0 || x >= (int)this->GetXSize()) return false; - if (y < 0 || y >= (int)this->GetYSize()) return false; - const VoxelStack *vs = this->GetStack(x, y); - if (z < vs->base || z >= vs->base + (int)vs->height) return false; + if (vox.x < 0 || vox.x >= (int)this->GetXSize()) return false; + if (vox.y < 0 || vox.y >= (int)this->GetYSize()) return false; + const VoxelStack *vs = this->GetStack(vox.x, vox.y); + if (vox.z < vs->base || vox.z >= vs->base + (int)vs->height) return false; return true; } @@ -607,27 +601,23 @@ public: /** * Get a voxel in the world by voxel coordinate. - * @param x X coordinate of the voxel. - * @param y Y coordinate of the voxel. - * @param z Z coordinate of the voxel. + * @param vox Coordinate of the voxel. * @return Address of the voxel (if it exists). */ - inline const Voxel *GetVoxel(uint16 x, uint16 y, int16 z) const + inline const Voxel *GetVoxel(const XYZPoint16 &vox) const { - return this->GetStack(x, y)->Get(z); + return this->GetStack(vox.x, vox.y)->Get(vox.z); } /** * Get a voxel in the world by voxel coordinate. - * @param x X coordinate of the voxel. - * @param y Y coordinate of the voxel. - * @param z Z coordinate of the voxel. + * @param vox Coordinate of the voxel. * @param create If the requested voxel does not exist, try to create it. * @return Address of the voxel (if it exists or could be created). */ - inline Voxel *GetCreateVoxel(uint16 x, uint16 y, int16 z, bool create) + inline Voxel *GetCreateVoxel(const XYZPoint16 &vox, bool create) { - return this->GetModifyStack(x, y)->GetCreate(z, create); + return this->GetModifyStack(vox.x, vox.y)->GetCreate(vox.z, create); } void MarkDirty(Viewport *vp); diff --git a/src/path.cpp b/src/path.cpp index cc46dd2..07c08e1 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -249,33 +249,27 @@ uint8 GetPathExits(const Voxel *v) */ bool TravelQueuePath(XYZPoint16 *voxel_pos, TileEdge *entry) { - int orig_xp = voxel_pos->x; - int orig_yp = voxel_pos->y; - int orig_zp = voxel_pos->z; - - int xpos = voxel_pos->x; - int ypos = voxel_pos->y; - int zpos = voxel_pos->z; + XYZPoint16 new_pos = *voxel_pos; TileEdge edge = *entry; /* Check that entry voxel actually exists. */ - if (!IsVoxelstackInsideWorld(xpos, ypos)) return false; + if (!IsVoxelstackInsideWorld(new_pos.x, new_pos.y)) return false; for (;;) { - xpos += _tile_dxy[edge].x; - ypos += _tile_dxy[edge].y; - if (!IsVoxelstackInsideWorld(xpos, ypos)) return false; + new_pos.x += _tile_dxy[edge].x; + new_pos.y += _tile_dxy[edge].y; + if (!IsVoxelstackInsideWorld(new_pos.x, new_pos.y)) return false; - const Voxel *vx = _world.GetVoxel(xpos, ypos, zpos); + const Voxel *vx = _world.GetVoxel(new_pos); if (vx == nullptr || !HasValidPath(vx)) { /* No path here, check the voxel below. */ - if (zpos == 0) return true; // Path ends here. - zpos--; - vx = _world.GetVoxel(xpos, ypos, zpos); + if (new_pos.z == 0) return true; // Path ends here. + new_pos.z--; + vx = _world.GetVoxel(new_pos); if (vx == nullptr || !HasValidPath(vx)) return true; // Path ends here. } - if (xpos == orig_xp && ypos == orig_yp && zpos == orig_zp) return false; // Cycle detected. + if (new_pos == *voxel_pos) return false; // Cycle detected. /* Stop if we found a non-queue path. */ if (_sprite_manager.GetPathStatus(GetPathType(vx->GetInstanceData())) != PAS_QUEUE_PATH) return true; @@ -289,8 +283,8 @@ bool TravelQueuePath(XYZPoint16 *voxel_pos, TileEdge *entry) /* Check that the new tile can go back to our last tile. */ uint8 rev_edge = (edge + 2) % 4; - if (!((exits & (0x01 << rev_edge)) != 0 && zpos == voxel_pos->z) && - !((exits & (0x10 << rev_edge)) != 0 && zpos == voxel_pos->z - 1)) { + if (!((exits & (0x01 << rev_edge)) != 0 && new_pos.z == voxel_pos->z) && + !((exits & (0x10 << rev_edge)) != 0 && new_pos.z == voxel_pos->z - 1)) { return false; } @@ -299,16 +293,14 @@ bool TravelQueuePath(XYZPoint16 *voxel_pos, TileEdge *entry) if (edge == rev_edge) continue; // Skip the direction we came from. if ((exits & (0x01 << edge)) != 0) break; if ((exits & (0x10 << edge)) != 0) { - zpos++; + new_pos.z++; break; } } if (edge == EDGE_COUNT) return false; // Queue path doesn't have a second exit. - voxel_pos->x = xpos; - voxel_pos->y = ypos; - voxel_pos->z = zpos; + *voxel_pos = new_pos; *entry = edge; } } @@ -388,9 +380,9 @@ static bool ExamineNeighbourPathEdge(const XYZPoint16 &voxel_pos, bool use_addit *dest_inst_data = PATH_INVALID; if (use_additions) { - v = _additions.GetCreateVoxel(voxel_pos.x, voxel_pos.y, voxel_pos.z, false); + v = _additions.GetCreateVoxel(voxel_pos, false); } else { - v = _world.GetCreateVoxel(voxel_pos.x, voxel_pos.y, voxel_pos.z, false); + v = _world.GetCreateVoxel(voxel_pos, false); } if (v == nullptr) return false; diff --git a/src/path_build.cpp b/src/path_build.cpp index 9a0cc77..d6887a6 100644 --- a/src/path_build.cpp +++ b/src/path_build.cpp @@ -90,12 +90,12 @@ bool PathExistsAtBottomEdge(XYZPoint16 voxel_pos, TileEdge edge) voxel_pos.y += _tile_dxy[edge].y; if (!IsVoxelstackInsideWorld(voxel_pos.x, voxel_pos.y)) return false; - const Voxel *vx = _world.GetVoxel(voxel_pos.x, voxel_pos.y, voxel_pos.z); + const Voxel *vx = _world.GetVoxel(voxel_pos); if (vx == nullptr || !HasValidPath(vx)) { /* No path here, check the voxel below. */ if (voxel_pos.z == 0) return false; voxel_pos.z--; - vx = _world.GetVoxel(voxel_pos.x, voxel_pos.y, voxel_pos.z); + vx = _world.GetVoxel(voxel_pos); if (vx == nullptr || !HasValidPath(vx)) return false; /* Path must end at the top of the voxel. */ return GetImplodedPathSlope(vx) == _path_up_from_edge[edge]; @@ -273,14 +273,14 @@ static uint8 CanBuildPathFromEdge(const XYZPoint16 &voxel_pos, TileEdge edge) if (!IsVoxelstackInsideWorld(voxel_pos.x + dxy.x, voxel_pos.y + dxy.y) || (_game_mode_mgr.InPlayMode() && _world.GetTileOwner(voxel_pos.x + dxy.x, voxel_pos.y + dxy.y) != OWN_PARK)) return 0; - const Voxel *v = _world.GetVoxel(voxel_pos.x, voxel_pos.y, voxel_pos.z); + const Voxel *v = _world.GetVoxel(voxel_pos); if (v != nullptr && HasValidPath(v)) { PathSprites ps = GetImplodedPathSlope(v); if (ps < PATH_FLAT_COUNT) return 1 << TSL_FLAT; if (ps == _path_up_from_edge[edge]) return 1 << TSL_UP; } if (voxel_pos.z > 0) { - v = _world.GetVoxel(voxel_pos.x, voxel_pos.y, voxel_pos.z - 1); + v = _world.GetVoxel(XYZPoint16(voxel_pos.x, voxel_pos.y, voxel_pos.z - 1)); if (v != nullptr && HasValidPath(v) && GetImplodedPathSlope(v) == _path_down_from_edge[edge]) return 1 << TSL_DOWN; } @@ -303,7 +303,7 @@ static uint8 GetPathAttachPoints(const XYZPoint16 &voxel_pos) if (!IsVoxelstackInsideWorld(voxel_pos.x, voxel_pos.y)) return 0; if (voxel_pos.z >= WORLD_Z_SIZE - 1) return 0; // The voxel containing the flat path, and one above it. - const Voxel *v = _world.GetVoxel(voxel_pos.x, voxel_pos.y, voxel_pos.z); + const Voxel *v = _world.GetVoxel(voxel_pos); if (v == nullptr) return 0; uint8 edges = 0; @@ -487,12 +487,12 @@ void PathBuildManager::MoveCursor(TileEdge edge, bool move_up) const Voxel *v_top, *v_bot; if (move_up) { /* Exit of current tile is at the top. */ - v_top = (this->pos.z > WORLD_Z_SIZE - 2) ? nullptr : _world.GetVoxel(this->pos.x + dxy.x, this->pos.y + dxy.y, this->pos.z + 1); - v_bot = _world.GetVoxel(this->pos.x + dxy.x, this->pos.y + dxy.y, this->pos.z); + v_top = (this->pos.z > WORLD_Z_SIZE - 2) ? nullptr : _world.GetVoxel(XYZPoint16(this->pos.x + dxy.x, this->pos.y + dxy.y, this->pos.z + 1)); + v_bot = _world.GetVoxel(XYZPoint16(this->pos.x + dxy.x, this->pos.y + dxy.y, this->pos.z)); } else { /* Exit of current tile is at the bottom. */ - v_top = _world.GetVoxel(this->pos.x + dxy.x, this->pos.y + dxy.y, this->pos.z); - v_bot = (this->pos.z == 0) ? nullptr : _world.GetVoxel(this->pos.x + dxy.x, this->pos.y + dxy.y, this->pos.z - 1); + v_top = _world.GetVoxel(XYZPoint16(this->pos.x + dxy.x, this->pos.y + dxy.y, this->pos.z)); + v_bot = (this->pos.z == 0) ? nullptr : _world.GetVoxel(XYZPoint16(this->pos.x + dxy.x, this->pos.y + dxy.y, this->pos.z - 1)); } /* Try to find a voxel with a path. */ @@ -543,7 +543,7 @@ void PathBuildManager::SelectMovement(bool move_forward) TileEdge edge = (move_forward) ? this->selected_arrow : (TileEdge)((this->selected_arrow + 2) % 4); bool move_up; - const Voxel *v = _world.GetVoxel(this->pos.x, this->pos.y, this->pos.z); + const Voxel *v = _world.GetVoxel(this->pos); if (v == nullptr) return; if (HasValidPath(v)) { move_up = (GetImplodedPathSlope(v) == _path_down_from_edge[edge]); @@ -706,7 +706,7 @@ bool PathBuildManager::GetRemoveIsEnabled() const { if (this->state == PBS_IDLE || this->state == PBS_WAIT_VOXEL) return false; /* If current tile has a path, it can be removed. */ - const Voxel *v = _world.GetVoxel(this->pos.x, this->pos.y, this->pos.z); + const Voxel *v = _world.GetVoxel(this->pos); if (v != nullptr && HasValidPath(v)) return true; return this->state == PBS_WAIT_BUY; } @@ -878,7 +878,7 @@ void PathBuildManager::SelectBuyRemove(bool buying) // Removing a path tile. if (this->state <= PBS_WAIT_VOXEL || this->state > PBS_WAIT_BUY) return; TileEdge edge = (TileEdge)((this->selected_arrow + 2) % 4); - const Voxel *v = _world.GetVoxel(this->pos.x, this->pos.y, this->pos.z); + const Voxel *v = _world.GetVoxel(this->pos); if (v == nullptr || !HasValidPath(v)) { this->MoveCursor(edge, false); this->UpdateState(); diff --git a/src/path_finding.cpp b/src/path_finding.cpp index b4f65bb..15244ea 100644 --- a/src/path_finding.cpp +++ b/src/path_finding.cpp @@ -155,7 +155,7 @@ bool PathSearcher::Search() } /* Add new open points. */ - const Voxel *v = _world.GetVoxel(wp->x, wp->y, wp->z); + const Voxel *v = _world.GetVoxel(XYZPoint16(wp->x, wp->y, wp->z)); if (v == nullptr) continue; // No voxel at the expected point, don't bother. uint8 exits = GetPathExits(v); @@ -173,14 +173,14 @@ bool PathSearcher::Search() if (new_z < 0 || new_z >= WORLD_Z_SIZE) continue; /* Now check the other side, new_z is the voxel where the path should be at the bottom. */ - const Voxel *v2 = _world.GetVoxel(wp->x + dxy.x, wp->y + dxy.y, new_z); + const Voxel *v2 = _world.GetVoxel(XYZPoint16(wp->x + dxy.x, wp->y + dxy.y, new_z)); if (v2 == nullptr) continue; uint8 other_exits = GetPathExits(v2); if ((other_exits & (1 << ((edge + 2) % 4))) == 0) { // No path here, try one voxel below new_z--; if (new_z < 0) continue; - v2 = _world.GetVoxel(wp->x + dxy.x, wp->y + dxy.y, new_z); + v2 = _world.GetVoxel(XYZPoint16(wp->x + dxy.x, wp->y + dxy.y, new_z)); if (v2 == nullptr) continue; other_exits = GetPathExits(v2); if ((other_exits & (0x10 << ((edge + 2) % 4))) == 0) continue; diff --git a/src/people.cpp b/src/people.cpp index f798c08..a1d3abe 100644 --- a/src/people.cpp +++ b/src/people.cpp @@ -44,7 +44,7 @@ static bool IsGoodEdgeRoad(int16 x, int16 y) { if (x < 0 || y < 0) return false; int16 z = _world.GetGroundHeight(x, y); - const Voxel *vs = _world.GetVoxel(x, y, z); + const Voxel *vs = _world.GetVoxel(XYZPoint16(x, y, z)); return HasValidPath(vs) && GetImplodedPathSlope(vs) < PATH_FLAT_COUNT; } diff --git a/src/person.cpp b/src/person.cpp index f4a483c..3d9f6e2 100644 --- a/src/person.cpp +++ b/src/person.cpp @@ -150,9 +150,9 @@ const char *Person::GetName() const * @return Z height of the path in the voxel at the give position. * @todo Make it work at sloped surface too, in case the person ends up at path-less land. */ -static int16 GetZHeight(XYZPoint16 vox, int16 x_pos, int16 y_pos) +static int16 GetZHeight(const XYZPoint16 &vox, int16 x_pos, int16 y_pos) { - const Voxel *v = _world.GetVoxel(vox.x, vox.y, vox.z); + const Voxel *v = _world.GetVoxel(vox); if (HasValidPath(v)) { uint8 slope = GetImplodedPathSlope(v); if (slope < PATH_FLAT_COUNT) return 0; @@ -188,7 +188,7 @@ void Person::Activate(const Point16 &start, PersonType person_type) this->vox_pos.x = start.x; this->vox_pos.y = start.y; this->vox_pos.z = _world.GetGroundHeight(start.x, start.y); - this->AddSelf(_world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false)); + this->AddSelf(_world.GetCreateVoxel(this->vox_pos, false)); if (start.x == 0) { this->x_pos = 0; @@ -463,7 +463,7 @@ void Guest::ExitRide(RideInstance *ri, TileEdge entry) this->vox_pos.y = ypos >> 8; this->y_pos = ypos & 0xff; this->vox_pos.z = zpos >> 8; this->z_pos = zpos & 0xff; this->activity = GA_WANDER; - this->AddSelf(_world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false)); + this->AddSelf(_world.GetCreateVoxel(this->vox_pos, false)); this->DecideMoveDirection(); } @@ -795,9 +795,9 @@ void Person::DeActivate(AnimateResult ar) { if (!this->IsActive()) return; - if (ar == OAR_REMOVE && _world.VoxelExists(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z)) { + if (ar == OAR_REMOVE && _world.VoxelExists(this->vox_pos)) { /* If not wandered off-world, remove the person from the voxel person list. */ - this->RemoveSelf(_world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false)); + this->RemoveSelf(_world.GetCreateVoxel(this->vox_pos, false)); } this->type = PERSON_INVALID; @@ -879,7 +879,7 @@ AnimateResult Person::OnAnimate(int delay) int dz = 0; TileEdge exit_edge = INVALID_EDGE; - this->RemoveSelf(_world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false)); + this->RemoveSelf(_world.GetCreateVoxel(this->vox_pos, false)); if (this->x_pos < 0) { dx--; this->vox_pos.x--; @@ -915,7 +915,7 @@ AnimateResult Person::OnAnimate(int delay) this->z_pos = 0; } /* At bottom of the voxel. */ - Voxel *v = _world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false); + Voxel *v = _world.GetCreateVoxel(this->vox_pos, false); if (v != nullptr) { SmallRideInstance instance = v->GetInstance(); if (instance >= SRI_FULL_RIDES) { @@ -935,7 +935,7 @@ AnimateResult Person::OnAnimate(int delay) dz--; this->vox_pos.z--; this->z_pos = 255; - Voxel *w = _world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false); + Voxel *w = _world.GetCreateVoxel(this->vox_pos, false); if (w != nullptr && HasValidPath(w)) { this->AddSelf(w); this->DecideMoveDirection(); @@ -948,7 +948,7 @@ AnimateResult Person::OnAnimate(int delay) if (dy != 0) { this->vox_pos.y -= dy; this->y_pos = (dy > 0) ? 255 : 0; } if (dz != 0) { this->vox_pos.z -= dz; this->z_pos = (dz > 0) ? 255 : 0; } - this->AddSelf(_world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false)); + this->AddSelf(_world.GetCreateVoxel(this->vox_pos, false)); this->DecideMoveDirection(); return OAR_OK; } @@ -957,7 +957,7 @@ AnimateResult Person::OnAnimate(int delay) dz--; this->vox_pos.z--; this->z_pos = 255; - v = _world.GetCreateVoxel(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, false); + v = _world.GetCreateVoxel(this->vox_pos, false); } if (v != nullptr && HasValidPath(v)) { this->AddSelf(v); diff --git a/src/ride_gui.cpp b/src/ride_gui.cpp index 8d7153d..70f383f 100644 --- a/src/ride_gui.cpp +++ b/src/ride_gui.cpp @@ -375,7 +375,7 @@ bool ShopPlacementManager::CanPlaceShop(const ShopType *selected_shop, int xpos, { /* 1. Can the position itself be used to build a shop? */ if (_world.GetTileOwner(xpos, ypos) != OWN_PARK) return false; - const Voxel *vx = _world.GetVoxel(xpos, ypos, zpos); + const Voxel *vx = _world.GetVoxel(XYZPoint16(xpos, ypos, zpos)); if (vx != nullptr) { if (!vx->CanPlaceInstance()) return false; // Cannot build on a path or other ride. return vx->GetGroundType() != GTP_INVALID && vx->GetGroundSlope() == SL_FLAT; // Can build at a flat surface. @@ -383,7 +383,7 @@ bool ShopPlacementManager::CanPlaceShop(const ShopType *selected_shop, int xpos, /* 2. Is the shop just above non-flat ground? */ if (zpos > 0) { - vx = _world.GetVoxel(xpos, ypos, zpos - 1); + vx = _world.GetVoxel(XYZPoint16(xpos, ypos, zpos - 1)); if (vx != nullptr && vx->GetInstance() == SRI_FREE && vx->GetGroundType() != GTP_INVALID && vx->GetGroundSlope() != SL_FLAT) return true; } @@ -486,7 +486,7 @@ void ShopPlacementManager::PlaceShop(const Point16 &pos) /// \todo Let the shop do this. ShopInstance *si = static_cast(_rides_manager.GetRideInstance(this->instance)); assert(si != nullptr && si->GetKind() == RTK_SHOP); - Voxel *vx = _additions.GetCreateVoxel(si->xpos, si->ypos, si->zpos, true); + Voxel *vx = _additions.GetCreateVoxel(XYZPoint16(si->xpos, si->ypos, si->zpos), true); assert(this->instance >= SRI_FULL_RIDES && this->instance <= SRI_LAST); vx->SetInstance((SmallRideInstance)this->instance); uint8 entrances = si->GetEntranceDirections(si->xpos, si->ypos, si->zpos); diff --git a/src/ride_type.cpp b/src/ride_type.cpp index 398c141..411cca3 100644 --- a/src/ride_type.cpp +++ b/src/ride_type.cpp @@ -630,11 +630,11 @@ RideInstance *RideExistsAtBottom(int xpos, int ypos, int zpos, TileEdge edge) ypos += _tile_dxy[edge].y; if (!IsVoxelstackInsideWorld(xpos, ypos)) return nullptr; - const Voxel *vx = _world.GetVoxel(xpos, ypos, zpos); + const Voxel *vx = _world.GetVoxel(XYZPoint16(xpos, ypos, zpos)); if (vx == nullptr || vx->GetInstance() < SRI_FULL_RIDES) { /* No ride here, check the voxel below. */ if (zpos == 0) return nullptr; - vx = _world.GetVoxel(xpos, ypos, zpos - 1); + vx = _world.GetVoxel(XYZPoint16(xpos, ypos, zpos - 1)); } if (vx == nullptr || vx->GetInstance() < SRI_FULL_RIDES) return nullptr; return _rides_manager.GetRideInstance(vx->GetInstance()); diff --git a/src/terraform.cpp b/src/terraform.cpp index ac814e7..e558a8c 100644 --- a/src/terraform.cpp +++ b/src/terraform.cpp @@ -138,7 +138,7 @@ GroundData *TerrainChanges::GetGroundData(const Point32 &pos) auto iter = this->changes.find(pos); if (iter == this->changes.end()) { uint8 height = _world.GetGroundHeight(pos.x, pos.y); - const Voxel *v = _world.GetVoxel(pos.x, pos.y, height); + const Voxel *v = _world.GetVoxel(XYZPoint16(pos.x, pos.y, height)); assert(v != nullptr && v->GetGroundType() != GTP_INVALID); std::pair p(pos, GroundData(height, ExpandTileSlope(v->GetGroundSlope()))); iter = this->changes.insert(p).first; diff --git a/src/track_piece.cpp b/src/track_piece.cpp index 1705474..6dd60c3 100644 --- a/src/track_piece.cpp +++ b/src/track_piece.cpp @@ -268,7 +268,7 @@ bool PositionedTrackPiece::CanBePlaced() const for (int i = 0; i < this->piece->voxel_count; i++) { /* Is the voxel above ground level? */ if (_world.GetGroundHeight(this->base_voxel.x + tvx->dx, this->base_voxel.y + tvx->dy) > this->base_voxel.z + tvx->dz) return false; - const Voxel *vx = _world.GetVoxel(this->base_voxel.x + tvx->dx, this->base_voxel.y + tvx->dy, this->base_voxel.z + tvx->dz); + const Voxel *vx = _world.GetVoxel(XYZPoint16(this->base_voxel.x + tvx->dx, this->base_voxel.y + tvx->dy, this->base_voxel.z + tvx->dz)); if (vx != nullptr && !vx->CanPlaceInstance()) return false; } return true; diff --git a/src/viewport.cpp b/src/viewport.cpp index 12610bd..0c19258 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1381,7 +1381,7 @@ void Viewport::OnDraw() void Viewport::MarkVoxelDirty(const XYZPoint16 &voxel_pos, int16 height) { if (height <= 0) { - const Voxel *v = _world.GetVoxel(voxel_pos.x, voxel_pos.y, voxel_pos.z); + const Voxel *v = _world.GetVoxel(voxel_pos); if (v == nullptr) { height = 1; } else { -- 2.2.1