33 #include "table/strings.h"
50 entity_overrides = MallocT<uint16>(
max_offset);
51 for (
size_t i = 0; i <
max_offset; i++) entity_overrides[i] = invalid;
62 free(entity_overrides);
63 free(grfid_overrides);
78 if (entity_overrides[entity_type] !=
invalid_ID)
return;
79 entity_overrides[entity_type] = local_id;
80 grfid_overrides[entity_type] = grfid;
94 grfid_overrides[i] = 0;
127 uint16
id = this->
GetID(grf_local_id, grfid);
142 if (CheckValidNewID(
id) && map->
entity_id == 0 && map->
grfid == 0) {
183 grfmsg(1,
"House.SetEntitySpec: Too many houses allocated. Ignoring.");
187 MemCpyT(HouseSpec::Get(house_id), hs);
191 HouseSpec *overridden_hs = HouseSpec::Get(i);
197 grfid_overrides[i] = 0;
214 if (entity_overrides[
id] == grf_local_id && grfid_overrides[
id] == grfid)
return id;
277 grfmsg(1,
"Industry.SetEntitySpec: Too many industries allocated. Ignoring.");
282 memcpy(&_industry_specs[ind_id], inds,
sizeof(*inds));
284 _industry_specs[ind_id].
enabled =
true;
287 void IndustryTileOverrideManager::SetEntitySpec(
const IndustryTileSpec *its)
292 grfmsg(1,
"IndustryTile.SetEntitySpec: Too many industry tiles allocated. Ignoring.");
296 memcpy(&_industry_tile_specs[indt_id], its,
sizeof(*its));
305 overridden_its->
enabled =
false;
307 grfid_overrides[i] = 0;
331 grfmsg(1,
"Object.SetEntitySpec: Too many objects allocated. Ignoring.");
338 memcpy(&_object_specs[type], spec,
sizeof(*spec));
339 ObjectClass::Assign(&_object_specs[type]);
409 default: NOT_REACHED();
411 return has_snow ? 4 : 0;
427 int8 x =
GB(parameter, 0, 4);
428 int8 y =
GB(parameter, 4, 4);
430 if (signed_offsets && x >= 8) x -= 16;
431 if (signed_offsets && y >= 8) y -= 16;
460 return tile_type << 24 |
Clamp(z, 0, 0xFF) << 16 | terrain_type << 8 | tileh;
486 if (cb_res < 0x400) {
490 case 0x400:
return res;
493 case 0x401: res =
CommandCost(default_error);
break;
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;
534 GetString(buffer, STR_NEWGRF_BUGGY,
lastof(buffer));
535 DEBUG(grf, 0,
"%s", buffer + 3);
539 GetString(buffer, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT,
lastof(buffer));
540 DEBUG(grf, 0,
"%s", buffer + 3);
556 if (grffile->grf_version < 8)
return cb_res != 0;
575 if (grffile->grf_version < 8)
return GB(cb_res, 0, 8) != 0;
590 assert(this->
seq == NULL);
591 assert(source != NULL);
598 MemCpyT(sprites, source, count);
610 if (source->registers != NULL) {
616 MemCpyT(regs, source->registers, count);
617 this->registers = regs;
628 assert(this->
seq == NULL);
640 assert(this->
seq != NULL);
641 assert(this->registers == NULL);
647 this->registers = CallocT<TileLayoutRegisters>(count);
665 uint32 var10_values = 0;
687 if (regs != NULL) flags = regs->
flags;
692 SetBit(var10_values, var10);
698 result->image.
sprite += ground ? newgrf_ground_offset : newgrf_offset;
701 result->image.
sprite += orig_offset;
708 SetBit(var10_values, var10);
714 result->image.
sprite += ground ? newgrf_ground_offset : newgrf_offset;
720 if (regs != NULL) regs++;
741 if (regs != NULL) flags = regs->
flags;
747 if (var10 == resolved_var10) {
756 result->image.
sprite += offset;
758 result->image.
sprite = SPR_IMG_QUERY;
780 if (var10 == resolved_var10) {
786 result->image.
pal += offset;
788 result->image.
sprite = SPR_IMG_QUERY;
789 result->image.
pal = PAL_NONE;
796 if (regs != NULL) regs++;