summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-01-27 01:15:29 +0000
committersmatz <smatz@openttd.org>2009-01-27 01:15:29 +0000
commit9cf1a1976282a307af04959d93e5234166cf38b4 (patch)
treeb3526b0aaedb2b466514f885642e6f84cd4313af
parent43121fc2cb468c15ae5f7cadf7cce8943616a711 (diff)
downloadopenttd-9cf1a1976282a307af04959d93e5234166cf38b4.tar.xz
(svn r15281) -Fix: company could never have auto-assigned colour 0 (dark blue)
-rw-r--r--src/company_cmd.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 6cc2fe0d4..2c9bd26ab 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -330,7 +330,7 @@ static const Colours _similar_colour[COLOUR_END][2] = {
{ COLOUR_GREY, INVALID_COLOUR }, // COLOUR_WHITE
};
-static byte GenerateCompanyColour()
+static Colours GenerateCompanyColour()
{
Colours colours[COLOUR_END];
@@ -426,10 +426,13 @@ Company *DoStartupNewCompany(bool is_ai)
{
if (!Company::CanAllocateItem()) return NULL;
+ /* we have to generate colour before this company is valid */
+ Colours colour = GenerateCompanyColour();
+
Company *c = new Company(STR_SV_UNNAMED, is_ai);
- /* Make a color */
- c->colour = GenerateCompanyColour();
+ c->colour = colour;
+
ResetCompanyLivery(c);
_company_colours[c->index] = c->colour;