225 } |
230 } |
226 return file; |
231 return file; |
227 } |
232 } |
228 |
233 |
229 |
234 |
|
235 /** Used when setting an object's property to map to the GRF's strings |
|
236 * while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one |
|
237 * @param str StringID that we want to have the equivalent in OoenTTD |
|
238 * @return the properly adjusted StringID |
|
239 */ |
|
240 static StringID MapGRFStringID(uint32 grfid, StringID str) |
|
241 { |
|
242 /* 0xD0 and 0xDC stand for all the TextIDs in the range |
|
243 * of 0xD000 (misc graphics texts) and 0xDC00 (misc persistent texts). |
|
244 * These strings are unique to each grf file, and thus require to be used with the |
|
245 * grfid in which they are declared */ |
|
246 if (GB(str, 8, 8) == 0xD0 || GB(str, 8, 8) == 0xDC) { |
|
247 return GetGRFStringID(grfid, str); |
|
248 } |
|
249 |
|
250 /* We have some changes in our cargo strings, resulting in some missing. */ |
|
251 if (str >= 0x006E && str <= 0x008D) return str - 0x20; |
|
252 if (str >= 0x008E && str <= 0x00AD) return str - 0x20; |
|
253 |
|
254 /* Map building names according to our lang file changes |
|
255 * 0x200F = Tall Office Block, first house name in the original data, the one that TTDPatch stil uses |
|
256 * 0x201F = Old houses is the last house name. |
|
257 * OpenTTD does not have exactly the same order aymore, so, the code below allows |
|
258 * to compensate for the difference */ |
|
259 if (str >= 0x200F && str <= 0x201F) return str + (STR_200F_TALL_OFFICE_BLOCK - 0x200F); |
|
260 |
|
261 return str; |
|
262 } |
|
263 |
|
264 static uint8 MapDOSColour(uint8 colour) |
|
265 { |
|
266 if (_use_dos_palette) return colour; |
|
267 |
|
268 if (colour < 10) { |
|
269 static uint8 dos_to_win_colour_map[] = { 0, 215, 216, 136, 88, 106, 32, 33, 40, 245 }; |
|
270 return dos_to_win_colour_map[colour]; |
|
271 } |
|
272 |
|
273 if (colour >= 245 && colour < 254) return colour - 28; |
|
274 |
|
275 return colour; |
|
276 } |
|
277 |
|
278 |
230 typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
279 typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
231 |
280 |
232 #define FOR_EACH_OBJECT for (i = 0; i < numinfo; i++) |
281 #define FOR_EACH_OBJECT for (i = 0; i < numinfo; i++) |
233 |
282 |
234 static void dewagonize(int condition, int engine) |
283 static void dewagonize(int condition, int engine) |
268 break; |
317 break; |
269 } |
318 } |
270 } |
319 } |
271 break; |
320 break; |
272 |
321 |
273 case 0x08: /* AI passenger service */ |
322 case 0x08: // AI passenger service |
274 /* TODO */ |
323 /* @todo missing feature */ |
275 FOR_EACH_OBJECT grf_load_byte(&buf); |
324 FOR_EACH_OBJECT grf_load_byte(&buf); |
276 ret = true; |
325 ret = true; |
277 break; |
326 break; |
278 |
327 |
279 case 0x09: /* Speed (1 unit is 1 kmh) */ |
328 case 0x09: // Speed (1 unit is 1 kmh) |
280 FOR_EACH_OBJECT { |
329 FOR_EACH_OBJECT { |
281 uint16 speed = grf_load_word(&buf); |
330 uint16 speed = grf_load_word(&buf); |
282 if (speed == 0xFFFF) speed = 0; |
331 if (speed == 0xFFFF) speed = 0; |
283 |
332 |
284 rvi[i].max_speed = speed; |
333 rvi[i].max_speed = speed; |
285 } |
334 } |
286 break; |
335 break; |
287 |
336 |
288 case 0x0B: /* Power */ |
337 case 0x0B: // Power |
289 FOR_EACH_OBJECT { |
338 FOR_EACH_OBJECT { |
290 uint16 power = grf_load_word(&buf); |
339 uint16 power = grf_load_word(&buf); |
291 |
340 |
292 if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) power /= 2; |
341 if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) power /= 2; |
293 |
342 |
294 rvi[i].power = power; |
343 rvi[i].power = power; |
295 dewagonize(power, engine + i); |
344 dewagonize(power, engine + i); |
296 } |
345 } |
297 break; |
346 break; |
298 |
347 |
299 case 0x0D: /* Running cost factor */ |
348 case 0x0D: // Running cost factor |
300 FOR_EACH_OBJECT { |
349 FOR_EACH_OBJECT { |
301 uint8 runcostfact = grf_load_byte(&buf); |
350 uint8 runcostfact = grf_load_byte(&buf); |
302 |
351 |
303 if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) runcostfact /= 2; |
352 if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) runcostfact /= 2; |
304 |
353 |
305 rvi[i].running_cost_base = runcostfact; |
354 rvi[i].running_cost_base = runcostfact; |
306 } |
355 } |
307 break; |
356 break; |
308 |
357 |
309 case 0x0E: /* Running cost base */ |
358 case 0x0E: // Running cost base |
310 FOR_EACH_OBJECT { |
359 FOR_EACH_OBJECT { |
311 uint32 base = grf_load_dword(&buf); |
360 uint32 base = grf_load_dword(&buf); |
312 |
361 |
313 switch (base) { |
362 switch (base) { |
314 case 0x4C30: rvi[i].running_cost_class = 0; break; |
363 case 0x4C30: rvi[i].running_cost_class = 0; break; |
315 case 0x4C36: rvi[i].running_cost_class = 1; break; |
364 case 0x4C36: rvi[i].running_cost_class = 1; break; |
316 case 0x4C3C: rvi[i].running_cost_class = 2; break; |
365 case 0x4C3C: rvi[i].running_cost_class = 2; break; |
317 case 0: break; /* Used by wagons */ |
366 case 0: break; // Used by wagons |
318 default: |
367 default: |
319 grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); |
368 grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); |
320 break; |
369 break; |
321 } |
370 } |
322 } |
371 } |
323 break; |
372 break; |
324 |
373 |
325 case 0x12: /* Sprite ID */ |
374 case 0x12: // Sprite ID |
326 FOR_EACH_OBJECT { |
375 FOR_EACH_OBJECT { |
327 uint8 spriteid = grf_load_byte(&buf); |
376 uint8 spriteid = grf_load_byte(&buf); |
328 |
377 |
329 /* TTD sprite IDs point to a location in a 16bit array, but we use it |
378 /* TTD sprite IDs point to a location in a 16bit array, but we use it |
330 * as an array index, so we need it to be half the original value. */ |
379 * as an array index, so we need it to be half the original value. */ |
426 grfmsg(2, "RailVehicleChangeInfo: Invalid train engine ID %d, ignoring", pos); |
475 grfmsg(2, "RailVehicleChangeInfo: Invalid train engine ID %d, ignoring", pos); |
427 } |
476 } |
428 } |
477 } |
429 break; |
478 break; |
430 |
479 |
431 case 0x1B: /* Powered wagons power bonus */ |
480 case 0x1B: // Powered wagons power bonus |
432 FOR_EACH_OBJECT rvi[i].pow_wag_power = grf_load_word(&buf); |
481 FOR_EACH_OBJECT rvi[i].pow_wag_power = grf_load_word(&buf); |
433 break; |
482 break; |
434 |
483 |
435 case 0x1C: /* Refit cost */ |
484 case 0x1C: // Refit cost |
436 FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
485 FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
437 break; |
486 break; |
438 |
487 |
439 case 0x1D: /* Refit cargo */ |
488 case 0x1D: // Refit cargo |
440 FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
489 FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
441 break; |
490 break; |
442 |
491 |
443 case 0x1E: /* Callback */ |
492 case 0x1E: // Callback |
444 FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
493 FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
445 break; |
494 break; |
446 |
495 |
447 case 0x1F: /* Tractive effort coefficient */ |
496 case 0x1F: // Tractive effort coefficient |
448 FOR_EACH_OBJECT rvi[i].tractive_effort = grf_load_byte(&buf); |
497 FOR_EACH_OBJECT rvi[i].tractive_effort = grf_load_byte(&buf); |
449 break; |
498 break; |
450 |
499 |
451 case 0x21: /* Shorter vehicle */ |
500 case 0x21: // Shorter vehicle |
452 FOR_EACH_OBJECT rvi[i].shorten_factor = grf_load_byte(&buf); |
501 FOR_EACH_OBJECT rvi[i].shorten_factor = grf_load_byte(&buf); |
453 break; |
502 break; |
454 |
503 |
455 case 0x22: /* Visual effect */ |
504 case 0x22: // Visual effect |
456 // see note in engine.h about rvi->visual_effect |
505 /* see note in engine.h about rvi->visual_effect */ |
457 FOR_EACH_OBJECT rvi[i].visual_effect = grf_load_byte(&buf); |
506 FOR_EACH_OBJECT rvi[i].visual_effect = grf_load_byte(&buf); |
458 break; |
507 break; |
459 |
508 |
460 case 0x23: /* Powered wagons weight bonus */ |
509 case 0x23: // Powered wagons weight bonus |
461 FOR_EACH_OBJECT rvi[i].pow_wag_weight = grf_load_byte(&buf); |
510 FOR_EACH_OBJECT rvi[i].pow_wag_weight = grf_load_byte(&buf); |
462 break; |
511 break; |
463 |
512 |
464 case 0x24: /* High byte of vehicle weight */ |
513 case 0x24: // High byte of vehicle weight |
465 FOR_EACH_OBJECT { |
514 FOR_EACH_OBJECT { |
466 byte weight = grf_load_byte(&buf); |
515 byte weight = grf_load_byte(&buf); |
467 |
516 |
468 if (weight > 4) { |
517 if (weight > 4) { |
469 grfmsg(2, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring", weight << 8); |
518 grfmsg(2, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring", weight << 8); |
471 SB(rvi[i].weight, 8, 8, weight); |
520 SB(rvi[i].weight, 8, 8, weight); |
472 } |
521 } |
473 } |
522 } |
474 break; |
523 break; |
475 |
524 |
476 case 0x25: /* User-defined bit mask to set when checking veh. var. 42 */ |
525 case 0x25: // User-defined bit mask to set when checking veh. var. 42 |
477 FOR_EACH_OBJECT rvi[i].user_def_data = grf_load_byte(&buf); |
526 FOR_EACH_OBJECT rvi[i].user_def_data = grf_load_byte(&buf); |
478 break; |
527 break; |
479 |
528 |
480 case 0x27: /* Miscellaneous flags */ |
529 case 0x27: // Miscellaneous flags |
481 FOR_EACH_OBJECT { |
530 FOR_EACH_OBJECT { |
482 ei[i].misc_flags = grf_load_byte(&buf); |
531 ei[i].misc_flags = grf_load_byte(&buf); |
483 if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
532 if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
484 } |
533 } |
485 break; |
534 break; |
486 |
535 |
487 case 0x28: /* Cargo classes allowed */ |
536 case 0x28: // Cargo classes allowed |
488 FOR_EACH_OBJECT cargo_allowed[engine + i] = grf_load_word(&buf); |
537 FOR_EACH_OBJECT cargo_allowed[engine + i] = grf_load_word(&buf); |
489 break; |
538 break; |
490 |
539 |
491 case 0x29: /* Cargo classes disallowed */ |
540 case 0x29: // Cargo classes disallowed |
492 FOR_EACH_OBJECT cargo_disallowed[engine + i] = grf_load_word(&buf); |
541 FOR_EACH_OBJECT cargo_disallowed[engine + i] = grf_load_word(&buf); |
493 break; |
542 break; |
494 |
543 |
495 case 0x2A: /* Long format introduction date (days since year 0) */ |
544 case 0x2A: // Long format introduction date (days since year 0) |
496 FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
545 FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
497 break; |
546 break; |
498 |
547 |
499 /* TODO */ |
548 /* @todo air drag and retire vehicle early |
500 /* Fall-through for unimplemented one byte long properties. */ |
549 * Fall-through for unimplemented one byte long properties. */ |
501 case 0x20: /* Air drag */ |
550 case 0x20: // Air drag |
502 case 0x26: /* Retire vehicle early */ |
551 case 0x26: // Retire vehicle early |
503 /* TODO */ |
|
504 FOR_EACH_OBJECT grf_load_byte(&buf); |
552 FOR_EACH_OBJECT grf_load_byte(&buf); |
505 ret = true; |
553 ret = true; |
506 break; |
554 break; |
507 |
555 |
508 default: |
556 default: |
520 byte *buf = *bufp; |
568 byte *buf = *bufp; |
521 int i; |
569 int i; |
522 bool ret = false; |
570 bool ret = false; |
523 |
571 |
524 switch (prop) { |
572 switch (prop) { |
525 case 0x08: /* Speed (1 unit is 0.5 kmh) */ |
573 case 0x08: // Speed (1 unit is 0.5 kmh) |
526 FOR_EACH_OBJECT rvi[i].max_speed = grf_load_byte(&buf); |
574 FOR_EACH_OBJECT rvi[i].max_speed = grf_load_byte(&buf); |
527 break; |
575 break; |
528 |
576 |
529 case 0x09: /* Running cost factor */ |
577 case 0x09: // Running cost factor |
530 FOR_EACH_OBJECT rvi[i].running_cost = grf_load_byte(&buf); |
578 FOR_EACH_OBJECT rvi[i].running_cost = grf_load_byte(&buf); |
531 break; |
579 break; |
532 |
580 |
533 case 0x0A: /* Running cost base */ |
581 case 0x0A: // Running cost base |
534 /* TODO: I have no idea. --pasky */ |
582 /* @todo : I have no idea. --pasky |
|
583 * I THINK it is used for overriding the base cost of all road vehicle (_price.roadveh_base) --belugas */ |
535 FOR_EACH_OBJECT grf_load_dword(&buf); |
584 FOR_EACH_OBJECT grf_load_dword(&buf); |
536 ret = true; |
585 ret = true; |
537 break; |
586 break; |
538 |
587 |
539 case 0x0E: /* Sprite ID */ |
588 case 0x0E: // Sprite ID |
540 FOR_EACH_OBJECT { |
589 FOR_EACH_OBJECT { |
541 uint8 spriteid = grf_load_byte(&buf); |
590 uint8 spriteid = grf_load_byte(&buf); |
542 |
591 |
543 // cars have different custom id in the GRF file |
592 /* cars have different custom id in the GRF file */ |
544 if (spriteid == 0xFF) spriteid = 0xFD; |
593 if (spriteid == 0xFF) spriteid = 0xFD; |
545 |
594 |
546 if (spriteid < 0xFD) spriteid >>= 1; |
595 if (spriteid < 0xFD) spriteid >>= 1; |
547 |
596 |
548 rvi[i].image_index = spriteid; |
597 rvi[i].image_index = spriteid; |
549 } |
598 } |
550 break; |
599 break; |
551 |
600 |
552 case 0x0F: /* Cargo capacity */ |
601 case 0x0F: // Cargo capacity |
553 FOR_EACH_OBJECT rvi[i].capacity = grf_load_byte(&buf); |
602 FOR_EACH_OBJECT rvi[i].capacity = grf_load_byte(&buf); |
554 break; |
603 break; |
555 |
604 |
556 case 0x10: /* Cargo type */ |
605 case 0x10: // Cargo type |
557 FOR_EACH_OBJECT { |
606 FOR_EACH_OBJECT { |
558 uint8 cargo = grf_load_byte(&buf); |
607 uint8 cargo = grf_load_byte(&buf); |
559 |
608 |
560 if (cargo < NUM_CARGO && HASBIT(_cargo_mask, cargo)) { |
609 if (cargo < NUM_CARGO && HASBIT(_cargo_mask, cargo)) { |
561 rvi[i].cargo_type = cargo; |
610 rvi[i].cargo_type = cargo; |
564 grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
613 grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
565 } |
614 } |
566 } |
615 } |
567 break; |
616 break; |
568 |
617 |
569 case 0x11: /* Cost factor */ |
618 case 0x11: // Cost factor |
570 FOR_EACH_OBJECT rvi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
619 FOR_EACH_OBJECT rvi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
571 break; |
620 break; |
572 |
621 |
573 case 0x12: /* SFX */ |
622 case 0x12: // SFX |
574 FOR_EACH_OBJECT rvi[i].sfx = (SoundFx)grf_load_byte(&buf); |
623 FOR_EACH_OBJECT rvi[i].sfx = (SoundFx)grf_load_byte(&buf); |
575 break; |
624 break; |
576 |
625 |
577 case 0x13: /* Power in 10hp */ |
626 case 0x13: // Power in 10hp |
578 case 0x14: /* Weight in 1/4 tons */ |
627 case 0x14: // Weight in 1/4 tons |
579 case 0x15: /* Speed in mph*0.8 */ |
628 case 0x15: // Speed in mph*0.8 |
580 /* TODO: Support for road vehicles realistic power |
629 /* TODO: Support for road vehicles realistic power |
581 * computations (called rvpower in TTDPatch) is just |
630 * computations (called rvpower in TTDPatch) is just |
582 * missing in OTTD yet. --pasky */ |
631 * missing in OTTD yet. --pasky */ |
583 FOR_EACH_OBJECT grf_load_byte(&buf); |
632 FOR_EACH_OBJECT grf_load_byte(&buf); |
584 ret = true; |
633 ret = true; |
585 break; |
634 break; |
586 |
635 |
587 case 0x16: /* Cargos available for refitting */ |
636 case 0x16: // Cargos available for refitting |
588 FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
637 FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
589 break; |
638 break; |
590 |
639 |
591 case 0x17: /* Callback mask */ |
640 case 0x17: // Callback mask |
592 FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
641 FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
593 break; |
642 break; |
594 |
643 |
595 case 0x1A: /* Refit cost */ |
644 case 0x1A: // Refit cost |
596 FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
645 FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
597 break; |
646 break; |
598 |
647 |
599 case 0x1C: /* Miscellaneous flags */ |
648 case 0x1C: // Miscellaneous flags |
600 FOR_EACH_OBJECT { |
649 FOR_EACH_OBJECT { |
601 ei[i].misc_flags = grf_load_byte(&buf); |
650 ei[i].misc_flags = grf_load_byte(&buf); |
602 if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
651 if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
603 } |
652 } |
604 break; |
653 break; |
605 |
654 |
606 case 0x1D: /* Cargo classes allowed */ |
655 case 0x1D: // Cargo classes allowed |
607 FOR_EACH_OBJECT cargo_allowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
656 FOR_EACH_OBJECT cargo_allowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
608 break; |
657 break; |
609 |
658 |
610 case 0x1E: /* Cargo classes disallowed */ |
659 case 0x1E: // Cargo classes disallowed |
611 FOR_EACH_OBJECT cargo_disallowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
660 FOR_EACH_OBJECT cargo_disallowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
612 break; |
661 break; |
613 |
662 |
614 case 0x1F: /* Long format introduction date (days since year 0) */ |
663 case 0x1F: // Long format introduction date (days since year 0) |
615 FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
664 FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
616 break; |
665 break; |
617 |
666 |
618 case 0x18: /* Tractive effort */ |
667 case 0x18: // Tractive effort |
619 case 0x19: /* Air drag */ |
668 case 0x19: // Air drag |
620 case 0x1B: /* Retire vehicle early */ |
669 case 0x1B: // Retire vehicle early |
621 /* TODO */ |
670 /* @todo */ |
622 FOR_EACH_OBJECT grf_load_byte(&buf); |
671 FOR_EACH_OBJECT grf_load_byte(&buf); |
623 ret = true; |
672 ret = true; |
624 break; |
673 break; |
625 |
674 |
626 default: |
675 default: |
640 int i; |
689 int i; |
641 bool ret = false; |
690 bool ret = false; |
642 |
691 |
643 //printf("e %x prop %x?\n", engine, prop); |
692 //printf("e %x prop %x?\n", engine, prop); |
644 switch (prop) { |
693 switch (prop) { |
645 case 0x08: /* Sprite ID */ |
694 case 0x08: // Sprite ID |
646 FOR_EACH_OBJECT { |
695 FOR_EACH_OBJECT { |
647 uint8 spriteid = grf_load_byte(&buf); |
696 uint8 spriteid = grf_load_byte(&buf); |
648 |
697 |
649 // ships have different custom id in the GRF file |
698 /* ships have different custom id in the GRF file */ |
650 if (spriteid == 0xFF) spriteid = 0xFD; |
699 if (spriteid == 0xFF) spriteid = 0xFD; |
651 |
700 |
652 if (spriteid < 0xFD) spriteid >>= 1; |
701 if (spriteid < 0xFD) spriteid >>= 1; |
653 |
702 |
654 svi[i].image_index = spriteid; |
703 svi[i].image_index = spriteid; |
655 } |
704 } |
656 break; |
705 break; |
657 |
706 |
658 case 0x09: /* Refittable */ |
707 case 0x09: // Refittable |
659 FOR_EACH_OBJECT svi[i].refittable = (grf_load_byte(&buf) != 0); |
708 FOR_EACH_OBJECT svi[i].refittable = (grf_load_byte(&buf) != 0); |
660 break; |
709 break; |
661 |
710 |
662 case 0x0A: /* Cost factor */ |
711 case 0x0A: // Cost factor |
663 FOR_EACH_OBJECT svi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
712 FOR_EACH_OBJECT svi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
664 break; |
713 break; |
665 |
714 |
666 case 0x0B: /* Speed (1 unit is 0.5 kmh) */ |
715 case 0x0B: // Speed (1 unit is 0.5 kmh) |
667 FOR_EACH_OBJECT svi[i].max_speed = grf_load_byte(&buf); |
716 FOR_EACH_OBJECT svi[i].max_speed = grf_load_byte(&buf); |
668 break; |
717 break; |
669 |
718 |
670 case 0x0C: /* Cargo type */ |
719 case 0x0C: // Cargo type |
671 FOR_EACH_OBJECT { |
720 FOR_EACH_OBJECT { |
672 uint8 cargo = grf_load_byte(&buf); |
721 uint8 cargo = grf_load_byte(&buf); |
673 |
722 |
674 if (cargo < NUM_CARGO && HASBIT(_cargo_mask, cargo)) { |
723 if (cargo < NUM_CARGO && HASBIT(_cargo_mask, cargo)) { |
675 svi[i].cargo_type = cargo; |
724 svi[i].cargo_type = cargo; |
678 grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
727 grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
679 } |
728 } |
680 } |
729 } |
681 break; |
730 break; |
682 |
731 |
683 case 0x0D: /* Cargo capacity */ |
732 case 0x0D: // Cargo capacity |
684 FOR_EACH_OBJECT svi[i].capacity = grf_load_word(&buf); |
733 FOR_EACH_OBJECT svi[i].capacity = grf_load_word(&buf); |
685 break; |
734 break; |
686 |
735 |
687 case 0x0F: /* Running cost factor */ |
736 case 0x0F: // Running cost factor |
688 FOR_EACH_OBJECT svi[i].running_cost = grf_load_byte(&buf); |
737 FOR_EACH_OBJECT svi[i].running_cost = grf_load_byte(&buf); |
689 break; |
738 break; |
690 |
739 |
691 case 0x10: /* SFX */ |
740 case 0x10: // SFX |
692 FOR_EACH_OBJECT svi[i].sfx = (SoundFx)grf_load_byte(&buf); |
741 FOR_EACH_OBJECT svi[i].sfx = (SoundFx)grf_load_byte(&buf); |
693 break; |
742 break; |
694 |
743 |
695 case 0x11: /* Cargos available for refitting */ |
744 case 0x11: // Cargos available for refitting |
696 FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
745 FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
697 break; |
746 break; |
698 |
747 |
699 case 0x12: /* Callback mask */ |
748 case 0x12: // Callback mask |
700 FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
749 FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
701 break; |
750 break; |
702 |
751 |
703 case 0x13: /* Refit cost */ |
752 case 0x13: // Refit cost |
704 FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
753 FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
705 break; |
754 break; |
706 |
755 |
707 case 0x17: /* Miscellaneous flags */ |
756 case 0x17: // Miscellaneous flags |
708 FOR_EACH_OBJECT { |
757 FOR_EACH_OBJECT { |
709 ei[i].misc_flags = grf_load_byte(&buf); |
758 ei[i].misc_flags = grf_load_byte(&buf); |
710 if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
759 if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
711 } |
760 } |
712 break; |
761 break; |
713 |
762 |
714 case 0x18: /* Cargo classes allowed */ |
763 case 0x18: // Cargo classes allowed |
715 FOR_EACH_OBJECT cargo_allowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
764 FOR_EACH_OBJECT cargo_allowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
716 break; |
765 break; |
717 |
766 |
718 case 0x19: /* Cargo classes disallowed */ |
767 case 0x19: // Cargo classes disallowed |
719 FOR_EACH_OBJECT cargo_disallowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
768 FOR_EACH_OBJECT cargo_disallowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
720 break; |
769 break; |
721 |
770 |
722 case 0x1A: /* Long format introduction date (days since year 0) */ |
771 case 0x1A: // Long format introduction date (days since year 0) |
723 FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
772 FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
724 break; |
773 break; |
725 |
774 |
726 case 0x14: /* Ocean speed fraction */ |
775 case 0x14: // Ocean speed fraction |
727 case 0x15: /* Canal speed fraction */ |
776 case 0x15: // Canal speed fraction |
728 case 0x16: /* Retire vehicle early */ |
777 case 0x16: // Retire vehicle early |
729 /* TODO */ |
778 /* @todo */ |
730 FOR_EACH_OBJECT grf_load_byte(&buf); |
779 FOR_EACH_OBJECT grf_load_byte(&buf); |
731 ret = true; |
780 ret = true; |
732 break; |
781 break; |
733 |
782 |
734 default: |
783 default: |
748 int i; |
797 int i; |
749 bool ret = false; |
798 bool ret = false; |
750 |
799 |
751 //printf("e %x prop %x?\n", engine, prop); |
800 //printf("e %x prop %x?\n", engine, prop); |
752 switch (prop) { |
801 switch (prop) { |
753 case 0x08: /* Sprite ID */ |
802 case 0x08: // Sprite ID |
754 FOR_EACH_OBJECT { |
803 FOR_EACH_OBJECT { |
755 uint8 spriteid = grf_load_byte(&buf); |
804 uint8 spriteid = grf_load_byte(&buf); |
756 |
805 |
757 // aircraft have different custom id in the GRF file |
806 /* aircraft have different custom id in the GRF file */ |
758 if (spriteid == 0xFF) spriteid = 0xFD; |
807 if (spriteid == 0xFF) spriteid = 0xFD; |
759 |
808 |
760 if (spriteid < 0xFD) spriteid >>= 1; |
809 if (spriteid < 0xFD) spriteid >>= 1; |
761 |
810 |
762 avi[i].image_index = spriteid; |
811 avi[i].image_index = spriteid; |
763 } |
812 } |
764 break; |
813 break; |
765 |
814 |
766 case 0x09: /* Helicopter */ |
815 case 0x09: // Helicopter |
767 FOR_EACH_OBJECT { |
816 FOR_EACH_OBJECT { |
768 if (grf_load_byte(&buf) == 0) { |
817 if (grf_load_byte(&buf) == 0) { |
769 avi[i].subtype = AIR_HELI; |
818 avi[i].subtype = AIR_HELI; |
770 } else { |
819 } else { |
771 SB(avi[i].subtype, 0, 1, 1); // AIR_CTOL |
820 SB(avi[i].subtype, 0, 1, 1); // AIR_CTOL |
772 } |
821 } |
773 } |
822 } |
774 break; |
823 break; |
775 |
824 |
776 case 0x0A: /* Large */ |
825 case 0x0A: // Large |
777 FOR_EACH_OBJECT SB(avi[i].subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); // AIR_FAST |
826 FOR_EACH_OBJECT SB(avi[i].subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); // AIR_FAST |
778 break; |
827 break; |
779 |
828 |
780 case 0x0B: /* Cost factor */ |
829 case 0x0B: // Cost factor |
781 FOR_EACH_OBJECT avi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
830 FOR_EACH_OBJECT avi[i].base_cost = grf_load_byte(&buf); // ?? is it base_cost? |
782 break; |
831 break; |
783 |
832 |
784 case 0x0C: /* Speed (1 unit is 8 mph, we translate to 1 unit is 1 km/h) */ |
833 case 0x0C: // Speed (1 unit is 8 mph, we translate to 1 unit is 1 km/h) |
785 FOR_EACH_OBJECT avi[i].max_speed = (grf_load_byte(&buf) * 129) / 10; |
834 FOR_EACH_OBJECT avi[i].max_speed = (grf_load_byte(&buf) * 129) / 10; |
786 break; |
835 break; |
787 |
836 |
788 case 0x0D: /* Acceleration */ |
837 case 0x0D: // Acceleration |
789 FOR_EACH_OBJECT avi[i].acceleration = (grf_load_byte(&buf) * 129) / 10; |
838 FOR_EACH_OBJECT avi[i].acceleration = (grf_load_byte(&buf) * 129) / 10; |
790 break; |
839 break; |
791 |
840 |
792 case 0x0E: /* Running cost factor */ |
841 case 0x0E: // Running cost factor |
793 FOR_EACH_OBJECT avi[i].running_cost = grf_load_byte(&buf); |
842 FOR_EACH_OBJECT avi[i].running_cost = grf_load_byte(&buf); |
794 break; |
843 break; |
795 |
844 |
796 case 0x0F: /* Passenger capacity */ |
845 case 0x0F: // Passenger capacity |
797 FOR_EACH_OBJECT avi[i].passenger_capacity = grf_load_word(&buf); |
846 FOR_EACH_OBJECT avi[i].passenger_capacity = grf_load_word(&buf); |
798 break; |
847 break; |
799 |
848 |
800 case 0x11: /* Mail capacity */ |
849 case 0x11: // Mail capacity |
801 FOR_EACH_OBJECT avi[i].mail_capacity = grf_load_byte(&buf); |
850 FOR_EACH_OBJECT avi[i].mail_capacity = grf_load_byte(&buf); |
802 break; |
851 break; |
803 |
852 |
804 case 0x12: /* SFX */ |
853 case 0x12: // SFX |
805 FOR_EACH_OBJECT avi[i].sfx = (SoundFx)grf_load_byte(&buf); |
854 FOR_EACH_OBJECT avi[i].sfx = (SoundFx)grf_load_byte(&buf); |
806 break; |
855 break; |
807 |
856 |
808 case 0x13: /* Cargos available for refitting */ |
857 case 0x13: // Cargos available for refitting |
809 FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
858 FOR_EACH_OBJECT ei[i].refit_mask = grf_load_dword(&buf); |
810 break; |
859 break; |
811 |
860 |
812 case 0x14: /* Callback mask */ |
861 case 0x14: // Callback mask |
813 FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
862 FOR_EACH_OBJECT ei[i].callbackmask = grf_load_byte(&buf); |
814 break; |
863 break; |
815 |
864 |
816 case 0x15: /* Refit cost */ |
865 case 0x15: // Refit cost |
817 FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
866 FOR_EACH_OBJECT ei[i].refit_cost = grf_load_byte(&buf); |
818 break; |
867 break; |
819 |
868 |
820 case 0x17: /* Miscellaneous flags */ |
869 case 0x17: // Miscellaneous flags |
821 FOR_EACH_OBJECT { |
870 FOR_EACH_OBJECT { |
822 ei[i].misc_flags = grf_load_byte(&buf); |
871 ei[i].misc_flags = grf_load_byte(&buf); |
823 if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
872 if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; |
824 } |
873 } |
825 break; |
874 break; |
826 |
875 |
827 case 0x18: /* Cargo classes allowed */ |
876 case 0x18: // Cargo classes allowed |
828 FOR_EACH_OBJECT cargo_allowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
877 FOR_EACH_OBJECT cargo_allowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
829 break; |
878 break; |
830 |
879 |
831 case 0x19: /* Cargo classes disallowed */ |
880 case 0x19: // Cargo classes disallowed |
832 FOR_EACH_OBJECT cargo_disallowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
881 FOR_EACH_OBJECT cargo_disallowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf); |
833 break; |
882 break; |
834 |
883 |
835 case 0x1A: /* Long format introduction date (days since year 0) */ |
884 case 0x1A: // Long format introduction date (days since year 0) |
836 FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
885 FOR_EACH_OBJECT ei[i].base_intro = grf_load_dword(&buf); |
837 break; |
886 break; |
838 |
887 |
839 case 0x16: /* Retire vehicle early */ |
888 case 0x16: // Retire vehicle early |
840 /* TODO */ |
889 /* @todo */ |
841 FOR_EACH_OBJECT grf_load_byte(&buf); |
890 FOR_EACH_OBJECT grf_load_byte(&buf); |
842 ret = true; |
891 ret = true; |
843 break; |
892 break; |
844 |
893 |
845 default: |
894 default: |
1035 statspec->layouts = srcstatspec->layouts; |
1084 statspec->layouts = srcstatspec->layouts; |
1036 statspec->copied_layouts = true; |
1085 statspec->copied_layouts = true; |
1037 } |
1086 } |
1038 break; |
1087 break; |
1039 |
1088 |
1040 case 0x10: /* Little/lots cargo threshold */ |
1089 case 0x10: // Little/lots cargo threshold |
1041 FOR_EACH_OBJECT statspec[i]->cargo_threshold = grf_load_word(&buf); |
1090 FOR_EACH_OBJECT statspec[i]->cargo_threshold = grf_load_word(&buf); |
1042 break; |
1091 break; |
1043 |
1092 |
1044 case 0x11: /* Pylon placement */ |
1093 case 0x11: // Pylon placement |
1045 FOR_EACH_OBJECT statspec[i]->pylons = grf_load_byte(&buf); |
1094 FOR_EACH_OBJECT statspec[i]->pylons = grf_load_byte(&buf); |
1046 break; |
1095 break; |
1047 |
1096 |
1048 case 0x12: /* Cargo types for random triggers */ |
1097 case 0x12: // Cargo types for random triggers |
1049 FOR_EACH_OBJECT statspec[i]->cargo_triggers = grf_load_dword(&buf); |
1098 FOR_EACH_OBJECT statspec[i]->cargo_triggers = grf_load_dword(&buf); |
1050 break; |
1099 break; |
1051 |
1100 |
1052 case 0x13: /* General flags */ |
1101 case 0x13: // General flags |
1053 FOR_EACH_OBJECT statspec[i]->flags = grf_load_byte(&buf); |
1102 FOR_EACH_OBJECT statspec[i]->flags = grf_load_byte(&buf); |
1054 break; |
1103 break; |
1055 |
1104 |
1056 case 0x14: /* Overhead wire placement */ |
1105 case 0x14: // Overhead wire placement |
1057 FOR_EACH_OBJECT statspec[i]->wires = grf_load_byte(&buf); |
1106 FOR_EACH_OBJECT statspec[i]->wires = grf_load_byte(&buf); |
1058 break; |
1107 break; |
1059 |
1108 |
1060 case 0x15: /* Blocked tiles */ |
1109 case 0x15: // Blocked tiles |
1061 FOR_EACH_OBJECT statspec[i]->blocked = grf_load_byte(&buf); |
1110 FOR_EACH_OBJECT statspec[i]->blocked = grf_load_byte(&buf); |
1062 break; |
1111 break; |
1063 |
1112 |
1064 case 0x16: /* TODO Animation info */ |
1113 case 0x16: // @todo Animation info |
1065 FOR_EACH_OBJECT grf_load_word(&buf); |
1114 FOR_EACH_OBJECT grf_load_word(&buf); |
1066 ret = true; |
1115 ret = true; |
1067 break; |
1116 break; |
1068 |
1117 |
1069 case 0x17: /* TODO Animation speed */ |
1118 case 0x17: // @todo Animation speed |
1070 FOR_EACH_OBJECT grf_load_byte(&buf); |
1119 FOR_EACH_OBJECT grf_load_byte(&buf); |
1071 ret = true; |
1120 ret = true; |
1072 break; |
1121 break; |
1073 |
1122 |
1074 case 0x18: /* TODO Animation triggers */ |
1123 case 0x18: // @todo Animation triggers |
1075 FOR_EACH_OBJECT grf_load_word(&buf); |
1124 FOR_EACH_OBJECT grf_load_word(&buf); |
1076 ret = true; |
1125 ret = true; |
1077 break; |
1126 break; |
1078 |
1127 |
1079 default: |
1128 default: |
1150 } |
1199 } |
1151 } |
1200 } |
1152 } |
1201 } |
1153 break; |
1202 break; |
1154 |
1203 |
1155 case 0x0E: /* Flags; bit 0 - disable far pillars */ |
1204 case 0x0E: // Flags; bit 0 - disable far pillars |
1156 FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf); |
1205 FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf); |
1157 break; |
1206 break; |
1158 |
1207 |
1159 case 0x0F: /* Long format year of availability (year since year 0) */ |
1208 case 0x0F: // Long format year of availability (year since year 0) |
1160 FOR_EACH_OBJECT _bridge[brid + i].avail_year = clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR); |
1209 FOR_EACH_OBJECT _bridge[brid + i].avail_year = clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR); |
1161 break; |
1210 break; |
1162 |
1211 |
1163 default: |
1212 default: |
1164 ret = true; |
1213 ret = true; |
|
1214 } |
|
1215 |
|
1216 *bufp = buf; |
|
1217 return ret; |
|
1218 } |
|
1219 |
|
1220 static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, int len) |
|
1221 { |
|
1222 HouseSpec **housespec; |
|
1223 byte *buf = *bufp; |
|
1224 int i; |
|
1225 bool ret = false; |
|
1226 |
|
1227 if (hid + numinfo >= HOUSE_MAX) { |
|
1228 grfmsg(1, "TownHouseChangeInfo: Too many houses loaded (%u), max (%u). Ignoring.", hid + numinfo, HOUSE_MAX-1); |
|
1229 return false; |
|
1230 } |
|
1231 |
|
1232 /* Allocate house specs if they haven't been allocated already. */ |
|
1233 if (_cur_grffile->housespec == NULL) { |
|
1234 _cur_grffile->housespec = CallocT<HouseSpec*>(HOUSE_MAX); |
|
1235 |
|
1236 /* Reset any overrides that have been set. */ |
|
1237 ResetHouseOverrides(); |
|
1238 } |
|
1239 |
|
1240 housespec = &_cur_grffile->housespec[hid]; |
|
1241 |
|
1242 if (prop != 0x08) { |
|
1243 /* Check that all the houses being modified have been defined. */ |
|
1244 FOR_EACH_OBJECT { |
|
1245 if (housespec[i] == NULL) { |
|
1246 grfmsg(2, "TownHouseChangeInfo: Attempt to modify undefined house %u. Ignoring.", hid + i); |
|
1247 return false; |
|
1248 } |
|
1249 } |
|
1250 } |
|
1251 |
|
1252 switch (prop) { |
|
1253 case 0x08: // Substitute building type, and definition of a new house |
|
1254 FOR_EACH_OBJECT { |
|
1255 byte subs_id = grf_load_byte(&buf); |
|
1256 |
|
1257 if (subs_id == 0xFF) { |
|
1258 /* Instead of defining a new house, a substitute house id |
|
1259 * of 0xFF disables the old house with the current id. */ |
|
1260 _house_specs[hid + i].enabled = false; |
|
1261 continue; |
|
1262 } else if (subs_id >= NEW_HOUSE_OFFSET) { |
|
1263 /* The substitute id must be one of the original houses. */ |
|
1264 grfmsg(2, "TownHouseChangeInfo: Attempt to use new house %u as substitute house for %u. Ignoring.", subs_id, hid + i); |
|
1265 return false; |
|
1266 } |
|
1267 |
|
1268 /* Allocate space for this house. */ |
|
1269 if (housespec[i] == NULL) housespec[i] = CallocT<HouseSpec>(1); |
|
1270 |
|
1271 memcpy(housespec[i], &_house_specs[subs_id], sizeof(_house_specs[subs_id])); |
|
1272 |
|
1273 housespec[i]->enabled = true; |
|
1274 housespec[i]->local_id = hid + i; |
|
1275 housespec[i]->substitute_id = subs_id; |
|
1276 housespec[i]->grffile = _cur_grffile; |
|
1277 housespec[i]->random_colour[0] = 0x04; // those 4 random colours are the base colour |
|
1278 housespec[i]->random_colour[1] = 0x08; // for all new houses |
|
1279 housespec[i]->random_colour[2] = 0x0C; // they stand for red, blue, orange and green |
|
1280 housespec[i]->random_colour[3] = 0x06; |
|
1281 |
|
1282 /* New houses do not (currently) expect to have a default start |
|
1283 * date before 1930, as this breaks the build date stuff. See |
|
1284 * FinaliseHouseArray() for more details. */ |
|
1285 if (housespec[i]->min_date < 1930) housespec[i]->min_date = 1930; |
|
1286 } |
|
1287 _have_newhouses = true; |
|
1288 break; |
|
1289 |
|
1290 case 0x09: // Building flags |
|
1291 FOR_EACH_OBJECT { |
|
1292 byte state = grf_load_byte(&buf); |
|
1293 housespec[i]->building_flags = (BuildingFlags)state; |
|
1294 } |
|
1295 break; |
|
1296 |
|
1297 case 0x0A: // Availability years |
|
1298 FOR_EACH_OBJECT { |
|
1299 uint16 years = grf_load_word(&buf); |
|
1300 housespec[i]->min_date = GB(years, 0, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 0, 8); |
|
1301 housespec[i]->max_date = GB(years, 8, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 8, 8); |
|
1302 } |
|
1303 break; |
|
1304 |
|
1305 case 0x0B: // Population |
|
1306 FOR_EACH_OBJECT housespec[i]->population = grf_load_byte(&buf); |
|
1307 break; |
|
1308 |
|
1309 case 0x0C: // Mail generation multiplier |
|
1310 FOR_EACH_OBJECT housespec[i]->mail_generation = grf_load_byte(&buf); |
|
1311 break; |
|
1312 |
|
1313 case 0x0D: // Passenger acceptance |
|
1314 case 0x0E: // Mail acceptance |
|
1315 FOR_EACH_OBJECT housespec[i]->cargo_acceptance[prop - 0x0D] = grf_load_byte(&buf); |
|
1316 break; |
|
1317 case 0x0F: // Goods/candy, food/fizzy drinks acceptance |
|
1318 FOR_EACH_OBJECT { |
|
1319 int8 goods = grf_load_byte(&buf); |
|
1320 |
|
1321 /* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance. |
|
1322 * Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */ |
|
1323 housespec[i]->accepts_cargo[2] = (goods >= 0) ? ((_opt.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) : |
|
1324 ((_opt.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD); |
|
1325 |
|
1326 housespec[i]->cargo_acceptance[2] = abs(goods); // but we do need positive value here |
|
1327 } |
|
1328 break; |
|
1329 |
|
1330 case 0x10: // Local authority rating decrease on removal |
|
1331 FOR_EACH_OBJECT housespec[i]->remove_rating_decrease = grf_load_word(&buf); |
|
1332 break; |
|
1333 |
|
1334 case 0x11: // Removal cost multiplier |
|
1335 FOR_EACH_OBJECT housespec[i]->removal_cost = grf_load_byte(&buf); |
|
1336 break; |
|
1337 |
|
1338 case 0x12: // Building name ID |
|
1339 FOR_EACH_OBJECT housespec[i]->building_name = MapGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
|
1340 break; |
|
1341 |
|
1342 case 0x13: // Building availability mask |
|
1343 FOR_EACH_OBJECT { |
|
1344 uint16 avail = grf_load_word(&buf); |
|
1345 housespec[i]->building_availability = (HouseZones)avail; |
|
1346 } |
|
1347 break; |
|
1348 |
|
1349 case 0x14: // House callback flags |
|
1350 FOR_EACH_OBJECT housespec[i]->callback_mask = grf_load_byte(&buf); |
|
1351 break; |
|
1352 |
|
1353 case 0x15: // House override byte |
|
1354 FOR_EACH_OBJECT { |
|
1355 byte override = grf_load_byte(&buf); |
|
1356 |
|
1357 /* The house being overridden must be an original house. */ |
|
1358 if (override >= NEW_HOUSE_OFFSET) { |
|
1359 grfmsg(2, "TownHouseChangeInfo: Attempt to override new house %u with house id %u. Ignoring.", override, hid); |
|
1360 return false; |
|
1361 } |
|
1362 |
|
1363 AddHouseOverride(hid, override); |
|
1364 } |
|
1365 break; |
|
1366 |
|
1367 case 0x16: // Periodic refresh multiplier |
|
1368 FOR_EACH_OBJECT housespec[i]->processing_time = grf_load_byte(&buf); |
|
1369 break; |
|
1370 |
|
1371 case 0x17: // Four random colours to use |
|
1372 FOR_EACH_OBJECT { |
|
1373 uint j; |
|
1374 for (j = 0; j < 4; j++) housespec[i]->random_colour[j] = grf_load_byte(&buf); |
|
1375 } |
|
1376 break; |
|
1377 |
|
1378 case 0x18: // Relative probability of appearing |
|
1379 FOR_EACH_OBJECT housespec[i]->probability = grf_load_byte(&buf); |
|
1380 break; |
|
1381 |
|
1382 case 0x19: // Extra flags |
|
1383 FOR_EACH_OBJECT { |
|
1384 byte flags = grf_load_byte(&buf); |
|
1385 housespec[i]->extra_flags = (HouseExtraFlags)flags; |
|
1386 } |
|
1387 break; |
|
1388 |
|
1389 case 0x1A: // Animation frames |
|
1390 FOR_EACH_OBJECT housespec[i]->animation_frames = grf_load_byte(&buf); |
|
1391 break; |
|
1392 |
|
1393 case 0x1B: // Animation speed |
|
1394 FOR_EACH_OBJECT housespec[i]->animation_speed = clamp(grf_load_byte(&buf), 2, 16); |
|
1395 break; |
|
1396 |
|
1397 case 0x1C: // Class of the building type |
|
1398 FOR_EACH_OBJECT housespec[i]->class_id = AllocateHouseClassID(grf_load_byte(&buf), _cur_grffile->grfid); |
|
1399 break; |
|
1400 |
|
1401 case 0x1D: // Callback flags 2 |
|
1402 FOR_EACH_OBJECT housespec[i]->callback_mask |= (grf_load_byte(&buf) << 8); |
|
1403 break; |
|
1404 |
|
1405 case 0x1E: // Accepted cargo types |
|
1406 FOR_EACH_OBJECT grf_load_dword(&buf); |
|
1407 ret = true; |
|
1408 break; |
|
1409 |
|
1410 default: |
|
1411 ret = true; |
|
1412 break; |
1165 } |
1413 } |
1166 |
1414 |
1167 *bufp = buf; |
1415 *bufp = buf; |
1168 return ret; |
1416 return ret; |
1169 } |
1417 } |
1277 } |
1525 } |
1278 } |
1526 } |
1279 break; |
1527 break; |
1280 |
1528 |
1281 case 0x10: // 12 * 32 * B Snow line height table |
1529 case 0x10: // 12 * 32 * B Snow line height table |
|
1530 if (numinfo > 1 || IsSnowLineSet()) { |
|
1531 grfmsg(1, "GlobalVarChangeInfo: The snowline can only be set once (%d)", numinfo); |
|
1532 } else if (len < SNOW_LINE_MONTHS * SNOW_LINE_DAYS) { |
|
1533 grfmsg(1, "GlobalVarChangeInfo: Not enough entries set in the snowline table (%d)", len); |
|
1534 } else { |
|
1535 byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; |
|
1536 |
|
1537 for (uint i = 0; i < SNOW_LINE_MONTHS; i++) { |
|
1538 for (uint j = 0; j < SNOW_LINE_DAYS; j++) { |
|
1539 table[i][j] = grf_load_byte(&buf); |
|
1540 } |
|
1541 } |
|
1542 SetSnowLine(table); |
|
1543 } |
|
1544 break; |
|
1545 |
1282 default: |
1546 default: |
1283 ret = true; |
1547 ret = true; |
1284 } |
1548 } |
1285 |
1549 |
1286 *bufp = buf; |
1550 *bufp = buf; |
1287 return ret; |
1551 return ret; |
1288 } |
1552 } |
1289 |
1553 |
1290 static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, int len) |
1554 static bool CargoChangeInfo(uint cid, int numinfo, int prop, byte **bufp, int len) |
1291 { |
1555 { |
|
1556 if (cid + numinfo > NUM_CARGO) { |
|
1557 grfmsg(2, "CargoChangeInfo: Cargo type %d out of range (max %d)", cid + numinfo, NUM_CARGO - 1); |
|
1558 return false; |
|
1559 } |
|
1560 |
|
1561 CargoSpec *cs = &_cargo[cid]; |
1292 byte *buf = *bufp; |
1562 byte *buf = *bufp; |
1293 int i; |
1563 int i; |
1294 bool ret = false; |
1564 bool ret = false; |
1295 |
1565 |
|
1566 switch (prop) { |
|
1567 case 0x08: /* Bit number of cargo */ |
|
1568 FOR_EACH_OBJECT { |
|
1569 cs[i].bitnum = grf_load_byte(&buf); |
|
1570 cs[i].grfid = _cur_grffile->grfid; |
|
1571 if (cs->IsValid()) { |
|
1572 SETBIT(_cargo_mask, cid + i); |
|
1573 } else { |
|
1574 CLRBIT(_cargo_mask, cid + i); |
|
1575 } |
|
1576 } |
|
1577 break; |
|
1578 |
|
1579 case 0x09: /* String ID for cargo type name */ |
|
1580 FOR_EACH_OBJECT cs[i].name = grf_load_word(&buf); |
|
1581 break; |
|
1582 |
|
1583 case 0x0A: /* String for cargo name, plural */ |
|
1584 FOR_EACH_OBJECT cs[i].name_plural = grf_load_word(&buf); |
|
1585 break; |
|
1586 |
|
1587 case 0x0B: |
|
1588 /* String for units of cargo. This is different in OpenTTD to TTDPatch |
|
1589 * (e.g. 10 tonnes of coal) */ |
|
1590 FOR_EACH_OBJECT cs[i].units_volume = grf_load_word(&buf); |
|
1591 break; |
|
1592 |
|
1593 case 0x0C: /* String for quantity of cargo (e.g. 10 tonnes of coal) */ |
|
1594 FOR_EACH_OBJECT cs[i].quantifier = grf_load_word(&buf); |
|
1595 break; |
|
1596 |
|
1597 case 0x0D: /* String for two letter cargo abbreviation */ |
|
1598 FOR_EACH_OBJECT cs[i].abbrev = grf_load_word(&buf); |
|
1599 break; |
|
1600 |
|
1601 case 0x0E: /* Sprite ID for cargo icon */ |
|
1602 FOR_EACH_OBJECT cs[i].sprite = grf_load_word(&buf); |
|
1603 break; |
|
1604 |
|
1605 case 0x0F: /* Weight of one unit of cargo */ |
|
1606 FOR_EACH_OBJECT cs[i].weight = grf_load_byte(&buf); |
|
1607 break; |
|
1608 |
|
1609 case 0x10: /* Used for payment calculation */ |
|
1610 FOR_EACH_OBJECT cs[i].transit_days[0] = grf_load_byte(&buf); |
|
1611 break; |
|
1612 |
|
1613 case 0x11: /* Used for payment calculation */ |
|
1614 FOR_EACH_OBJECT cs[i].transit_days[1] = grf_load_byte(&buf); |
|
1615 break; |
|
1616 |
|
1617 case 0x12: /* Base cargo price */ |
|
1618 FOR_EACH_OBJECT cs[i].initial_payment = grf_load_dword(&buf); |
|
1619 break; |
|
1620 |
|
1621 case 0x13: /* Colour for station rating bars */ |
|
1622 FOR_EACH_OBJECT cs[i].rating_colour = MapDOSColour(grf_load_byte(&buf)); |
|
1623 break; |
|
1624 |
|
1625 case 0x14: /* Colour for cargo graph */ |
|
1626 FOR_EACH_OBJECT cs[i].legend_colour = MapDOSColour(grf_load_byte(&buf)); |
|
1627 break; |
|
1628 |
|
1629 case 0x15: /* Freight status */ |
|
1630 FOR_EACH_OBJECT cs[i].is_freight = grf_load_byte(&buf) != 0; |
|
1631 break; |
|
1632 |
|
1633 case 0x16: /* Cargo classes */ |
|
1634 FOR_EACH_OBJECT cs[i].classes = grf_load_word(&buf); |
|
1635 break; |
|
1636 |
|
1637 case 0x17: /* Cargo label */ |
|
1638 FOR_EACH_OBJECT { |
|
1639 cs[i].label = grf_load_dword(&buf); |
|
1640 cs[i].label = BSWAP32(cs[i].label); |
|
1641 } |
|
1642 break; |
|
1643 |
|
1644 case 0x18: /* Town growth substitute type */ |
|
1645 FOR_EACH_OBJECT { |
|
1646 uint8 substitute_type = grf_load_byte(&buf); |
|
1647 switch (substitute_type) { |
|
1648 case 0x00: cs[i].town_effect = TE_PASSENGERS; break; |
|
1649 case 0x02: cs[i].town_effect = TE_MAIL; break; |
|
1650 case 0x05: cs[i].town_effect = TE_GOODS; break; |
|
1651 case 0x09: cs[i].town_effect = TE_WATER; break; |
|
1652 case 0x0B: cs[i].town_effect = TE_FOOD; break; |
|
1653 default: |
|
1654 grfmsg(1, "CargoChangeInfo: Unknown town growth substitute value %d, setting to none.", substitute_type); |
|
1655 case 0xFF: cs[i].town_effect = TE_NONE; break; |
|
1656 } |
|
1657 } |
|
1658 break; |
|
1659 |
|
1660 case 0x19: /* Town growth coefficient */ |
|
1661 FOR_EACH_OBJECT cs[i].multipliertowngrowth = grf_load_word(&buf); |
|
1662 break; |
|
1663 |
|
1664 case 0x1A: /* Bitmask of callbacks to use */ |
|
1665 FOR_EACH_OBJECT cs[i].callback_mask = grf_load_byte(&buf); |
|
1666 break; |
|
1667 |
|
1668 default: |
|
1669 ret = true; |
|
1670 } |
|
1671 |
|
1672 *bufp = buf; |
|
1673 return ret; |
|
1674 } |
|
1675 |
|
1676 |
|
1677 static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, int len) |
|
1678 { |
|
1679 byte *buf = *bufp; |
|
1680 int i; |
|
1681 bool ret = false; |
|
1682 |
1296 if (_cur_grffile->sound_offset == 0) { |
1683 if (_cur_grffile->sound_offset == 0) { |
1297 grfmsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); |
1684 grfmsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); |
1298 return false; |
1685 return false; |
1299 } |
1686 } |
1300 |
1687 |
1301 switch (prop) { |
1688 switch (prop) { |
1302 case 0x08: /* Relative volume */ |
1689 case 0x08: // Relative volume |
1303 FOR_EACH_OBJECT { |
1690 FOR_EACH_OBJECT { |
1304 uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
1691 uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
1305 |
1692 |
1306 if (sound >= GetNumSounds()) { |
1693 if (sound >= GetNumSounds()) { |
1307 grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); |
1694 grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); |
1422 case GSF_ROAD: |
1809 case GSF_ROAD: |
1423 case GSF_SHIP: |
1810 case GSF_SHIP: |
1424 case GSF_AIRCRAFT: |
1811 case GSF_AIRCRAFT: |
1425 /* Common properties for vehicles */ |
1812 /* Common properties for vehicles */ |
1426 switch (prop) { |
1813 switch (prop) { |
1427 case 0x00: /* Introduction date */ |
1814 case 0x00: // Introduction date |
1428 FOR_EACH_OBJECT ei[i].base_intro = grf_load_word(&buf) + DAYS_TILL_ORIGINAL_BASE_YEAR; |
1815 FOR_EACH_OBJECT ei[i].base_intro = grf_load_word(&buf) + DAYS_TILL_ORIGINAL_BASE_YEAR; |
1429 break; |
1816 break; |
1430 |
1817 |
1431 case 0x02: /* Decay speed */ |
1818 case 0x02: // Decay speed |
1432 FOR_EACH_OBJECT SB(ei[i].unk2, 0, 7, grf_load_byte(&buf) & 0x7F); |
1819 FOR_EACH_OBJECT SB(ei[i].unk2, 0, 7, grf_load_byte(&buf) & 0x7F); |
1433 break; |
1820 break; |
1434 |
1821 |
1435 case 0x03: /* Vehicle life */ |
1822 case 0x03: // Vehicle life |
1436 FOR_EACH_OBJECT ei[i].lifelength = grf_load_byte(&buf); |
1823 FOR_EACH_OBJECT ei[i].lifelength = grf_load_byte(&buf); |
1437 break; |
1824 break; |
1438 |
1825 |
1439 case 0x04: /* Model life */ |
1826 case 0x04: // Model life |
1440 FOR_EACH_OBJECT ei[i].base_life = grf_load_byte(&buf); |
1827 FOR_EACH_OBJECT ei[i].base_life = grf_load_byte(&buf); |
1441 break; |
1828 break; |
1442 |
1829 |
1443 case 0x06: /* Climates available */ |
1830 case 0x06: // Climates available |
1444 FOR_EACH_OBJECT ei[i].climates = grf_load_byte(&buf); |
1831 FOR_EACH_OBJECT ei[i].climates = grf_load_byte(&buf); |
1445 break; |
1832 break; |
1446 |
1833 |
1447 case 0x07: /* Loading speed */ |
1834 case 0x07: // Loading speed |
1448 /* Hyronymus explained me what does |
1835 /* Hyronymus explained me what does |
1449 * this mean and insists on having a |
1836 * this mean and insists on having a |
1450 * credit ;-). --pasky */ |
1837 * credit ;-). --pasky */ |
1451 FOR_EACH_OBJECT ei[i].load_amount = grf_load_byte(&buf); |
1838 FOR_EACH_OBJECT ei[i].load_amount = grf_load_byte(&buf); |
1452 break; |
1839 break; |
1851 } |
2268 } |
1852 |
2269 |
1853 break; |
2270 break; |
1854 } |
2271 } |
1855 |
2272 |
|
2273 case GSF_TOWNHOUSE: { |
|
2274 byte sprites = _cur_grffile->spriteset_numents; |
|
2275 byte num_sprites = max((uint8)1, type); |
|
2276 uint i; |
|
2277 |
|
2278 group = AllocateSpriteGroup(); |
|
2279 group->type = SGT_TILELAYOUT; |
|
2280 group->g.layout.num_sprites = sprites; |
|
2281 group->g.layout.dts = CallocT<DrawTileSprites>(1); |
|
2282 |
|
2283 /* Groundsprite */ |
|
2284 group->g.layout.dts->ground_sprite = grf_load_word(&buf); |
|
2285 group->g.layout.dts->ground_pal = grf_load_word(&buf); |
|
2286 /* Remap transparent/colour modifier bits */ |
|
2287 if (HASBIT(group->g.layout.dts->ground_sprite, 14)) { |
|
2288 CLRBIT(group->g.layout.dts->ground_sprite, 14); |
|
2289 SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT); |
|
2290 } |
|
2291 if (HASBIT(group->g.layout.dts->ground_sprite, 15)) { |
|
2292 CLRBIT(group->g.layout.dts->ground_sprite, 15); |
|
2293 SETBIT(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_COLOR); |
|
2294 } |
|
2295 if (HASBIT(group->g.layout.dts->ground_pal, 14)) { |
|
2296 CLRBIT(group->g.layout.dts->ground_pal, 14); |
|
2297 SETBIT(group->g.layout.dts->ground_sprite, SPRITE_MODIFIER_OPAQUE); |
|
2298 } |
|
2299 if (HASBIT(group->g.layout.dts->ground_pal, 15)) { |
|
2300 /* Bit 31 set means this is a custom sprite, so rewrite it to the |
|
2301 * last spriteset defined. */ |
|
2302 SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground_sprite, 0, 14) * sprites; |
|
2303 SB(group->g.layout.dts->ground_sprite, 0, SPRITE_WIDTH, sprite); |
|
2304 CLRBIT(group->g.layout.dts->ground_pal, 15); |
|
2305 } |
|
2306 |
|
2307 group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1); |
|
2308 |
|
2309 for (i = 0; i < num_sprites; i++) { |
|
2310 DrawTileSeqStruct *seq = (DrawTileSeqStruct*)&group->g.layout.dts->seq[i]; |
|
2311 |
|
2312 seq->image = grf_load_word(&buf); |
|
2313 seq->pal = grf_load_word(&buf); |
|
2314 seq->delta_x = grf_load_byte(&buf); |
|
2315 seq->delta_y = grf_load_byte(&buf); |
|
2316 |
|
2317 if (HASBIT(seq->image, 14)) { |
|
2318 CLRBIT(seq->image, 14); |
|
2319 SETBIT(seq->image, PALETTE_MODIFIER_TRANSPARENT); |
|
2320 } |
|
2321 if (HASBIT(seq->image, 15)) { |
|
2322 CLRBIT(seq->image, 15); |
|
2323 SETBIT(seq->image, PALETTE_MODIFIER_COLOR); |
|
2324 } |
|
2325 if (HASBIT(seq->pal, 14)) { |
|
2326 CLRBIT(seq->pal, 14); |
|
2327 SETBIT(seq->image, SPRITE_MODIFIER_OPAQUE); |
|
2328 } |
|
2329 if (HASBIT(seq->pal, 15)) { |
|
2330 /* Bit 31 set means this is a custom sprite, so rewrite it to the |
|
2331 * last spriteset defined. */ |
|
2332 SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image, 0, 14) * sprites; |
|
2333 SB(seq->image, 0, SPRITE_WIDTH, sprite); |
|
2334 CLRBIT(seq->pal, 15); |
|
2335 } |
|
2336 |
|
2337 if (type > 0) { |
|
2338 seq->delta_z = grf_load_byte(&buf); |
|
2339 if ((byte)seq->delta_z == 0x80) continue; |
|
2340 } |
|
2341 |
|
2342 seq->size_x = grf_load_byte(&buf); |
|
2343 seq->size_y = grf_load_byte(&buf); |
|
2344 seq->size_z = grf_load_byte(&buf); |
|
2345 } |
|
2346 |
|
2347 /* Set the terminator value. */ |
|
2348 ((DrawTileSeqStruct*)group->g.layout.dts->seq)[i].delta_x = (byte)0x80; |
|
2349 |
|
2350 break; |
|
2351 } |
|
2352 |
1856 /* Loading of Tile Layout and Production Callback groups would happen here */ |
2353 /* Loading of Tile Layout and Production Callback groups would happen here */ |
1857 default: grfmsg(1, "NewSpriteGroup: Unsupported feature %d, skipping", feature); |
2354 default: grfmsg(1, "NewSpriteGroup: Unsupported feature %d, skipping", feature); |
1858 } |
2355 } |
1859 } |
2356 } |
1860 } |
2357 } |
1866 { |
2363 { |
1867 /* Special cargo types for purchase list and stations */ |
2364 /* Special cargo types for purchase list and stations */ |
1868 if (feature == GSF_STATION && ctype == 0xFE) return CT_DEFAULT_NA; |
2365 if (feature == GSF_STATION && ctype == 0xFE) return CT_DEFAULT_NA; |
1869 if (ctype == 0xFF) return CT_PURCHASE; |
2366 if (ctype == 0xFF) return CT_PURCHASE; |
1870 |
2367 |
|
2368 if (_cur_grffile->cargo_max == 0) { |
|
2369 /* No cargo table, so use bitnum values */ |
|
2370 if (ctype >= 32) { |
|
2371 grfmsg(1, "FeatureMapSpriteGroup: Cargo bitnum %d out of range (max 31), skipping.", ctype); |
|
2372 return CT_INVALID; |
|
2373 } |
|
2374 |
|
2375 for (CargoID c = 0; c < NUM_CARGO; c++) { |
|
2376 const CargoSpec *cs = GetCargo(c); |
|
2377 if (!cs->IsValid()) continue; |
|
2378 |
|
2379 if (cs->bitnum == ctype) { |
|
2380 grfmsg(6, "FeatureMapSpriteGroup: Cargo bitnum %d mapped to cargo type %d.", ctype, c); |
|
2381 return c; |
|
2382 } |
|
2383 } |
|
2384 |
|
2385 grfmsg(5, "FeatureMapSpriteGroup: Cargo bitnum %d not available in this climate, skipping.", ctype); |
|
2386 return CT_INVALID; |
|
2387 } |
|
2388 |
1871 /* Check if the cargo type is out of bounds of the cargo translation table */ |
2389 /* Check if the cargo type is out of bounds of the cargo translation table */ |
1872 if (ctype >= (_cur_grffile->cargo_max == 0 ? _default_cargo_max : _cur_grffile->cargo_max)) { |
2390 if (ctype >= _cur_grffile->cargo_max) { |
1873 grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range (max %d), skipping.", ctype, (_cur_grffile->cargo_max == 0 ? _default_cargo_max : _cur_grffile->cargo_max) - 1); |
2391 grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range (max %d), skipping.", ctype, _cur_grffile->cargo_max - 1); |
1874 return CT_INVALID; |
2392 return CT_INVALID; |
1875 } |
2393 } |
1876 |
2394 |
1877 /* Look up the cargo label from the translation table */ |
2395 /* Look up the cargo label from the translation table */ |
1878 CargoLabel cl = _cur_grffile->cargo_max == 0 ? _default_cargo_list[ctype] : _cur_grffile->cargo_list[ctype]; |
2396 CargoLabel cl = _cur_grffile->cargo_list[ctype]; |
1879 if (cl == 0) { |
2397 if (cl == 0) { |
1880 grfmsg(5, "FeatureMapSpriteGroup: Cargo type %d not available in this climate, skipping.", ctype); |
2398 grfmsg(5, "FeatureMapSpriteGroup: Cargo type %d not available in this climate, skipping.", ctype); |
1881 return CT_INVALID; |
2399 return CT_INVALID; |
1882 } |
2400 } |
1883 |
2401 |
1888 } |
2406 } |
1889 |
2407 |
1890 grfmsg(6, "FeatureMapSpriteGroup: Cargo '%c%c%c%c' mapped to cargo type %d.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), ctype); |
2408 grfmsg(6, "FeatureMapSpriteGroup: Cargo '%c%c%c%c' mapped to cargo type %d.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), ctype); |
1891 return ctype; |
2409 return ctype; |
1892 } |
2410 } |
|
2411 |
|
2412 |
|
2413 static void VehicleMapSpriteGroup(byte *buf, byte feature, uint8 idcount, uint8 cidcount, bool wagover) |
|
2414 { |
|
2415 static byte *last_engines; |
|
2416 static int last_engines_count; |
|
2417 |
|
2418 if (!wagover) { |
|
2419 if (last_engines_count != idcount) { |
|
2420 last_engines = ReallocT(last_engines, idcount); |
|
2421 last_engines_count = idcount; |
|
2422 } |
|
2423 } else { |
|
2424 if (last_engines_count == 0) { |
|
2425 grfmsg(0, "FeatureMapSpriteGroup: WagonOverride: No engine to do override with"); |
|
2426 return; |
|
2427 } |
|
2428 |
|
2429 grfmsg(6, "FeatureMapSpriteGroup: WagonOverride: %u engines, %u wagons", |
|
2430 last_engines_count, idcount); |
|
2431 } |
|
2432 |
|
2433 for (uint i = 0; i < idcount; i++) { |
|
2434 uint8 engine_id = buf[3 + i]; |
|
2435 uint8 engine = engine_id + _vehshifts[feature]; |
|
2436 byte *bp = &buf[4 + idcount]; |
|
2437 |
|
2438 if (engine_id > _vehcounts[feature]) { |
|
2439 grfmsg(0, "Id %u for feature 0x%02X is out of bounds", engine_id, feature); |
|
2440 return; |
|
2441 } |
|
2442 |
|
2443 grfmsg(7, "FeatureMapSpriteGroup: [%d] Engine %d...", i, engine); |
|
2444 |
|
2445 for (uint c = 0; c < cidcount; c++) { |
|
2446 uint8 ctype = grf_load_byte(&bp); |
|
2447 uint16 groupid = grf_load_word(&bp); |
|
2448 |
|
2449 grfmsg(8, "FeatureMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); |
|
2450 |
|
2451 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
2452 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); |
|
2453 continue; |
|
2454 } |
|
2455 |
|
2456 ctype = TranslateCargo(feature, ctype); |
|
2457 if (ctype == CT_INVALID) continue; |
|
2458 |
|
2459 if (wagover) { |
|
2460 SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
|
2461 } else { |
|
2462 SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
|
2463 last_engines[i] = engine; |
|
2464 } |
|
2465 } |
|
2466 } |
|
2467 |
|
2468 { |
|
2469 byte *bp = &buf[4 + idcount + cidcount * 3]; |
|
2470 uint16 groupid = grf_load_word(&bp); |
|
2471 |
|
2472 grfmsg(8, "-- Default group id 0x%04X", groupid); |
|
2473 |
|
2474 for (uint i = 0; i < idcount; i++) { |
|
2475 uint8 engine = buf[3 + i] + _vehshifts[feature]; |
|
2476 |
|
2477 /* Don't tell me you don't love duplicated code! */ |
|
2478 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
2479 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
|
2480 groupid, _cur_grffile->spritegroups_count); |
|
2481 continue; |
|
2482 } |
|
2483 |
|
2484 if (wagover) { |
|
2485 /* If the ID for this action 3 is the same as the vehicle ID, |
|
2486 * this indicates we have a helicopter rotor override. */ |
|
2487 if (feature == GSF_AIRCRAFT && engine == last_engines[i]) { |
|
2488 SetRotorOverrideSprites(engine, _cur_grffile->spritegroups[groupid]); |
|
2489 } else { |
|
2490 /* TODO: No multiple cargo types per vehicle yet. --pasky */ |
|
2491 SetWagonOverrideSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
|
2492 } |
|
2493 } else { |
|
2494 SetCustomEngineSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid]); |
|
2495 SetEngineGRF(engine, _cur_grffile); |
|
2496 last_engines[i] = engine; |
|
2497 } |
|
2498 } |
|
2499 } |
|
2500 } |
|
2501 |
|
2502 |
|
2503 static void StationMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount) |
|
2504 { |
|
2505 for (uint i = 0; i < idcount; i++) { |
|
2506 uint8 stid = buf[3 + i]; |
|
2507 StationSpec *statspec = _cur_grffile->stations[stid]; |
|
2508 byte *bp = &buf[4 + idcount]; |
|
2509 |
|
2510 for (uint c = 0; c < cidcount; c++) { |
|
2511 uint8 ctype = grf_load_byte(&bp); |
|
2512 uint16 groupid = grf_load_word(&bp); |
|
2513 |
|
2514 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
2515 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
|
2516 groupid, _cur_grffile->spritegroups_count); |
|
2517 continue; |
|
2518 } |
|
2519 |
|
2520 ctype = TranslateCargo(GSF_STATION, ctype); |
|
2521 if (ctype == CT_INVALID) continue; |
|
2522 |
|
2523 statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; |
|
2524 } |
|
2525 } |
|
2526 |
|
2527 { |
|
2528 byte *bp = &buf[4 + idcount + cidcount * 3]; |
|
2529 uint16 groupid = grf_load_word(&bp); |
|
2530 |
|
2531 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
2532 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
|
2533 groupid, _cur_grffile->spritegroups_count); |
|
2534 return; |
|
2535 } |
|
2536 |
|
2537 for (uint i = 0; i < idcount; i++) { |
|
2538 uint8 stid = buf[3 + i]; |
|
2539 StationSpec *statspec = _cur_grffile->stations[stid]; |
|
2540 |
|
2541 statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
|
2542 statspec->grfid = _cur_grffile->grfid; |
|
2543 statspec->localidx = stid; |
|
2544 SetCustomStationSpec(statspec); |
|
2545 } |
|
2546 } |
|
2547 } |
|
2548 |
|
2549 |
|
2550 static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount) |
|
2551 { |
|
2552 byte *bp = &buf[4 + idcount + cidcount * 3]; |
|
2553 uint16 groupid = grf_load_word(&bp); |
|
2554 |
|
2555 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
2556 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", |
|
2557 groupid, _cur_grffile->spritegroups_count); |
|
2558 return; |
|
2559 } |
|
2560 |
|
2561 for (uint i = 0; i < idcount; i++) { |
|
2562 uint8 hid = buf[3 + i]; |
|
2563 HouseSpec *hs = _cur_grffile->housespec[hid]; |
|
2564 |
|
2565 if (hs == NULL) { |
|
2566 grfmsg(1, "FeatureMapSpriteGroup: Too many houses defined, skipping"); |
|
2567 return; |
|
2568 } |
|
2569 |
|
2570 hs->spritegroup = _cur_grffile->spritegroups[groupid]; |
|
2571 } |
|
2572 } |
|
2573 |
|
2574 |
|
2575 static void CargoMapSpriteGroup(byte *buf, uint8 idcount, uint8 cidcount) |
|
2576 { |
|
2577 byte *bp = &buf[4 + idcount + cidcount * 3]; |
|
2578 uint16 groupid = grf_load_word(&bp); |
|
2579 |
|
2580 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
2581 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", |
|
2582 groupid, _cur_grffile->spritegroups_count); |
|
2583 return; |
|
2584 } |
|
2585 |
|
2586 for (uint i = 0; i < idcount; i++) { |
|
2587 CargoID cid = buf[3 + i]; |
|
2588 |
|
2589 if (cid >= NUM_CARGO) { |
|
2590 grfmsg(1, "FeatureMapSpriteGroup: Cargo ID %d out of range, skipping"); |
|
2591 continue; |
|
2592 } |
|
2593 |
|
2594 CargoSpec *cs = &_cargo[cid]; |
|
2595 cs->grfid = _cur_grffile->grfid; |
|
2596 cs->group = _cur_grffile->spritegroups[groupid]; |
|
2597 } |
|
2598 } |
|
2599 |
1893 |
2600 |
1894 /* Action 0x03 */ |
2601 /* Action 0x03 */ |
1895 static void FeatureMapSpriteGroup(byte *buf, int len) |
2602 static void FeatureMapSpriteGroup(byte *buf, int len) |
1896 { |
2603 { |
1897 /* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid> |
2604 /* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid> |
1932 if (!check_length(len, 4 + idcount + cidcount * 3, "FeatureMapSpriteGroup")) return; |
2633 if (!check_length(len, 4 + idcount + cidcount * 3, "FeatureMapSpriteGroup")) return; |
1933 |
2634 |
1934 grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d", |
2635 grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d", |
1935 feature, idcount, cidcount, wagover); |
2636 feature, idcount, cidcount, wagover); |
1936 |
2637 |
1937 if (feature > GSF_STATION) { |
|
1938 grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); |
|
1939 return; |
|
1940 } |
|
1941 |
|
1942 |
|
1943 if (feature == GSF_STATION) { |
|
1944 // We do things differently for stations. |
|
1945 |
|
1946 for (uint i = 0; i < idcount; i++) { |
|
1947 uint8 stid = buf[3 + i]; |
|
1948 StationSpec *statspec = _cur_grffile->stations[stid]; |
|
1949 byte *bp = &buf[4 + idcount]; |
|
1950 |
|
1951 for (uint c = 0; c < cidcount; c++) { |
|
1952 uint8 ctype = grf_load_byte(&bp); |
|
1953 uint16 groupid = grf_load_word(&bp); |
|
1954 |
|
1955 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
1956 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
|
1957 groupid, _cur_grffile->spritegroups_count); |
|
1958 return; |
|
1959 } |
|
1960 |
|
1961 ctype = TranslateCargo(feature, ctype); |
|
1962 if (ctype == CT_INVALID) continue; |
|
1963 |
|
1964 statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; |
|
1965 } |
|
1966 } |
|
1967 |
|
1968 { |
|
1969 byte *bp = buf + 4 + idcount + cidcount * 3; |
|
1970 uint16 groupid = grf_load_word(&bp); |
|
1971 |
|
1972 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
1973 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", |
|
1974 groupid, _cur_grffile->spritegroups_count); |
|
1975 return; |
|
1976 } |
|
1977 |
|
1978 for (uint i = 0; i < idcount; i++) { |
|
1979 uint8 stid = buf[3 + i]; |
|
1980 StationSpec *statspec = _cur_grffile->stations[stid]; |
|
1981 |
|
1982 statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
|
1983 statspec->grfid = _cur_grffile->grfid; |
|
1984 statspec->localidx = stid; |
|
1985 SetCustomStationSpec(statspec); |
|
1986 } |
|
1987 } |
|
1988 return; |
|
1989 } |
|
1990 |
|
1991 // FIXME: Tropicset contains things like: |
|
1992 // 03 00 01 19 01 00 00 00 00 - this is missing one 00 at the end, |
|
1993 // what should we exactly do with that? --pasky |
|
1994 |
|
1995 if (_cur_grffile->spriteset_start == 0 || _cur_grffile->spritegroups == 0) { |
2638 if (_cur_grffile->spriteset_start == 0 || _cur_grffile->spritegroups == 0) { |
1996 grfmsg(1, "FeatureMapSpriteGroup: No sprite set to work on! Skipping"); |
2639 grfmsg(1, "FeatureMapSpriteGroup: No sprite set to work on! Skipping"); |
1997 return; |
2640 return; |
1998 } |
2641 } |
1999 |
2642 |
2000 if (!wagover && last_engines_count != idcount) { |
2643 switch (feature) { |
2001 last_engines = ReallocT(last_engines, idcount); |
2644 case GSF_TRAIN: |
2002 last_engines_count = idcount; |
2645 case GSF_ROAD: |
2003 } |
2646 case GSF_SHIP: |
2004 |
2647 case GSF_AIRCRAFT: |
2005 if (wagover) { |
2648 VehicleMapSpriteGroup(buf, feature, idcount, cidcount, wagover); |
2006 if (last_engines_count == 0) { |
|
2007 grfmsg(0, "FeatureMapSpriteGroup: WagonOverride: No engine to do override with"); |
|
2008 return; |
2649 return; |
2009 } |
2650 |
2010 grfmsg(6, "FeatureMapSpriteGroup: WagonOverride: %u engines, %u wagons", |
2651 case GSF_STATION: |
2011 last_engines_count, idcount); |
2652 StationMapSpriteGroup(buf, idcount, cidcount); |
2012 } |
|
2013 |
|
2014 |
|
2015 for (uint i = 0; i < idcount; i++) { |
|
2016 uint8 engine_id = buf[3 + i]; |
|
2017 uint8 engine = engine_id + _vehshifts[feature]; |
|
2018 byte *bp = &buf[4 + idcount]; |
|
2019 |
|
2020 if (engine_id > _vehcounts[feature]) { |
|
2021 grfmsg(0, "Id %u for feature 0x%02X is out of bounds", engine_id, feature); |
|
2022 return; |
2653 return; |
2023 } |
2654 |
2024 |
2655 case GSF_TOWNHOUSE: |
2025 grfmsg(7, "FeatureMapSpriteGroup: [%d] Engine %d...", i, engine); |
2656 TownHouseMapSpriteGroup(buf, idcount, cidcount); |
2026 |
2657 return; |
2027 for (uint c = 0; c < cidcount; c++) { |
2658 |
2028 uint8 ctype = grf_load_byte(&bp); |
2659 case GSF_CARGOS: |
2029 uint16 groupid = grf_load_word(&bp); |
2660 CargoMapSpriteGroup(buf, idcount, cidcount); |
2030 |
2661 return; |
2031 grfmsg(8, "FeatureMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); |
2662 |
2032 |
2663 default: |
2033 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
2664 grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); |
2034 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); |
2665 return; |
2035 return; |
|
2036 } |
|
2037 |
|
2038 ctype = TranslateCargo(feature, ctype); |
|
2039 if (ctype == CT_INVALID) continue; |
|
2040 |
|
2041 if (wagover) { |
|
2042 SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
|
2043 } else { |
|
2044 SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
|
2045 last_engines[i] = engine; |
|
2046 } |
|
2047 } |
|
2048 } |
|
2049 |
|
2050 { |
|
2051 byte *bp = buf + 4 + idcount + cidcount * 3; |
|
2052 uint16 groupid = grf_load_word(&bp); |
|
2053 |
|
2054 grfmsg(8, "-- Default group id 0x%04X", groupid); |
|
2055 |
|
2056 for (uint i = 0; i < idcount; i++) { |
|
2057 uint8 engine = buf[3 + i] + _vehshifts[feature]; |
|
2058 |
|
2059 // Don't tell me you don't love duplicated code! |
|
2060 if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
|
2061 grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); |
|
2062 return; |
|
2063 } |
|
2064 |
|
2065 if (wagover) { |
|
2066 /* If the ID for this action 3 is the same as the vehicle ID, |
|
2067 * this indicates we have a helicopter rotor override. */ |
|
2068 if (feature == GSF_AIRCRAFT && engine == last_engines[i]) { |
|
2069 SetRotorOverrideSprites(engine, _cur_grffile->spritegroups[groupid]); |
|
2070 } else { |
|
2071 // TODO: No multiple cargo types per vehicle yet. --pasky |
|
2072 SetWagonOverrideSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
|
2073 } |
|
2074 } else { |
|
2075 SetCustomEngineSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid]); |
|
2076 SetEngineGRF(engine, _cur_grffile); |
|
2077 last_engines[i] = engine; |
|
2078 } |
|
2079 } |
|
2080 } |
2666 } |
2081 } |
2667 } |
2082 |
2668 |
2083 /* Action 0x04 */ |
2669 /* Action 0x04 */ |
2084 static void FeatureNewName(byte *buf, int len) |
2670 static void FeatureNewName(byte *buf, int len) |
2146 AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id); |
2732 AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id); |
2147 } |
2733 } |
2148 break; |
2734 break; |
2149 } |
2735 } |
2150 |
2736 |
|
2737 case GSF_TOWNHOUSE: |
2151 default: |
2738 default: |
2152 switch (GB(id, 8, 8)) { |
2739 switch (GB(id, 8, 8)) { |
2153 case 0xC4: /* Station class name */ |
2740 case 0xC4: // Station class name |
2154 if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
2741 if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
2155 grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
2742 grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
2156 } else { |
2743 } else { |
2157 StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; |
2744 StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; |
2158 SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); |
2745 SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); |
2159 } |
2746 } |
2160 break; |
2747 break; |
2161 |
2748 |
2162 case 0xC5: /* Station name */ |
2749 case 0xC5: // Station name |
2163 if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
2750 if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
2164 grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
2751 grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
2165 } else { |
2752 } else { |
2166 _cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
2753 _cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
2167 } |
2754 } |
2168 break; |
2755 break; |
2169 |
2756 |
2170 case 0xC9: |
2757 case 0xC9: { // House name |
|
2758 if (_cur_grffile->housespec == NULL || _cur_grffile->housespec[GB(id, 0, 8)] == NULL) { |
|
2759 grfmsg(1, "FeatureNewName: Attempt to name undefined house 0x%X, ignoring.", GB(id, 0, 8)); |
|
2760 } else { |
|
2761 _cur_grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
|
2762 } |
|
2763 break; |
|
2764 } |
|
2765 |
2171 case 0xD0: |
2766 case 0xD0: |
2172 case 0xDC: |
2767 case 0xDC: |
2173 AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
2768 AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
2174 break; |
2769 break; |
2175 |
2770 |
2220 buf++; |
2814 buf++; |
2221 uint8 type = grf_load_byte(&buf); |
2815 uint8 type = grf_load_byte(&buf); |
2222 uint16 num = grf_load_extended(&buf); |
2816 uint16 num = grf_load_extended(&buf); |
2223 |
2817 |
2224 switch (type) { |
2818 switch (type) { |
2225 case 0x04: /* Signal graphics */ |
2819 case 0x04: // Signal graphics |
2226 if (num != 112 && num != 240) { |
2820 if (num != 112 && num != 240) { |
2227 grfmsg(1, "GraphicsNews: Signal graphics sprite count must be 112 or 240, skipping"); |
2821 grfmsg(1, "GraphicsNews: Signal graphics sprite count must be 112 or 240, skipping"); |
2228 return; |
2822 return; |
2229 } |
2823 } |
2230 _signal_base = _cur_spriteid; |
2824 _signal_base = _cur_spriteid; |
2231 break; |
2825 break; |
2232 |
2826 |
2233 case 0x05: /* Catenary graphics */ |
2827 case 0x05: // Catenary graphics |
2234 if (num != 48) { |
2828 if (num != 48) { |
2235 grfmsg(1, "GraphicsNews: Catenary graphics sprite count must be 48, skipping"); |
2829 grfmsg(1, "GraphicsNews: Catenary graphics sprite count must be 48, skipping"); |
2236 return; |
2830 return; |
2237 } |
2831 } |
2238 replace = SPR_ELRAIL_BASE + 3; |
2832 replace = SPR_ELRAIL_BASE + 3; |
2239 break; |
2833 break; |
2240 |
2834 |
2241 case 0x06: /* Foundations */ |
2835 case 0x06: // Foundations |
2242 if (num != 74) { |
2836 if (num != 74) { |
2243 grfmsg(1, "GraphicsNews: Foundation graphics sprite count must be 74, skipping"); |
2837 grfmsg(1, "GraphicsNews: Foundation graphics sprite count must be 74, skipping"); |
2244 return; |
2838 return; |
2245 } |
2839 } |
2246 replace = SPR_SLOPES_BASE; |
2840 replace = SPR_SLOPES_BASE; |
2247 break; |
2841 break; |
2248 |
2842 |
2249 case 0x08: /* Canal graphics */ |
2843 case 0x08: // Canal graphics |
2250 if (num != 65) { |
2844 if (num != 65) { |
2251 grfmsg(1, "GraphicsNews: Canal graphics sprite count must be 65, skipping"); |
2845 grfmsg(1, "GraphicsNews: Canal graphics sprite count must be 65, skipping"); |
2252 return; |
2846 return; |
2253 } |
2847 } |
2254 replace = SPR_CANALS_BASE + 5; |
2848 replace = SPR_CANALS_BASE + 5; |
2255 break; |
2849 break; |
2256 |
2850 |
2257 case 0x0D: /* Coast graphics */ |
2851 case 0x0D: // Coast graphics |
2258 if (num != 16) { |
2852 if (num != 16) { |
2259 grfmsg(1, "GraphicsNews: Coast graphics sprite count must be 16, skipping"); |
2853 grfmsg(1, "GraphicsNews: Coast graphics sprite count must be 16, skipping"); |
2260 return; |
2854 return; |
2261 } |
2855 } |
2262 _coast_base = _cur_spriteid; |
2856 _coast_base = _cur_spriteid; |
2281 } |
2875 } |
2282 |
2876 |
2283 static uint32 GetParamVal(byte param, uint32 *cond_val) |
2877 static uint32 GetParamVal(byte param, uint32 *cond_val) |
2284 { |
2878 { |
2285 switch (param) { |
2879 switch (param) { |
2286 case 0x81: /* current year */ |
2880 case 0x81: // current year |
2287 return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; |
2881 return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; |
2288 |
2882 |
2289 case 0x83: /* current climate, 0=temp, 1=arctic, 2=trop, 3=toyland */ |
2883 case 0x83: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland |
2290 return _opt.landscape; |
2884 return _opt.landscape; |
2291 |
2885 |
2292 case 0x84: /* GRF loading stage */ |
2886 case 0x84: // GRF loading stage |
2293 return (_cur_stage > GLS_INIT) | ((_cur_stage == GLS_ACTIVATION) << 9); |
2887 return (_cur_stage > GLS_INIT) | ((_cur_stage == GLS_ACTIVATION) << 9); |
2294 |
2888 |
2295 case 0x85: /* TTDPatch flags, only for bit tests */ |
2889 case 0x85: // TTDPatch flags, only for bit tests |
2296 if (cond_val == NULL) { |
2890 if (cond_val == NULL) { |
2297 /* Supported in Action 0x07 and 0x09, not 0x0D */ |
2891 /* Supported in Action 0x07 and 0x09, not 0x0D */ |
2298 return 0; |
2892 return 0; |
2299 } else { |
2893 } else { |
2300 uint32 param_val = _ttdpatch_flags[*cond_val / 0x20]; |
2894 uint32 param_val = _ttdpatch_flags[*cond_val / 0x20]; |
2301 *cond_val %= 0x20; |
2895 *cond_val %= 0x20; |
2302 return param_val; |
2896 return param_val; |
2303 } |
2897 } |
2304 |
2898 |
2305 case 0x86: /* road traffic side, bit 4 clear=left, set=right */ |
2899 case 0x86: // road traffic side, bit 4 clear=left, set=right |
2306 return _opt.road_side << 4; |
2900 return _opt.road_side << 4; |
2307 |
2901 |
2308 case 0x88: /* GRF ID check */ |
2902 case 0x88: // GRF ID check |
2309 return 0; |
2903 return 0; |
2310 |
2904 |
2311 case 0x8B: { /* TTDPatch version */ |
2905 case 0x8B: { // TTDPatch version |
2312 uint major = 2; |
2906 uint major = 2; |
2313 uint minor = 6; |
2907 uint minor = 6; |
2314 uint revision = 0; // special case: 2.0.1 is 2.0.10 |
2908 uint revision = 0; // special case: 2.0.1 is 2.0.10 |
2315 uint build = 1168; |
2909 uint build = 1168; |
2316 return (major << 24) | (minor << 20) | (revision << 16) | build; |
2910 return (major << 24) | (minor << 20) | (revision << 16) | build; |
2317 } |
2911 } |
2318 |
2912 |
2319 case 0x8D: /* TTD Version, 00=DOS, 01=Windows */ |
2913 case 0x8D: // TTD Version, 00=DOS, 01=Windows |
2320 return !_use_dos_palette; |
2914 return !_use_dos_palette; |
2321 |
2915 |
2322 case 0x8E: /* Y-offset for train sprites */ |
2916 case 0x8E: // Y-offset for train sprites |
2323 return _traininfo_vehicle_pitch; |
2917 return _traininfo_vehicle_pitch; |
2324 |
2918 |
2325 case 0x92: /* Game mode */ |
2919 case 0x92: // Game mode |
2326 return _game_mode; |
2920 return _game_mode; |
2327 |
2921 |
2328 case 0x9A: /* Always -1 */ |
2922 case 0x9A: // Always -1 |
2329 return UINT_MAX; |
2923 return UINT_MAX; |
2330 |
2924 |
2331 case 0x9D: /* TTD Platform, 00=TTDPatch, 01=OpenTTD */ |
2925 case 0x9D: // TTD Platform, 00=TTDPatch, 01=OpenTTD |
2332 return 1; |
2926 return 1; |
2333 |
2927 |
2334 case 0x9E: /* Miscellaneous GRF features */ |
2928 case 0x9E: // Miscellaneous GRF features |
2335 return _misc_grf_features; |
2929 return _misc_grf_features; |
2336 |
2930 |
2337 default: |
2931 default: |
2338 /* GRF Parameter */ |
2932 /* GRF Parameter */ |
2339 if (param < 0x80) return _cur_grffile->param[param]; |
2933 if (param < 0x80) return _cur_grffile->param[param]; |
3571 */ |
4179 */ |
3572 static void ResetNewGRFData() |
4180 static void ResetNewGRFData() |
3573 { |
4181 { |
3574 CleanUpStrings(); |
4182 CleanUpStrings(); |
3575 |
4183 |
3576 // Copy/reset original engine info data |
4184 /* Copy/reset original engine info data */ |
3577 memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info)); |
4185 memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info)); |
3578 memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info)); |
4186 memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info)); |
3579 memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info)); |
4187 memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info)); |
3580 memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info)); |
4188 memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info)); |
3581 memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info)); |
4189 memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info)); |
3582 |
4190 |
3583 // Copy/reset original bridge info data |
4191 /* Copy/reset original bridge info data |
3584 // First, free sprite table data |
4192 * First, free sprite table data */ |
3585 for (uint i = 0; i < MAX_BRIDGES; i++) { |
4193 for (uint i = 0; i < MAX_BRIDGES; i++) { |
3586 if (_bridge[i].sprite_table != NULL) { |
4194 if (_bridge[i].sprite_table != NULL) { |
3587 for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]); |
4195 for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]); |
3588 free(_bridge[i].sprite_table); |
4196 free(_bridge[i].sprite_table); |
3589 } |
4197 } |
3590 } |
4198 } |
3591 memcpy(&_bridge, &orig_bridge, sizeof(_bridge)); |
4199 memcpy(&_bridge, &orig_bridge, sizeof(_bridge)); |
3592 |
4200 |
3593 // Reset refit/cargo class data |
4201 /* Reset refit/cargo class data */ |
3594 memset(&cargo_allowed, 0, sizeof(cargo_allowed)); |
4202 memset(&cargo_allowed, 0, sizeof(cargo_allowed)); |
3595 memset(&cargo_disallowed, 0, sizeof(cargo_disallowed)); |
4203 memset(&cargo_disallowed, 0, sizeof(cargo_disallowed)); |
3596 |
4204 |
3597 // Reset GRM reservations |
4205 /* Reset GRM reservations */ |
3598 memset(&_grm_engines, 0, sizeof(_grm_engines)); |
4206 memset(&_grm_engines, 0, sizeof(_grm_engines)); |
3599 |
4207 |
3600 // Unload sprite group data |
4208 /* Unload sprite group data */ |
3601 UnloadWagonOverrides(); |
4209 UnloadWagonOverrides(); |
3602 UnloadRotorOverrideSprites(); |
4210 UnloadRotorOverrideSprites(); |
3603 UnloadCustomEngineSprites(); |
4211 UnloadCustomEngineSprites(); |
3604 UnloadCustomEngineNames(); |
4212 UnloadCustomEngineNames(); |
3605 ResetEngineListOrder(); |
4213 ResetEngineListOrder(); |
3606 |
4214 |
3607 // Reset price base data |
4215 /* Reset price base data */ |
3608 ResetPriceBaseMultipliers(); |
4216 ResetPriceBaseMultipliers(); |
3609 |
4217 |
3610 /* Reset the curencies array */ |
4218 /* Reset the curencies array */ |
3611 ResetCurrencies(); |
4219 ResetCurrencies(); |
3612 |
4220 |
3613 // Reset station classes |
4221 /* Reset the house array */ |
|
4222 ResetCustomHouses(); |
|
4223 ResetHouses(); |
|
4224 |
|
4225 /* Reset station classes */ |
3614 ResetStationClasses(); |
4226 ResetStationClasses(); |
3615 ResetCustomStations(); |
4227 ResetCustomStations(); |
3616 |
4228 |
|
4229 /* Reset the snowline table. */ |
|
4230 ClearSnowLine(); |
|
4231 |
3617 /* Reset NewGRF files */ |
4232 /* Reset NewGRF files */ |
3618 ResetNewGRF(); |
4233 ResetNewGRF(); |
3619 |
4234 |
3620 // Add engine type to engine data. This is needed for the refit precalculation. |
4235 /* Add engine type to engine data. This is needed for the refit precalculation. */ |
3621 AddTypeToEngines(); |
4236 AddTypeToEngines(); |
3622 |
4237 |
3623 /* Set up the default cargo types */ |
4238 /* Set up the default cargo types */ |
3624 SetupCargoForClimate(_opt.landscape); |
4239 SetupCargoForClimate(_opt.landscape); |
3625 |
|
3626 /* Generate default cargo translation table */ |
|
3627 memset(_default_cargo_list, 0, sizeof(_default_cargo_list)); |
|
3628 for (CargoID c = 0; c != NUM_CARGO; c++) { |
|
3629 const CargoSpec *cs = GetCargo(c); |
|
3630 if (cs->IsValid()) _default_cargo_list[cs->bitnum] = cs->label; |
|
3631 } |
|
3632 |
4240 |
3633 /* Reset misc GRF features and train list display variables */ |
4241 /* Reset misc GRF features and train list display variables */ |
3634 _misc_grf_features = 0; |
4242 _misc_grf_features = 0; |
3635 _traininfo_vehicle_pitch = 0; |
4243 _traininfo_vehicle_pitch = 0; |
3636 _traininfo_vehicle_width = 29; |
4244 _traininfo_vehicle_width = 29; |
3637 _have_2cc = false; |
4245 _have_2cc = false; |
|
4246 _have_newhouses = false; |
3638 _signal_base = 0; |
4247 _signal_base = 0; |
3639 _coast_base = 0; |
4248 _coast_base = 0; |
3640 |
4249 |
3641 InitializeSoundPool(); |
4250 InitializeSoundPool(); |
3642 InitializeSpriteGroupPool(); |
4251 InitializeSpriteGroupPool(); |
3755 /* Skip engine if not available in this climate */ |
4364 /* Skip engine if not available in this climate */ |
3756 if (!HASBIT(_engine_info[engine].climates, _opt.landscape)) continue; |
4365 if (!HASBIT(_engine_info[engine].climates, _opt.landscape)) continue; |
3757 |
4366 |
3758 uint32 mask = 0; |
4367 uint32 mask = 0; |
3759 uint32 not_mask = 0; |
4368 uint32 not_mask = 0; |
3760 uint32 xor_mask = _engine_info[engine].refit_mask; |
4369 uint32 xor_mask = 0; |
|
4370 |
|
4371 if (_engine_info[engine].refit_mask != 0) { |
|
4372 const GRFFile *file = GetEngineGRF(engine); |
|
4373 if (file != NULL && file->cargo_max != 0) { |
|
4374 /* Apply cargo translation table to the refit mask */ |
|
4375 uint num_cargo = min(32, file->cargo_max); |
|
4376 for (uint i = 0; i < num_cargo; i++) { |
|
4377 if (!HASBIT(_engine_info[engine].refit_mask, i)) continue; |
|
4378 |
|
4379 CargoID c = GetCargoIDByLabel(file->cargo_list[i]); |
|
4380 if (c == CT_INVALID) continue; |
|
4381 |
|
4382 SETBIT(xor_mask, c); |
|
4383 } |
|
4384 } else { |
|
4385 /* No cargo table, so use the cargo bitnum values */ |
|
4386 for (CargoID c = 0; c < NUM_CARGO; c++) { |
|
4387 const CargoSpec *cs = GetCargo(c); |
|
4388 if (!cs->IsValid()) continue; |
|
4389 |
|
4390 if (HASBIT(_engine_info[engine].refit_mask, cs->bitnum)) SETBIT(xor_mask, c); |
|
4391 } |
|
4392 } |
|
4393 } |
3761 |
4394 |
3762 if (cargo_allowed[engine] != 0) { |
4395 if (cargo_allowed[engine] != 0) { |
3763 // Build up the list of cargo types from the set cargo classes. |
4396 /* Build up the list of cargo types from the set cargo classes. */ |
3764 for (CargoID i = 0; i < NUM_CARGO; i++) { |
4397 for (CargoID i = 0; i < NUM_CARGO; i++) { |
3765 const CargoSpec *cs = GetCargo(i); |
4398 const CargoSpec *cs = GetCargo(i); |
3766 if (cargo_allowed[engine] & cs->classes) SETBIT(mask, i); |
4399 if (cargo_allowed[engine] & cs->classes) SETBIT(mask, i); |
3767 if (cargo_disallowed[engine] & cs->classes) SETBIT(not_mask, i); |
4400 if (cargo_disallowed[engine] & cs->classes) SETBIT(not_mask, i); |
3768 } |
4401 } |
3769 } else { |
4402 } else { |
3770 // Don't apply default refit mask to wagons or engines with no capacity |
4403 /* Don't apply default refit mask to wagons or engines with no capacity */ |
3771 if (xor_mask == 0 && ( |
4404 if (xor_mask == 0 && ( |
3772 GetEngine(engine)->type != VEH_TRAIN || ( |
4405 GetEngine(engine)->type != VEH_TRAIN || ( |
3773 RailVehInfo(engine)->capacity != 0 && |
4406 RailVehInfo(engine)->capacity != 0 && |
3774 RailVehInfo(engine)->railveh_type != RAILVEH_WAGON |
4407 RailVehInfo(engine)->railveh_type != RAILVEH_WAGON |
3775 ) |
4408 ) |
3811 break; |
4442 break; |
3812 } |
4443 } |
3813 } |
4444 } |
3814 } |
4445 } |
3815 } |
4446 } |
|
4447 |
|
4448 /** Add all new houses to the house array. House properties can be set at any |
|
4449 * time in the GRF file, so we can only add a house spec to the house array |
|
4450 * after the file has finished loading. We also need to check the dates, due to |
|
4451 * the TTDPatch behaviour described below that we need to emulate. */ |
|
4452 static void FinaliseHouseArray() |
|
4453 { |
|
4454 /* If there are no houses with start dates before 1930, then all houses |
|
4455 * with start dates of 1930 have them reset to 0. This is in order to be |
|
4456 * compatible with TTDPatch, where if no houses have start dates before |
|
4457 * 1930 and the date is before 1930, the game pretends that this is 1930. |
|
4458 * If there have been any houses defined with start dates before 1930 then |
|
4459 * the dates are left alone. */ |
|
4460 bool reset_dates = true; |
|
4461 |
|
4462 for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
|
4463 if (file->housespec == NULL) continue; |
|
4464 |
|
4465 for (int i = 0; i < HOUSE_MAX; i++) { |
|
4466 HouseSpec *hs = file->housespec[i]; |
|
4467 if (hs != NULL) { |
|
4468 SetHouseSpec(hs); |
|
4469 if (hs->min_date < 1930) reset_dates = false; |
|
4470 } |
|
4471 } |
|
4472 } |
|
4473 |
|
4474 if (reset_dates) { |
|
4475 for (int i = NEW_HOUSE_OFFSET; i < HOUSE_MAX; i++) { |
|
4476 HouseSpec *hs = GetHouseSpecs(i); |
|
4477 |
|
4478 if (hs->enabled && hs->min_date == 1930) hs->min_date = 0; |
|
4479 } |
|
4480 } |
|
4481 } |
|
4482 |
|
4483 |
|
4484 /** Each cargo string needs to be mapped from TTDPatch to OpenTTD string IDs. |
|
4485 * This is done after loading so that strings from Action 4 will be mapped |
|
4486 * properly. */ |
|
4487 static void MapNewCargoStrings() |
|
4488 { |
|
4489 for (CargoID c = 0; c < NUM_CARGO; c++) { |
|
4490 CargoSpec *cs = &_cargo[c]; |
|
4491 /* Don't map if the cargo is unavailable or not from NewGRF */ |
|
4492 if (!cs->IsValid() || cs->grfid == 0) continue; |
|
4493 |
|
4494 cs->name = MapGRFStringID(cs->grfid, cs->name); |
|
4495 cs->name_plural = MapGRFStringID(cs->grfid, cs->name_plural); |
|
4496 cs->units_volume = MapGRFStringID(cs->grfid, cs->units_volume); |
|
4497 cs->quantifier = MapGRFStringID(cs->grfid, cs->quantifier); |
|
4498 cs->abbrev = MapGRFStringID(cs->grfid, cs->abbrev); |
|
4499 } |
|
4500 } |
|
4501 |
3816 |
4502 |
3817 /* Here we perform initial decoding of some special sprites (as are they |
4503 /* Here we perform initial decoding of some special sprites (as are they |
3818 * described at http://www.ttdpatch.net/src/newgrf.txt, but this is only a very |
4504 * described at http://www.ttdpatch.net/src/newgrf.txt, but this is only a very |
3819 * partial implementation yet). */ |
4505 * partial implementation yet). */ |
3820 /* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
4506 /* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
3833 * --pasky */ |
4519 * --pasky */ |
3834 /* We need a pre-stage to set up GOTO labels of Action 0x10 because the grf |
4520 /* We need a pre-stage to set up GOTO labels of Action 0x10 because the grf |
3835 * is not in memory and scanning the file every time would be too expensive. |
4521 * is not in memory and scanning the file every time would be too expensive. |
3836 * In other stages we skip action 0x10 since it's already dealt with. */ |
4522 * In other stages we skip action 0x10 since it's already dealt with. */ |
3837 static const SpecialSpriteHandler handlers[][GLS_END] = { |
4523 static const SpecialSpriteHandler handlers[][GLS_END] = { |
3838 /* 0x00 */ { NULL, SafeChangeInfo, NULL, InitChangeInfo, FeatureChangeInfo, }, |
4524 /* 0x00 */ { NULL, SafeChangeInfo, NULL, InitChangeInfo, ReserveChangeInfo, FeatureChangeInfo, }, |
3839 /* 0x01 */ { NULL, GRFUnsafe, NULL, NULL, NewSpriteSet, }, |
4525 /* 0x01 */ { NULL, GRFUnsafe, NULL, NULL, NULL, NewSpriteSet, }, |
3840 /* 0x02 */ { NULL, GRFUnsafe, NULL, NULL, NewSpriteGroup, }, |
4526 /* 0x02 */ { NULL, GRFUnsafe, NULL, NULL, NULL, NewSpriteGroup, }, |
3841 /* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, FeatureMapSpriteGroup, }, |
4527 /* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, NULL, FeatureMapSpriteGroup, }, |
3842 /* 0x04 */ { NULL, NULL, NULL, NULL, FeatureNewName, }, |
4528 /* 0x04 */ { NULL, NULL, NULL, NULL, NULL, FeatureNewName, }, |
3843 /* 0x05 */ { NULL, NULL, NULL, NULL, GraphicsNew, }, |
4529 /* 0x05 */ { NULL, NULL, NULL, NULL, NULL, GraphicsNew, }, |
3844 /* 0x06 */ { NULL, NULL, NULL, CfgApply, CfgApply, }, |
4530 /* 0x06 */ { NULL, NULL, NULL, CfgApply, CfgApply, CfgApply, }, |
3845 /* 0x07 */ { NULL, NULL, NULL, NULL, SkipIf, }, |
4531 /* 0x07 */ { NULL, NULL, NULL, NULL, SkipIf, SkipIf, }, |
3846 /* 0x08 */ { ScanInfo, NULL, NULL, GRFInfo, GRFInfo, }, |
4532 /* 0x08 */ { ScanInfo, NULL, NULL, GRFInfo, NULL, GRFInfo, }, |
3847 /* 0x09 */ { NULL, NULL, NULL, SkipIf, SkipIf, }, |
4533 /* 0x09 */ { NULL, NULL, NULL, SkipIf, SkipIf, SkipIf, }, |
3848 /* 0x0A */ { NULL, NULL, NULL, NULL, SpriteReplace, }, |
4534 /* 0x0A */ { NULL, NULL, NULL, NULL, NULL, SpriteReplace, }, |
3849 /* 0x0B */ { NULL, NULL, NULL, GRFLoadError, GRFLoadError, }, |
4535 /* 0x0B */ { NULL, NULL, NULL, GRFLoadError, GRFLoadError, GRFLoadError, }, |
3850 /* 0x0C */ { NULL, NULL, NULL, GRFComment, GRFComment, }, |
4536 /* 0x0C */ { NULL, NULL, NULL, GRFComment, NULL, GRFComment, }, |
3851 /* 0x0D */ { NULL, SafeParamSet, NULL, ParamSet, ParamSet, }, |
4537 /* 0x0D */ { NULL, SafeParamSet, NULL, ParamSet, ParamSet, ParamSet, }, |
3852 /* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, }, |
4538 /* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, GRFInhibit, }, |
3853 /* 0x0F */ { NULL, NULL, NULL, NULL, NULL, }, |
4539 /* 0x0F */ { NULL, NULL, NULL, NULL, NULL, NULL, }, |
3854 /* 0x10 */ { NULL, NULL, DefineGotoLabel, NULL, NULL, }, |
4540 /* 0x10 */ { NULL, NULL, DefineGotoLabel, NULL, NULL, NULL, }, |
3855 /* 0x11 */ { NULL, GRFUnsafe, NULL, NULL, GRFSound, }, |
4541 /* 0x11 */ { NULL, GRFUnsafe, NULL, NULL, NULL, GRFSound, }, |
3856 /* 0x12 */ { NULL, NULL, NULL, NULL, LoadFontGlyph, }, |
4542 /* 0x12 */ { NULL, NULL, NULL, NULL, NULL, LoadFontGlyph, }, |
3857 /* 0x13 */ { NULL, NULL, NULL, NULL, TranslateGRFStrings, }, |
4543 /* 0x13 */ { NULL, NULL, NULL, NULL, NULL, TranslateGRFStrings, }, |
3858 }; |
4544 }; |
3859 |
4545 |
3860 byte* buf; |
4546 byte* buf; |
3861 |
4547 |
3862 if (_preload_sprite == NULL) { |
4548 if (_preload_sprite == NULL) { |