src/newgrf_cargo.cpp
author translators
Thu, 18 Dec 2008 18:47:39 +0000
changeset 10437 6d64230b9fb9
parent 9750 7114408dd1fa
permissions -rw-r--r--
(svn r14691) -Update: WebTranslator2 update to 2008-12-18 18:47:25
arabic_egypt - 132 fixed, 1 changed by khaloofah (133)
czech - 10 fixed, 25 changed by Hadez (35)
esperanto - 15 fixed by Athaba (15)
greek - 7 fixed by ouranogrammi (7)
indonesian - 88 changed by fanioz (88)
latvian - 117 fixed, 16 changed by peerer (83), marismols (50)
lithuanian - 15 fixed by Zogg (15)
malay - 38 fixed by tombakemas (5), Syed (33)
serbian - 39 fixed, 1 changed by Jenraux (40)
thai - 105 fixed by vetbook (105)
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     1
/* $Id$ */
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8756
diff changeset
     3
/** @file newgrf_cargo.cpp Implementation of NewGRF cargoes. */
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8756
diff changeset
     4
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     5
#include "stdafx.h"
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     6
#include "openttd.h"
6383
ec677b36d183 (svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138
parents: 6365
diff changeset
     7
#include "debug.h"
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     8
#include "cargotype.h"
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
     9
#include "newgrf.h"
b52bd4ca10b6 (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"
b52bd4ca10b6 (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"
b52bd4ca10b6 (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"
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    13
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    14
b52bd4ca10b6 (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)
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    16
{
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    17
	return 0;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    18
}
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    19
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    20
b52bd4ca10b6 (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)
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    22
{
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    23
	return 0;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    24
}
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    25
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    26
b52bd4ca10b6 (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)
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    28
{
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    29
	return;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    30
}
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    31
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    32
b52bd4ca10b6 (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)
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    34
{
6383
ec677b36d183 (svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138
parents: 6365
diff changeset
    35
	DEBUG(grf, 1, "Unhandled cargo property 0x%X", variable);
ec677b36d183 (svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138
parents: 6365
diff changeset
    36
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    37
	*available = false;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    38
	return 0;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    39
}
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    40
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    41
b52bd4ca10b6 (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)
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    43
{
6657
75f1dccae0dd (svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138
parents: 6460
diff changeset
    44
	/* Cargo action 2s should always have only 1 "loaded" state, but some
75f1dccae0dd (svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138
parents: 6460
diff changeset
    45
	 * times things don't follow the spec... */
75f1dccae0dd (svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138
parents: 6460
diff changeset
    46
	if (group->g.real.num_loaded > 0) return group->g.real.loaded[0];
75f1dccae0dd (svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138
parents: 6460
diff changeset
    47
	if (group->g.real.num_loading > 0) return group->g.real.loading[0];
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    48
6657
75f1dccae0dd (svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138
parents: 6460
diff changeset
    49
	return NULL;
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    50
}
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    51
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    52
b52bd4ca10b6 (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)
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    54
{
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    55
	res->GetRandomBits = &CargoGetRandomBits;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    56
	res->GetTriggers   = &CargoGetTriggers;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    57
	res->SetTriggers   = &CargoSetTriggers;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    58
	res->GetVariable   = &CargoGetVariable;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    59
	res->ResolveReal   = &CargoResolveReal;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    60
b52bd4ca10b6 (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;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    62
7327
d810677fb909 (svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium
parents: 7199
diff changeset
    63
	res->callback        = CBID_NO_CALLBACK;
6365
b52bd4ca10b6 (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;
b52bd4ca10b6 (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;
b52bd4ca10b6 (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;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    67
	res->trigger         = 0;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    68
	res->reseed          = 0;
8756
b6f8dc6a246f (svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents: 8564
diff changeset
    69
	res->count           = 0;
9750
7114408dd1fa (svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch
parents: 9728
diff changeset
    70
	res->grffile         = cs->grffile;
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    71
}
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    72
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    73
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    74
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    75
{
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    76
	const SpriteGroup *group;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    77
	ResolverObject object;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    78
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    79
	NewCargoResolver(&object, cs);
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    80
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    81
	group = Resolve(cs->group, &object);
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    82
	if (group == NULL || group->type != SGT_RESULT) return 0;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    83
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    84
	return group->g.result.sprite;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    85
}
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    86
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    87
7327
d810677fb909 (svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium
parents: 7199
diff changeset
    88
uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs)
6365
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    89
{
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    90
	ResolverObject object;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    91
	const SpriteGroup *group;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    92
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    93
	NewCargoResolver(&object, cs);
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    94
	object.callback = callback;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    95
	object.callback_param1 = param1;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    96
	object.callback_param2 = param2;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    97
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    98
	group = Resolve(cs->group, &object);
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
    99
	if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
   100
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
   101
	return group->g.callback.result;
b52bd4ca10b6 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
diff changeset
   102
}
6460
705fbddbf3dc (svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138
parents: 6383
diff changeset
   103
705fbddbf3dc (svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138
parents: 6383
diff changeset
   104
7717
3b26778638d1 (svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx
parents: 7327
diff changeset
   105
CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
6460
705fbddbf3dc (svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138
parents: 6383
diff changeset
   106
{
705fbddbf3dc (svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138
parents: 6383
diff changeset
   107
	/* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */
7717
3b26778638d1 (svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx
parents: 7327
diff changeset
   108
	if (grffile->grf_version < 7) {
3b26778638d1 (svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx
parents: 7327
diff changeset
   109
		if (!usebit) return cargo;
3b26778638d1 (svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx
parents: 7327
diff changeset
   110
		/* Else the cargo value is a 'climate independent' 'bitnum' */
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7717
diff changeset
   111
		if (HasBit(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo);
7717
3b26778638d1 (svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx
parents: 7327
diff changeset
   112
	} else {
9728
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   113
		/* If the GRF contains a translation table... */
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   114
		if (grffile->cargo_max > 0) {
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   115
			/* ...and the cargo is in bounds, then get the cargo ID for
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   116
			 * the label */
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   117
			if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   118
		} else {
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   119
			/* Else the cargo value is a 'climate independent' 'bitnum' */
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   120
			if (HasBit(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo);
60bc400cb942 (svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
peter1138
parents: 9111
diff changeset
   121
		}
7717
3b26778638d1 (svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx
parents: 7327
diff changeset
   122
	}
3b26778638d1 (svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx
parents: 7327
diff changeset
   123
	return CT_INVALID;
6460
705fbddbf3dc (svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138
parents: 6383
diff changeset
   124
}
7199
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   125
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   126
uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile)
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   127
{
8564
7e523a2943d4 (svn r12142) -Fix [FS#1766]: Callback 0x3D always gets a cargobit in var 0x18, independent of grf version.
frosch
parents: 7928
diff changeset
   128
	/* Note: All grf versions use CargoBit here. Pre-version 7 do NOT use the 'climate dependent' ID. */
7199
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   129
	const CargoSpec *cs = GetCargo(cargo);
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   130
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   131
	/* If the GRF contains a translation table (and the cargo is in the table)
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   132
	 * then get the cargo ID for the label */
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   133
	for (uint i = 0; i < grffile->cargo_max; i++) {
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   134
		if (cs->label == grffile->cargo_list[i]) return i;
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   135
	}
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   136
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   137
	/* No matching label was found, so we return the 'climate independent' 'bitnum' */
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   138
	return cs->bitnum;;
e65a28455ee3 (svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents: 6657
diff changeset
   139
}