mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
The track design was recognised as a Corkscrew RC, not as a Hypercoaster. Moved the conversion code from the track design repository to the TD6Importer (where it should have been, really). This also fixes the issue that Hypercoasters, Monster Trucks, Classic Mini Roller Coasters, Spinning Wild Mouses and Hyper-Twisters placed from a track design have the wrong ride type.
This commit is contained in:
committed by
GitHub
parent
0ae86d0558
commit
e5ec74feaf
@@ -24,6 +24,7 @@
|
||||
- Fix: [#12881] Guests' favourite rides are not listed in the guest window.
|
||||
- Fix: [#12910] Plugin API: getRide sometimes returns null for valid ride IDs.
|
||||
- Fix: [#12912] Plugin: selectedCell of CustomListView is being ignored on creation.
|
||||
- Fix: [#12918] Cannot place vanilla TD6 tracks of the Hypercoaster, Monster Trucks, Classic Mini Roller Coaster, Spinning Wild Mouse and Hyper-Twister types.
|
||||
- Fix: Incomplete loop collision box allowed overlapping track (original bug).
|
||||
- Improved: [#12806] Add Esperanto diacritics to the sprite font.
|
||||
- Improved: [#12837] Arabic text is now drawn and shaped correctly on Windows.
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "../core/MemoryStream.h"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../object/ObjectRepository.h"
|
||||
#include "../object/RideObject.h"
|
||||
#include "../rct12/SawyerChunkReader.h"
|
||||
#include "../rct12/SawyerEncoding.h"
|
||||
#include "../ride/Ride.h"
|
||||
@@ -20,6 +22,10 @@
|
||||
#include "../ride/TrackDesign.h"
|
||||
#include "../ride/TrackDesignRepository.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
static std::mutex _objectLookupMutex;
|
||||
|
||||
/**
|
||||
* Class to import RollerCoaster Tycoon 2 track designs (*.TD6).
|
||||
*/
|
||||
@@ -200,8 +206,30 @@ public:
|
||||
}
|
||||
|
||||
td->name = _name;
|
||||
|
||||
UpdateRideType(td);
|
||||
|
||||
return td;
|
||||
}
|
||||
|
||||
void UpdateRideType(std::unique_ptr<TrackDesign>& td)
|
||||
{
|
||||
if (RCT2RideTypeNeedsConversion(td->type))
|
||||
{
|
||||
std::scoped_lock<std::mutex> lock(_objectLookupMutex);
|
||||
auto* rawObject = object_repository_load_object(&td->vehicle_object);
|
||||
if (rawObject != nullptr)
|
||||
{
|
||||
const auto* rideEntry = static_cast<const rct_ride_entry*>(
|
||||
static_cast<RideObject*>(rawObject)->GetLegacyData());
|
||||
if (rideEntry != nullptr)
|
||||
{
|
||||
td->type = RCT2RideTypeToOpenRCT2RideType(td->type, rideEntry);
|
||||
}
|
||||
object_delete(rawObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<ITrackImporter> TrackImporter::CreateTD6()
|
||||
|
||||
@@ -21,14 +21,12 @@
|
||||
#include "../core/String.hpp"
|
||||
#include "../localisation/LocalisationService.h"
|
||||
#include "../object/ObjectRepository.h"
|
||||
#include "../object/RideObject.h"
|
||||
#include "../ride/RideData.h"
|
||||
#include "../util/Util.h"
|
||||
#include "TrackDesign.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
@@ -55,8 +53,6 @@ std::string GetNameFromTrackPath(const std::string& path)
|
||||
return name;
|
||||
}
|
||||
|
||||
static std::mutex _objectLookupMutex;
|
||||
|
||||
class TrackDesignFileIndex final : public FileIndex<TrackRepositoryItem>
|
||||
{
|
||||
private:
|
||||
@@ -82,27 +78,10 @@ public:
|
||||
auto td6 = track_design_open(path.c_str());
|
||||
if (td6 != nullptr)
|
||||
{
|
||||
ObjectEntryIndex rideType = td6->type;
|
||||
if (RCT2RideTypeNeedsConversion(td6->type))
|
||||
{
|
||||
std::scoped_lock<std::mutex> lock(_objectLookupMutex);
|
||||
auto* rawObject = object_repository_load_object(&td6->vehicle_object);
|
||||
if (rawObject != nullptr)
|
||||
{
|
||||
const auto* rideEntry = static_cast<const rct_ride_entry*>(
|
||||
static_cast<RideObject*>(rawObject)->GetLegacyData());
|
||||
if (rideEntry != nullptr)
|
||||
{
|
||||
rideType = RCT2RideTypeToOpenRCT2RideType(td6->type, rideEntry);
|
||||
}
|
||||
object_delete(rawObject);
|
||||
}
|
||||
}
|
||||
|
||||
TrackRepositoryItem item;
|
||||
item.Name = GetNameFromTrackPath(path);
|
||||
item.Path = path;
|
||||
item.RideType = rideType;
|
||||
item.RideType = td6->type;
|
||||
item.ObjectEntry = std::string(td6->vehicle_object.name, 8);
|
||||
item.Flags = 0;
|
||||
if (IsTrackReadOnly(path))
|
||||
|
||||
Reference in New Issue
Block a user