OpenTTD Source 20261112-master-gbcbec5e63f
newgrf_act0_industries.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "../stdafx.h"
11#include "../debug.h"
12#include "../newgrf_cargo.h"
13#include "../industry.h"
14#include "../industrytype.h"
15#include "../industry_map.h"
17#include "newgrf_bytereader.h"
18#include "newgrf_internal.h"
20
21#include "table/strings.h"
22
23#include "../safeguards.h"
24
27
35{
37
38 switch (prop) {
39 case 0x09:
40 case 0x0D:
41 case 0x0E:
42 case 0x10:
43 case 0x11:
44 case 0x12:
45 buf.ReadByte();
46 break;
47
48 case 0x0A:
49 case 0x0B:
50 case 0x0C:
51 case 0x0F:
52 buf.ReadWord();
53 break;
54
55 case 0x13:
56 buf.Skip(buf.ReadByte() * 2);
57 break;
58
59 default:
61 break;
62 }
63 return ret;
64}
65
74static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, ByteReader &buf)
75{
77
78 if (last > NUM_INDUSTRYTILES_PER_GRF) {
79 GrfMsg(Severity::Error, "IndustryTilesChangeInfo: Too many industry tiles loaded ({}), max ({}). Ignoring.", last, NUM_INDUSTRYTILES_PER_GRF);
81 }
82
83 /* Allocate industry tile specs if they haven't been allocated already. */
84 if (_cur_gps.grffile->indtspec.size() < last) _cur_gps.grffile->indtspec.resize(last);
85
86 for (uint id = first; id < last; ++id) {
87 auto &tsp = _cur_gps.grffile->indtspec[id];
88
89 if (prop != 0x08 && tsp == nullptr) {
91 if (cir > ret) ret = cir;
92 continue;
93 }
94
95 switch (prop) {
96 case 0x08: { // Substitute industry tile type
97 uint8_t subs_id = buf.ReadByte();
98 if (subs_id >= NEW_INDUSTRYTILEOFFSET) {
99 /* The substitute id must be one of the original industry tile. */
100 GrfMsg(Severity::Warning, "IndustryTilesChangeInfo: Attempt to use new industry tile {} as substitute industry tile for {}. Ignoring.", subs_id, id);
101 continue;
102 }
103
104 /* Allocate space for this industry. */
105 if (tsp == nullptr) {
106 tsp = std::make_unique<IndustryTileSpec>(_industry_tile_specs[subs_id]);
107
108 /* A copied tile should not have the animation infos copied too.
109 * The anim_state should be left untouched, though
110 * It is up to the author to animate them */
111 tsp->anim_production = INDUSTRYTILE_NOANIM;
112 tsp->anim_next = INDUSTRYTILE_NOANIM;
113
114 tsp->grf_prop.local_id = id;
115 tsp->grf_prop.subst_id = subs_id;
116 tsp->grf_prop.SetGRFFile(_cur_gps.grffile);
117 _industile_mngr.AddEntityID(id, _cur_gps.grffile->grfid, subs_id); // pre-reserve the tile slot
118 }
119 break;
120 }
121
122 case 0x09: { // Industry tile override
123 uint8_t ovrid = buf.ReadByte();
124
125 /* The industry being overridden must be an original industry. */
126 if (ovrid >= NEW_INDUSTRYTILEOFFSET) {
127 GrfMsg(Severity::Warning, "IndustryTilesChangeInfo: Attempt to override new industry tile {} with industry tile id {}. Ignoring.", ovrid, id);
128 continue;
129 }
130
131 _industile_mngr.Add(id, _cur_gps.grffile->grfid, ovrid);
132 break;
133 }
134
135 case 0x0A: // Tile acceptance
136 case 0x0B:
137 case 0x0C: {
138 uint16_t acctp = buf.ReadWord();
139 tsp->accepts_cargo[prop - 0x0A] = GetCargoTranslation(GB(acctp, 0, 8), _cur_gps.grffile);
140 tsp->acceptance[prop - 0x0A] = Clamp(GB(acctp, 8, 8), 0, 16);
141 tsp->accepts_cargo_label[prop - 0x0A] = CT_INVALID;
142 break;
143 }
144
145 case 0x0D: // Land shape flags
146 tsp->slopes_refused = Slope{buf.ReadByte()};
147 break;
148
149 case 0x0E: // Callback mask
150 tsp->callback_mask = IndustryTileCallbackMasks{buf.ReadByte()};
151 break;
152
153 case 0x0F: // Animation information
154 tsp->animation.frames = buf.ReadByte();
155 tsp->animation.status = AnimationStatus{buf.ReadByte()};
156 break;
157
158 case 0x10: // Animation speed
159 tsp->animation.speed = buf.ReadByte();
160 break;
161
162 case 0x11: // Triggers for callback 25
163 tsp->animation.triggers = IndustryAnimationTriggers{buf.ReadByte()};
164 break;
165
166 case 0x12: // Special flags
167 tsp->special_flags = IndustryTileSpecialFlags{buf.ReadByte()};
168 break;
169
170 case 0x13: { // variable length cargo acceptance
171 uint8_t num_cargoes = buf.ReadByte();
172 if (num_cargoes > std::size(tsp->acceptance)) {
173 GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
174 error->param_value[1] = prop;
176 }
177 for (uint i = 0; i < std::size(tsp->acceptance); i++) {
178 if (i < num_cargoes) {
179 tsp->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile);
180 /* Tile acceptance can be negative to counteract the IndustryTileSpecialFlag::AcceptsAllCargo flag */
181 tsp->acceptance[i] = static_cast<int8_t>(buf.ReadByte());
182 } else {
183 tsp->accepts_cargo[i] = INVALID_CARGO;
184 tsp->acceptance[i] = 0;
185 }
186 if (i < std::size(tsp->accepts_cargo_label)) tsp->accepts_cargo_label[i] = CT_INVALID;
187 }
188 break;
189 }
190
191 case 0x14: // Badge list
193 break;
194
195 default:
197 break;
198 }
199 }
200
201 return ret;
202}
203
211{
213
214 switch (prop) {
215 case 0x09:
216 case 0x0B:
217 case 0x0F:
218 case 0x12:
219 case 0x13:
220 case 0x14:
221 case 0x17:
222 case 0x18:
223 case 0x19:
224 case 0x21:
225 case 0x22:
226 buf.ReadByte();
227 break;
228
229 case 0x0C:
230 case 0x0D:
231 case 0x0E:
232 case 0x10: // INDUSTRY_ORIGINAL_NUM_OUTPUTS bytes
233 case 0x1B:
234 case 0x1F:
235 case 0x24:
236 buf.ReadWord();
237 break;
238
239 case 0x11: // INDUSTRY_ORIGINAL_NUM_INPUTS bytes + 1
240 case 0x1A:
241 case 0x1C:
242 case 0x1D:
243 case 0x1E:
244 case 0x20:
245 case 0x23:
246 buf.ReadDWord();
247 break;
248
249 case 0x0A: {
250 uint8_t num_table = buf.ReadByte();
251 for (uint8_t j = 0; j < num_table; j++) {
252 for (uint k = 0;; k++) {
253 uint8_t x = buf.ReadByte();
254 if (x == 0xFE && k == 0) {
255 buf.ReadByte();
256 buf.ReadByte();
257 break;
258 }
259
260 uint8_t y = buf.ReadByte();
261 if (x == 0 && y == 0x80) break;
262
263 uint8_t gfx = buf.ReadByte();
264 if (gfx == 0xFE) buf.ReadWord();
265 }
266 }
267 break;
268 }
269
270 case 0x16:
271 for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_INPUTS; j++) buf.ReadByte();
272 break;
273
274 case 0x15:
275 case 0x25:
276 case 0x26:
277 case 0x27:
278 buf.Skip(buf.ReadByte());
279 break;
280
281 case 0x28: {
282 int num_inputs = buf.ReadByte();
283 int num_outputs = buf.ReadByte();
284 buf.Skip(num_inputs * num_outputs * 2);
285 break;
286 }
287
288 case 0x29: // Badge list
289 SkipBadgeList(buf);
290 break;
291
292 default:
294 break;
295 }
296 return ret;
297}
298
305{
306 const size_t size = layout.size();
307 if (size == 0) return false;
308
309 for (size_t i = 0; i < size - 1; i++) {
310 for (size_t j = i + 1; j < size; j++) {
311 if (layout[i].ti.x == layout[j].ti.x &&
312 layout[i].ti.y == layout[j].ti.y) {
313 return false;
314 }
315 }
316 }
317
318 bool have_regular_tile = false;
319 for (const auto &tilelayout : layout) {
320 if (tilelayout.gfx != GFX_WATERTILE_SPECIALCHECK) {
321 have_regular_tile = true;
322 break;
323 }
324 }
325
326 return have_regular_tile;
327}
328
337static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, ByteReader &buf)
338{
340
341 if (last > NUM_INDUSTRYTYPES_PER_GRF) {
342 GrfMsg(Severity::Error, "IndustriesChangeInfo: Too many industries loaded ({}), max ({}). Ignoring.", last, NUM_INDUSTRYTYPES_PER_GRF);
344 }
345
346 /* Allocate industry specs if they haven't been allocated already. */
347 if (_cur_gps.grffile->industryspec.size() < last) _cur_gps.grffile->industryspec.resize(last);
348
349 for (uint id = first; id < last; ++id) {
350 auto &indsp = _cur_gps.grffile->industryspec[id];
351
352 if (prop != 0x08 && indsp == nullptr) {
354 if (cir > ret) ret = cir;
355 continue;
356 }
357
358 switch (prop) {
359 case 0x08: { // Substitute industry type
360 uint8_t subs_id = buf.ReadByte();
361 if (subs_id == 0xFF) {
362 /* Instead of defining a new industry, a substitute industry id
363 * of 0xFF disables the old industry with the current id. */
364 if (id < NEW_INDUSTRYOFFSET) _industry_specs[id].enabled = false;
365 continue;
366 } else if (subs_id >= NEW_INDUSTRYOFFSET) {
367 /* The substitute id must be one of the original industry. */
368 GrfMsg(Severity::Warning, "_industry_specs: Attempt to use new industry {} as substitute industry for {}. Ignoring.", subs_id, id);
369 continue;
370 }
371
372 /* Allocate space for this industry.
373 * Only need to do it once. If ever it is called again, it should not
374 * do anything */
375 if (indsp == nullptr) {
376 indsp = std::make_unique<IndustrySpec>(_origin_industry_specs[subs_id]);
377
378 indsp->enabled = true;
379 indsp->grf_prop.local_id = id;
380 indsp->grf_prop.subst_id = subs_id;
381 indsp->grf_prop.SetGRFFile(_cur_gps.grffile);
382 /* If the grf industry needs to check its surrounding upon creation, it should
383 * rely on callbacks, not on the original placement functions */
384 indsp->check_proc = IndustryCheck::None;
385 }
386 break;
387 }
388
389 case 0x09: { // Industry type override
390 uint8_t ovrid = buf.ReadByte();
391
392 /* The industry being overridden must be an original industry. */
393 if (ovrid >= NEW_INDUSTRYOFFSET) {
394 GrfMsg(Severity::Warning, "IndustriesChangeInfo: Attempt to override new industry {} with industry id {}. Ignoring.", ovrid, id);
395 continue;
396 }
397 indsp->grf_prop.override_id = ovrid;
398 _industry_mngr.Add(id, _cur_gps.grffile->grfid, ovrid);
399 break;
400 }
401
402 case 0x0A: { // Set industry layout(s)
403 uint8_t num_layouts = buf.ReadByte();
404 size_t definition_size = buf.ReadDWord();
405 size_t definition_end = definition_size + buf.GetBytesRead();
406
407 std::vector<IndustryTileLayout> layouts;
408 layouts.reserve(num_layouts);
409
410 IndustryTileLayout layout;
411
412 for (uint8_t j = 0; j < num_layouts; j++) {
413 bool invalid_layout = false;
414 layout.clear();
415
416 for (uint k = 0;; k++) {
417 if (definition_end < buf.GetBytesRead()) {
418 GrfMsg(Severity::Notice, "IndustriesChangeInfo: Incorrect size for industry tile layout definition for industry {}.", id);
419 /* Avoid warning twice */
420 definition_end = SIZE_MAX;
421 }
422
423 IndustryTileLayoutTile &it = layout.emplace_back();
424
425 it.ti.x = buf.ReadByte(); // Offsets from northernmost tile
426
427 if (it.ti.x == 0xFE && k == 0) {
428 /* This means we have to borrow the layout from an old industry */
429 IndustryType type = buf.ReadByte();
430 uint8_t laynbr = buf.ReadByte();
431
432 if (type >= lengthof(_origin_industry_specs)) {
433 GrfMsg(Severity::Error, "IndustriesChangeInfo: Invalid original industry number for layout import, industry {}", id);
434 DisableGrf(STR_NEWGRF_ERROR_INVALID_ID);
436 }
437 if (laynbr >= _origin_industry_specs[type].layouts.size()) {
438 GrfMsg(Severity::Error, "IndustriesChangeInfo: Invalid original industry layout index for layout import, industry {}", id);
439 DisableGrf(STR_NEWGRF_ERROR_INVALID_ID);
441 }
442 layout = _origin_industry_specs[type].layouts[laynbr];
443 break;
444 }
445
446 it.ti.y = buf.ReadByte(); // Or table definition finalisation
447
448 if (it.ti.x == 0 && it.ti.y == 0x80) {
449 /* Terminator, remove and finish up */
450 layout.pop_back();
451 break;
452 }
453
454 it.gfx = buf.ReadByte();
455
456 if (it.gfx == 0xFE) {
457 /* Use a new tile from this GRF */
458 int local_tile_id = buf.ReadWord();
459
460 /* Read the ID from the _industile_mngr. */
461 int tempid = _industile_mngr.GetID(local_tile_id, _cur_gps.grffile->grfid);
462
463 if (tempid == INVALID_INDUSTRYTILE) {
464 GrfMsg(Severity::Warning, "IndustriesChangeInfo: Attempt to use industry tile {} with industry id {}, not yet defined. Ignoring.", local_tile_id, id);
465 invalid_layout = true;
466 } else {
467 /* Declared as been valid, can be used */
468 it.gfx = tempid;
469 }
470 } else if (it.gfx == 0xFF) {
472 it.ti.x = (int8_t)GB(it.ti.x, 0, 8);
473 it.ti.y = (int8_t)GB(it.ti.y, 0, 8);
474
475 /* When there were only 256x256 maps, TileIndex was a uint16_t and
476 * it.ti was just a TileIndexDiff that was added to it.
477 * As such negative "x" values were shifted into the "y" position.
478 * x = -1, y = 1 -> x = 255, y = 0
479 * Since GRF version 8 the position is interpreted as pair of independent int8.
480 * For GRF version < 8 we need to emulate the old shifting behaviour.
481 */
482 if (_cur_gps.grffile->grf_version < 8 && it.ti.x < 0) it.ti.y += 1;
483 } else if (it.gfx >= NEW_INDUSTRYTILEOFFSET) {
484 GrfMsg(Severity::Warning, "IndustriesChangeInfo: Attempt to use invalid industry tile {} with industry id {}. Ignoring.", it.gfx, id);
485 invalid_layout = true;
486 }
487 }
488
489 if (invalid_layout) continue;
490
491 if (!ValidateIndustryLayout(layout)) {
492 /* The industry layout was not valid, so skip this one. */
493 GrfMsg(Severity::Error, "IndustriesChangeInfo: Invalid industry layout for industry id {}. Ignoring", id);
494 } else {
495 layouts.push_back(layout);
496 }
497 }
498
499 /* Install final layout construction in the industry spec */
500 indsp->layouts = std::move(layouts);
501 break;
502 }
503
504 case 0x0B: // Industry production flags
505 indsp->life_type = IndustryLifeTypes{buf.ReadByte()};
506 break;
507
508 case 0x0C: // Industry closure message
509 AddStringForMapping(GRFStringID{buf.ReadWord()}, &indsp->closure_text);
510 break;
511
512 case 0x0D: // Production increase message
513 AddStringForMapping(GRFStringID{buf.ReadWord()}, &indsp->production_up_text);
514 break;
515
516 case 0x0E: // Production decrease message
517 AddStringForMapping(GRFStringID{buf.ReadWord()}, &indsp->production_down_text);
518 break;
519
520 case 0x0F: // Fund cost multiplier
521 indsp->cost_multiplier = buf.ReadByte();
522 break;
523
524 case 0x10: // Production cargo types
525 for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_OUTPUTS; j++) {
526 indsp->produced_cargo[j] = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile);
527 indsp->produced_cargo_label[j] = CT_INVALID;
528 }
529 break;
530
531 case 0x11: // Acceptance cargo types
532 for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_INPUTS; j++) {
533 indsp->accepts_cargo[j] = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile);
534 indsp->accepts_cargo_label[j] = CT_INVALID;
535 }
536 buf.ReadByte(); // Unused, eat it up
537 break;
538
539 case 0x12: // Production multipliers
540 case 0x13:
541 indsp->production_rate[prop - 0x12] = buf.ReadByte();
542 break;
543
544 case 0x14: // Minimal amount of cargo distributed
545 indsp->minimal_cargo = buf.ReadByte();
546 break;
547
548 case 0x15: { // Random sound effects
549 uint8_t num_sounds = buf.ReadByte();
550
551 std::vector<uint8_t> sounds;
552 sounds.reserve(num_sounds);
553 for (uint8_t j = 0; j < num_sounds; ++j) {
554 sounds.push_back(buf.ReadByte());
555 }
556
557 indsp->random_sounds = std::move(sounds);
558 break;
559 }
560
561 case 0x16: // Conflicting industry types
562 for (uint8_t j = 0; j < 3; j++) indsp->conflicting[j] = buf.ReadByte();
563 break;
564
565 case 0x17: // Probability in random game
566 indsp->appear_creation[to_underlying(_settings_game.game_creation.landscape)] = buf.ReadByte();
567 break;
568
569 case 0x18: // Probability during gameplay
570 indsp->appear_ingame[to_underlying(_settings_game.game_creation.landscape)] = buf.ReadByte();
571 break;
572
573 case 0x19: // Map colour
574 indsp->map_colour = PixelColour{buf.ReadByte()};
575 break;
576
577 case 0x1A: // Special industry flags to define special behavior
578 indsp->behaviour = IndustryBehaviours{buf.ReadDWord()};
579 break;
580
581 case 0x1B: // New industry text ID
582 AddStringForMapping(GRFStringID{buf.ReadWord()}, &indsp->new_industry_text);
583 break;
584
585 case 0x1C: // Input cargo multipliers for the three input cargo types
586 case 0x1D:
587 case 0x1E: {
588 uint32_t multiples = buf.ReadDWord();
589 indsp->input_cargo_multiplier[prop - 0x1C][0] = GB(multiples, 0, 16);
590 indsp->input_cargo_multiplier[prop - 0x1C][1] = GB(multiples, 16, 16);
591 break;
592 }
593
594 case 0x1F: // Industry name
595 AddStringForMapping(GRFStringID{buf.ReadWord()}, &indsp->name);
596 break;
597
598 case 0x20: // Prospecting success chance
599 indsp->prospecting_chance = buf.ReadDWord();
600 break;
601
602 case 0x21: // Callback mask
603 case 0x22: { // Callback additional mask
604 auto mask = indsp->callback_mask.base();
605 SB(mask, (prop - 0x21) * 8, 8, buf.ReadByte());
606 indsp->callback_mask = IndustryCallbackMasks{mask};
607 break;
608 }
609
610 case 0x23: // removal cost multiplier
611 indsp->removal_cost_multiplier = buf.ReadDWord();
612 break;
613
614 case 0x24: { // name for nearby station
615 GRFStringID str{buf.ReadWord()};
616 if (str == 0) {
617 indsp->station_name = STR_NULL;
618 } else {
619 AddStringForMapping(str, &indsp->station_name);
620 }
621 break;
622 }
623
624 case 0x25: { // variable length produced cargoes
625 uint8_t num_cargoes = buf.ReadByte();
626 if (num_cargoes > std::size(indsp->produced_cargo)) {
627 GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
628 error->param_value[1] = prop;
630 }
631 for (size_t i = 0; i < std::size(indsp->produced_cargo); i++) {
632 if (i < num_cargoes) {
633 CargoType cargo = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile);
634 indsp->produced_cargo[i] = cargo;
635 } else {
636 indsp->produced_cargo[i] = INVALID_CARGO;
637 }
638 if (i < std::size(indsp->produced_cargo_label)) indsp->produced_cargo_label[i] = CT_INVALID;
639 }
640 break;
641 }
642
643 case 0x26: { // variable length accepted cargoes
644 uint8_t num_cargoes = buf.ReadByte();
645 if (num_cargoes > std::size(indsp->accepts_cargo)) {
646 GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
647 error->param_value[1] = prop;
649 }
650 for (size_t i = 0; i < std::size(indsp->accepts_cargo); i++) {
651 if (i < num_cargoes) {
652 CargoType cargo = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile);
653 indsp->accepts_cargo[i] = cargo;
654 } else {
655 indsp->accepts_cargo[i] = INVALID_CARGO;
656 }
657 if (i < std::size(indsp->accepts_cargo_label)) indsp->accepts_cargo_label[i] = CT_INVALID;
658 }
659 break;
660 }
661
662 case 0x27: { // variable length production rates
663 uint8_t num_cargoes = buf.ReadByte();
664 if (num_cargoes > lengthof(indsp->production_rate)) {
665 GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
666 error->param_value[1] = prop;
668 }
669 for (uint i = 0; i < lengthof(indsp->production_rate); i++) {
670 if (i < num_cargoes) {
671 indsp->production_rate[i] = buf.ReadByte();
672 } else {
673 indsp->production_rate[i] = 0;
674 }
675 }
676 break;
677 }
678
679 case 0x28: { // variable size input/output production multiplier table
680 uint8_t num_inputs = buf.ReadByte();
681 uint8_t num_outputs = buf.ReadByte();
682 if (num_inputs > std::size(indsp->accepts_cargo) || num_outputs > std::size(indsp->produced_cargo)) {
683 GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
684 error->param_value[1] = prop;
686 }
687 for (size_t i = 0; i < std::size(indsp->accepts_cargo); i++) {
688 for (size_t j = 0; j < std::size(indsp->produced_cargo); j++) {
689 uint16_t mult = 0;
690 if (i < num_inputs && j < num_outputs) mult = buf.ReadWord();
691 indsp->input_cargo_multiplier[i][j] = mult;
692 }
693 }
694 break;
695 }
696
697 case 0x29: // Badge list
698 indsp->badges = ReadBadgeList(buf, GrfSpecFeature::Industries);
699 break;
700
701 default:
703 break;
704 }
705 }
706
707 return ret;
708}
709
713template <> ChangeInfoResult GrfChangeInfoHandler<GrfSpecFeature::IndustryTiles>::Activation(uint first, uint last, int prop, ByteReader &buf) { return IndustrytilesChangeInfo(first, last, prop, buf); }
714
718template <> ChangeInfoResult GrfChangeInfoHandler<GrfSpecFeature::Industries>::Activation(uint first, uint last, int prop, ByteReader &buf) { return IndustriesChangeInfo(first, last, prop, buf); }
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
Definition cargo_type.h:74
static constexpr CargoType INVALID_CARGO
Invalid marker for cargoes.
Definition cargo_type.h:83
CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
Class to read from a NewGRF file.
uint32_t ReadDWord()
Read a single DWord (32 bits).
uint16_t ReadWord()
Read a single Word (16 bits).
size_t GetBytesRead() const
Get number of already read bytes.
uint8_t ReadByte()
Read a single byte (8 bits).
Functions related to debugging.
@ Warning
Warning, wrong but okay if you don't know.
Definition debug_type.h:17
@ Notice
Notice.
Definition debug_type.h:18
@ Error
Error, but we are recovering.
Definition debug_type.h:16
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
Definition enum_type.hpp:21
Base of all industries.
Accessors to map for industries.
static const IndustryGfx NEW_INDUSTRYTILEOFFSET
original number of tiles
static const IndustryGfx INDUSTRYTILE_NOANIM
Sentinel value to mark industry tiles as having no animation.
static const IndustryType NEW_INDUSTRYOFFSET
original number of industry types
static const int INDUSTRY_ORIGINAL_NUM_INPUTS
Original number of accepted cargo types.
static constexpr IndustryGfx GFX_WATERTILE_SPECIALCHECK
Sentinel marker in industry layout to perform a water tile check.
static const IndustryGfx NUM_INDUSTRYTILES_PER_GRF
Maximum number of industry tiles per NewGRF.
EnumBitSet< IndustryAnimationTrigger, uint8_t > IndustryAnimationTriggers
Bitset of IndustryAnimationTrigger elements.
static const IndustryGfx INVALID_INDUSTRYTILE
one above amount is considered invalid
static const int INDUSTRY_ORIGINAL_NUM_OUTPUTS
Original number of produced cargo types.
static const IndustryType NUM_INDUSTRYTYPES_PER_GRF
maximum number of industry types per NewGRF; limited to 128 because bit 7 has a special meaning in so...
Industry type specs.
EnumBitSet< IndustryLifeType, uint8_t > IndustryLifeTypes
Bitset of IndustryLifeType elements.
std::vector< IndustryTileLayoutTile > IndustryTileLayout
A complete tile layout for an industry is a list of tiles.
EnumBitSet< IndustryBehaviour, uint32_t > IndustryBehaviours
Bitset of IndustryBehaviour elements.
@ None
Always succeeds.
EnumBitSet< IndustryTileSpecialFlag, uint8_t > IndustryTileSpecialFlags
Bitset of IndustryTileSpecialFlag elements.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition math_func.hpp:79
GRFError * DisableGrf(StringID message, GRFConfig *config)
Disable a GRF.
Definition newgrf.cpp:139
@ IndustryTiles
Industry tiles feature.
Definition newgrf.h:91
@ Industries
Industries feature.
Definition newgrf.h:92
std::vector< BadgeID > ReadBadgeList(ByteReader &buf, GrfSpecFeature feature)
Read a list of badges.
void SkipBadgeList(ByteReader &buf)
Skip a list of badges.
const IndustrySpec _origin_industry_specs[NEW_INDUSTRYOFFSET]
Extern declaration for _origin_industry_specs in table/build_industry.h.
static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader &buf)
Ignore an industry property.
static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, ByteReader &buf)
Define properties for industries.
static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, ByteReader &buf)
Define properties for industry tiles.
static bool ValidateIndustryLayout(const IndustryTileLayout &layout)
Validate the industry layout; e.g.
static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader &buf)
Ignore an industry tile property.
AnimationStatus
Statuses of animation within NewGRFs.
NewGRF buffer reader definition.
EnumBitSet< IndustryTileCallbackMask, uint8_t > IndustryTileCallbackMasks
Bitset of IndustryTileCallbackMask elements.
EnumBitSet< IndustryCallbackMask, uint16_t > IndustryCallbackMasks
Bitset of IndustryCallbackMask elements.
CargoType GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
Translate a GRF-local cargo slot/bitnum into a CargoType.
Cargo support for NewGRFs.
Functions for NewGRF industries.
NewGRF internal processing state.
ChangeInfoResult
Possible return values for the GrfChangeInfoHandler functions.
@ Success
Variable was parsed and read.
@ Unhandled
Variable was parsed but unread.
@ Unknown
Variable is unknown.
@ Disabled
GRF was disabled due to error.
@ InvalidId
Attempt to modify an invalid ID.
void AddStringForMapping(GRFStringID source, std::function< void(StringID)> &&func)
Record a static StringID for getting translated later.
NewGRF string mapping definition.
StrongType::Typedef< uint32_t, struct GRFStringIDTag, StrongType::Compare, StrongType::Integer > GRFStringID
Type for GRF-internal string IDs.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
Slope
Enumeration for the slope-type.
Definition slope_type.h:53
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:261
Information about why GRF had problems during initialisation.
std::array< uint32_t, 2 > param_value
Values of GRF parameters to show for message and custom_message.
static ChangeInfoResult Reserve(uint first, uint last, int prop, ByteReader &buf)
Implementation of the GrfLoadingStage::Reserve stage of this feature.
static ChangeInfoResult Activation(uint first, uint last, int prop, ByteReader &buf)
Implementation of the GrfLoadingStage::Activation stage of this feature.
Defines the data structure for constructing industry.
Definition of one tile in an industry tile layout.
Colour for pixel/line drawing.
Definition gfx_type.h:307
int16_t x
The x value of the coordinate.
Definition map_type.h:32
int16_t y
The y value of the coordinate.
Definition map_type.h:33