station_cmd.c
changeset 408 63a8c0505aab
parent 405 6830ae7a0d5d
child 413 36afcda97345
equal deleted inserted replaced
407:6de2d3c7f0e3 408:63a8c0505aab
   975 
   975 
   976 		for (i = 0; i <= _waypoint_highest_id; i++) {
   976 		for (i = 0; i <= _waypoint_highest_id; i++) {
   977 			if (_waypoint_data[i].grfid == spec->grfid
   977 			if (_waypoint_data[i].grfid == spec->grfid
   978 			    && _waypoint_data[i].localidx == local_stid + 1) {
   978 			    && _waypoint_data[i].localidx == local_stid + 1) {
   979 				stid = i;
   979 				stid = i;
       
   980 				/* FIXME: Release original SpriteGroup to
       
   981 				 * prevent leaks. But first we need to
       
   982 				 * refcount the SpriteGroup. --pasky */
   980 				break;
   983 				break;
   981 			}
   984 			}
   982 		}
   985 		}
   983 	}
   986 	}
   984 
   987 
  1001 	if (stid > _waypoint_highest_id)
  1004 	if (stid > _waypoint_highest_id)
  1002 		return NULL;
  1005 		return NULL;
  1003 	return &_waypoint_data[stid];
  1006 	return &_waypoint_data[stid];
  1004 }
  1007 }
  1005 
  1008 
  1006 uint32 GetCustomStationRelocation(struct StationSpec *spec, byte ctype)
  1009 uint32 GetCustomStationRelocation(struct StationSpec *spec, struct Station *stat, byte ctype)
  1007 {
  1010 {
       
  1011 	struct RealSpriteGroup *rsg;
       
  1012 
  1008 	assert(spec->classid == 'WAYP');
  1013 	assert(spec->classid == 'WAYP');
  1009 
  1014 
  1010 	/* In the future, variational spritegroups will kick in through this
  1015 	/* In the future, variational spritegroups will kick in through this
  1011 	 * accessor.  */
  1016 	 * accessor, using @stat.  */
  1012 
  1017 	rsg = TriviallyGetRSG(&spec->spritegroup[ctype]);
  1013 	if (spec->relocation[ctype].loading_count != 0) {
  1018 
  1014 		return spec->relocation[ctype].loading[0];
  1019 	if (rsg->sprites_per_set != 0) {
  1015 	} else if (spec->relocation[ctype].loading_count != 0) {
  1020 		if (rsg->loading_count != 0) {
  1016 		return spec->relocation[ctype].loaded[0];
  1021 			return rsg->loading[0];
  1017 	} else {
  1022 		} else if (rsg->loading_count != 0) {
  1018 		error("Custom station 0x%08x::0x%02x has no sprites associated.",
  1023 			return rsg->loaded[0];
  1019 		       spec->grfid, spec->localidx);
  1024 		}
  1020 		/* This is what gets subscribed of dtss->image in grfspecial.c,
  1025 	}
  1021 		 * so it's probably kinda "default offset". Try to use it as
  1026 
  1022 		 * emergency measure. */
  1027 	error("Custom station 0x%08x::0x%02x has no sprites associated.",
  1023 		return 0x42D;
  1028 	       spec->grfid, spec->localidx);
  1024 	}
  1029 	/* This is what gets subscribed of dtss->image in grfspecial.c,
       
  1030 	 * so it's probably kinda "default offset". Try to use it as
       
  1031 	 * emergency measure. */
       
  1032 	return 0x42D;
  1025 }
  1033 }
  1026 
  1034 
  1027 int GetCustomStationsCount(uint32 classid)
  1035 int GetCustomStationsCount(uint32 classid)
  1028 {
  1036 {
  1029 	assert(classid == 'WAYP');
  1037 	assert(classid == 'WAYP');