예제 #1
0
/****************************************************************************
  Set the given terrain at the specified tile.
****************************************************************************/
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
{
  /* The terrain change is valid if one of the following is TRUE:
   * - pterrain is NULL (= unknown terrain)
   * - ptile is a virtual tile
   * - pterrain does not has the flag TER_NO_CITIES
   * - there is no city on ptile.
   * This should be read as: The terrain change is INVALID if a terrain with
   * the flag TER_NO_CITIES is given for a real tile with a city (i.e. all
   * check evaluate to TRUE). */
  fc_assert_msg(NULL == pterrain
                || tile_virtual_check(ptile)
                || !terrain_has_flag(pterrain, TER_NO_CITIES)
                || NULL == tile_city(ptile),
                "At (%d, %d), the terrain \"%s\" (nb %d) doesn't "
                "support cities, whereas \"%s\" (nb %d) is built there.",
                TILE_XY(ptile), terrain_rule_name(pterrain),
                terrain_number(pterrain), city_name(tile_city(ptile)),
                tile_city(ptile)->id);

  ptile->terrain = pterrain;
  if (NULL != pterrain
   && NULL != ptile->resource
   && terrain_has_resource(pterrain, ptile->resource)) {
    /* cannot use set_special() for internal values */
    BV_SET(ptile->special, S_RESOURCE_VALID);
  } else {
    BV_CLR(ptile->special, S_RESOURCE_VALID);
  }
}
예제 #2
0
파일: tile.c 프로젝트: 2085020/freeciv-web
/****************************************************************************
  Set the given terrain at the specified tile.
****************************************************************************/
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
{
  ptile->terrain = pterrain;
  if (NULL != pterrain
   && NULL != ptile->resource
   && terrain_has_resource(pterrain, ptile->resource)) {
    /* cannot use set_special() for internal values */
    BV_SET(ptile->special, S_RESOURCE_VALID);
  } else {
    BV_CLR(ptile->special, S_RESOURCE_VALID);
  }
}
예제 #3
0
/**************************************************************************
  Popup a dialog asking the unit which improvement they would like to
  pillage.
**************************************************************************/
void popup_pillage_dialog(struct unit *punit,
			  bv_special spe,
                          bv_bases bases,
                          bv_roads roads)
{
  Widget shell, form, dlabel, button, prev;
  struct act_tgt tgt;

  if (is_showing_pillage_dialog) {
    return;
  }
  is_showing_pillage_dialog = TRUE;
  unit_to_use_to_pillage = punit->id;

  XtSetSensitive (toplevel, FALSE);

  shell = I_T(XtCreatePopupShell("pillagedialog", transientShellWidgetClass,
				 toplevel, NULL, 0));
  form = XtVaCreateManagedWidget ("form", formWidgetClass, shell, NULL);
  dlabel = I_L(XtVaCreateManagedWidget("dlabel", labelWidgetClass, form, NULL));

  prev = dlabel;
  while (get_preferred_pillage(&tgt, spe, bases, roads)) {
    bv_special what_spe;
    bv_bases what_base;
    bv_roads what_road;
    int what = S_LAST;

    BV_CLR_ALL(what_spe);
    BV_CLR_ALL(what_base);
    BV_CLR_ALL(what_road);

    switch (tgt.type) {
      case ATT_SPECIAL:
        BV_SET(what_spe, tgt.obj.spe);
        what = tgt.obj.spe;
        clear_special(&spe, tgt.obj.spe);
        break;
      case ATT_BASE:
        BV_SET(what_base, tgt.obj.base);
        what = tgt.obj.base + S_LAST;
        BV_CLR(bases, tgt.obj.base);
        break;
      case ATT_ROAD:
        BV_SET(what_road, tgt.obj.road);
        what = tgt.obj.road + S_LAST + game.control.num_base_types;
        BV_CLR(roads, tgt.obj.road);
        break;
    }

    button =
      XtVaCreateManagedWidget ("button", commandWidgetClass, form,
                               XtNfromVert, prev,
                               XtNlabel,
                               (XtArgVal)(get_infrastructure_text(what_spe,
                                                                  what_base,
                                                                  what_road)),
                               NULL);
    XtAddCallback(button, XtNcallback, pillage_callback,
                  INT_TO_XTPOINTER(what));

    prev = button;
  }
  button =
    I_L(XtVaCreateManagedWidget("closebutton", commandWidgetClass, form,
				XtNfromVert, prev,
				NULL));
  XtAddCallback (button, XtNcallback, pillage_callback, NULL);

  xaw_set_relative_position (toplevel, shell, 10, 0);
  XtPopup (shell, XtGrabNone);
}
예제 #4
0
/****************************************************************************
  Removes base from tile if such exist
****************************************************************************/
void tile_remove_base(struct tile *ptile, const struct base_type *pbase)
{
  BV_CLR(ptile->bases, base_index(pbase));
}