Merge remote-tracking branch 'upstream/1.11' into 1.11

This commit is contained in:
dP
2021-03-15 20:11:52 +03:00
327 changed files with 31198 additions and 8572 deletions

View File

@@ -47,7 +47,7 @@
#include "safeguards.h"
/** The sprite picker. */
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, nullptr, 0, std::vector<SpriteID>() };
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, nullptr, std::vector<SpriteID>() };
/**
* Get the feature index related to the window number.
@@ -81,12 +81,14 @@ enum NIType {
NIT_CARGO, ///< The property is a cargo
};
typedef const void *NIOffsetProc(const void *b);
/** Representation of the data from a NewGRF property. */
struct NIProperty {
const char *name; ///< A (human readable) name for the property
ptrdiff_t offset; ///< Offset of the variable in the class
byte read_size; ///< Number of bytes (i.e. byte, word, dword etc)
byte prop; ///< The number of the property
const char *name; ///< A (human readable) name for the property
NIOffsetProc *offset_proc; ///< Callback proc to get the actual variable address in memory
byte read_size; ///< Number of bytes (i.e. byte, word, dword etc)
byte prop; ///< The number of the property
byte type;
};
@@ -96,11 +98,11 @@ struct NIProperty {
* information on when they actually apply.
*/
struct NICallback {
const char *name; ///< The human readable name of the callback
ptrdiff_t offset; ///< Offset of the variable in the class
byte read_size; ///< The number of bytes (i.e. byte, word, dword etc) to read
byte cb_bit; ///< The bit that needs to be set for this callback to be enabled
uint16 cb_id; ///< The number of the callback
const char *name; ///< The human readable name of the callback
NIOffsetProc *offset_proc; ///< Callback proc to get the actual variable address in memory
byte read_size; ///< The number of bytes (i.e. byte, word, dword etc) to read
byte cb_bit; ///< The bit that needs to be set for this callback to be enabled
uint16 cb_id; ///< The number of the callback
};
/** Mask to show no bit needs to be enabled for the callback. */
static const int CBM_NO_BIT = UINT8_MAX;
@@ -494,7 +496,7 @@ struct NewGRFInspectWindow : Window {
if (nif->properties != nullptr) {
this->DrawString(r, i++, "Properties:");
for (const NIProperty *nip = nif->properties; nip->name != nullptr; nip++) {
const void *ptr = (const byte *)base + nip->offset;
const void *ptr = nip->offset_proc(base);
uint value;
switch (nip->read_size) {
case 1: value = *(const uint8 *)ptr; break;
@@ -528,7 +530,7 @@ struct NewGRFInspectWindow : Window {
this->DrawString(r, i++, "Callbacks:");
for (const NICallback *nic = nif->callbacks; nic->name != nullptr; nic++) {
if (nic->cb_bit != CBM_NO_BIT) {
const void *ptr = (const byte *)base_spec + nic->offset;
const void *ptr = nic->offset_proc(base_spec);
uint value;
switch (nic->read_size) {
case 1: value = *(const uint8 *)ptr; break;