|
@@ -11,21 +11,22 @@
|
|
|
|
|
|
#include "../../stdafx.h"
|
|
|
#include "script_news.hpp"
|
|
|
#include "script_error.hpp"
|
|
|
#include "../../command_type.h"
|
|
|
#include "../../string_func.h"
|
|
|
|
|
|
/* static */ bool ScriptNews::Create(NewsType type, Text *text, ScriptCompany::CompanyID company)
|
|
|
{
|
|
|
CCountedPtr<Text> counter(text);
|
|
|
|
|
|
EnforcePrecondition(false, text != NULL);
|
|
|
EnforcePrecondition(false, !StrEmpty(text->GetEncodedText()));
|
|
|
const char *encoded = text->GetEncodedText();
|
|
|
EnforcePreconditionEncodedText(false, encoded);
|
|
|
EnforcePrecondition(false, type == NT_ECONOMY || type == NT_SUBSIDIES || type == NT_GENERAL);
|
|
|
EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
|
|
|
|
|
|
uint8 c = company;
|
|
|
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
|
|
|
|
|
|
return ScriptObject::DoCommand(0, type | (NR_NONE << 8) | (c << 16), 0, CMD_CUSTOM_NEWS_ITEM, text->GetEncodedText());
|
|
|
return ScriptObject::DoCommand(0, type | (NR_NONE << 8) | (c << 16), 0, CMD_CUSTOM_NEWS_ITEM, encoded);
|
|
|
}
|