From 681500be7641677a17b348ad4f27b5c5609af385 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Wed, 31 Dec 2014 20:21:48 +0000 Subject: [PATCH 09/14] change RideInstance and friends --- src/coaster.cpp | 4 ++-- src/coaster.h | 4 ++-- src/person.cpp | 31 ++++++++++-------------- src/person.h | 2 +- src/ride_gui.cpp | 68 +++++++++++++++++++++++++--------------------------- src/ride_type.cpp | 38 ++++++++++++----------------- src/ride_type.h | 8 +++---- src/shop_placement.h | 4 ++-- src/shop_type.cpp | 23 +++++++----------- src/shop_type.h | 12 ++++------ 10 files changed, 83 insertions(+), 111 deletions(-) diff --git a/src/coaster.cpp b/src/coaster.cpp index cf2c079..e88d6e6 100644 --- a/src/coaster.cpp +++ b/src/coaster.cpp @@ -597,7 +597,7 @@ void CoasterInstance::GetSprites(uint16 voxel_number, uint8 orient, const ImageD } } -uint8 CoasterInstance::GetEntranceDirections(uint16 xvox, uint16 yvox, uint8 zvox) const +uint8 CoasterInstance::GetEntranceDirections(const XYZPoint16 &vox) const { return 0; /// \todo add entrance bits for the coaster. } @@ -607,7 +607,7 @@ RideEntryResult CoasterInstance::EnterRide(int guest, TileEdge edge) return RER_REFUSED; /// \todo Store the guest number. } -void CoasterInstance::GetExit(int guest, TileEdge entry_edge, uint32 *xpos, uint32 *ypos, uint32 *zpos) +XYZPoint32 CoasterInstance::GetExit(int guest, TileEdge entry_edge) { assert(false); // Not yet implemented. } diff --git a/src/coaster.h b/src/coaster.h index 7646f57..10a7b7f 100644 --- a/src/coaster.h +++ b/src/coaster.h @@ -192,9 +192,9 @@ public: } void GetSprites(uint16 voxel_number, uint8 orient, const ImageData *sprites[4]) const override; - uint8 GetEntranceDirections(uint16 xvox, uint16 yvox, uint8 zvox) const override; + uint8 GetEntranceDirections(const XYZPoint16 &vox) const override; RideEntryResult EnterRide(int guest, TileEdge entry) override; - void GetExit(int guest, TileEdge entry_edge, uint32 *xpos, uint32 *ypos, uint32 *zpos) override; + XYZPoint32 GetExit(int guest, TileEdge entry_edge) override; void RemoveAllPeople() override; RideInstanceState DecideRideState(); diff --git a/src/person.cpp b/src/person.cpp index 3d9f6e2..750ac31 100644 --- a/src/person.cpp +++ b/src/person.cpp @@ -382,27 +382,21 @@ TileEdge Person::GetCurrentEdge() const /** * Decide whether visiting the exit edge is useful. * @param current_edge Edge at the current position. - * @param x X coordinate of the current voxel. - * @param y Y coordinate of the current voxel. - * @param z Z coordinate of the current voxel. + * @param cur_pos Coordinate of the current voxel. * @param exit_edge Exit edge being examined. * @param seen_wanted_ride [inout] Whether the wanted ride is seen. * @return Desire of the guest to visit the indicated edge. */ -RideVisitDesire Guest::ComputeExitDesire(TileEdge current_edge, int x, int y, int z, TileEdge exit_edge, bool *seen_wanted_ride) +RideVisitDesire Guest::ComputeExitDesire(TileEdge current_edge, XYZPoint16 cur_pos, TileEdge exit_edge, bool *seen_wanted_ride) { if (current_edge == exit_edge) return RVD_NO_VISIT; // Skip incoming edge (may get added later if no other options exist). - XYZPoint16 voxel_pos(x, y, z); - bool travel = TravelQueuePath(&voxel_pos, &exit_edge); + bool travel = TravelQueuePath(&cur_pos, &exit_edge); if (!travel) return RVD_NO_VISIT; // Path leads to nowhere. - x = voxel_pos.x; - y = voxel_pos.y; - z = voxel_pos.z; - if (PathExistsAtBottomEdge(XYZPoint16(x, y, z), exit_edge)) return RVD_NO_RIDE; // Found a path. + if (PathExistsAtBottomEdge(cur_pos, exit_edge)) return RVD_NO_RIDE; // Found a path. - RideInstance *ri = RideExistsAtBottom(x, y, z, exit_edge); + RideInstance *ri = RideExistsAtBottom(cur_pos, exit_edge); if (ri == nullptr || ri->state != RIS_OPEN) return RVD_NO_VISIT; // No ride, or a closed one. if (ri == this->ride) { // Guest decided before that this shop/ride should be visited. @@ -411,7 +405,7 @@ RideVisitDesire Guest::ComputeExitDesire(TileEdge current_edge, int x, int y, in } Point16 dxy = _tile_dxy[exit_edge]; - if (!ri->CanBeVisited(x + dxy.x, y + dxy.y, z, exit_edge)) return RVD_NO_VISIT; // Ride cannot be entered here. + if (!ri->CanBeVisited(XYZPoint16(cur_pos.x + dxy.x, cur_pos.y + dxy.y, cur_pos.z), exit_edge)) return RVD_NO_VISIT; // Ride cannot be entered here. RideVisitDesire rvd = this->WantToVisit(ri); if ((rvd == RVD_MAY_VISIT || rvd == RVD_MUST_VISIT) && this->ride == nullptr) { @@ -457,11 +451,10 @@ void Guest::ExitRide(RideInstance *ri, TileEdge entry) assert(this->activity == GA_ON_RIDE); assert(this->ride == ri); - uint32 xpos, ypos, zpos; - ri->GetExit(this->id, entry, &xpos, &ypos, &zpos); - this->vox_pos.x = xpos >> 8; this->x_pos = xpos & 0xff; - this->vox_pos.y = ypos >> 8; this->y_pos = ypos & 0xff; - this->vox_pos.z = zpos >> 8; this->z_pos = zpos & 0xff; + XYZPoint32 exit_pos = ri->GetExit(this->id, entry); + this->vox_pos.x = exit_pos.x >> 8; this->x_pos = exit_pos.x & 0xff; + this->vox_pos.y = exit_pos.y >> 8; this->y_pos = exit_pos.y & 0xff; + this->vox_pos.z = exit_pos.z >> 8; this->z_pos = exit_pos.z & 0xff; this->activity = GA_WANDER; this->AddSelf(_world.GetCreateVoxel(this->vox_pos, false)); this->DecideMoveDirection(); @@ -503,7 +496,7 @@ uint8 Guest::GetExitDirections(const Voxel *v, TileEdge start_edge, bool *seen_w continue; } - RideVisitDesire rvd = ComputeExitDesire(start_edge, this->vox_pos.x, this->vox_pos.y, z, exit_edge, seen_wanted_ride); + RideVisitDesire rvd = ComputeExitDesire(start_edge, XYZPoint16(this->vox_pos.x, this->vox_pos.y, z), exit_edge, seen_wanted_ride); switch (rvd) { case RVD_NO_RIDE: break; // A path is one of the options. @@ -1066,7 +1059,7 @@ AnimateResult Guest::EdgeOfWorldOnAnimate() AnimateResult Guest::VisitRideOnAnimate(RideInstance *ri, TileEdge exit_edge) { - if (ri->CanBeVisited(this->vox_pos.x, this->vox_pos.y, this->vox_pos.z, exit_edge) && this->SelectItem(ri) != ITP_NOTHING) { + if (ri->CanBeVisited(this->vox_pos, exit_edge) && this->SelectItem(ri) != ITP_NOTHING) { /* All lights are green, let's try to enter the ride. */ this->activity = GA_ON_RIDE; this->ride = ri; diff --git a/src/person.h b/src/person.h index b7a9058..a83f78f 100644 --- a/src/person.h +++ b/src/person.h @@ -203,7 +203,7 @@ public: protected: void DecideMoveDirection() override; - RideVisitDesire ComputeExitDesire(TileEdge current_edge, int x, int y, int z, TileEdge exit_edge, bool *seen_wanted_ride); + RideVisitDesire ComputeExitDesire(TileEdge current_edge, XYZPoint16 cur_pos, TileEdge exit_edge, bool *seen_wanted_ride); uint8 GetExitDirections(const Voxel *v, TileEdge start_edge, bool *seen_wanted_ride, bool *queue_mode); RideVisitDesire WantToVisit(const RideInstance *ri) override; AnimateResult EdgeOfWorldOnAnimate() override; diff --git a/src/ride_gui.cpp b/src/ride_gui.cpp index 70f383f..7140453 100644 --- a/src/ride_gui.cpp +++ b/src/ride_gui.cpp @@ -364,26 +364,24 @@ void ShowRideSelectGui() /** * Can a shop be placed at the given voxel? * @param selected_shop Shop to place. - * @param xpos X coordinate of the voxel. - * @param ypos Y coordinate of the voxel. - * @param zpos Z coordinate of the voxel. + * @param pos Coordinate of the voxel. * @pre voxel coordinate must be valid in the world. * @pre \a selected_shop may not be \c nullptr. * @return Shop can be placed at the given position. */ -bool ShopPlacementManager::CanPlaceShop(const ShopType *selected_shop, int xpos, int ypos, int zpos) +bool ShopPlacementManager::CanPlaceShop(const ShopType *selected_shop, const XYZPoint16 &pos) { /* 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(XYZPoint16(xpos, ypos, zpos)); + if (_world.GetTileOwner(pos.x, pos.y) != OWN_PARK) return false; + const Voxel *vx = _world.GetVoxel(pos); 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. } /* 2. Is the shop just above non-flat ground? */ - if (zpos > 0) { - vx = _world.GetVoxel(XYZPoint16(xpos, ypos, zpos - 1)); + if (pos.z > 0) { + vx = _world.GetVoxel(XYZPoint16(pos.x, pos.y, pos.z - 1)); if (vx != nullptr && vx->GetInstance() == SRI_FREE && vx->GetGroundType() != GTP_INVALID && vx->GetGroundSlope() != SL_FLAT) return true; } @@ -393,7 +391,7 @@ bool ShopPlacementManager::CanPlaceShop(const ShopType *selected_shop, int xpos, for (TileEdge entrance = EDGE_BEGIN; entrance < EDGE_COUNT; entrance++) { // Loop over the 4 unrotated directions. if ((selected_shop->flags & (1 << entrance)) == 0) continue; // No entrance here. TileEdge entr = (TileEdge)((entrance + vp->orientation + this->orientation) & 3); // Perform rotation specified by the user in the GUI. - if (PathExistsAtBottomEdge(XYZPoint16(xpos, ypos, zpos), entr)) return true; + if (PathExistsAtBottomEdge(pos, entr)) return true; } return false; } @@ -401,12 +399,10 @@ bool ShopPlacementManager::CanPlaceShop(const ShopType *selected_shop, int xpos, /** * Decide at which voxel to place a shop. It should be placed at a voxel intersecting with the view line * through the given point in the world. - * @param xworld X coordinate of the point. - * @param yworld Y coordinate of the point. - * @param zworld Z coordinate of the point. + * @param world_pos Coordinate of the point. * @return Result of the placement process. */ -RidePlacementResult ShopPlacementManager::ComputeShopVoxel(int32 xworld, int32 yworld, int32 zworld) +RidePlacementResult ShopPlacementManager::ComputeShopVoxel(XYZPoint32 world_pos) { ShopInstance *si = static_cast(_rides_manager.GetRideInstance(this->instance)); assert(si != nullptr && si->GetKind() == RTK_SHOP); // It should be possible to set the position of a shop. @@ -425,33 +421,33 @@ RidePlacementResult ShopPlacementManager::ComputeShopVoxel(int32 xworld, int32 y default: NOT_REACHED(); } + XYZPoint16 pos; /* Move to the top voxel of the world. */ - int zpos = WORLD_Z_SIZE - 1; - int dz = zpos * 256 - zworld; - xworld += dx * dz / 2; - yworld += dy * dz / 2; - - while (zpos >= 0) { - int xpos = xworld / 256; - int ypos = yworld / 256; - if (IsVoxelstackInsideWorld(xpos, ypos) && this->CanPlaceShop(st, xpos, ypos, zpos)) { + pos.z = WORLD_Z_SIZE - 1; + int dz = pos.z * 256 - world_pos.z; + world_pos.x += dx * dz / 2; + world_pos.y += dy * dz / 2; + + while (pos.z >= 0) { + pos.x = world_pos.x / 256; + pos.y = world_pos.y / 256; + if (IsVoxelstackInsideWorld(pos.x, pos.y) && this->CanPlaceShop(st, pos)) { /* Position of the shop the same as previously? */ - if (si->xpos != (uint16)xpos || si->ypos != (uint16)ypos || si->zpos != (uint8)zpos || - si->orientation != this->orientation) { - si->SetRide((this->orientation + vp->orientation) & 3, xpos, ypos, zpos); + if (si->vox_pos != pos || si->orientation != this->orientation) { + si->SetRide((this->orientation + vp->orientation) & 3, pos); return RPR_CHANGED; } return RPR_SAMEPOS; } else { /* Since z gets smaller, we subtract dx and dy, thus the checks reverse. */ - if (xpos < 0 && dx > 0) break; - if (xpos >= _world.GetXSize() && dx < 0) break; - if (ypos < 0 && dy > 0) break; - if (ypos >= _world.GetYSize() && dy < 0) break; + if (pos.x < 0 && dx > 0) break; + if (pos.x >= _world.GetXSize() && dx < 0) break; + if (pos.y < 0 && dy > 0) break; + if (pos.y >= _world.GetYSize() && dy < 0) break; } - xworld -= 128 * dx; - yworld -= 128 * dy; - zpos--; + world_pos.x -= 128 * dx; + world_pos.y -= 128 * dy; + pos.z--; } return RPR_FAIL; } @@ -467,7 +463,7 @@ void ShopPlacementManager::PlaceShop(const Point16 &pos) Point32 wxy = vp->ComputeHorizontalTranslation(vp->rect.width / 2 - pos.x, vp->rect.height / 2 - pos.y); /* Clean current display if needed. */ - switch (this->ComputeShopVoxel(wxy.x, wxy.y, vp->view_pos.z)) { + switch (this->ComputeShopVoxel(XYZPoint32(wxy.x, wxy.y, vp->view_pos.z))) { case RPR_FAIL: if (this->state == SPS_BAD_POS) return; // Nothing to do. _additions.MarkDirty(vp); @@ -486,12 +482,12 @@ 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(XYZPoint16(si->xpos, si->ypos, si->zpos), true); + Voxel *vx = _additions.GetCreateVoxel(si->vox_pos, 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); + uint8 entrances = si->GetEntranceDirections(si->vox_pos); vx->SetInstanceData(entrances); - AddRemovePathEdges(XYZPoint16(si->xpos, si->ypos, si->zpos), PATH_EMPTY, entrances, true, PAS_QUEUE_PATH); + AddRemovePathEdges(si->vox_pos, PATH_EMPTY, entrances, true, PAS_QUEUE_PATH); _additions.MarkDirty(vp); vp->EnsureAdditionsAreVisible(); this->state = SPS_GOOD_POS; diff --git a/src/ride_type.cpp b/src/ride_type.cpp index 411cca3..3f3c20a 100644 --- a/src/ride_type.cpp +++ b/src/ride_type.cpp @@ -191,11 +191,9 @@ const RideType *RideInstance::GetRideType() const */ /** - * \fn uint8 RideInstance::GetEntranceDirections(uint16 xvox, uint16 yvox, uint8 zvox) const + * \fn uint8 RideInstance::GetEntranceDirections(const XYZPoint16 &vox) const * Get the set edges with an entrance to the ride. - * @param xvox X position of the voxel with the ride. - * @param yvox Y position of the voxel with the ride. - * @param zvox Z position of the voxel with the ride. + * @param vox Position of the voxel with the ride. * @return Bit set of #TileEdge that allows entering the ride (seen from the ride). */ @@ -211,13 +209,11 @@ const RideType *RideInstance::GetRideType() const */ /** - * \fn void RideInstance::GetExit(int guest, TileEdge entry_edge, uint32 *xpos, uint32 *ypos, uint32 *zpos) + * \fn XYZPoint32 RideInstance::GetExit(int guest, TileEdge entry_edge) * Get the exit coordinates of the ride, is near the middle of a tile edge. * @param guest Number of the guest querying the exit coordinates. * @param entry_edge %Edge used for entering the ride. - * @param xpos X world position of the exit. - * @param ypos Y world position of the exit. - * @param zpos Z world position of the exit + * @return World position of the exit. */ /** @@ -227,16 +223,14 @@ const RideType *RideInstance::GetRideType() const /** * Can the ride be visited, assuming it is approached from direction \a edge? - * @param xvox X position of the voxel with the ride. - * @param yvox Y position of the voxel with the ride. - * @param zvox Z position of the voxel with the ride. + * @param vox Position of the voxel with the ride. * @param edge Direction of movement (exit direction of the neighbouring voxel). * @return Whether the ride can be visited. */ -bool RideInstance::CanBeVisited(uint16 xvox, uint16 yvox, uint8 zvox, TileEdge edge) const +bool RideInstance::CanBeVisited(const XYZPoint16 &vox, TileEdge edge) const { if (this->state != RIS_OPEN) return false; - return GB(this->GetEntranceDirections(xvox, yvox, zvox), (edge + 2) % 4, 1) != 0; + return GB(this->GetEntranceDirections(vox), (edge + 2) % 4, 1) != 0; } /** @@ -617,24 +611,22 @@ void RidesManager::CheckNoAllocatedRides() const /** * Does a ride entrance exists at/to the bottom the given voxel in the neighbouring voxel? - * @param xpos X coordinate of the voxel. - * @param ypos Y coordinate of the voxel. - * @param zpos Z coordinate of the voxel. + * @param pos Coordinate of the voxel. * @param edge Direction to move to get the neighbouring voxel. * @pre voxel coordinate must be valid in the world. * @return The ride at the neighbouring voxel, if available (else \c nullptr is returned). */ -RideInstance *RideExistsAtBottom(int xpos, int ypos, int zpos, TileEdge edge) +RideInstance *RideExistsAtBottom(XYZPoint16 pos, TileEdge edge) { - xpos += _tile_dxy[edge].x; - ypos += _tile_dxy[edge].y; - if (!IsVoxelstackInsideWorld(xpos, ypos)) return nullptr; + pos.x += _tile_dxy[edge].x; + pos.y += _tile_dxy[edge].y; + if (!IsVoxelstackInsideWorld(pos.x, pos.y)) return nullptr; - const Voxel *vx = _world.GetVoxel(XYZPoint16(xpos, ypos, zpos)); + const Voxel *vx = _world.GetVoxel(pos); if (vx == nullptr || vx->GetInstance() < SRI_FULL_RIDES) { /* No ride here, check the voxel below. */ - if (zpos == 0) return nullptr; - vx = _world.GetVoxel(XYZPoint16(xpos, ypos, zpos - 1)); + if (pos.z == 0) return nullptr; + vx = _world.GetVoxel(XYZPoint16(pos.x, pos.y, pos.z - 1)); } if (vx == nullptr || vx->GetInstance() < SRI_FULL_RIDES) return nullptr; return _rides_manager.GetRideInstance(vx->GetInstance()); diff --git a/src/ride_type.h b/src/ride_type.h index 42a1d99..bb5be88 100644 --- a/src/ride_type.h +++ b/src/ride_type.h @@ -137,11 +137,11 @@ public: virtual ~RideInstance(); virtual void GetSprites(uint16 voxel_number, uint8 orient, const ImageData *sprites[4]) const = 0; - virtual uint8 GetEntranceDirections(uint16 xvox, uint16 yvox, uint8 zvox) const = 0; + virtual uint8 GetEntranceDirections(const XYZPoint16 &vox) const = 0; virtual RideEntryResult EnterRide(int guest, TileEdge entry_edge) = 0; - virtual void GetExit(int guest, TileEdge entry_edge, uint32 *xpos, uint32 *ypos, uint32 *zpos) = 0; + virtual XYZPoint32 GetExit(int guest, TileEdge entry_edge) = 0; virtual void RemoveAllPeople() = 0; - bool CanBeVisited(uint16 xvox, uint16 yvox, uint8 zvox, TileEdge edge) const; + bool CanBeVisited(const XYZPoint16 &vox, TileEdge edge) const; void SellItem(int item_index); ItemType GetSaleItemType(int item_index) const; @@ -217,7 +217,7 @@ public: RideInstance *instances[MAX_NUMBER_OF_RIDE_INSTANCES]; ///< Rides available in the park. }; -RideInstance *RideExistsAtBottom(int xpos, int ypos, int zpos, TileEdge edge); +RideInstance *RideExistsAtBottom(XYZPoint16 pos, TileEdge edge); extern RidesManager _rides_manager; diff --git a/src/shop_placement.h b/src/shop_placement.h index 269d49a..394ab20 100644 --- a/src/shop_placement.h +++ b/src/shop_placement.h @@ -59,8 +59,8 @@ public: Point16 mouse_pos; ///< Stored mouse position. private: - bool CanPlaceShop(const ShopType *selected_shop, int xpos, int ypos, int zpos); - RidePlacementResult ComputeShopVoxel(int32 xworld, int32 yworld, int32 zworld); + bool CanPlaceShop(const ShopType *selected_shop, const XYZPoint16 &pos); + RidePlacementResult ComputeShopVoxel(XYZPoint32 world_pos); void PlaceShop(const Point16 &pos); }; diff --git a/src/shop_type.cpp b/src/shop_type.cpp index e446a66..c3b61bb 100644 --- a/src/shop_type.cpp +++ b/src/shop_type.cpp @@ -140,9 +140,6 @@ const StringID *ShopType::GetInstanceNames() const ShopInstance::ShopInstance(const ShopType *type) : RideInstance(type) { this->orientation = 0; - this->xpos = 0; - this->ypos = 0; - this->zpos = 0; int capacity = type->GetRideCapacity(); assert(capacity == 0 || (capacity & 0xFF) == 1); ///< \todo Implement loading of guests into a batch. @@ -178,21 +175,19 @@ void ShopInstance::GetSprites(uint16 voxel_number, uint8 orient, const ImageData * @param ypos Y position of the shop. * @param zpos Z position of the shop. */ -void ShopInstance::SetRide(uint8 orientation, uint16 xpos, uint16 ypos, uint8 zpos) +void ShopInstance::SetRide(uint8 orientation, const XYZPoint16 &pos) { assert(this->state == RIS_ALLOCATED); - assert(_world.GetTileOwner(xpos, ypos) == OWN_PARK); // May only place it in your own park. + assert(_world.GetTileOwner(pos.x, pos.y) == OWN_PARK); // May only place it in your own park. this->orientation = orientation; - this->xpos = xpos; - this->ypos = ypos; - this->zpos = zpos; + this->vox_pos = pos; this->flags = 0; } -uint8 ShopInstance::GetEntranceDirections(uint16 xvox, uint16 yvox, uint8 zvox) const +uint8 ShopInstance::GetEntranceDirections(const XYZPoint16 &vox) const { - if (xvox != this->xpos || yvox != this->ypos || zvox != this->zpos) return 0; + if (vox != this->vox_pos) return 0; uint8 entrances = this->GetShopType()->flags & SHF_ENTRANCE_BITS; return ROL(entrances, 4, this->orientation); @@ -218,14 +213,12 @@ RideEntryResult ShopInstance::EnterRide(int guest, TileEdge entry) return RER_REFUSED; } -void ShopInstance::GetExit(int guest, TileEdge entry_edge, uint32 *xpos, uint32 *ypos, uint32 *zpos) +XYZPoint32 ShopInstance::GetExit(int guest, TileEdge entry_edge) { /* Put the guest just outside the ride. */ Point16 dxy = _exit_dxy[(entry_edge + 2) % 4]; - *xpos = this->xpos * 256 + dxy.x; - *ypos = this->ypos * 256 + dxy.y; - *zpos = this->zpos * 256; - return; + return XYZPoint32(this->vox_pos.x * 256 + dxy.x, this->vox_pos.y * 256 + dxy.y, this->vox_pos.z * 256); + } void ShopInstance::RemoveAllPeople() diff --git a/src/shop_type.h b/src/shop_type.h index f8cdcc3..c0ead08 100644 --- a/src/shop_type.h +++ b/src/shop_type.h @@ -47,17 +47,15 @@ public: const ShopType *GetShopType() const; void GetSprites(uint16 voxel_number, uint8 orient, const ImageData *sprites[4]) const override; - void SetRide(uint8 orientation, uint16 xpos, uint16 ypos, uint8 zpos); - uint8 GetEntranceDirections(uint16 xvox, uint16 yvox, uint8 zvox) const override; + void SetRide(uint8 orientation, const XYZPoint16 &pos); + uint8 GetEntranceDirections(const XYZPoint16 &vox) const override; RideEntryResult EnterRide(int guest, TileEdge entry) override; - void GetExit(int guest, TileEdge entry_edge, uint32 *xpos, uint32 *ypos, uint32 *zpos) override; + XYZPoint32 GetExit(int guest, TileEdge entry_edge) override; void RemoveAllPeople() override; void OnAnimate(int delay) override; - uint8 orientation; ///< Orientation of the shop. - uint16 xpos; ///< X position of the shop base voxel. - uint16 ypos; ///< Y position of the shop base voxel. - uint8 zpos; ///< Z position of the shop base voxel. + uint8 orientation; ///< Orientation of the shop. + XYZPoint16 vox_pos; ///< Position of the shop base voxel. private: OnRideGuests onride_guests; ///< Guests in the ride. -- 2.2.1