grfspecial.c
changeset 391 279aef3587a5
parent 389 16ee9854091e
child 396 a89470eeb5d3
equal deleted inserted replaced
390:c67581486cde 391:279aef3587a5
    67 	GSF_TRAIN,
    67 	GSF_TRAIN,
    68 	GSF_ROAD,
    68 	GSF_ROAD,
    69 	GSF_SHIP,
    69 	GSF_SHIP,
    70 	GSF_AIRCRAFT,
    70 	GSF_AIRCRAFT,
    71 	GSF_STATION,
    71 	GSF_STATION,
       
    72 	GSF_BRIDGE,
       
    73 	GSF_TOWNHOUSE,
    72 };
    74 };
    73 
    75 
    74 
    76 
    75 typedef void (*SpecialSpriteHandler)(byte *buf, int len);
    77 typedef void (*SpecialSpriteHandler)(byte *buf, int len);
    76 
    78 
   695 	int ret = 0;
   697 	int ret = 0;
   696 
   698 
   697 	/* This is one single huge TODO. It doesn't handle anything more than
   699 	/* This is one single huge TODO. It doesn't handle anything more than
   698 	 * just waypoints for now. */
   700 	 * just waypoints for now. */
   699 
   701 
       
   702 	/* TODO: Differentiate between railtypes. This is missing in the new
       
   703 	 * GRF file specification yet, though, so I need to agree on this with
       
   704 	 * patchman yet. We just assume all the station stuff is for railtype 0
       
   705 	 * (railroad) for now. --pasky */
       
   706 
   700 	//printf("sci %d %d [0x%02x]\n", stid, numinfo, prop);
   707 	//printf("sci %d %d [0x%02x]\n", stid, numinfo, prop);
   701 	switch (prop) {
   708 	switch (prop) {
   702 		case 0x08:
   709 		case 0x08:
   703 		{	/* Class ID */
   710 		{	/* Class ID */
   704 			FOR_EACH_ENGINE {
   711 			FOR_EACH_ENGINE {
   875 	 * B id            ID of first vehicle/station to change, if num-info is
   882 	 * B id            ID of first vehicle/station to change, if num-info is
   876 	 *                 greater than one, this one and the following
   883 	 *                 greater than one, this one and the following
   877 	 *                 vehicles/stations will be changed
   884 	 *                 vehicles/stations will be changed
   878 	 * B property      what property to change, depends on the feature
   885 	 * B property      what property to change, depends on the feature
   879 	 * V new-info      new bytes of info (variable size; depends on properties) */
   886 	 * V new-info      new bytes of info (variable size; depends on properties) */
   880 	/* TODO: Stations. */
   887 	/* TODO: Bridges, town houses. */
   881 
   888 
   882 	static const VCI_Handler handler[5] = {
   889 	static const VCI_Handler handler[7] = {
   883 		/* GSF_TRAIN */    RailVehicleChangeInfo,
   890 		/* GSF_TRAIN */    RailVehicleChangeInfo,
   884 		/* GSF_ROAD */     RoadVehicleChangeInfo,
   891 		/* GSF_ROAD */     RoadVehicleChangeInfo,
   885 		/* GSF_SHIP */     ShipVehicleChangeInfo,
   892 		/* GSF_SHIP */     ShipVehicleChangeInfo,
   886 		/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo,
   893 		/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo,
   887 		/* GSF_STATION */  StationChangeInfo,
   894 		/* GSF_STATION */  StationChangeInfo,
       
   895 		/* GSF_BRIDGE */   NULL,
       
   896 		/* GSF_TOWNHOUSE */NULL,
   888 	};
   897 	};
   889 
   898 
   890 	uint8 feature;
   899 	uint8 feature;
   891 	uint8 numprops;
   900 	uint8 numprops;
   892 	uint8 numinfo;
   901 	uint8 numinfo;
   899 	numinfo = buf[3];
   908 	numinfo = buf[3];
   900 	engine = buf[4];
   909 	engine = buf[4];
   901 
   910 
   902 	DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d",
   911 	DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d",
   903 	               feature, numprops, engine, numinfo);
   912 	               feature, numprops, engine, numinfo);
       
   913 
       
   914 	if (feature > GSF_STATION) {
       
   915 		grfmsg(GMS_WARN, "VehicleChangeInfo: Unsupported feature %d, skipping.", feature);
       
   916 		return;
       
   917 	}
   904 
   918 
   905 	if (feature != GSF_STATION)
   919 	if (feature != GSF_STATION)
   906 		ei = &_engine_info[engine + _vehshifts[feature]];
   920 		ei = &_engine_info[engine + _vehshifts[feature]];
   907 
   921 
   908 	buf += 5;
   922 	buf += 5;
  1135 	 * B num-cid       number of cargo IDs (sprite group IDs) in this definition
  1149 	 * B num-cid       number of cargo IDs (sprite group IDs) in this definition
  1136 	 *                 can be zero, in that case the def-cid is used always
  1150 	 *                 can be zero, in that case the def-cid is used always
  1137 	 * B cargo-type    type of this cargo type (e.g. mail=2, wood=7, see below)
  1151 	 * B cargo-type    type of this cargo type (e.g. mail=2, wood=7, see below)
  1138 	 * W cid           cargo ID (sprite group ID) for this type of cargo
  1152 	 * W cid           cargo ID (sprite group ID) for this type of cargo
  1139 	 * W def-cid       default cargo ID (sprite group ID) */
  1153 	 * W def-cid       default cargo ID (sprite group ID) */
  1140 	/* TODO: Only trains supported now. */
  1154 	/* TODO: Bridges, town houses. */
  1141 	/* TODO: Multiple cargo support could be useful even for trains/cars -
  1155 	/* TODO: Multiple cargo support could be useful even for trains/cars -
  1142 	 * cargo id 0xff is used for showing images in the build train list. */
  1156 	 * cargo id 0xff is used for showing images in the build train list. */
  1143 
  1157 
  1144 	static byte *last_engines;
  1158 	static byte *last_engines;
  1145 	static int last_engines_count;
  1159 	static int last_engines_count;
  1157 	cidcount = buf[3 + idcount];
  1171 	cidcount = buf[3 + idcount];
  1158 	check_length(len, 4 + idcount + cidcount * 3, "VehicleMapSpriteGroup");
  1172 	check_length(len, 4 + idcount + cidcount * 3, "VehicleMapSpriteGroup");
  1159 
  1173 
  1160 	DEBUG(grf, 6) ("VehicleMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d.",
  1174 	DEBUG(grf, 6) ("VehicleMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d.",
  1161 			feature, idcount, cidcount, wagover);
  1175 			feature, idcount, cidcount, wagover);
       
  1176 
       
  1177 	if (feature > GSF_STATION) {
       
  1178 		grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Unsupported feature %d, skipping.", feature);
       
  1179 		return;
       
  1180 	}
  1162 
  1181 
  1163 
  1182 
  1164 	if (feature == GSF_STATION) {
  1183 	if (feature == GSF_STATION) {
  1165 		// We do things differently for stations.
  1184 		// We do things differently for stations.
  1166 
  1185