Review: Needs Fixing

I found a couple more nits. Otherwise LGTM, please merge after fixing them.

Diff comments:

> === modified file 'src/ai/ai_help_structs.h'
> --- src/ai/ai_help_structs.h  2015-03-26 06:59:37 +0000
> +++ src/ai/ai_help_structs.h  2015-04-07 13:33:49 +0000
> @@ -438,7 +438,7 @@
>  
>       // a ship circumvents all islands in the same direction, the value
>       // is assigned only once
> -     Widelands::ScoutingDirection island_circ_direction = 
> Widelands::ScoutingDirection::kClockwise;
> +     Widelands::IslandExploreDirection island_circ_direction = 
> Widelands::IslandExploreDirection::kClockwise;
>       bool waiting_for_command_ = false;
>       int32_t last_command_time = 0;
>  };
> 
> === modified file 'src/ai/defaultai.cc'
> --- src/ai/defaultai.cc       2015-03-26 20:35:19 +0000
> +++ src/ai/defaultai.cc       2015-04-07 13:33:49 +0000
> @@ -3795,9 +3795,9 @@
>       allships.push_back(ShipObserver());
>       allships.back().ship = &ship;
>       if (game().get_gametime() % 2 == 0) {
> -             allships.back().island_circ_direction = 
> ScoutingDirection::kClockwise;
> +             allships.back().island_circ_direction = 
> IslandExploreDirection::kClockwise;
>       } else {
> -             allships.back().island_circ_direction = 
> ScoutingDirection::kCounterClockwise;
> +             allships.back().island_circ_direction = 
> IslandExploreDirection::kCounterClockwise;
>       }
>  }
>  
> @@ -4058,10 +4058,10 @@
>                       so.waiting_for_command_ = false;
>                       ;
>               } else {
> -                     // 2.B Yes, pick one of avaiable directions
> +                     // 2.B Yes, pick one of avaliable directions
>                       const Direction final_direction =
>                          possible_directions.at(gametime % 
> possible_directions.size());
> -                     game().send_player_ship_scout_direction(*so.ship, 
> final_direction);
> +                     game().send_player_ship_scouting_direction(*so.ship, 
> static_cast<WalkingDir>(final_direction));
>                       so.last_command_time = gametime;
>                       so.waiting_for_command_ = false;
>               }
> 
> === modified file 'src/economy/portdock.cc'
> --- src/economy/portdock.cc   2015-02-16 20:23:15 +0000
> +++ src/economy/portdock.cc   2015-04-07 13:33:49 +0000
> @@ -213,12 +213,11 @@
>  
>       PlayerImmovable::cleanup(egbase);
>  
> -     //now let attempt to recreate the portdock
> +     // Now let's attempt to recreate the portdock.
>       if (wh) {
>               if (!wh->m_cleanup_in_progress){
>                       if (upcast(Game, game, &egbase)) {
>                               if (game->is_loaded()) { //do not attempt when 
> shutting down
> -                                     Player& player = owner();
>                                       wh->restore_portdock_or_destroy(egbase);
>                               }
>                       }
> 
> === modified file 'src/logic/game.cc'
> --- src/logic/game.cc 2015-02-08 19:08:36 +0000
> +++ src/logic/game.cc 2015-04-07 13:33:49 +0000
> @@ -874,7 +874,7 @@
>  }
>  
>  
> -void Game::send_player_ship_scout_direction(Ship & ship, uint8_t direction)
> +void Game::send_player_ship_scouting_direction(Ship & ship, WalkingDir 
> direction)
>  {
>       send_player_command
>               (*new CmdShipScoutDirection
> @@ -888,7 +888,7 @@
>                       (get_gametime(), ship.get_owner()->player_number(), 
> ship.serial(), coords));
>  }
>  
> -void Game::send_player_ship_explore_island(Ship & ship, ScoutingDirection 
> direction)
> +void Game::send_player_ship_explore_island(Ship & ship, 
> IslandExploreDirection direction)
>  {
>       send_player_command
>               (*new CmdShipExploreIsland
> 
> === modified file 'src/logic/game.h'
> --- src/logic/game.h  2015-02-08 19:08:36 +0000
> +++ src/logic/game.h  2015-04-07 13:33:49 +0000
> @@ -41,6 +41,7 @@
>  struct Flag;
>  struct Path;
>  struct PlayerImmovable;
> +enum class IslandExploreDirection;
>  enum class ScoutingDirection;
>  struct Ship;
>  struct PlayerEndStatus;
> @@ -181,9 +182,9 @@
>       void send_player_enemyflagaction
>               (const Flag &, PlayerNumber, uint32_t count);
>  
> -     void send_player_ship_scout_direction(Ship &, uint8_t);
> +     void send_player_ship_scouting_direction(Ship &, WalkingDir);
>       void send_player_ship_construct_port(Ship &, Coords);
> -     void send_player_ship_explore_island(Ship &, ScoutingDirection);
> +     void send_player_ship_explore_island(Ship &, IslandExploreDirection);
>       void send_player_sink_ship(Ship &);
>       void send_player_cancel_expedition_ship(Ship &);
>  
> 
> === modified file 'src/logic/playercommand.cc'
> --- src/logic/playercommand.cc        2015-02-19 19:37:09 +0000
> +++ src/logic/playercommand.cc        2015-04-07 13:33:49 +0000
> @@ -777,7 +777,7 @@
>       PlayerCommand (0, des.unsigned_8())
>  {
>       serial = des.unsigned_32();
> -     dir    = des.unsigned_8();
> +     dir    = static_cast<WalkingDir>(des.unsigned_8());
>  }
>  
>  void CmdShipScoutDirection::execute (Game & game)
> @@ -796,7 +796,7 @@
>                               (ship->state_is_expedition())?"Y":"N");
>                       return;
>               }
> -             ship->exp_scout_direction(game, dir);
> +             ship->exp_scouting_direction(game, dir);
>       }
>  }
>  
> @@ -805,7 +805,7 @@
>       ser.unsigned_8 (PLCMD_SHIP_SCOUT);
>       ser.unsigned_8 (sender());
>       ser.unsigned_32(serial);
> -     ser.unsigned_8 (dir);
> +     ser.unsigned_8 (static_cast<uint8_t>(dir));
>  }
>  
>  #define PLAYER_CMD_SHIP_SCOUT_DIRECTION_VERSION 1
> @@ -818,7 +818,7 @@
>                       PlayerCommand::read(fr, egbase, mol);
>                       serial = 
> get_object_serial_or_zero<Ship>(fr.unsigned_32(), mol);
>                       // direction
> -                     dir = fr.unsigned_8();
> +                     dir = static_cast<WalkingDir>(fr.unsigned_8());
>               } else
>                       throw GameDataError("unknown/unhandled version %u", 
> packet_version);
>       } catch (const WException & e) {
> @@ -837,7 +837,7 @@
>       
> fw.unsigned_32(mos.get_object_file_index_or_zero(egbase.objects().get_object(serial)));
>  
>       // direction
> -     fw.unsigned_8(dir);
> +     fw.unsigned_8(static_cast<uint8_t>(dir));
>  }
>  
>  
> @@ -912,7 +912,7 @@
>       PlayerCommand (0, des.unsigned_8())
>  {
>       serial = des.unsigned_32();
> -     scouting_direction = static_cast<ScoutingDirection>(des.unsigned_8());
> +     island_explore_direction = 
> static_cast<IslandExploreDirection>(des.unsigned_8());
>  }
>  
>  void CmdShipExploreIsland::execute (Game & game)
> @@ -931,7 +931,7 @@
>                               (ship->state_is_expedition())?"Y":"N");
>                       return;
>               }
> -             ship->exp_explore_island(game, scouting_direction);
> +             ship->exp_explore_island(game, island_explore_direction);
>       }
>  }
>  
> @@ -940,7 +940,7 @@
>       ser.unsigned_8 (PLCMD_SHIP_EXPLORE);
>       ser.unsigned_8 (sender());
>       ser.unsigned_32(serial);
> -     ser.unsigned_8 (static_cast<uint8_t>(scouting_direction));
> +     ser.unsigned_8 (static_cast<uint8_t>(island_explore_direction));
>  }
>  
>  #define PLAYER_CMD_SHIP_EXPLORE_ISLAND_VERSION 1
> @@ -952,7 +952,7 @@
>               if (packet_version == PLAYER_CMD_SHIP_EXPLORE_ISLAND_VERSION) {
>                       PlayerCommand::read(fr, egbase, mol);
>                       serial = 
> get_object_serial_or_zero<Ship>(fr.unsigned_32(), mol);
> -                     scouting_direction = 
> static_cast<ScoutingDirection>(fr.unsigned_8());
> +                     island_explore_direction = 
> static_cast<IslandExploreDirection>(fr.unsigned_8());
>               } else
>                       throw GameDataError("unknown/unhandled version %u", 
> packet_version);
>       } catch (const WException & e) {
> @@ -971,7 +971,7 @@
>       
> fw.unsigned_32(mos.get_object_file_index_or_zero(egbase.objects().get_object(serial)));
>  
>       // Direction of exploration
> -     fw.unsigned_8(static_cast<uint8_t>(scouting_direction));
> +     fw.unsigned_8(static_cast<uint8_t>(island_explore_direction));
>  }
>  
>  
> 
> === modified file 'src/logic/playercommand.h'
> --- src/logic/playercommand.h 2015-02-05 12:11:20 +0000
> +++ src/logic/playercommand.h 2015-04-07 13:33:49 +0000
> @@ -313,7 +313,7 @@
>  struct CmdShipScoutDirection : public PlayerCommand {
>       CmdShipScoutDirection() : PlayerCommand(), serial(0) {} // For savegame 
> loading
>       CmdShipScoutDirection
> -             (int32_t const t, PlayerNumber const p, Serial s, uint8_t 
> direction)
> +             (int32_t const t, PlayerNumber const p, Serial s, WalkingDir 
> direction)
>               : PlayerCommand(t, p), serial(s), dir(direction)
>       {}
>  
> @@ -329,7 +329,7 @@
>  
>  private:
>       Serial serial;
> -     uint8_t dir;
> +     WalkingDir dir;
>  };
>  
>  struct CmdShipConstructPort : public PlayerCommand {
> @@ -357,8 +357,8 @@
>  struct CmdShipExploreIsland : public PlayerCommand {
>       CmdShipExploreIsland() : PlayerCommand(), serial(0) {} // For savegame 
> loading
>       CmdShipExploreIsland
> -             (int32_t const t, PlayerNumber const p, Serial s, 
> ScoutingDirection direction)
> -             : PlayerCommand(t, p), serial(s), scouting_direction(direction)
> +             (int32_t const t, PlayerNumber const p, Serial s, 
> IslandExploreDirection direction)
> +             : PlayerCommand(t, p), serial(s), 
> island_explore_direction(direction)
>       {}
>  
>       void write(FileWrite &, EditorGameBase &, MapObjectSaver  &) override;
> @@ -373,7 +373,7 @@
>  
>  private:
>       Serial serial;
> -     ScoutingDirection scouting_direction;
> +     IslandExploreDirection island_explore_direction;
>  };
>  
>  struct CmdShipSink : public PlayerCommand {
> 
> === modified file 'src/logic/ship.cc'
> --- src/logic/ship.cc 2015-02-05 12:11:20 +0000
> +++ src/logic/ship.cc 2015-04-07 13:33:49 +0000
> @@ -550,15 +550,15 @@
>       case EXP_SCOUTING: {
>               if (m_expedition->island_exploration) {  // Exploration of the 
> island
>                       if (exp_close_to_coast()) {
> -                             if (m_expedition->direction == 0) {
> +                             if (m_expedition->scouting_direction == 
> WalkingDir::IDLE) {
>                                       // Make sure we know the location of 
> the coast and use it as initial direction we
>                                       // come from
> -                                     m_expedition->direction = WALK_SE;
> -                                     for (uint8_t secure = 0; 
> exp_dir_swimable(m_expedition->direction); ++secure) {
> +                                     m_expedition->scouting_direction = 
> WALK_SE;
> +                                     for (uint8_t secure = 0; 
> exp_dir_swimable(m_expedition->scouting_direction); ++secure) {
>                                               assert(secure < 6);
> -                                             m_expedition->direction = 
> get_cw_neighbour(m_expedition->direction);
> +                                             
> m_expedition->scouting_direction = 
> get_cw_neighbour(m_expedition->scouting_direction);
>                                       }
> -                                     m_expedition->direction = 
> get_backward_dir(m_expedition->direction);
> +                                     m_expedition->scouting_direction = 
> get_backward_dir(m_expedition->scouting_direction);
>                                       // Save the position - this is where we 
> start
>                                       m_expedition->exploration_start = 
> get_position();
>                               } else {
> @@ -579,18 +579,18 @@
>                               // The ship is supposed to follow the coast as 
> close as possible, therefore the check
>                               // for
>                               // a swimable field begins at the neighbour 
> field of the direction we came from.
> -                             m_expedition->direction = 
> get_backward_dir(m_expedition->direction);
> -                             if (m_expedition->scouting_direction == 
> ScoutingDirection::kClockwise) {
> +                             m_expedition->scouting_direction = 
> get_backward_dir(m_expedition->scouting_direction);
> +                             if (m_expedition->island_explore_direction == 
> IslandExploreDirection::kClockwise) {
>                                       do {
> -                                             m_expedition->direction = 
> get_ccw_neighbour(m_expedition->direction);
> -                                     } while 
> (!exp_dir_swimable(m_expedition->direction));
> +                                             
> m_expedition->scouting_direction = 
> get_ccw_neighbour(m_expedition->scouting_direction);
> +                                     } while 
> (!exp_dir_swimable(m_expedition->scouting_direction));
>                               } else {
>                                       do {
> -                                             m_expedition->direction = 
> get_cw_neighbour(m_expedition->direction);
> -                                     } while 
> (!exp_dir_swimable(m_expedition->direction));
> +                                             
> m_expedition->scouting_direction = 
> get_cw_neighbour(m_expedition->scouting_direction);
> +                                     } while 
> (!exp_dir_swimable(m_expedition->scouting_direction));
>                               }
>                               state.ivar1 = 1;
> -                             return start_task_move(game, 
> m_expedition->direction, descr().get_sail_anims(), false);
> +                             return start_task_move(game, 
> m_expedition->scouting_direction, descr().get_sail_anims(), false);
>                       } else {
>                               // The ship got the command to scout around an 
> island, but is not close to any island
>                               // Most likely the command was send as the ship 
> was on an exploration and just leaving
> @@ -615,10 +615,10 @@
>                               return start_task_idle(game, 
> descr().main_animation(), 1500);
>                       }
>               } else {  // scouting towards a specific direction
> -                     if (exp_dir_swimable(m_expedition->direction)) {
> +                     if (exp_dir_swimable(m_expedition->scouting_direction)) 
> {
>                               // the scouting direction is still free to move
>                               state.ivar1 = 1;
> -                             start_task_move(game, m_expedition->direction, 
> descr().get_sail_anims(), false);
> +                             start_task_move(game, 
> m_expedition->scouting_direction, descr().get_sail_anims(), false);
>                               return;
>                       }
>                       // coast reached
> @@ -791,9 +791,9 @@
>       m_expedition.reset(new Expedition());
>       m_expedition->seen_port_buildspaces.reset(new std::list<Coords>());
>       m_expedition->island_exploration = false;
> -     m_expedition->direction = 0;
> +     m_expedition->scouting_direction = WalkingDir::IDLE;
>       m_expedition->exploration_start = Coords(0, 0);
> -     m_expedition->scouting_direction = ScoutingDirection::kClockwise;
> +     m_expedition->island_explore_direction = 
> IslandExploreDirection::kClockwise;
>       m_expedition->economy.reset(new Economy(*get_owner()));
>  
>       // We are no longer in any other economy, but instead are an economy of 
> our
> @@ -824,13 +824,22 @@
>  
>  /// Initializes / changes the direction of scouting to @arg direction
>  /// @note only called via player command
> -void Ship::exp_scout_direction(Game&, uint8_t direction) {
> +void Ship::exp_scouting_direction(Game&, WalkingDir scouting_direction) {
>       assert(m_expedition);
>       m_ship_state = EXP_SCOUTING;
> -     m_expedition->direction = direction;
> +     m_expedition->scouting_direction = scouting_direction;
>       m_expedition->island_exploration = false;
>  }
>  
> +//Returns integer of direction, or WalkingDir::IDLE if query invalid

documentation should go into the header. also below

> +//Intended for LUA scripting
> +WalkingDir Ship::get_scouting_direction() {
> +     if (m_expedition && m_ship_state == EXP_SCOUTING && 
> !m_expedition->island_exploration) {
> +             return m_expedition->scouting_direction;
> +     }
> +     return WalkingDir::IDLE;
> +}
> +
>  /// Initializes the construction of a port at @arg c
>  /// @note only called via player command
>  void Ship::exp_construct_port(Game&, const Coords& c) {
> @@ -840,16 +849,26 @@
>       m_ship_state = EXP_COLONIZING;
>  }
>  
> -/// Initializes / changes the direction the island exploration in @arg 
> scouting_direction direction
> +/// Initializes / changes the direction the island exploration in @arg 
> island_explore_direction direction
>  /// @note only called via player command
> -void Ship::exp_explore_island(Game&, ScoutingDirection scouting_direction) {
> +void Ship::exp_explore_island(Game&, IslandExploreDirection 
> island_explore_direction) {
>       assert(m_expedition);
>       m_ship_state = EXP_SCOUTING;
> -     m_expedition->scouting_direction = scouting_direction;
> -     m_expedition->direction = 0;
> +     m_expedition->island_explore_direction = island_explore_direction;
> +     m_expedition->scouting_direction = WalkingDir::IDLE;
>       m_expedition->island_exploration = true;
>  }
>  
> +//Returns integer of direction, or 255 if query invalid
> +//Intended for LUA scripting
> +IslandExploreDirection Ship::get_island_explore_direction() {
> +     if (m_expedition && m_ship_state == EXP_SCOUTING && 
> m_expedition->island_exploration) {
> +             return m_expedition->island_explore_direction;
> +     }
> +     return IslandExploreDirection::kNotSet;
> +}
> +
> +
>  /// Cancels a currently running expedition
>  /// @note only called via player command
>  void Ship::exp_cancel(Game& game) {
> @@ -995,11 +1014,11 @@
>                               // whether scouting or exploring
>                               m_expedition->island_exploration = 
> fr.unsigned_8() == 1;
>                               // current direction
> -                             m_expedition->direction = fr.unsigned_8();
> +                             m_expedition->scouting_direction = 
> static_cast<WalkingDir>(fr.unsigned_8());
>                               // Start coordinates of an island exploration
>                               m_expedition->exploration_start = 
> read_coords_32(&fr);
>                               // Whether the exploration is done clockwise or 
> counter clockwise
> -                             m_expedition->scouting_direction = 
> static_cast<ScoutingDirection>(fr.unsigned_8());
> +                             m_expedition->island_explore_direction = 
> static_cast<IslandExploreDirection>(fr.unsigned_8());
>                       }
>               } else
>                       m_ship_state = TRANSPORT;
> @@ -1114,11 +1133,11 @@
>               // whether scouting or exploring
>               fw.unsigned_8(m_expedition->island_exploration ? 1 : 0);
>               // current direction
> -             fw.unsigned_8(m_expedition->direction);
> +             
> fw.unsigned_8(static_cast<uint8_t>(m_expedition->scouting_direction));
>               // Start coordinates of an island exploration
>               write_coords_32(&fw, m_expedition->exploration_start);
>               // Whether the exploration is done clockwise or counter 
> clockwise
> -             
> fw.unsigned_8(static_cast<uint8_t>(m_expedition->scouting_direction));
> +             
> fw.unsigned_8(static_cast<uint8_t>(m_expedition->island_explore_direction));
>       }
>  
>       
> fw.unsigned_32(mos.get_object_file_index_or_zero(m_lastdock.get(egbase)));
> 
> === modified file 'src/logic/ship.h'
> --- src/logic/ship.h  2015-02-05 12:11:20 +0000
> +++ src/logic/ship.h  2015-04-07 13:33:49 +0000
> @@ -38,9 +38,10 @@
>  class PortDock;
>  
>  // This can't be part of the Ship class because of forward declaration in 
> game.h
> -enum class ScoutingDirection {
> +enum class IslandExploreDirection {
>       kCounterClockwise = 0, // This comes first for savegame compatibility 
> (used to be = 0)
> -     kClockwise = 1
> +     kClockwise = 1,
> +     kNotSet
>  };
>  
>  struct NoteShipMessage {
> @@ -202,9 +203,11 @@
>               return m_expedition->seen_port_buildspaces.get();
>       }
>  
> -     void exp_scout_direction(Game &, uint8_t);
> +     void exp_scouting_direction(Game &, WalkingDir);
>       void exp_construct_port (Game &, const Coords&);
> -     void exp_explore_island (Game &, ScoutingDirection);
> +     void exp_explore_island (Game &, IslandExploreDirection);
> +     WalkingDir get_scouting_direction();
> +     IslandExploreDirection get_island_explore_direction();
>  
>       void exp_cancel (Game &);
>       void sink_ship  (Game &);
> @@ -242,9 +245,9 @@
>               std::unique_ptr<std::list<Coords> > seen_port_buildspaces;
>               bool swimable[LAST_DIRECTION];
>               bool island_exploration;
> -             uint8_t direction;
> +             WalkingDir scouting_direction;
>               Coords exploration_start;
> -             ScoutingDirection scouting_direction;
> +             IslandExploreDirection island_explore_direction;
>               std::unique_ptr<Economy> economy;
>       };
>       std::unique_ptr<Expedition> m_expedition;
> 
> === modified file 'src/logic/walkingdir.cc'
> --- src/logic/walkingdir.cc   2014-07-14 10:45:44 +0000
> +++ src/logic/walkingdir.cc   2015-04-07 13:33:49 +0000
> @@ -22,61 +22,61 @@
>  namespace Widelands {
>  
>  /// \returns the neighbour direction in clockwise
> -uint8_t get_cw_neighbour(uint8_t dir) {
> +WalkingDir get_cw_neighbour(WalkingDir dir) {
>       switch (dir) {
> -             case WALK_NE:
> -                     return WALK_E;
> -             case WALK_E:
> -                     return WALK_SE;
> -             case WALK_SE:
> -                     return WALK_SW;
> -             case WALK_SW:
> -                     return WALK_W;
> -             case WALK_W:
> -                     return WALK_NW;
> -             case WALK_NW:
> -                     return WALK_NE;
> +             case WalkingDir::WALK_NE:
> +                     return WalkingDir::WALK_E;
> +             case WalkingDir::WALK_E:
> +                     return WalkingDir::WALK_SE;
> +             case WalkingDir::WALK_SE:
> +                     return WalkingDir::WALK_SW;
> +             case WalkingDir::WALK_SW:
> +                     return WalkingDir::WALK_W;
> +             case WalkingDir::WALK_W:
> +                     return WalkingDir::WALK_NW;
> +             case WalkingDir::WALK_NW:
> +                     return WalkingDir::WALK_NE;
>               default:
> -                     return 0;
> +                     return WalkingDir::IDLE;
>       }
>  }
>  
>  /// \returns the neighbour direction in counterclockwise
> -uint8_t get_ccw_neighbour(uint8_t dir) {
> +WalkingDir get_ccw_neighbour(WalkingDir dir) {
>       switch (dir) {
> -             case WALK_E:
> -                     return WALK_NE;
> -             case WALK_NE:
> -                     return WALK_NW;
> -             case WALK_NW:
> -                     return WALK_W;
> -             case WALK_W:
> -                     return WALK_SW;
> -             case WALK_SW:
> -                     return WALK_SE;
> -             case WALK_SE:
> -                     return WALK_E;
> +             case WalkingDir::WALK_E:
> +                     return WalkingDir::WALK_NE;
> +             case WalkingDir::WALK_NE:
> +                     return WalkingDir::WALK_NW;
> +             case WalkingDir::WALK_NW:
> +                     return WalkingDir::WALK_W;
> +             case WalkingDir::WALK_W:
> +                     return WalkingDir::WALK_SW;
> +             case WalkingDir::WALK_SW:
> +                     return WalkingDir::WALK_SE;
> +             case WalkingDir::WALK_SE:
> +                     return WalkingDir::WALK_E;
>               default:
> -                     return 0;
> +                     return WalkingDir::IDLE;
>       }
>  }
>  
> -uint8_t get_backward_dir(uint8_t dir) {
> +WalkingDir get_backward_dir(WalkingDir dir) {
>       switch (dir) {
> -             case WALK_E:
> -                     return WALK_W;
> -             case WALK_NE:
> -                     return WALK_SW;
> -             case WALK_NW:
> -                     return WALK_SE;
> -             case WALK_W:
> -                     return WALK_E;
> -             case WALK_SW:
> -                     return WALK_NE;
> -             case WALK_SE:
> -                     return WALK_NW;
> +             case WalkingDir::WALK_E:
> +                     return WalkingDir::WALK_W;
> +             case WalkingDir::WALK_NE:
> +                     return WalkingDir::WALK_SW;
> +             case WalkingDir::WALK_NW:
> +                     return WalkingDir::WALK_SE;
> +             case WalkingDir::WALK_W:
> +                     return WalkingDir::WALK_E;
> +             case WalkingDir::WALK_SW:
> +                     return WalkingDir::WALK_NE;
> +             case WalkingDir::WALK_SE:
> +                     return WalkingDir::WALK_NW;
>               default:
> -                     return 0;
> +                     return WalkingDir::IDLE;
>       }
>  }
>  
> 
> === modified file 'src/logic/walkingdir.h'
> --- src/logic/walkingdir.h    2014-07-05 16:41:51 +0000
> +++ src/logic/walkingdir.h    2015-04-07 13:33:49 +0000
> @@ -37,9 +37,9 @@
>       LAST_DIRECTION  = 6,
>  };
>  
> -uint8_t get_cw_neighbour(uint8_t dir);
> -uint8_t get_ccw_neighbour(uint8_t dir);
> -uint8_t get_backward_dir(uint8_t dir);
> +WalkingDir get_cw_neighbour(WalkingDir dir);
> +WalkingDir get_ccw_neighbour(WalkingDir dir);
> +WalkingDir get_backward_dir(WalkingDir dir);
>  
>  }
>  
> 
> === modified file 'src/scripting/lua_game.cc'
> --- src/scripting/lua_game.cc 2015-01-31 16:03:59 +0000
> +++ src/scripting/lua_game.cc 2015-04-07 13:33:49 +0000
> @@ -97,6 +97,7 @@
>       METHOD(LuaPlayer, hide_fields),
>       METHOD(LuaPlayer, reveal_scenario),
>       METHOD(LuaPlayer, reveal_campaign),
> +     METHOD(LuaPlayer, get_ships),
>       METHOD(LuaPlayer, get_buildings),
>       METHOD(LuaPlayer, get_suitability),
>       METHOD(LuaPlayer, allow_workers),
> @@ -628,6 +629,7 @@
>  int LuaPlayer::reveal_campaign(lua_State * L) {
>       if (get_game(L).get_ipl()->player_number() != player_number())
>               report_error(L, "Can only be called for interactive player!");
> +             report_error(L, "Can only be called for interactive player!");
>  
>       CampaignVisibilitySave cvs;
>       cvs.set_campaign_visibility(luaL_checkstring(L, 2), true);
> @@ -635,6 +637,41 @@
>       return 0;
>  }
>  
> +/* RST
> +     .. method:: get_ships()
> +
> +             :returns: array of player's ships
> +             :rtype: :class:`array` or :class:`table`
> +*/
> +int LuaPlayer::get_ships(lua_State * L) {
> +     EditorGameBase & egbase = get_egbase(L);
> +     Map * map = egbase.get_map();
> +     PlayerNumber p = (get(L, egbase)).player_number();
> +     lua_newtable(L);
> +     uint32_t cidx = 1;
> +
> +     std::set<OPtr<Ship>> found_ships;
> +     for (int16_t y = 0; y < map->get_height(); ++y) {
> +             for (int16_t x = 0; x < map->get_width(); ++x) {
> +                     FCoords f = map->get_fcoords(Coords(x, y));
> +                     // there are too many bobs on the map so we investigate
> +                     // only bobs on water
> +                     if (f.field->nodecaps() & MOVECAPS_SWIM) {
> +                             for (Bob* bob = f.field->get_first_bob(); bob; 
> bob = bob->get_next_on_field()) {
> +                                     if (upcast(Ship, ship, bob)) {
> +                                             if 
> (ship->get_owner()->player_number() == p && !found_ships.count(ship)) {
> +                                                     
> found_ships.insert(ship);
> +                                                     lua_pushuint32(L, 
> cidx++);
> +                                                     
> LuaMaps::upcasted_map_object_to_lua(L, ship);
> +                                                     lua_rawset(L, -3);
> +                                             }
> +                                     }
> +                             }
> +                     }
> +             }
> +     }
> +     return 1;
> +}
>  
>  /* RST
>       .. method:: get_buildings(which)
> 
> === modified file 'src/scripting/lua_game.h'
> --- src/scripting/lua_game.h  2015-02-09 05:57:08 +0000
> +++ src/scripting/lua_game.h  2015-04-07 13:33:49 +0000
> @@ -83,6 +83,7 @@
>       int hide_fields(lua_State * L);
>       int reveal_scenario(lua_State * L);
>       int reveal_campaign(lua_State * L);
> +     int get_ships(lua_State * L);
>       int get_buildings(lua_State * L);
>       int get_suitability(lua_State * L);
>       int allow_workers(lua_State * L);
> 
> === modified file 'src/scripting/lua_map.cc'
> --- src/scripting/lua_map.cc  2015-02-12 21:03:20 +0000
> +++ src/scripting/lua_map.cc  2015-04-07 13:33:49 +0000
> @@ -32,6 +32,7 @@
>  #include "logic/maphollowregion.h"
>  #include "logic/mapregion.h"
>  #include "logic/player.h"
> +#include "logic/ship.h"
>  #include "logic/soldier.h"
>  #include "logic/warelist.h"
>  #include "logic/widelands_geometry.h"
> @@ -44,6 +45,10 @@
>  #include "scripting/lua_game.h"
>  #include "wui/mapviewpixelfunctions.h"
>  
> +
> +//#include "scripting/luna_impl.h" //

commented out headers?

> +//#include "economy/portdock.h"
> +
>  using namespace Widelands;
>  
>  namespace LuaMaps {
> @@ -2681,13 +2686,13 @@
>   ==========================================================
>   */
>  
> +
>  /*
>   ==========================================================
>   C METHODS
>   ==========================================================
>   */
>  
> -
>  /* RST
>  Building
>  --------
> @@ -2806,10 +2811,13 @@
>       METHOD(LuaWarehouse, get_workers),
>       METHOD(LuaWarehouse, set_soldiers),
>       METHOD(LuaWarehouse, get_soldiers),
> +     METHOD(LuaWarehouse, start_expedition),
> +     METHOD(LuaWarehouse, cancel_expedition),
>       {nullptr, nullptr},
>  };
>  const PropertyType<LuaWarehouse> LuaWarehouse::Properties[] = {
>       PROP_RO(LuaWarehouse, portdock),
> +     PROP_RO(LuaWarehouse, expedition_in_progress),
>       {nullptr, nullptr, nullptr},
>  };
>  
> @@ -2829,6 +2837,26 @@
>       return upcasted_map_object_to_lua(L, get(L, 
> get_egbase(L))->get_portdock());
>  }
>  
> +/* RST
> +     .. attribute:: expedition_in_progress
> +
> +             (RO) If this Warehouse is a port, and an expedition is in
> +             progress, returns true, otherwise nil
> +*/
> +int LuaWarehouse::get_expedition_in_progress(lua_State * L) {
> +
> +     Warehouse* Wh = get(L, get_egbase(L));

variable names are lower_case in Widelands.

> +
> +     if (upcast(Game, game, &get_egbase(L))) {
> +             PortDock* pd = Wh->get_portdock();
> +             if (pd) {
> +                     if (pd->expedition_started()){
> +                             return 1;
> +                     }
> +             }
> +     }
> +     return 0;
> +}
>  
>  /*
>   ==========================================================
> @@ -2895,13 +2923,72 @@
>       return do_set_soldiers(L, wh->get_position(), wh, wh->get_owner());
>  }
>  
> +/* RST
> +     .. method:: start_expedition(port)
> +
> +             :arg port
> +
> +             Starts preparation for expedition
> +
> +*/
> +int LuaWarehouse::start_expedition(lua_State* L) {
> +
> +     Warehouse* Wh = get(L, get_egbase(L));
> +
> +     if (!Wh) {
> +             return 0;
> +     }
> +
> +     if (upcast(Game, game, &get_egbase(L))) {
> +             PortDock* pd = Wh->get_portdock();
> +             if (!pd) {
> +                     return 0;
> +             }
> +             if (!pd->expedition_started()){
> +                     game->send_player_start_or_cancel_expedition(*Wh);
> +                     return 1;
> +             }
> +     }
> +
> +     return 0;
> +}
> +
> +/* RST
> +     .. method:: cancel_expedition(port)
> +
> +             :arg port
> +
> +             Cancels an expedition if in progress
> +
> +*/
> +int LuaWarehouse::cancel_expedition(lua_State* L) {
> +
> +     Warehouse* Wh = get(L, get_egbase(L));
> +
> +     if (!Wh) {
> +             return 0;
> +     }
> +
> +     if (upcast(Game, game, &get_egbase(L))) {
> +             PortDock* pd = Wh->get_portdock();
> +                     if (!pd) {
> +                             return 0;
> +                     }
> +             if (pd->expedition_started()){
> +                     game->send_player_start_or_cancel_expedition(*Wh);
> +                     return 1;
> +             }
> +     }
> +
> +     return 0;
> +}
> +
>  /*
>   ==========================================================
>   C METHODS
>   ==========================================================
>   */
>  
> -
>  /* RST
>  ProductionSite
>  --------------
> @@ -3179,6 +3266,7 @@
>       {nullptr, nullptr},
>  };
>  const PropertyType<LuaBob> LuaBob::Properties[] = {
> +     PROP_RO(LuaBob, field),
>       {nullptr, nullptr, nullptr},
>  };
>  
> @@ -3189,6 +3277,27 @@
>   */
>  
>  /* RST
> +     .. attribute:: field //working here
> +
> +             (RO) The field the bob is located on
> +*/
> +// UNTESTED
> +int LuaBob::get_field(lua_State * L) {
> +
> +     EditorGameBase & egbase = get_egbase(L);
> +
> +     Coords coords = get(L, egbase)->get_position();
> +
> +     return to_lua<LuaMaps::LuaField>(L, new LuaMaps::LuaField(coords.x, 
> coords.y));
> +}
> +
> +
> +/*
> + ==========================================================
> + LUA METHODS
> + ==========================================================
> + */
> +/* RST
>       .. method:: has_caps(capname)
>  
>               Similar to :meth:`Field::has_caps`.
> @@ -3214,13 +3323,6 @@
>       return 1;
>  }
>  
> -
> -/*
> - ==========================================================
> - LUA METHODS
> - ==========================================================
> - */
> -
>  /*
>   ==========================================================
>   C METHODS
> @@ -3240,12 +3342,16 @@
>  const MethodType<LuaShip> LuaShip::Methods[] = {
>       METHOD(LuaShip, get_wares),
>       METHOD(LuaShip, get_workers),
> +     METHOD(LuaShip, build_colonization_port),
>       {nullptr, nullptr},
>  };
>  const PropertyType<LuaShip> LuaShip::Properties[] = {
>       PROP_RO(LuaShip, debug_economy),
>       PROP_RO(LuaShip, last_portdock),
>       PROP_RO(LuaShip, destination),
> +     PROP_RO(LuaShip, state),
> +     PROP_RW(LuaShip, scouting_direction),
> +     PROP_RW(LuaShip, island_explore_direction),
>       {nullptr, nullptr, nullptr},
>  };
>  
> @@ -3285,6 +3391,149 @@
>       return upcasted_map_object_to_lua(L, get(L, 
> egbase)->get_lastdock(egbase));
>  }
>  
> +/* RST
> +     .. attribute:: state
> +
> +     Query which state the ship is in:
> +
> +     - transport,
> +     - exp_waiting, exp_scouting, exp_found_port_space, exp_colonizing,
> +     - sink_request, sink_animation
> +
> +             (RW) returns the :class:`string` ship's state, or :const:`nil` 
> if there is no valid state.
> +
> +
> +*/
> +// UNTESTED sink states
> +int LuaShip::get_state(lua_State* L) {
> +     if (upcast(Game, game, &get_egbase(L))) {
> +             switch (get(L, get_egbase(L))->get_ship_state()) {
> +                     case Ship::TRANSPORT:
> +                             lua_pushstring(L, "transport");
> +                             break;
> +                     case Ship::EXP_WAITING:
> +                             lua_pushstring(L, "exp_waiting");
> +                             break;
> +                     case Ship::EXP_SCOUTING:
> +                             lua_pushstring(L, "exp_scouting");
> +                             break;
> +                     case Ship::EXP_FOUNDPORTSPACE:
> +                             lua_pushstring(L, "exp_found_port_space");
> +                             break;
> +                     case Ship::EXP_COLONIZING:
> +                             lua_pushstring(L, "exp_colonizing");
> +                             break;
> +                     case Ship::SINK_REQUEST:
> +                             lua_pushstring(L, "sink_request");
> +                             break;
> +                     case Ship::SINK_ANIMATION:
> +                             lua_pushstring(L, "sink_animation");
> +                             break;
> +                     default:
> +                             lua_pushnil(L);
> +                             return 0;
> +                     }
> +             return 1;
> +     }
> +     return 0;
> +}
> +
> +int LuaShip::get_scouting_direction(lua_State* L) {
> +     if (upcast(Game, game, &get_egbase(L))) {
> +             switch (get(L, get_egbase(L))->get_scouting_direction()) {
> +                     case WalkingDir::WALK_NE:
> +                             lua_pushstring(L, "ne");
> +                             break;
> +                     case WalkingDir::WALK_E:
> +                             lua_pushstring(L, "e");
> +                             break;
> +                     case WalkingDir::WALK_SE:
> +                             lua_pushstring(L, "se");
> +                             break;
> +                     case WalkingDir::WALK_SW:
> +                             lua_pushstring(L, "sw");
> +                             break;
> +                     case WalkingDir::WALK_W:
> +                             lua_pushstring(L, "w");
> +                             break;
> +                     case WalkingDir::WALK_NW:
> +                             lua_pushstring(L, "nw");
> +                             break;
> +                     default:
> +                             return 0;
> +                     }
> +             return 1;
> +     }
> +     return 0;
> +}
> +
> +int LuaShip::set_scouting_direction(lua_State* L) {
> +     if (upcast(Game, game, &get_egbase(L))) {
> +             std::string dirname = luaL_checkstring(L, 3);
> +             WalkingDir dir = WalkingDir::IDLE;
> +
> +             if (dirname == "ne") {
> +                     dir = WalkingDir::WALK_NE;
> +             } else if (dirname == "e") {
> +                     dir = WalkingDir::WALK_E;
> +             } else if (dirname == "se") {
> +                     dir = WalkingDir::WALK_SE;
> +             } else if (dirname == "sw") {
> +                     dir = WalkingDir::WALK_SW;
> +             } else if (dirname == "w") {
> +                     dir = WalkingDir::WALK_W;
> +             } else if (dirname == "nw") {
> +                     dir = WalkingDir::WALK_NW;
> +             } else {
> +                     return 0;
> +             }
> +             game->send_player_ship_scouting_direction(*get(L, 
> get_egbase(L)), dir);
> +             return 1;
> +     }
> +     return 0;
> +
> +}
> +
> +/* RST
> +     .. attribute:: island_explore_direction
> +
> +             (RW) actual direction if the ship sails around an island.
> +             Sets/returns cw, ccw or nil
> +
> +*/
> +int LuaShip::get_island_explore_direction(lua_State* L) {
> +     if (upcast(Game, game, &get_egbase(L))) {
> +             switch (get(L, get_egbase(L))->get_island_explore_direction()) {
> +                     case IslandExploreDirection::kCounterClockwise:
> +                             lua_pushstring(L, "ccw");
> +                             break;
> +                     case IslandExploreDirection::kClockwise:
> +                             lua_pushstring(L, "cw");
> +                             break;
> +                     default:
> +                             return 0;
> +             }
> +             return 1;
> +     }
> +     return 0;
> +}
> +
> +int LuaShip::set_island_explore_direction(lua_State* L) {
> +     if (upcast(Game, game, &get_egbase(L))) {
> +             Ship* ship = get(L, get_egbase(L));
> +             std::string dir = luaL_checkstring(L, 3);
> +             if (dir == "ccw"){
> +                      game->send_player_ship_explore_island(*ship,  
> IslandExploreDirection::kCounterClockwise);
> +             } else if (dir == "cw") {
> +                      game->send_player_ship_explore_island(*ship, 
> IslandExploreDirection::kClockwise);
> +             } else {
> +                     return 0;
> +             }
> +             return 1;
> +     }
> +     return 0;
> +}
> +
>  /*
>   ==========================================================
>   LUA METHODS
> @@ -3341,6 +3590,25 @@
>       return 1;
>  }
>  
> +/* RST
> +     .. method:: build_colonization_port()
> +
> +             Returns true if port space construction was started (ship was 
> in adequate
> +             status and a found portspace was nearby)
> +
> +             :returns: true/false
> +*/
> +int LuaShip::build_colonization_port(lua_State* L) {
> +     Ship* ship =  get(L, get_egbase(L));
> +     if (ship->get_ship_state() == Widelands::Ship::EXP_FOUNDPORTSPACE) {
> +             if (upcast(Game, game, &get_egbase(L))) {
> +                     game->send_player_ship_construct_port(*ship, 
> ship->exp_port_spaces()->front());
> +                     return 1;
> +             }
> +     }
> +     return 0;
> +}
> +
>  /*
>   ==========================================================
>   C METHODS
> 
> === modified file 'src/scripting/lua_map.h'
> --- src/scripting/lua_map.h   2015-02-12 21:03:20 +0000
> +++ src/scripting/lua_map.h   2015-04-07 13:33:49 +0000
> @@ -688,6 +688,7 @@
>        * Properties
>        */
>       int get_portdock(lua_State* L);
> +     int get_expedition_in_progress(lua_State* L);
>  
>       /*
>        * Lua Methods
> @@ -698,6 +699,8 @@
>       int set_workers(lua_State*);
>       int set_soldiers(lua_State*);
>       int get_soldiers(lua_State*);
> +     int start_expedition(lua_State*);
> +     int cancel_expedition(lua_State*);
>  
>       /*
>        * C Methods
> @@ -806,6 +809,7 @@
>       /*
>        * Properties
>        */
> +     int get_field(lua_State *);
>       int has_caps(lua_State *);
>  
>       /*
> @@ -885,12 +889,17 @@
>       int get_debug_economy(lua_State * L);
>       int get_last_portdock(lua_State* L);
>       int get_destination(lua_State* L);
> -
> +     int get_state(lua_State* L);
> +     int get_scouting_direction(lua_State* L);
> +     int set_scouting_direction(lua_State* L);
> +     int get_island_explore_direction(lua_State* L);
> +     int set_island_explore_direction(lua_State* L);
>       /*
>        * Lua methods
>        */
>       int get_wares(lua_State* L);
>       int get_workers(lua_State* L);
> +     int build_colonization_port(lua_State* L);
>  
>       /*
>        * C methods
> 
> === modified file 'src/wui/shipwindow.cc'
> --- src/wui/shipwindow.cc     2015-02-05 12:11:20 +0000
> +++ src/wui/shipwindow.cc     2015-04-07 13:33:49 +0000
> @@ -68,9 +68,9 @@
>       void act_destination();
>       void act_sink();
>       void act_cancel_expedition();
> -     void act_scout_towards(uint8_t);
> +     void act_scout_towards(WalkingDir);
>       void act_construct_port();
> -     void act_explore_island(ScoutingDirection);
> +     void act_explore_island(IslandExploreDirection);
>  
>  private:
>       InteractiveGameBase & m_igbase;
> @@ -120,7 +120,7 @@
>               m_btn_explore_island_cw =
>                       make_button
>                               (exp_top, "expcw", _("Explore the island’s 
> coast clockwise"), pic_explore_cw,
> -                              boost::bind(&ShipWindow::act_explore_island, 
> this, ScoutingDirection::kClockwise));
> +                              boost::bind(&ShipWindow::act_explore_island, 
> this, IslandExploreDirection::kClockwise));
>               exp_top->add(m_btn_explore_island_cw, 0, false);
>  
>               m_btn_scout[WALK_NE - 1] =
> @@ -156,7 +156,7 @@
>               m_btn_explore_island_ccw =
>                       make_button
>                               (exp_bot, "expccw", _("Explore the island’s 
> coast counter clockwise"), pic_explore_ccw,
> -                              boost::bind(&ShipWindow::act_explore_island, 
> this, ScoutingDirection::kCounterClockwise));
> +                              boost::bind(&ShipWindow::act_explore_island, 
> this, IslandExploreDirection::kCounterClockwise));
>               exp_bot->add(m_btn_explore_island_ccw, 0, false);
>  
>               m_btn_scout[WALK_SE - 1] =
> @@ -312,11 +312,11 @@
>  }
>  
>  /// Sends a player command to the ship to scout towards a specific direction
> -void ShipWindow::act_scout_towards(uint8_t direction) {
> +void ShipWindow::act_scout_towards(WalkingDir direction) {
>       // ignore request if the direction is not swimable at all
> -     if (!m_ship.exp_dir_swimable(direction))
> +     if (!m_ship.exp_dir_swimable(static_cast<Direction>(direction)))
>               return;
> -     m_igbase.game().send_player_ship_scout_direction(m_ship, direction);
> +     m_igbase.game().send_player_ship_scouting_direction(m_ship, direction);
>  }
>  
>  /// Constructs a port at the port build space in vision range
> @@ -327,7 +327,7 @@
>  }
>  
>  /// Explores the island cw or ccw
> -void ShipWindow::act_explore_island(ScoutingDirection direction) {
> +void ShipWindow::act_explore_island(IslandExploreDirection direction) {
>       bool coast_nearby = false;
>       bool moveable = false;
>       for (Direction dir = 1; (dir <= LAST_DIRECTION) && (!coast_nearby || 
> !moveable); ++dir) {
> 
> === modified file 'test/maps/expedition.wmf/scripting/init.lua'
> --- test/maps/expedition.wmf/scripting/init.lua       2014-08-01 15:30:12 
> +0000
> +++ test/maps/expedition.wmf/scripting/init.lua       2015-04-07 13:33:49 
> +0000
> @@ -93,24 +93,6 @@
>     assert_equal(1, port:get_workers("builder"))
>  end
>  
> -function start_expedition()
> -   assert_true(click_building(p1, "port"))
> -   sleep(100)
> -   assert_true(click_button("start_expedition"))
> -   sleep(100)
> -   close_windows()
> -   sleep(100)
> -end
> -
> -function cancel_expedition_in_port()
> -   assert_true(click_building(p1, "port"))
> -   sleep(100)
> -   assert_true(click_button("cancel_expedition"))
> -   sleep(100)
> -   close_windows()
> -   sleep(100)
> -end
> -
>  function cancel_expedition_in_shipwindow(which_ship)
>     click_on_ship(which_ship or first_ship)
>     assert_true(click_button("cancel_expedition"))
> @@ -174,7 +156,7 @@
>     game.desired_speed = 10 * 1000
>  
>     -- Start a new expedition.
> -   start_expedition()
> +   port:start_expedition()
>     wait_for_message("Expedition Ready")
>     game.desired_speed = 10 * 1000
>     sleep(10000)
> @@ -205,14 +187,15 @@
>     game.desired_speed = 10 * 1000
>  
>     -- Start a new expedition.
> -   start_expedition()
> +   port:start_expedition()
>     wait_for_message("Expedition Ready")
>     game.desired_speed = 10 * 1000
>     sleep(10000)
>  
> -   click_on_ship(first_ship)
> -   assert_true(click_button("expccw"))
> -   sleep(8000)
> +   first_ship.island_explore_direction="ccw"
> +   sleep(2000)
> +   assert_equal("ccw",first_ship.island_explore_direction)
> +   sleep(6000)
>  
>     stable_save("sailing")
>     assert_equal(1, p1:get_workers("builder"))
> @@ -235,13 +218,14 @@
>     game.desired_speed = 10 * 1000
>  
>     -- Send expedition to port space.
> -   start_expedition()
> +   port:start_expedition()
>     wait_for_message("Expedition Ready")
>     assert_equal(1, p1:get_workers("builder"))
>     sleep(500)
>  
> -   click_on_ship(first_ship)
> -   assert_true(click_button("expccw"))
> +   first_ship.island_explore_direction="ccw"
> +   sleep(2000)
> +   assert_equal("ccw",first_ship.island_explore_direction)
>     wait_for_message("Port Space Found")
>     sleep(500)
>     assert_equal(1, p1:get_workers("builder"))
> @@ -272,12 +256,13 @@
>     port:set_wares("blackwood", 100)
>  
>  
> -   start_expedition()
> +   port:start_expedition()
>     wait_for_message("Expedition Ready")
> -   click_on_ship(first_ship)
> -   assert_true(click_button("expccw"))
> +   first_ship.island_explore_direction="ccw"
> +   sleep(2000)
> +   assert_equal("ccw",first_ship.island_explore_direction)
>     wait_for_message("Port Space Found")
> -   assert_true(click_button("buildport"))
> +   first_ship:build_colonization_port()
>     sleep(500)
>     assert_equal(1, p1:get_workers("builder"))
>     wait_for_message("Port")
> 
> === added file 
> 'test/maps/expedition.wmf/scripting/test_ship_movement_controls.lua'
> --- test/maps/expedition.wmf/scripting/test_ship_movement_controls.lua        
> 1970-01-01 00:00:00 +0000
> +++ test/maps/expedition.wmf/scripting/test_ship_movement_controls.lua        
> 2015-04-07 13:33:49 +0000
> @@ -0,0 +1,115 @@
> +run(function()

Awesome test!

> +   game.desired_speed = 30 * 1000
> +     p1:place_bob("ship", map:get_field(10, 10))
> +
> +     port = map:get_field(16, 16).immovable
> +     port:set_wares("log", 10) -- no sense to wait
> +     port:set_wares("blackwood", 10)
> +
> +     --getting table with all our ships (single one only)
> +     ships = p1:get_ships()
> +
> +     --veryfing that ship is indeed placed where should be :)
> +     assert_equal(10,ships[1].field.x)
> +     assert_equal(10,ships[1].field.y)
> +
> +     --ships table should contain 1 item (1 ship)
> +     assert_equal(1, #ships)
> +
> +     --ship has no wares on it
> +     assert_equal(0,ships[1]:get_wares())
> +
> +     --no destination is set
> +     assert(not ships[1].destination)
> +
> +     --ships in transport state
> +     assert_equal("transport", ships[1].state)
> +
> +     --the  warehouse is probably not in expedition state :)
> +     assert(not map:get_field(8, 18).immovable.expedition_in_progress)
> +
> +     --starting prepartion for expedition
> +     assert(not port.expedition_in_progress)
> +     port:start_expedition()
> +     sleep (300)
> +     assert(port.expedition_in_progress)
> +
> +     --ships changes state when exp ready
> +     while ships[1].state == "transport" do sleep(2000) end
> +     assert_equal("exp_waiting", ships[1].state)
> +
> +     --sending NW and verifying
> +     ships[1].scouting_direction="nw"
> +     sleep(6000)
> +     assert_equal("nw", ships[1].scouting_direction)
> +     assert_equal("exp_scouting", ships[1].state)
> +
> +     while ships[1].scouting_direction == "nw" do
> +             sleep (2000)
> +     end
> +
> +     --now ships stops nearby NW coast, so sending it back
> +     ships[1].scouting_direction="se"
> +     sleep(4000)
> +     assert_equal("se", ships[1].scouting_direction)
> +
> +     --testing remaining directions
> +     ships[1].scouting_direction="e"
> +     sleep(2000)
> +     assert_equal("e", ships[1].scouting_direction)
> +
> +     ships[1].scouting_direction="w"
> +     sleep(2000)
> +     assert_equal("w", ships[1].scouting_direction)
> +
> +     ships[1].scouting_direction="sw"
> +     sleep(2000)
> +     assert_equal("sw", ships[1].scouting_direction)
> +
> +     ships[1].scouting_direction="ne"
> +     sleep(2000)
> +     assert_equal("ne", ships[1].scouting_direction)
> +
> +     --back to original course
> +     ships[1].scouting_direction="se"
> +     sleep(2000)
> +     assert_equal("se", ships[1].scouting_direction)
> +
> +     --waiting till it stops (no direction/nil is returned)
> +     while ships[1].scouting_direction do sleep(2000) end
> +
> +     --sending to scout the island
> +     ships[1].island_explore_direction="ccw";
> +     sleep(3000)
> +     assert_equal("ccw", ships[1].island_explore_direction)
> +     assert_equal("exp_scouting", ships[1].state)
> +
> +     --fine, now change the direction
> +     ships[1].island_explore_direction="cw";
> +     sleep(3000)
> +     assert_equal("cw", ships[1].island_explore_direction)
> +
> +     -- wait till it finds a port
> +     wait_for_message("Port Space Found")
> +     sleep(500)
> +     assert_equal("exp_found_port_space", ships[1].state)
> +
> +     --starting colonization port here
> +     assert(ships[1]:build_colonization_port())
> +     sleep(500)
> +     assert_equal("exp_colonizing", ships[1].state)
> +     sleep(15000)
> +     stable_save("port_in_constr")
> +
> +     -- while unfinished yet, removing it
> +     new_port=map:get_field(16,2).immovable
> +     assert(new_port)
> +     new_port:remove()
> +     sleep(3000)
> +
> +     --yes, the ships is back in transport mode
> +     assert_equal("transport", ships[1].state)
> +
> +     print("# All Tests passed.")
> +     wl.ui.MapView():close()
> +end)
> 
> === modified file 
> 'test/maps/expedition.wmf/scripting/test_starting_and_immediately_canceling.lua'
> --- 
> test/maps/expedition.wmf/scripting/test_starting_and_immediately_canceling.lua
>     2013-10-29 20:22:08 +0000
> +++ 
> test/maps/expedition.wmf/scripting/test_starting_and_immediately_canceling.lua
>     2015-04-07 13:33:49 +0000
> @@ -5,8 +5,12 @@
>  
>     -- Start and immediately cancel an expedition.
>     print("---- 1 -----")
> -   start_expedition()
> -   cancel_expedition_in_port()
> +   port:start_expedition()
> +   sleep(500)
> +   assert(port.expedition_in_progress)
> +   port:cancel_expedition()
> +   sleep(500)
> +   assert(not port.expedition_in_progress)
>     sleep(500)
>     assert_equal(1, p1:get_workers("builder"))
>  
> 
> === modified file 
> 'test/maps/expedition.wmf/scripting/test_starting_wait_a_while_cancel.lua'
> --- test/maps/expedition.wmf/scripting/test_starting_wait_a_while_cancel.lua  
> 2013-10-29 20:22:08 +0000
> +++ test/maps/expedition.wmf/scripting/test_starting_wait_a_while_cancel.lua  
> 2015-04-07 13:33:49 +0000
> @@ -4,12 +4,12 @@
>  
>     -- Start an expedition, but let them carry some wares into it. This also
>     -- gives the builder enough time to walk over.
> -   start_expedition()
> +   port:start_expedition()
>     sleep(50000)
>     stable_save("cancel_in_port")
>     assert_equal(1, p1:get_workers("builder"))
>  
> -   cancel_expedition_in_port()
> +   port:cancel_expedition()
>     sleep(500)
>     assert_equal(1, p1:get_workers("builder"))
>  
> 
> === modified file 'test/maps/ship_transportation.wmf/scripting/init.lua'
> --- test/maps/ship_transportation.wmf/scripting/init.lua      2015-02-10 
> 21:25:14 +0000
> +++ test/maps/ship_transportation.wmf/scripting/init.lua      2015-04-07 
> 13:33:49 +0000
> @@ -37,23 +37,6 @@
>     return nil
>  end
>  
> -function portdock2()
> -     local portdock = map:get_field(15, 4).immovable
> -     if portdock then
> -             return portdock
> -     end
> -     local portdock = map:get_field(14, 5).immovable
> -     if portdock then
> -             return portdock
> -     end
> -     local portdock = map:get_field(14, 4).immovable
> -     if portdock then
> -             return portdock
> -     end
> -     print ("portdock not found")
> -     return nill
> -end
> -
>  function start_building_farm()
>     p1:place_building("farm", map:get_field(18, 4), true, true)
>     connected_road(p1, map:get_field(18,5).immovable, "l,l|tl,tr|", true)
> 
> === modified file 
> 'test/maps/ship_transportation.wmf/scripting/test_rip_portdock_with_worker_and_ware_in_transit.lua'
> --- 
> test/maps/ship_transportation.wmf/scripting/test_rip_portdock_with_worker_and_ware_in_transit.lua
>  2015-02-10 21:25:14 +0000
> +++ 
> test/maps/ship_transportation.wmf/scripting/test_rip_portdock_with_worker_and_ware_in_transit.lua
>  2015-04-07 13:33:49 +0000
> @@ -32,7 +32,9 @@
>       stable_save("restored_port")
>     
>     -- remove the portdock while the blackwood is in transit.
> -   portdock2():remove()
> +   port2_portdock=port2().portdock
> +   assert(port2_portdock)
> +   port2_portdock:remove()
>     
>     sleep(5000)
>  
> 
> === modified file 
> 'test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_worker_in_portdock.lua'
> --- 
> test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_worker_in_portdock.lua
>       2014-01-18 12:40:08 +0000
> +++ 
> test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_worker_in_portdock.lua
>       2015-04-07 13:33:49 +0000
> @@ -5,6 +5,13 @@
>     create_first_port()
>     create_second_port()
>  
> +   --removing portdock first
> +   portdock_fields=port2().portdock.fields
> +   portdock_fields[1].immovable:remove()
> +   sleep(100)
> +   --portdock should be back, as port is still there
> +   assert (portdock_fields[1].immovable) 
> +   
>     start_building_farm()
>     port1():set_workers{
>        builder = 1,
> @@ -16,8 +23,13 @@
>     assert_equal(p1:get_workers("builder"), 1)
>     assert_equal(port1():get_workers("builder"), 0)
>  
> +   portdock_fields=port2().portdock.fields
>     port2():remove()
>     sleep(100)
> +   --verify that also portdock was removed
> +   assert (not portdock_fields[1].immovable)
> +   
> +   sleep(100)
>  
>     stable_save("worker_in_portdock")
>  
> 


-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1380287/+merge/252507
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/bug-1380287.

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to