Skip to content

Commit a06a410

Browse files
committed
Added support for MartySamas 5.8 Files
1 parent 103fea8 commit a06a410

28 files changed

Lines changed: 4501 additions & 37 deletions

Metin2Integration/Client/MartySama58/EterPackManager_Vpk.cpp

Lines changed: 635 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#pragma once
2+
3+
//
4+
// EterPackManager_Vpk.h - MartySama 5.8 Profile
5+
//
6+
// Drop-in replacement for EterPackManager.h that adds native VPK support
7+
// to the MartySama 5.8 architecture.
8+
//
9+
// Key differences from the 40250 profile:
10+
// - Uses boost::unordered_map (MartySama uses Boost throughout)
11+
// - Uses #pragma once (MartySama header style)
12+
// - Includes HybridCrypt methods (same as MartySama's original)
13+
// - Include paths match MartySama's directory layout (../eterBase/)
14+
//
15+
// Key differences from the FliegeV3 profile:
16+
// - Has HybridCrypt support (WriteHybridCryptPackInfo, RetrieveHybridCryptPackKeys,
17+
// RetrieveHybridCryptPackSDB)
18+
// - Has DecryptPackIV
19+
// - Uses boost::unordered_map (not std::unordered_map)
20+
//
21+
// Usage: Replace #include "EterPackManager.h" with this file, or merge
22+
// the additions into your existing EterPackManager.h.
23+
//
24+
// Reference: Original MartySama 5.8 EterPackManager.h (93 lines)
25+
//
26+
27+
#include <windows.h>
28+
#include <boost/unordered_map.hpp>
29+
#include "../eterBase/Singleton.h"
30+
#include "../eterBase/Stl.h"
31+
32+
#include "EterPack.h"
33+
#include "VpkLoader.h" // <-- NEW: CVpkPack
34+
35+
class CEterPackManager : public CSingleton<CEterPackManager>
36+
{
37+
public:
38+
struct SCache
39+
{
40+
BYTE* m_abBufData;
41+
DWORD m_dwBufSize;
42+
};
43+
44+
public:
45+
enum ESearchModes
46+
{
47+
SEARCH_FILE_FIRST,
48+
SEARCH_PACK_FIRST
49+
};
50+
51+
typedef std::list<CEterPack*> TEterPackList;
52+
typedef boost::unordered_map<std::string, CEterPack*, stringhash> TEterPackMap;
53+
54+
// NEW: VPK pack storage (uses boost::unordered_map to match MartySama conventions)
55+
typedef std::list<CVpkPack*> TVpkPackList;
56+
typedef boost::unordered_map<std::string, CVpkPack*, stringhash> TVpkPackMap;
57+
58+
public:
59+
CEterPackManager();
60+
virtual ~CEterPackManager();
61+
62+
void SetCacheMode();
63+
void SetRelativePathMode();
64+
65+
void LoadStaticCache(const char* c_szFileName);
66+
67+
void SetSearchMode(bool bPackFirst);
68+
int GetSearchMode();
69+
70+
//THEMIDA
71+
bool Get(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
72+
73+
//THEMIDA
74+
bool GetFromPack(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
75+
76+
//THEMIDA
77+
bool GetFromFile(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
78+
bool isExist(const char * c_szFileName);
79+
bool isExistInPack(const char * c_szFileName);
80+
81+
// Original EPK registration (unchanged)
82+
bool RegisterPack(const char * c_szName, const char * c_szDirectory, const BYTE* c_pbIV = NULL);
83+
void RegisterRootPack(const char * c_szName);
84+
bool RegisterPackWhenPackMaking(const char * c_szName, const char * c_szDirectory, CEterPack* pPack);
85+
86+
// NEW: VPK-specific registration
87+
bool RegisterVpkPack(const char* c_szName, const char* c_szDirectory);
88+
89+
// NEW: Auto-detect registration - checks for .vpk first, falls back to .eix/.epk
90+
bool RegisterPackAuto(const char* c_szName, const char* c_szDirectory, const BYTE* c_pbIV = NULL);
91+
92+
// NEW: Set the global VPK passphrase (used for all encrypted VPK packs)
93+
void SetVpkPassphrase(const char* passphrase);
94+
95+
bool DecryptPackIV(DWORD key);
96+
97+
const char * GetRootPackFileName();
98+
99+
//for hybridcrypt
100+
//THEMIDA
101+
void WriteHybridCryptPackInfo(const char* pFileName);
102+
103+
//THEMIDA
104+
void RetrieveHybridCryptPackKeys(const BYTE* pStream);
105+
//THEMIDA
106+
void RetrieveHybridCryptPackSDB(const BYTE* pStream);
107+
108+
public:
109+
void ArrangeMemoryMappedPack();
110+
111+
protected:
112+
int ConvertFileName(const char * c_szFileName, std::string & rstrFileName);
113+
bool CompareName(const char * c_szDirectoryName, DWORD iLength, const char * c_szFileName);
114+
115+
CEterPack* FindPack(const char* c_szPathName);
116+
117+
SCache* __FindCache(DWORD dwFileNameHash);
118+
void __ClearCacheMap();
119+
120+
protected:
121+
bool m_bTryRelativePath;
122+
bool m_isCacheMode;
123+
int m_iSearchMode;
124+
125+
CEterFileDict m_FileDict;
126+
CEterPack m_RootPack;
127+
TEterPackList m_PackList;
128+
TEterPackMap m_PackMap;
129+
TEterPackMap m_DirPackMap;
130+
131+
boost::unordered_map<DWORD, SCache> m_kMap_dwNameKey_kCache;
132+
133+
CRITICAL_SECTION m_csFinder;
134+
135+
// NEW: VPK state
136+
TVpkPackList m_VpkPackList;
137+
TVpkPackMap m_VpkPackMap;
138+
std::string m_strVpkPassphrase;
139+
};

0 commit comments

Comments
 (0)