mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Validate audio/video driver command-line arguments
This will exit early if the audio/video driver specified doesn't exist.
This commit is contained in:
parent
daf4a9f9be
commit
ca268dfecd
@ -444,6 +444,32 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
if (I->next()) {
|
||||
|
||||
audio_driver = I->next()->get();
|
||||
|
||||
bool found = false;
|
||||
for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {
|
||||
if (audio_driver == OS::get_singleton()->get_audio_driver_name(i)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
OS::get_singleton()->print("Unknown audio driver '%s', aborting.\nValid options are ", audio_driver.utf8().get_data());
|
||||
|
||||
for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {
|
||||
if (i == OS::get_singleton()->get_audio_driver_count() - 1) {
|
||||
OS::get_singleton()->print(" and ");
|
||||
} else if (i != 0) {
|
||||
OS::get_singleton()->print(", ");
|
||||
}
|
||||
|
||||
OS::get_singleton()->print("'%s'", OS::get_singleton()->get_audio_driver_name(i));
|
||||
}
|
||||
|
||||
OS::get_singleton()->print(".\n");
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
N = I->next()->next();
|
||||
} else {
|
||||
OS::get_singleton()->print("Missing audio driver argument, aborting.\n");
|
||||
@ -455,6 +481,32 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
if (I->next()) {
|
||||
|
||||
video_driver = I->next()->get();
|
||||
|
||||
bool found = false;
|
||||
for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {
|
||||
if (video_driver == OS::get_singleton()->get_video_driver_name(i)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
OS::get_singleton()->print("Unknown video driver '%s', aborting.\nValid options are ", video_driver.utf8().get_data());
|
||||
|
||||
for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {
|
||||
if (i == OS::get_singleton()->get_video_driver_count() - 1) {
|
||||
OS::get_singleton()->print(" and ");
|
||||
} else if (i != 0) {
|
||||
OS::get_singleton()->print(", ");
|
||||
}
|
||||
|
||||
OS::get_singleton()->print("'%s'", OS::get_singleton()->get_video_driver_name(i));
|
||||
}
|
||||
|
||||
OS::get_singleton()->print(".\n");
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
N = I->next()->next();
|
||||
} else {
|
||||
OS::get_singleton()->print("Missing video driver argument, aborting.\n");
|
||||
@ -989,10 +1041,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
}
|
||||
|
||||
if (video_driver_idx < 0) {
|
||||
|
||||
//OS::get_singleton()->alert("Invalid Video Driver: " + video_driver);
|
||||
video_driver_idx = 0;
|
||||
//goto error;
|
||||
}
|
||||
|
||||
if (audio_driver == "") { // specified in project.godot
|
||||
@ -1009,10 +1058,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
}
|
||||
|
||||
if (audio_driver_idx < 0) {
|
||||
|
||||
OS::get_singleton()->alert("Invalid Audio Driver: " + audio_driver);
|
||||
audio_driver_idx = 0;
|
||||
//goto error;
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user