37#if ENABLE_NLS && defined(_WIN32)
45static void printHelp()
50 <<
_(
"mana [options] [mana-file]") << endl << endl
51 <<
_(
"[mana-file] : The mana file is an XML file (.mana)") << endl
52 <<
_(
" used to set custom parameters") << endl
53 <<
_(
" to the mana client.")
55 <<
_(
"Options:") << endl
56 <<
_(
" -v --version : Display the version") << endl
57 <<
_(
" -h --help : Display this help") << endl
58 <<
_(
" -C --config-dir : Configuration directory to use") << endl
59 <<
_(
" -U --username : Login with this username") << endl
60 <<
_(
" -P --password : Login with this password") << endl
61 <<
_(
" -c --character : Login with this character") << endl
62 <<
_(
" -s --server : Login server name or IP") << endl
63 <<
_(
" -p --port : Login server port") << endl
64 <<
_(
" -y --server-type : Login server type") << endl
65 <<
_(
" --update-host : Use this update host") << endl
66 <<
_(
" -D --default : Choose default character server and "
68 <<
_(
" -u --skip-update : Skip the update downloads") << endl
69 <<
_(
" -d --data : Directory to load game data from") << endl
70 <<
_(
" --localdata-dir : Directory to use as local data directory") << endl
71 <<
_(
" --chat-log-dir : Chat log dir to use") << endl
72 <<
_(
" --screenshot-dir : Directory to store screenshots") << endl
74 <<
_(
" --no-opengl : Disable OpenGL for this session") << endl
79static void printVersion()
84static void parseOptions(
int argc,
char *argv[],
Client::Options &options)
86 const char *optstring =
"hvud:U:P:Dc:s:p:C:y:";
88 const struct option long_options[] = {
89 {
"config-dir", required_argument,
nullptr,
'C' },
90 {
"data", required_argument,
nullptr,
'd' },
91 {
"default", no_argument,
nullptr,
'D' },
92 {
"password", required_argument,
nullptr,
'P' },
93 {
"character", required_argument,
nullptr,
'c' },
94 {
"help", no_argument,
nullptr,
'h' },
95 {
"localdata-dir", required_argument,
nullptr,
'L' },
96 {
"update-host", required_argument,
nullptr,
'H' },
97 {
"port", required_argument,
nullptr,
'p' },
98 {
"server", required_argument,
nullptr,
's' },
99 {
"skip-update", no_argument,
nullptr,
'u' },
100 {
"username", required_argument,
nullptr,
'U' },
101 {
"no-opengl", no_argument,
nullptr,
'O' },
102 {
"chat-log-dir", required_argument,
nullptr,
'T' },
103 {
"version", no_argument,
nullptr,
'v' },
104 {
"screenshot-dir", required_argument,
nullptr,
'i' },
105 {
"server-type", required_argument,
nullptr,
'y' },
109 while (optind < argc)
111 int result = getopt_long(argc, argv, optstring, long_options,
nullptr);
147 options.
serverPort =
static_cast<uint16_t
>(atoi(optarg));
174 std::cerr <<
_(
"Invalid server type, expected one of: tmwathena, manaserv") << std::endl;
189static void initInternationalization()
195 ULONG numLanguages = 0;
196 ULONG bufferSize = 0;
197 if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numLanguages,
nullptr, &bufferSize))
199 if (numLanguages == 0 || bufferSize < 2)
202 std::wstring localeNamesW(bufferSize, L
'\0');
203 if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numLanguages, localeNamesW.data(), &bufferSize))
209 for (
size_t i = 0; i < localeNamesW.size() - 2; ++i) {
210 auto &c = localeNamesW[i];
217 _wputenv_s(L
"LANG", localeNamesW.c_str());
220 setlocale(LC_MESSAGES,
"");
223 const auto translationsDir = getResourcesLocation() +
"/Translations";
224 bindtextdomain(
"mana", translationsDir.c_str());
226 bindtextdomain(
"mana", LOCALEDIR);
229 bind_textdomain_codeset(
"mana",
"UTF-8");
235int main(
int argc,
char *argv[])
237#if defined(DEBUG) && defined(__MINGW32__)
239 LoadLibrary(
"exchndl.dll");
242 setlocale(LC_ALL,
".UTF8");
247 parseOptions(argc, argv, options);
258 initInternationalization();
262 std::cout <<
"Error while initializing PhysFS: "
271 return client.
exec();
The core part of the client.
static ServerType parseType(const std::string &type)
int main(int argc, char *argv[])
bool init(const char *argv0)
const char * getLastError()
void init()
Initializes the XML engine.
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
A structure holding the values of various options that can be passed from the command line.
std::string screenshotDir