1
0
Fork 0

Codefix: Clone should make a clone, not copy some data to another instance

pull/13577/head
Rubidium 2025-01-12 22:00:19 +01:00 committed by rubidium42
parent faa845398f
commit a50c953854
3 changed files with 4 additions and 28 deletions

View File

@ -2000,7 +2000,9 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
if (buf.HasData(4) && buf.PeekDWord() == 0) {
buf.Skip(4);
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;
}
@ -2050,8 +2052,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
statspec->renderdata.reserve(srcstatspec->renderdata.size());
for (const auto &it : srcstatspec->renderdata) {
NewGRFSpriteLayout *dts = &statspec->renderdata.emplace_back();
dts->Clone(&it);
statspec->renderdata.emplace_back(it);
}
break;
}

View File

@ -566,16 +566,6 @@ bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t
/* 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.

View File

@ -121,21 +121,6 @@ struct NewGRFSpriteLayout : ZeroedMemoryAllocator, DrawTileSprites {
void Allocate(uint num_sprites);
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