summaryrefslogtreecommitdiff
path: root/src/newgrf_config.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2020-05-17 23:31:47 +0200
committerMichael Lutz <michi@icosahedron.de>2020-05-21 20:02:34 +0200
commit43cd892e0c2c012355d7eb6d47cfa4ad4b7e68eb (patch)
tree589c8791baba745a7dfc3a33b19a28c8b0046ea8 /src/newgrf_config.h
parentf2b40f40aa7cbccaed20ec52b41d4704a45d8db1 (diff)
downloadopenttd-43cd892e0c2c012355d7eb6d47cfa4ad4b7e68eb.tar.xz
Codechange: Replace custom linked list for GRF texts with STL vectors and strings.
Diffstat (limited to 'src/newgrf_config.h')
-rw-r--r--src/newgrf_config.h34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/newgrf_config.h b/src/newgrf_config.h
index 8c3b2ecdf..2c8a8559d 100644
--- a/src/newgrf_config.h
+++ b/src/newgrf_config.h
@@ -16,6 +16,7 @@
#include "misc/countedptr.hpp"
#include "fileio_type.h"
#include "textfile_type.h"
+#include "newgrf_text.h"
/** GRF config bit flags */
enum GCF_Flags {
@@ -83,6 +84,16 @@ struct GRFIdentifier {
uint32 grfid; ///< GRF ID (defined by Action 0x08)
uint8 md5sum[16]; ///< MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
+ GRFIdentifier() = default;
+ GRFIdentifier(const GRFIdentifier &other) = default;
+ GRFIdentifier(GRFIdentifier &&other) = default;
+ GRFIdentifier(uint32 grfid, const uint8 *md5sum) : grfid(grfid)
+ {
+ MemCpyT(this->md5sum, md5sum, lengthof(this->md5sum));
+ }
+
+ GRFIdentifier& operator =(const GRFIdentifier &other) = default;
+
/**
* Does the identification match the provided values?
* @param grfid Expected grfid.
@@ -121,9 +132,8 @@ enum GRFParameterType {
struct GRFParameterInfo {
GRFParameterInfo(uint nr);
GRFParameterInfo(GRFParameterInfo &info);
- ~GRFParameterInfo();
- struct GRFText *name; ///< The name of this parameter
- struct GRFText *desc; ///< The description of this parameter
+ GRFTextList name; ///< The name of this parameter
+ GRFTextList desc; ///< The description of this parameter
GRFParameterType type; ///< The type of this parameter
uint32 min_value; ///< The minimal value this parameter can have
uint32 max_value; ///< The maximal value of this parameter
@@ -131,7 +141,7 @@ struct GRFParameterInfo {
byte param_nr; ///< GRF parameter to store content in
byte first_bit; ///< First bit to use in the GRF parameter
byte num_bit; ///< Number of bits to use for this parameter
- SmallMap<uint32, struct GRFText *> value_names; ///< Names for each value.
+ SmallMap<uint32, GRFTextList> value_names; ///< Names for each value.
bool complete_labels; ///< True if all values have a label.
uint32 GetValue(struct GRFConfig *config) const;
@@ -139,14 +149,6 @@ struct GRFParameterInfo {
void Finalize();
};
-/** Reference counted wrapper around a GRFText pointer. */
-struct GRFTextWrapper : public SimpleCountedObject {
- struct GRFText *text; ///< The actual text
-
- GRFTextWrapper();
- ~GRFTextWrapper();
-};
-
/** Information about GRF, used in the game and (part of it) in savegames */
struct GRFConfig : ZeroedMemoryAllocator {
GRFConfig(const char *filename = nullptr);
@@ -156,9 +158,9 @@ struct GRFConfig : ZeroedMemoryAllocator {
GRFIdentifier ident; ///< grfid and md5sum to uniquely identify newgrfs
uint8 original_md5sum[16]; ///< MD5 checksum of original file if only a 'compatible' file was loaded
char *filename; ///< Filename - either with or without full path
- GRFTextWrapper *name; ///< NOSAVE: GRF name (Action 0x08)
- GRFTextWrapper *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
- GRFTextWrapper *url; ///< NOSAVE: URL belonging to this GRF.
+ GRFTextWrapper name; ///< NOSAVE: GRF name (Action 0x08)
+ GRFTextWrapper info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
+ GRFTextWrapper url; ///< NOSAVE: URL belonging to this GRF.
GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B)
uint32 version; ///< NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown
@@ -229,7 +231,7 @@ void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFC
/** For communication about GRFs over the network */
#define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>"
-GRFTextWrapper *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
+GRFTextWrapper FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
void UpdateNewGRFScanStatus(uint num, const char *name);
bool UpdateNewGRFConfigPalette(int32 p1 = 0);