-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
98 lines (92 loc) · 3.89 KB
/
Copy pathMain.cpp
File metadata and controls
98 lines (92 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "plugin.h"
#include <vector>
#include <filesystem>
#include "DebugPrint.h"
using namespace plugin;
using namespace std;
using namespace std::filesystem;
enum SearchPathFlags
{
SEARCHPATH_ADD_TO_TAIL, ///< Put this search location after existing locations
SEARCHPATH_ADD_TO_HEAD ///< Put this search location before the existing locations
};
path GetIniSearchPath(wstring const &key) {
wchar_t buf[MAX_PATH];
GetPrivateProfileStringW(L"SearchPaths", key.c_str(), L"", buf, MAX_PATH, FIFA::GameDirPath(L"plugins\\AssetLoader.ini").c_str());
return path(ToUTF8(buf));
}
uintptr_t gSetSearchPath = 0;
void METHOD FileSysManager_SetSearchPath(void *t, DUMMY_ARG, char const *searchPath) {
vector<path> searchPaths;
path s = searchPath;
for (size_t i = 1; i <= 10; i++) {
auto p = GetIniSearchPath(Format(L"Path%d", i));
if (!p.is_absolute())
p = s / p;
if (find(searchPaths.begin(), searchPaths.end(), p) == searchPaths.end())
searchPaths.push_back(p);
}
if (find(searchPaths.begin(), searchPaths.end(), s) == searchPaths.end())
searchPaths.push_back(searchPath);
string newSearchPath;
bool first = true;
for (auto const &p : searchPaths) {
if (first)
first = false;
else
newSearchPath += ';';
newSearchPath += p.string();
}
CallMethodDynGlobal(gSetSearchPath, t, newSearchPath.c_str());
}
class FifaAssetLoader {
public:
FifaAssetLoader() {
if (!CheckPluginName(Magic<'A','s','s','e','t','L','o','a','d','e','r','.','a','s','i'>()))
return;
auto v = FIFA::GetAppVersion();
switch (v.id()) {
case ID_FIFA14_1700:
patch::SetUChar(0x14E10EE + 1, SEARCHPATH_ADD_TO_TAIL);
patch::SetUChar(0x14E1131 + 1, SEARCHPATH_ADD_TO_TAIL);
gSetSearchPath = patch::RedirectCall(0x14E0FBC, FileSysManager_SetSearchPath);
break;
case ID_FIFA14_1400_3DM:
patch::SetUChar(0x14E309E + 1, SEARCHPATH_ADD_TO_TAIL);
patch::SetUChar(0x14E30E1 + 1, SEARCHPATH_ADD_TO_TAIL);
gSetSearchPath = patch::RedirectCall(0x14E2F6C, FileSysManager_SetSearchPath);
break;
case ID_FIFA13_1700_RLD:
patch::SetUChar(0x1299B3E + 1, SEARCHPATH_ADD_TO_TAIL);
patch::SetUChar(0x1299B81 + 1, SEARCHPATH_ADD_TO_TAIL);
gSetSearchPath = patch::RedirectCall(0x1299A0C, FileSysManager_SetSearchPath);
break;
case ID_FIFA13_1800:
patch::SetUChar(0x129EADE + 1, SEARCHPATH_ADD_TO_TAIL);
patch::SetUChar(0x129EB21 + 1, SEARCHPATH_ADD_TO_TAIL);
gSetSearchPath = patch::RedirectCall(0x129E9AC, FileSysManager_SetSearchPath);
break;
case ID_FIFA12_1700:
patch::SetUChar(0xB9BCB5 + 1, SEARCHPATH_ADD_TO_TAIL);
patch::SetUChar(0xB9BCF8 + 1, SEARCHPATH_ADD_TO_TAIL);
gSetSearchPath = patch::RedirectCall(0xB9BB62, FileSysManager_SetSearchPath);
break;
case ID_FIFA12_1500_SKD:
patch::SetUChar(0xB99FB5 + 1, SEARCHPATH_ADD_TO_TAIL);
patch::SetUChar(0xB99FF8 + 1, SEARCHPATH_ADD_TO_TAIL);
gSetSearchPath = patch::RedirectCall(0xB99E62, FileSysManager_SetSearchPath);
break;
case ID_FIFA12_1000_RLD:
patch::SetUChar(0x516085 + 1, SEARCHPATH_ADD_TO_TAIL);
patch::SetUChar(0x5160C8 + 1, SEARCHPATH_ADD_TO_TAIL);
gSetSearchPath = patch::RedirectCall(0x515F32, FileSysManager_SetSearchPath);
break;
case ID_FIFA11_1010_FLT:
case ID_FIFA11_1010:
patch::SetUChar(0x8E8E0C + 1, SEARCHPATH_ADD_TO_TAIL);
patch::SetUChar(0x8E8E4F + 1, SEARCHPATH_ADD_TO_TAIL);
gSetSearchPath = patch::RedirectCall(0x8E8D11, FileSysManager_SetSearchPath);
break;
}
}
} fifaAssetLoader;