Codechange: Un-bitstuff all remaining commands.

This commit is contained in:
Michael Lutz
2021-11-23 01:05:58 +01:00
parent 58cff7b081
commit 13528bfcd0
40 changed files with 192 additions and 260 deletions

View File

@@ -837,23 +837,17 @@ void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceTy
/**
* Create a new custom news item.
* @param flags type of operation
* @param tile unused
* @param p1 various bitstuffed elements
* - p1 = (bit 0 - 7) - NewsType of the message.
* - 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.
* @aram type NewsType of the message.
* @param reftype1 NewsReferenceType of first reference.
* @param company Company this news message is for.
* @param reference 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(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32 reference, 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 (text.empty()) return CMD_ERROR;
@@ -861,27 +855,27 @@ CommandCost CmdCustomNewsItem(DoCommandFlag flags, TileIndex tile, uint32 p1, ui
switch (reftype1) {
case NR_NONE: break;
case NR_TILE:
if (!IsValidTile(p2)) return CMD_ERROR;
if (!IsValidTile(reference)) return CMD_ERROR;
break;
case NR_VEHICLE:
if (!Vehicle::IsValidID(p2)) return CMD_ERROR;
if (!Vehicle::IsValidID(reference)) return CMD_ERROR;
break;
case NR_STATION:
if (!Station::IsValidID(p2)) return CMD_ERROR;
if (!Station::IsValidID(reference)) return CMD_ERROR;
break;
case NR_INDUSTRY:
if (!Industry::IsValidID(p2)) return CMD_ERROR;
if (!Industry::IsValidID(reference)) return CMD_ERROR;
break;
case NR_TOWN:
if (!Town::IsValidID(p2)) return CMD_ERROR;
if (!Town::IsValidID(reference)) return CMD_ERROR;
break;
case NR_ENGINE:
if (!Engine::IsValidID(p2)) return CMD_ERROR;
if (!Engine::IsValidID(reference)) return CMD_ERROR;
break;
default: return CMD_ERROR;
@@ -892,7 +886,7 @@ CommandCost CmdCustomNewsItem(DoCommandFlag flags, TileIndex tile, uint32 p1, ui
if (flags & DC_EXEC) {
NewsStringData *news = new NewsStringData(text);
SetDParamStr(0, news->string);
AddNewsItem(STR_NEWS_CUSTOM_ITEM, type, NF_NORMAL, reftype1, p2, NR_NONE, UINT32_MAX, news);
AddNewsItem(STR_NEWS_CUSTOM_ITEM, type, NF_NORMAL, reftype1, reference, NR_NONE, UINT32_MAX, news);
}
return CommandCost();