(svn r584) -newgrf: Increase chance to get a TTDPatch savegame using custom GRF files loaded (pasky)

This commit is contained in:
darkvater 2004-11-14 10:18:15 +00:00
parent a9a7957eaa
commit 4f6fa3b468
2 changed files with 13 additions and 6 deletions

View File

@ -11,6 +11,7 @@
extern byte _name_array[512][32]; extern byte _name_array[512][32];
extern TileIndex _animated_tile_list[256]; extern TileIndex _animated_tile_list[256];
extern uint16 _custom_sprites_base;
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma pack(push, 1) #pragma pack(push, 1)
@ -758,6 +759,8 @@ static void FixVehicle(Vehicle *n, OldVehicle *o, int num)
n->owner = o->owner; n->owner = o->owner;
n->tile = o->tile; n->tile = o->tile;
n->cur_image = o->cur_image; n->cur_image = o->cur_image;
if (o->cur_image >= 0x2000) // TTDPatch maps sprites from 0x2000 up.
n->cur_image -= 0x2000 - _custom_sprites_base;
n->vehstatus = o->vehstatus; n->vehstatus = o->vehstatus;
n->cur_speed = o->cur_speed; n->cur_speed = o->cur_speed;
@ -774,7 +777,11 @@ static void FixVehicle(Vehicle *n, OldVehicle *o, int num)
n->build_year = o->build_year; n->build_year = o->build_year;
n->unitnumber = o->unitnumber; n->unitnumber = o->unitnumber;
n->engine_type = o->engine_type; n->engine_type = o->engine_type;
n->spritenum = o->spritenum>>1; switch (o->spritenum) {
case 0xfd: n->spritenum = 0xfd; break;
case 0xff: n->spritenum = 0xfe; break;
default: n->spritenum = o->spritenum >> 1; break;
}
n->day_counter = o->day_counter; n->day_counter = o->day_counter;
n->breakdowns_since_last_service = o->breakdowns_since_last_service; n->breakdowns_since_last_service = o->breakdowns_since_last_service;
n->breakdown_ctr = o->breakdown_ctr; n->breakdown_ctr = o->breakdown_ctr;
@ -1108,7 +1115,7 @@ bool LoadOldSaveGame(const char *file)
_opt.currency = m->currency; _opt.currency = m->currency;
_opt.kilometers = m->use_kilometers; _opt.kilometers = m->use_kilometers;
_opt.town_name = m->town_name_type; _opt.town_name = m->town_name_type;
_opt.landscape = m->landscape_type; _opt.landscape = m->landscape_type & 0xf;
_opt.snow_line = m->snow_line_height; _opt.snow_line = m->snow_line_height;
_opt.autosave = 0; _opt.autosave = 0;
_opt.road_side = m->road_side; _opt.road_side = m->road_side;

View File

@ -22,6 +22,7 @@ int _replace_sprites_offset[16];
static const char *_cur_grffile; static const char *_cur_grffile;
static int _loading_stage; static int _loading_stage;
static int _skip_specials; static int _skip_specials;
uint16 _custom_sprites_base;
static SpriteHdr _cur_sprite; static SpriteHdr _cur_sprite;
@ -794,7 +795,6 @@ static void LoadSpriteTables()
// So just load all files from disk.. // So just load all files from disk..
int load_index = 0; int load_index = 0;
int old_load_index = 0;
for(i=0; _filename_list[i] != NULL; i++) { for(i=0; _filename_list[i] != NULL; i++) {
load_index += LoadGrfFile(_filename_list[i], load_index, (byte)i); load_index += LoadGrfFile(_filename_list[i], load_index, (byte)i);
@ -815,16 +815,16 @@ static void LoadSpriteTables()
/* Load newgrf sprites */ /* Load newgrf sprites */
_loading_stage = 0; _custom_sprites_base = load_index;
old_load_index = load_index;
_loading_stage = 0;
for (j = 0; j != lengthof(_newgrf_files) && _newgrf_files[j]; j++) { for (j = 0; j != lengthof(_newgrf_files) && _newgrf_files[j]; j++) {
InitNewGRFFile(_newgrf_files[j], load_index); InitNewGRFFile(_newgrf_files[j], load_index);
load_index += LoadNewGrfFile(_newgrf_files[j], load_index, i++); load_index += LoadNewGrfFile(_newgrf_files[j], load_index, i++);
} }
_loading_stage = 1; _loading_stage = 1;
load_index = old_load_index; load_index = _custom_sprites_base;
for (j = 0; j != lengthof(_newgrf_files) && _newgrf_files[j]; j++) for (j = 0; j != lengthof(_newgrf_files) && _newgrf_files[j]; j++)
load_index += LoadNewGrfFile(_newgrf_files[j], load_index, i++); load_index += LoadNewGrfFile(_newgrf_files[j], load_index, i++);