Skip to content

Commit 4c499ff

Browse files
authored
Merge pull request #204 from zrax/location_negative_prefixes
Make Location encoding algorithm consistent with other implementations.
2 parents 96df946 + f18b39f commit 4c499ff

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

PlasMOUL/Key.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ MOUL::Location::Location(int prefix, int page, uint16_t flags)
2828
: m_flags(flags)
2929
{
3030
if (prefix < 0)
31-
m_sequence = (page & 0xFFFF) - (prefix << 16) + 0xFF000001;
31+
m_sequence = ((-prefix << 16) + (page & 0xFFFF)) + 0xFF000001;
3232
else
33-
m_sequence = (page & 0xFFFF) + (prefix << 16) + 33;
33+
m_sequence = (prefix << 16) + (page & 0xFFFF) + 33;
3434
}
3535

3636
void MOUL::Location::read(DS::Stream* stream)

Tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include(FetchContent)
22
FetchContent_Declare(
33
Catch2
44
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
5-
GIT_TAG v2.13.9
5+
GIT_TAG v2.13.10
66
)
77
FetchContent_MakeAvailable(Catch2)
88

Tests/Test_Location.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,17 @@ TEST_CASE("Test MOUL::Location", "[location]")
5353
CHECK_SEQUENCE(MOUL::Location(1, -34, 0), 0x0001FFFF);
5454
CHECK_SEQUENCE(MOUL::Location(-255, 65535, 0), 0x00000000);
5555
CHECK_SEQUENCE(MOUL::Location(-255, -2, 0), 0xFFFFFFFF);
56+
57+
// Examples from real PRPs
58+
CHECK_SEQUENCE(MOUL::Location(6, 1, 0), 0x00060022); // city:canyon
59+
CHECK_SEQUENCE(MOUL::Location(6, 101, 0), 0x00060086); // city:museumDoor
60+
CHECK_SEQUENCE(MOUL::Location(6, -2, 0), 0x0007001F); // city:BuiltIn
61+
CHECK_SEQUENCE(MOUL::Location(6, -1, 0), 0x00070020); // city:Textures
62+
CHECK_SEQUENCE(MOUL::Location(1234, 5, 0), 0x04D20026); // GoMePubNew:Entry
63+
CHECK_SEQUENCE(MOUL::Location(40004, 1, 0), 0x9C440022); // VeeTsah:Temple
64+
CHECK_SEQUENCE(MOUL::Location(40004, -1, 0), 0x9C450020); // VeeTsah:Textures
65+
CHECK_SEQUENCE(MOUL::Location(-1, 8, 0), 0xFF010009); // GlobalAnimations:MaileIdle
66+
CHECK_SEQUENCE(MOUL::Location(-1, 435, 0), 0xFF0101B4); // GlobalAnimations:FemaleSwimDockExit
67+
CHECK_SEQUENCE(MOUL::Location(-6, 3, 0), 0xFF060004); // GlobalAvatars:Audio
5668
}
5769
}

0 commit comments

Comments
 (0)