Bug #2238 ยป 0078-Fix-client-crash-on-government_name_for_player.patch
| client/plrdlg_common.c | ||
|---|---|---|
|
static const char *col_government(const struct player *them)
|
||
|
{
|
||
|
static char buf[100];
|
||
|
const struct player *me = client_player();
|
||
|
/* 'contact' gives the knowledge of other's government */
|
||
|
if (me == them
|
||
|
|| client_is_global_observer()
|
||
|
|| team_has_embassy(me->team, them)
|
||
|
|| player_diplstate_get(me, them)->contact_turns_left > 0 ) {
|
||
|
fc_snprintf(buf, sizeof(buf),"%s", government_name_for_player(them));
|
||
|
} else {
|
||
|
fc_snprintf(buf, sizeof(buf),"?");
|
||
|
}
|
||
|
/* This gives sensible result even when the government is not known */
|
||
|
fc_snprintf(buf, sizeof(buf), "%s", government_name_for_player(them));
|
||
|
return buf;
|
||
|
}
|
||
| common/government.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
const char *government_name_for_player(const struct player *pplayer)
|
||
|
{
|
||
|
const struct government *pgov;
|
||
|
if (!pplayer->is_alive) {
|
||
|
return "-";
|
||
|
}
|
||
|
return government_name_translation(government_of_player(pplayer));
|
||
|
pgov = government_of_player(pplayer);
|
||
|
if (!pgov) {
|
||
|
/* Can happen on client side when we have
|
||
|
* no contact to the player. */
|
||
|
return "?";
|
||
|
}
|
||
|
return government_name_translation(pgov);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||