Process command line arguments.

This commit is contained in:
Steve 2018-03-09 18:26:04 +00:00
parent 61dd0ceb40
commit b4d681a4eb
5 changed files with 77 additions and 65 deletions

View File

@ -39,7 +39,7 @@ int main(int argc, char *argv[])
initSDL();
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN);
initGameSystem();
@ -114,11 +114,63 @@ static long capFrameRate(const long then)
static void handleCommandLine(int argc, char *argv[])
{
int i;
char *worldId;
worldId = NULL;
for (i = 1 ; i < argc ; i++)
{
if (strcmp(argv[i], "-debug") == 0)
{
dev.debug = 1;
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
}
if (strcmp(argv[i], "-info") == 0)
{
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
}
if (strcmp(argv[i], "-blind") == 0)
{
dev.cheatBlind = 1;
}
if (strcmp(argv[i], "-noenemies") == 0)
{
dev.cheatNoEnemies = 1;
}
if (strcmp(argv[i], "-keys") == 0)
{
dev.cheatKeys = 1;
}
if (strcmp(argv[i], "-power") == 0)
{
dev.cheatPower = 1;
}
if (strcmp(argv[i], "-health") == 0)
{
dev.cheatHealth = 1;
}
if (strcmp(argv[i], "-levels") == 0)
{
dev.cheatLevels = 1;
}
if (strcmp(argv[i], "-screenshots") == 0)
{
dev.takeScreenshots = 1;
}
if (strcmp(argv[i], "-world") == 0)
{
worldId = argv[++i];
}
}
initAtlasTest();
initWorldTest(worldId);
}

View File

@ -28,10 +28,10 @@ extern void drawTrophyAlert(void);
extern void expireTexts(int all);
extern void handleInput(void);
extern void init18N(int argc, char *argv[]);
extern void initAtlasTest(void);
extern void initGameSystem(void);
extern void initLookups(void);
extern void initSDL(void);
extern void initWorldTest(char *worldId);
extern void prepareScene(void);
extern void presentScene(void);
extern void saveScreenshot(char *name);

View File

@ -1,60 +0,0 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "atlasTest.h"
void initAtlasTest(void)
{
int test;
dev.debug = 0;
dev.cheatStatic = 0;
dev.cheatBlind = 1;
dev.cheatNoEnemies = 0;
dev.cheatKeys = 0;
dev.cheatPower = 0;
dev.cheatHealth = 0;
dev.cheatLevels = 0;
dev.takeScreenshots = 0;
loadGame();
saveGame();
createScreenshotFolder();
test = 2;
switch (test)
{
case 0:
initOptions();
break;
case 1:
STRNCPY(game.worldId, "beachApproach", MAX_NAME_LENGTH);
initWorld();
break;
case 2:
initHub();
break;
}
}

20
src/test/worldTest.c Normal file
View File

@ -0,0 +1,20 @@
#include "worldTest.h"
void initWorldTest(char *worldId)
{
loadGame();
saveGame();
createScreenshotFolder();
if (worldId != NULL)
{
STRNCPY(game.worldId, worldId, MAX_NAME_LENGTH);
initWorld();
}
else
{
initHub();
}
}