diff options
-rw-r--r-- | src/game.c | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -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); } |