mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 21:33:59 +02:00
- updated commandline too show usage when using wrong parameters
This commit is contained in:
@@ -424,14 +424,14 @@ void MainWindow::setProgram(Program *program) {
|
|||||||
// =====================================================
|
// =====================================================
|
||||||
SystemFlags debugger;
|
SystemFlags debugger;
|
||||||
|
|
||||||
bool hasCommandArgument(int argc, char** argv,string argName, int *foundIndex=NULL) {
|
bool hasCommandArgument(int argc, const char** argv,const string argName, int *foundIndex=NULL, int startLookupIndex=1) {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if(foundIndex != NULL) {
|
if(foundIndex != NULL) {
|
||||||
*foundIndex = -1;
|
*foundIndex = -1;
|
||||||
}
|
}
|
||||||
int compareLen = strlen(argName.c_str());
|
int compareLen = strlen(argName.c_str());
|
||||||
for(int idx = 1; idx < argc; idx++) {
|
for(int idx = startLookupIndex; idx < argc; idx++) {
|
||||||
if(strnicmp(argName.c_str(),argv[idx],compareLen) == 0) {
|
if(strnicmp(argName.c_str(),argv[idx],compareLen) == 0) {
|
||||||
result = true;
|
result = true;
|
||||||
if(foundIndex != NULL) {
|
if(foundIndex != NULL) {
|
||||||
@@ -444,13 +444,23 @@ bool hasCommandArgument(int argc, char** argv,string argName, int *foundIndex=NU
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int glestMain(int argc, char** argv){
|
int glestMain(int argc, const char** argv){
|
||||||
|
|
||||||
#ifdef SL_LEAK_DUMP
|
#ifdef SL_LEAK_DUMP
|
||||||
AllocRegistry memoryLeaks = AllocRegistry::getInstance();
|
AllocRegistry memoryLeaks = AllocRegistry::getInstance();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_HELP]) == true) {
|
bool foundInvalidArgs = false;
|
||||||
|
const int knownArgCount = sizeof(GAME_ARGS) / sizeof(GAME_ARGS[0]);
|
||||||
|
for(int idx = 1; idx < argc; ++idx) {
|
||||||
|
if( hasCommandArgument(knownArgCount, GAME_ARGS,argv[idx],NULL,0) == false) {
|
||||||
|
foundInvalidArgs = true;
|
||||||
|
printf("\nInvalid argument: %s\n",argv[idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_HELP]) == true ||
|
||||||
|
foundInvalidArgs == true) {
|
||||||
printf("\n%s, usage\n\n",argv[0]);
|
printf("\n%s, usage\n\n",argv[0]);
|
||||||
printf("Commandline Parameter:\t\tDescription:");
|
printf("Commandline Parameter:\t\tDescription:");
|
||||||
printf("\n----------------------\t\t------------");
|
printf("\n----------------------\t\t------------");
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define MAIN_FUNCTION(X) int main(int argc, char **argv) \
|
#define MAIN_FUNCTION(X) int main(int argc, const char **argv) \
|
||||||
{ \
|
{ \
|
||||||
if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { \
|
if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { \
|
||||||
std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; \
|
std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; \
|
||||||
|
Reference in New Issue
Block a user