947 dts->seq = NULL; |
947 dts->seq = NULL; |
948 dts->ground_sprite = grf_load_word(&buf); |
948 dts->ground_sprite = grf_load_word(&buf); |
949 dts->ground_pal = grf_load_word(&buf); |
949 dts->ground_pal = grf_load_word(&buf); |
950 if (dts->ground_sprite == 0) continue; |
950 if (dts->ground_sprite == 0) continue; |
951 if (HasBit(dts->ground_pal, 15)) { |
951 if (HasBit(dts->ground_pal, 15)) { |
952 CLRBIT(dts->ground_pal, 15); |
952 ClrBit(dts->ground_pal, 15); |
953 SETBIT(dts->ground_sprite, SPRITE_MODIFIER_USE_OFFSET); |
953 SETBIT(dts->ground_sprite, SPRITE_MODIFIER_USE_OFFSET); |
954 } |
954 } |
955 |
955 |
956 while (buf < *bufp + len) { |
956 while (buf < *bufp + len) { |
957 DrawTileSeqStruct *dtss; |
957 DrawTileSeqStruct *dtss; |
970 dtss->image = grf_load_word(&buf); |
970 dtss->image = grf_load_word(&buf); |
971 dtss->pal = grf_load_word(&buf); |
971 dtss->pal = grf_load_word(&buf); |
972 |
972 |
973 /* Remap flags as ours collide */ |
973 /* Remap flags as ours collide */ |
974 if (HasBit(dtss->pal, 15)) { |
974 if (HasBit(dtss->pal, 15)) { |
975 CLRBIT(dtss->pal, 15); |
975 ClrBit(dtss->pal, 15); |
976 SETBIT(dtss->image, SPRITE_MODIFIER_USE_OFFSET); |
976 SETBIT(dtss->image, SPRITE_MODIFIER_USE_OFFSET); |
977 } |
977 } |
978 |
978 |
979 if (HasBit(dtss->image, 15)) { |
979 if (HasBit(dtss->image, 15)) { |
980 CLRBIT(dtss->image, 15); |
980 ClrBit(dtss->image, 15); |
981 SETBIT(dtss->image, PALETTE_MODIFIER_COLOR); |
981 SETBIT(dtss->image, PALETTE_MODIFIER_COLOR); |
982 } |
982 } |
983 if (HasBit(dtss->image, 14)) { |
983 if (HasBit(dtss->image, 14)) { |
984 CLRBIT(dtss->image, 14); |
984 ClrBit(dtss->image, 14); |
985 SETBIT(dtss->image, PALETTE_MODIFIER_TRANSPARENT); |
985 SETBIT(dtss->image, PALETTE_MODIFIER_TRANSPARENT); |
986 } |
986 } |
987 } |
987 } |
988 } |
988 } |
989 break; |
989 break; |
1572 cs->bitnum = grf_load_byte(&buf); |
1572 cs->bitnum = grf_load_byte(&buf); |
1573 if (cs->IsValid()) { |
1573 if (cs->IsValid()) { |
1574 cs->grfid = _cur_grffile->grfid; |
1574 cs->grfid = _cur_grffile->grfid; |
1575 SETBIT(_cargo_mask, cid + i); |
1575 SETBIT(_cargo_mask, cid + i); |
1576 } else { |
1576 } else { |
1577 CLRBIT(_cargo_mask, cid + i); |
1577 ClrBit(_cargo_mask, cid + i); |
1578 } |
1578 } |
1579 break; |
1579 break; |
1580 |
1580 |
1581 case 0x09: /* String ID for cargo type name */ |
1581 case 0x09: /* String ID for cargo type name */ |
1582 cs->name = grf_load_word(&buf); |
1582 cs->name = grf_load_word(&buf); |
2581 /* Groundsprite */ |
2581 /* Groundsprite */ |
2582 group->g.layout.dts->ground_sprite = grf_load_word(&buf); |
2582 group->g.layout.dts->ground_sprite = grf_load_word(&buf); |
2583 group->g.layout.dts->ground_pal = grf_load_word(&buf); |
2583 group->g.layout.dts->ground_pal = grf_load_word(&buf); |
2584 /* Remap transparent/colour modifier bits */ |
2584 /* Remap transparent/colour modifier bits */ |
2585 if (HasBit(group->g.layout.dts->ground_sprite, 14)) { |
2585 if (HasBit(group->g.layout.dts->ground_sprite, 14)) { |
2586 CLRBIT(group->g.layout.dts->ground_sprite, 14); |
2586 ClrBit(group->g.layout.dts->ground_sprite, 14); |
2587 SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT); |
2587 SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT); |
2588 } |
2588 } |
2589 if (HasBit(group->g.layout.dts->ground_sprite, 15)) { |
2589 if (HasBit(group->g.layout.dts->ground_sprite, 15)) { |
2590 CLRBIT(group->g.layout.dts->ground_sprite, 15); |
2590 ClrBit(group->g.layout.dts->ground_sprite, 15); |
2591 SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_COLOR); |
2591 SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_COLOR); |
2592 } |
2592 } |
2593 if (HasBit(group->g.layout.dts->ground_pal, 14)) { |
2593 if (HasBit(group->g.layout.dts->ground_pal, 14)) { |
2594 CLRBIT(group->g.layout.dts->ground_pal, 14); |
2594 ClrBit(group->g.layout.dts->ground_pal, 14); |
2595 SETBIT(group->g.layout.dts->ground_sprite, SPRITE_MODIFIER_OPAQUE); |
2595 SETBIT(group->g.layout.dts->ground_sprite, SPRITE_MODIFIER_OPAQUE); |
2596 } |
2596 } |
2597 if (HasBit(group->g.layout.dts->ground_pal, 15)) { |
2597 if (HasBit(group->g.layout.dts->ground_pal, 15)) { |
2598 /* Bit 31 set means this is a custom sprite, so rewrite it to the |
2598 /* Bit 31 set means this is a custom sprite, so rewrite it to the |
2599 * last spriteset defined. */ |
2599 * last spriteset defined. */ |
2600 SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground_sprite, 0, 14) * sprites; |
2600 SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground_sprite, 0, 14) * sprites; |
2601 SB(group->g.layout.dts->ground_sprite, 0, SPRITE_WIDTH, sprite); |
2601 SB(group->g.layout.dts->ground_sprite, 0, SPRITE_WIDTH, sprite); |
2602 CLRBIT(group->g.layout.dts->ground_pal, 15); |
2602 ClrBit(group->g.layout.dts->ground_pal, 15); |
2603 } |
2603 } |
2604 |
2604 |
2605 group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1); |
2605 group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1); |
2606 |
2606 |
2607 for (i = 0; i < num_sprites; i++) { |
2607 for (i = 0; i < num_sprites; i++) { |
2611 seq->pal = grf_load_word(&buf); |
2611 seq->pal = grf_load_word(&buf); |
2612 seq->delta_x = grf_load_byte(&buf); |
2612 seq->delta_x = grf_load_byte(&buf); |
2613 seq->delta_y = grf_load_byte(&buf); |
2613 seq->delta_y = grf_load_byte(&buf); |
2614 |
2614 |
2615 if (HasBit(seq->image, 14)) { |
2615 if (HasBit(seq->image, 14)) { |
2616 CLRBIT(seq->image, 14); |
2616 ClrBit(seq->image, 14); |
2617 SETBIT(seq->image, PALETTE_MODIFIER_TRANSPARENT); |
2617 SETBIT(seq->image, PALETTE_MODIFIER_TRANSPARENT); |
2618 } |
2618 } |
2619 if (HasBit(seq->image, 15)) { |
2619 if (HasBit(seq->image, 15)) { |
2620 CLRBIT(seq->image, 15); |
2620 ClrBit(seq->image, 15); |
2621 SETBIT(seq->image, PALETTE_MODIFIER_COLOR); |
2621 SETBIT(seq->image, PALETTE_MODIFIER_COLOR); |
2622 } |
2622 } |
2623 if (HasBit(seq->pal, 14)) { |
2623 if (HasBit(seq->pal, 14)) { |
2624 CLRBIT(seq->pal, 14); |
2624 ClrBit(seq->pal, 14); |
2625 SETBIT(seq->image, SPRITE_MODIFIER_OPAQUE); |
2625 SETBIT(seq->image, SPRITE_MODIFIER_OPAQUE); |
2626 } |
2626 } |
2627 if (HasBit(seq->pal, 15)) { |
2627 if (HasBit(seq->pal, 15)) { |
2628 /* Bit 31 set means this is a custom sprite, so rewrite it to the |
2628 /* Bit 31 set means this is a custom sprite, so rewrite it to the |
2629 * last spriteset defined. */ |
2629 * last spriteset defined. */ |
2630 SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image, 0, 14) * sprites; |
2630 SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image, 0, 14) * sprites; |
2631 SB(seq->image, 0, SPRITE_WIDTH, sprite); |
2631 SB(seq->image, 0, SPRITE_WIDTH, sprite); |
2632 CLRBIT(seq->pal, 15); |
2632 ClrBit(seq->pal, 15); |
2633 } |
2633 } |
2634 |
2634 |
2635 if (type > 0) { |
2635 if (type > 0) { |
2636 seq->delta_z = grf_load_byte(&buf); |
2636 seq->delta_z = grf_load_byte(&buf); |
2637 if ((byte)seq->delta_z == 0x80) continue; |
2637 if ((byte)seq->delta_z == 0x80) continue; |
3113 uint8 lang = grf_load_byte(&buf); |
3113 uint8 lang = grf_load_byte(&buf); |
3114 uint8 num = grf_load_byte(&buf); |
3114 uint8 num = grf_load_byte(&buf); |
3115 bool generic = HasBit(lang, 7); |
3115 bool generic = HasBit(lang, 7); |
3116 uint16 id = generic ? grf_load_word(&buf) : grf_load_byte(&buf); |
3116 uint16 id = generic ? grf_load_word(&buf) : grf_load_byte(&buf); |
3117 |
3117 |
3118 CLRBIT(lang, 7); |
3118 ClrBit(lang, 7); |
3119 |
3119 |
3120 if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { |
3120 if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { |
3121 id += _vehshifts[feature]; |
3121 id += _vehshifts[feature]; |
3122 } |
3122 } |
3123 uint16 endid = id + num; |
3123 uint16 endid = id + num; |
3255 buf++; |
3255 buf++; |
3256 uint8 type = grf_load_byte(&buf); |
3256 uint8 type = grf_load_byte(&buf); |
3257 uint16 num = grf_load_extended(&buf); |
3257 uint16 num = grf_load_extended(&buf); |
3258 uint16 skip_num = 0; |
3258 uint16 skip_num = 0; |
3259 uint16 offset = HasBit(type, 7) ? grf_load_extended(&buf) : 0; |
3259 uint16 offset = HasBit(type, 7) ? grf_load_extended(&buf) : 0; |
3260 CLRBIT(type, 7); // Clear the high bit as that only indicates whether there is an offset. |
3260 ClrBit(type, 7); // Clear the high bit as that only indicates whether there is an offset. |
3261 |
3261 |
3262 switch (type) { |
3262 switch (type) { |
3263 case 0x04: // Signal graphics |
3263 case 0x04: // Signal graphics |
3264 if (num != PRESIGNAL_SPRITE_COUNT && num != PRESIGNAL_AND_SEMAPHORE_SPRITE_COUNT && num != PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT) { |
3264 if (num != PRESIGNAL_SPRITE_COUNT && num != PRESIGNAL_AND_SEMAPHORE_SPRITE_COUNT && num != PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT) { |
3265 grfmsg(1, "GraphicsNew: Signal graphics sprite count must be 48, 112 or 240, skipping"); |
3265 grfmsg(1, "GraphicsNew: Signal graphics sprite count must be 48, 112 or 240, skipping"); |
3872 * is set. */ |
3872 * is set. */ |
3873 if (!HasBit(severity, 7) && _cur_stage == GLS_INIT) { |
3873 if (!HasBit(severity, 7) && _cur_stage == GLS_INIT) { |
3874 grfmsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage %d", _cur_stage); |
3874 grfmsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage %d", _cur_stage); |
3875 return; |
3875 return; |
3876 } |
3876 } |
3877 CLRBIT(severity, 7); |
3877 ClrBit(severity, 7); |
3878 |
3878 |
3879 if (severity >= lengthof(sevstr)) { |
3879 if (severity >= lengthof(sevstr)) { |
3880 grfmsg(7, "GRFLoadError: Invalid severity id %d. Setting to 2 (non-fatal error).", severity); |
3880 grfmsg(7, "GRFLoadError: Invalid severity id %d. Setting to 2 (non-fatal error).", severity); |
3881 severity = 2; |
3881 severity = 2; |
3882 } else if (severity == 3) { |
3882 } else if (severity == 3) { |
4369 len--; |
4369 len--; |
4370 grfmsg(6, "FeatureTownName: definition 0x%02X", id & 0x7F); |
4370 grfmsg(6, "FeatureTownName: definition 0x%02X", id & 0x7F); |
4371 |
4371 |
4372 if (HasBit(id, 7)) { |
4372 if (HasBit(id, 7)) { |
4373 /* Final definition */ |
4373 /* Final definition */ |
4374 CLRBIT(id, 7); |
4374 ClrBit(id, 7); |
4375 bool new_scheme = _cur_grffile->grf_version >= 7; |
4375 bool new_scheme = _cur_grffile->grf_version >= 7; |
4376 |
4376 |
4377 if (!check_length(len, 1, "FeatureTownName: lang_id")) return; |
4377 if (!check_length(len, 1, "FeatureTownName: lang_id")) return; |
4378 byte lang = grf_load_byte(&buf); |
4378 byte lang = grf_load_byte(&buf); |
4379 len--; |
4379 len--; |
4380 |
4380 |
4381 byte nb_gen = townname->nb_gen; |
4381 byte nb_gen = townname->nb_gen; |
4382 do { |
4382 do { |
4383 CLRBIT(lang, 7); |
4383 ClrBit(lang, 7); |
4384 |
4384 |
4385 if (!check_length(len, 1, "FeatureTownName: style name")) return; |
4385 if (!check_length(len, 1, "FeatureTownName: style name")) return; |
4386 const char *name = grf_load_string(&buf, len); |
4386 const char *name = grf_load_string(&buf, len); |
4387 len -= strlen(name) + 1; |
4387 len -= strlen(name) + 1; |
4388 grfmsg(6, "FeatureTownName: lang 0x%X -> '%s'", lang, TranslateTTDPatchCodes(name)); |
4388 grfmsg(6, "FeatureTownName: lang 0x%X -> '%s'", lang, TranslateTTDPatchCodes(name)); |
5605 if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid); |
5605 if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid); |
5606 LoadNewGRFFile(c, slot++, stage); |
5606 LoadNewGRFFile(c, slot++, stage); |
5607 if (stage == GLS_RESERVE) { |
5607 if (stage == GLS_RESERVE) { |
5608 SETBIT(c->flags, GCF_RESERVED); |
5608 SETBIT(c->flags, GCF_RESERVED); |
5609 } else if (stage == GLS_ACTIVATION) { |
5609 } else if (stage == GLS_ACTIVATION) { |
5610 CLRBIT(c->flags, GCF_RESERVED); |
5610 ClrBit(c->flags, GCF_RESERVED); |
5611 ClearTemporaryNewGRFData(); |
5611 ClearTemporaryNewGRFData(); |
5612 BuildCargoTranslationMap(); |
5612 BuildCargoTranslationMap(); |
5613 DEBUG(sprite, 2, "LoadNewGRF: Currently %i sprites are loaded", _cur_spriteid); |
5613 DEBUG(sprite, 2, "LoadNewGRF: Currently %i sprites are loaded", _cur_spriteid); |
5614 } |
5614 } |
5615 } |
5615 } |