mirror of https://github.com/OpenTTD/OpenTTD.git
Cleanup: Replace single-use Pair struct with std::pair.
This struct is defined in geometry_type but not used by any geometry-related code, only for subsidy code where both parameters are cast from int to NewsReferenceType.
This commit is contained in:
parent
bf4fe19a66
commit
5ff15443e9
|
@ -62,10 +62,4 @@ struct PointDimension {
|
||||||
int height;
|
int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A pair of two integers */
|
|
||||||
struct Pair {
|
|
||||||
int a;
|
|
||||||
int b;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* GEOMETRY_TYPE_HPP */
|
#endif /* GEOMETRY_TYPE_HPP */
|
||||||
|
|
|
@ -50,14 +50,14 @@ void Subsidy::AwardTo(CompanyID company)
|
||||||
char *cn = stredup(company_name);
|
char *cn = stredup(company_name);
|
||||||
|
|
||||||
/* Add a news item */
|
/* Add a news item */
|
||||||
Pair reftype = SetupSubsidyDecodeParam(this, false);
|
std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(this, false);
|
||||||
InjectDParam(1);
|
InjectDParam(1);
|
||||||
|
|
||||||
SetDParamStr(0, cn);
|
SetDParamStr(0, cn);
|
||||||
AddNewsItem(
|
AddNewsItem(
|
||||||
STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier,
|
STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier,
|
||||||
NT_SUBSIDIES, NF_NORMAL,
|
NT_SUBSIDIES, NF_NORMAL,
|
||||||
(NewsReferenceType)reftype.a, this->src, (NewsReferenceType)reftype.b, this->dst,
|
reftype.first, this->src, reftype.second, this->dst,
|
||||||
cn
|
cn
|
||||||
);
|
);
|
||||||
AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index));
|
AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index));
|
||||||
|
@ -72,7 +72,7 @@ void Subsidy::AwardTo(CompanyID company)
|
||||||
* @param mode Unit of cargo used, \c true means general name, \c false means singular form.
|
* @param mode Unit of cargo used, \c true means general name, \c false means singular form.
|
||||||
* @return Reference of the subsidy in the news system.
|
* @return Reference of the subsidy in the news system.
|
||||||
*/
|
*/
|
||||||
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode)
|
std::pair<NewsReferenceType, NewsReferenceType> SetupSubsidyDecodeParam(const Subsidy *s, bool mode)
|
||||||
{
|
{
|
||||||
NewsReferenceType reftype1 = NR_NONE;
|
NewsReferenceType reftype1 = NR_NONE;
|
||||||
NewsReferenceType reftype2 = NR_NONE;
|
NewsReferenceType reftype2 = NR_NONE;
|
||||||
|
@ -107,10 +107,7 @@ Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode)
|
||||||
}
|
}
|
||||||
SetDParam(5, s->dst);
|
SetDParam(5, s->dst);
|
||||||
|
|
||||||
Pair p;
|
return std::pair<NewsReferenceType, NewsReferenceType>(reftype1, reftype2);
|
||||||
p.a = reftype1;
|
|
||||||
p.b = reftype2;
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,8 +216,8 @@ void CreateSubsidy(CargoID cid, SourceType src_type, SourceID src, SourceType ds
|
||||||
s->remaining = SUBSIDY_OFFER_MONTHS;
|
s->remaining = SUBSIDY_OFFER_MONTHS;
|
||||||
s->awarded = INVALID_COMPANY;
|
s->awarded = INVALID_COMPANY;
|
||||||
|
|
||||||
Pair reftype = SetupSubsidyDecodeParam(s, false);
|
std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, false);
|
||||||
AddNewsItem(STR_NEWS_SERVICE_SUBSIDY_OFFERED, NT_SUBSIDIES, NF_NORMAL, (NewsReferenceType)reftype.a, s->src, (NewsReferenceType)reftype.b, s->dst);
|
AddNewsItem(STR_NEWS_SERVICE_SUBSIDY_OFFERED, NT_SUBSIDIES, NF_NORMAL, reftype.first, s->src, reftype.second, s->dst);
|
||||||
SetPartOfSubsidyFlag(s->src_type, s->src, POS_SRC);
|
SetPartOfSubsidyFlag(s->src_type, s->src, POS_SRC);
|
||||||
SetPartOfSubsidyFlag(s->dst_type, s->dst, POS_DST);
|
SetPartOfSubsidyFlag(s->dst_type, s->dst, POS_DST);
|
||||||
AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index));
|
AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index));
|
||||||
|
@ -494,14 +491,14 @@ void SubsidyMonthlyLoop()
|
||||||
for (Subsidy *s : Subsidy::Iterate()) {
|
for (Subsidy *s : Subsidy::Iterate()) {
|
||||||
if (--s->remaining == 0) {
|
if (--s->remaining == 0) {
|
||||||
if (!s->IsAwarded()) {
|
if (!s->IsAwarded()) {
|
||||||
Pair reftype = SetupSubsidyDecodeParam(s, true);
|
std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, true);
|
||||||
AddNewsItem(STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED, NT_SUBSIDIES, NF_NORMAL, (NewsReferenceType)reftype.a, s->src, (NewsReferenceType)reftype.b, s->dst);
|
AddNewsItem(STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED, NT_SUBSIDIES, NF_NORMAL, reftype.first, s->src, reftype.second, s->dst);
|
||||||
AI::BroadcastNewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
AI::BroadcastNewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
||||||
Game::NewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
Game::NewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
||||||
} else {
|
} else {
|
||||||
if (s->awarded == _local_company) {
|
if (s->awarded == _local_company) {
|
||||||
Pair reftype = SetupSubsidyDecodeParam(s, true);
|
std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, true);
|
||||||
AddNewsItem(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, NT_SUBSIDIES, NF_NORMAL, (NewsReferenceType)reftype.a, s->src, (NewsReferenceType)reftype.b, s->dst);
|
AddNewsItem(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, NT_SUBSIDIES, NF_NORMAL, reftype.first, s->src, reftype.second, s->dst);
|
||||||
}
|
}
|
||||||
AI::BroadcastNewEvent(new ScriptEventSubsidyExpired(s->index));
|
AI::BroadcastNewEvent(new ScriptEventSubsidyExpired(s->index));
|
||||||
Game::NewEvent(new ScriptEventSubsidyExpired(s->index));
|
Game::NewEvent(new ScriptEventSubsidyExpired(s->index));
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
#include "station_type.h"
|
#include "station_type.h"
|
||||||
#include "company_type.h"
|
#include "company_type.h"
|
||||||
#include "cargo_type.h"
|
#include "cargo_type.h"
|
||||||
|
#include "news_type.h"
|
||||||
|
|
||||||
Pair SetupSubsidyDecodeParam(const struct Subsidy *s, bool mode);
|
std::pair<NewsReferenceType, NewsReferenceType> SetupSubsidyDecodeParam(const struct Subsidy *s, bool mode);
|
||||||
void DeleteSubsidyWith(SourceType type, SourceID index);
|
void DeleteSubsidyWith(SourceType type, SourceID index);
|
||||||
bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type, SourceID src, const Station *st);
|
bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type, SourceID src, const Station *st);
|
||||||
void RebuildSubsidisedSourceAndDestinationCache();
|
void RebuildSubsidisedSourceAndDestinationCache();
|
||||||
|
|
Loading…
Reference in New Issue