File diff r1961:7949b074d614 → r1962:cc4c06e3f6b5
players.c
Show inline comments
 
@@ -191,13 +191,13 @@ void InvalidatePlayerWindows(Player *p)
 
}
 

	
 
bool CheckPlayerHasMoney(int32 cost)
 
{
 
	if (cost > 0) {
 
		uint pid = _current_player;
 
		if (pid < MAX_PLAYERS && cost > DEREF_PLAYER(pid)->player_money) {
 
		if (pid < MAX_PLAYERS && cost > GetPlayer(pid)->player_money) {
 
			SetDParam(0, cost);
 
			_error_message = STR_0003_NOT_ENOUGH_CASH_REQUIRES;
 
			return false;
 
		}
 
	}
 
	return true;
 
@@ -219,18 +219,18 @@ static void SubtractMoneyFromAnyPlayer(P
 
}
 

	
 
void SubtractMoneyFromPlayer(int32 cost)
 
{
 
	PlayerID pid = _current_player;
 
	if (pid < MAX_PLAYERS)
 
		SubtractMoneyFromAnyPlayer(DEREF_PLAYER(pid), cost);
 
		SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
 
}
 

	
 
void SubtractMoneyFromPlayerFract(byte player, int32 cost)
 
{
 
	Player *p = DEREF_PLAYER(player);
 
	Player *p = GetPlayer(player);
 
	byte m = p->player_money_fraction;
 
	p->player_money_fraction = m - (byte)cost;
 
	cost >>= 8;
 
	if (p->player_money_fraction > m)
 
		cost++;
 
	if (cost != 0)
 
@@ -253,13 +253,13 @@ void GetNameOfOwner(byte owner, uint til
 
	SetDParam(2, owner);
 

	
 
	if (owner != OWNER_TOWN) {
 
		if (owner >= 8)
 
			SetDParam(0, STR_0150_SOMEONE);
 
		else {
 
			Player *p = DEREF_PLAYER(owner);
 
			Player *p = GetPlayer(owner);
 
			SetDParam(0, p->name_1);
 
			SetDParam(1, p->name_2);
 
		}
 
	} else {
 
		Town *t = ClosestTownFromTile(tile, (uint)-1);
 
		SetDParam(0, t->townnametype);
 
@@ -541,13 +541,13 @@ void OnTick_Players(void)
 
{
 
	Player *p;
 

	
 
	if (_game_mode == GM_EDITOR)
 
		return;
 

	
 
	p = DEREF_PLAYER(_cur_player_tick_index);
 
	p = GetPlayer(_cur_player_tick_index);
 
	_cur_player_tick_index = (_cur_player_tick_index + 1) % MAX_PLAYERS;
 
	if (p->name_1 != 0) GenerateCompanyName(p);
 

	
 
	if (!_networking && _game_mode != GM_MENU && !--_next_competitor_start) {
 
		MaybeStartNewPlayer();
 
	}
 
@@ -597,13 +597,13 @@ void PlayersYearlyLoop(void)
 
			InvalidateWindow(WC_FINANCES, p->index);
 
		}
 
	}
 

	
 
	if (_patches.show_finances && _local_player != OWNER_SPECTATOR) {
 
		ShowPlayerFinances(_local_player);
 
		p = DEREF_PLAYER(_local_player);
 
		p = GetPlayer(_local_player);
 
		if (p->num_valid_stat_ent > 5 && p->old_economy[0].performance_history < p->old_economy[4].performance_history) {
 
			SndPlayFx(SND_01_BAD_YEAR);
 
		} else {
 
			SndPlayFx(SND_00_GOOD_YEAR);
 
		}
 
	}
 
@@ -625,13 +625,13 @@ void DeletePlayerWindows(int pi)
 

	
 
static void DeletePlayerStuff(int pi)
 
{
 
	Player *p;
 

	
 
	DeletePlayerWindows(pi);
 
	p = DEREF_PLAYER(pi);
 
	p = GetPlayer(pi);
 
	DeleteName(p->name_1);
 
	DeleteName(p->president_name_1);
 
	p->name_1 = 0;
 
	p->president_name_1 = 0;
 
}
 

	
 
@@ -732,13 +732,13 @@ int32 CmdPlayerCtrl(int x, int y, uint32
 
		Player *p;
 

	
 
		if (p2 >= MAX_PLAYERS) return CMD_ERROR;
 

	
 
		if (!(flags & DC_EXEC)) return 0;
 

	
 
		p = DEREF_PLAYER(p2);
 
		p = GetPlayer(p2);
 

	
 
		/* Only allow removal of HUMAN companies */
 
		if (IS_HUMAN_PLAYER(p->index)) {
 
			/* Delete any open window of the company */
 
			DeletePlayerWindows(p->index);
 

	
 
@@ -1112,13 +1112,13 @@ static void Save_PLYR(void)
 
}
 

	
 
static void Load_PLYR(void)
 
{
 
	int index;
 
	while ((index = SlIterateArray()) != -1) {
 
		Player *p = DEREF_PLAYER(index);
 
		Player *p = GetPlayer(index);
 
		p->is_ai = (index != 0);
 
		SaveLoad_PLYR(p);
 
		_player_colors[index] = p->player_color;
 
		UpdatePlayerMoney32(p);
 
	}
 
}