src/newgrf.cpp
changeset 7772 c89384e3f8de
parent 7757 3e63b119a5bf
child 7780 12ef69de4e60
equal deleted inserted replaced
7771:a900b80b48f2 7772:c89384e3f8de
    43 #include "newgrf_canal.h"
    43 #include "newgrf_canal.h"
    44 #include "table/build_industry.h"
    44 #include "table/build_industry.h"
    45 #include "newgrf_commons.h"
    45 #include "newgrf_commons.h"
    46 #include "newgrf_townname.h"
    46 #include "newgrf_townname.h"
    47 #include "newgrf_industries.h"
    47 #include "newgrf_industries.h"
       
    48 #include "table/landscape_sprite.h"
       
    49 #include "gfxinit.h"
    48 
    50 
    49 /* TTDPatch extended GRF format codec
    51 /* TTDPatch extended GRF format codec
    50  * (c) Petr Baudis 2004 (GPL'd)
    52  * (c) Petr Baudis 2004 (GPL'd)
    51  * Changes by Florian octo Forster are (c) by the OpenTTD development team.
    53  * Changes by Florian octo Forster are (c) by the OpenTTD development team.
    52  *
    54  *
  3230 	 * E num-sprites   How many sprites are in this set?
  3232 	 * E num-sprites   How many sprites are in this set?
  3231 	 * V other data    Graphics type specific data.  Currently unused. */
  3233 	 * V other data    Graphics type specific data.  Currently unused. */
  3232 	/* TODO */
  3234 	/* TODO */
  3233 
  3235 
  3234 	SpriteID replace = 0;
  3236 	SpriteID replace = 0;
       
  3237 	const SpriteID *index_tbl = NULL;
  3235 
  3238 
  3236 	if (!check_length(len, 2, "GraphicsNew")) return;
  3239 	if (!check_length(len, 2, "GraphicsNew")) return;
  3237 	buf++;
  3240 	buf++;
  3238 	uint8 type = grf_load_byte(&buf);
  3241 	uint8 type = grf_load_byte(&buf);
  3239 	uint16 num = grf_load_extended(&buf);
  3242 	uint16 num = grf_load_extended(&buf);
  3254 			}
  3257 			}
  3255 			replace = SPR_ELRAIL_BASE + 3;
  3258 			replace = SPR_ELRAIL_BASE + 3;
  3256 			break;
  3259 			break;
  3257 
  3260 
  3258 		case 0x06: // Foundations
  3261 		case 0x06: // Foundations
  3259 			if (num != 74) {
  3262 			switch (num) {
  3260 				grfmsg(1, "GraphicsNew: Foundation graphics sprite count must be 74, skipping");
  3263 				case 74: replace = SPR_SLOPES_BASE; break;
  3261 				return;
  3264 				case 90: index_tbl = _slopes_action05_90; break;
       
  3265 				default:
       
  3266 					grfmsg(1, "GraphicsNew: Foundation graphics sprite count must be 74 or 90, skipping");
       
  3267 					return;
  3262 			}
  3268 			}
  3263 			replace = SPR_SLOPES_BASE;
       
  3264 			break;
  3269 			break;
  3265 
  3270 
  3266 		case 0x08: // Canal graphics
  3271 		case 0x08: // Canal graphics
  3267 			if (num != 65) {
  3272 			if (num != 65) {
  3268 				grfmsg(1, "GraphicsNew: Canal graphics sprite count must be 65, skipping");
  3273 				grfmsg(1, "GraphicsNew: Canal graphics sprite count must be 65, skipping");
  3322 		default:
  3327 		default:
  3323 			grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)",
  3328 			grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)",
  3324 					type, num);
  3329 					type, num);
  3325 			_skip_sprites = num;
  3330 			_skip_sprites = num;
  3326 			return;
  3331 			return;
       
  3332 	}
       
  3333 
       
  3334 	if (index_tbl != NULL) {
       
  3335 		grfmsg(2, "GraphicsNew: Loading %u sprites of type 0x%02X at indexed SpriteIDs", num, type);
       
  3336 		LoadSpritesIndexed(_file_index, &_nfo_line, index_tbl);
       
  3337 		return;
  3327 	}
  3338 	}
  3328 
  3339 
  3329 	if (replace == 0) {
  3340 	if (replace == 0) {
  3330 		grfmsg(2, "GraphicsNew: Loading %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, _cur_spriteid);
  3341 		grfmsg(2, "GraphicsNew: Loading %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, _cur_spriteid);
  3331 	} else {
  3342 	} else {