Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Feature #661437 » UnitStay-S3_0.patch

Marko Lindqvist, 2017-05-17 01:33 AM

View differences:

freeciv/common/movement.c 2017-05-17 03:50:27.029238976 +0300
537 537

  
538 538
  The unit can move if:
539 539
    1) The unit is idle or on server goto.
540
    2) The target location is next to the unit.
541
    3) There are no non-allied units on the target tile.
542
    4) Animals cannot move out from home terrains
543
    5) Unit can move to a tile where it can't survive on its own if there
540
    2) Unit is not prohibited from moving by scenario
541
    3) The target location is next to the unit.
542
    4) There are no non-allied units on the target tile.
543
    5) Animals cannot move out from home terrains
544
    6) Unit can move to a tile where it can't survive on its own if there
544 545
       is free transport capacity.
545
    6) There are no peaceful but non allied units on the target tile.
546
    7) There is not a non allied city on the target tile when
546
    7) There are no peaceful but non allied units on the target tile.
547
    8) There is not a non allied city on the target tile when
547 548
       enter_enemy_city is false. When enter_enemy_city is true a non
548 549
       peaceful city is also accepted.
549
    8) There is no non-allied unit blocking (zoc) [or igzoc is true].
550
    9) Triremes cannot move out of sight from land.
551
   10) It is not the territory of a player we are at peace with.
552
   11) The unit is unable to disembark from current transporter.
553
   12) The unit is making a non-native move (e.g. lack of road)
550
    9) There is no non-allied unit blocking (zoc) [or igzoc is true].
551
   10) Triremes cannot move out of sight from land.
552
   11) It is not the territory of a player we are at peace with.
553
   12) The unit is unable to disembark from current transporter.
554
   13) The unit is making a non-native move (e.g. lack of road)
554 555
**************************************************************************/
555 556
enum unit_move_result
556 557
unit_move_to_tile_test(const struct unit *punit,
......
573 574
  }
574 575

  
575 576
  /* 2) */
577
  if (punit->stay) {
578
    return MR_UNIT_STAY;
579
  }
580

  
581
  /* 3) */
576 582
  if (!is_tiles_adjacent(src_tile, dst_tile)) {
577 583
    /* Of course you can only move to adjacent positions. */
578 584
    return MR_BAD_DESTINATION;
579 585
  }
580 586

  
581
  /* 3) */
587
  /* 4) */
582 588
  if (is_non_allied_unit_tile(dst_tile, puowner)) {
583 589
    /* You can't move onto a tile with non-allied units on it (try
584 590
     * attacking instead). */
585 591
    return MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT;
586 592
  }
587 593

  
588
  /* 4) */
594
  /* 5) */
589 595
  if (puowner->ai_common.barbarian_type == ANIMAL_BARBARIAN
590 596
      && dst_tile->terrain->animal != punittype) {
591 597
    return MR_ANIMAL_DISALLOWED;
592 598
  }
593 599

  
594
  /* 5) */
600
  /* 6) */
595 601
  if (embark_to != NULL) {
596 602
    if (!could_unit_load(punit, embark_to)) {
597 603
      return MR_NO_TRANSPORTER_CAPACITY;
......
601 607
    return MR_NO_TRANSPORTER_CAPACITY;
602 608
  }
603 609

  
604
  /* 6) */
610
  /* 7) */
605 611
  if (is_non_attack_unit_tile(dst_tile, puowner)) {
606 612
    /* You can't move into a non-allied tile.
607 613
     *
......
610 616
    return MR_NO_WAR;
611 617
  }
612 618

  
613
  /* 7) */
619
  /* 8) */
614 620
  if ((pcity = tile_city(dst_tile))) {
615 621
    if (enter_enemy_city) {
616 622
      if (pplayers_non_attack(city_owner(pcity), puowner)) {
......
628 634
    }
629 635
  }
630 636

  
631
  /* 8) */
637
  /* 9) */
632 638
  zoc = igzoc
633 639
    || can_step_taken_wrt_to_zoc(punittype, puowner, src_tile, dst_tile);
634 640
  if (!zoc) {
......
636 642
    return MR_ZOC;
637 643
  }
638 644

  
639
  /* 9) */
645
  /* 10) */
640 646
  if (utype_has_flag(punittype, UTYF_COAST_STRICT) && !is_safe_ocean(dst_tile)) {
641 647
    return MR_TRIREME;
642 648
  }
643 649

  
644
  /* 10) */
650
  /* 11) */
645 651
  if (!utype_has_flag(punittype, UTYF_CIVILIAN)
646 652
      && !player_can_invade_tile(puowner, dst_tile)) {
647 653
    return MR_PEACE;
648 654
  }
649 655

  
650
  /* 11) */
656
  /* 12) */
651 657
  if (unit_transported(punit)
652 658
     && !can_unit_unload(punit, unit_transport_get(punit))) {
653 659
    return MR_CANNOT_DISEMBARK;
654 660
  }
655 661

  
656
  /* 12) */
662
  /* 13) */
657 663
  if (!(is_native_move(utype_class(punittype), src_tile, dst_tile)
658 664
        /* Allow non-native moves into cities or boarding transport. */
659 665
        || pcity
freeciv/common/movement.h 2017-05-17 03:51:13.932866769 +0300
43 43
  MR_CANNOT_DISEMBARK,
44 44
  MR_NON_NATIVE_MOVE,  /* Usually RMM_RELAXED road diagonally without link */
45 45
  MR_ANIMAL_DISALLOWED,
46
  MR_UNIT_STAY,
46 47
  MR_NOT_ALLOWED
47 48
};
48 49

  
freeciv/common/unit.c 2017-05-17 03:45:48.719454289 +0300
1616 1616
  punit->action_decision_want = ACT_DEC_NOTHING;
1617 1617
  punit->action_decision_tile = NULL;
1618 1618

  
1619
  punit->stay = FALSE;
1620

  
1619 1621
  if (is_server()) {
1620 1622
    punit->server.debug = FALSE;
1621 1623
    punit->server.birth_turn = game.info.turn;
freeciv/common/unit.h 2017-05-17 03:45:28.515615672 +0300
173 173
  enum action_decision action_decision_want;
174 174
  struct tile *action_decision_tile;
175 175

  
176
  bool stay; /* Unit is prohibited from moving */
177

  
176 178
  union {
177 179
    struct {
178 180
      /* Only used at the client (the server is omniscient; ./client/). */
freeciv/server/savegame3.c 2017-05-17 03:47:24.150693160 +0300
5423 5423
    punit->action_decision_tile = NULL;
5424 5424
  }
5425 5425

  
5426
  punit->stay = secfile_lookup_bool_default(loading->file, FALSE, "%s.stay", unitstr);
5427

  
5426 5428
  /* load the unit orders */
5427 5429
  {
5428 5430
    int len = secfile_lookup_int_default(loading->file, 0,
......
5819 5821
                         "%s.action_decision_tile_y", buf);
5820 5822
    }
5821 5823

  
5824
    secfile_insert_bool(saving->file, punit->stay,
5825
                        "%s.stay", buf);
5826

  
5822 5827
    if (punit->has_orders) {
5823 5828
      int len = punit->orders.length;
5824 5829
      char orders_buf[len + 1], dir_buf[len + 1];
(2-2/2)