File diff r2951:a52cbb930051 → r2952:e97f823d2dbe
economy.c
Show inline comments
 
@@ -496,25 +496,25 @@ void DrawNewsBankrupcy(Window *w)
 

	
 
	DrawNewsBorder(w);
 

	
 
	p = GetPlayer(WP(w,news_d).ni->string_id & 15);
 
	DrawPlayerFace(p->face, p->player_color, 2, 23);
 
	GfxFillRect(3, 23, 3+91, 23+118, 0x323 | USE_COLORTABLE);
 

	
 
	SetDParam(0, p->president_name_1);
 
	SetDParam(1, p->president_name_2);
 

	
 
	DrawStringMultiCenter(49, 148, STR_7058_PRESIDENT, 94);
 

	
 
	switch(WP(w,news_d).ni->string_id >> 4) {
 
	switch (WP(w,news_d).ni->string_id >> 4) {
 
	case 1:
 
		DrawStringCentered(w->width>>1, 1, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE, 0);
 

	
 
		SetDParam(0, p->name_1);
 
		SetDParam(1, p->name_2);
 

	
 
		DrawStringMultiCenter(
 
			((w->width - 101) >> 1) + 98,
 
			90,
 
			STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED,
 
			w->width - 101);
 
		break;
 
@@ -797,25 +797,25 @@ void ResetPriceBaseMultipliers(void)
 
void SetPriceBaseMultiplier(uint price, byte factor)
 
{
 
	assert(price < NUM_PRICES);
 
	price_base_multiplier[price] = factor;
 
}
 

	
 
void StartupEconomy(void)
 
{
 
	int i;
 

	
 
	assert(sizeof(_price) == NUM_PRICES * sizeof(int32));
 

	
 
	for(i=0; i!=NUM_PRICES; i++) {
 
	for (i = 0; i != NUM_PRICES; i++) {
 
		int32 price = _price_base[i];
 
		if (_price_category[i] != 0) {
 
			uint mod = _price_category[i] == 1 ? _opt.diff.vehicle_costs : _opt.diff.construction_cost;
 
			if (mod < 1) {
 
				price = price * 3 >> 2;
 
			} else if (mod > 1) {
 
				price = price * 9 >> 3;
 
			}
 
		}
 
		if (price_base_multiplier[i] > 8) {
 
			price <<= price_base_multiplier[i] - 8;
 
		} else {
 
@@ -874,39 +874,39 @@ Pair SetupSubsidyDecodeParam(const Subsi
 
	}
 

	
 
	tp.a = tile;
 
	tp.b = tile2;
 

	
 
	return tp;
 
}
 

	
 
void DeleteSubsidyWithIndustry(uint16 index)
 
{
 
	Subsidy *s;
 

	
 
	for(s=_subsidies; s != endof(_subsidies); s++) {
 
	for (s = _subsidies; s != endof(_subsidies); s++) {
 
		if (s->cargo_type != CT_INVALID && s->age < 12 &&
 
				s->cargo_type != CT_PASSENGERS && s->cargo_type != CT_MAIL &&
 
				(index == s->from || (s->cargo_type!=CT_GOODS && s->cargo_type!=CT_FOOD && index==s->to))) {
 
			s->cargo_type = CT_INVALID;
 
		}
 
	}
 
}
 

	
 
void DeleteSubsidyWithStation(uint16 index)
 
{
 
	Subsidy *s;
 
	bool dirty = false;
 

	
 
	for(s=_subsidies; s != endof(_subsidies); s++) {
 
	for (s = _subsidies; s != endof(_subsidies); s++) {
 
		if (s->cargo_type != CT_INVALID && s->age >= 12 &&
 
				(s->from == index || s->to == index)) {
 
			s->cargo_type = CT_INVALID;
 
			dirty = true;
 
		}
 
	}
 

	
 
	if (dirty)
 
		InvalidateWindow(WC_SUBSIDIES_LIST, 0);
 
}
 

	
 
typedef struct FoundRoute {
 
@@ -1005,27 +1005,26 @@ static bool CheckSubsidyDuplicate(Subsid
 
}
 

	
 

	
 
static void SubsidyMonthlyHandler(void)
 
{
 
	Subsidy *s;
 
	Pair pair;
 
	Station *st;
 
	uint n;
 
	FoundRoute fr;
 
	bool modified = false;
 

	
 
	for(s=_subsidies; s != endof(_subsidies); s++) {
 
		if (s->cargo_type == CT_INVALID)
 
			continue;
 
	for (s = _subsidies; s != endof(_subsidies); s++) {
 
		if (s->cargo_type == CT_INVALID) continue;
 

	
 
		if (s->age == 12-1) {
 
			pair = SetupSubsidyDecodeParam(s, 1);
 
			AddNewsItem(STR_202E_OFFER_OF_SUBSIDY_EXPIRED, NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), pair.a, pair.b);
 
			s->cargo_type = CT_INVALID;
 
			modified = true;
 
		} else if (s->age == 2*12-1) {
 
			st = GetStation(s->to);
 
			if (st->owner == _local_player) {
 
				pair = SetupSubsidyDecodeParam(s, 1);
 
				AddNewsItem(STR_202F_SUBSIDY_WITHDRAWN_SERVICE, NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), pair.a, pair.b);
 
			}
 
@@ -1081,25 +1080,25 @@ static const SaveLoad _subsidies_desc[] 
 
	SLE_CONDVAR(Subsidy,from,			SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVAR(Subsidy,from,			SLE_UINT16, 5, 255),
 
	SLE_CONDVAR(Subsidy,to,				SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVAR(Subsidy,to,				SLE_UINT16, 5, 255),
 
	SLE_END()
 
};
 

	
 
static void Save_SUBS(void)
 
{
 
	int i;
 
	Subsidy *s;
 

	
 
	for(i=0; i!=lengthof(_subsidies); i++) {
 
	for (i = 0; i != lengthof(_subsidies); i++) {
 
		s = &_subsidies[i];
 
		if (s->cargo_type != CT_INVALID) {
 
			SlSetArrayIndex(i);
 
			SlObject(s, _subsidies_desc);
 
		}
 
	}
 
}
 

	
 
static void Load_SUBS(void)
 
{
 
	int index;
 
	while ((index = SlIterateArray()) != -1)
 
@@ -1528,25 +1527,25 @@ static void DoAcquireCompany(Player *p)
 
	AddNewsItem( (StringID)(_current_player + 16*2), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
 

	
 
	// original code does this a little bit differently
 
	pi = p->index;
 
	ChangeOwnershipOfPlayerItems(pi, _current_player);
 

	
 
	if (p->bankrupt_value == 0) {
 
		owner = GetPlayer(_current_player);
 
		owner->current_loan += p->current_loan;
 
	}
 

	
 
	value = CalculateCompanyValue(p) >> 2;
 
	for(i=0; i!=4; i++) {
 
	for (i = 0; i != 4; i++) {
 
		if (p->share_owners[i] != OWNER_SPECTATOR) {
 
			owner = GetPlayer(p->share_owners[i]);
 
			owner->money64 += value;
 
			owner->yearly_expenses[0][EXPENSES_OTHER] += value;
 
			UpdatePlayerMoney32(owner);
 
		}
 
	}
 

	
 
	p->is_active = false;
 

	
 
	DeletePlayerWindows(pi);
 
	RebuildVehicleLists();	//Updates the open windows to add the newly acquired vehicles to the lists