src/economy.cpp
changeset 9234 bfc9d27d3d0d
parent 9199 ce9fbdff6581
child 9236 0c4f622cbcec
equal deleted inserted replaced
9233:b29c7a028999 9234:bfc9d27d3d0d
   529 		case 2:
   529 		case 2:
   530 			SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE);
   530 			SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE);
   531 			SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED);
   531 			SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED);
   532 			SetDParam(2, owner);
   532 			SetDParam(2, owner);
   533 			AddNewsItem(STR_02B6,
   533 			AddNewsItem(STR_02B6,
   534 				NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, owner | NB_BTROUBLE);
   534 				NS_COMPANY_TROUBLE, 0, owner | NB_BTROUBLE);
   535 			break;
   535 			break;
   536 		case 3: {
   536 		case 3: {
   537 			/* XXX - In multiplayer, should we ask other players if it wants to take
   537 			/* XXX - In multiplayer, should we ask other players if it wants to take
   538 		          over when it is a human company? -- TrueLight */
   538 		          over when it is a human company? -- TrueLight */
   539 			if (IsHumanPlayer(owner)) {
   539 			if (IsHumanPlayer(owner)) {
   540 				SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE);
   540 				SetDParam(0, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE);
   541 				SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED);
   541 				SetDParam(1, STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED);
   542 				SetDParam(2, owner);
   542 				SetDParam(2, owner);
   543 				AddNewsItem(STR_02B6,
   543 				AddNewsItem(STR_02B6,
   544 					NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, owner | NB_BTROUBLE);
   544 					NS_COMPANY_TROUBLE, 0, owner | NB_BTROUBLE);
   545 				break;
   545 				break;
   546 			}
   546 			}
   547 
   547 
   548 			/* Check if the company has any value.. if not, declare it bankrupt
   548 			/* Check if the company has any value.. if not, declare it bankrupt
   549 			 *  right now */
   549 			 *  right now */
   562 
   562 
   563 			/* Show bankrupt news */
   563 			/* Show bankrupt news */
   564 			SetDParam(0, STR_705C_BANKRUPT);
   564 			SetDParam(0, STR_705C_BANKRUPT);
   565 			SetDParam(1, STR_705D_HAS_BEEN_CLOSED_DOWN_BY);
   565 			SetDParam(1, STR_705D_HAS_BEEN_CLOSED_DOWN_BY);
   566 			SetDParam(2, p->index);
   566 			SetDParam(2, p->index);
   567 			AddNewsItem(STR_02B6, NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, owner | NB_BBANKRUPT);
   567 			AddNewsItem(STR_02B6, NS_COMPANY_BANKRUPT, 0, owner | NB_BBANKRUPT);
   568 
   568 
   569 			if (IsHumanPlayer(owner)) {
   569 			if (IsHumanPlayer(owner)) {
   570 				/* XXX - If we are in offline mode, leave the player playing. Eg. there
   570 				/* XXX - If we are in offline mode, leave the player playing. Eg. there
   571 				 * is no THE-END, otherwise mark the player as spectator to make sure
   571 				 * is no THE-END, otherwise mark the player as spectator to make sure
   572 				 * he/she is no long in control of this company */
   572 				 * he/she is no long in control of this company */
   772 {
   772 {
   773 	if (_opt.diff.economy == 0) return;
   773 	if (_opt.diff.economy == 0) return;
   774 
   774 
   775 	if (--_economy.fluct == 0) {
   775 	if (--_economy.fluct == 0) {
   776 		_economy.fluct = -(int)GB(Random(), 0, 2);
   776 		_economy.fluct = -(int)GB(Random(), 0, 2);
   777 		AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NM_NORMAL, NF_NONE, NT_ECONOMY, DNC_NONE, 0, 0);
   777 		AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NS_ECONOMY, 0, 0);
   778 	} else if (_economy.fluct == -12) {
   778 	} else if (_economy.fluct == -12) {
   779 		_economy.fluct = GB(Random(), 0, 8) + 312;
   779 		_economy.fluct = GB(Random(), 0, 8) + 312;
   780 		AddNewsItem(STR_7074_RECESSION_OVER_UPTURN_IN, NM_NORMAL, NF_NONE, NT_ECONOMY, DNC_NONE, 0, 0);
   780 		AddNewsItem(STR_7074_RECESSION_OVER_UPTURN_IN, NS_ECONOMY, 0, 0);
   781 	}
   781 	}
   782 }
   782 }
   783 
   783 
   784 static byte _price_category[NUM_PRICES] = {
   784 static byte _price_category[NUM_PRICES] = {
   785 	0, 2, 2, 2, 2, 2, 2, 2,
   785 	0, 2, 2, 2, 2, 2, 2, 2,
  1115 	for (s = _subsidies; s != endof(_subsidies); s++) {
  1115 	for (s = _subsidies; s != endof(_subsidies); s++) {
  1116 		if (s->cargo_type == CT_INVALID) continue;
  1116 		if (s->cargo_type == CT_INVALID) continue;
  1117 
  1117 
  1118 		if (s->age == 12-1) {
  1118 		if (s->age == 12-1) {
  1119 			pair = SetupSubsidyDecodeParam(s, 1);
  1119 			pair = SetupSubsidyDecodeParam(s, 1);
  1120 			AddNewsItem(STR_202E_OFFER_OF_SUBSIDY_EXPIRED, NM_NORMAL, NF_TILE | NF_TILE2, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
  1120 			AddNewsItem(STR_202E_OFFER_OF_SUBSIDY_EXPIRED, NS_SUBSIDIES, pair.a, pair.b);
  1121 			s->cargo_type = CT_INVALID;
  1121 			s->cargo_type = CT_INVALID;
  1122 			modified = true;
  1122 			modified = true;
  1123 		} else if (s->age == 2*12-1) {
  1123 		} else if (s->age == 2*12-1) {
  1124 			st = GetStation(s->to);
  1124 			st = GetStation(s->to);
  1125 			if (st->owner == _local_player) {
  1125 			if (st->owner == _local_player) {
  1126 				pair = SetupSubsidyDecodeParam(s, 1);
  1126 				pair = SetupSubsidyDecodeParam(s, 1);
  1127 				AddNewsItem(STR_202F_SUBSIDY_WITHDRAWN_SERVICE, NM_NORMAL, NF_TILE | NF_TILE2, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
  1127 				AddNewsItem(STR_202F_SUBSIDY_WITHDRAWN_SERVICE, NS_SUBSIDIES, pair.a, pair.b);
  1128 			}
  1128 			}
  1129 			s->cargo_type = CT_INVALID;
  1129 			s->cargo_type = CT_INVALID;
  1130 			modified = true;
  1130 			modified = true;
  1131 		} else {
  1131 		} else {
  1132 			s->age++;
  1132 			s->age++;
  1161 				}
  1161 				}
  1162 	add_subsidy:
  1162 	add_subsidy:
  1163 				if (!CheckSubsidyDuplicate(s)) {
  1163 				if (!CheckSubsidyDuplicate(s)) {
  1164 					s->age = 0;
  1164 					s->age = 0;
  1165 					pair = SetupSubsidyDecodeParam(s, 0);
  1165 					pair = SetupSubsidyDecodeParam(s, 0);
  1166 					AddNewsItem(STR_2030_SERVICE_SUBSIDY_OFFERED, NM_NORMAL, NF_TILE | NF_TILE2, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
  1166 					AddNewsItem(STR_2030_SERVICE_SUBSIDY_OFFERED, NS_SUBSIDIES, pair.a, pair.b);
  1167 					modified = true;
  1167 					modified = true;
  1168 					break;
  1168 					break;
  1169 				}
  1169 				}
  1170 			}
  1170 			}
  1171 		} while (n--);
  1171 		} while (n--);
  1378 			InjectDParam(1);
  1378 			InjectDParam(1);
  1379 
  1379 
  1380 			SetDParam(0, _current_player);
  1380 			SetDParam(0, _current_player);
  1381 			AddNewsItem(
  1381 			AddNewsItem(
  1382 				STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
  1382 				STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
  1383 				NM_NORMAL, NF_TILE | NF_TILE2, NT_SUBSIDIES, DNC_NONE,
  1383 				NS_SUBSIDIES,
  1384 				pair.a, pair.b
  1384 				pair.a, pair.b
  1385 			);
  1385 			);
  1386 
  1386 
  1387 			InvalidateWindow(WC_SUBSIDIES_LIST, 0);
  1387 			InvalidateWindow(WC_SUBSIDIES_LIST, 0);
  1388 			return true;
  1388 			return true;
  1820 	SetDParam(0, STR_7059_TRANSPORT_COMPANY_MERGER);
  1820 	SetDParam(0, STR_7059_TRANSPORT_COMPANY_MERGER);
  1821 	SetDParam(1, p->bankrupt_value == 0 ? STR_707F_HAS_BEEN_TAKEN_OVER_BY : STR_705A_HAS_BEEN_SOLD_TO_FOR);
  1821 	SetDParam(1, p->bankrupt_value == 0 ? STR_707F_HAS_BEEN_TAKEN_OVER_BY : STR_705A_HAS_BEEN_SOLD_TO_FOR);
  1822 	SetDParam(2, p->index);
  1822 	SetDParam(2, p->index);
  1823 	SetDParam(3, _current_player);
  1823 	SetDParam(3, _current_player);
  1824 	SetDParam(4, p->bankrupt_value);
  1824 	SetDParam(4, p->bankrupt_value);
  1825 	AddNewsItem(STR_02B6, NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, _current_player | NB_BMERGER);
  1825 	AddNewsItem(STR_02B6, NS_COMPANY_MERGER, 0, _current_player | NB_BMERGER);
  1826 
  1826 
  1827 	/* original code does this a little bit differently */
  1827 	/* original code does this a little bit differently */
  1828 	PlayerID pi = p->index;
  1828 	PlayerID pi = p->index;
  1829 	ChangeNetworkOwner(pi, _current_player);
  1829 	ChangeNetworkOwner(pi, _current_player);
  1830 	ChangeOwnershipOfPlayerItems(pi, _current_player);
  1830 	ChangeOwnershipOfPlayerItems(pi, _current_player);