* 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. * @param str GRF-local GRFStringID that we want to have the equivalent in OpenTTD. * @return The properly adjusted StringID. */
| 127 | * @return The properly adjusted StringID. |
| 128 | */ |
| 129 | StringID MapGRFStringID(uint32_t grfid, GRFStringID str) |
| 130 | { |
| 131 | if (IsInsideMM(str.base(), 0xD800, 0x10000)) { |
| 132 | /* General text provided by NewGRF. |
| 133 | * In the specs this is called the 0xDCxx range (misc persistent texts), |
| 134 | * but we meanwhile extended the range to 0xD800-0xFFFF. |
| 135 | * Note: We are not involved in the "persistent" business, since we do not store |
| 136 | * any NewGRF strings in savegames. */ |
| 137 | return GetGRFStringID(grfid, str); |
| 138 | } else if (IsInsideMM(str.base(), 0xD000, 0xD800)) { |
| 139 | /* Callback text provided by NewGRF. |
| 140 | * In the specs this is called the 0xD0xx range (misc graphics texts). |
| 141 | * These texts can be returned by various callbacks. |
| 142 | * |
| 143 | * Due to how TTDP implements the GRF-local- to global-textid translation |
| 144 | * texts included via 0x80 or 0x81 control codes have to add 0x400 to the textid. |
| 145 | * We do not care about that difference and just mask out the 0x400 bit. |
| 146 | */ |
| 147 | str = GRFStringID(str.base() & ~0x400); |
| 148 | return GetGRFStringID(grfid, str); |
| 149 | } else { |
| 150 | /* The NewGRF wants to include/reference an original TTD string. |
| 151 | * Try our best to find an equivalent one. */ |
| 152 | return TTDPStringIDToOTTDStringIDMapping(str); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Finalise all string mappings. |
no test coverage detected