diff options
author | Alberth <alberth@openttd.org> | 2018-12-29 13:31:31 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2018-12-29 16:15:44 +0100 |
commit | 4a255e879aa60ac21a12097f1896f0a6dd110770 (patch) | |
tree | 38b30626dbe591458937721dc3344cd6bf96ca22 /src/script/api | |
parent | d8f6c80696f354c257614450f66de813044fb854 (diff) | |
download | openttd-4a255e879aa60ac21a12097f1896f0a6dd110770.tar.xz |
Fix #6966: Only allow switching to a valid company.
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/script_companymode.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/script/api/script_companymode.cpp b/src/script/api/script_companymode.cpp index 1931a5db7..a5d3963a2 100644 --- a/src/script/api/script_companymode.cpp +++ b/src/script/api/script_companymode.cpp @@ -10,6 +10,7 @@ /** @file script_companymode.cpp Implementation of ScriptCompanyMode. */ #include "../../stdafx.h" +#include "../../company_base.h" #include "script_companymode.hpp" #include "../../safeguards.h" @@ -17,6 +18,7 @@ ScriptCompanyMode::ScriptCompanyMode(int company) { if (company < OWNER_BEGIN || company >= MAX_COMPANIES) company = INVALID_COMPANY; + if (!::Company::IsValidID(company)) company = INVALID_COMPANY; this->last_company = ScriptObject::GetCompany(); ScriptObject::SetCompany((CompanyID)company); |