/** * Remove a path from a tile, and free the voxels above it as well. * @param voxel_pos Coordinate of the voxel. * @param path_spr Imploded sprite number. * @see BuildPathAtTile */ static void RemovePathAtTile(const XYZPoint16 &voxel_pos, uint8 path_spr) { VoxelStack *avs = _additions.GetModifyStack(voxel_pos.x, voxel_pos.y); Voxel *av = avs->GetCreate(voxel_pos.z, false); av->SetInstance(SRI_FREE); av->SetInstanceData(0); AddRemovePathEdges(voxel_pos, path_spr, EDGE_ALL, true, PAS_UNUSED); MarkVoxelDirty(voxel_pos); av = avs->GetCreate(voxel_pos.z + 1, false); av->SetInstance(SRI_FREE); av->SetInstanceData(0); if (path_spr >= PATH_FLAT_COUNT) { av = avs->GetCreate(voxel_pos.z + 2, false); av->SetInstance(SRI_FREE); av->SetInstanceData(0); } }
/** * Build a path at a tile, and claim the voxels above it as well. * @param voxel_pos Coordinate of the voxel. * @param path_type The type of path to build. * @param path_spr Imploded sprite number. * @see RemovePathAtTile */ static void BuildPathAtTile(const XYZPoint16 &voxel_pos, PathType path_type, uint8 path_spr) { VoxelStack *avs = _additions.GetModifyStack(voxel_pos.x, voxel_pos.y); Voxel *av = avs->GetCreate(voxel_pos.z, true); av->SetInstance(SRI_PATH); uint8 slope = AddRemovePathEdges(voxel_pos, path_spr, EDGE_ALL, true, _sprite_manager.GetPathStatus(path_type)); av->SetInstanceData(MakePathInstanceData(slope, path_type)); av = avs->GetCreate(voxel_pos.z + 1, true); av->ClearVoxel(); av->SetInstance(SRI_PATH); av->SetInstanceData(PATH_INVALID); if (path_spr >= PATH_FLAT_COUNT) { // For non-flat sprites, add another voxel. av = avs->GetCreate(voxel_pos.z + 2, true); av->ClearVoxel(); av->SetInstance(SRI_PATH); av->SetInstanceData(PATH_INVALID); } MarkVoxelDirty(voxel_pos); }
void RideBuildWindow::SelectorMouseButtonEvent(uint8 state) { if (!IsLeftClick(state)) return; if (this->selector.area.width != 1 || this->selector.area.height != 1) return; ShopInstance *si = static_cast<ShopInstance *>(this->instance); SmallRideInstance inst_number = static_cast<SmallRideInstance>(this->instance->GetIndex()); uint8 entrances = si->GetEntranceDirections(si->vox_pos); Voxel *v = _world.GetCreateVoxel(si->vox_pos, true); assert(v != nullptr && v->GetInstance() == SRI_FREE); v->SetInstance(inst_number); v->SetInstanceData(entrances); _rides_manager.NewInstanceAdded(inst_number); AddRemovePathEdges(si->vox_pos, PATH_EMPTY, entrances, false, PAS_QUEUE_PATH); this->instance = nullptr; // Delete this window, and si = nullptr; // (Also clean the copy of the pointer.) delete this; ShowShopManagementGui(inst_number); // Open gui for the new shop. }