Fixed some memory problems; Adjusted timer_delay2 for robot briefings

This commit is contained in:
zicodxx 2007-11-23 21:14:57 +00:00
parent df7a1ca071
commit 1639e0f1f5
4 changed files with 33 additions and 10 deletions

View file

@ -1,5 +1,9 @@
D2X-Rebirth Changelog D2X-Rebirth Changelog
20071123
--------
main/aipath.c, main/fireball.c, main/titles.c: Fixed some memory problems; Adjusted timer_delay2 for robot briefings
20071121 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 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

View file

@ -393,6 +393,9 @@ if ((objp->type == OBJ_ROBOT) && (objp->ctype.ai_info.behavior == AIB_RUN_FROM))
dont_add: ; dont_add: ;
} // for (sidenum... } // for (sidenum...
if (qtail<=0)
return 0;
if (qhead >= qtail) { if (qhead >= qtail) {
// Couldn't get to goal, return a path as far as we got, which probably acceptable to the unparticular caller. // 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; end_seg = seg_queue[qtail-1].end;
@ -406,6 +409,9 @@ dont_add: ;
cpp_done1: ; cpp_done1: ;
} // while (cur_seg ... } // while (cur_seg ...
if (qtail<=0)
return 0;
// Set qtail to the segment which ends at the goal. // Set qtail to the segment which ends at the goal.
while (seg_queue[--qtail].end != end_seg) while (seg_queue[--qtail].end != end_seg)
if (qtail < 0) { if (qtail < 0) {

View file

@ -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)); // 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; start_seg = objp->segnum;
head = 0; head = 0;
tail = 0; tail = 0;
seg_queue[head++] = start_seg; seg_queue[head++] = start_seg;
memset(visited, 0, Highest_segment_index+1);
memset(depth, 0, Highest_segment_index+1);
cur_depth = 0; cur_depth = 0;
for (i=0; i<MAX_SIDES_PER_SEGMENT; i++) for (i=0; i<MAX_SIDES_PER_SEGMENT; i++)
@ -462,10 +464,11 @@ int pick_connected_segment(object *objp, int max_depth)
side_rand[i] = temp; side_rand[i] = temp;
} }
while (tail != head) { while (tail != head) {
int sidenum; int sidenum, count;
segment *segp; segment *segp;
sbyte ind1, ind2, temp; int ind1, ind2, temp;
if (cur_depth >= max_depth) { if (cur_depth >= max_depth) {
// mprintf((0, "selected segment %i\n", seg_queue[tail])); // 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[ind1] = side_rand[ind2];
side_rand[ind2] = temp; side_rand[ind2] = temp;
for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) { count = 0;
int snrand = side_rand[sidenum]; for (sidenum=ind1; count<MAX_SIDES_PER_SEGMENT; count++) {
int wall_num = segp->sides[snrand].wall_num; int snrand, wall_num;
if (((wall_num == -1) && (segp->children[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) { if (visited[segp->children[snrand]] == 0) {
seg_queue[head++] = segp->children[snrand]; seg_queue[head++] = segp->children[snrand];
visited[segp->children[snrand]] = 1; 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)) { if ((seg_queue[tail] < 0) || (seg_queue[tail] > Highest_segment_index)) {
// -- Int3(); // Something bad has happened. Queue is trashed. --MK, 12/13/94 // -- Int3(); // Something bad has happened. Queue is trashed. --MK, 12/13/94
return -1; return -1;
} }
cur_depth = depth[seg_queue[tail]]; cur_depth = depth[seg_queue[tail]];
} }

View file

@ -976,7 +976,7 @@ int show_briefing(int screen_num, char *message)
if (Bitmap_name[0] != 0) if (Bitmap_name[0] != 0)
show_animated_bitmap(); show_animated_bitmap();
start_time += KEY_DELAY_DEFAULT/2; start_time += KEY_DELAY_DEFAULT/2;
timer_delay2(20); timer_delay2(50);
} }
#ifndef NDEBUG #ifndef NDEBUG
@ -1123,7 +1123,7 @@ int show_briefing(int screen_num, char *message)
if (Bitmap_name[0] != 0) if (Bitmap_name[0] != 0)
show_animated_bitmap(); show_animated_bitmap();
start_time += KEY_DELAY_DEFAULT/2; start_time += KEY_DELAY_DEFAULT/2;
timer_delay2(20); timer_delay2(50);
} }
if (RobotPlaying) if (RobotPlaying)