当前位置: 首页>>代码示例>>C++>>正文


C++ CommandCost::MultiplyCost方法代码示例

本文整理汇总了C++中CommandCost::MultiplyCost方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandCost::MultiplyCost方法的具体用法?C++ CommandCost::MultiplyCost怎么用?C++ CommandCost::MultiplyCost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandCost的用法示例。


在下文中一共展示了CommandCost::MultiplyCost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SubtractMoneyFromAnyCompany

/**
 * Deduct costs of a command from the money of a company.
 * @param c Company to pay the bill.
 * @param cost Money to pay.
 */
static void SubtractMoneyFromAnyCompany(Company *c, CommandCost cost)
{
	if (cost.GetCost() == 0) return;
	assert(cost.GetExpensesType() != INVALID_EXPENSES);

	if (HasBit(1 << EXPENSES_TRAIN_INC    |
	           1 << EXPENSES_ROADVEH_INC  |
	           1 << EXPENSES_AIRCRAFT_INC |
	           1 << EXPENSES_SHIP_INC     |
			   1 << EXPENSES_SHARING_INC, cost.GetExpensesType())) {
		c->cur_economy.income -= cost.GetCost();
	} else if (HasBit(1 << EXPENSES_TRAIN_RUN    |
	                  1 << EXPENSES_ROADVEH_RUN  |
	                  1 << EXPENSES_AIRCRAFT_RUN |
//	                  1 << EXPENSES_SHIP_RUN     |
//	                  1 << EXPENSES_LOST_RUN     |
//	                  1 << EXPENSES_PROPERTY     |
//	                  1 << EXPENSES_LOAN_INT     |
                          1 << EXPENSES_SHIP_RUN , cost.GetExpensesType())) {
               if ((_settings_game.economy.day_length_balance_type == DBT_ALL_COSTS ||
                         _settings_game.economy.day_length_balance_type == DBT_RUN_COST)) {
                       cost.MultiplyCost(_settings_game.economy.day_length_balance_factor);
               }
                c->cur_economy.expenses -= cost.GetCost();
       } else if (HasBit(1 << EXPENSES_LOST_RUN, cost.GetExpensesType())) {
               if (_settings_game.economy.day_length_balance_type == DBT_ALL_COSTS) {
                       cost.AffectCost(_settings_game.economy.day_length_balance_factor);
               }
                c->cur_economy.expenses -= cost.GetCost();
       } else if (HasBit(1 << EXPENSES_SHARING_COST, cost.GetExpensesType())) {
               if (_settings_game.economy.day_length_balance_type == DBT_ALL_COSTS) {
                       cost.AffectCost(_settings_game.economy.day_length_balance_factor);
               }
                c->cur_economy.expenses -= cost.GetCost();
       } else if (HasBit(1 << EXPENSES_LOAN_INT, cost.GetExpensesType())) {
               if (_settings_game.economy.day_length_balance_type == DBT_ALL_COSTS ||
                  (_settings_game.economy.day_length_balance_type == DBT_RUN_COST &&
                       _settings_game.economy.include_loan_int_to_run)) {
                       cost.AffectCost(_settings_game.economy.day_length_balance_factor);
               }
                c->cur_economy.expenses -= cost.GetCost();
       } else if (HasBit(1 << EXPENSES_PROPERTY, cost.GetExpensesType())) {
               if (_settings_game.economy.day_length_balance_type == DBT_ALL_COSTS ||
                  (_settings_game.economy.day_length_balance_type == DBT_RUN_COST &&
                       _settings_game.economy.include_prop_main_to_run)) {
                       cost.AffectCost(_settings_game.economy.day_length_balance_factor);
               }
               c->cur_economy.expenses -= cost.GetCost();
       } else if (HasBit(1 << EXPENSES_CONSTRUCTION, cost.GetExpensesType())) {
               /* Multiply construction costs according to day length balance type. */
               if (_settings_game.economy.day_length_balance_type == DBT_ALL_COSTS) {
                       cost.AffectCost(_settings_game.economy.day_length_balance_factor);
               }
        }

       /* Subtract money. */
       c->money -= cost.GetCost();
       c->yearly_expenses[0][cost.GetExpensesType()] += cost.GetCost();

	InvalidateCompanyWindows(c);
}
开发者ID:koreapyj,项目名称:openttd-yapp,代码行数:66,代码来源:company_cmd.cpp


注:本文中的CommandCost::MultiplyCost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。