aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-23 16:37:47 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-23 16:37:47 +0000
commitc77468a0306b63cef0f5dc8293fb8142479df9c1 (patch)
tree8b7562c6b8d151523cd16eab6750c32d11191f0a /src
parent5893f7a7f453b4c59d448370b3d8fd009fb82b3d (diff)
Game debug information
General fussiness git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@158 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src')
-rw-r--r--src/game.c10
-rw-r--r--src/main.c15
-rw-r--r--src/types.h3
3 files changed, 23 insertions, 5 deletions
diff --git a/src/game.c b/src/game.c
index a155c69..8f942a1 100644
--- a/src/game.c
+++ b/src/game.c
@@ -177,12 +177,15 @@ static void game_load_all_connected(Game *game) {
int i;
Room *room;
+ if ( game->debug ) printf("GM: Loading all relevant rooms...\n");
+
/* Go down the current list of rooms, setting 'needed_this_time' to 0 */
for ( i=0; i<game->num_rooms; i++ ) {
game->rooms[i]->needed_this_time = 0;
}
/* Is the current room in the list? Load it if not */
+ if ( game->debug ) printf("GM: Current: %2i %2i %2i\n", game->cur_room_x, game->cur_room_y, game->cur_room_z);
room = game_find_room(game, game->cur_room_x, game->cur_room_y, game->cur_room_z);
if ( room == NULL ) {
room = room_load(game->cur_room_x, game->cur_room_y, game->cur_room_z, game->models, game->render);
@@ -206,10 +209,12 @@ static void game_load_all_connected(Game *game) {
rz = room->connected[i].rz;
con = game_find_room(game, rx, ry, rz);
if ( con == NULL ) {
+ if ( game->debug ) printf("GM: Loading %2i %2i %2i\n", rx, ry, rz);
game->rooms[game->num_rooms] = room_load(rx, ry, rz, game->models, game->render);
game->num_rooms++;
} else {
con->needed_this_time = 1;
+ if ( game->debug ) printf("GM: %2i %2i %2i is still relevant\n", con->rx, con->ry, con->rz);
}
}
@@ -217,10 +222,14 @@ static void game_load_all_connected(Game *game) {
/* Remove any rooms left in the list which are no longer needed */
for ( i=0; i<game->num_rooms; i++ ) {
if ( !game->rooms[i]->needed_this_time ) {
+ if ( game->debug ) printf("GM: %2i %2i %2i no longer needed\n",
+ game->rooms[i]->rx, game->rooms[i]->ry, game->rooms[i]->rz);
game_delete_room(game, i);
}
}
+ if ( game->debug ) printf("GM: Done.\n");
+
}
/* Create a new "game" structure */
@@ -231,6 +240,7 @@ Game *game_new(int width, int height, GameOptions gameopts) {
g = malloc(sizeof(Game));
if ( g == NULL ) return NULL;
+ g->debug = gameopts.game_debug;
g->thrusting = 0;
g->turn_left = 0;
g->turn_right = 0;
diff --git a/src/main.c b/src/main.c
index 7b022fd..3f97c64 100644
--- a/src/main.c
+++ b/src/main.c
@@ -57,6 +57,7 @@ int main(int argc, char *argv[]) {
gameopts.disable_fbos = 0;
gameopts.disable_shaders = 0;
gameopts.audio_debug = 0;
+ gameopts.game_debug = 0;
gameopts.no_music = 0;
const struct option longopts[] = { {"fullscreen", 0, NULL, 'f'},
@@ -67,6 +68,7 @@ int main(int argc, char *argv[]) {
{"disable-fbos", 0, &gameopts.disable_fbos, 1},
{"disable-shaders", 0, &gameopts.disable_shaders, 1},
{"audio-debug", 0, &gameopts.audio_debug, 1},
+ {"game-debug", 0, &gameopts.game_debug, 1},
{"no-music", 0, NULL, 'n'},
{0, 0, NULL, 0} };
@@ -114,14 +116,17 @@ int main(int argc, char *argv[]) {
printf("Post-apocalyptic Jet Set Willy, set in a 3D nuclear power station.\n\n");
printf(" -h, --help Display this help message and exit.\n");
printf(" -v, --version Display version number and exit.\n");
- printf(" -r, --resolution <res> Set display resolution. See below for possible values for <res>.\n");
+ printf(" -r, --resolution <res> Set display resolution. "
+ "See below for possible values for <res>.\n");
printf(" -f, --fullscreen Use the full screen.\n");
printf(" -n, --no-music Don't play any background music.\n");
printf("\nAdvanced options:\n\n");
printf(" --disable-vbos Disable the use of vertex buffer objects.\n");
printf(" --disable-fbos Disable the use of framebuffer objects.\n");
printf(" --disable-shaders Disable the use of shaders.\n");
- printf(" --audio-debug Print audio debugging messages to stdout.\n\n");
+ printf(" --audio-debug Print audio debugging messages to stdout.\n");
+ printf(" --game-debug Print game control debugging messages to stdout.\n");
+ printf("\n");
printf("Allowable values for <res> are as follows:\n\n");
printf("<res> Width Height\n");
printf(" 640 - 640 x 480\n");
@@ -229,9 +234,9 @@ int main(int argc, char *argv[]) {
}
//printf("%+7.4f %+7.4f %+7.4f %+5.1f deg %+7.5f %+7.5f %+7.5f %2i %2i %2i %3i fps\r",
- // game->lander->x, game->lander->y, game->lander->z,
- // rad2deg(game->lander->yaw), game->lander->vx, game->lander->vy, game->lander->vz,
- // game->cur_room_x, game->cur_room_y, game->cur_room_z, game->fps);
+ // game->lander->x, game->lander->y, game->lander->z,
+ // rad2deg(game->lander->yaw), game->lander->vx, game->lander->vy, game->lander->vz,
+ // game->cur_room_x, game->cur_room_y, game->cur_room_z, game->fps);
//fflush(stdout);
/* Calculate FPS every half a second */
diff --git a/src/types.h b/src/types.h
index fb59f2d..925cdd5 100644
--- a/src/types.h
+++ b/src/types.h
@@ -35,6 +35,7 @@ typedef struct {
int disable_fbos;
int disable_shaders;
int audio_debug;
+ int game_debug;
int no_music;
} GameOptions;
@@ -224,6 +225,8 @@ typedef struct {
typedef struct {
+ int debug;
+
unsigned int thrusting;
unsigned int turn_left;
unsigned int turn_right;