summaryrefslogtreecommitdiff
path: root/sprite.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-11-17 08:52:47 +0000
committertron <tron@openttd.org>2004-11-17 08:52:47 +0000
commit13f0b6c0cf754184cfef8645e709f10240da5f98 (patch)
tree71bd164389e546b1a8a5c1c879b57c1574cb95d2 /sprite.h
parent0086bb9d0678876e2e3e9b4002a0f44af2c45ee4 (diff)
downloadopenttd-13f0b6c0cf754184cfef8645e709f10240da5f98.tar.xz
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
Diffstat (limited to 'sprite.h')
-rw-r--r--sprite.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/sprite.h b/sprite.h
index b75b30dd4..8b17fa943 100644
--- a/sprite.h
+++ b/sprite.h
@@ -82,16 +82,36 @@ struct DeterministicSpriteGroup {
struct SpriteGroup *default_group;
};
+struct RandomizedSpriteGroup {
+ // Take this object:
+ enum VarSpriteGroupScope var_scope;
+
+ // Check for these triggers:
+ enum RandomizedSpriteGroupCompareMode {
+ RSG_CMP_ANY,
+ RSG_CMP_ALL,
+ } cmp_mode;
+ byte triggers;
+
+ // Look for this in the per-object randomized bitmask:
+ byte lowest_randbit;
+ byte num_groups; // must be power of 2
+
+ // Take the group with appropriate index:
+ struct SpriteGroup *groups;
+};
+
struct SpriteGroup {
enum SpriteGroupType {
SGT_REAL,
SGT_DETERMINISTIC,
- SGT_RANDOM, /* TODO */
+ SGT_RANDOMIZED,
} type;
union {
struct RealSpriteGroup real;
struct DeterministicSpriteGroup determ;
+ struct RandomizedSpriteGroup random;
} g;
};
@@ -108,4 +128,13 @@ struct SpriteGroup *EvalDeterministicSpriteGroup(struct DeterministicSpriteGroup
/* Get value of a common deterministic SpriteGroup variable. */
int GetDeterministicSpriteValue(byte var);
+/* This takes randomized bitmask (probably associated with
+ * vehicle/station/whatever) and chooses corresponding SpriteGroup
+ * accordingly to the given RandomizedSpriteGroup. */
+struct SpriteGroup *EvalRandomizedSpriteGroup(struct RandomizedSpriteGroup *rsg, byte random_bits);
+/* Triggers given RandomizedSpriteGroup with given bitmask and returns and-mask
+ * of random bits to be reseeded, or zero if there were no triggers matched
+ * (then they are |ed to @waiting_triggers instead). */
+byte RandomizedSpriteGroupTriggeredBits(struct RandomizedSpriteGroup *rsg, byte triggers, byte *waiting_triggers);
+
#endif