|
@@ -10,12 +10,13 @@
|
|
|
/** @file newgrf_cargo.cpp Implementation of NewGRF cargoes. */
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include "debug.h"
|
|
|
#include "newgrf_spritegroup.h"
|
|
|
|
|
|
/** Resolver of cargo. */
|
|
|
struct CargoResolverObject : public ResolverObject {
|
|
|
CargoResolverObject(const CargoSpec *cs, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
|
|
|
|
|
|
/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
|
|
|
};
|
|
|
|
|
@@ -26,17 +27,29 @@ struct CargoResolverObject : public Reso
|
|
|
if (group->num_loaded > 0) return group->loaded[0];
|
|
|
if (group->num_loading > 0) return group->loading[0];
|
|
|
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Constructor of the cargo resolver.
|
|
|
* @param cs Cargo being resolved.
|
|
|
* @param callback Callback ID.
|
|
|
* @param callback_param1 First parameter (var 10) of the callback.
|
|
|
* @param callback_param2 Second parameter (var 18) of the callback.
|
|
|
*/
|
|
|
CargoResolverObject::CargoResolverObject(const CargoSpec *cs, CallbackID callback, uint32 callback_param1, uint32 callback_param2)
|
|
|
: ResolverObject(cs->grffile, callback, callback_param1, callback_param2)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the custom sprite for the given cargo type.
|
|
|
* @param cs Cargo being queried.
|
|
|
* @return Custom sprite to draw, or \c 0 if not available.
|
|
|
*/
|
|
|
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
|
|
|
{
|
|
|
CargoResolverObject object(cs);
|
|
|
const SpriteGroup *group = SpriteGroup::Resolve(cs->group, &object);
|
|
|
if (group == NULL) return 0;
|
|
|
|