summaryrefslogtreecommitdiff
path: root/src/newgrf_text.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_text.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_text.h')
-rw-r--r--src/newgrf_text.h27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/newgrf_text.h b/src/newgrf_text.h
index 709f4dd24..bdd1f1bc9 100644
--- a/src/newgrf_text.h
+++ b/src/newgrf_text.h
@@ -14,26 +14,39 @@
#include "strings_type.h"
#include "core/smallvec_type.hpp"
#include "table/control_codes.h"
+#include <utility>
+#include <vector>
+#include <string>
/** This character, the thorn ('รพ'), indicates a unicode string to NFO. */
static const WChar NFO_UTF8_IDENTIFIER = 0x00DE;
+/** A GRF text with associated language ID. */
+struct GRFText {
+ byte langid; ///< The language associated with this GRFText.
+ std::string text; ///< The actual (translated) text.
+};
+
+/** A GRF text with a list of translations. */
+typedef std::vector<GRFText> GRFTextList;
+/** Reference counted wrapper around a GRFText pointer. */
+typedef std::shared_ptr<GRFTextList> GRFTextWrapper;
+
StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string);
StringID GetGRFStringID(uint32 grfid, StringID stringid);
-const char *GetGRFStringFromGRFText(const struct GRFText *text);
+const char *GetGRFStringFromGRFText(const GRFTextList &text_list);
+const char *GetGRFStringFromGRFText(const GRFTextWrapper &text);
const char *GetGRFStringPtr(uint16 stringid);
void CleanUpStrings();
void SetCurrentGrfLangID(byte language_id);
char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const char *str, int *olen = nullptr, StringControlCode byte80 = SCC_NEWGRF_PRINT_WORD_STRING_ID);
-struct GRFText *DuplicateGRFText(struct GRFText *orig);
-void AddGRFTextToList(struct GRFText **list, struct GRFText *text_to_add);
-void AddGRFTextToList(struct GRFText **list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add);
-void AddGRFTextToList(struct GRFText **list, const char *text_to_add);
-void CleanUpGRFText(struct GRFText *grftext);
+void AddGRFTextToList(GRFTextList &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add);
+void AddGRFTextToList(GRFTextWrapper &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add);
+void AddGRFTextToList(GRFTextWrapper &list, const char *text_to_add);
bool CheckGrfLangID(byte lang_id, byte grf_version);
-void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32 *values = nullptr);
+void StartTextRefStackUsage(const struct GRFFile *grffile, byte numEntries, const uint32 *values = nullptr);
void StopTextRefStackUsage();
void RewindTextRefStack();
bool UsingNewGRFTextStack();