-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdecompiler.cpp
90 lines (76 loc) · 1.54 KB
/
decompiler.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
#include <IL/il.h>
#include <iostream>
#include <string.h>
#include "SMFMap.h"
#include <stdlib.h>
#ifdef WIN32
#include <windows.h>
#include <direct.h>
#include <io.h>
#endif
void help(char ** argv)
{
std::cout << "Usage: " << argv[0] << " -directory [directory where .smt files are] -mapfile [name of the smf file , NOT path ]" << std::endl;
}
int main(int argc, char** argv)
{
ilInit();
if ( argc == 1 )
{
help(argv);
return 1;
}else{
std::string mapdirectory;
std::string mapfile;
bool valid1=false,valid2=false;
for ( int i = 1; i < argc; i++ )
{
if ( strlen(argv[i]) > 1 )
{
if ( argv[i][0] == '-' )
{
if ( strcmp(&argv[i][1],"directory") == 0 )
{
valid1 = true;
if ( i+1 < argc )
{
mapdirectory = argv[++i];
}else{
goto error;
}
}else if ( strcmp(&argv[i][1],"mapfile") == 0 )
{
if ( i+1 < argc )
{
mapfile = argv[++i];
}else{
goto error;
}
valid2 = true;
}
else if ( strncmp(&argv[i][1],"h",1) == 0 )//Help
{
goto error;
}
}
}
}
if ( valid1 && valid2 )
goto success;
error:
help(argv);
return 1;
success:
#ifndef WIN32
if ( chdir(mapdirectory.c_str()) )
#else
if ( _chdir(mapdirectory.c_str()) )
#endif
{
std::cerr << "Cannot change working directory to " << mapdirectory << std::endl;
return 1;
}
SMFMap * m = new SMFMap(mapfile);
m->SaveSourceFiles();
}
}