OpenTTD

newgrf_commons.cpp
Go to the documentation of this file.
1 /* $Id: newgrf_commons.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 <http://www.gnu.org/licenses/>.
8 */
9
15 #include "stdafx.h"
16 #include "debug.h"
17 #include "landscape.h"
18 #include "house.h"
19 #include "industrytype.h"
20 #include "newgrf_config.h"
21 #include "clear_map.h"
22 #include "station_map.h"
23 #include "tree_map.h"
24 #include "tunnelbridge_map.h"
25 #include "newgrf_object.h"
26 #include "genworld.h"
27 #include "newgrf_spritegroup.h"
28 #include "newgrf_text.h"
29 #include "company_base.h"
30 #include "error.h"
31 #include "strings_func.h"
32
33 #include "table/strings.h"
34
35 #include "safeguards.h"
36
43 OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid)
44 {
45 max_offset = offset;
46 max_new_entities = maximum;
47 invalid_ID = invalid;
48
49 mapping_ID = CallocT<EntityIDMapping>(max_new_entities);
50 entity_overrides = MallocT<uint16>(max_offset);
51 for (size_t i = 0; i < max_offset; i++) entity_overrides[i] = invalid;
52 grfid_overrides = CallocT<uint32>(max_offset);
53 }
54
59 OverrideManagerBase::~OverrideManagerBase()
60 {
61 free(mapping_ID);
62 free(entity_overrides);
63 free(grfid_overrides);
64 }
65
74 void OverrideManagerBase::Add(uint8 local_id, uint32 grfid, uint entity_type)
75 {
76 assert(entity_type < max_offset);
77 /* An override can be set only once */
78 if (entity_overrides[entity_type] != invalid_ID) return;
79 entity_overrides[entity_type] = local_id;
80 grfid_overrides[entity_type] = grfid;
81 }
82
84 void OverrideManagerBase::ResetMapping()
85 {
86 memset(mapping_ID, 0, (max_new_entities - 1) * sizeof(EntityIDMapping));
87 }
88
90 void OverrideManagerBase::ResetOverride()
91 {
92 for (uint16 i = 0; i < max_offset; i++) {
93 entity_overrides[i] = invalid_ID;
94 grfid_overrides[i] = 0;
95 }
96 }
97
104 uint16 OverrideManagerBase::GetID(uint8 grf_local_id, uint32 grfid) const
105 {
106 const EntityIDMapping *map;
107
108 for (uint16 id = 0; id < max_new_entities; id++) {
109 map = &mapping_ID[id];
110 if (map->entity_id == grf_local_id && map->grfid == grfid) {
111 return id;
112 }
113 }
114
115 return invalid_ID;
116 }
117
125 uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id)
126 {
127 uint16 id = this->GetID(grf_local_id, grfid);
128 EntityIDMapping *map;
129
130 /* Look to see if this entity has already been added. This is done
131 * separately from the loop below in case a GRF has been deleted, and there
132 * are any gaps in the array.
133 */
134 if (id != invalid_ID) {
135 return id;
136 }
137
138 /* This entity hasn't been defined before, so give it an ID now. */
139 for (id = max_offset; id < max_new_entities; id++) {
140 map = &mapping_ID[id];
141
142 if (CheckValidNewID(id) && map->entity_id == 0 && map->grfid == 0) {
143 map->entity_id = grf_local_id;
144 map->grfid = grfid;
145 map->substitute_id = substitute_id;
146 return id;
147 }
148 }
149
150 return invalid_ID;
151 }
152
158 uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const
159 {
160 return mapping_ID[entity_id].grfid;
161 }
162
168 uint16 OverrideManagerBase::GetSubstituteID(uint16 entity_id) const
169 {
170 return mapping_ID[entity_id].substitute_id;
171 }
172
178 void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs)
179 {
180 HouseID house_id = this->AddEntityID(hs->grf_prop.local_id, hs->grf_prop.grffile->grfid, hs->grf_prop.subst_id);
181
182 if (house_id == invalid_ID) {
183 grfmsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring.");
184 return;
185 }
186
187 MemCpyT(HouseSpec::Get(house_id), hs);
188
189 /* Now add the overrides. */
190 for (int i = 0; i != max_offset; i++) {
191 HouseSpec *overridden_hs = HouseSpec::Get(i);
192
193 if (entity_overrides[i] != hs->grf_prop.local_id || grfid_overrides[i] != hs->grf_prop.grffile->grfid) continue;
194
195 overridden_hs->grf_prop.override = house_id;
196 entity_overrides[i] = invalid_ID;
197 grfid_overrides[i] = 0;
198 }
199 }
200
207 uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid) const
208 {
209 uint16 id = OverrideManagerBase::GetID(grf_local_id, grfid);
210 if (id != invalid_ID) return id;
211
212 /* No mapping found, try the overrides */
213 for (id = 0; id < max_offset; id++) {
214 if (entity_overrides[id] == grf_local_id && grfid_overrides[id] == grfid) return id;
215 }
216
217 return invalid_ID;
218 }
219
227 uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id)
228 {
229 /* This entity hasn't been defined before, so give it an ID now. */
230 for (uint16 id = 0; id < max_new_entities; id++) {
231 /* Skip overridden industries */
232 if (id < max_offset && entity_overrides[id] != invalid_ID) continue;
233
234 /* Get the real live industry */
235 const IndustrySpec *inds = GetIndustrySpec(id);
236
237 /* This industry must be one that is not available(enabled), mostly because of climate.
238 * And it must not already be used by a grf (grffile == NULL).
239 * So reserve this slot here, as it is the chosen one */
240 if (!inds->enabled && inds->grf_prop.grffile == NULL) {
241 EntityIDMapping *map = &mapping_ID[id];
242
243 if (map->entity_id == 0 && map->grfid == 0) {
244 /* winning slot, mark it as been used */
245 map->entity_id = grf_local_id;
246 map->grfid = grfid;
247 map->substitute_id = substitute_id;
248 return id;
249 }
250 }
251 }
252
253 return invalid_ID;
254 }
255
262 void IndustryOverrideManager::SetEntitySpec(IndustrySpec *inds)
263 {
264 /* First step : We need to find if this industry is already specified in the savegame data. */
265 IndustryType ind_id = this->GetID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid);
266
267 if (ind_id == invalid_ID) {
268 /* Not found.
269 * Or it has already been overridden, so you've lost your place old boy.
270 * Or it is a simple substitute.
271 * We need to find a free available slot */
272 ind_id = this->AddEntityID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid, inds->grf_prop.subst_id);
273 inds->grf_prop.override = invalid_ID; // make sure it will not be detected as overridden
274 }
275
276 if (ind_id == invalid_ID) {
277 grfmsg(1, "Industry.SetEntitySpec: Too many industries allocated. Ignoring.");
278 return;
279 }
280
281 /* Now that we know we can use the given id, copy the spec to its final destination... */
282 memcpy(&_industry_specs[ind_id], inds, sizeof(*inds));
283 /* ... and mark it as usable*/
284 _industry_specs[ind_id].enabled = true;
285 }
286
287 void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its)
288 {
289 IndustryGfx indt_id = this->AddEntityID(its->grf_prop.local_id, its->grf_prop.grffile->grfid, its->grf_prop.subst_id);
290
291 if (indt_id == invalid_ID) {
292 grfmsg(1, "IndustryTile.SetEntitySpec: Too many industry tiles allocated. Ignoring.");
293 return;
294 }
295
296 memcpy(&_industry_tile_specs[indt_id], its, sizeof(*its));
297
298 /* Now add the overrides. */
299 for (int i = 0; i < max_offset; i++) {
300 IndustryTileSpec *overridden_its = &_industry_tile_specs[i];
301
302 if (entity_overrides[i] != its->grf_prop.local_id || grfid_overrides[i] != its->grf_prop.grffile->grfid) continue;
303
304 overridden_its->grf_prop.override = indt_id;
305 overridden_its->enabled = false;
306 entity_overrides[i] = invalid_ID;
307 grfid_overrides[i] = 0;
308 }
309 }
310
317 void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec)
318 {
319 /* First step : We need to find if this object is already specified in the savegame data. */
320 ObjectType type = this->GetID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid);
321
322 if (type == invalid_ID) {
323 /* Not found.
324 * Or it has already been overridden, so you've lost your place old boy.
325 * Or it is a simple substitute.
326 * We need to find a free available slot */
327 type = this->AddEntityID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid, OBJECT_TRANSMITTER);
328 }
329
330 if (type == invalid_ID) {
331 grfmsg(1, "Object.SetEntitySpec: Too many objects allocated. Ignoring.");
332 return;
333 }
334
335 extern ObjectSpec _object_specs[NUM_OBJECTS];
336
337 /* Now that we know we can use the given id, copy the spec to its final destination. */
338 memcpy(&_object_specs[type], spec, sizeof(*spec));
339 ObjectClass::Assign(&_object_specs[type]);
340 }
341
350 uint32 GetTerrainType(TileIndex tile, TileContext context)
351 {
352 switch (_settings_game.game_creation.landscape) {
353 case LT_TROPIC: return GetTropicZone(tile);
354 case LT_ARCTIC: {
355 bool has_snow;
356 switch (GetTileType(tile)) {
357 case MP_CLEAR:
358 /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
359 if (_generating_world) goto genworld;
360 has_snow = IsSnowTile(tile) && GetClearDensity(tile) >= 2;
361 break;
362
363 case MP_RAILWAY: {
364 /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
365 if (_generating_world) goto genworld; // we do not care about foundations here
366 RailGroundType ground = GetRailGroundType(tile);
367 has_snow = (ground == RAIL_GROUND_ICE_DESERT || (context == TCX_UPPER_HALFTILE && ground == RAIL_GROUND_HALF_SNOW));
368 break;
369 }
370
371 case MP_ROAD:
372 /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
373 if (_generating_world) goto genworld; // we do not care about foundations here
374 has_snow = IsOnSnow(tile);
375 break;
376
377 case MP_TREES: {
378 /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
379 if (_generating_world) goto genworld;
380 TreeGround ground = GetTreeGround(tile);
381 has_snow = (ground == TREE_GROUND_SNOW_DESERT || ground == TREE_GROUND_ROUGH_SNOW) && GetTreeDensity(tile) >= 2;
382 break;
383 }
384
385 case MP_TUNNELBRIDGE:
386 if (context == TCX_ON_BRIDGE) {
387 has_snow = (GetBridgeHeight(tile) > GetSnowLine());
388 } else {
389 /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
390 if (_generating_world) goto genworld; // we do not care about foundations here
391 has_snow = HasTunnelBridgeSnowOrDesert(tile);
392 }
393 break;
394
395 case MP_STATION:
396 case MP_HOUSE:
397 case MP_INDUSTRY:
398 case MP_OBJECT:
399 /* These tiles usually have a levelling foundation. So use max Z */
400 has_snow = (GetTileMaxZ(tile) > GetSnowLine());
401 break;
402
403 case MP_VOID:
404 case MP_WATER:
405 genworld:
406 has_snow = (GetTileZ(tile) > GetSnowLine());
407 break;
408
409 default: NOT_REACHED();
410 }
411 return has_snow ? 4 : 0;
412 }
413 default: return 0;
414 }
415 }
416
425 TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis)
426 {
427 int8 x = GB(parameter, 0, 4);
428 int8 y = GB(parameter, 4, 4);
429
430 if (signed_offsets && x >= 8) x -= 16;
431 if (signed_offsets && y >= 8) y -= 16;
432
433 /* Swap width and height depending on axis for railway stations */
434 if (axis == INVALID_AXIS && HasStationTileRail(tile)) axis = GetRailStationAxis(tile);
435 if (axis == AXIS_Y) Swap(x, y);
436
437 /* Make sure we never roam outside of the map, better wrap in that case */
438 return TILE_MASK(tile + TileDiffXY(x, y));
439 }
440
448 uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
449 {
450 TileType tile_type = GetTileType(tile);
451
452 /* Fake tile type for trees on shore */
453 if (IsTileType(tile, MP_TREES) && GetTreeGround(tile) == TREE_GROUND_SHORE) tile_type = MP_WATER;
454
455 int z;
456 Slope tileh = GetTilePixelSlope(tile, &z);
457 /* Return 0 if the tile is a land tile */
458 byte terrain_type = (HasTileWaterClass(tile) ? (GetWaterClass(tile) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
459 if (grf_version8) z /= TILE_HEIGHT;
460 return tile_type << 24 | Clamp(z, 0, 0xFF) << 16 | terrain_type << 8 | tileh;
461 }
462
469 uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
470 {
471 if (l == NULL && Company::IsValidID(owner)) l = &Company::Get(owner)->livery[LS_DEFAULT];
472 return owner | (Company::IsValidAiID(owner) ? 0x10000 : 0) | (l != NULL ? (l->colour1 << 24) | (l->colour2 << 28) : 0);
473 }
474
482 CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error)
483 {
484 CommandCost res;
485
486 if (cb_res < 0x400) {
487 res = CommandCost(GetGRFStringID(grffile->grfid, 0xD000 + cb_res));
488 } else {
489 switch (cb_res) {
490 case 0x400: return res; // No error.
491
492 default: // unknown reason -> default error
493 case 0x401: res = CommandCost(default_error); break;
494
495 case 0x402: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST); break;
496 case 0x403: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT); break;
497 case 0x404: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_ABOVE_SNOW_LINE); break;
498 case 0x405: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_BELOW_SNOW_LINE); break;
499 case 0x406: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_SEA); break;
500 case 0x407: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_CANAL); break;
501 case 0x408: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_RIVER); break;
502 }
503 }
504
505 /* Copy some parameters from the registers to the error message text ref. stack */
506 res.UseTextRefStack(grffile, 4);
507
508 return res;
509 }
510
518 void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
519 {
520 GRFConfig *grfconfig = GetGRFConfig(grfid);
521
522 if (!HasBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT)) {
523 SetBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT);
524 SetDParamStr(0, grfconfig->GetName());
525 SetDParam(1, cbid);
526 SetDParam(2, cb_res);
527 ShowErrorMessage(STR_NEWGRF_BUGGY, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, WL_CRITICAL);
528 }
529
530 /* debug output */
531 char buffer[512];
532
533 SetDParamStr(0, grfconfig->GetName());
534 GetString(buffer, STR_NEWGRF_BUGGY, lastof(buffer));
535 DEBUG(grf, 0, "%s", buffer + 3);
536
537 SetDParam(1, cbid);
538 SetDParam(2, cb_res);
539 GetString(buffer, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, lastof(buffer));
540 DEBUG(grf, 0, "%s", buffer + 3);
541 }
542
552 bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
553 {
554 assert(cb_res != CALLBACK_FAILED); // We do not know what to return
555
556 if (grffile->grf_version < 8) return cb_res != 0;
557
558 if (cb_res > 1) ErrorUnknownCallbackResult(grffile->grfid, cbid, cb_res);
559 return cb_res != 0;
560 }
561
571 bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
572 {
573 assert(cb_res != CALLBACK_FAILED); // We do not know what to return
574
575 if (grffile->grf_version < 8) return GB(cb_res, 0, 8) != 0;
576
577 if (cb_res > 1) ErrorUnknownCallbackResult(grffile->grfid, cbid, cb_res);
578 return cb_res != 0;
579 }
580
581
582 /* static */ SmallVector<DrawTileSeqStruct, 8> NewGRFSpriteLayout::result_seq;
583
588 void NewGRFSpriteLayout::Clone(const DrawTileSeqStruct *source)
589 {
590 assert(this->seq == NULL);
591 assert(source != NULL);
592
593 size_t count = 1; // 1 for the terminator
594 const DrawTileSeqStruct *element;
595 foreach_draw_tile_seq(element, source) count++;
596
597 DrawTileSeqStruct *sprites = MallocT<DrawTileSeqStruct>(count);
598 MemCpyT(sprites, source, count);
599 this->seq = sprites;
600 }
601
606 void NewGRFSpriteLayout::Clone(const NewGRFSpriteLayout *source)
607 {
608 this->Clone((const DrawTileSprites*)source);
609
610 if (source->registers != NULL) {
611 size_t count = 1; // 1 for the ground sprite
612 const DrawTileSeqStruct *element;
613 foreach_draw_tile_seq(element, source->seq) count++;
614
615 TileLayoutRegisters *regs = MallocT<TileLayoutRegisters>(count);
616 MemCpyT(regs, source->registers, count);
617 this->registers = regs;
618 }
619 }
620
621
626 void NewGRFSpriteLayout::Allocate(uint num_sprites)
627 {
628 assert(this->seq == NULL);
629
630 DrawTileSeqStruct *sprites = CallocT<DrawTileSeqStruct>(num_sprites + 1);
631 sprites[num_sprites].MakeTerminator();
632 this->seq = sprites;
633 }
634
638 void NewGRFSpriteLayout::AllocateRegisters()
639 {
640 assert(this->seq != NULL);
641 assert(this->registers == NULL);
642
643 size_t count = 1; // 1 for the ground sprite
644 const DrawTileSeqStruct *element;
645 foreach_draw_tile_seq(element, this->seq) count++;
646
647 this->registers = CallocT<TileLayoutRegisters>(count);
648 }
649
662 uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const
663 {
664 result_seq.Clear();
665 uint32 var10_values = 0;
666
667 /* Create a copy of the spritelayout, so we can modify some values.
668 * Also include the groundsprite into the sequence for easier processing. */
669 DrawTileSeqStruct *result = result_seq.Append();
670 result->image = ground;
671 result->delta_x = 0;
672 result->delta_y = 0;
673 result->delta_z = (int8)0x80;
674
675 const DrawTileSeqStruct *dtss;
676 foreach_draw_tile_seq(dtss, this->seq) {
677 *result_seq.Append() = *dtss;
678 }
679 result_seq.Append()->MakeTerminator();
680
681 /* Determine the var10 values the action-1-2-3 chains needs to be resolved for,
682 * and apply the default sprite offsets (unless disabled). */
683 const TileLayoutRegisters *regs = this->registers;
684 bool ground = true;
685 foreach_draw_tile_seq(result, result_seq.Begin()) {
686 TileLayoutFlags flags = TLF_NOTHING;
687 if (regs != NULL) flags = regs->flags;
688
689 /* Record var10 value for the sprite */
690 if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) {
691 uint8 var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0);
692 SetBit(var10_values, var10);
693 }
694
695 /* Add default sprite offset, unless there is a custom one */
696 if (!(flags & TLF_SPRITE)) {
697 if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
698 result->image.sprite += ground ? newgrf_ground_offset : newgrf_offset;
699 if (constr_stage > 0 && regs != NULL) result->image.sprite += GetConstructionStageOffset(constr_stage, regs->max_sprite_offset);
700 } else {
701 result->image.sprite += orig_offset;
702 }
703 }
704
705 /* Record var10 value for the palette */
706 if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_PALETTE_REG_FLAGS)) {
707 uint8 var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0);
708 SetBit(var10_values, var10);
709 }
710
711 /* Add default palette offset, unless there is a custom one */
712 if (!(flags & TLF_PALETTE)) {
713 if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
714 result->image.sprite += ground ? newgrf_ground_offset : newgrf_offset;
715 if (constr_stage > 0 && regs != NULL) result->image.sprite += GetConstructionStageOffset(constr_stage, regs->max_palette_offset);
716 }
717 }
718
719 ground = false;
720 if (regs != NULL) regs++;
721 }
722
723 return var10_values;
724 }
725
734 void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const
735 {
736 DrawTileSeqStruct *result;
737 const TileLayoutRegisters *regs = this->registers;
738 bool ground = true;
739 foreach_draw_tile_seq(result, result_seq.Begin()) {
740 TileLayoutFlags flags = TLF_NOTHING;
741 if (regs != NULL) flags = regs->flags;
742
743 /* Is the sprite or bounding box affected by an action-1-2-3 chain? */
744 if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) {
745 /* Does the var10 value apply to this sprite? */
746 uint8 var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0);
747 if (var10 == resolved_var10) {
748 /* Apply registers */
749 if ((flags & TLF_DODRAW) && GetRegister(regs->dodraw) == 0) {
750 result->image.sprite = 0;
751 } else {
752 if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) result->image.sprite += resolved_sprite;
753 if (flags & TLF_SPRITE) {
754 int16 offset = (int16)GetRegister(regs->sprite); // mask to 16 bits to avoid trouble
755 if (!HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_sprite_offset)) {
756 result->image.sprite += offset;
757 } else {
758 result->image.sprite = SPR_IMG_QUERY;
759 }
760 }
761
762 if (result->IsParentSprite()) {
763 if (flags & TLF_BB_XY_OFFSET) {
764 result->delta_x += (int32)GetRegister(regs->delta.parent[0]);
765 result->delta_y += (int32)GetRegister(regs->delta.parent[1]);
766 }
767 if (flags & TLF_BB_Z_OFFSET) result->delta_z += (int32)GetRegister(regs->delta.parent[2]);
768 } else {
769 if (flags & TLF_CHILD_X_OFFSET) result->delta_x += (int32)GetRegister(regs->delta.child[0]);
770 if (flags & TLF_CHILD_Y_OFFSET) result->delta_y += (int32)GetRegister(regs->delta.child[1]);
771 }
772 }
773 }
774 }
775
776 /* Is the palette affected by an action-1-2-3 chain? */
777 if (result->image.sprite != 0 && (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_PALETTE_REG_FLAGS))) {
778 /* Does the var10 value apply to this sprite? */
779 uint8 var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0);
780 if (var10 == resolved_var10) {
781 /* Apply registers */
782 if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) result->image.pal += resolved_sprite;
783 if (flags & TLF_PALETTE) {
784 int16 offset = (int16)GetRegister(regs->palette); // mask to 16 bits to avoid trouble
785 if (!HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_palette_offset)) {
786 result->image.pal += offset;
787 } else {
788 result->image.sprite = SPR_IMG_QUERY;
789 result->image.pal = PAL_NONE;
790 }
791 }
792 }
793 }
794
795 ground = false;
796 if (regs != NULL) regs++;
797 }
798 }
strings_func.h
Functions related to OTTD&#39;s strings.
GetTileType
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:89
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:277
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
ObjectOverrideManager::SetEntitySpec
void SetEntitySpec(ObjectSpec *spec)
Method to install the new object data in its proper slot The slot assignment is internal of this meth...
Definition: newgrf_commons.cpp:317
IndustrySpec::enabled
bool enabled
entity still available (by default true).newgrf can disable it, though
Definition: industrytype.h:135
GetTropicZone
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
Definition: tile_map.h:231
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:406
TLF_CHILD_Y_OFFSET
Add signed offset to child sprite Y positions from register TileLayoutRegisters::delta.child[1].
Definition: newgrf_commons.h:47
NUM_OBJECTS
static const ObjectType NUM_OBJECTS
Number of supported objects overall.
Definition: object_type.h:27
OBJECT_TRANSMITTER
static const ObjectType OBJECT_TRANSMITTER
The large antenna.
Definition: object_type.h:18
GameCreationSettings::landscape
byte landscape
the landscape we&#39;re currently in
Definition: settings_type.h:288
station_map.h
Maps accessors for stations.
OverrideManagerBase::invalid_ID
uint16 invalid_ID
ID used to detected invalid entities;.
Definition: newgrf_commons.h:202
IsSnowTile
static bool IsSnowTile(TileIndex t)
Test if a tile is covered with snow.
Definition: clear_map.h:37
MP_INDUSTRY
Part of an industry.
Definition: tile_type.h:51
NewGRFSpriteLayout::Allocate
void Allocate(uint num_sprites)
Allocate a spritelayout for num_sprites building sprites.
Definition: newgrf_commons.cpp:626
TileLayoutFlags
TileLayoutFlags
Flags to enable register usage in sprite layouts.
Definition: newgrf_commons.h:35
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:246
GetWaterClass
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
Definition: water_map.h:106
TileType
TileType
The different types of tiles.
Definition: tile_type.h:42
debug.h
Functions related to debugging.
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:123
OverrideManagerBase::AddEntityID
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id)
Reserves a place in the mapping array for an entity to be installed.
Definition: newgrf_commons.cpp:125
TLF_BB_XY_OFFSET
Add signed offset to bounding box X and Y positions from register TileLayoutRegisters::delta.parent[0..1].
Definition: newgrf_commons.h:43
MP_ROAD
A tile with road (or tram tracks)
Definition: tile_type.h:45
GetTerrainType
uint32 GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
Definition: newgrf_commons.cpp:350
OverrideManagerBase::GetGRFID
uint32 GetGRFID(uint16 entity_id) const
Gives the GRFID of the file the entity belongs to.
Definition: newgrf_commons.cpp:158
OverrideManagerBase::Add
void Add(uint8 local_id, uint32 grfid, uint entity_type)
Since the entity IDs defined by the GRF file does not necessarily correlate to those used by the game...
Definition: newgrf_commons.cpp:74
ObjectSpec::grf_prop
GRFFilePropsBase< 2 > grf_prop
Properties related the the grf file.
Definition: newgrf_object.h:62
TREE_GROUND_ROUGH_SNOW
A snow tile that is rough underneath.
Definition: tree_map.h:58
TileLayoutRegisters::max_palette_offset
uint16 max_palette_offset
Maximum offset to add to the palette. (limited by size of the spriteset)
Definition: newgrf_commons.h:99
TLF_SPRITE_VAR10
Resolve sprite with a specific value in variable 10.
Definition: newgrf_commons.h:49
TLF_SPRITE_REG_FLAGS
Flags which require resolving the action-1-2-3 chain for the sprite, even if it is no action-1 sprite...
Definition: newgrf_commons.h:64
TLF_PALETTE
Add signed offset to palette from register TileLayoutRegisters::palette.
Definition: newgrf_commons.h:40
DrawTileSeqStruct::MakeTerminator
void MakeTerminator()
Make this struct a sequence terminator.
Definition: sprite.h:37
RAIL_GROUND_ICE_DESERT
Icy or sandy.
Definition: rail_map.h:499
CommandCost::UseTextRefStack
void UseTextRefStack(const GRFFile *grffile, uint num_registers)
Activate usage of the NewGRF TextRefStack for the error message.
Definition: command.cpp:795
TLF_SPRITE
Add signed offset to sprite from register TileLayoutRegisters::sprite.
Definition: newgrf_commons.h:39
ObjectSpec
Allow incrementing of ObjectClassID variables.
Definition: newgrf_object.h:60
industrytype.h
Industry type specs.
GetBridgeHeight
int GetBridgeHeight(TileIndex t)
Get the height (&#39;z&#39;) of a bridge.
Definition: bridge_map.cpp:72
NewGRFSpriteLayout::result_seq
static SmallVector< DrawTileSeqStruct, 8 > result_seq
Temporary storage when preprocessing spritelayouts.
Definition: newgrf_commons.h:173
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:50
SmallVector< DrawTileSeqStruct, 8 >
GetGRFStringID
StringID GetGRFStringID(uint32 grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
Definition: newgrf_text.cpp:702
MP_RAILWAY
A railway.
Definition: tile_type.h:44
tree_map.h
Map accessors for tree tiles.
genworld.h
Functions related to world/map generation.
MP_OBJECT
Contains objects such as transmitters and owned land.
Definition: tile_type.h:53
NewGRFSpriteLayout::AllocateRegisters
void AllocateRegisters()
Allocate memory for register modifiers.
Definition: newgrf_commons.cpp:638
CommandCost
Common return value for all commands.
Definition: command_type.h:25
OverrideManagerBase::OverrideManagerBase
OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid)
Constructor of generic class.
Definition: newgrf_commons.cpp:43
HouseID
uint16 HouseID
OpenTTD ID of house types.
Definition: house_type.h:15
GetErrorMessageFromLocationCallbackResult
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error)
Get the error message from a shape/location/slope check callback result.
Definition: newgrf_commons.cpp:482
DrawTileSprites::seq
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
Definition: sprite.h:62
GetTileZ
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
Definition: tile_map.cpp:182
_object_specs
ObjectSpec _object_specs[NUM_OBJECTS]
All the object specifications.
Definition: newgrf_object.cpp:34
newgrf_object.h
Functions related to NewGRF objects.
OverrideManagerBase::GetID
virtual uint16 GetID(uint8 grf_local_id, uint32 grfid) const
Return the ID (if ever available) of a previously inserted entity.
Definition: newgrf_commons.cpp:104
EntityIDMapping::grfid
uint32 grfid
The GRF ID of the file the entity belongs to.
Definition: newgrf_commons.h:189
RAIL_GROUND_HALF_SNOW
Snow only on higher part of slope (steep or one corner raised)
Definition: rail_map.h:501
TLF_DODRAW
Only draw sprite if value of register TileLayoutRegisters::dodraw is non-zero.
Definition: newgrf_commons.h:38
WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
Definition: error.h:26
TCX_ON_BRIDGE
Querying information about stuff on the bridge (via some bridgehead).
Definition: newgrf_commons.h:29
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
Definition: error_gui.cpp:378
IsOnSnow
static bool IsOnSnow(TileIndex t)
Check if a road tile has snow/desert.
Definition: road_map.h:429
newgrf_text.h
Header of Action 04 "universal holder" structure and functions.
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:279
TileLayoutRegisters::palette_var10
uint8 palette_var10
Value for variable 10 when resolving the palette.
Definition: newgrf_commons.h:105
GetRegister
static uint32 GetRegister(uint i)
Gets the value of a so-called newgrf "register".
Definition: newgrf_spritegroup.h:30
NewGRFSpriteLayout::Clone
void Clone(const DrawTileSeqStruct *source)
Clone the building sprites of a spritelayout.
Definition: newgrf_commons.cpp:588
OverrideManagerBase::max_new_entities
uint16 max_new_entities
what is the amount of entities, old and new summed
Definition: newgrf_commons.h:200
TCX_UPPER_HALFTILE
Querying information about the upper part of a tile with halftile foundation.
Definition: newgrf_commons.h:28
GRFConfig::grf_bugs
uint32 grf_bugs
NOSAVE: bugs in this GRF in this run,.
Definition: newgrf_config.h:170
newgrf_spritegroup.h
Action 2 handling.
GetNearbyTile
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
Definition: newgrf_commons.cpp:425
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
Definition: tile_map.h:143
error.h
Functions related to errors.
AXIS_Y
The y axis.
Definition: direction_type.h:129
NewGRFSpriteLayout::PrepareLayout
uint32 PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const
Prepares a sprite layout before resolving action-1-2-3 chains.
Definition: newgrf_commons.cpp:662
TileLayoutRegisters::max_sprite_offset
uint16 max_sprite_offset
Maximum offset to add to the sprite. (limited by size of the spriteset)
Definition: newgrf_commons.h:98
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:153
DrawTileSprites
Ground palette sprite of a tile, together with its sprite layout.
Definition: sprite.h:60
Company::IsValidAiID
static bool IsValidAiID(size_t index)
Is this company a valid company, controlled by the computer (a NoAI program)?
Definition: company_base.h:132
EntityIDMapping::substitute_id
uint8 substitute_id
The (original) entity ID to use if this GRF is not available.
Definition: newgrf_commons.h:191
house.h
definition of HouseSpec and accessors
EntityIDMapping
Maps an entity id stored on the map to a GRF file.
Definition: newgrf_commons.h:188
OverrideManagerBase::~OverrideManagerBase
virtual ~OverrideManagerBase()
Destructor of the generic class.
Definition: newgrf_commons.cpp:59
ConvertBooleanCallback
bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:552
foreach_draw_tile_seq
#define foreach_draw_tile_seq(idx, list)
Iterate through all DrawTileSeqStructs in DrawTileSprites.
Definition: sprite.h:81
HasStationTileRail
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint...
Definition: station_map.h:147
GetIndustrySpec
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Definition: industry_cmd.cpp:116
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
HouseOverrideManager::SetEntitySpec
void SetEntitySpec(const HouseSpec *hs)
Install the specs into the HouseSpecs array It will find itself the proper slot on which it will go...
Definition: newgrf_commons.cpp:178
safeguards.h
A number of safeguards to prevent using unsafe methods.
MP_WATER
Water tile.
Definition: tile_type.h:49
GetRailStationAxis
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
Definition: station_map.h:338
NewGRFSpriteLayout::ProcessRegisters
void ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const
Evaluates the register modifiers and integrates them into the preprocessed sprite layout...
Definition: newgrf_commons.cpp:734
GetTilePixelSlope
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
Definition: tile_map.h:273
TILE_HEIGHT
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
Definition: tile_type.h:18
Livery
Information about a particular livery.
Definition: livery.h:76
TileLayoutRegisters::sprite_var10
uint8 sprite_var10
Value for variable 10 when resolving the sprite.
Definition: newgrf_commons.h:104
GetTreeDensity
static uint GetTreeDensity(TileIndex t)
Returns the &#39;density&#39; of a tile with trees.
Definition: tree_map.h:114
SPRITE_MODIFIER_CUSTOM_SPRITE
Set when a sprite originates from an Action 1.
Definition: sprites.h:1506
IndustrySpec
Defines the data structure for constructing industry.
Definition: industrytype.h:101
TileLayoutRegisters::sprite
uint8 sprite
Register specifying a signed offset for the sprite.
Definition: newgrf_commons.h:96
TLF_BB_Z_OFFSET
Add signed offset to bounding box Z positions from register TileLayoutRegisters::delta.parent[2].
Definition: newgrf_commons.h:44
IndustryTileSpec::enabled
bool enabled
entity still available (by default true).newgrf can disable it, though
Definition: industrytype.h:163
IndustryTileSpec::grf_prop
GRFFileProps grf_prop
properties related to the grf file
Definition: industrytype.h:164
DrawTileSeqStruct::IsParentSprite
bool IsParentSprite() const
Check whether this is a parent sprite with a boundingbox.
Definition: sprite.h:49
GBUG_UNKNOWN_CB_RESULT
A callback returned an unknown/invalid result.
Definition: newgrf_config.h:48
IndustrySpec::grf_prop
GRFFileProps grf_prop
properties related to the grf file
Definition: industrytype.h:136
ObjectType
uint16 ObjectType
Types of objects.
Definition: object_type.h:16
NewGRFSpriteLayout
NewGRF supplied spritelayout.
Definition: newgrf_commons.h:115
Convert8bitBooleanCallback
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:571
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
TREE_GROUND_SNOW_DESERT
a desert or snow tile, depend on landscape
Definition: tree_map.h:56
Livery::colour2
byte colour2
Second colour, for vehicles with 2CC support.
Definition: livery.h:79
TLF_PALETTE_REG_FLAGS
Flags which require resolving the action-1-2-3 chain for the palette, even if it is no action-1 palet...
Definition: newgrf_commons.h:67
newgrf_config.h
Functions to find and configure NewGRFs.
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:139
MemCpyT
static void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
Definition: mem_func.hpp:25
DEBUG
#define DEBUG(name, level,...)
Output a line of debugging information.
Definition: debug.h:39
GRFFileProps::override
uint16 override
id of the entity been replaced by
Definition: newgrf_commons.h:333
EntityIDMapping::entity_id
uint8 entity_id
The entity ID within the GRF file.
Definition: newgrf_commons.h:190
GetClearDensity
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
Definition: clear_map.h:85
TLF_PALETTE_VAR10
Resolve palette with a specific value in variable 10.
Definition: newgrf_commons.h:50
TileLayoutRegisters
Additional modifiers for items in sprite layouts.
Definition: newgrf_commons.h:93
OverrideManagerBase::mapping_ID
EntityIDMapping * mapping_ID
mapping of ids from grf files. Public out of convenience
Definition: newgrf_commons.h:206
HasTunnelBridgeSnowOrDesert
static bool HasTunnelBridgeSnowOrDesert(TileIndex t)
Tunnel: Is this tunnel entrance in a snowy or desert area? Bridge: Does the bridge ramp lie in a snow...
Definition: tunnelbridge_map.h:54
HouseSpec
Definition: house.h:98
MP_TREES
Tile got trees.
Definition: tile_type.h:47
GetGRFConfig
GRFConfig * GetGRFConfig(uint32 grfid, uint32 mask)
Retrieve a NewGRF from the current config by its grfid.
Definition: newgrf_config.cpp:889
IndustryOverrideManager::GetID
virtual uint16 GetID(uint8 grf_local_id, uint32 grfid) const
Return the ID (if ever available) of a previously inserted entity.
Definition: newgrf_commons.cpp:207
TileLayoutRegisters::child
uint8 child[2]
Registers for signed offsets for the position of child sprites.
Definition: newgrf_commons.h:102
ErrorUnknownCallbackResult
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Definition: newgrf_commons.cpp:518
_generating_world
bool _generating_world
Whether we are generating the map or not.
Definition: genworld.cpp:61
MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition: tile_type.h:52
MP_VOID
Invisible tiles at the SW and SE border.
Definition: tile_type.h:50
OverrideManagerBase::ResetMapping
void ResetMapping()
Resets the mapping, which is used while initializing game.
Definition: newgrf_commons.cpp:84
GetNearbyTileInformation
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62.
Definition: newgrf_commons.cpp:448
GetTileMaxZ
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
Definition: tile_map.cpp:215
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
clear_map.h
Map accessors for &#39;clear&#39; tiles.
GetTreeGround
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
Definition: tree_map.h:89
TLF_CHILD_X_OFFSET
Add signed offset to child sprite X positions from register TileLayoutRegisters::delta.child[0].
Definition: newgrf_commons.h:46
DrawTileSeqStruct::delta_z
int8 delta_z
0x80 identifies child sprites
Definition: sprite.h:30
grfmsg
void CDECL grfmsg(int severity, const char *str,...)
DEBUG() function dedicated to newGRF debugging messages Function is essentially the same as DEBUG(grf...
Definition: newgrf.cpp:375
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:34
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:50
GetCompanyInfo
uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
Returns company information like in vehicle var 43 or station var 43.
Definition: newgrf_commons.cpp:469
MP_STATION
A tile of a station.
Definition: tile_type.h:48
landscape.h
Functions related to OTTD&#39;s landscape.
GetSnowLine
byte GetSnowLine()
Get the current snow line, either variable or static.
Definition: landscape.cpp:564
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
Definition: pool_type.hpp:235
GRFFilePropsBase::local_id
uint16 local_id
id defined by the grf file for this entity
Definition: newgrf_commons.h:319
RailGroundType
RailGroundType
The ground &#39;under&#39; the rail.
Definition: rail_map.h:486
tunnelbridge_map.h
Functions that have tunnels and bridges in common.
TileDiffXY
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:181
GRFConfig::GetName
const char * GetName() const
Get the name of this grf.
Definition: newgrf_config.cpp:126
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:114
HouseSpec::grf_prop
GRFFileProps grf_prop
Properties related the the grf file.
Definition: house.h:114
OverrideManagerBase::ResetOverride
void ResetOverride()
Resets the override, which is used while initializing game.
Definition: newgrf_commons.cpp:90
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:320
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:105
HasTileWaterClass
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
Definition: water_map.h:95
Livery::colour1
byte colour1
First colour, for all vehicles.
Definition: livery.h:78
GetConstructionStageOffset
static uint GetConstructionStageOffset(uint construction_stage, uint num_sprites)
Determines which sprite to use from a spriteset for a specific construction stage.
Definition: newgrf_commons.h:77
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:544
MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition: tile_type.h:43
MP_HOUSE
A house by a town.
Definition: tile_type.h:46
IndustryTileSpec
Defines the data structure of each individual tile of an industry.
Definition: industrytype.h:148
TreeGround
TreeGround
Enumeration for ground types of tiles with trees.
Definition: tree_map.h:53
TREE_GROUND_SHORE
shore
Definition: tree_map.h:57
DrawTileSeqStruct::delta_x
int8 delta_x
0x80 is sequence terminator
Definition: sprite.h:28
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
OverrideManagerBase::max_offset
uint16 max_offset
what is the length of the original entity&#39;s array of specs
Definition: newgrf_commons.h:199
INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:131
PalSpriteID::sprite
SpriteID sprite
The &#39;real&#39; sprite.
Definition: gfx_type.h:25
TileLayoutRegisters::parent
uint8 parent[3]
Registers for signed offsets for the bounding box position of parent sprites.
Definition: newgrf_commons.h:101
TileLayoutRegisters::dodraw
uint8 dodraw
Register deciding whether the sprite shall be drawn at all. Non-zero means drawing.
Definition: newgrf_commons.h:95
DrawTileSeqStruct
A tile child sprite and palette to draw for stations etc, with 3D bounding box.
Definition: sprite.h:27
IndustryOverrideManager::SetEntitySpec
void SetEntitySpec(IndustrySpec *inds)
Method to install the new industry data in its proper slot The slot assignment is internal of this me...
Definition: newgrf_commons.cpp:262
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:127
TILE_MASK
#define TILE_MASK(x)
&#39;Wraps&#39; the given tile to it is within the map.
Definition: map_func.h:28
TileLayoutRegisters::palette
uint8 palette
Register specifying a signed offset for the palette.
Definition: newgrf_commons.h:97
TileLayoutRegisters::flags
TileLayoutFlags flags
Flags defining which members are valid and to be used.
Definition: newgrf_commons.h:94
OverrideManagerBase::GetSubstituteID
uint16 GetSubstituteID(uint16 entity_id) const
Gives the substitute of the entity, as specified by the grf file.
Definition: newgrf_commons.cpp:168
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:104
IndustryOverrideManager::AddEntityID
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id)
Method to find an entity ID and to mark it as reserved for the Industry to be included.
Definition: newgrf_commons.cpp:227
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:201
PalSpriteID::pal
PaletteID pal
The palette (use PAL_NONE) if not needed)
Definition: gfx_type.h:26
TileContext
TileContext
Context for tile accesses.
Definition: newgrf_commons.h:26