From 74e7bf47281b5dc6ae97f336d258e1d02abd254a Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Fri, 10 Jun 2011 20:15:53 -0700 Subject: [PATCH] Fixed the Birthday Bug: Correctly re-compute static_light when restoring a game - finally --- ChangeLog | 12 +++++++----- main/state.c | 49 +++++++++++++------------------------------------ 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d4ac6ed..dfd6b5bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,14 @@ -2011-06-10 Ben Baker - - * main/gamerend.c: clear the top and bottom of the screen in death - sequence (bug #2572) - 2011-06-10 Christian Beckhaeuser * main/gamerend.c: fix for death-sequence and sdl segfault in 320xXXX (bug #2513) + * main/state.c: Fixed the Birthday Bug: Correctly re-compute + static_light when restoring a game - finally (bug #2375) + +2011-06-10 Ben Baker + + * main/gamerend.c: clear the top and bottom of the screen in death + sequence (bug #2572) 2007-01-30 Bradley Bell diff --git a/main/state.c b/main/state.c index 778c7afa..3fa0b1e9 100644 --- a/main/state.c +++ b/main/state.c @@ -169,8 +169,6 @@ extern sbyte robot_fire_buf[MAX_ROBOTS_CONTROLLED][18+3]; extern ubyte Hack_DblClick_MenuMode; #endif -void compute_all_static_light(void); - //------------------------------------------------------------------- void state_callback(int nitems,newmenu_item * items, int * last_key, int citem) { @@ -1000,6 +998,8 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore) player restore_players[MAX_PLAYERS]; #endif fix old_gametime = GameTime; + short TempTmapNum[MAX_SEGMENTS][MAX_SIDES_PER_SEGMENT]; + short TempTmapNum2[MAX_SEGMENTS][MAX_SIDES_PER_SEGMENT]; #if defined(MACINTOSH) && !defined(NDEBUG) if (strncmp(filename, "Players/", 9)) @@ -1258,12 +1258,12 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore) PHYSFS_read(fp, &Num_triggers, sizeof(int), 1); PHYSFS_read(fp, Triggers, sizeof(trigger), Num_triggers); - //Restore tmap info + //Restore tmap info (to temp values so we can use compiled-in tmap info to compute static_light) for (i=0; i<=Highest_segment_index; i++ ) { for (j=0; j<6; j++ ) { PHYSFS_read(fp, &Segments[i].sides[j].wall_num, sizeof(short), 1); - PHYSFS_read(fp, &Segments[i].sides[j].tmap_num, sizeof(short), 1); - PHYSFS_read(fp, &Segments[i].sides[j].tmap_num2, sizeof(short), 1); + PHYSFS_read(fp, &TempTmapNum[i][j], sizeof(short), 1); + PHYSFS_read(fp, &TempTmapNum2[i][j], sizeof(short), 1); } } @@ -1359,13 +1359,20 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore) if (version >= 16) { PHYSFS_read(fp, Light_subtracted, sizeof(Light_subtracted[0]), MAX_SEGMENTS); apply_all_changed_light(); - compute_all_static_light(); // set static_light field in segment struct. See note at that function. } else { int i; for (i=0; i<=Highest_segment_index; i++) Light_subtracted[i] = 0; } + // static_light should now be computed - now actually set tmap info + for (i=0; i<=Highest_segment_index; i++ ) { + for (j=0; j<6; j++ ) { + Segments[i].sides[j].tmap_num=TempTmapNum[i][j]; + Segments[i].sides[j].tmap_num2=TempTmapNum2[i][j]; + } + } + if (!secret_restore) { if (version >= 20) { PHYSFS_read(fp, &First_secret_visit, sizeof(First_secret_visit), 1); @@ -1410,36 +1417,6 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore) return 1; } -// When loading a saved game, segp->static_light is bogus. -// This is because apply_all_changed_light, which is supposed to properly update this value, -// cannot do so because it needs the original light cast from a light which is no longer there. -// That is, a light has been blown out, so the texture remaining casts 0 light, but the static light -// which is present in the static_light field contains the light cast from that light. -void compute_all_static_light(void) -{ - int i, j, k; - - for (i=0; i<=Highest_segment_index; i++) { - fix total_light; - segment *segp; - - segp = &Segments[i]; - total_light = 0; - - for (j=0; jsides[j]; - - for (k=0; k<4; k++) - total_light += sidep->uvls[k].l; - } - - Segment2s[i].static_light = total_light/(MAX_SIDES_PER_SEGMENT*4); - } - -} - int state_get_game_id(char *filename) { -- 2.39.2