src/newgrf.cpp
changeset 6769 13ccbd0f86b3
parent 6765 50903afa1a48
child 6781 17e17ed7d032
equal deleted inserted replaced
6768:379e38fcab7e 6769:13ccbd0f86b3
    72 static uint32 _ttdpatch_flags[8];
    72 static uint32 _ttdpatch_flags[8];
    73 
    73 
    74 /* Used by Action 0x06 to preload a pseudo sprite and modify its content */
    74 /* Used by Action 0x06 to preload a pseudo sprite and modify its content */
    75 static byte *_preload_sprite = NULL;
    75 static byte *_preload_sprite = NULL;
    76 
    76 
    77 /* Set if any vehicle is loaded which uses 2cc (two company colours) */
    77 /* Indicates which are the newgrf features currently loaded ingame */
    78 bool _have_2cc = false;
    78 uint8 _loaded_newgrf_features;
    79 
       
    80 /* Set if there are any newhouses loaded. */
       
    81 bool _have_newhouses = false;
       
    82 
       
    83 
    79 
    84 enum GrfDataType {
    80 enum GrfDataType {
    85 	GDT_SOUND,
    81 	GDT_SOUND,
    86 };
    82 };
    87 
    83 
   537 			break;
   533 			break;
   538 
   534 
   539 		case 0x27: // Miscellaneous flags
   535 		case 0x27: // Miscellaneous flags
   540 			FOR_EACH_OBJECT {
   536 			FOR_EACH_OBJECT {
   541 				ei[i].misc_flags = grf_load_byte(&buf);
   537 				ei[i].misc_flags = grf_load_byte(&buf);
   542 				if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true;
   538 				if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) SETBIT(_loaded_newgrf_features, GRFLOADED_2CC);
   543 			}
   539 			}
   544 			break;
   540 			break;
   545 
   541 
   546 		case 0x28: // Cargo classes allowed
   542 		case 0x28: // Cargo classes allowed
   547 			FOR_EACH_OBJECT cargo_allowed[engine + i] = grf_load_word(&buf);
   543 			FOR_EACH_OBJECT cargo_allowed[engine + i] = grf_load_word(&buf);
   659 			break;
   655 			break;
   660 
   656 
   661 		case 0x1C: // Miscellaneous flags
   657 		case 0x1C: // Miscellaneous flags
   662 			FOR_EACH_OBJECT {
   658 			FOR_EACH_OBJECT {
   663 				ei[i].misc_flags = grf_load_byte(&buf);
   659 				ei[i].misc_flags = grf_load_byte(&buf);
   664 				if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true;
   660 				if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) SETBIT(_loaded_newgrf_features, GRFLOADED_2CC);
   665 			}
   661 			}
   666 			break;
   662 			break;
   667 
   663 
   668 		case 0x1D: // Cargo classes allowed
   664 		case 0x1D: // Cargo classes allowed
   669 			FOR_EACH_OBJECT cargo_allowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf);
   665 			FOR_EACH_OBJECT cargo_allowed[ROAD_ENGINES_INDEX + engine + i] = grf_load_word(&buf);
   770 			break;
   766 			break;
   771 
   767 
   772 		case 0x17: // Miscellaneous flags
   768 		case 0x17: // Miscellaneous flags
   773 			FOR_EACH_OBJECT {
   769 			FOR_EACH_OBJECT {
   774 				ei[i].misc_flags = grf_load_byte(&buf);
   770 				ei[i].misc_flags = grf_load_byte(&buf);
   775 				if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true;
   771 				if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) SETBIT(_loaded_newgrf_features, GRFLOADED_2CC);
   776 			}
   772 			}
   777 			break;
   773 			break;
   778 
   774 
   779 		case 0x18: // Cargo classes allowed
   775 		case 0x18: // Cargo classes allowed
   780 			FOR_EACH_OBJECT cargo_allowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf);
   776 			FOR_EACH_OBJECT cargo_allowed[SHIP_ENGINES_INDEX + engine + i] = grf_load_word(&buf);
   886 			break;
   882 			break;
   887 
   883 
   888 		case 0x17: // Miscellaneous flags
   884 		case 0x17: // Miscellaneous flags
   889 			FOR_EACH_OBJECT {
   885 			FOR_EACH_OBJECT {
   890 				ei[i].misc_flags = grf_load_byte(&buf);
   886 				ei[i].misc_flags = grf_load_byte(&buf);
   891 				if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true;
   887 				if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) SETBIT(_loaded_newgrf_features, GRFLOADED_2CC);
   892 			}
   888 			}
   893 			break;
   889 			break;
   894 
   890 
   895 		case 0x18: // Cargo classes allowed
   891 		case 0x18: // Cargo classes allowed
   896 			FOR_EACH_OBJECT cargo_allowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf);
   892 			FOR_EACH_OBJECT cargo_allowed[AIRCRAFT_ENGINES_INDEX + engine + i] = grf_load_word(&buf);
  1295 				/* New houses do not (currently) expect to have a default start
  1291 				/* New houses do not (currently) expect to have a default start
  1296 				 * date before 1930, as this breaks the build date stuff. See
  1292 				 * date before 1930, as this breaks the build date stuff. See
  1297 				 * FinaliseHouseArray() for more details. */
  1293 				 * FinaliseHouseArray() for more details. */
  1298 				if (housespec[i]->min_date < 1930) housespec[i]->min_date = 1930;
  1294 				if (housespec[i]->min_date < 1930) housespec[i]->min_date = 1930;
  1299 			}
  1295 			}
  1300 			_have_newhouses = true;
  1296 			SETBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES);
  1301 			break;
  1297 			break;
  1302 
  1298 
  1303 		case 0x09: // Building flags
  1299 		case 0x09: // Building flags
  1304 			FOR_EACH_OBJECT {
  1300 			FOR_EACH_OBJECT {
  1305 				byte state = grf_load_byte(&buf);
  1301 				byte state = grf_load_byte(&buf);
  4457 
  4453 
  4458 	/* Reset misc GRF features and train list display variables */
  4454 	/* Reset misc GRF features and train list display variables */
  4459 	_misc_grf_features = 0;
  4455 	_misc_grf_features = 0;
  4460 	_traininfo_vehicle_pitch = 0;
  4456 	_traininfo_vehicle_pitch = 0;
  4461 	_traininfo_vehicle_width = 29;
  4457 	_traininfo_vehicle_width = 29;
  4462 	_have_2cc = false;
  4458 
  4463 	_have_newhouses = false;
  4459 	_loaded_newgrf_features = 0;
       
  4460 
  4464 	_signal_base = 0;
  4461 	_signal_base = 0;
  4465 	_coast_base = 0;
  4462 	_coast_base = 0;
  4466 
  4463 
  4467 	InitializeSoundPool();
  4464 	InitializeSoundPool();
  4468 	InitializeSpriteGroupPool();
  4465 	InitializeSpriteGroupPool();