fix: Properly read in scene metadata (#1170)

* fix: Properly read in scene metadata

* Fix reading in rental time and period from property path

* remove useless name in var
change hex to decimal so it's readable
fix scene transistion loop logic

* fix typoe and remove whitespace
This commit is contained in:
Aaron Kimbrell 2023-08-10 16:35:12 -05:00 committed by GitHub
parent 2cc13c6499
commit beaceb947b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 39 deletions

View File

@ -54,22 +54,22 @@ void Zone::LoadZoneIntoMemory() {
std::istream file(&buffer); std::istream file(&buffer);
if (file) { if (file) {
BinaryIO::BinaryRead(file, m_ZoneFileFormatVersion); BinaryIO::BinaryRead(file, m_FileFormatVersion);
uint32_t mapRevision = 0; uint32_t mapRevision = 0;
if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision); if (m_FileFormatVersion >= Zone::FileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision);
BinaryIO::BinaryRead(file, m_WorldID); BinaryIO::BinaryRead(file, m_WorldID);
if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) Game::logger->Log("Zone", "WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID()); if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) Game::logger->Log("Zone", "WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID());
AddRevision(LWOSCENEID_INVALID, mapRevision); AddRevision(LWOSCENEID_INVALID, mapRevision);
if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::Beta) { if (m_FileFormatVersion >= Zone::FileFormatVersion::Beta) {
BinaryIO::BinaryRead(file, m_Spawnpoint); BinaryIO::BinaryRead(file, m_Spawnpoint);
BinaryIO::BinaryRead(file, m_SpawnpointRotation); BinaryIO::BinaryRead(file, m_SpawnpointRotation);
} }
if (m_ZoneFileFormatVersion <= Zone::ZoneFileFormatVersion::LateAlpha) { if (m_FileFormatVersion <= Zone::FileFormatVersion::LateAlpha) {
uint8_t sceneCount; uint8_t sceneCount;
BinaryIO::BinaryRead(file, sceneCount); BinaryIO::BinaryRead(file, sceneCount);
m_SceneCount = sceneCount; m_SceneCount = sceneCount;
@ -93,14 +93,14 @@ void Zone::LoadZoneIntoMemory() {
BinaryIO::BinaryRead(file, stringLength); BinaryIO::BinaryRead(file, stringLength);
m_ZoneDesc = BinaryIO::ReadString(file, stringLength); m_ZoneDesc = BinaryIO::ReadString(file, stringLength);
if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::PreAlpha) { if (m_FileFormatVersion >= Zone::FileFormatVersion::PreAlpha) {
BinaryIO::BinaryRead(file, m_NumberOfSceneTransitionsLoaded); BinaryIO::BinaryRead(file, m_NumberOfSceneTransitionsLoaded);
for (uint32_t i = 0; i < m_NumberOfSceneTransitionsLoaded; ++i) { for (uint32_t i = 0; i < m_NumberOfSceneTransitionsLoaded; ++i) {
LoadSceneTransition(file); LoadSceneTransition(file);
} }
} }
if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::EarlyAlpha) { if (m_FileFormatVersion >= Zone::FileFormatVersion::EarlyAlpha) {
BinaryIO::BinaryRead(file, m_PathDataLength); BinaryIO::BinaryRead(file, m_PathDataLength);
BinaryIO::BinaryRead(file, m_PathChunkVersion); // always should be 1 BinaryIO::BinaryRead(file, m_PathChunkVersion); // always should be 1
@ -244,16 +244,29 @@ void Zone::LoadScene(std::istream& file) {
scene.triggers.insert({ trigger->id, trigger }); scene.triggers.insert({ trigger->id, trigger });
} }
BinaryIO::BinaryRead(file, scene.id); if (m_FileFormatVersion >= Zone::FileFormatVersion::LatePreAlpha || m_FileFormatVersion < Zone::FileFormatVersion::PrePreAlpha) {
BinaryIO::BinaryRead(file, scene.sceneType); BinaryIO::BinaryRead(file, scene.id);
lwoSceneID.SetSceneID(scene.id); lwoSceneID.SetSceneID(scene.id);
}
if (m_FileFormatVersion >= Zone::FileFormatVersion::LatePreAlpha) {
BinaryIO::BinaryRead(file, scene.sceneType);
lwoSceneID.SetLayerID(scene.sceneType);
uint8_t sceneNameLength; uint8_t sceneNameLength;
BinaryIO::BinaryRead(file, sceneNameLength); BinaryIO::BinaryRead(file, sceneNameLength);
scene.name = BinaryIO::ReadString(file, sceneNameLength); scene.name = BinaryIO::ReadString(file, sceneNameLength);
file.ignore(3); }
lwoSceneID.SetLayerID(scene.sceneType); if (m_FileFormatVersion == Zone::FileFormatVersion::LatePreAlpha){
BinaryIO::BinaryRead(file, scene.unknown1);
BinaryIO::BinaryRead(file, scene.unknown2);
}
if (m_FileFormatVersion >= Zone::FileFormatVersion::LatePreAlpha) {
BinaryIO::BinaryRead(file, scene.color_r);
BinaryIO::BinaryRead(file, scene.color_b);
BinaryIO::BinaryRead(file, scene.color_g);
}
m_Scenes.insert(std::make_pair(lwoSceneID, scene)); m_Scenes.insert(std::make_pair(lwoSceneID, scene));
m_NumberOfScenesLoaded++; m_NumberOfScenesLoaded++;
@ -345,7 +358,7 @@ const Path* Zone::GetPath(std::string name) const {
void Zone::LoadSceneTransition(std::istream& file) { void Zone::LoadSceneTransition(std::istream& file) {
SceneTransition sceneTrans; SceneTransition sceneTrans;
if (m_ZoneFileFormatVersion < Zone::ZoneFileFormatVersion::Auramar) { if (m_FileFormatVersion < Zone::FileFormatVersion::Auramar) {
uint8_t length; uint8_t length;
BinaryIO::BinaryRead(file, length); BinaryIO::BinaryRead(file, length);
sceneTrans.name = BinaryIO::ReadString(file, length); sceneTrans.name = BinaryIO::ReadString(file, length);
@ -353,7 +366,7 @@ void Zone::LoadSceneTransition(std::istream& file) {
} }
//BR<42>THER MAY I HAVE SOME L<><4C>PS? //BR<42>THER MAY I HAVE SOME L<><4C>PS?
uint8_t loops = (m_ZoneFileFormatVersion < Zone::ZoneFileFormatVersion::EarlyAlpha || m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::Launch) ? 2 : 5; uint8_t loops = (m_FileFormatVersion <= Zone::FileFormatVersion::LatePreAlpha || m_FileFormatVersion >= Zone::FileFormatVersion::Launch) ? 2 : 5;
for (uint8_t i = 0; i < loops; ++i) { for (uint8_t i = 0; i < loops; ++i) {
sceneTrans.points.push_back(LoadSceneTransitionInfo(file)); sceneTrans.points.push_back(LoadSceneTransitionInfo(file));
@ -401,7 +414,7 @@ void Zone::LoadPath(std::istream& file) {
} else if (path.pathType == PathType::Property) { } else if (path.pathType == PathType::Property) {
BinaryIO::BinaryRead(file, path.property.pathType); BinaryIO::BinaryRead(file, path.property.pathType);
BinaryIO::BinaryRead(file, path.property.price); BinaryIO::BinaryRead(file, path.property.price);
BinaryIO::BinaryRead(file, path.property.rentalTimeUnit); BinaryIO::BinaryRead(file, path.property.rentalTime);
BinaryIO::BinaryRead(file, path.property.associatedZone); BinaryIO::BinaryRead(file, path.property.associatedZone);
if (path.pathVersion >= 5) { if (path.pathVersion >= 5) {
@ -426,14 +439,12 @@ void Zone::LoadPath(std::istream& file) {
if (path.pathVersion >= 7) { if (path.pathVersion >= 7) {
BinaryIO::BinaryRead(file, path.property.cloneLimit); BinaryIO::BinaryRead(file, path.property.cloneLimit);
BinaryIO::BinaryRead(file, path.property.repMultiplier); BinaryIO::BinaryRead(file, path.property.repMultiplier);
BinaryIO::BinaryRead(file, path.property.rentalTimeUnit); BinaryIO::BinaryRead(file, path.property.rentalPeriod);
} }
if (path.pathVersion >= 8) { if (path.pathVersion >= 8) {
BinaryIO::BinaryRead(file, path.property.achievementRequired); BinaryIO::BinaryRead(file, path.property.achievementRequired);
BinaryIO::BinaryRead(file, path.property.playerZoneCoords.x); BinaryIO::BinaryRead(file, path.property.playerZoneCoords);
BinaryIO::BinaryRead(file, path.property.playerZoneCoords.y);
BinaryIO::BinaryRead(file, path.property.playerZoneCoords.z);
BinaryIO::BinaryRead(file, path.property.maxBuildHeight); BinaryIO::BinaryRead(file, path.property.maxBuildHeight);
} }
} else if (path.pathType == PathType::Camera) { } else if (path.pathType == PathType::Camera) {
@ -543,11 +554,7 @@ void Zone::LoadPath(std::istream& file) {
if (ldfConfig) waypoint.config.push_back(ldfConfig); if (ldfConfig) waypoint.config.push_back(ldfConfig);
} }
} }
path.pathWaypoints.push_back(waypoint); path.pathWaypoints.push_back(waypoint);
} }
m_Paths.push_back(path); m_Paths.push_back(path);
} }

View File

@ -18,6 +18,11 @@ struct SceneRef {
uint32_t id; uint32_t id;
uint32_t sceneType; //0 = general, 1 = audio? uint32_t sceneType; //0 = general, 1 = audio?
std::string name; std::string name;
NiPoint3 unknown1;
float unknown2;
uint8_t color_r;
uint8_t color_g;
uint8_t color_b;
Level* level; Level* level;
std::map<uint32_t, LUTriggers::Trigger*> triggers; std::map<uint32_t, LUTriggers::Trigger*> triggers;
}; };
@ -101,7 +106,7 @@ enum class PropertyType : int32_t {
Headspace = 3 Headspace = 3
}; };
enum class PropertyRentalTimeUnit : int32_t { enum class PropertyRentalPeriod : uint32_t {
Forever = 0, Forever = 0,
Seconds = 1, Seconds = 1,
Minutes = 2, Minutes = 2,
@ -112,7 +117,7 @@ enum class PropertyRentalTimeUnit : int32_t {
Years = 7 Years = 7
}; };
enum class PropertyAchievmentRequired : int32_t { enum class PropertyAchievmentRequired : uint32_t {
None = 0, None = 0,
Builder = 1, Builder = 1,
Craftsman = 2, Craftsman = 2,
@ -134,13 +139,14 @@ struct MovingPlatformPath {
struct PropertyPath { struct PropertyPath {
PropertyPathType pathType; PropertyPathType pathType;
int32_t price; int32_t price;
PropertyRentalTimeUnit rentalTimeUnit; uint32_t rentalTime;
uint64_t associatedZone; uint64_t associatedZone;
std::string displayName; std::string displayName;
std::string displayDesc; std::string displayDesc;
PropertyType type; PropertyType type;
int32_t cloneLimit; uint32_t cloneLimit;
float repMultiplier; float repMultiplier;
PropertyRentalPeriod rentalPeriod;
PropertyAchievmentRequired achievementRequired; PropertyAchievmentRequired achievementRequired;
NiPoint3 playerZoneCoords; NiPoint3 playerZoneCoords;
float maxBuildHeight; float maxBuildHeight;
@ -177,15 +183,17 @@ struct Path {
class Zone { class Zone {
public: public:
enum class ZoneFileFormatVersion : uint32_t { //Times are guessed. enum class FileFormatVersion : uint32_t { //Times are guessed.
PreAlpha = 0x20, PrePreAlpha = 30,
EarlyAlpha = 0x23, PreAlpha = 32,
Alpha = 0x24, LatePreAlpha = 33,
LateAlpha = 0x25, EarlyAlpha = 35,
Beta = 0x26, Alpha = 36,
Launch = 0x27, LateAlpha = 37,
Auramar = 0x28, Beta = 38,
Latest = 0x29 Launch = 39,
Auramar = 40,
Latest = 41
}; };
public: public:
@ -221,7 +229,7 @@ private:
uint32_t m_NumberOfScenesLoaded; uint32_t m_NumberOfScenesLoaded;
uint32_t m_NumberOfObjectsLoaded; uint32_t m_NumberOfObjectsLoaded;
uint32_t m_NumberOfSceneTransitionsLoaded; uint32_t m_NumberOfSceneTransitionsLoaded;
ZoneFileFormatVersion m_ZoneFileFormatVersion; FileFormatVersion m_FileFormatVersion;
uint32_t m_CheckSum; uint32_t m_CheckSum;
uint32_t m_WorldID; //should be equal to the MapID uint32_t m_WorldID; //should be equal to the MapID
NiPoint3 m_Spawnpoint; NiPoint3 m_Spawnpoint;