summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-01-12 18:01:16 +0000
committerfrosch <frosch@openttd.org>2014-01-12 18:01:16 +0000
commit00e7ceeca4ffa42c3837462c6444d1a7d5201a96 (patch)
tree3de76ee792d3bfb58eab3307c8777a6528657aa5 /src
parent4f419b8f84fc2e36eec9a89a1f2d3cbfb626ce5d (diff)
downloadopenttd-00e7ceeca4ffa42c3837462c6444d1a7d5201a96.tar.xz
(svn r26243) -Cleanup: Move TTDPStringIDToOTTDStringIDMapping to newgrf.cpp, it's only used there.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp64
-rw-r--r--src/newgrf_text.cpp64
-rw-r--r--src/newgrf_text.h2
3 files changed, 64 insertions, 66 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 4a25b1dd8..160bacca3 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -455,6 +455,70 @@ typedef std::map<StringID *, uint32> StringIDToGRFIDMapping;
static StringIDToGRFIDMapping _string_to_grf_mapping;
/**
+ * Perform a mapping from TTDPatch's string IDs to OpenTTD's
+ * string IDs, but only for the ones we are aware off; the rest
+ * like likely unused and will show a warning.
+ * @param str the string ID to convert
+ * @return the converted string ID
+ */
+static StringID TTDPStringIDToOTTDStringIDMapping(StringID str)
+{
+ /* StringID table for TextIDs 0x4E->0x6D */
+ static const StringID units_volume[] = {
+ STR_ITEMS, STR_PASSENGERS, STR_TONS, STR_BAGS,
+ STR_LITERS, STR_ITEMS, STR_CRATES, STR_TONS,
+ STR_TONS, STR_TONS, STR_TONS, STR_BAGS,
+ STR_TONS, STR_TONS, STR_TONS, STR_BAGS,
+ STR_TONS, STR_TONS, STR_BAGS, STR_LITERS,
+ STR_TONS, STR_LITERS, STR_TONS, STR_ITEMS,
+ STR_BAGS, STR_LITERS, STR_TONS, STR_ITEMS,
+ STR_TONS, STR_ITEMS, STR_LITERS, STR_ITEMS
+ };
+
+ /* A string straight from a NewGRF; this was already translated by MapGRFStringID(). */
+ assert(!IsInsideMM(str, 0xD000, 0xD7FF));
+
+#define TEXTID_TO_STRINGID(begin, end, stringid, stringend) \
+ assert_compile(stringend - stringid == end - begin); \
+ if (str >= begin && str <= end) return str + (stringid - begin)
+
+ /* We have some changes in our cargo strings, resulting in some missing. */
+ TEXTID_TO_STRINGID(0x000E, 0x002D, STR_CARGO_PLURAL_NOTHING, STR_CARGO_PLURAL_FIZZY_DRINKS);
+ TEXTID_TO_STRINGID(0x002E, 0x004D, STR_CARGO_SINGULAR_NOTHING, STR_CARGO_SINGULAR_FIZZY_DRINK);
+ if (str >= 0x004E && str <= 0x006D) return units_volume[str - 0x004E];
+ TEXTID_TO_STRINGID(0x006E, 0x008D, STR_QUANTITY_NOTHING, STR_QUANTITY_FIZZY_DRINKS);
+ TEXTID_TO_STRINGID(0x008E, 0x00AD, STR_ABBREV_NOTHING, STR_ABBREV_FIZZY_DRINKS);
+ TEXTID_TO_STRINGID(0x00D1, 0x00E0, STR_COLOUR_DARK_BLUE, STR_COLOUR_WHITE);
+
+ /* Map building names according to our lang file changes. There are several
+ * ranges of house ids, all of which need to be remapped to allow newgrfs
+ * to use original house names. */
+ TEXTID_TO_STRINGID(0x200F, 0x201F, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1, STR_TOWN_BUILDING_NAME_OLD_HOUSES_1);
+ TEXTID_TO_STRINGID(0x2036, 0x2041, STR_TOWN_BUILDING_NAME_COTTAGES_1, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1);
+ TEXTID_TO_STRINGID(0x2059, 0x205C, STR_TOWN_BUILDING_NAME_IGLOO_1, STR_TOWN_BUILDING_NAME_PIGGY_BANK_1);
+
+ /* Same thing for industries */
+ TEXTID_TO_STRINGID(0x4802, 0x4826, STR_INDUSTRY_NAME_COAL_MINE, STR_INDUSTRY_NAME_SUGAR_MINE);
+ TEXTID_TO_STRINGID(0x482D, 0x482E, STR_NEWS_INDUSTRY_CONSTRUCTION, STR_NEWS_INDUSTRY_PLANTED);
+ TEXTID_TO_STRINGID(0x4832, 0x4834, STR_NEWS_INDUSTRY_CLOSURE_GENERAL, STR_NEWS_INDUSTRY_CLOSURE_LACK_OF_TREES);
+ TEXTID_TO_STRINGID(0x4835, 0x4838, STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_GENERAL, STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_FARM);
+ TEXTID_TO_STRINGID(0x4839, 0x483A, STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_GENERAL, STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_FARM);
+
+ switch (str) {
+ case 0x4830: return STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY;
+ case 0x4831: return STR_ERROR_FOREST_CAN_ONLY_BE_PLANTED;
+ case 0x483B: return STR_ERROR_CAN_ONLY_BE_POSITIONED;
+ }
+#undef TEXTID_TO_STRINGID
+
+ if (str == STR_NULL) return STR_EMPTY;
+
+ DEBUG(grf, 0, "Unknown StringID 0x%04X remapped to STR_EMPTY. Please open a Feature Request if you need it", str);
+
+ return STR_EMPTY;
+}
+
+/**
* Used when setting an object's property to map to the GRF's strings
* while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one
* @param grfid Id of the grf file.
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index 66e19034f..b14a26bbd 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -36,70 +36,6 @@
#define TABSIZE 11
/**
- * Perform a mapping from TTDPatch's string IDs to OpenTTD's
- * string IDs, but only for the ones we are aware off; the rest
- * like likely unused and will show a warning.
- * @param str the string ID to convert
- * @return the converted string ID
- */
-StringID TTDPStringIDToOTTDStringIDMapping(StringID str)
-{
- /* StringID table for TextIDs 0x4E->0x6D */
- static const StringID units_volume[] = {
- STR_ITEMS, STR_PASSENGERS, STR_TONS, STR_BAGS,
- STR_LITERS, STR_ITEMS, STR_CRATES, STR_TONS,
- STR_TONS, STR_TONS, STR_TONS, STR_BAGS,
- STR_TONS, STR_TONS, STR_TONS, STR_BAGS,
- STR_TONS, STR_TONS, STR_BAGS, STR_LITERS,
- STR_TONS, STR_LITERS, STR_TONS, STR_ITEMS,
- STR_BAGS, STR_LITERS, STR_TONS, STR_ITEMS,
- STR_TONS, STR_ITEMS, STR_LITERS, STR_ITEMS
- };
-
- /* A string straight from a NewGRF; this was already translated by MapGRFStringID(). */
- assert(!IsInsideMM(str, 0xD000, 0xD7FF));
-
-#define TEXTID_TO_STRINGID(begin, end, stringid, stringend) \
- assert_compile(stringend - stringid == end - begin); \
- if (str >= begin && str <= end) return str + (stringid - begin)
-
- /* We have some changes in our cargo strings, resulting in some missing. */
- TEXTID_TO_STRINGID(0x000E, 0x002D, STR_CARGO_PLURAL_NOTHING, STR_CARGO_PLURAL_FIZZY_DRINKS);
- TEXTID_TO_STRINGID(0x002E, 0x004D, STR_CARGO_SINGULAR_NOTHING, STR_CARGO_SINGULAR_FIZZY_DRINK);
- if (str >= 0x004E && str <= 0x006D) return units_volume[str - 0x004E];
- TEXTID_TO_STRINGID(0x006E, 0x008D, STR_QUANTITY_NOTHING, STR_QUANTITY_FIZZY_DRINKS);
- TEXTID_TO_STRINGID(0x008E, 0x00AD, STR_ABBREV_NOTHING, STR_ABBREV_FIZZY_DRINKS);
- TEXTID_TO_STRINGID(0x00D1, 0x00E0, STR_COLOUR_DARK_BLUE, STR_COLOUR_WHITE);
-
- /* Map building names according to our lang file changes. There are several
- * ranges of house ids, all of which need to be remapped to allow newgrfs
- * to use original house names. */
- TEXTID_TO_STRINGID(0x200F, 0x201F, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1, STR_TOWN_BUILDING_NAME_OLD_HOUSES_1);
- TEXTID_TO_STRINGID(0x2036, 0x2041, STR_TOWN_BUILDING_NAME_COTTAGES_1, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1);
- TEXTID_TO_STRINGID(0x2059, 0x205C, STR_TOWN_BUILDING_NAME_IGLOO_1, STR_TOWN_BUILDING_NAME_PIGGY_BANK_1);
-
- /* Same thing for industries */
- TEXTID_TO_STRINGID(0x4802, 0x4826, STR_INDUSTRY_NAME_COAL_MINE, STR_INDUSTRY_NAME_SUGAR_MINE);
- TEXTID_TO_STRINGID(0x482D, 0x482E, STR_NEWS_INDUSTRY_CONSTRUCTION, STR_NEWS_INDUSTRY_PLANTED);
- TEXTID_TO_STRINGID(0x4832, 0x4834, STR_NEWS_INDUSTRY_CLOSURE_GENERAL, STR_NEWS_INDUSTRY_CLOSURE_LACK_OF_TREES);
- TEXTID_TO_STRINGID(0x4835, 0x4838, STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_GENERAL, STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_FARM);
- TEXTID_TO_STRINGID(0x4839, 0x483A, STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_GENERAL, STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_FARM);
-
- switch (str) {
- case 0x4830: return STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY;
- case 0x4831: return STR_ERROR_FOREST_CAN_ONLY_BE_PLANTED;
- case 0x483B: return STR_ERROR_CAN_ONLY_BE_POSITIONED;
- }
-#undef TEXTID_TO_STRINGID
-
- if (str == STR_NULL) return STR_EMPTY;
-
- DEBUG(grf, 0, "Unknown StringID 0x%04X remapped to STR_EMPTY. Please open a Feature Request if you need it", str);
-
- return STR_EMPTY;
-}
-
-/**
* Explains the newgrf shift bit positioning.
* the grf base will not be used in order to find the string, but rather for
* jumping from standard langID scheme to the new one.
diff --git a/src/newgrf_text.h b/src/newgrf_text.h
index 78e0b8ca5..6587fc1fe 100644
--- a/src/newgrf_text.h
+++ b/src/newgrf_text.h
@@ -43,8 +43,6 @@ struct TextRefStack *CreateTextRefStackBackup();
void RestoreTextRefStackBackup(struct TextRefStack *backup);
uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, int64 *argv, uint argv_size, bool modify_argv);
-StringID TTDPStringIDToOTTDStringIDMapping(StringID string);
-
/** Mapping of language data between a NewGRF and OpenTTD. */
struct LanguageMap {
/** Mapping between NewGRF and OpenTTD IDs. */