mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Clone should make a clone, not copy some data to another instance
parent
faa845398f
commit
a50c953854
|
@ -2000,7 +2000,9 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
if (buf.HasData(4) && buf.PeekDWord() == 0) {
|
if (buf.HasData(4) && buf.PeekDWord() == 0) {
|
||||||
buf.Skip(4);
|
buf.Skip(4);
|
||||||
extern const DrawTileSpriteSpan _station_display_datas_rail[8];
|
extern const DrawTileSpriteSpan _station_display_datas_rail[8];
|
||||||
dts->Clone(&_station_display_datas_rail[t % 8]);
|
const DrawTileSpriteSpan &dtss = _station_display_datas_rail[t % 8];
|
||||||
|
dts->ground = dtss.ground;
|
||||||
|
dts->seq.insert(dts->seq.end(), dtss.GetSequence().begin(), dtss.GetSequence().end());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2050,8 +2052,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
||||||
statspec->renderdata.reserve(srcstatspec->renderdata.size());
|
statspec->renderdata.reserve(srcstatspec->renderdata.size());
|
||||||
|
|
||||||
for (const auto &it : srcstatspec->renderdata) {
|
for (const auto &it : srcstatspec->renderdata) {
|
||||||
NewGRFSpriteLayout *dts = &statspec->renderdata.emplace_back();
|
statspec->renderdata.emplace_back(it);
|
||||||
dts->Clone(&it);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -566,16 +566,6 @@ bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t
|
||||||
|
|
||||||
/* static */ std::vector<DrawTileSeqStruct> NewGRFSpriteLayout::result_seq;
|
/* static */ std::vector<DrawTileSeqStruct> NewGRFSpriteLayout::result_seq;
|
||||||
|
|
||||||
/**
|
|
||||||
* Clone a spritelayout.
|
|
||||||
* @param source The spritelayout to copy.
|
|
||||||
*/
|
|
||||||
void NewGRFSpriteLayout::Clone(const NewGRFSpriteLayout *source)
|
|
||||||
{
|
|
||||||
this->Clone((const DrawTileSprites*)source);
|
|
||||||
this->registers = source->registers;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a spritelayout for \a num_sprites building sprites.
|
* Allocate a spritelayout for \a num_sprites building sprites.
|
||||||
|
|
|
@ -121,21 +121,6 @@ struct NewGRFSpriteLayout : ZeroedMemoryAllocator, DrawTileSprites {
|
||||||
|
|
||||||
void Allocate(uint num_sprites);
|
void Allocate(uint num_sprites);
|
||||||
void AllocateRegisters();
|
void AllocateRegisters();
|
||||||
void Clone(const NewGRFSpriteLayout *source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clone a spritelayout.
|
|
||||||
* @param source The spritelayout to copy.
|
|
||||||
*/
|
|
||||||
void Clone(const DrawTileSprites *source)
|
|
||||||
{
|
|
||||||
assert(source != nullptr && this != source);
|
|
||||||
|
|
||||||
auto source_sequence = source->GetSequence();
|
|
||||||
assert(this->seq.empty() && !source_sequence.empty());
|
|
||||||
this->ground = source->ground;
|
|
||||||
this->seq.insert(this->seq.end(), source_sequence.begin(), source_sequence.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether this spritelayout needs preprocessing by
|
* Tests whether this spritelayout needs preprocessing by
|
||||||
|
|
Loading…
Reference in New Issue