Fix -Wdeprecated-copy and -Wclass-memaccess warnings on GCC 9

pull/115/head
Jonathan G Rennison 5 years ago
parent e81697c363
commit 91ca46c774

@ -2704,11 +2704,14 @@ bool AfterLoadGame()
/* yearly_expenses has 3*15 entries now, saveload code gave us 3*13.
* Move the old data to the right place in the new array and clear the new data.
* The move has to be done in reverse order (first 2, then 1). */
MemMoveT(&c->yearly_expenses[2][0], &c->yearly_expenses[1][11], 13);
MemMoveT(&c->yearly_expenses[1][0], &c->yearly_expenses[0][13], 13);
// MemMoveT(&c->yearly_expenses[2][0], &c->yearly_expenses[1][11], 13);
// MemMoveT(&c->yearly_expenses[1][0], &c->yearly_expenses[0][13], 13);
// The below are equivalent to the MemMoveT calls above
std::copy_backward(&c->yearly_expenses[1][11], &c->yearly_expenses[1][11] + 13, &c->yearly_expenses[2][0] + 13);
std::copy_backward(&c->yearly_expenses[0][13], &c->yearly_expenses[0][13] + 13, &c->yearly_expenses[1][0] + 13);
/* Clear the old location of just-moved data, so sharing income/expenses is set to 0 */
MemSetT(&c->yearly_expenses[0][13], 0, 2);
MemSetT(&c->yearly_expenses[1][13], 0, 2);
std::fill_n(&c->yearly_expenses[0][13], 2, 0);
std::fill_n(&c->yearly_expenses[1][13], 2, 0);
}
}

@ -358,6 +358,8 @@ public:
FlowStatMapIterator(const FlowStatMapIterator<FlowStat, FlowStatMap, btree::btree_map<StationID, uint16>::iterator> &other) :
fsm(other.fsm), current(other.current) {}
FlowStatMapIterator &operator=(const FlowStatMapIterator &) = default;
reference operator*() const { return this->fsm->flows_storage[this->current->second]; }
pointer operator->() const { return &(this->fsm->flows_storage[this->current->second]); }

@ -194,8 +194,7 @@ SpriteID TileZoneCheckUnservedBuildingsEvaluation(TileIndex tile, Owner owner)
}
CargoArray dat;
memset(&dat, 0, sizeof(dat));
dat.Clear();
AddAcceptedCargo(tile, dat, nullptr);
if (dat[CT_MAIL] + dat[CT_PASSENGERS] == 0) {
// nothing is accepted, so now test if cargo is produced

Loading…
Cancel
Save