File diff r25561:3defb050f30b → r25562:30716ba6a396
src/news_gui.cpp
Show inline comments
 
@@ -837,23 +837,23 @@ void AddNewsItem(StringID string, NewsTy
 
 * - p1 = (bit  8 - 15) - NewsReferenceType of first reference.
 
 * - p1 = (bit 16 - 23) - Company this news message is for.
 
 * @param p2 First reference of the news message.
 
 * @param text The text of the news message.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCustomNewsItem(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCustomNewsItem(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 

	
 
	NewsType type = (NewsType)GB(p1, 0, 8);
 
	NewsReferenceType reftype1 = (NewsReferenceType)GB(p1, 8, 8);
 
	CompanyID company = (CompanyID)GB(p1, 16, 8);
 

	
 
	if (company != INVALID_OWNER && !Company::IsValidID(company)) return CMD_ERROR;
 
	if (type >= NT_END) return CMD_ERROR;
 
	if (StrEmpty(text)) return CMD_ERROR;
 
	if (text.empty()) return CMD_ERROR;
 

	
 
	switch (reftype1) {
 
		case NR_NONE: break;
 
		case NR_TILE:
 
			if (!IsValidTile(p2)) return CMD_ERROR;
 
			break;
 
@@ -881,13 +881,13 @@ CommandCost CmdCustomNewsItem(TileIndex 
 
		default: return CMD_ERROR;
 
	}
 

	
 
	if (company != INVALID_OWNER && company != _local_company) return CommandCost();
 

	
 
	if (flags & DC_EXEC) {
 
		char *news = stredup(text);
 
		char *news = stredup(text.c_str());
 
		SetDParamStr(0, news);
 
		AddNewsItem(STR_NEWS_CUSTOM_ITEM, type, NF_NORMAL, reftype1, p2, NR_NONE, UINT32_MAX, news);
 
	}
 

	
 
	return CommandCost();
 
}