(svn r4740) - Newstations: add function to evaluate station callbacks
This commit is contained in:
		@@ -10,6 +10,7 @@
 | 
				
			|||||||
#include "table/strings.h"
 | 
					#include "table/strings.h"
 | 
				
			||||||
#include "station.h"
 | 
					#include "station.h"
 | 
				
			||||||
#include "station_map.h"
 | 
					#include "station_map.h"
 | 
				
			||||||
 | 
					#include "newgrf_callbacks.h"
 | 
				
			||||||
#include "newgrf_station.h"
 | 
					#include "newgrf_station.h"
 | 
				
			||||||
#include "newgrf_spritegroup.h"
 | 
					#include "newgrf_spritegroup.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -345,6 +346,32 @@ SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint16 GetStationCallback(uint16 callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const SpriteGroup *group;
 | 
				
			||||||
 | 
						ResolverObject object;
 | 
				
			||||||
 | 
						CargoID ctype = (st == NULL) ? GC_PURCHASE : GC_DEFAULT_NA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						NewStationResolver(&object, statspec, st, tile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						object.callback        = callback;
 | 
				
			||||||
 | 
						object.callback_param1 = param1;
 | 
				
			||||||
 | 
						object.callback_param2 = param2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						group = Resolve(statspec->spritegroup[ctype], &object);
 | 
				
			||||||
 | 
						if ((group == NULL || group->type != SGT_CALLBACK) && ctype != GC_DEFAULT_NA) {
 | 
				
			||||||
 | 
							group = Resolve(statspec->spritegroup[GC_DEFAULT_NA], &object);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if ((group == NULL || group->type != SGT_CALLBACK) && ctype != GC_DEFAULT) {
 | 
				
			||||||
 | 
							group = Resolve(statspec->spritegroup[GC_DEFAULT], &object);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return group->g.callback.result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Allocate a StationSpec to a Station. This is called once per build operation.
 | 
					 * Allocate a StationSpec to a Station. This is called once per build operation.
 | 
				
			||||||
 * @param spec StationSpec to allocate.
 | 
					 * @param spec StationSpec to allocate.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,6 +99,7 @@ const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station);
 | 
				
			|||||||
 * NULL - that means we are in a build dialog). The station structure is used
 | 
					 * NULL - that means we are in a build dialog). The station structure is used
 | 
				
			||||||
 * for variational sprite groups. */
 | 
					 * for variational sprite groups. */
 | 
				
			||||||
SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
 | 
					SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
 | 
				
			||||||
 | 
					uint16 GetStationCallback(uint16 callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Allocate a StationSpec to a Station. This is called once per build operation. */
 | 
					/* Allocate a StationSpec to a Station. This is called once per build operation. */
 | 
				
			||||||
int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec);
 | 
					int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user