12 #include "newgrf.h" |
12 #include "newgrf.h" |
13 #include "newgrf_callbacks.h" |
13 #include "newgrf_callbacks.h" |
14 #include "newgrf_spritegroup.h" |
14 #include "newgrf_spritegroup.h" |
15 #include "newgrf_industries.h" |
15 #include "newgrf_industries.h" |
16 #include "newgrf_commons.h" |
16 #include "newgrf_commons.h" |
|
17 #include "date.h" |
17 |
18 |
18 /* Since the industry IDs defined by the GRF file don't necessarily correlate |
19 /* Since the industry IDs defined by the GRF file don't necessarily correlate |
19 * to those used by the game, the IDs used for overriding old industries must be |
20 * to those used by the game, the IDs used for overriding old industries must be |
20 * translated when the idustry spec is set. */ |
21 * translated when the idustry spec is set. */ |
21 IndustryOverrideManager _industry_mngr(NEW_INDUSTRYOFFSET, NUM_INDUSTRYTYPES, INVALID_INDUSTRYTYPE); |
22 IndustryOverrideManager _industry_mngr(NEW_INDUSTRYOFFSET, NUM_INDUSTRYTYPES, INVALID_INDUSTRYTYPE); |
149 * format is rr(reserved) cc(count) dddd(manhattan distance of closest sister) |
150 * format is rr(reserved) cc(count) dddd(manhattan distance of closest sister) |
150 * A lot more should be done, since it has to check for local id, grf id etc... |
151 * A lot more should be done, since it has to check for local id, grf id etc... |
151 * let's just say it is a beginning ;) */ |
152 * let's just say it is a beginning ;) */ |
152 case 0x67: return GetIndustryTypeCount(industry->type) << 16 | 0; |
153 case 0x67: return GetIndustryTypeCount(industry->type) << 16 | 0; |
153 |
154 |
154 /* Industry founder information. |
|
155 * 0x10 if randomly created or from a map pre-newindustry. |
|
156 * Else, the company who funded it */ |
|
157 case 0xA7: return 0x10; |
|
158 |
|
159 case 0xB0: // Date when built since 1920 (in days) |
|
160 case 0xB3: // Construction type |
|
161 case 0xB4: break; // Date last cargo accepted since 1920 (in days) |
|
162 |
|
163 /* Industry structure access*/ |
155 /* Industry structure access*/ |
164 case 0x80: return industry->xy; |
156 case 0x80: return industry->xy; |
165 case 0x81: return GB(industry->xy, 8, 8); |
157 case 0x81: return GB(industry->xy, 8, 8); |
166 /* Pointer to the town the industry is associated with */ |
158 /* Pointer to the town the industry is associated with */ |
167 case 0x82: |
159 case 0x82: |
168 case 0x83: |
160 case 0x83: |
169 case 0x84: |
161 case 0x84: |
170 case 0x85: break; // not supported |
162 case 0x85: DEBUG(grf, 0, "NewGRFs shouldn't be doing pointer magic"); break; // not supported |
171 case 0x86: return industry->width; |
163 case 0x86: return industry->width; |
172 case 0x87: return industry->height;// xy dimensions |
164 case 0x87: return industry->height;// xy dimensions |
173 /* */ |
165 /* */ |
174 case 0x88: |
166 case 0x88: |
175 case 0x89: return indspec->produced_cargo[variable - 0x88]; |
167 case 0x89: return indspec->produced_cargo[variable - 0x88]; |
206 case 0xA3: return GB(industry->last_month_transported[0], 8, 8); |
198 case 0xA3: return GB(industry->last_month_transported[0], 8, 8); |
207 case 0xA4: return industry->last_month_transported[1]; |
199 case 0xA4: return industry->last_month_transported[1]; |
208 case 0xA5: return GB(industry->last_month_transported[0], 8, 8); |
200 case 0xA5: return GB(industry->last_month_transported[0], 8, 8); |
209 |
201 |
210 case 0xA6: return industry->type; |
202 case 0xA6: return industry->type; |
211 |
203 case 0xA7: return industry->founder; |
212 case 0xA8: return industry->random_color; |
204 case 0xA8: return industry->random_color; |
213 case 0xA9: return industry->last_prod_year; // capped? |
205 case 0xA9: return clamp(0, industry->last_prod_year - 1920, 255); |
214 case 0xAA: return industry->counter; |
206 case 0xAA: return industry->counter; |
215 case 0xAB: return GB(industry->counter, 8, 8); |
207 case 0xAB: return GB(industry->counter, 8, 8); |
216 case 0xAC: return industry->was_cargo_delivered; |
208 case 0xAC: return industry->was_cargo_delivered; |
|
209 |
|
210 case 0xB0: return clamp(0, industry->construction_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 65535); // Date when built since 1920 (in days) |
|
211 case 0xB3: return industry->construction_type; // Construction type |
|
212 case 0xB4: return clamp(0, industry->last_cargo_accepted_at - DAYS_TILL_ORIGINAL_BASE_YEAR, 65535); // Date last cargo accepted since 1920 (in days) |
217 } |
213 } |
218 |
214 |
219 DEBUG(grf, 1, "Unhandled industry property 0x%X", variable); |
215 DEBUG(grf, 1, "Unhandled industry property 0x%X", variable); |
220 |
216 |
221 *available = false; |
217 *available = false; |