TBTR: Fix palette recolouring of templates
Fix group overrides affecting template image when cloning vehicle Update template when changing company colours Update template images on demand instead of at load
This commit is contained in:
@@ -3838,7 +3838,7 @@ bool AfterLoadGame()
|
||||
AfterLoadLinkGraphs();
|
||||
|
||||
AfterLoadTraceRestrict();
|
||||
AfterLoadTemplateVehiclesUpdateImage();
|
||||
AfterLoadTemplateVehiclesUpdate();
|
||||
if (SlXvIsFeaturePresent(XSLFI_TEMPLATE_REPLACEMENT, 1, 5)) {
|
||||
AfterLoadTemplateVehiclesUpdateProperties();
|
||||
}
|
||||
@@ -3937,7 +3937,7 @@ void ReloadNewGRFData()
|
||||
/* redraw the whole screen */
|
||||
MarkWholeScreenDirty();
|
||||
CheckTrainsLengths();
|
||||
AfterLoadTemplateVehiclesUpdateImage();
|
||||
AfterLoadTemplateVehiclesUpdateImages();
|
||||
AfterLoadTemplateVehiclesUpdateProperties();
|
||||
UpdateAllAnimatedTileSpeeds();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ void ResetTempEngineData();
|
||||
Engine *GetTempDataEngine(EngineID index);
|
||||
void CopyTempEngineData();
|
||||
|
||||
void AfterLoadTemplateVehiclesUpdateImage();
|
||||
void AfterLoadTemplateVehiclesUpdate();
|
||||
void AfterLoadTemplateVehiclesUpdateImages();
|
||||
void AfterLoadTemplateVehiclesUpdateProperties();
|
||||
|
||||
extern int32 _saved_scrollpos_x;
|
||||
|
||||
@@ -99,7 +99,7 @@ void AfterLoadTemplateVehicles()
|
||||
}
|
||||
}
|
||||
|
||||
void AfterLoadTemplateVehiclesUpdateImage()
|
||||
void AfterLoadTemplateVehiclesUpdate()
|
||||
{
|
||||
SavedRandomSeeds saved_seeds;
|
||||
SaveRandomSeeds(&saved_seeds);
|
||||
@@ -113,36 +113,14 @@ void AfterLoadTemplateVehiclesUpdateImage()
|
||||
}
|
||||
}
|
||||
|
||||
for (TemplateVehicle *tv : TemplateVehicle::Iterate()) {
|
||||
if (tv->Prev() == nullptr) {
|
||||
Backup<CompanyID> cur_company(_current_company, tv->owner, FILE_LINE);
|
||||
StringID err;
|
||||
Train* t = VirtualTrainFromTemplateVehicle(tv, err, 0);
|
||||
if (t != nullptr) {
|
||||
int tv_len = 0;
|
||||
for (TemplateVehicle *u = tv; u != nullptr; u = u->Next()) {
|
||||
tv_len++;
|
||||
}
|
||||
int t_len = 0;
|
||||
for (Train *u = t; u != nullptr; u = u->Next()) {
|
||||
t_len++;
|
||||
}
|
||||
if (t_len == tv_len) {
|
||||
Train *v = t;
|
||||
for (TemplateVehicle *u = tv; u != nullptr; u = u->Next(), v = v->Next()) {
|
||||
v->GetImage(DIR_W, EIT_IN_DEPOT, &u->sprite_seq);
|
||||
u->image_dimensions.SetFromTrain(v);
|
||||
}
|
||||
} else {
|
||||
DEBUG(misc, 0, "AfterLoadTemplateVehiclesUpdateImage: vehicle count mismatch: %u, %u", t_len, tv_len);
|
||||
}
|
||||
delete t;
|
||||
}
|
||||
cur_company.Restore();
|
||||
}
|
||||
}
|
||||
|
||||
RestoreRandomSeeds(saved_seeds);
|
||||
|
||||
InvalidateTemplateReplacementImages();
|
||||
}
|
||||
|
||||
void AfterLoadTemplateVehiclesUpdateImages()
|
||||
{
|
||||
InvalidateTemplateReplacementImages();
|
||||
}
|
||||
|
||||
void AfterLoadTemplateVehiclesUpdateProperties()
|
||||
|
||||
Reference in New Issue
Block a user