src/newgrf_industrytiles.cpp
author belugas
Wed, 13 Jun 2007 02:29:08 +0000
changeset 6884 a931841e9df4
child 6899 7edc4e4b1fd8
permissions -rw-r--r--
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
-Codechange: ResolverObject receives member gfx, making it compatible for both industries and industry tiles
-Codechange: NewIndustryResolver now has his randombits and triggers (even if not implemented)
6884
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     1
/* $Id$ */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     2
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     3
/** @file newgrf_industrytiles.cpp */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     4
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     5
#include "stdafx.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     6
#include "openttd.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     7
#include "functions.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     8
#include "variables.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
     9
#include "debug.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    10
#include "viewport.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    11
#include "landscape.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    12
#include "newgrf.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    13
#include "industry.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    14
#include "newgrf_commons.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    15
#include "newgrf_spritegroup.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    16
#include "newgrf_callbacks.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    17
#include "newgrf_industries.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    18
#include "industry_map.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    19
#include "clear_map.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    20
#include "table/sprites.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    21
#include "sprite.h"
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    22
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    23
/**
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    24
 * Based on newhouses equivalent, but adapted for newindustries
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    25
 * @param parameter from callback.  It's in fact a pair of coordinates
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    26
 * @param tile TileIndex from which the callback was initiated
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    27
 * @param index of the industry been queried for
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    28
 * @return a construction of bits obeying the newgrf format
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    29
 */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    30
static uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    31
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    32
	byte tile_type;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    33
	bool is_same_industry;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    34
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    35
	tile = GetNearbyTile(parameter, tile);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    36
	is_same_industry = (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == index);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    37
	tile_type = GetTerrainType(tile) << 2 | (IsTileType(tile, MP_WATER) ? 1 : 0) << 1 | (is_same_industry ? 1 : 0);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    38
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    39
	return GetTileType(tile) << 24 | (TileHeight(tile) * 8) << 16 | tile_type << 8 | GetTileSlope(tile, NULL);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    40
}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    41
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    42
/** This is the position of the tile relative to the northernmost tile of the industry.
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    43
 * Format: 00yxYYXX
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    44
 * Variable  Content
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    45
 * x         the x offset from the northernmost tile
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    46
 * XX        same, but stored in a byte instead of a nibble
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    47
 * y         the y offset from the northernmost tile
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    48
 * YY        same, but stored in a byte instead of a nibble
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    49
 * @param tile TileIndex of the tile to evaluate
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    50
 * @param ind_tile northernmost tile of the industry
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    51
 */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    52
static uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    53
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    54
	byte x = TileX(ind_tile) - TileX(tile);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    55
	byte y = TileY(ind_tile) - TileY(tile);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    56
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    57
	return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    58
}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    59
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    60
static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    61
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    62
	const Industry *inds = object->u.industry.ind;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    63
	TileIndex tile       = object->u.industry.tile;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    64
	IndustryGfx gfx      = object->u.industry.gfx;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    65
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    66
	if (object->scope == VSG_SCOPE_PARENT) {
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    67
		return IndustryGetVariable(object, variable, parameter, available);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    68
	}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    69
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    70
	switch (variable) {
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    71
		case 0x40 : return GetIndustryConstructionStage(tile); /* Construction state of the tile: a value between 0 and 3 */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    72
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    73
		case 0x41 : return GetTerrainType(tile);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    74
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    75
		case 0x42 : return GetTownRadiusGroup(ClosestTownFromTile(tile, (uint)-1), tile); /* Current town zone of the tile in the nearest town */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    76
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    77
		case 0x43 : return GetRelativePosition(tile, inds->xy); /* Relative position */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    78
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    79
		case 0x44 : break; /* Animation frame. Like house variable 46 but can contain anything 0..FF. */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    80
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    81
		case 0x60 : return GetNearbyIndustryTileInformation(parameter, tile, inds->index); /* Land info of nearby tiles */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    82
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    83
		case 0x61 : {/* Animation stage of nearby tiles */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    84
			tile = GetNearbyTile(parameter, tile);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    85
			return 0;  // TODO define the animation scheme for newgrf.  Based on same as old one?
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    86
		}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    87
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    88
		/* Get industry tile ID at offset */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    89
		case 0x62 : return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), tile, inds);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    90
	}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    91
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    92
	return 0;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    93
}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    94
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    95
static const SpriteGroup *IndustryTileResolveReal(const ResolverObject *object, const SpriteGroup *group)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    96
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    97
	/* IndustryTile do not have 'real' groups.  Or do they?? */
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    98
	return NULL;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
    99
}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   100
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   101
uint32 IndustryTileGetRandomBits(const ResolverObject *object)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   102
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   103
	const TileIndex tile = object->u.industry.tile;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   104
	return (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) ? 0 : GetIndustryRandomBits(tile);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   105
}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   106
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   107
uint32 IndustryTileGetTriggers(const ResolverObject *object)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   108
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   109
	const TileIndex tile = object->u.industry.tile;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   110
	return (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) ? 0 : GetIndustryTriggers(tile);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   111
}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   112
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   113
void IndustryTileSetTriggers(const ResolverObject *object, int triggers)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   114
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   115
	const TileIndex tile = object->u.industry.tile;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   116
	if (IsTileType(tile, MP_INDUSTRY)) SetIndustryTriggers(tile, triggers);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   117
}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   118
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   119
static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIndex tile, Industry *indus)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   120
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   121
	res->GetRandomBits = IndustryTileGetRandomBits;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   122
	res->GetTriggers   = IndustryTileGetTriggers;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   123
	res->SetTriggers   = IndustryTileSetTriggers;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   124
	res->GetVariable   = IndustryTileGetVariable;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   125
	res->ResolveReal   = IndustryTileResolveReal;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   126
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   127
	res->u.industry.tile = tile;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   128
	res->u.industry.ind  = indus;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   129
	res->u.industry.gfx  = gfx;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   130
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   131
	res->callback        = 0;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   132
	res->callback_param1 = 0;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   133
	res->callback_param2 = 0;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   134
	res->last_value      = 0;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   135
	res->trigger         = 0;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   136
	res->reseed          = 0;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   137
}
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   138
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   139
uint16 GetIndustryTileCallback(uint16 callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile)
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   140
{
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   141
	ResolverObject object;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   142
	const SpriteGroup *group;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   143
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   144
	NewIndustryTileResolver(&object, gfx_id, tile, industry);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   145
	object.callback = callback;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   146
	object.callback_param1 = param1;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   147
	object.callback_param2 = param2;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   148
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   149
	group = Resolve(GetIndustryTileSpec(gfx_id)->grf_prop.spritegroup, &object);
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   150
	if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   151
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   152
	return group->g.callback.result;
a931841e9df4 (svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff changeset
   153
}