Debugging and auto mission completion.

This commit is contained in:
Steve 2018-02-23 19:26:13 +00:00
parent 01246d14b6
commit b03776cef6
3 changed files with 44 additions and 9 deletions

View File

@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "player.h" #include "player.h"
static void doDebugControls(void); static void doDebugControls(void);
static void compareQuadtree(void);
static int last = 0;
void doPlayer(void) void doPlayer(void)
{ {
@ -59,8 +61,39 @@ static void doDebugControls(void)
if (app.keyboard[SDL_SCANCODE_0] && world.state != WS_COMPLETE) if (app.keyboard[SDL_SCANCODE_0] && world.state != WS_COMPLETE)
{ {
stopMusic(); quitMission();
world.state = WS_COMPLETE;
world.missionCompleteTimer = FPS * 3; autoCompleteMission();
app.keyboard[SDL_SCANCODE_0] = 0;
}
if (last < SDL_GetTicks())
{
compareQuadtree();
last = SDL_GetTicks() + 1000;
}
}
static void compareQuadtree(void)
{
Entity **candidates, *e;
int numCandidates, numEnts;
candidates = getAllEntsWithin(0, 0, MAP_WIDTH * MAP_TILE_SIZE, MAP_HEIGHT * MAP_TILE_SIZE, NULL);
numEnts = 0;
/* counting entities to draw */
for (numCandidates = 0, e = candidates[numCandidates] ; e != NULL ; e = candidates[++numCandidates]) {};
for (e = world.entityHead.next ; e != NULL ; e = e->next) {numEnts++;}
printf("numEnts=%d, numCandidates=%d\n", numEnts, numCandidates);
if (numCandidates > numEnts)
{
exit(1);
} }
} }

View File

@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h" #include "../common.h"
extern void stopMusic(void); extern void quitMission(void);
extern void autoCompleteMission(void);
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
extern App app; extern App app;
extern Dev dev; extern Dev dev;

View File

@ -44,9 +44,9 @@ static void trophies(void);
static void quit(void); static void quit(void);
static void returnFromTrophyStats(void); static void returnFromTrophyStats(void);
static void drawQuit(void); static void drawQuit(void);
static void quitMission(void); void quitMission(void);
static void returnFromOptions(void); static void returnFromOptions(void);
static void completeTrainingMission(void); void autoCompleteMission(void);
static Texture *background; static Texture *background;
static int observationIndex; static int observationIndex;
@ -762,7 +762,7 @@ static void returnFromTrophyStats(void)
app.keyboard[SDL_SCANCODE_ESCAPE] = 0; app.keyboard[SDL_SCANCODE_ESCAPE] = 0;
} }
static void quitMission(void) void quitMission(void)
{ {
resume(); resume();
stopMusic(); stopMusic();
@ -771,7 +771,7 @@ static void quitMission(void)
if (world.missionType == MT_TRAINING) if (world.missionType == MT_TRAINING)
{ {
completeTrainingMission(); autoCompleteMission();
} }
} }
@ -783,7 +783,7 @@ static void returnFromOptions(void)
returnFromTrophyStats(); returnFromTrophyStats();
} }
static void completeTrainingMission(void) void autoCompleteMission(void)
{ {
Objective *o; Objective *o;
Entity *e; Entity *e;