TBTR: Savegame and API changes to support multiple sprites per vehicle.

This commit is contained in:
Jonathan G Rennison 2016-11-01 20:27:30 +00:00
parent d204062300
commit 92254acf8d
7 changed files with 13 additions and 10 deletions

View File

@ -45,7 +45,7 @@ std::vector<uint32> _sl_xv_discardable_chunk_ids; ///< list of chunks
static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version os SLXI chunk
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_TEMPLATE_REPLACEMENT, XSCF_NULL, 1, 1, "template_replacement", NULL, NULL, "TRPL,TMPL" },
{ XSLFI_TEMPLATE_REPLACEMENT, XSCF_NULL, 2, 2, "template_replacement", NULL, NULL, "TRPL,TMPL" },
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
};

View File

@ -38,7 +38,9 @@ const SaveLoad* GTD() {
SLE_VAR(TemplateVehicle, max_te, SLE_UINT32),
SLE_VAR(TemplateVehicle, spritenum, SLE_UINT8),
SLE_VAR(TemplateVehicle, cur_image, SLE_UINT32),
SLE_CONDVAR_X(TemplateVehicle, sprite_seq.seq[0].sprite, SLE_UINT32, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TEMPLATE_REPLACEMENT, 0, 1)),
SLE_CONDVAR_X(TemplateVehicle, sprite_seq.count, SLE_UINT32, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TEMPLATE_REPLACEMENT, 2)),
SLE_CONDARR_X(TemplateVehicle, sprite_seq.seq, SLE_UINT32, 8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TEMPLATE_REPLACEMENT, 2)),
SLE_VAR(TemplateVehicle, image_width, SLE_UINT32),
SLE_END()
@ -123,7 +125,7 @@ void AfterLoadTemplateVehiclesUpdateImage()
Train *v = t;
for (TemplateVehicle *u = tv; u != NULL; u = u->Next(), v = v->Next()) {
u->spritenum = v->spritenum;
u->cur_image = v->GetImage(DIR_W, EIT_PURCHASE);
v->GetImage(DIR_W, EIT_PURCHASE, &u->sprite_seq);
u->image_width = v->GetDisplayImageWidth();
}
}

View File

@ -64,7 +64,7 @@ TemplateVehicle::TemplateVehicle(VehicleType ty, EngineID eid, byte subtypeflag,
this->previous = 0x0;
this->owner_b = _current_company;
this->cur_image = SPR_IMG_QUERY;
this->sprite_seq.Set(SPR_IMG_QUERY);
this->owner = current_owner;

View File

@ -90,7 +90,7 @@ public:
uint32 max_te;
byte spritenum;
SpriteID cur_image;
VehicleSpriteSeq sprite_seq; ///< Vehicle appearance.
uint32 image_width;
TemplateVehicle(VehicleType type = VEH_INVALID, EngineID e = INVALID_ENGINE, byte B = 0, Owner = _local_company);
@ -105,6 +105,7 @@ public:
this->reuse_depot_vehicles = true;
this->keep_remaining_vehicles = true;
this->refit_as_template = true;
this->sprite_seq.count = 1;
}
~TemplateVehicle();

View File

@ -132,7 +132,7 @@ void DrawTemplate(const TemplateVehicle *tv, int left, int right, int y)
while (t) {
PaletteID pal = GetEnginePalette(t->engine_type, _current_company);
DrawSprite(t->cur_image, pal, offset + t->image_width / 2, ScaleGUITrad(11));
t->sprite_seq.Draw(offset + t->image_width / 2, ScaleGUITrad(11), pal, false);
offset += t->image_width;
t = t->Next();
@ -167,7 +167,7 @@ inline void SetupTemplateVehicleFromVirtual(TemplateVehicle *tmp, TemplateVehicl
tmp->max_te = gcache->cached_max_te / 1000;
tmp->spritenum = virt->spritenum;
tmp->cur_image = virt->GetImage(DIR_W, EIT_PURCHASE);
virt->GetImage(DIR_W, EIT_PURCHASE, &tmp->sprite_seq);
Point *p = new Point();
tmp->image_width = virt->GetDisplayImageWidth(p);
}

View File

@ -4124,7 +4124,7 @@ Train* CmdBuildVirtualRailWagon(const Engine *e)
v->railtype = rvi->railtype;
v->build_year = _cur_year;
v->cur_image = SPR_IMG_QUERY;
v->sprite_seq.Set(SPR_IMG_QUERY);
v->random_bits = VehicleRandomBits();
v->group_id = DEFAULT_GROUP;
@ -4200,7 +4200,7 @@ Train* CmdBuildVirtualRailVehicle(EngineID eid, bool lax_engine_check, StringID
v->railtype = rvi->railtype;
_new_vehicle_id = v->index;
v->cur_image = SPR_IMG_QUERY;
v->sprite_seq.Set(SPR_IMG_QUERY);
v->random_bits = VehicleRandomBits();
v->group_id = DEFAULT_GROUP;

View File

@ -809,7 +809,7 @@ inline void SetupTemplateVehicleFromVirtual(TemplateVehicle *tmp, TemplateVehicl
tmp->max_te = gcache->cached_max_te / 1000;
tmp->spritenum = virt->spritenum;
tmp->cur_image = virt->GetImage(DIR_W, EIT_PURCHASE);
virt->GetImage(DIR_W, EIT_PURCHASE, &tmp->sprite_seq);
tmp->image_width = virt->GetDisplayImageWidth();
}