src/misc_cmd.cpp
changeset 9354 845e07db4549
parent 9346 bfd803297888
child 9358 2e1e4d2f71dd
equal deleted inserted replaced
9353:9d76aef9fe2b 9354:845e07db4549
   144 
   144 
   145 	Money loan;
   145 	Money loan;
   146 	switch (p2) {
   146 	switch (p2) {
   147 		default: return CMD_ERROR; // Invalid method
   147 		default: return CMD_ERROR; // Invalid method
   148 		case 0: // Take some extra loan
   148 		case 0: // Take some extra loan
   149 			loan = (IsHumanPlayer(_current_player) || _patches.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI;
   149 			loan = (IsHumanPlayer(_current_player) || _settings.ai.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI;
   150 			break;
   150 			break;
   151 		case 1: // Take a loan as big as possible
   151 		case 1: // Take a loan as big as possible
   152 			loan = _economy.max_loan - p->current_loan;
   152 			loan = _economy.max_loan - p->current_loan;
   153 			break;
   153 			break;
   154 	}
   154 	}
   180 
   180 
   181 	Money loan;
   181 	Money loan;
   182 	switch (p2) {
   182 	switch (p2) {
   183 		default: return CMD_ERROR; // Invalid method
   183 		default: return CMD_ERROR; // Invalid method
   184 		case 0: // Pay back one step
   184 		case 0: // Pay back one step
   185 			loan = min(p->current_loan, (Money)(IsHumanPlayer(_current_player) || _patches.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI);
   185 			loan = min(p->current_loan, (Money)(IsHumanPlayer(_current_player) || _settings.ai.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI);
   186 			break;
   186 			break;
   187 		case 1: // Pay back as much as possible
   187 		case 1: // Pay back as much as possible
   188 			loan = max(min(p->current_loan, p->player_money), (Money)LOAN_INTERVAL);
   188 			loan = max(min(p->current_loan, p->player_money), (Money)LOAN_INTERVAL);
   189 			loan -= loan % LOAN_INTERVAL;
   189 			loan -= loan % LOAN_INTERVAL;
   190 			break;
   190 			break;
   358  * @param p1 the amount of money to transfer; max 20.000.000
   358  * @param p1 the amount of money to transfer; max 20.000.000
   359  * @param p2 the player to transfer the money to
   359  * @param p2 the player to transfer the money to
   360  */
   360  */
   361 CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   361 CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   362 {
   362 {
   363 	if (!_patches.give_money) return CMD_ERROR;
   363 	if (!_settings.economy.give_money) return CMD_ERROR;
   364 
   364 
   365 	const Player *p = GetPlayer(_current_player);
   365 	const Player *p = GetPlayer(_current_player);
   366 	CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
   366 	CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
   367 
   367 
   368 	/* You can only transfer funds that is in excess of your loan */
   368 	/* You can only transfer funds that is in excess of your loan */
   407 
   407 
   408 		/* Since the tolerance of the town council has a direct impact on the noise generation/tolerance,
   408 		/* Since the tolerance of the town council has a direct impact on the noise generation/tolerance,
   409 		 * launch a re-evaluation of the actual values only when setting has changed */
   409 		 * launch a re-evaluation of the actual values only when setting has changed */
   410 		if (p2 == GAME_DIFFICULTY_TOWNCOUNCIL_TOLERANCE && _game_mode == GM_NORMAL) {
   410 		if (p2 == GAME_DIFFICULTY_TOWNCOUNCIL_TOLERANCE && _game_mode == GM_NORMAL) {
   411 			UpdateAirportsNoise();
   411 			UpdateAirportsNoise();
   412 			if (_patches.station_noise_level) {
   412 			if (_settings.economy.station_noise_level) {
   413 				InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
   413 				InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
   414 			}
   414 			}
   415 		}
   415 		}
   416 
   416 
   417 		/* If we are a network-client, update the difficult setting (if it is open).
   417 		/* If we are a network-client, update the difficult setting (if it is open).