From 5f5b5b415ff5c0c667b89075450be389e99d3055 Mon Sep 17 00:00:00 2001 From: zicodxx Date: Wed, 4 May 2011 15:07:53 +0200 Subject: [PATCH] Due to increased size of MAX_SEGMENTS old savegames became incompatible. To compensate added MAX_SEGMENTS_ORIGINAL with the original segment amount and read certain savegame info with this info when dealing with standard-sized levels and use Highest_segment_index when dealing with larger levels which are incompatible with older versions of the game anyways. Makes savegame site more efficient and still maintain backwards compability --- CHANGELOG.txt | 1 + main/segment.h | 6 ++++-- main/state.c | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6cf0302e0..4e2e9c681 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -7,6 +7,7 @@ main/endlevel.c: Make sure the big explosion at the end of the escape sequence a main/multi.c: Fix crash in multi_maybe_disable_friendly_fire() when killer == NULL 2d/font.c: mipmapping was always on for fonts due to changed filtering code in ogl.c main/physics.c: To compensate fewer FVI runs in lower FPS and wall penetration caused by strong forces allowed fix_illegal_wall_intersection() to move an object out of the wall half it's size improving the collisions once more +main/segment.h, main/state.c: Due to increased size of MAX_SEGMENTS old savegames became incompatible. To compensate added MAX_SEGMENTS_ORIGINAL with the original segment amount and read certain savegame info with this info when dealing with standard-sized levels and use Highest_segment_index when dealing with larger levels which are incompatible with older versions of the game anyways. Makes savegame site more efficient and still maintain backwards compability 20110424 -------- diff --git a/main/segment.h b/main/segment.h index 7a4d64240..dc44193bf 100644 --- a/main/segment.h +++ b/main/segment.h @@ -46,8 +46,10 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define WBACK 4 #define WFRONT 5 -#define MAX_SEGMENTS 9000 -#define MAX_SEGMENT_VERTICES (4*MAX_SEGMENTS) +#define MAX_SEGMENTS_ORIGINAL 900 +#define MAX_SEGMENT_VERTICES_ORIGINAL (4*MAX_SEGMENTS_ORIGINAL) +#define MAX_SEGMENTS 9000 +#define MAX_SEGMENT_VERTICES (4*MAX_SEGMENTS) //normal everyday vertices diff --git a/main/state.c b/main/state.c index aa20568ec..d062d2441 100644 --- a/main/state.c +++ b/main/state.c @@ -1018,7 +1018,13 @@ int state_save_all_sub(char *filename, char *desc) ai_save_state( fp ); // Save the automap visited info - PHYSFS_write(fp, Automap_visited, sizeof(ubyte), MAX_SEGMENTS); + if ( Highest_segment_index+1 > MAX_SEGMENTS_ORIGINAL ) + { + for ( i = 0; i <= Highest_segment_index; i++ ) + PHYSFS_write(fp, Automap_visited, sizeof(ubyte), 1); + } + else + PHYSFS_write(fp, Automap_visited, sizeof(ubyte), MAX_SEGMENTS_ORIGINAL); PHYSFS_write(fp, &state_game_id, sizeof(uint), 1); i = 0; @@ -1352,7 +1358,14 @@ RetryObjectLoading: ai_restore_state( fp, swap ); // Restore the automap visited info - PHYSFS_read(fp, Automap_visited, sizeof(ubyte), MAX_SEGMENTS); + if ( Highest_segment_index+1 > MAX_SEGMENTS_ORIGINAL ) + { + memset(&Automap_visited, 0, MAX_SEGMENTS); + for ( i = 0; i <= Highest_segment_index; i++ ) + PHYSFS_read(fp, Automap_visited, sizeof(ubyte), 1); + } + else + PHYSFS_read(fp, Automap_visited, sizeof(ubyte), MAX_SEGMENTS_ORIGINAL); // Restore hacked up weapon system stuff. Auto_fire_fusion_cannon_time = 0;