1
0
Fork 0

(svn r3647) Some style-changes to the parameter parser

release/0.5
Darkvater 2006-02-21 17:29:53 +00:00
parent 12290369e2
commit 35ce486704
1 changed files with 19 additions and 29 deletions

View File

@ -307,13 +307,14 @@ int ttd_main(int argc, char* argv[])
{ {
MyGetOptData mgo; MyGetOptData mgo;
int i; int i;
bool network = false;
char *network_conn = NULL;
const char *optformat; const char *optformat;
char musicdriver[16], sounddriver[16], videodriver[16]; char musicdriver[16], sounddriver[16], videodriver[16];
int resolution[2] = {0,0}; int resolution[2] = {0,0};
uint startdate = -1; uint startdate = -1;
bool dedicated;
bool dedicated = false;
bool network = false;
char *network_conn = NULL;
musicdriver[0] = sounddriver[0] = videodriver[0] = 0; musicdriver[0] = sounddriver[0] = videodriver[0] = 0;
@ -321,7 +322,6 @@ int ttd_main(int argc, char* argv[])
_switch_mode = SM_MENU; _switch_mode = SM_MENU;
_switch_mode_errorstr = INVALID_STRING_ID; _switch_mode_errorstr = INVALID_STRING_ID;
_dedicated_forks = false; _dedicated_forks = false;
dedicated = false;
_config_file = NULL; _config_file = NULL;
// The last param of the following function means this: // The last param of the following function means this:
@ -340,23 +340,17 @@ int ttd_main(int argc, char* argv[])
case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break; case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break;
case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break; case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break;
case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break; case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break;
case 'D': { case 'D':
strcpy(musicdriver, "null"); strcpy(musicdriver, "null");
strcpy(sounddriver, "null"); strcpy(sounddriver, "null");
strcpy(videodriver, "dedicated"); strcpy(videodriver, "dedicated");
dedicated = true; dedicated = true;
} break; break;
case 'f': { case 'f': _dedicated_forks = true; break;
_dedicated_forks = true; case 'n':
}; break; network = true;
case 'n': { network_conn = mgo_opt; // optional IP parameter, NULL if unset
network = true; break;
if (mgo.opt)
// Optional, you can give an IP
network_conn = mgo.opt;
else
network_conn = NULL;
} break;
case 'b': _ai.network_client = true; break; case 'b': _ai.network_client = true; break;
case 'r': ParseResolution(resolution, mgo.opt); break; case 'r': ParseResolution(resolution, mgo.opt); break;
case 't': startdate = atoi(mgo.opt); break; case 't': startdate = atoi(mgo.opt); break;
@ -375,12 +369,8 @@ int ttd_main(int argc, char* argv[])
} else } else
_switch_mode = SM_NEWGAME; _switch_mode = SM_NEWGAME;
break; break;
case 'G': case 'G': _random_seeds[0][0] = atoi(mgo.opt); break;
_random_seeds[0][0] = atoi(mgo.opt); case 'c': _config_file = strdup(mgo.opt); break;
break;
case 'c':
_config_file = strdup(mgo.opt);
break;
case -2: case -2:
case 'h': case 'h':
showhelp(); showhelp();
@ -390,7 +380,7 @@ int ttd_main(int argc, char* argv[])
if (_ai.network_client && !network) { if (_ai.network_client && !network) {
_ai.network_client = false; _ai.network_client = false;
DEBUG(ai, 0)("[AI] Can't enable network-AI, because '-n' is not used\n"); DEBUG(ai, 0) ("[AI] Can't enable network-AI, because '-n' is not used\n");
} }
DeterminePaths(); DeterminePaths();
@ -441,7 +431,7 @@ int ttd_main(int argc, char* argv[])
GfxLoadSprites(); GfxLoadSprites();
LoadStringWidthTable(); LoadStringWidthTable();
DEBUG(misc, 1) ("Loading drivers..."); DEBUG(driver, 1) ("Loading drivers...");
LoadDriver(SOUND_DRIVER, _ini_sounddriver); LoadDriver(SOUND_DRIVER, _ini_sounddriver);
LoadDriver(MUSIC_DRIVER, _ini_musicdriver); LoadDriver(MUSIC_DRIVER, _ini_musicdriver);
LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads