Mercurial > hg > openttd
annotate src/newgrf_cargo.cpp @ 8386:b61dbe67cbb3 draft
(svn r11956) -Fix [FS#1675]: Disallow building locks and docks on rapids.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Wed, 23 Jan 2008 08:47:49 +0000 |
parents | 4e8dfd103163 |
children | 2785566a8c4e |
rev | line source |
---|---|
6365
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
2 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
3 #include "stdafx.h" |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
4 #include "openttd.h" |
6383
1c59b042b9e3
(svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138 <peter1138@openttd.org>
parents:
6365
diff
changeset
|
5 #include "debug.h" |
6365
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
6 #include "cargotype.h" |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
7 #include "newgrf.h" |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
8 #include "newgrf_callbacks.h" |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
9 #include "newgrf_spritegroup.h" |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
10 #include "newgrf_cargo.h" |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
11 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
12 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
13 static uint32 CargoGetRandomBits(const ResolverObject *object) |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
14 { |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
15 return 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
16 } |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
17 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
18 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
19 static uint32 CargoGetTriggers(const ResolverObject *object) |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
20 { |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
21 return 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
22 } |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
23 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
24 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
25 static void CargoSetTriggers(const ResolverObject *object, int triggers) |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
26 { |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
27 return; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
28 } |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
29 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
30 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
31 static uint32 CargoGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
32 { |
6383
1c59b042b9e3
(svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138 <peter1138@openttd.org>
parents:
6365
diff
changeset
|
33 DEBUG(grf, 1, "Unhandled cargo property 0x%X", variable); |
1c59b042b9e3
(svn r9473) -Codechange: add 'unhandled variable' debug message to newcargo resolver
peter1138 <peter1138@openttd.org>
parents:
6365
diff
changeset
|
34 |
6365
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
35 *available = false; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
36 return 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
37 } |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
38 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
39 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
40 static const SpriteGroup *CargoResolveReal(const ResolverObject *object, const SpriteGroup *group) |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
41 { |
6657
05dc53b3e64a
(svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138 <peter1138@openttd.org>
parents:
6460
diff
changeset
|
42 /* Cargo action 2s should always have only 1 "loaded" state, but some |
05dc53b3e64a
(svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138 <peter1138@openttd.org>
parents:
6460
diff
changeset
|
43 * times things don't follow the spec... */ |
05dc53b3e64a
(svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138 <peter1138@openttd.org>
parents:
6460
diff
changeset
|
44 if (group->g.real.num_loaded > 0) return group->g.real.loaded[0]; |
05dc53b3e64a
(svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138 <peter1138@openttd.org>
parents:
6460
diff
changeset
|
45 if (group->g.real.num_loading > 0) return group->g.real.loading[0]; |
6365
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
46 |
6657
05dc53b3e64a
(svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138 <peter1138@openttd.org>
parents:
6460
diff
changeset
|
47 return NULL; |
6365
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
48 } |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
49 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
50 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
51 static void NewCargoResolver(ResolverObject *res, const CargoSpec *cs) |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
52 { |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
53 res->GetRandomBits = &CargoGetRandomBits; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
54 res->GetTriggers = &CargoGetTriggers; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
55 res->SetTriggers = &CargoSetTriggers; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
56 res->GetVariable = &CargoGetVariable; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
57 res->ResolveReal = &CargoResolveReal; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
58 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
59 res->u.cargo.cs = cs; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
60 |
7327
0ab2820a1e52
(svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium <rubidium@openttd.org>
parents:
7199
diff
changeset
|
61 res->callback = CBID_NO_CALLBACK; |
6365
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
62 res->callback_param1 = 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
63 res->callback_param2 = 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
64 res->last_value = 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
65 res->trigger = 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
66 res->reseed = 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
67 } |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
68 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
69 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
70 SpriteID GetCustomCargoSprite(const CargoSpec *cs) |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
71 { |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
72 const SpriteGroup *group; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
73 ResolverObject object; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
74 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
75 NewCargoResolver(&object, cs); |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
76 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
77 group = Resolve(cs->group, &object); |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
78 if (group == NULL || group->type != SGT_RESULT) return 0; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
79 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
80 return group->g.result.sprite; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
81 } |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
82 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
83 |
7327
0ab2820a1e52
(svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium <rubidium@openttd.org>
parents:
7199
diff
changeset
|
84 uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs) |
6365
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
85 { |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
86 ResolverObject object; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
87 const SpriteGroup *group; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
88 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
89 NewCargoResolver(&object, cs); |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
90 object.callback = callback; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
91 object.callback_param1 = param1; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
92 object.callback_param2 = param2; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
93 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
94 group = Resolve(cs->group, &object); |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
95 if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
96 |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
97 return group->g.callback.result; |
0d8a8ec46519
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents:
diff
changeset
|
98 } |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6383
diff
changeset
|
99 |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6383
diff
changeset
|
100 |
7717
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
101 CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit) |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6383
diff
changeset
|
102 { |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6383
diff
changeset
|
103 /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ |
7717
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
104 if (grffile->grf_version < 7) { |
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
105 if (!usebit) return cargo; |
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
106 /* Else the cargo value is a 'climate independent' 'bitnum' */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7717
diff
changeset
|
107 if (HasBit(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo); |
7717
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
108 } else { |
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
109 /* If the GRF contains a translation table (and the cargo is in bounds) |
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
110 * then get the cargo ID for the label */ |
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
111 if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]); |
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
112 } |
8dbe339637d3
(svn r11252) -Revert r11239, Fix r9620: cargo translation was not done correctly
glx <glx@openttd.org>
parents:
7327
diff
changeset
|
113 return CT_INVALID; |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6383
diff
changeset
|
114 } |
7199
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
115 |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
116 uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile) |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
117 { |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
118 /* Pre-version 7 uses the 'climate dependent' ID, i.e. cargo is the cargo ID */ |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
119 if (grffile->grf_version < 7) return cargo; |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
120 |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
121 const CargoSpec *cs = GetCargo(cargo); |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
122 |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
123 /* If the GRF contains a translation table (and the cargo is in the table) |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
124 * then get the cargo ID for the label */ |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
125 for (uint i = 0; i < grffile->cargo_max; i++) { |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
126 if (cs->label == grffile->cargo_list[i]) return i; |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
127 } |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
128 |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
129 /* No matching label was found, so we return the 'climate independent' 'bitnum' */ |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
130 return cs->bitnum;; |
0814b1155c40
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium <rubidium@openttd.org>
parents:
6657
diff
changeset
|
131 } |