(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from

invalid players (eg spectators) which could lead to crashes.
This commit is contained in:
Darkvater
2006-10-31 21:15:56 +00:00
parent 993cb13c8d
commit eadf788cc5
11 changed files with 35 additions and 28 deletions

View File

@@ -219,24 +219,24 @@ static const WindowDesc _other_player_finances_small_desc = {
PlayerFinancesWndProc
};
static const WindowDesc * const desc_table[2*2] = {
&_player_finances_desc,&_player_finances_small_desc,
&_other_player_finances_desc,&_other_player_finances_small_desc,
};
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied)
{
Window *w;
int mode;
static const WindowDesc * const desc_table[2 * 2] = {
&_player_finances_desc, &_player_finances_small_desc,
&_other_player_finances_desc, &_other_player_finances_small_desc,
};
if (!IsValidPlayer(player)) return;
mode = (player != _local_player) * 2 + show_small;
w = AllocateWindowDescFront(desc_table[mode], player);
if (w != NULL) {
w->caption_color = w->window_number;
WP(w,def_d).data_1 = mode;
if (show_stickied) {
w->flags4 |= WF_STICKY;
}
if (show_stickied) w->flags4 |= WF_STICKY;
}
}
@@ -878,6 +878,8 @@ void ShowPlayerCompany(PlayerID player)
{
Window *w;
if (!IsValidPlayer(player)) return;
w = AllocateWindowDescFront(&_player_company_desc, player);
if (w != NULL) w->caption_color = w->window_number;
}