Enable debug mode by passing -debug.

This commit is contained in:
Steve 2015-12-20 12:25:20 +00:00
parent a22e2a9f8d
commit d8eb896456
11 changed files with 106 additions and 79 deletions

View File

@ -1,6 +1,5 @@
VERSION = 0.5
REVISION = $(shell date +"%y%m%d")
DEBUG = $(shell stat dev 1>/dev/null 2>&1 && echo 1 || echo 0)
SEARCHPATH += src/ src/battle src/draw src/game src/galaxy src/json src/system src/test
vpath %.c $(SEARCHPATH)

View File

@ -8,7 +8,7 @@ OBJS += unixInit.o
include common.mk
CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDEBUG=$(DEBUG) -DDATA_DIR=\"$(DATA_DIR)\"
CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\"
CXXFLAGS += -Wall -ansi -pedantic -Werror -Wstrict-prototypes
CXXFLAGS += -g -lefence

View File

@ -6,7 +6,7 @@ LIBPATH = /usr/x86_64-w64-mingw32/lib
SEARCHPATH += src/plat/win32
OBJS += win32Init.o
CXXFLAGS += `$(SDLC) --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDEBUG=$(DEBUG) -DDATA_DIR=\"$(DATA_DIR)\"
CXXFLAGS += `$(SDLC) --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\"
CXXFLAGS += -Wall -ansi -pedantic -Werror -Wstrict-prototypes
CXXFLAGS += -g -lefence

View File

@ -270,13 +270,11 @@ static void handleKeyboard(void)
battle.status = MS_PAUSED;
}
#if DEBUG
if (app.keyboard[SDL_SCANCODE_F10])
if (dev.debug && app.keyboard[SDL_SCANCODE_F10])
{
completeMission();
battle.missionFinishedTimer = -FPS;
}
#endif
}
static void start(void)

View File

@ -81,5 +81,6 @@ extern void drawDebris(void);
extern App app;
extern Battle battle;
extern Dev dev;
extern Entity *player;
extern Game game;

View File

@ -46,13 +46,14 @@ void prepareScene(void)
void presentScene(void)
{
#if DEBUG
if (dev.debug)
{
drawText(5, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "DEBUG MODE");
if (dev.showFPS)
{
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 25, 14, TA_CENTER, colors.white, "FPS: %d", dev.fps);
}
#endif
}
drawMouse();

View File

@ -702,9 +702,10 @@ Mission *getMission(char *filename)
int isMissionAvailable(Mission *mission, Mission *prev)
{
#if !DEBUG
Mission *reqMission;
if (!dev.debug)
{
if (mission->requires)
{
if (strcmp(mission->requires, "PREVIOUS") == 0)
@ -721,7 +722,7 @@ int isMissionAvailable(Mission *mission, Mission *prev)
}
}
}
#endif
}
return 1;
}

View File

@ -48,5 +48,6 @@ extern char *getFileLocation(char *filename);
extern void updateCapitalShipComponentNames(Entity *parent);
extern Battle battle;
extern Dev dev;
extern Entity *player;
extern Game game;

View File

@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "main.h"
static void handleArguments(int argc, char *argv[]);
int main(int argc, char *argv[])
{
float td;
@ -40,14 +42,7 @@ int main(int argc, char *argv[])
initGameSystem();
if (argc > 1)
{
loadTestMission(argv[1]);
}
else
{
initTitle();
}
handleArguments(argc, argv);
dev.fps = frames = td = 0;
then = SDL_GetTicks();
@ -126,3 +121,32 @@ int main(int argc, char *argv[])
return 0;
}
static void handleArguments(int argc, char *argv[])
{
int i;
int testingMission = 0;
for (i = 1 ; i < argc ; i++)
{
/* assume this is filename for testing */
if (argv[i][0] != '-')
{
loadTestMission(argv[i]);
testingMission = 1;
}
else
{
if (strcmp(argv[i], "-debug") == 0)
{
dev.debug = 1;
}
}
}
if (!testingMission)
{
initTitle();
}
}

View File

@ -37,6 +37,7 @@ typedef struct GridCell GridCell;
typedef struct ScriptRunner ScriptRunner;
typedef struct {
int debug;
int takeScreenshots;
int noAIWeapons;
int showFPS;

View File

@ -22,7 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void doDevKeys(void)
{
#if DEBUG
if (dev.debug)
{
if (app.keyboard[SDL_SCANCODE_1])
{
dev.playerImmortal = !dev.playerImmortal;
@ -71,5 +72,5 @@ void doDevKeys(void)
app.keyboard[SDL_SCANCODE_0] = 0;
printf("DEBUG: dev.takeScreenshots=%d\n", dev.takeScreenshots);
}
#endif
}
}