-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
225 lines (159 loc) · 4.48 KB
/
main.cpp
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// Strike
// Bad Ass Hackers 2021-2024
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include "b3d.h"
#include "baf.h"
#include "lab.h"
#include "./unshieldv3/unshieldv3.h"
bool fileexist(const char* sz)
{
FILE* f = fopen(sz, "rb");
if (f == nullptr)
return false;
fclose(f);
return true;
}
int main(int argc, char* argv[])
{
printf("---------------------------------------------------\n");
printf("| TPM Extractor - BAH 2021-2024 |\n");
printf("| Strike & shiny & KnightCop |\n");
printf("| |\n");
printf("| .Z decompression by Wolfgang Frisch |\n");
printf("| |\n");
printf("| This project is in no way affiliated with |\n");
printf("| LEC or Disney. Use at your own peril. |\n");
printf("---------------------------------------------------\n");
if (argc < 3)
{
printf("Usage: TPMExtractor.exe DiscDir DumpDir\n");
goto end;
}
char discRoot[MAX_PATH];
strcpy(discRoot, argv[1]);
char dumpRoot[MAX_PATH];
strcpy(dumpRoot, argv[2]);
char bigZPath[MAX_PATH];
sprintf(bigZPath, "%s/GAMEDATA/GOBS/BIG.Z", discRoot);
if(!fileexist(bigZPath))
{
printf("Could not find: %s\n", bigZPath);
goto end;
}
printf("Install disc: %s\n", discRoot);
{
printf("Dump directory: %s\n", dumpRoot);
if(!CreateDirectory(dumpRoot, NULL))
if (GetLastError() == ERROR_PATH_NOT_FOUND)
{
printf("Couldn't create dump directory: %s\n", dumpRoot);
goto end;
}
}
char bigLabDump[MAX_PATH];
sprintf(bigLabDump, "%s/biglab/", dumpRoot);
CreateDirectory(bigLabDump, NULL);
char checklab[MAX_PATH];
sprintf(checklab, "%s/_backup_.baf", bigLabDump);
//if (!fileexist(checklab))
{
char bigLabPath[MAX_PATH];
sprintf(bigLabPath, "%s/big.lab", dumpRoot);
//if (!fileexist(bigLabPath))
{
printf("Extracting BIG.Z -> big.lab\n");
if (!extract(bigZPath, dumpRoot))
goto end;
}
printf("Extract big.lab to: %s...\n", bigLabDump);
extractlab(bigLabPath, bigLabDump);
DeleteFile(bigLabPath);
}
char localizeLabDump[MAX_PATH];
sprintf(localizeLabDump, "%s/localizelab", dumpRoot);
CreateDirectory(localizeLabDump, NULL);
sprintf(checklab, "%s/courier.gcf", localizeLabDump);
//if (!fileexist(checklab))
{
printf("Extract LOCALIZE.LAB to: %s...\n", localizeLabDump);
char localizeLabPath[MAX_PATH];
sprintf(localizeLabPath, "%s/GAMEDATA/GOBS/LOCALIZE.LAB", discRoot);
extractlab(localizeLabPath, localizeLabDump);
}
char voiceLabDump[MAX_PATH];
sprintf(voiceLabDump, "%s/voicelab", dumpRoot);
CreateDirectory(voiceLabDump, NULL);
sprintf(checklab, "%s/3GD6715.WV", voiceLabDump);
//if (!fileexist(checklab))
{
printf("Extract VOICE.LAB to: %s...\n", voiceLabDump);
char voiceLabPath[MAX_PATH];
sprintf(voiceLabPath, "%s/GAMEDATA/GOBS/VOICE.LAB", discRoot);
extractlab(voiceLabPath, voiceLabDump);
}
{
char levelDumpRoot[MAX_PATH];
sprintf(levelDumpRoot, "%s/LEVEL/", dumpRoot);
CreateDirectory(levelDumpRoot, NULL);
const char* levels[] = {
"ASSAULT.B3D",
"BIGCITY.B3D",
"ESPA.B3D",
"FEDSHIP.B3D",
"FINAL.B3D",
"GARDEN.B3D",
"GUNGA.B3D",
"MAUL.B3D",
"QUEEN.B3D",
"RACE.B3D",
"SWAMP.B3D"
};
for (int x = 0; x < sizeof(levels) / sizeof(char*); x++)
{
char b3dfile[MAX_PATH];
sprintf(b3dfile, "%s/GAMEDATA/LEVEL/%s", discRoot, levels[x]);
b3dexperiment(b3dfile, levelDumpRoot, true);
}
}
{
printf("Processing .BAF files...\n");
char bafdump[MAX_PATH];
sprintf(bafdump, "%s/BAF/", dumpRoot);
CreateDirectory(bafdump, NULL);
char findbaf[MAX_PATH];
sprintf(findbaf, "%s*.baf", bigLabDump);
WIN32_FIND_DATA fd;
HANDLE searchHandle = FindFirstFile(findbaf, &fd);
while (searchHandle != INVALID_HANDLE_VALUE)
{
// dont read paths
if ((~fd.dwFileAttributes) & FILE_ATTRIBUTE_DIRECTORY)
{
char baffile[MAX_PATH];
sprintf(baffile, "%s/%s", bigLabDump, fd.cFileName);
char bafname[32];
strcpy(bafname, fd.cFileName);
for(int i=0; ; i++)
if (bafname[i] == '.')
{
bafname[i] = 0;
break;
}
char baffiledump[MAX_PATH];
sprintf(baffiledump, "%s/%s/", bafdump, bafname);
CreateDirectory(baffiledump, NULL);
dumpbaf(baffile, baffiledump);
}
if (!FindNextFile(searchHandle, &fd))
break;
}
}
end:
printf("\n\n---------------Press any key to exit---------------\n");
while (!_getch())
Sleep(10);
return 0;
}