2
* OpenTyrian: A modern cross-platform port of Tyrian
3
* Copyright (C) 2007-2009 The OpenTyrian Development Team
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#include "arg_parse.h"
35
JE_boolean richMode = false, constantPlay = false, constantDie = false;
37
/* YKS: Note: LOOT cheat had non letters removed. */
38
const char pars[][9] = {
39
"LOOT", "RECORD", "NOJOY", "CONSTANT", "DEATH", "NOSOUND", "NOXMAS", "YESXMAS"
42
void JE_paramCheck( int argc, char *argv[] )
44
const Options options[] =
46
{ 'h', 'h', "help", false },
48
{ 's', 's', "no-sound", false },
49
{ 'j', 'j', "no-joystick", false },
50
{ 'x', 'x', "no-xmas", false },
52
{ 't', 't', "data", true },
54
{ 'n', 'n', "net", true },
55
{ 256, 0, "net-player-name", true }, // TODO: no short codes because there should
56
{ 257, 0, "net-player-number", true }, // be a menu for entering these in the future
57
{ 'p', 'p', "net-port", true },
58
{ 'd', 'd', "net-delay", true },
60
{ 'X', 'X', "xmas", false },
61
{ 'c', 'c', "constant", false },
62
{ 'k', 'k', "death", false },
63
{ 'r', 'r', "record", false },
64
{ 'l', 'l', "loot", false },
73
option = parse_args(argc, (const char **)argv, options);
75
if (option.value == NOT_OPTION)
81
case AMBIGUOUS_OPTION:
82
case OPTION_MISSING_ARG:
83
fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]);
88
printf("Usage: %s [OPTION...]\n\n"
90
" -h, --help Show help about options\n\n"
91
" -s, --no-sound Disable audio\n"
92
" -j, --no-joystick Disable joystick/gamepad input\n"
93
" -x, --no-xmas Disable Christmas mode\n\n"
94
" -t, --data=DIR Set Tyrian data directory\n\n"
95
" -n, --net=HOST[:PORT] Start a networked game\n"
96
" --net-player-name=NAME Sets local player name in a networked game\n"
97
" --net-player-number=NUMBER Sets local player number in a networked game\n"
99
" -p, --net-port=PORT Local port to bind (default is 1333)\n"
100
" -d, --net-delay=FRAMES Set lag-compensation delay (default is 1)\n", argv[0]);
105
// Disables sound/music usage
106
audio_disabled = true;
110
// Disables joystick detection
111
ignore_joystick = true;
118
// set custom Tyrian data directory
120
custom_data_dir = option.arg;
124
isNetworkGame = true;
126
intptr_t temp = (intptr_t)strchr(option.arg, ':');
129
temp -= (intptr_t)option.arg;
131
int temp_port = atoi(&option.arg[temp + 1]);
132
if (temp_port > 0 && temp_port < 49152)
133
network_opponent_port = temp_port;
136
fprintf(stderr, "%s: error: invalid network port number\n", argv[0]);
140
network_opponent_host = malloc(temp + 1);
141
strnztcpy(network_opponent_host, option.arg, temp);
145
network_opponent_host = malloc(strlen(option.arg) + 1);
146
strcpy(network_opponent_host, option.arg);
150
case 256: // --net-player-name
151
network_player_name = malloc(strlen(option.arg) + 1);
152
strcpy(network_player_name, option.arg);
155
case 257: // --net-player-number
157
int temp = atoi(option.arg);
158
if (temp >= 1 && temp <= 2)
159
thisPlayerNum = temp;
162
fprintf(stderr, "%s: error: invalid network player number\n", argv[0]);
169
int temp = atoi(option.arg);
170
if (temp > 0 && temp < 49152)
171
network_player_port = temp;
174
fprintf(stderr, "%s: error: invalid network port number\n", argv[0]);
182
if (sscanf(option.arg, "%d", &temp) == 1)
183
network_delay = 1 + temp;
186
fprintf(stderr, "%s: error: invalid network delay value\n", argv[0]);
196
/* Constant play for testing purposes (C key activates invincibility)
197
This might be useful for publishers to see everything - especially
198
those who can't play it */
211
// Gives you mucho bucks
221
// legacy parameter support
222
for (int i = option.argn; i < argc; ++i)
224
for (uint j = 0; j < strlen(argv[i]); ++j)
225
argv[i][j] = toupper((unsigned char)argv[i][j]);
227
for (uint j = 0; j < COUNTOF(pars); ++j)
229
if (strcmp(argv[i], pars[j]) == 0)
240
ignore_joystick = true;
249
audio_disabled = true;