* 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 Grf-local GRFStringID to convert. * @return the converted string ID */
| 63 | * @return the converted string ID |
| 64 | */ |
| 65 | static StringID TTDPStringIDToOTTDStringIDMapping(GRFStringID str) |
| 66 | { |
| 67 | /* StringID table for TextIDs 0x4E->0x6D */ |
| 68 | static const StringID units_volume[] = { |
| 69 | STR_ITEMS, STR_PASSENGERS, STR_TONS, STR_BAGS, |
| 70 | STR_LITERS, STR_ITEMS, STR_CRATES, STR_TONS, |
| 71 | STR_TONS, STR_TONS, STR_TONS, STR_BAGS, |
| 72 | STR_TONS, STR_TONS, STR_TONS, STR_BAGS, |
| 73 | STR_TONS, STR_TONS, STR_BAGS, STR_LITERS, |
| 74 | STR_TONS, STR_LITERS, STR_TONS, STR_ITEMS, |
| 75 | STR_BAGS, STR_LITERS, STR_TONS, STR_ITEMS, |
| 76 | STR_TONS, STR_ITEMS, STR_LITERS, STR_ITEMS |
| 77 | }; |
| 78 | |
| 79 | /* A string straight from a NewGRF; this was already translated by MapGRFStringID(). */ |
| 80 | assert(!IsInsideMM(str.base(), 0xD000, 0xD7FF)); |
| 81 | |
| 82 | #define TEXTID_TO_STRINGID(begin, end, stringid, stringend) \ |
| 83 | static_assert(stringend - stringid == end - begin); \ |
| 84 | if (str.base() >= begin && str.base() <= end) return StringID{str.base() + (stringid - begin)} |
| 85 | |
| 86 | /* We have some changes in our cargo strings, resulting in some missing. */ |
| 87 | TEXTID_TO_STRINGID(0x000E, 0x002D, STR_CARGO_PLURAL_NOTHING, STR_CARGO_PLURAL_FIZZY_DRINKS); |
| 88 | TEXTID_TO_STRINGID(0x002E, 0x004D, STR_CARGO_SINGULAR_NOTHING, STR_CARGO_SINGULAR_FIZZY_DRINK); |
| 89 | if (str.base() >= 0x004E && str.base() <= 0x006D) return units_volume[str.base() - 0x004E]; |
| 90 | TEXTID_TO_STRINGID(0x006E, 0x008D, STR_QUANTITY_NOTHING, STR_QUANTITY_FIZZY_DRINKS); |
| 91 | TEXTID_TO_STRINGID(0x008E, 0x00AD, STR_ABBREV_NOTHING, STR_ABBREV_FIZZY_DRINKS); |
| 92 | TEXTID_TO_STRINGID(0x00D1, 0x00E0, STR_COLOUR_DARK_BLUE, STR_COLOUR_WHITE); |
| 93 | |
| 94 | /* Map building names according to our lang file changes. There are several |
| 95 | * ranges of house ids, all of which need to be remapped to allow newgrfs |
| 96 | * to use original house names. */ |
| 97 | TEXTID_TO_STRINGID(0x200F, 0x201F, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1, STR_TOWN_BUILDING_NAME_OLD_HOUSES_1); |
| 98 | TEXTID_TO_STRINGID(0x2036, 0x2041, STR_TOWN_BUILDING_NAME_COTTAGES_1, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1); |
| 99 | TEXTID_TO_STRINGID(0x2059, 0x205C, STR_TOWN_BUILDING_NAME_IGLOO_1, STR_TOWN_BUILDING_NAME_PIGGY_BANK_1); |
| 100 | |
| 101 | /* Same thing for industries */ |
| 102 | TEXTID_TO_STRINGID(0x4802, 0x4826, STR_INDUSTRY_NAME_COAL_MINE, STR_INDUSTRY_NAME_SUGAR_MINE); |
| 103 | TEXTID_TO_STRINGID(0x482D, 0x482E, STR_NEWS_INDUSTRY_CONSTRUCTION, STR_NEWS_INDUSTRY_PLANTED); |
| 104 | TEXTID_TO_STRINGID(0x4832, 0x4834, STR_NEWS_INDUSTRY_CLOSURE_GENERAL, STR_NEWS_INDUSTRY_CLOSURE_LACK_OF_TREES); |
| 105 | TEXTID_TO_STRINGID(0x4835, 0x4838, STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_GENERAL, STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_FARM); |
| 106 | TEXTID_TO_STRINGID(0x4839, 0x483A, STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_GENERAL, STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_FARM); |
| 107 | |
| 108 | switch (str.base()) { |
| 109 | case 0x4830: return STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY; |
| 110 | case 0x4831: return STR_ERROR_FOREST_CAN_ONLY_BE_PLANTED; |
| 111 | case 0x483B: return STR_ERROR_CAN_ONLY_BE_POSITIONED; |
| 112 | } |
| 113 | #undef TEXTID_TO_STRINGID |
| 114 | |
| 115 | if (str.base() == 0) return STR_EMPTY; |
| 116 | |
| 117 | Debug(grf, 0, "Unknown StringID 0x{:04X} remapped to STR_EMPTY. Please open a Feature Request if you need it", str); |
| 118 | |
| 119 | return STR_EMPTY; |
| 120 | } |
| 121 | |
| 122 | /** |
no test coverage detected