summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-23 22:28:35 +0000
committerrubidium <rubidium@openttd.org>2010-08-23 22:28:35 +0000
commit9d1145e50cead52c479900e8a05e1b154860cec2 (patch)
tree76af47fbff3dc468881923817b3b9276ffbd10f3 /src
parentf6f218cf6b360fa8524f851d2e33aad275f1fe39 (diff)
downloadopenttd-9d1145e50cead52c479900e8a05e1b154860cec2.tar.xz
(svn r20605) -Fix [FS#4063]: let NewGRFs var43 var (information about liveries) for vehicles not be influenced by the local setting determining whether to show liveries or not.
Diffstat (limited to 'src')
-rw-r--r--src/livery.h4
-rw-r--r--src/newgrf_engine.cpp8
-rw-r--r--src/vehicle.cpp7
-rw-r--r--src/vehicle_func.h2
4 files changed, 13 insertions, 8 deletions
diff --git a/src/livery.h b/src/livery.h
index aa7af96f5..8806aff58 100644
--- a/src/livery.h
+++ b/src/livery.h
@@ -14,6 +14,10 @@
#include "company_type.h"
+static const byte LIT_NONE = 0; ///< Don't show the liveries at all
+static const byte LIT_COMPANY = 1; ///< Show the liveries of your own company
+static const byte LIT_ALL = 2; ///< Show the liveries of all companies
+
/** List of different livery schemes. */
enum LiveryScheme {
LS_BEGIN = 0,
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 097a27f74..16aa5dce0 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -441,13 +441,13 @@ static uint8 LiveryHelper(EngineID engine, const Vehicle *v)
if (v == NULL) {
if (!Company::IsValidID(_current_company)) return 0;
- l = GetEngineLivery(engine, _current_company, INVALID_ENGINE, NULL);
+ l = GetEngineLivery(engine, _current_company, INVALID_ENGINE, NULL, LIT_ALL);
} else if (v->type == VEH_TRAIN) {
- l = GetEngineLivery(v->engine_type, v->owner, Train::From(v)->tcache.first_engine, v);
+ l = GetEngineLivery(v->engine_type, v->owner, Train::From(v)->tcache.first_engine, v, LIT_ALL);
} else if (v->type == VEH_ROAD) {
- l = GetEngineLivery(v->engine_type, v->owner, RoadVehicle::From(v)->rcache.first_engine, v);
+ l = GetEngineLivery(v->engine_type, v->owner, RoadVehicle::From(v)->rcache.first_engine, v, LIT_ALL);
} else {
- l = GetEngineLivery(v->engine_type, v->owner, INVALID_ENGINE, v);
+ l = GetEngineLivery(v->engine_type, v->owner, INVALID_ENGINE, v, LIT_ALL);
}
return l->colour1 + l->colour2 * 16;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 5384f2954..db4eea58c 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1403,9 +1403,10 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
* @param company Owner of the vehicle
* @param parent_engine_type EngineID of the front vehicle. INVALID_VEHICLE if vehicle is at front itself.
* @param v the vehicle. NULL if in purchase list etc.
+ * @param livery_setting The livery settings to use for acquiring the livery information.
* @return livery to use
*/
-const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v)
+const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, byte livery_setting)
{
const Company *c = Company::Get(company);
LiveryScheme scheme = LS_DEFAULT;
@@ -1413,7 +1414,7 @@ const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID
/* The default livery is always available for use, but its in_use flag determines
* whether any _other_ liveries are in use. */
- if (c->livery[LS_DEFAULT].in_use && (_settings_client.gui.liveries == 2 || (_settings_client.gui.liveries == 1 && company == _local_company))) {
+ if (c->livery[LS_DEFAULT].in_use && (livery_setting == LIT_ALL || (livery_setting == LIT_COMPANY && company == _local_company))) {
/* Determine the livery scheme to use */
const Engine *e = Engine::Get(engine_type);
switch (e->type) {
@@ -1540,7 +1541,7 @@ static PaletteID GetEngineColourMap(EngineID engine_type, CompanyID company, Eng
/* Spectator has news shown too, but has invalid company ID - as well as dedicated server */
if (!Company::IsValidID(company)) return map;
- const Livery *livery = GetEngineLivery(engine_type, company, parent_engine_type, v);
+ const Livery *livery = GetEngineLivery(engine_type, company, parent_engine_type, v, _settings_client.gui.liveries);
map += livery->colour1;
if (twocc) map += livery->colour2 * 16;
diff --git a/src/vehicle_func.h b/src/vehicle_func.h
index bbeeeac83..63aaaf0e2 100644
--- a/src/vehicle_func.h
+++ b/src/vehicle_func.h
@@ -92,7 +92,7 @@ static inline bool IsCompanyBuildableVehicleType(const BaseVehicle *v)
return IsCompanyBuildableVehicleType(v->type);
}
-const struct Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v);
+const struct Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v, byte livery_setting);
/**
* Get the colour map for an engine. This used for unbuilt engines in the user interface.