Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "../../stdafx.h"
00013 #include "script_news.hpp"
00014 #include "script_error.hpp"
00015 #include "../../news_func.h"
00016 #include "../../strings_func.h"
00017 #include "../../command_type.h"
00018 #include "../../string_func.h"
00019 #include "table/strings.h"
00020
00021 bool ScriptNews::Create(NewsType type, Text *text, ScriptCompany::CompanyID company)
00022 {
00023 CCountedPtr<Text> counter(text);
00024
00025 EnforcePrecondition(false, text != NULL);
00026 EnforcePrecondition(false, !StrEmpty(text->GetEncodedText()));
00027 EnforcePrecondition(false, type >= NT_ARRIVAL_COMPANY && type <= NT_GENERAL);
00028 EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
00029
00030 uint8 c = company;
00031 if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
00032
00033 return ScriptObject::DoCommand(0, type | (NR_NONE << 8) | (c << 16), 0, CMD_CUSTOM_NEWS_ITEM, text->GetEncodedText());
00034 }