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

This commit is contained in:
Jonathan G Rennison
2019-11-05 18:08:02 +00:00
parent e81697c363
commit 91ca46c774
3 changed files with 10 additions and 6 deletions

View File

@@ -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);
}
}