Enable debug mode by passing -debug.
This commit is contained in:
parent
a22e2a9f8d
commit
d8eb896456
|
@ -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)
|
||||
|
|
2
makefile
2
makefile
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -81,5 +81,6 @@ extern void drawDebris(void);
|
|||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern Entity *player;
|
||||
extern Game game;
|
||||
|
|
|
@ -46,13 +46,14 @@ void prepareScene(void)
|
|||
|
||||
void presentScene(void)
|
||||
{
|
||||
#if DEBUG
|
||||
drawText(5, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "DEBUG MODE");
|
||||
if (dev.showFPS)
|
||||
if (dev.debug)
|
||||
{
|
||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 25, 14, TA_CENTER, colors.white, "FPS: %d", dev.fps);
|
||||
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();
|
||||
|
||||
|
|
|
@ -702,26 +702,27 @@ Mission *getMission(char *filename)
|
|||
|
||||
int isMissionAvailable(Mission *mission, Mission *prev)
|
||||
{
|
||||
#if !DEBUG
|
||||
Mission *reqMission;
|
||||
|
||||
if (mission->requires)
|
||||
if (!dev.debug)
|
||||
{
|
||||
if (strcmp(mission->requires, "PREVIOUS") == 0)
|
||||
if (mission->requires)
|
||||
{
|
||||
return prev->completed;
|
||||
}
|
||||
else
|
||||
{
|
||||
reqMission = getMission(mission->requires);
|
||||
|
||||
if (reqMission != NULL)
|
||||
if (strcmp(mission->requires, "PREVIOUS") == 0)
|
||||
{
|
||||
return reqMission->completed;
|
||||
return prev->completed;
|
||||
}
|
||||
else
|
||||
{
|
||||
reqMission = getMission(mission->requires);
|
||||
|
||||
if (reqMission != NULL)
|
||||
{
|
||||
return reqMission->completed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
40
src/main.c
40
src/main.c
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef struct GridCell GridCell;
|
|||
typedef struct ScriptRunner ScriptRunner;
|
||||
|
||||
typedef struct {
|
||||
int debug;
|
||||
int takeScreenshots;
|
||||
int noAIWeapons;
|
||||
int showFPS;
|
||||
|
|
|
@ -22,54 +22,55 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
void doDevKeys(void)
|
||||
{
|
||||
#if DEBUG
|
||||
if (app.keyboard[SDL_SCANCODE_1])
|
||||
if (dev.debug)
|
||||
{
|
||||
dev.playerImmortal = !dev.playerImmortal;
|
||||
app.keyboard[SDL_SCANCODE_1] = 0;
|
||||
printf("DEBUG: dev.playerImmortal=%d\n", dev.playerImmortal);
|
||||
}
|
||||
if (app.keyboard[SDL_SCANCODE_1])
|
||||
{
|
||||
dev.playerImmortal = !dev.playerImmortal;
|
||||
app.keyboard[SDL_SCANCODE_1] = 0;
|
||||
printf("DEBUG: dev.playerImmortal=%d\n", dev.playerImmortal);
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_2])
|
||||
{
|
||||
dev.playerUnlimitedMissiles = !dev.playerUnlimitedMissiles;
|
||||
app.keyboard[SDL_SCANCODE_2] = 0;
|
||||
printf("DEBUG: dev.playerUnlimitedMissiles=%d\n", dev.playerUnlimitedMissiles);
|
||||
}
|
||||
if (app.keyboard[SDL_SCANCODE_2])
|
||||
{
|
||||
dev.playerUnlimitedMissiles = !dev.playerUnlimitedMissiles;
|
||||
app.keyboard[SDL_SCANCODE_2] = 0;
|
||||
printf("DEBUG: dev.playerUnlimitedMissiles=%d\n", dev.playerUnlimitedMissiles);
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_3])
|
||||
{
|
||||
dev.noAIWeapons = !dev.noAIWeapons;
|
||||
app.keyboard[SDL_SCANCODE_3] = 0;
|
||||
printf("DEBUG: dev.noAIWeapons=%d\n", dev.noAIWeapons);
|
||||
}
|
||||
if (app.keyboard[SDL_SCANCODE_3])
|
||||
{
|
||||
dev.noAIWeapons = !dev.noAIWeapons;
|
||||
app.keyboard[SDL_SCANCODE_3] = 0;
|
||||
printf("DEBUG: dev.noAIWeapons=%d\n", dev.noAIWeapons);
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_4])
|
||||
{
|
||||
dev.noEntityActions = !dev.noEntityActions;
|
||||
app.keyboard[SDL_SCANCODE_4] = 0;
|
||||
printf("DEBUG: dev.noEntityActions=%d\n", dev.noEntityActions);
|
||||
}
|
||||
if (app.keyboard[SDL_SCANCODE_4])
|
||||
{
|
||||
dev.noEntityActions = !dev.noEntityActions;
|
||||
app.keyboard[SDL_SCANCODE_4] = 0;
|
||||
printf("DEBUG: dev.noEntityActions=%d\n", dev.noEntityActions);
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_5])
|
||||
{
|
||||
dev.allImmortal = !dev.allImmortal;
|
||||
app.keyboard[SDL_SCANCODE_5] = 0;
|
||||
printf("DEBUG: dev.allImmortal=%d\n", dev.allImmortal);
|
||||
}
|
||||
if (app.keyboard[SDL_SCANCODE_5])
|
||||
{
|
||||
dev.allImmortal = !dev.allImmortal;
|
||||
app.keyboard[SDL_SCANCODE_5] = 0;
|
||||
printf("DEBUG: dev.allImmortal=%d\n", dev.allImmortal);
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_9])
|
||||
{
|
||||
dev.showFPS = !dev.showFPS;
|
||||
app.keyboard[SDL_SCANCODE_9] = 0;
|
||||
printf("DEBUG: dev.showFPS=%d\n", dev.showFPS);
|
||||
}
|
||||
if (app.keyboard[SDL_SCANCODE_9])
|
||||
{
|
||||
dev.showFPS = !dev.showFPS;
|
||||
app.keyboard[SDL_SCANCODE_9] = 0;
|
||||
printf("DEBUG: dev.showFPS=%d\n", dev.showFPS);
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_0])
|
||||
{
|
||||
dev.takeScreenshots = !dev.takeScreenshots;
|
||||
app.keyboard[SDL_SCANCODE_0] = 0;
|
||||
printf("DEBUG: dev.takeScreenshots=%d\n", dev.takeScreenshots);
|
||||
if (app.keyboard[SDL_SCANCODE_0])
|
||||
{
|
||||
dev.takeScreenshots = !dev.takeScreenshots;
|
||||
app.keyboard[SDL_SCANCODE_0] = 0;
|
||||
printf("DEBUG: dev.takeScreenshots=%d\n", dev.takeScreenshots);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue