Skip to content

Commit

Permalink
[MapleLib] Fix issues reading Map2.wz (gms v230+, sea v212+)
Browse files Browse the repository at this point in the history
-not a complete fix, it cant save yet without breaking.
-also, needs more testing to ensure compatibility to recent 64 bit WZs plus all of the older .wzs.
  • Loading branch information
lastbattle committed Mar 13, 2022
1 parent b31d0c8 commit 05245dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions MapleLib/WzLib/WzDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ internal void ParseDirectory(bool lazyParse = false)
int fsize;
int checksum;
uint offset;
int unk_GMS230 = 0;

long rememberPos = 0;
switch (type)
Expand All @@ -213,8 +214,16 @@ internal void ParseDirectory(bool lazyParse = false)
int stringOffset = reader.ReadInt32();
rememberPos = reader.BaseStream.Position;
reader.BaseStream.Position = reader.Header.FStart + stringOffset;

if (this.wzFile.Is64BitWzFile)
{
unk_GMS230 = reader.ReadByte(); // something added in GMS v230/ SEA v212
// TODO: the saving part too.
}
type = reader.ReadByte();
fname = reader.ReadString();

//Console.WriteLine("EntryCount: {0}, Unk: {1}, type: {2}, fname: {3}", entryCount, unk_GMS230, type, fname);
break;
}
case 3:
Expand Down
6 changes: 3 additions & 3 deletions MapleLib/WzLib/WzFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public class WzFile : WzObject
internal WzHeader header;
internal string name = "";
internal ushort wzVersionHeader = 0;
internal const ushort wzVersionHeader64bit_start = 777;
internal const ushort wzVersionHeader64bit_start = 770; // 777 for KMS, GMS v230 uses 778.. wut
internal uint versionHash = 0;
internal short mapleStoryPatchVersion = 0;
internal WzMapleVersion maplepLocalVersion;
internal MapleStoryLocalisation mapleLocaleVersion = MapleStoryLocalisation.Not_Known;

internal bool b64BitClient = false; // KMS update after Q4 2021, ver 1.2.357
private bool b64BitClient_withVerHeader = false; //
internal bool b64BitClient_withVerHeader = false; //

internal byte[] WzIv;
#endregion
Expand Down Expand Up @@ -240,7 +240,7 @@ internal WzFileParseStatus ParseMainWzDirectory(bool lazyParse = false)
// -- the latest KMS update seems to have changed it to 778? 779?
if (b64BitClient)
{
for (ushort maplestoryVerToDecode = wzVersionHeader64bit_start; maplestoryVerToDecode < wzVersionHeader64bit_start + 10; maplestoryVerToDecode++)
for (ushort maplestoryVerToDecode = wzVersionHeader64bit_start; maplestoryVerToDecode < wzVersionHeader64bit_start + 20; maplestoryVerToDecode++)
{
if (TryDecodeWithWZVersionNumber(reader, wzVersionHeader, maplestoryVerToDecode, lazyParse))
{
Expand Down

0 comments on commit 05245dc

Please sign in to comment.