OpenTTD Source  14.0-beta3
newgrf_commons.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 <http://www.gnu.org/licenses/>.
6  */
7 
13 #include "stdafx.h"
14 #include "debug.h"
15 #include "landscape.h"
16 #include "house.h"
17 #include "industrytype.h"
18 #include "newgrf_config.h"
19 #include "clear_map.h"
20 #include "station_map.h"
21 #include "tree_map.h"
22 #include "tunnelbridge_map.h"
23 #include "newgrf_object.h"
24 #include "genworld.h"
25 #include "newgrf_spritegroup.h"
26 #include "newgrf_text.h"
27 #include "company_base.h"
28 #include "error.h"
29 #include "strings_func.h"
30 #include "string_func.h"
31 
32 #include "table/strings.h"
33 
34 #include "safeguards.h"
35 
42 OverrideManagerBase::OverrideManagerBase(uint16_t offset, uint16_t maximum, uint16_t invalid)
43 {
44  this->max_offset = offset;
45  this->max_entities = maximum;
46  this->invalid_id = invalid;
47 
48  this->mappings.resize(this->max_entities);
49  this->entity_overrides.resize(this->max_offset);
50  std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_id);
51  this->grfid_overrides.resize(this->max_offset);
52 }
53 
62 void OverrideManagerBase::Add(uint16_t local_id, uint32_t grfid, uint entity_type)
63 {
64  assert(entity_type < this->max_offset);
65  /* An override can be set only once */
66  if (this->entity_overrides[entity_type] != this->invalid_id) return;
67  this->entity_overrides[entity_type] = local_id;
68  this->grfid_overrides[entity_type] = grfid;
69 }
70 
73 {
74  std::fill(this->mappings.begin(), this->mappings.end(), EntityIDMapping{});
75 }
76 
79 {
80  std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_id);
81  std::fill(this->grfid_overrides.begin(), this->grfid_overrides.end(), uint32_t());
82 }
83 
90 uint16_t OverrideManagerBase::GetID(uint16_t grf_local_id, uint32_t grfid) const
91 {
92  for (uint16_t id = 0; id < this->max_entities; id++) {
93  const EntityIDMapping *map = &this->mappings[id];
94  if (map->entity_id == grf_local_id && map->grfid == grfid) {
95  return id;
96  }
97  }
98 
99  return this->invalid_id;
100 }
101 
109 uint16_t OverrideManagerBase::AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id)
110 {
111  uint16_t id = this->GetID(grf_local_id, grfid);
112 
113  /* Look to see if this entity has already been added. This is done
114  * separately from the loop below in case a GRF has been deleted, and there
115  * are any gaps in the array.
116  */
117  if (id != this->invalid_id) return id;
118 
119  /* This entity hasn't been defined before, so give it an ID now. */
120  for (id = this->max_offset; id < this->max_entities; id++) {
121  EntityIDMapping *map = &this->mappings[id];
122 
123  if (CheckValidNewID(id) && map->entity_id == 0 && map->grfid == 0) {
124  map->entity_id = grf_local_id;
125  map->grfid = grfid;
126  map->substitute_id = substitute_id;
127  return id;
128  }
129  }
130 
131  return this->invalid_id;
132 }
133 
139 uint32_t OverrideManagerBase::GetGRFID(uint16_t entity_id) const
140 {
141  return this->mappings[entity_id].grfid;
142 }
143 
149 uint16_t OverrideManagerBase::GetSubstituteID(uint16_t entity_id) const
150 {
151  return this->mappings[entity_id].substitute_id;
152 }
153 
160 {
161  HouseID house_id = this->AddEntityID(hs->grf_prop.local_id, hs->grf_prop.grffile->grfid, hs->grf_prop.subst_id);
162 
163  if (house_id == this->invalid_id) {
164  GrfMsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring.");
165  return;
166  }
167 
168  *HouseSpec::Get(house_id) = *hs;
169 
170  /* Now add the overrides. */
171  for (int i = 0; i < this->max_offset; i++) {
172  HouseSpec *overridden_hs = HouseSpec::Get(i);
173 
174  if (this->entity_overrides[i] != hs->grf_prop.local_id || this->grfid_overrides[i] != hs->grf_prop.grffile->grfid) continue;
175 
176  overridden_hs->grf_prop.override = house_id;
177  this->entity_overrides[i] = this->invalid_id;
178  this->grfid_overrides[i] = 0;
179  }
180 }
181 
188 uint16_t IndustryOverrideManager::GetID(uint16_t grf_local_id, uint32_t grfid) const
189 {
190  uint16_t id = OverrideManagerBase::GetID(grf_local_id, grfid);
191  if (id != this->invalid_id) return id;
192 
193  /* No mapping found, try the overrides */
194  for (id = 0; id < this->max_offset; id++) {
195  if (this->entity_overrides[id] == grf_local_id && this->grfid_overrides[id] == grfid) return id;
196  }
197 
198  return this->invalid_id;
199 }
200 
208 uint16_t IndustryOverrideManager::AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id)
209 {
210  /* This entity hasn't been defined before, so give it an ID now. */
211  for (uint16_t id = 0; id < this->max_entities; id++) {
212  /* Skip overridden industries */
213  if (id < this->max_offset && this->entity_overrides[id] != this->invalid_id) continue;
214 
215  /* Get the real live industry */
216  const IndustrySpec *inds = GetIndustrySpec(id);
217 
218  /* This industry must be one that is not available(enabled), mostly because of climate.
219  * And it must not already be used by a grf (grffile == nullptr).
220  * So reserve this slot here, as it is the chosen one */
221  if (!inds->enabled && inds->grf_prop.grffile == nullptr) {
222  EntityIDMapping *map = &this->mappings[id];
223 
224  if (map->entity_id == 0 && map->grfid == 0) {
225  /* winning slot, mark it as been used */
226  map->entity_id = grf_local_id;
227  map->grfid = grfid;
228  map->substitute_id = substitute_id;
229  return id;
230  }
231  }
232  }
233 
234  return this->invalid_id;
235 }
236 
244 {
245  /* First step : We need to find if this industry is already specified in the savegame data. */
246  IndustryType ind_id = this->GetID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid);
247 
248  if (ind_id == this->invalid_id) {
249  /* Not found.
250  * Or it has already been overridden, so you've lost your place.
251  * Or it is a simple substitute.
252  * We need to find a free available slot */
253  ind_id = this->AddEntityID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid, inds->grf_prop.subst_id);
254  inds->grf_prop.override = this->invalid_id; // make sure it will not be detected as overridden
255  }
256 
257  if (ind_id == this->invalid_id) {
258  GrfMsg(1, "Industry.SetEntitySpec: Too many industries allocated. Ignoring.");
259  return;
260  }
261 
262  /* Now that we know we can use the given id, copy the spec to its final destination... */
263  _industry_specs[ind_id] = *inds;
264  /* ... and mark it as usable*/
265  _industry_specs[ind_id].enabled = true;
266 }
267 
268 void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its)
269 {
270  IndustryGfx indt_id = this->AddEntityID(its->grf_prop.local_id, its->grf_prop.grffile->grfid, its->grf_prop.subst_id);
271 
272  if (indt_id == this->invalid_id) {
273  GrfMsg(1, "IndustryTile.SetEntitySpec: Too many industry tiles allocated. Ignoring.");
274  return;
275  }
276 
277  _industry_tile_specs[indt_id] = *its;
278 
279  /* Now add the overrides. */
280  for (int i = 0; i < this->max_offset; i++) {
281  IndustryTileSpec *overridden_its = &_industry_tile_specs[i];
282 
283  if (this->entity_overrides[i] != its->grf_prop.local_id || this->grfid_overrides[i] != its->grf_prop.grffile->grfid) continue;
284 
285  overridden_its->grf_prop.override = indt_id;
286  overridden_its->enabled = false;
287  this->entity_overrides[i] = this->invalid_id;
288  this->grfid_overrides[i] = 0;
289  }
290 }
291 
299 {
300  /* First step : We need to find if this object is already specified in the savegame data. */
301  ObjectType type = this->GetID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid);
302 
303  if (type == this->invalid_id) {
304  /* Not found.
305  * Or it has already been overridden, so you've lost your place.
306  * Or it is a simple substitute.
307  * We need to find a free available slot */
308  type = this->AddEntityID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid, OBJECT_TRANSMITTER);
309  }
310 
311  if (type == this->invalid_id) {
312  GrfMsg(1, "Object.SetEntitySpec: Too many objects allocated. Ignoring.");
313  return;
314  }
315 
316  extern std::vector<ObjectSpec> _object_specs;
317 
318  /* Now that we know we can use the given id, copy the spec to its final destination. */
319  if (type >= _object_specs.size()) _object_specs.resize(type + 1);
320  _object_specs[type] = *spec;
321 }
322 
331 uint32_t GetTerrainType(TileIndex tile, TileContext context)
332 {
334  case LT_TROPIC: return GetTropicZone(tile);
335  case LT_ARCTIC: {
336  bool has_snow;
337  switch (GetTileType(tile)) {
338  case MP_CLEAR:
339  /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
340  if (_generating_world) goto genworld;
341  has_snow = IsSnowTile(tile) && GetClearDensity(tile) >= 2;
342  break;
343 
344  case MP_RAILWAY: {
345  /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
346  if (_generating_world) goto genworld; // we do not care about foundations here
347  RailGroundType ground = GetRailGroundType(tile);
348  has_snow = (ground == RAIL_GROUND_ICE_DESERT || (context == TCX_UPPER_HALFTILE && ground == RAIL_GROUND_HALF_SNOW));
349  break;
350  }
351 
352  case MP_ROAD:
353  /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
354  if (_generating_world) goto genworld; // we do not care about foundations here
355  has_snow = IsOnSnow(tile);
356  break;
357 
358  case MP_TREES: {
359  /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
360  if (_generating_world) goto genworld;
361  TreeGround ground = GetTreeGround(tile);
362  has_snow = (ground == TREE_GROUND_SNOW_DESERT || ground == TREE_GROUND_ROUGH_SNOW) && GetTreeDensity(tile) >= 2;
363  break;
364  }
365 
366  case MP_TUNNELBRIDGE:
367  if (context == TCX_ON_BRIDGE) {
368  has_snow = (GetBridgeHeight(tile) > GetSnowLine());
369  } else {
370  /* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
371  if (_generating_world) goto genworld; // we do not care about foundations here
372  has_snow = HasTunnelBridgeSnowOrDesert(tile);
373  }
374  break;
375 
376  case MP_STATION:
377  case MP_HOUSE:
378  case MP_INDUSTRY:
379  case MP_OBJECT:
380  /* These tiles usually have a levelling foundation. So use max Z */
381  has_snow = (GetTileMaxZ(tile) > GetSnowLine());
382  break;
383 
384  case MP_VOID:
385  case MP_WATER:
386  genworld:
387  has_snow = (GetTileZ(tile) > GetSnowLine());
388  break;
389 
390  default: NOT_REACHED();
391  }
392  return has_snow ? 4 : 0;
393  }
394  default: return 0;
395  }
396 }
397 
406 TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis)
407 {
408  int8_t x = GB(parameter, 0, 4);
409  int8_t y = GB(parameter, 4, 4);
410 
411  if (signed_offsets && x >= 8) x -= 16;
412  if (signed_offsets && y >= 8) y -= 16;
413 
414  /* Swap width and height depending on axis for railway stations */
415  if (axis == INVALID_AXIS && HasStationTileRail(tile)) axis = GetRailStationAxis(tile);
416  if (axis == AXIS_Y) Swap(x, y);
417 
418  /* Make sure we never roam outside of the map, better wrap in that case */
419  return Map::WrapToMap(tile + TileDiffXY(x, y));
420 }
421 
429 uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8)
430 {
431  TileType tile_type = GetTileType(tile);
432 
433  /* Fake tile type for trees on shore */
434  if (IsTileType(tile, MP_TREES) && GetTreeGround(tile) == TREE_GROUND_SHORE) tile_type = MP_WATER;
435 
436  int z;
437  Slope tileh = GetTilePixelSlope(tile, &z);
438  /* Return 0 if the tile is a land tile */
439  byte terrain_type = (HasTileWaterClass(tile) ? (GetWaterClass(tile) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
440  if (grf_version8) z /= TILE_HEIGHT;
441  return tile_type << 24 | ClampTo<uint8_t>(z) << 16 | terrain_type << 8 | tileh;
442 }
443 
450 uint32_t GetCompanyInfo(CompanyID owner, const Livery *l)
451 {
452  if (l == nullptr && Company::IsValidID(owner)) l = &Company::Get(owner)->livery[LS_DEFAULT];
453  return owner | (Company::IsValidAiID(owner) ? 0x10000 : 0) | (l != nullptr ? (l->colour1 << 24) | (l->colour2 << 28) : 0);
454 }
455 
463 CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, const GRFFile *grffile, StringID default_error)
464 {
465  CommandCost res;
466 
467  if (cb_res < 0x400) {
468  res = CommandCost(GetGRFStringID(grffile->grfid, 0xD000 + cb_res));
469  } else {
470  switch (cb_res) {
471  case 0x400: return res; // No error.
472 
473  default: // unknown reason -> default error
474  case 0x401: res = CommandCost(default_error); break;
475 
476  case 0x402: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST); break;
477  case 0x403: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT); break;
478  case 0x404: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_ABOVE_SNOW_LINE); break;
479  case 0x405: res = CommandCost(STR_ERROR_CAN_ONLY_BE_BUILT_BELOW_SNOW_LINE); break;
480  case 0x406: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_SEA); break;
481  case 0x407: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_CANAL); break;
482  case 0x408: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_RIVER); break;
483  }
484  }
485 
486  /* Copy some parameters from the registers to the error message text ref. stack */
487  res.UseTextRefStack(grffile, 4);
488 
489  return res;
490 }
491 
499 void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
500 {
501  GRFConfig *grfconfig = GetGRFConfig(grfid);
502 
503  if (!HasBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT)) {
505  SetDParamStr(0, grfconfig->GetName());
506  SetDParam(1, cbid);
507  SetDParam(2, cb_res);
508  ShowErrorMessage(STR_NEWGRF_BUGGY, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, WL_CRITICAL);
509  }
510 
511  /* debug output */
512  SetDParamStr(0, grfconfig->GetName());
513  Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY)));
514 
515  SetDParam(1, cbid);
516  SetDParam(2, cb_res);
517  Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT)));
518 }
519 
529 bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
530 {
531  assert(cb_res != CALLBACK_FAILED); // We do not know what to return
532 
533  if (grffile->grf_version < 8) return cb_res != 0;
534 
535  if (cb_res > 1) ErrorUnknownCallbackResult(grffile->grfid, cbid, cb_res);
536  return cb_res != 0;
537 }
538 
548 bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
549 {
550  assert(cb_res != CALLBACK_FAILED); // We do not know what to return
551 
552  if (grffile->grf_version < 8) return GB(cb_res, 0, 8) != 0;
553 
554  if (cb_res > 1) ErrorUnknownCallbackResult(grffile->grfid, cbid, cb_res);
555  return cb_res != 0;
556 }
557 
558 
559 /* static */ std::vector<DrawTileSeqStruct> NewGRFSpriteLayout::result_seq;
560 
566 {
567  assert(this->seq == nullptr);
568  assert(source != nullptr);
569 
570  size_t count = 1; // 1 for the terminator
571  const DrawTileSeqStruct *element;
572  foreach_draw_tile_seq(element, source) count++;
573 
574  DrawTileSeqStruct *sprites = MallocT<DrawTileSeqStruct>(count);
575  MemCpyT(sprites, source, count);
576  this->seq = sprites;
577 }
578 
584 {
585  this->Clone((const DrawTileSprites*)source);
586 
587  if (source->registers != nullptr) {
588  size_t count = 1; // 1 for the ground sprite
589  const DrawTileSeqStruct *element;
590  foreach_draw_tile_seq(element, source->seq) count++;
591 
592  TileLayoutRegisters *regs = MallocT<TileLayoutRegisters>(count);
593  MemCpyT(regs, source->registers, count);
594  this->registers = regs;
595  }
596 }
597 
598 
603 void NewGRFSpriteLayout::Allocate(uint num_sprites)
604 {
605  assert(this->seq == nullptr);
606 
607  DrawTileSeqStruct *sprites = CallocT<DrawTileSeqStruct>(num_sprites + 1);
608  sprites[num_sprites].MakeTerminator();
609  this->seq = sprites;
610 }
611 
616 {
617  assert(this->seq != nullptr);
618  assert(this->registers == nullptr);
619 
620  size_t count = 1; // 1 for the ground sprite
621  const DrawTileSeqStruct *element;
622  foreach_draw_tile_seq(element, this->seq) count++;
623 
624  this->registers = CallocT<TileLayoutRegisters>(count);
625 }
626 
639 uint32_t NewGRFSpriteLayout::PrepareLayout(uint32_t orig_offset, uint32_t newgrf_ground_offset, uint32_t newgrf_offset, uint constr_stage, bool separate_ground) const
640 {
641  result_seq.clear();
642  uint32_t var10_values = 0;
643 
644  /* Create a copy of the spritelayout, so we can modify some values.
645  * Also include the groundsprite into the sequence for easier processing. */
646  DrawTileSeqStruct *result = &result_seq.emplace_back();
647  result->image = ground;
648  result->delta_x = 0;
649  result->delta_y = 0;
650  result->delta_z = (int8_t)0x80;
651 
652  const DrawTileSeqStruct *dtss;
653  foreach_draw_tile_seq(dtss, this->seq) {
654  result_seq.push_back(*dtss);
655  }
656  result_seq.emplace_back().MakeTerminator();
657  /* Determine the var10 values the action-1-2-3 chains needs to be resolved for,
658  * and apply the default sprite offsets (unless disabled). */
659  const TileLayoutRegisters *regs = this->registers;
660  bool ground = true;
661  foreach_draw_tile_seq(result, result_seq.data()) {
662  TileLayoutFlags flags = TLF_NOTHING;
663  if (regs != nullptr) flags = regs->flags;
664 
665  /* Record var10 value for the sprite */
666  if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) {
667  uint8_t var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0);
668  SetBit(var10_values, var10);
669  }
670 
671  /* Add default sprite offset, unless there is a custom one */
672  if (!(flags & TLF_SPRITE)) {
673  if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
674  result->image.sprite += ground ? newgrf_ground_offset : newgrf_offset;
675  if (constr_stage > 0 && regs != nullptr) result->image.sprite += GetConstructionStageOffset(constr_stage, regs->max_sprite_offset);
676  } else {
677  result->image.sprite += orig_offset;
678  }
679  }
680 
681  /* Record var10 value for the palette */
682  if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_PALETTE_REG_FLAGS)) {
683  uint8_t var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0);
684  SetBit(var10_values, var10);
685  }
686 
687  /* Add default palette offset, unless there is a custom one */
688  if (!(flags & TLF_PALETTE)) {
689  if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
690  result->image.sprite += ground ? newgrf_ground_offset : newgrf_offset;
691  if (constr_stage > 0 && regs != nullptr) result->image.sprite += GetConstructionStageOffset(constr_stage, regs->max_palette_offset);
692  }
693  }
694 
695  ground = false;
696  if (regs != nullptr) regs++;
697  }
698 
699  return var10_values;
700 }
701 
710 void NewGRFSpriteLayout::ProcessRegisters(uint8_t resolved_var10, uint32_t resolved_sprite, bool separate_ground) const
711 {
712  DrawTileSeqStruct *result;
713  const TileLayoutRegisters *regs = this->registers;
714  bool ground = true;
715  foreach_draw_tile_seq(result, result_seq.data()) {
716  TileLayoutFlags flags = TLF_NOTHING;
717  if (regs != nullptr) flags = regs->flags;
718 
719  /* Is the sprite or bounding box affected by an action-1-2-3 chain? */
720  if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) {
721  /* Does the var10 value apply to this sprite? */
722  uint8_t var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0);
723  if (var10 == resolved_var10) {
724  /* Apply registers */
725  if ((flags & TLF_DODRAW) && GetRegister(regs->dodraw) == 0) {
726  result->image.sprite = 0;
727  } else {
728  if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) result->image.sprite += resolved_sprite;
729  if (flags & TLF_SPRITE) {
730  int16_t offset = (int16_t)GetRegister(regs->sprite); // mask to 16 bits to avoid trouble
731  if (!HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_sprite_offset)) {
732  result->image.sprite += offset;
733  } else {
734  result->image.sprite = SPR_IMG_QUERY;
735  }
736  }
737 
738  if (result->IsParentSprite()) {
739  if (flags & TLF_BB_XY_OFFSET) {
740  result->delta_x += (int32_t)GetRegister(regs->delta.parent[0]);
741  result->delta_y += (int32_t)GetRegister(regs->delta.parent[1]);
742  }
743  if (flags & TLF_BB_Z_OFFSET) result->delta_z += (int32_t)GetRegister(regs->delta.parent[2]);
744  } else {
745  if (flags & TLF_CHILD_X_OFFSET) result->delta_x += (int32_t)GetRegister(regs->delta.child[0]);
746  if (flags & TLF_CHILD_Y_OFFSET) result->delta_y += (int32_t)GetRegister(regs->delta.child[1]);
747  }
748  }
749  }
750  }
751 
752  /* Is the palette affected by an action-1-2-3 chain? */
753  if (result->image.sprite != 0 && (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_PALETTE_REG_FLAGS))) {
754  /* Does the var10 value apply to this sprite? */
755  uint8_t var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0);
756  if (var10 == resolved_var10) {
757  /* Apply registers */
758  if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) result->image.pal += resolved_sprite;
759  if (flags & TLF_PALETTE) {
760  int16_t offset = (int16_t)GetRegister(regs->palette); // mask to 16 bits to avoid trouble
761  if (!HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_palette_offset)) {
762  result->image.pal += offset;
763  } else {
764  result->image.sprite = SPR_IMG_QUERY;
765  result->image.pal = PAL_NONE;
766  }
767  }
768  }
769  }
770 
771  ground = false;
772  if (regs != nullptr) regs++;
773  }
774 }
MP_CLEAR
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition: tile_type.h:48
MP_HOUSE
@ MP_HOUSE
A house by a town.
Definition: tile_type.h:51
TCX_UPPER_HALFTILE
@ TCX_UPPER_HALFTILE
Querying information about the upper part of a tile with halftile foundation.
Definition: newgrf_commons.h:25
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:118
OverrideManagerBase::GetGRFID
uint32_t GetGRFID(uint16_t entity_id) const
Gives the GRFID of the file the entity belongs to.
Definition: newgrf_commons.cpp:139
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:335
GetTileMaxZ
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
Definition: tile_map.cpp:141
RAIL_GROUND_HALF_SNOW
@ RAIL_GROUND_HALF_SNOW
Snow only on higher part of slope (steep or one corner raised)
Definition: rail_map.h:500
TLF_DODRAW
@ TLF_DODRAW
Only draw sprite if value of register TileLayoutRegisters::dodraw is non-zero.
Definition: newgrf_commons.h:35
ObjectSpec
Allow incrementing of ObjectClassID variables.
Definition: newgrf_object.h:60
TileLayoutRegisters::dodraw
uint8_t dodraw
Register deciding whether the sprite shall be drawn at all. Non-zero means drawing.
Definition: newgrf_commons.h:92
ObjectSpec::grf_prop
GRFFilePropsBase< 2 > grf_prop
Properties related the the grf file.
Definition: newgrf_object.h:62
Swap
constexpr void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:283
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
Definition: error_gui.cpp:367
GetTreeGround
TreeGround GetTreeGround(Tile t)
Returns the groundtype for tree tiles.
Definition: tree_map.h:88
GetWaterClass
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
Definition: water_map.h:115
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:356
TLF_CHILD_X_OFFSET
@ TLF_CHILD_X_OFFSET
Add signed offset to child sprite X positions from register TileLayoutRegisters::delta....
Definition: newgrf_commons.h:43
company_base.h
EntityIDMapping::grfid
uint32_t grfid
The GRF ID of the file the entity belongs to.
Definition: newgrf_commons.h:186
tunnelbridge_map.h
EntityIDMapping::entity_id
uint16_t entity_id
The entity ID within the GRF file.
Definition: newgrf_commons.h:187
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:116
NewGRFSpriteLayout::AllocateRegisters
void AllocateRegisters()
Allocate memory for register modifiers.
Definition: newgrf_commons.cpp:615
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
IndustryOverrideManager::AddEntityID
uint16_t AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id) override
Method to find an entity ID and to mark it as reserved for the Industry to be included.
Definition: newgrf_commons.cpp:208
GB
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
GetRegister
uint32_t GetRegister(uint i)
Gets the value of a so-called newgrf "register".
Definition: newgrf_spritegroup.h:29
TREE_GROUND_SHORE
@ TREE_GROUND_SHORE
shore
Definition: tree_map.h:56
GetBridgeHeight
int GetBridgeHeight(TileIndex t)
Get the height ('z') of a bridge.
Definition: bridge_map.cpp:70
Map::WrapToMap
static TileIndex WrapToMap(TileIndex tile)
'Wraps' the given "tile" so it is within the map.
Definition: map_func.h:317
GRFConfig::grf_bugs
uint32_t grf_bugs
NOSAVE: bugs in this GRF in this run,.
Definition: newgrf_config.h:166
GetTileZ
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
Definition: tile_map.cpp:121
StrMakeValid
static void StrMakeValid(T &dst, const char *str, const char *last, StringValidationSettings settings)
Copies the valid (UTF-8) characters from str up to last to the dst.
Definition: string.cpp:114
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition: tile_type.h:49
MP_INDUSTRY
@ MP_INDUSTRY
Part of an industry.
Definition: tile_type.h:56
GetGRFConfig
GRFConfig * GetGRFConfig(uint32_t grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
Definition: newgrf_config.cpp:716
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
GetTerrainType
uint32_t 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:331
NewGRFSpriteLayout::ProcessRegisters
void ProcessRegisters(uint8_t resolved_var10, uint32_t resolved_sprite, bool separate_ground) const
Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
Definition: newgrf_commons.cpp:710
clear_map.h
newgrf_config.h
GetConstructionStageOffset
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:74
_object_specs
std::vector< ObjectSpec > _object_specs
All the object specifications.
Definition: newgrf_object.cpp:33
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
TLF_BB_Z_OFFSET
@ TLF_BB_Z_OFFSET
Add signed offset to bounding box Z positions from register TileLayoutRegisters::delta....
Definition: newgrf_commons.h:41
MP_ROAD
@ MP_ROAD
A tile with road (or tram tracks)
Definition: tile_type.h:50
GetRailStationAxis
Axis GetRailStationAxis(Tile t)
Get the rail direction of a rail station.
Definition: station_map.h:410
genworld.h
TileLayoutRegisters
Additional modifiers for items in sprite layouts.
Definition: newgrf_commons.h:90
Debug
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:619
GetTileType
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
Definition: tile_map.h:96
OverrideManagerBase::invalid_id
uint16_t invalid_id
ID used to detected invalid entities.
Definition: newgrf_commons.h:199
MemCpyT
void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
Definition: mem_func.hpp:23
DrawTileSprites::ground
PalSpriteID ground
Palette and sprite for the ground.
Definition: sprite.h:59
TileLayoutRegisters::sprite_var10
uint8_t sprite_var10
Value for variable 10 when resolving the sprite.
Definition: newgrf_commons.h:101
GRFFileProps::override
uint16_t override
id of the entity been replaced by
Definition: newgrf_commons.h:332
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:48
TileLayoutRegisters::palette
uint8_t palette
Register specifying a signed offset for the palette.
Definition: newgrf_commons.h:94
CommandCost::UseTextRefStack
void UseTextRefStack(const GRFFile *grffile, uint num_registers)
Activate usage of the NewGRF TextRefStack for the error message.
Definition: command.cpp:422
CommandCost
Common return value for all commands.
Definition: command_type.h:23
GetSnowLine
byte GetSnowLine()
Get the current snow line, either variable or static.
Definition: landscape.cpp:611
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:147
ObjectType
uint16_t ObjectType
Types of objects.
Definition: object_type.h:14
GetCompanyInfo
uint32_t GetCompanyInfo(CompanyID owner, const Livery *l)
Returns company information like in vehicle var 43 or station var 43.
Definition: newgrf_commons.cpp:450
TLF_BB_XY_OFFSET
@ TLF_BB_XY_OFFSET
Add signed offset to bounding box X and Y positions from register TileLayoutRegisters::delta....
Definition: newgrf_commons.h:40
OverrideManagerBase::ResetMapping
void ResetMapping()
Resets the mapping, which is used while initializing game.
Definition: newgrf_commons.cpp:72
TLF_CHILD_Y_OFFSET
@ TLF_CHILD_Y_OFFSET
Add signed offset to child sprite Y positions from register TileLayoutRegisters::delta....
Definition: newgrf_commons.h:44
HasTunnelBridgeSnowOrDesert
bool HasTunnelBridgeSnowOrDesert(Tile 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:52
MP_OBJECT
@ MP_OBJECT
Contains objects such as transmitters and owned land.
Definition: tile_type.h:58
MP_WATER
@ MP_WATER
Water tile.
Definition: tile_type.h:54
HasStationTileRail
bool HasStationTileRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition: station_map.h:146
TileLayoutRegisters::max_palette_offset
uint16_t max_palette_offset
Maximum offset to add to the palette. (limited by size of the spriteset)
Definition: newgrf_commons.h:96
foreach_draw_tile_seq
#define foreach_draw_tile_seq(idx, list)
Iterate through all DrawTileSeqStructs in DrawTileSprites.
Definition: sprite.h:79
TileDiffXY
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:401
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
GetNearbyTileInformation
uint32_t 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:429
TileContext
TileContext
Context for tile accesses.
Definition: newgrf_commons.h:23
NewGRFSpriteLayout
NewGRF supplied spritelayout.
Definition: newgrf_commons.h:112
safeguards.h
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:298
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:138
SPRITE_MODIFIER_CUSTOM_SPRITE
@ SPRITE_MODIFIER_CUSTOM_SPRITE
Set when a sprite originates from an Action 1.
Definition: sprites.h:1539
IndustryTileSpec::enabled
bool enabled
entity still available (by default true).newgrf can disable it, though
Definition: industrytype.h:172
DrawTileSprites
Ground palette sprite of a tile, together with its sprite layout.
Definition: sprite.h:58
OverrideManagerBase::GetSubstituteID
uint16_t GetSubstituteID(uint16_t entity_id) const
Gives the substitute of the entity, as specified by the grf file.
Definition: newgrf_commons.cpp:149
MP_TUNNELBRIDGE
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition: tile_type.h:57
newgrf_text.h
OverrideManagerBase::OverrideManagerBase
OverrideManagerBase(uint16_t offset, uint16_t maximum, uint16_t invalid)
Constructor of generic class.
Definition: newgrf_commons.cpp:42
error.h
OverrideManagerBase::AddEntityID
virtual uint16_t AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id)
Reserves a place in the mapping array for an entity to be installed.
Definition: newgrf_commons.cpp:109
GetErrorMessageFromLocationCallbackResult
CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, const GRFFile *grffile, StringID default_error)
Get the error message from a shape/location/slope check callback result.
Definition: newgrf_commons.cpp:463
EntityIDMapping
Maps an entity id stored on the map to a GRF file.
Definition: newgrf_commons.h:185
GetGRFStringID
StringID GetGRFStringID(uint32_t grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
Definition: newgrf_text.cpp:587
IndustryOverrideManager::GetID
uint16_t GetID(uint16_t grf_local_id, uint32_t grfid) const override
Return the ID (if ever available) of a previously inserted entity.
Definition: newgrf_commons.cpp:188
stdafx.h
landscape.h
IndustrySpec
Defines the data structure for constructing industry.
Definition: industrytype.h:105
NewGRFSpriteLayout::PrepareLayout
uint32_t PrepareLayout(uint32_t orig_offset, uint32_t newgrf_ground_offset, uint32_t newgrf_offset, uint constr_stage, bool separate_ground) const
Prepares a sprite layout before resolving action-1-2-3 chains.
Definition: newgrf_commons.cpp:639
IndustryTileSpec::grf_prop
GRFFileProps grf_prop
properties related to the grf file
Definition: industrytype.h:173
house.h
GBUG_UNKNOWN_CB_RESULT
@ GBUG_UNKNOWN_CB_RESULT
A callback returned an unknown/invalid result.
Definition: newgrf_config.h:47
RailGroundType
RailGroundType
The ground 'under' the rail.
Definition: rail_map.h:485
HasTileWaterClass
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
Definition: water_map.h:104
GRFFilePropsBase::local_id
uint16_t local_id
id defined by the grf file for this entity
Definition: newgrf_commons.h:318
newgrf_object.h
ConvertBooleanCallback
bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:529
MP_TREES
@ MP_TREES
Tile got trees.
Definition: tile_type.h:52
newgrf_spritegroup.h
_generating_world
bool _generating_world
Whether we are generating the map or not.
Definition: genworld.cpp:62
string_func.h
IndustrySpec::enabled
bool enabled
entity still available (by default true).newgrf can disable it, though
Definition: industrytype.h:140
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:420
TreeGround
TreeGround
Enumeration for ground types of tiles with trees.
Definition: tree_map.h:52
strings_func.h
MP_VOID
@ MP_VOID
Invisible tiles at the SW and SE border.
Definition: tile_type.h:55
INVALID_AXIS
@ INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:120
TileLayoutRegisters::parent
uint8_t parent[3]
Registers for signed offsets for the bounding box position of parent sprites.
Definition: newgrf_commons.h:98
GetTilePixelSlope
Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
Definition: tile_map.h:280
TileType
TileType
The different types of tiles.
Definition: tile_type.h:47
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
TCX_ON_BRIDGE
@ TCX_ON_BRIDGE
Querying information about stuff on the bridge (via some bridgehead).
Definition: newgrf_commons.h:26
Livery::colour1
Colours colour1
First colour, for all vehicles.
Definition: livery.h:80
industrytype.h
tree_map.h
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:53
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition: strings.cpp:327
IndustrySpec::grf_prop
GRFFileProps grf_prop
properties related to the grf file
Definition: industrytype.h:141
OverrideManagerBase::ResetOverride
void ResetOverride()
Resets the override, which is used while initializing game.
Definition: newgrf_commons.cpp:78
TileLayoutFlags
TileLayoutFlags
Flags to enable register usage in sprite layouts.
Definition: newgrf_commons.h:32
SetDParamStr
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:352
HouseID
uint16_t HouseID
OpenTTD ID of house types.
Definition: house_type.h:13
ErrorUnknownCallbackResult
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Definition: newgrf_commons.cpp:499
NewGRFSpriteLayout::Clone
void Clone(const DrawTileSeqStruct *source)
Clone the building sprites of a spritelayout.
Definition: newgrf_commons.cpp:565
DrawTileSprites::seq
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
Definition: sprite.h:60
station_map.h
TileLayoutRegisters::sprite
uint8_t sprite
Register specifying a signed offset for the sprite.
Definition: newgrf_commons.h:93
DrawTileSeqStruct::MakeTerminator
void MakeTerminator()
Make this struct a sequence terminator.
Definition: sprite.h:35
TileLayoutRegisters::flags
TileLayoutFlags flags
Flags defining which members are valid and to be used.
Definition: newgrf_commons.h:91
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
OverrideManagerBase::max_entities
uint16_t max_entities
what is the amount of entities, old and new summed
Definition: newgrf_commons.h:197
TileLayoutRegisters::child
uint8_t child[2]
Registers for signed offsets for the position of child sprites.
Definition: newgrf_commons.h:99
GetNearbyTile
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
Definition: newgrf_commons.cpp:406
OverrideManagerBase::Add
void Add(uint16_t local_id, uint32_t 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:62
HouseSpec
Definition: house.h:98
IsSnowTile
bool IsSnowTile(Tile t)
Test if a tile is covered with snow.
Definition: clear_map.h:35
EntityIDMapping::substitute_id
uint16_t substitute_id
The (original) entity ID to use if this GRF is not available.
Definition: newgrf_commons.h:188
TREE_GROUND_SNOW_DESERT
@ TREE_GROUND_SNOW_DESERT
a desert or snow tile, depend on landscape
Definition: tree_map.h:55
TLF_PALETTE_REG_FLAGS
@ 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:64
TLF_SPRITE
@ TLF_SPRITE
Add signed offset to sprite from register TileLayoutRegisters::sprite.
Definition: newgrf_commons.h:36
TLF_PALETTE
@ TLF_PALETTE
Add signed offset to palette from register TileLayoutRegisters::palette.
Definition: newgrf_commons.h:37
GetIndustrySpec
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Definition: industry_cmd.cpp:123
OverrideManagerBase::max_offset
uint16_t max_offset
what is the length of the original entity's array of specs
Definition: newgrf_commons.h:196
IsTileType
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:324
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:319
OverrideManagerBase::mappings
std::vector< EntityIDMapping > mappings
mapping of ids from grf files. Public out of convenience
Definition: newgrf_commons.h:203
TileLayoutRegisters::max_sprite_offset
uint16_t max_sprite_offset
Maximum offset to add to the sprite. (limited by size of the spriteset)
Definition: newgrf_commons.h:95
OBJECT_TRANSMITTER
static const ObjectType OBJECT_TRANSMITTER
The large antenna.
Definition: object_type.h:16
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:243
IndustryTileSpec
Defines the data structure of each individual tile of an industry.
Definition: industrytype.h:156
TLF_PALETTE_VAR10
@ TLF_PALETTE_VAR10
Resolve palette with a specific value in variable 10.
Definition: newgrf_commons.h:47
Livery::colour2
Colours colour2
Second colour, for vehicles with 2CC support.
Definition: livery.h:81
TLF_SPRITE_REG_FLAGS
@ 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:61
GetTropicZone
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
Definition: tile_map.h:238
TLF_SPRITE_VAR10
@ TLF_SPRITE_VAR10
Resolve sprite with a specific value in variable 10.
Definition: newgrf_commons.h:46
Livery
Information about a particular livery.
Definition: livery.h:78
NewGRFSpriteLayout::result_seq
static std::vector< DrawTileSeqStruct > result_seq
Temporary storage when preprocessing spritelayouts.
Definition: newgrf_commons.h:170
Convert8bitBooleanCallback
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:548
RAIL_GROUND_ICE_DESERT
@ RAIL_GROUND_ICE_DESERT
Icy or sandy.
Definition: rail_map.h:498
GetClearDensity
uint GetClearDensity(Tile t)
Get the density of a non-field clear tile.
Definition: clear_map.h:83
HouseSpec::grf_prop
GRFFileProps grf_prop
Properties related the the grf file.
Definition: house.h:115
GetTreeDensity
uint GetTreeDensity(Tile t)
Returns the 'density' of a tile with trees.
Definition: tree_map.h:113
NewGRFSpriteLayout::Allocate
void Allocate(uint num_sprites)
Allocate a spritelayout for num_sprites building sprites.
Definition: newgrf_commons.cpp:603
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:107
WL_CRITICAL
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
Definition: error.h:27
debug.h
OverrideManagerBase::GetID
virtual uint16_t GetID(uint16_t grf_local_id, uint32_t grfid) const
Return the ID (if ever available) of a previously inserted entity.
Definition: newgrf_commons.cpp:90
IsOnSnow
bool IsOnSnow(Tile t)
Check if a road tile has snow/desert.
Definition: road_map.h:459
GRFConfig::GetName
const char * GetName() const
Get the name of this grf.
Definition: newgrf_config.cpp:98
DrawTileSeqStruct
A tile child sprite and palette to draw for stations etc, with 3D bounding box.
Definition: sprite.h:25
TileLayoutRegisters::palette_var10
uint8_t palette_var10
Value for variable 10 when resolving the palette.
Definition: newgrf_commons.h:102
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:159
TREE_GROUND_ROUGH_SNOW
@ TREE_GROUND_ROUGH_SNOW
A snow tile that is rough underneath.
Definition: tree_map.h:57
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103