summaryrefslogtreecommitdiff
path: root/src/object_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-10-12 19:48:42 +0000
committerrubidium <rubidium@openttd.org>2010-10-12 19:48:42 +0000
commitfeece0b42c559f50893873bf4179646d9e4195cf (patch)
tree8a7f70ad04f52211de1bf0176f150f6d4bcbddf4 /src/object_cmd.cpp
parent3866ecad3863a3d3ad64e4c489c5ceea6d5a2667 (diff)
downloadopenttd-feece0b42c559f50893873bf4179646d9e4195cf.tar.xz
(svn r20919) -Fix [FS#4140]: objects didn't change colour when the company changed colour. Now they do, except when the "decide colour" callback is (defined to be) used
Diffstat (limited to 'src/object_cmd.cpp')
-rw-r--r--src/object_cmd.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 0ddcf3664..4ad51d58f 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -128,6 +128,27 @@ void UpdateCompanyHQ(TileIndex tile, uint score)
}
}
+/**
+ * Updates the colour of the object whenever a company changes.
+ * @param c The company the company colour changed of.
+ */
+void UpdateObjectColours(const Company *c)
+{
+ Object *obj;
+ FOR_ALL_OBJECTS(obj) {
+ Owner owner = GetTileOwner(obj->location.tile);
+ /* Not the current owner, so colour doesn't change. */
+ if (owner != c->index) continue;
+
+ const ObjectSpec *spec = ObjectSpec::GetByTile(obj->location.tile);
+ /* Using the object colour callback, so not using company colour. */
+ if (HasBit(spec->callback_mask, CBM_OBJ_COLOUR)) continue;
+
+ const Livery *l = c->livery;
+ obj->colour = ((spec->flags & OBJECT_FLAG_2CC_COLOUR) ? (l->colour2 * 16) : 0) + l->colour1;
+ }
+}
+
extern CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z, bool check_bridge);
static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags);