TrinityCore
Loading...
Searching...
No Matches
VMapAssembler.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "Banner.h"
19#include "GitRevision.h"
20#include "Locales.h"
21#include "Optional.h"
22#include "TileAssembler.h"
23#include "Util.h"
24#include <boost/program_options.hpp>
25#include <iostream>
26#include <string>
27#include <thread>
28
29namespace po = boost::program_options;
30
41Optional<int> HandleArgs(int argc, char* argv[], std::string* src, std::string* dest, uint32* threads);
42
43int main(int argc, char* argv[])
44{
46
48
49 std::string src, dest;
50 uint32 threads = 0;
51 if (Optional<int> exitCode = HandleArgs(argc, argv, &src, &dest, &threads))
52 return *exitCode;
53
54 Trinity::Banner::Show("VMAP assembler", [](char const* text) { std::cout << text << std::endl; }, nullptr);
55
56 std::cout << "using " << src << " as source directory and writing output to " << dest << std::endl;
57
58 VMAP::TileAssembler ta(src, dest, threads);
59
60 if (!ta.convertWorld2())
61 {
62 std::cout << "exit with errors" << std::endl;
63 return 1;
64 }
65
66 std::cout << "Ok, all done" << std::endl;
67 return 0;
68}
69
70Optional<int> HandleArgs(int argc, char* argv[], std::string* src, std::string* dest, uint32* threads)
71{
72 po::options_description visible("Usage: vmap4assembler [OPTION]... [SRC] [DEST]\n\nWhere OPTION can be any of");
73 visible.add_options()
74 ("threads", po::value<uint32>(threads)->default_value(std::thread::hardware_concurrency()), "number of threads to use")
75 ("help,h", "print usage message")
76 ("version,v", "print version build info");
77
78 po::options_description all;
79 all.add(visible);
80 all.add_options()
81 ("src", po::value(src)->default_value("Buildings"), "raw data dir")
82 ("dest", po::value(dest)->default_value("vmaps"), "vmap dest dir");
83
84 po::positional_options_description positional;
85 positional.add("src", 1);
86 positional.add("dest", 1);
87
88 po::variables_map variablesMap;
89 try
90 {
91 store(po::command_line_parser(argc, argv).options(all).positional(positional).run(), variablesMap);
92 notify(variablesMap);
93 }
94 catch (std::exception& e)
95 {
96 std::cerr << e.what() << '\n';
97 return 1;
98 }
99
100 if (variablesMap.find("help") != variablesMap.end())
101 {
102 std::cout << visible << '\n';
103 return 0;
104 }
105
106 if (variablesMap.find("version") != variablesMap.end())
107 {
108 std::cout << GitRevision::GetFullVersion() << '\n';
109 return 0;
110 }
111
112 return {};
113}
114
115#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
117// must be at end of file because of init_seg pragma
119#endif
uint32_t uint32
Definition Define.h:154
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
int main(int argc, char *argv[])
Optional< int > HandleArgs(int argc, char *argv[], std::string *src, std::string *dest, uint32 *threads)
INIT_CRASH_HANDLER()
TC_COMMON_API char const * GetFullVersion()
TC_COMMON_API void Show(char const *applicationName, void(*log)(char const *text), void(*logExtraInfo)())
Definition Banner.cpp:22
TC_COMMON_API void Init()
Definition Locales.cpp:28
TC_COMMON_API void VerifyOsVersion()
Definition Util.cpp:35