diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 63be51857..9be446499 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D2X-Rebirth Changelog +20071123 +-------- +main/aipath.c, main/fireball.c, main/titles.c: Fixed some memory problems; Adjusted timer_delay2 for robot briefings + 20071121 -------- arch/sdl/key.c, arch/sdl/timer.c, include/timer.h, main/game.c, main/gamecntl.c, main/kconfig.c, main/kmatrix.c, main/network.c, main/newmenu.c, main/scores.c, main/titles.c: Introduced timer_delay2 as replacement for timer_delay to sleep according to given FPS rate considering calc time between frames diff --git a/main/aipath.c b/main/aipath.c index ca327bf6e..926e1dace 100644 --- a/main/aipath.c +++ b/main/aipath.c @@ -393,6 +393,9 @@ if ((objp->type == OBJ_ROBOT) && (objp->ctype.ai_info.behavior == AIB_RUN_FROM)) dont_add: ; } // for (sidenum... + if (qtail<=0) + return 0; + if (qhead >= qtail) { // Couldn't get to goal, return a path as far as we got, which probably acceptable to the unparticular caller. end_seg = seg_queue[qtail-1].end; @@ -406,6 +409,9 @@ dont_add: ; cpp_done1: ; } // while (cur_seg ... + if (qtail<=0) + return 0; + // Set qtail to the segment which ends at the goal. while (seg_queue[--qtail].end != end_seg) if (qtail < 0) { diff --git a/main/fireball.c b/main/fireball.c index 1d4e3d59c..9ab76b3ea 100644 --- a/main/fireball.c +++ b/main/fireball.c @@ -440,13 +440,15 @@ int pick_connected_segment(object *objp, int max_depth) // mprintf((0, "Finding a segment %i segments away from segment %i: ", max_depth, objp->segnum)); + memset(visited, 0, Highest_segment_index+1); + memset(depth, 0, Highest_segment_index+1); + memset(seg_queue,0,QUEUE_SIZE*2); + start_seg = objp->segnum; head = 0; tail = 0; seg_queue[head++] = start_seg; - memset(visited, 0, Highest_segment_index+1); - memset(depth, 0, Highest_segment_index+1); cur_depth = 0; for (i=0; i= max_depth) { // mprintf((0, "selected segment %i\n", seg_queue[tail])); @@ -482,11 +485,19 @@ int pick_connected_segment(object *objp, int max_depth) side_rand[ind1] = side_rand[ind2]; side_rand[ind2] = temp; - for (sidenum=0; sidenumsides[snrand].wall_num; + count = 0; + for (sidenum=ind1; countchildren[snrand] > -1)) || door_is_openable_by_player(segp, snrand)) { + if (sidenum == MAX_SIDES_PER_SEGMENT) + sidenum = 0; + + snrand = side_rand[sidenum]; + wall_num = segp->sides[snrand].wall_num; + sidenum++; + + if ((wall_num == -1 || door_is_openable_by_player(segp, snrand)) && segp->children[snrand] > -1) + { if (visited[segp->children[snrand]] == 0) { seg_queue[head++] = segp->children[snrand]; visited[segp->children[snrand]] = 1; @@ -501,10 +512,12 @@ int pick_connected_segment(object *objp, int max_depth) } } } + if ((seg_queue[tail] < 0) || (seg_queue[tail] > Highest_segment_index)) { // -- Int3(); // Something bad has happened. Queue is trashed. --MK, 12/13/94 return -1; } + cur_depth = depth[seg_queue[tail]]; } diff --git a/main/titles.c b/main/titles.c index 39f3963d1..b5f164f98 100644 --- a/main/titles.c +++ b/main/titles.c @@ -976,7 +976,7 @@ int show_briefing(int screen_num, char *message) if (Bitmap_name[0] != 0) show_animated_bitmap(); start_time += KEY_DELAY_DEFAULT/2; - timer_delay2(20); + timer_delay2(50); } #ifndef NDEBUG @@ -1123,7 +1123,7 @@ int show_briefing(int screen_num, char *message) if (Bitmap_name[0] != 0) show_animated_bitmap(); start_time += KEY_DELAY_DEFAULT/2; - timer_delay2(20); + timer_delay2(50); } if (RobotPlaying)