-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cpp
122 lines (112 loc) · 3.17 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
#include "CLCHeaders.h"
#include "Converters/XML/MissionConvert.h"
#include "Converters/XML/MovieDataConvert.h"
#include "Converters/CustomFormat/VegetationDumpConvert.h"
#include "XML/EntArchetypeObtainer.h"
#include "Converters/XML/TerrainLayerInfoConvert.h"
#include <chrono>
#include <locale>
#include <codecvt>
#include <future>
#ifdef USE_PAK_INTERACTION
#include "zipper/unzipper.h"
#endif
inline void PakConvert(const char* path)
{
#ifdef USE_PAK_INTERACTION
MissionConvert c_m;
MovieDataConvert m_m;
TerrainLayerInfoConvert t_m;
zipper::Unzipper arch(path);
std::vector<unsigned char> data;
bool success = arch.extractEntryToMemory(cry_fname::in::MISSIONXML, data);
if (success)
{
c_m.ConvertFromByteArray(data);
c_m.ExtractTOD();
}
success = arch.extractEntryToMemory(cry_fname::in::MDATA, data);
if (success) m_m.ConvertFromByteArray(data);
success = arch.extractEntryToMemory(cry_fname::in::LVLDATA, data);
if (success) t_m.ConvertFromByteArray(data);
std::cout << "[PakConvert] " << path << " converted\n";
#else
std::cout << path << " was not processed because CLC was compiled without USE_PAK_INTERACTION\n";
#endif
}
inline void ConvertData(const char* path)
{
MissionConvert mis_convert;
MovieDataConvert mdata_convert;
TerrainLayerInfoConvert terlay_convert;
if (!fs::exists(path)){
std::cout << path << " doesn't exist.\n";
return;
}
switch (Util::DetectDataType(path))
{
case Util::DATA_TYPES::DIR:
ConvertData(path);
break;
case Util::DATA_TYPES::MDATA:
if (mdata_convert.ConvertFromDisk(path))
{
std::cout << "[MovieData] Converted moviedata to .lyr!\n";
}
break;
case Util::DATA_TYPES::MISSION:
if (mis_convert.ConvertFromDisk(path))
{
std::cout << "[MissionConvert] Converted mission to .lyr!\n";
mis_convert.ExtractTOD();
}
break;
case Util::DATA_TYPES::PAK:
PakConvert(path);
break;
case Util::DATA_TYPES::AIDUMP:
std::cout << "Use CryDumper for AIDump.\n";
break;
case Util::DATA_TYPES::TERRAINDUMP:
std::cout << "Use CryDumper for TerrainDump.\n";
break;
case Util::DATA_TYPES::VEGDUMP:
VegetationDumpConvert(path, std::string(path) + "clc_veg.veg");
break;
case Util::DATA_TYPES::GEOMDUMP:
std::cout << "Use CryDumper for GeomDump.\n";
break;
case Util::DATA_TYPES::TERLAYDUMP:
terlay_convert.ConvertFromDisk(path);
break;
case Util::DATA_TYPES::UNKNOWN:
std::cout << "Unknown file format.\n";
break;
}
}
int main(int argc, char* argv[])
{
auto begin = std::chrono::steady_clock::now();
std::ios_base::sync_with_stdio(false);
std::cout << "CryLevelConvert V2 by Prophet\n";
MissionConvert::GetEntArcObtainter().FillEntArcList();
if (argc > 1)
{
for (int a = 1; a < argc; a++)
{
std::cout << argv[a] << "\n";
std::async(std::launch::async, ConvertData, argv[a]);
}
}
else
{
ConvertData(cry_fname::in::MISSIONXML.data());
ConvertData(cry_fname::in::MDATA.data());
ConvertData(cry_fname::in::LVLDATA.data());
VegetationDumpConvert("veg_dump.txt", "clc_veg.veg");
}
auto end = std::chrono::steady_clock::now();
auto elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin);
std::cout << "Elapsed time: " << elapsed_ms.count() << " ms\n";
Util::DelayedExit();
}