Mercurial > hg > openttd
annotate src/newgrf_spritegroup.cpp @ 20307:93d7e37bd666 draft
(svn r25259) -Codechange: track capacities and usage of links
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 19 May 2013 14:22:04 +0000 |
parents | 0dba7f49118c |
children |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12027
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12027
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12027
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12027
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12027
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12027
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12027
diff
changeset
|
9 |
9111
d48433370037
(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 <rubidium@openttd.org>
parents:
9088
diff
changeset
|
10 /** @file newgrf_spritegroup.cpp Handling of primarily NewGRF action 2. */ |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
11 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #include "stdafx.h" |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
13 #include "debug.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
14 #include "newgrf_spritegroup.h" |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11933
diff
changeset
|
15 #include "core/pool_func.hpp" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
16 |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11933
diff
changeset
|
17 SpriteGroupPool _spritegroup_pool("SpriteGroup"); |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11933
diff
changeset
|
18 INSTANTIATE_POOL_METHODS(SpriteGroup) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
19 |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
20 RealSpriteGroup::~RealSpriteGroup() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
21 { |
18362
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18317
diff
changeset
|
22 free(this->loaded); |
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18317
diff
changeset
|
23 free(this->loading); |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
24 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
25 |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
26 DeterministicSpriteGroup::~DeterministicSpriteGroup() |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
27 { |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
28 free(this->adjusts); |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
29 free(this->ranges); |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
30 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
31 |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
32 RandomizedSpriteGroup::~RandomizedSpriteGroup() |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
33 { |
18362
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18317
diff
changeset
|
34 free(this->groups); |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
35 } |
6332
60486b0b3e39
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents:
6247
diff
changeset
|
36 |
14900
56c61f6f2085
(svn r19497) -Fix: [NewGRF] Bytes and words get sign-extended for temporary/persistent storage. (Spotted by yexo)
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
37 TemporaryStorageArray<int32, 0x110> _temp_store; |
6521
9aecb1a6dea5
(svn r9707) -Codechange: Add some support for NewGRF var 7D, temporary storage array.
peter1138 <peter1138@openttd.org>
parents:
6357
diff
changeset
|
38 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
39 |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
40 static inline uint32 GetVariable(const ResolverObject *object, ScopeResolver *scope, byte variable, uint32 parameter, bool *available) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
41 { |
8546
1b7b256d26af
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch <frosch@openttd.org>
parents:
8474
diff
changeset
|
42 /* First handle variables common with Action7/9/D */ |
1b7b256d26af
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch <frosch@openttd.org>
parents:
8474
diff
changeset
|
43 uint32 value; |
18317
a04775eae135
(svn r23153) -Change: [NewGRF v8] Use heightlevel units in variable 20/A0.
frosch <frosch@openttd.org>
parents:
18302
diff
changeset
|
44 if (GetGlobalVariable(variable, &value, object->grffile)) return value; |
8546
1b7b256d26af
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch <frosch@openttd.org>
parents:
8474
diff
changeset
|
45 |
1b7b256d26af
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch <frosch@openttd.org>
parents:
8474
diff
changeset
|
46 /* Non-common variable */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
47 switch (variable) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
48 case 0x0C: return object->callback; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
49 case 0x10: return object->callback_param1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
50 case 0x18: return object->callback_param2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
51 case 0x1C: return object->last_value; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
52 |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
53 case 0x5F: return (scope->GetRandomBits() << 8) | scope->GetTriggers(); |
9540
7afa7f629e6c
(svn r13544) -Codechange: Add support for NewGRF varaction2 variable 5F.
peter1138 <peter1138@openttd.org>
parents:
9111
diff
changeset
|
54 |
17779
c4ca794c8396
(svn r22564) -Codechange: Rename Get and Store persistent storage functions to GetValue and StoreValue.
terkhen <terkhen@openttd.org>
parents:
17778
diff
changeset
|
55 case 0x7D: return _temp_store.GetValue(parameter); |
6521
9aecb1a6dea5
(svn r9707) -Codechange: Add some support for NewGRF var 7D, temporary storage array.
peter1138 <peter1138@openttd.org>
parents:
6357
diff
changeset
|
56 |
9750
0654bf387d06
(svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch <frosch@openttd.org>
parents:
9540
diff
changeset
|
57 case 0x7F: |
14151
899cf0332cda
(svn r18699) -Fix [FS#PlanetAndy]: GRF parameters were not properly initialised to zero, and not always checked for valid range.
frosch <frosch@openttd.org>
parents:
13167
diff
changeset
|
58 if (object == NULL || object->grffile == NULL) return 0; |
899cf0332cda
(svn r18699) -Fix [FS#PlanetAndy]: GRF parameters were not properly initialised to zero, and not always checked for valid range.
frosch <frosch@openttd.org>
parents:
13167
diff
changeset
|
59 return object->grffile->GetParam(parameter); |
9750
0654bf387d06
(svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch <frosch@openttd.org>
parents:
9540
diff
changeset
|
60 |
19968
0dba7f49118c
(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents:
19762
diff
changeset
|
61 /* Not a common variable, so evaluate the feature specific variables */ |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
62 default: return scope->GetVariable(variable, parameter, available); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
63 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
64 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
65 |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
66 ScopeResolver::ScopeResolver(ResolverObject *ro) |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
67 { |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
68 this->ro = ro; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
69 } |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
70 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
71 ScopeResolver::~ScopeResolver() {} |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
72 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
73 /** |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
74 * Get a few random bits. Default implementation has no random bits. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
75 * @return Random bits. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
76 */ |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
77 /* virtual */ uint32 ScopeResolver::GetRandomBits() const |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
78 { |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
79 return 0; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
80 } |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
81 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
82 /** |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
83 * Get the triggers. Base class returns \c 0 to prevent trouble. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
84 * @return The triggers. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
85 */ |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
86 /* virtual */ uint32 ScopeResolver::GetTriggers() const |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
87 { |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
88 return 0; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
89 } |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
90 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
91 /** |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
92 * Set the triggers. Base class implementation does nothing. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
93 * @param triggers Triggers to set. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
94 */ |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
95 /* virtual */ void ScopeResolver::SetTriggers(int triggers) const {} |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
96 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
97 /** |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
98 * Get a variable value. Default implementation has no available variables. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
99 * @param variable Variable to read |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
100 * @param parameter Parameter for 60+x variables |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
101 * @param[out] available Set to false, in case the variable does not exist. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
102 * @return Value |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
103 */ |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
104 /* virtual */ uint32 ScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
105 { |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
106 DEBUG(grf, 1, "Unhandled scope variable 0x%X", variable); |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
107 *available = false; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
108 return UINT_MAX; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
109 } |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
110 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
111 /** |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
112 * Store a value into the persistent storage area (PSA). Default implementation does nothing (for newgrf classes without storage). |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
113 * @param pos Position to store into. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
114 * @param value Value to store. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
115 */ |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
116 /* virtual */ void ScopeResolver::StorePSA(uint reg, int32 value) {} |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
117 |
19760
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
118 /** |
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
119 * Resolver constructor. |
19968
0dba7f49118c
(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents:
19762
diff
changeset
|
120 * @param grffile NewGRF file associated with the object (or \c NULL if none). |
19760
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
121 * @param callback Callback code being resolved (default value is #CBID_NO_CALLBACK). |
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
122 * @param callback_param1 First parameter (var 10) of the callback (only used when \a callback is also set). |
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
123 * @param callback_param2 Second parameter (var 18) of the callback (only used when \a callback is also set). |
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
124 */ |
19746
65c85e05d795
(svn r24679) -Codechange: Add resolver classes for towns.
alberth <alberth@openttd.org>
parents:
19745
diff
changeset
|
125 ResolverObject::ResolverObject(const GRFFile *grffile, CallbackID callback, uint32 callback_param1, uint32 callback_param2) |
19759
a0cb237a6924
(svn r24692) -Cleanup: Cleanup final parts of the old resolver code.
alberth <alberth@openttd.org>
parents:
19746
diff
changeset
|
126 : default_scope(this) |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
127 { |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
128 this->callback = callback; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
129 this->callback_param1 = callback_param1; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
130 this->callback_param2 = callback_param2; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
131 this->ResetState(); |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
132 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
133 this->grffile = grffile; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
134 } |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
135 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
136 ResolverObject::~ResolverObject() {} |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
137 |
19760
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
138 /** |
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
139 * Get the real sprites of the grf. |
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
140 * @param group Group to get. |
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
141 * @return The available sprite group. |
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
142 */ |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
143 /* virtual */ const SpriteGroup *ResolverObject::ResolveReal(const RealSpriteGroup *group) const |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
144 { |
19759
a0cb237a6924
(svn r24692) -Cleanup: Cleanup final parts of the old resolver code.
alberth <alberth@openttd.org>
parents:
19746
diff
changeset
|
145 return NULL; |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
146 } |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
147 |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
148 /** |
19760
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
149 * Get a resolver for the \a scope. |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
150 * @param scope Scope to return. |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
151 * @param relative Additional parameter for #VSG_SCOPE_RELATIVE. |
19760
a8afd1ad99d8
(svn r24693) -Doc: Add some doxymentation into the newgrf code.
alberth <alberth@openttd.org>
parents:
19759
diff
changeset
|
152 * @return The resolver for the requested scope. |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
153 */ |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
154 /* virtual */ ScopeResolver *ResolverObject::GetScope(VarSpriteGroupScope scope, byte relative) |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
155 { |
19759
a0cb237a6924
(svn r24692) -Cleanup: Cleanup final parts of the old resolver code.
alberth <alberth@openttd.org>
parents:
19746
diff
changeset
|
156 return &this->default_scope; |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
157 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
158 |
7612
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
159 /** |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
160 * Rotate val rot times to the right |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
161 * @param val the value to rotate |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
162 * @param rot the amount of times to rotate |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
163 * @return the rotated value |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
164 */ |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
165 static uint32 RotateRight(uint32 val, uint32 rot) |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
166 { |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
167 /* Do not rotate more than necessary */ |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
168 rot %= 32; |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
169 |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
170 return (val >> rot) | (val << (32 - rot)); |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
171 } |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
172 |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
173 |
5600
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
174 /* Evaluate an adjustment for a variable of the given size. |
11361
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
175 * U is the unsigned type and S is the signed type to use. */ |
5600
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
176 template <typename U, typename S> |
19762
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
177 static U EvalAdjustT(const DeterministicSpriteGroupAdjust *adjust, ScopeResolver *scope, U last_value, uint32 value) |
5600
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
178 { |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
179 value >>= adjust->shift_num; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
180 value &= adjust->and_mask; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
181 |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
182 if (adjust->type != DSGA_TYPE_NONE) value += (S)adjust->add_val; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
183 |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
184 switch (adjust->type) { |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
185 case DSGA_TYPE_DIV: value /= (S)adjust->divmod_val; break; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
186 case DSGA_TYPE_MOD: value %= (U)adjust->divmod_val; break; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
187 case DSGA_TYPE_NONE: break; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
188 } |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
189 |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
190 switch (adjust->operation) { |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
191 case DSGA_OP_ADD: return last_value + value; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
192 case DSGA_OP_SUB: return last_value - value; |
5601
ca6b459bf488
(svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar <celestar@openttd.org>
parents:
5600
diff
changeset
|
193 case DSGA_OP_SMIN: return min((S)last_value, (S)value); |
ca6b459bf488
(svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar <celestar@openttd.org>
parents:
5600
diff
changeset
|
194 case DSGA_OP_SMAX: return max((S)last_value, (S)value); |
5600
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
195 case DSGA_OP_UMIN: return min((U)last_value, (U)value); |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
196 case DSGA_OP_UMAX: return max((U)last_value, (U)value); |
6617
bfd51a1acb47
(svn r9837) -Fix: [NewGRF] Catch occurance of division-by-zero in varaction handling.
peter1138 <peter1138@openttd.org>
parents:
6521
diff
changeset
|
197 case DSGA_OP_SDIV: return value == 0 ? (S)last_value : (S)last_value / (S)value; |
bfd51a1acb47
(svn r9837) -Fix: [NewGRF] Catch occurance of division-by-zero in varaction handling.
peter1138 <peter1138@openttd.org>
parents:
6521
diff
changeset
|
198 case DSGA_OP_SMOD: return value == 0 ? (S)last_value : (S)last_value % (S)value; |
bfd51a1acb47
(svn r9837) -Fix: [NewGRF] Catch occurance of division-by-zero in varaction handling.
peter1138 <peter1138@openttd.org>
parents:
6521
diff
changeset
|
199 case DSGA_OP_UDIV: return value == 0 ? (U)last_value : (U)last_value / (U)value; |
bfd51a1acb47
(svn r9837) -Fix: [NewGRF] Catch occurance of division-by-zero in varaction handling.
peter1138 <peter1138@openttd.org>
parents:
6521
diff
changeset
|
200 case DSGA_OP_UMOD: return value == 0 ? (U)last_value : (U)last_value % (U)value; |
5600
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
201 case DSGA_OP_MUL: return last_value * value; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
202 case DSGA_OP_AND: return last_value & value; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
203 case DSGA_OP_OR: return last_value | value; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
204 case DSGA_OP_XOR: return last_value ^ value; |
17779
c4ca794c8396
(svn r22564) -Codechange: Rename Get and Store persistent storage functions to GetValue and StoreValue.
terkhen <terkhen@openttd.org>
parents:
17778
diff
changeset
|
205 case DSGA_OP_STO: _temp_store.StoreValue((U)value, (S)last_value); return last_value; |
6521
9aecb1a6dea5
(svn r9707) -Codechange: Add some support for NewGRF var 7D, temporary storage array.
peter1138 <peter1138@openttd.org>
parents:
6357
diff
changeset
|
206 case DSGA_OP_RST: return value; |
19762
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
207 case DSGA_OP_STOP: scope->StorePSA((U)value, (S)last_value); return last_value; |
7612
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
208 case DSGA_OP_ROR: return RotateRight(last_value, value); |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
209 case DSGA_OP_SCMP: return ((S)last_value == (S)value) ? 1 : ((S)last_value < (S)value ? 0 : 2); |
967884079cd0
(svn r11141) -Codechange: add support for NewGRF's varaction2 operators 11, 12 and 13.
rubidium <rubidium@openttd.org>
parents:
7610
diff
changeset
|
210 case DSGA_OP_UCMP: return ((U)last_value == (U)value) ? 1 : ((U)last_value < (U)value ? 0 : 2); |
15668
433a5dc96551
(svn r20333) -Fix (r20332): Mask second operand to 5 bits to avoid differences between platforms.
frosch <frosch@openttd.org>
parents:
15667
diff
changeset
|
211 case DSGA_OP_SHL: return (U)last_value << ((U)value & 0x1F); // mask 'value' to 5 bits, which should behave the same on all architectures. |
433a5dc96551
(svn r20333) -Fix (r20332): Mask second operand to 5 bits to avoid differences between platforms.
frosch <frosch@openttd.org>
parents:
15667
diff
changeset
|
212 case DSGA_OP_SHR: return (U)last_value >> ((U)value & 0x1F); |
433a5dc96551
(svn r20333) -Fix (r20332): Mask second operand to 5 bits to avoid differences between platforms.
frosch <frosch@openttd.org>
parents:
15667
diff
changeset
|
213 case DSGA_OP_SAR: return (S)last_value >> ((U)value & 0x1F); |
5600
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
214 default: return value; |
37c5d98c3fa6
(svn r8054) -Codechange: Use a template function instead of a macro for evaluating NewGRF var adjusts
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
215 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
216 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
217 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
218 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
219 const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) const |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
220 { |
5607
f746786ae8b3
(svn r8063) -Codechange: When evaluating newgrf varaction2s the 'last value' should start off at 0, and the result of the operation is remembered.
peter1138 <peter1138@openttd.org>
parents:
5606
diff
changeset
|
221 uint32 last_value = 0; |
5606
1176330381e4
(svn r8062) -Codechange: change newgrf varaction2 value from signed to unsigned
peter1138 <peter1138@openttd.org>
parents:
5604
diff
changeset
|
222 uint32 value = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
223 uint i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
224 |
19762
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
225 ScopeResolver *scope = object->GetScope(this->var_scope); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
226 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
227 for (i = 0; i < this->num_adjusts; i++) { |
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
228 DeterministicSpriteGroupAdjust *adjust = &this->adjusts[i]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
229 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
230 /* Try to get the variable. We shall assume it is available, unless told otherwise. */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
231 bool available = true; |
5617
ef79a2605252
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros <maedhros@openttd.org>
parents:
5607
diff
changeset
|
232 if (adjust->variable == 0x7E) { |
13167
db329fb4c246
(svn r17672) -Revert (r8081): 'last_value' and 'reseed' are shared between procedure and main chain.
frosch <frosch@openttd.org>
parents:
13165
diff
changeset
|
233 const SpriteGroup *subgroup = SpriteGroup::Resolve(adjust->subroutine, object); |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
234 if (subgroup == NULL) { |
5617
ef79a2605252
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros <maedhros@openttd.org>
parents:
5607
diff
changeset
|
235 value = CALLBACK_FAILED; |
ef79a2605252
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros <maedhros@openttd.org>
parents:
5607
diff
changeset
|
236 } else { |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
237 value = subgroup->GetCallbackResult(); |
5617
ef79a2605252
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros <maedhros@openttd.org>
parents:
5607
diff
changeset
|
238 } |
13167
db329fb4c246
(svn r17672) -Revert (r8081): 'last_value' and 'reseed' are shared between procedure and main chain.
frosch <frosch@openttd.org>
parents:
13165
diff
changeset
|
239 |
19762
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
240 /* Note: 'last_value' and 'reseed' are shared between the main chain and the procedure */ |
16870
35ca0d633732
(svn r21604) -Add: Variable 7B for accessing 60+x variables while taking the parameter from the accumulator.
frosch <frosch@openttd.org>
parents:
16474
diff
changeset
|
241 } else if (adjust->variable == 0x7B) { |
19762
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
242 value = GetVariable(object, scope, adjust->parameter, last_value, &available); |
5617
ef79a2605252
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros <maedhros@openttd.org>
parents:
5607
diff
changeset
|
243 } else { |
19762
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
244 value = GetVariable(object, scope, adjust->variable, adjust->parameter, &available); |
5617
ef79a2605252
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros <maedhros@openttd.org>
parents:
5607
diff
changeset
|
245 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
246 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
247 if (!available) { |
16474
17ecbae7d3b4
(svn r21198) -Fix: don't call variables properties in debug messages
rubidium <rubidium@openttd.org>
parents:
15944
diff
changeset
|
248 /* Unsupported variable: skip further processing and return either |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
249 * the group from the first range or the default group. */ |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
250 return SpriteGroup::Resolve(this->num_ranges > 0 ? this->ranges[0].group : this->default_group, object); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
251 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
252 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
253 switch (this->size) { |
19762
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
254 case DSG_SIZE_BYTE: value = EvalAdjustT<uint8, int8> (adjust, scope, last_value, value); break; |
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
255 case DSG_SIZE_WORD: value = EvalAdjustT<uint16, int16>(adjust, scope, last_value, value); break; |
a8d6df7f637d
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
frosch <frosch@openttd.org>
parents:
19760
diff
changeset
|
256 case DSG_SIZE_DWORD: value = EvalAdjustT<uint32, int32>(adjust, scope, last_value, value); break; |
12027
54dbb2d04329
(svn r16434) -Cleanup: remove some dead code; primarily stuff that can't be reached like break after returns or break after functions that never return (i.e. NOT_REACHED)
rubidium <rubidium@openttd.org>
parents:
12015
diff
changeset
|
257 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
258 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
259 last_value = value; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
260 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
261 |
5607
f746786ae8b3
(svn r8063) -Codechange: When evaluating newgrf varaction2s the 'last value' should start off at 0, and the result of the operation is remembered.
peter1138 <peter1138@openttd.org>
parents:
5606
diff
changeset
|
262 object->last_value = last_value; |
f746786ae8b3
(svn r8063) -Codechange: When evaluating newgrf varaction2s the 'last value' should start off at 0, and the result of the operation is remembered.
peter1138 <peter1138@openttd.org>
parents:
5606
diff
changeset
|
263 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
264 if (this->num_ranges == 0) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
265 /* nvar == 0 is a special case -- we turn our value into a callback result */ |
9088
5b5958727985
(svn r12947) -Fix: keep only first 15 bits for non failed callback results
glx <glx@openttd.org>
parents:
9020
diff
changeset
|
266 if (value != CALLBACK_FAILED) value = GB(value, 0, 15); |
18300
4161e822c9f8
(svn r23136) -Change: [NewGRF v8] Deprecate old-style callback results 0xFF??.
frosch <frosch@openttd.org>
parents:
18103
diff
changeset
|
267 static CallbackResultSpriteGroup nvarzero(0, true); |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
268 nvarzero.result = value; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
269 return &nvarzero; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
270 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
271 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
272 for (i = 0; i < this->num_ranges; i++) { |
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
273 if (this->ranges[i].low <= value && value <= this->ranges[i].high) { |
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
274 return SpriteGroup::Resolve(this->ranges[i].group, object); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
275 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
276 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
277 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
278 return SpriteGroup::Resolve(this->default_group, object); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
279 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
280 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
281 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
282 const SpriteGroup *RandomizedSpriteGroup::Resolve(ResolverObject *object) const |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
283 { |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
284 ScopeResolver *scope = object->GetScope(this->var_scope, this->count); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
285 if (object->trigger != 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 /* Handle triggers */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
287 /* Magic code that may or may not do the right things... */ |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
288 byte waiting_triggers = scope->GetTriggers(); |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
289 byte match = this->triggers & (waiting_triggers | object->trigger); |
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
290 bool res = (this->cmp_mode == RSG_CMP_ANY) ? (match != 0) : (match == this->triggers); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
291 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
292 if (res) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
293 waiting_triggers &= ~match; |
17844
91d7b400b453
(svn r22635) -Fix: Correctly reseed random bits of industries and industry tiles.
frosch <frosch@openttd.org>
parents:
17779
diff
changeset
|
294 object->reseed[this->var_scope] |= (this->num_groups - 1) << this->lowest_randbit; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
295 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
296 waiting_triggers |= object->trigger; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
297 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
298 |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
299 scope->SetTriggers(waiting_triggers); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
300 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
301 |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
302 uint32 mask = (this->num_groups - 1) << this->lowest_randbit; |
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
303 byte index = (scope->GetRandomBits() & mask) >> this->lowest_randbit; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
304 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
305 return SpriteGroup::Resolve(this->groups[index], object); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
306 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
307 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
308 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
309 const SpriteGroup *RealSpriteGroup::Resolve(ResolverObject *object) const |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
310 { |
19745
3a40c69fc098
(svn r24678) -Codechange: Introduce scope resolver base class and prepare for adding derived classes.
alberth <alberth@openttd.org>
parents:
18891
diff
changeset
|
311 return object->ResolveReal(this); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
312 } |
17738
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
313 |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
314 /** |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
315 * Process registers and the construction stage into the sprite layout. |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
316 * The passed construction stage might get reset to zero, if it gets incorporated into the layout |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
317 * during the preprocessing. |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
318 * @param [in, out] stage Construction stage (0-3), or NULL if not applicable. |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
319 * @return sprite layout to draw. |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
320 */ |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
321 const DrawTileSprites *TileLayoutSpriteGroup::ProcessRegisters(uint8 *stage) const |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
322 { |
18103
8adf9c55b5e5
(svn r22924) -Codechange: Enhance NewGRFSpriteLayout for drawing construction stages in spritelayouts with inconsistent number of sprites per spriteset.
frosch <frosch@openttd.org>
parents:
18102
diff
changeset
|
323 if (!this->dts.NeedsPreprocessing()) { |
8adf9c55b5e5
(svn r22924) -Codechange: Enhance NewGRFSpriteLayout for drawing construction stages in spritelayouts with inconsistent number of sprites per spriteset.
frosch <frosch@openttd.org>
parents:
18102
diff
changeset
|
324 if (stage != NULL && this->dts.consistent_max_offset > 0) *stage = GetConstructionStageOffset(*stage, this->dts.consistent_max_offset); |
8adf9c55b5e5
(svn r22924) -Codechange: Enhance NewGRFSpriteLayout for drawing construction stages in spritelayouts with inconsistent number of sprites per spriteset.
frosch <frosch@openttd.org>
parents:
18102
diff
changeset
|
325 return &this->dts; |
8adf9c55b5e5
(svn r22924) -Codechange: Enhance NewGRFSpriteLayout for drawing construction stages in spritelayouts with inconsistent number of sprites per spriteset.
frosch <frosch@openttd.org>
parents:
18102
diff
changeset
|
326 } |
17738
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
327 |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
328 static DrawTileSprites result; |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
329 uint8 actual_stage = stage != NULL ? *stage : 0; |
18103
8adf9c55b5e5
(svn r22924) -Codechange: Enhance NewGRFSpriteLayout for drawing construction stages in spritelayouts with inconsistent number of sprites per spriteset.
frosch <frosch@openttd.org>
parents:
18102
diff
changeset
|
330 this->dts.PrepareLayout(0, 0, 0, actual_stage, false); |
17738
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
331 this->dts.ProcessRegisters(0, 0, false); |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
332 result.seq = this->dts.GetLayout(&result.ground); |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
333 |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
334 /* Stage has been processed by PrepareLayout(), set it to zero. */ |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
335 if (stage != NULL) *stage = 0; |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
336 |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
337 return &result; |
fe79e4216f58
(svn r22518) -Feature: [NewGRF] Advanced sprite layouts with register modifiers.
frosch <frosch@openttd.org>
parents:
17682
diff
changeset
|
338 } |