diff options
author | Charles Pigott <charlespigott@googlemail.com> | 2019-06-29 19:58:30 +0100 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2019-09-30 14:00:06 +0100 |
commit | 71a3e83468e36613ffe53b4e1689d52062da7c80 (patch) | |
tree | 49635f491cfd19a94d9a7b9b3cbbe45342f1c23b /src/newgrf_text.cpp | |
parent | acf0242961bf68312a5d9887e58832304e1f45c5 (diff) | |
download | openttd-71a3e83468e36613ffe53b4e1689d52062da7c80.tar.xz |
Fix: GCC9's warnings about deprecated implicit assignment operators
Diffstat (limited to 'src/newgrf_text.cpp')
-rw-r--r-- | src/newgrf_text.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 55a1301b1..0a6cfd4a8 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -18,6 +18,10 @@ */ #include "stdafx.h" + +#include <algorithm> +#include <array> + #include "newgrf.h" #include "strings_func.h" #include "newgrf_storage.h" @@ -812,22 +816,14 @@ void CleanUpStrings() } struct TextRefStack { - byte stack[0x30]; + std::array<byte, 0x30> stack; byte position; const GRFFile *grffile; bool used; TextRefStack() : position(0), grffile(nullptr), used(false) {} - TextRefStack(const TextRefStack &stack) : - position(stack.position), - grffile(stack.grffile), - used(stack.used) - { - memcpy(this->stack, stack.stack, sizeof(this->stack)); - } - - uint8 PopUnsignedByte() { assert(this->position < lengthof(this->stack)); return this->stack[this->position++]; } + uint8 PopUnsignedByte() { assert(this->position < this->stack.size()); return this->stack[this->position++]; } int8 PopSignedByte() { return (int8)this->PopUnsignedByte(); } uint16 PopUnsignedWord() @@ -865,9 +861,8 @@ struct TextRefStack { if (this->position >= 2) { this->position -= 2; } else { - for (int i = lengthof(stack) - 1; i >= this->position + 2; i--) { - this->stack[i] = this->stack[i - 2]; - } + // Rotate right 2 positions + std::rotate(this->stack.rbegin(), this->stack.rbegin() + 2, this->stack.rend()); } this->stack[this->position] = GB(word, 0, 8); this->stack[this->position + 1] = GB(word, 8, 8); @@ -939,12 +934,12 @@ void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint3 _newgrf_textrefstack.ResetStack(grffile); - byte *p = _newgrf_textrefstack.stack; + auto stack_it = _newgrf_textrefstack.stack.begin(); for (uint i = 0; i < numEntries; i++) { uint32 value = values != nullptr ? values[i] : _temp_store.GetValue(0x100 + i); for (uint j = 0; j < 32; j += 8) { - *p = GB(value, j, 8); - p++; + *stack_it = GB(value, j, 8); + stack_it++; } } } |