summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/script_companymode.cpp2
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);