Merge branch 'master' into jgrpp

# Conflicts:
#	source.list
#	src/blitter/32bpp_anim.cpp
#	src/linkgraph/linkgraphjob.cpp
#	src/order_cmd.cpp
#	src/vehicle.cpp
#	src/vehicle_type.h
This commit is contained in:
Jonathan G Rennison
2019-10-05 21:27:20 +01:00
132 changed files with 1354 additions and 300 deletions

View File

@@ -14,10 +14,14 @@
* holding everything that the newgrf action 04 will send over to OpenTTD.
* One of the biggest problems is that Dynamic lang Array uses ISO codes
* as way to identifying current user lang, while newgrf uses bit shift codes
* not related to ISO. So equivalence functionnality had to be set.
* not related to ISO. So equivalence functionality had to be set.
*/
#include "stdafx.h"
#include <algorithm>
#include <array>
#include "newgrf.h"
#include "strings_func.h"
#include "newgrf_storage.h"
@@ -831,22 +835,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()
@@ -884,9 +880,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);
@@ -958,12 +953,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++;
}
}
}