MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateObjectColours

Function UpdateObjectColours

src/object_cmd.cpp:184–197  ·  view source on GitHub ↗

* Updates the colour of the object whenever a company changes. * @param c The company the company colour changed of. */

Source from the content-addressed store, hash-verified

182 * @param c The company the company colour changed of.
183 */
184void UpdateObjectColours(const Company *c)
185{
186 for (Object *obj : Object::Iterate()) {
187 Owner owner = GetTileOwner(obj->location.tile);
188 /* Not the current owner, so colour doesn't change. */
189 if (owner != c->index) continue;
190
191 const ObjectSpec *spec = ObjectSpec::GetByTile(obj->location.tile);
192 /* Using the object colour callback, so not using company colour. */
193 if (spec->callback_mask.Test(ObjectCallbackMask::Colour)) continue;
194
195 obj->colour = c->GetCompanyRecolourOffset(LS_DEFAULT, spec->flags.Test(ObjectFlag::Uses2CC));
196 }
197}
198
199extern CommandCost CheckBuildableTile(TileIndex tile, DiagDirections invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge);
200static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlags flags);

Callers 1

CmdSetCompanyColourFunction · 0.85

Calls 3

GetTileOwnerFunction · 0.85
TestMethod · 0.80

Tested by

no test coverage detected