Skip to content

Commit

Permalink
Fix OpenTTD#6966: Only allow switching to a valid company.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberth289346 authored and nielsmh committed Dec 29, 2018
1 parent d8f6c80 commit 4a255e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/script/api/script_companymode.cpp
Expand Up @@ -10,13 +10,15 @@
/** @file script_companymode.cpp Implementation of ScriptCompanyMode. */

#include "../../stdafx.h"
#include "../../company_base.h"
#include "script_companymode.hpp"

#include "../../safeguards.h"

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);
Expand Down

0 comments on commit 4a255e8

Please sign in to comment.