aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-24 13:52:35 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-24 13:52:35 +0000
commit46be4debae45f0c63b0017ec0297be5c752d9848 (patch)
treef65f6aec080ca8f443f8d832816fbe5dca405468 /src
parent7cf1897c7a04ecad268e0ca0d28baa17b5118c53 (diff)
Room recursion stuff
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@163 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src')
-rw-r--r--src/game.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/game.c b/src/game.c
index 7c4880c..4d75d2d 100644
--- a/src/game.c
+++ b/src/game.c
@@ -170,11 +170,27 @@ static void game_delete_room(Game *game, int idx) {
}
+static int room_can_be_seen(Game *game, int rx, int ry, int rz) {
+
+ int crx, cry, crz;
+
+ crx = game->cur_room_x;
+ cry = game->cur_room_y;
+ crz = game->cur_room_z;
+
+ if ( (crx==0) && (cry==0) && (crz==0) && (rx==0) && (ry==2) && (rz==4) ) return 0;
+
+ return 1;
+
+}
+
static void game_load_all_connected(Room *room, Game *game) {
int i;
+ if ( room->checked_this_time ) return;
room->checked_this_time = 1;
+ room->needed_this_time = 1;
for ( i=0; i<room->num_connected; i++ ) {
@@ -185,28 +201,24 @@ static void game_load_all_connected(Room *room, Game *game) {
ry = room->connected[i].ry;
rz = room->connected[i].rz;
+ if ( !room_can_be_seen(game, rx, ry, rz) ) continue;
+
con = game_find_room(game, rx, ry, rz);
if ( con == NULL ) {
if ( game->debug ) printf("GM: Loading %2i %2i %2i\n", rx, ry, rz);
con = room_load(rx, ry, rz, game->models, game->render);
+ con->checked_this_time = 0;
/* Add the new room to the list */
- con->needed_this_time = 1;
- con->checked_this_time = 0;
game->rooms[game->num_rooms] = con;
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);
-
}
/* Recurse */
- if ( !con->checked_this_time ) game_load_all_connected(con, game);
+ game_load_all_connected(con, game);
}
@@ -234,17 +246,17 @@ static void game_load_all_relevant(Game *game) {
if ( game->debug ) printf("GM: Couldn't load the current room. Giving up.\n");
return;
}
+ room->checked_this_time = 0;
game->rooms[game->num_rooms] = room;
game->num_rooms++;
}
- room->needed_this_time = 1;
game_load_all_connected(room, 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",
+ if ( game->debug ) printf("GM: %2i %2i %2i is no longer needed\n",
game->rooms[i]->rx, game->rooms[i]->ry, game->rooms[i]->rz);
game_delete_room(game, i);
}