Ejemplo n.º 1
0
/***************************************************************
  Returns true iff p1 can cancel treaty on p2.

  The senate may not allow you to break the treaty.  In this 
  case you must first dissolve the senate then you can break 
  it.  This is waived if you have statue of liberty since you 
  could easily just dissolve and then recreate it. 
***************************************************************/
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1, 
                                           const struct player *p2)
{
  enum diplstate_type ds = pplayer_get_diplstate(p1, p2)->type;

  if (p1 == p2 || ds == DS_WAR) {
    return DIPL_ERROR;
  }
  if (players_on_same_team(p1, p2)) {
    return DIPL_ERROR;
  }
  if (p1->diplstates[player_index(p2)].has_reason_to_cancel == 0
      && get_player_bonus(p1, EFT_HAS_SENATE) > 0
      && get_player_bonus(p1, EFT_ANY_GOVERNMENT) == 0) {
    return DIPL_SENATE_BLOCKING;
  }
  return DIPL_OK;
}
Ejemplo n.º 2
0
/**************************************************************************
  Updates the player list dialog.

  FIXME: use plrdlg_common.c
**************************************************************************/
void update_players_dialog(void)
{
   if(players_dialog_shell && !is_plrdlg_frozen()) {
    int j = 0;
    Dimension width;
    static char *namelist_ptrs[MAX_NUM_PLAYERS];
    static char namelist_text[MAX_NUM_PLAYERS][256];
    const struct player_diplstate *pds;

    players_iterate(pplayer) {
      char idlebuf[32], statebuf[32], namebuf[32], dsbuf[32];
      
      /* skip barbarians */
      if(is_barbarian(pplayer))
        continue;

      /* text for state */
      sz_strlcpy(statebuf, plrdlg_col_state(pplayer));

      /* text for idleness */
      if(pplayer->nturns_idle>3) {
	my_snprintf(idlebuf, sizeof(idlebuf),
		    PL_("(idle %d turn)",
			"(idle %d turns)",
			pplayer->nturns_idle - 1),
		    pplayer->nturns_idle - 1);
      } else {
	idlebuf[0]='\0';
      }

      /* text for name, plus AI marker */       
      if (pplayer->ai_data.control) {
        my_snprintf(namebuf, sizeof(namebuf), "*%-15s",player_name(pplayer));
      } else {
        my_snprintf(namebuf, sizeof(namebuf), "%-16s",player_name(pplayer));
      }
      namebuf[16] = '\0';

      /* text for diplstate type and turns -- not applicable if this is me */
      if (NULL == client.conn.playing
          || pplayer == client.conn.playing) {
	strcpy(dsbuf, "-");
      } else {
	pds = pplayer_get_diplstate(client.conn.playing, pplayer);
	if (pds->type == DS_CEASEFIRE) {
	  my_snprintf(dsbuf, sizeof(dsbuf), "%s (%d)",
		      diplstate_text(pds->type), pds->turns_left);
	} else {
	  my_snprintf(dsbuf, sizeof(dsbuf), "%s",
		      diplstate_text(pds->type));
	}
      }

      /* assemble the whole lot */
      my_snprintf(namelist_text[j], sizeof(namelist_text[j]),
	      "%-16s %-12s %-8s %-15s %-8s %-6s   %-15s%s", 
	      namebuf,
	      nation_adjective_for_player(pplayer), 
	      get_embassy_status(client.conn.playing, pplayer),
	      dsbuf,
	      get_vision_status(client.conn.playing, pplayer),
	      statebuf,
	      player_addr_hack(pplayer),  /* Fixme for multi-conn */
	      idlebuf);

      namelist_ptrs[j]=namelist_text[j];
      list_index_to_player_index[j] = player_number(pplayer);
      j++;
    } players_iterate_end;
    
    XawListChange(players_list, namelist_ptrs, j, 0, True);

    XtVaGetValues(players_list, XtNwidth, &width, NULL);
    XtVaSetValues(players_label, XtNwidth, width, NULL); 
  }