src/newgrf_cargo.cpp
author richk
Tue, 17 Jun 2008 13:41:57 +0000
branchNewGRF_ports
changeset 10995 311b38c7f9a7
parent 10724 68a692eacf22
permissions -rw-r--r--
(svn r13549) [NewGRF_ports] -Change: Make recolouring of groundtile (0x0f80) specific to NewGRF_ports only.
Also base groundsprite on airport_tile of station. This prevents mixed colour groundtiles in an airport.
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     1
/* $Id$ */
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     2
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10184
diff changeset
     3
/** @file newgrf_cargo.cpp Implementation of NewGRF cargoes. */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10184
diff changeset
     4
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     5
#include "stdafx.h"
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     6
#include "openttd.h"
6709
e440af8c72ca (svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138
parents: 6691
diff changeset
     7
#include "debug.h"
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     8
#include "cargotype.h"
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     9
#include "newgrf.h"
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    10
#include "newgrf_callbacks.h"
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    11
#include "newgrf_spritegroup.h"
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    12
#include "newgrf_cargo.h"
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    13
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    14
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    15
static uint32 CargoGetRandomBits(const ResolverObject *object)
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    16
{
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    17
	return 0;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    18
}
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    19
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    20
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    21
static uint32 CargoGetTriggers(const ResolverObject *object)
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    22
{
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    23
	return 0;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    24
}
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    25
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    26
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    27
static void CargoSetTriggers(const ResolverObject *object, int triggers)
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    28
{
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    29
	return;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    30
}
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    31
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    32
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    33
static uint32 CargoGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    34
{
6709
e440af8c72ca (svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138
parents: 6691
diff changeset
    35
	DEBUG(grf, 1, "Unhandled cargo property 0x%X", variable);
e440af8c72ca (svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138
parents: 6691
diff changeset
    36
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    37
	*available = false;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    38
	return 0;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    39
}
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    40
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    41
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    42
static const SpriteGroup *CargoResolveReal(const ResolverObject *object, const SpriteGroup *group)
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    43
{
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
    44
	/* Cargo action 2s should always have only 1 "loaded" state, but some
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
    45
	 * times things don't follow the spec... */
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
    46
	if (group->g.real.num_loaded > 0) return group->g.real.loaded[0];
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
    47
	if (group->g.real.num_loading > 0) return group->g.real.loading[0];
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    48
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
    49
	return NULL;
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    50
}
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    51
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    52
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    53
static void NewCargoResolver(ResolverObject *res, const CargoSpec *cs)
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    54
{
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    55
	res->GetRandomBits = &CargoGetRandomBits;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    56
	res->GetTriggers   = &CargoGetTriggers;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    57
	res->SetTriggers   = &CargoSetTriggers;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    58
	res->GetVariable   = &CargoGetVariable;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    59
	res->ResolveReal   = &CargoResolveReal;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    60
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    61
	res->u.cargo.cs = cs;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    62
6743
cabfaa4a0295 (svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents: 6720
diff changeset
    63
	res->callback        = CBID_NO_CALLBACK;
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    64
	res->callback_param1 = 0;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    65
	res->callback_param2 = 0;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    66
	res->last_value      = 0;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    67
	res->trigger         = 0;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    68
	res->reseed          = 0;
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    69
	res->count           = 0;
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    70
}
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    71
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    72
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    73
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    74
{
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    75
	const SpriteGroup *group;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    76
	ResolverObject object;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    77
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    78
	NewCargoResolver(&object, cs);
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    79
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    80
	group = Resolve(cs->group, &object);
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    81
	if (group == NULL || group->type != SGT_RESULT) return 0;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    82
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    83
	return group->g.result.sprite;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    84
}
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    85
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    86
6743
cabfaa4a0295 (svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents: 6720
diff changeset
    87
uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs)
6691
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    88
{
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    89
	ResolverObject object;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    90
	const SpriteGroup *group;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    91
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    92
	NewCargoResolver(&object, cs);
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    93
	object.callback = callback;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    94
	object.callback_param1 = param1;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    95
	object.callback_param2 = param2;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    96
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    97
	group = Resolve(cs->group, &object);
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    98
	if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    99
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
   100
	return group->g.callback.result;
e8c27a509894 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
   101
}
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
   102
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
   103
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   104
CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
   105
{
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
   106
	/* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   107
	if (grffile->grf_version < 7) {
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   108
		if (!usebit) return cargo;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   109
		/* Else the cargo value is a 'climate independent' 'bitnum' */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   110
		if (HasBit(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   111
	} else {
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   112
		/* If the GRF contains a translation table (and the cargo is in bounds)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   113
		 * then get the cargo ID for the label */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   114
		if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   115
	}
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6743
diff changeset
   116
	return CT_INVALID;
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6709
diff changeset
   117
}
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   118
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   119
uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile)
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   120
{
6878
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents: 6871
diff changeset
   121
	/* Note: All grf versions use CargoBit here. Pre-version 7 do NOT use the 'climate dependent' ID. */
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   122
	const CargoSpec *cs = GetCargo(cargo);
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   123
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   124
	/* If the GRF contains a translation table (and the cargo is in the table)
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   125
	 * then get the cargo ID for the label */
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   126
	for (uint i = 0; i < grffile->cargo_max; i++) {
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   127
		if (cs->label == grffile->cargo_list[i]) return i;
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   128
	}
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   129
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   130
	/* No matching label was found, so we return the 'climate independent' 'bitnum' */
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   131
	return cs->bitnum;;
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   132
}