# HG changeset patch # User truelight # Date 1187528501 0 # Node ID 708f1e3cc4c4230f03794527ee3cfeb9c523e48b # Parent e729875795142ca19818ef7158686b6e904adbcf (svn r10936) [NoAI] -Fix: allow water_protection for non-water-building in DoCommand diff -r e72987579514 -r 708f1e3cc4c4 src/ai/api/ai_marine.cpp --- a/src/ai/api/ai_marine.cpp Fri Aug 03 22:09:42 2007 +0000 +++ b/src/ai/api/ai_marine.cpp Sun Aug 19 13:01:41 2007 +0000 @@ -52,7 +52,7 @@ /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, vertical, 0, CMD_BUILD_SHIP_DEPOT); + return this->DoCommand(tile, vertical, 0, CMD_BUILD_SHIP_DEPOT, false); } bool AIMarine::BuildDock(TileIndex tile) @@ -60,7 +60,7 @@ /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, 1, 0, CMD_BUILD_DOCK); + return this->DoCommand(tile, 1, 0, CMD_BUILD_DOCK, false); } bool AIMarine::BuildBuoy(TileIndex tile) @@ -68,7 +68,7 @@ /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, 0, 0, CMD_BUILD_BUOY); + return this->DoCommand(tile, 0, 0, CMD_BUILD_BUOY, false); } bool AIMarine::BuildLock(TileIndex tile) @@ -76,7 +76,7 @@ /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, 0, 0, CMD_BUILD_LOCK); + return this->DoCommand(tile, 0, 0, CMD_BUILD_LOCK, false); } bool AIMarine::BuildCanal(TileIndex tile) @@ -84,7 +84,7 @@ /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, tile, 0, CMD_BUILD_CANAL); + return this->DoCommand(tile, tile, 0, CMD_BUILD_CANAL, false); } bool AIMarine::RemoveWaterDepot(TileIndex tile) @@ -95,7 +95,7 @@ /* Not a water depot tile */ if (!IsWaterDepotTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } bool AIMarine::RemoveDock(TileIndex tile) @@ -106,7 +106,7 @@ /* Not a dock tile */ if (!IsDockTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } bool AIMarine::RemoveBuoy(TileIndex tile) @@ -117,7 +117,7 @@ /* Not a buoy tile */ if (!IsBuoyTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } bool AIMarine::RemoveLock(TileIndex tile) @@ -128,7 +128,7 @@ /* Not a lock tile */ if (!IsLockTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } bool AIMarine::RemoveCanal(TileIndex tile) @@ -139,5 +139,5 @@ /* Not a canal tile */ if (!IsCanalTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } diff -r e72987579514 -r 708f1e3cc4c4 src/ai/api/ai_object.cpp --- a/src/ai/api/ai_object.cpp Fri Aug 03 22:09:42 2007 +0000 +++ b/src/ai/api/ai_object.cpp Sun Aug 19 13:01:41 2007 +0000 @@ -102,7 +102,7 @@ command_struct->event_data = NULL; } -bool AIObject::DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint procc) +bool AIObject::DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint procc, bool water_protection) { uint32 flags = 0; PlayerID old_lp; @@ -110,6 +110,7 @@ const char* tmp_cmdtext; if (procc != CMD_LANDSCAPE_CLEAR) flags |= DC_AUTO; + if (water_protection) flags |= DC_NO_WATER; /* The test already resets _cmd_text, so backup the pointer */ tmp_cmdtext = _cmd_text; diff -r e72987579514 -r 708f1e3cc4c4 src/ai/api/ai_object.hpp --- a/src/ai/api/ai_object.hpp Fri Aug 03 22:09:42 2007 +0000 +++ b/src/ai/api/ai_object.hpp Sun Aug 19 13:01:41 2007 +0000 @@ -41,7 +41,7 @@ /** * Executes a raw DoCommand for the AI. */ - static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint procc); + static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint procc, bool water_protection = true); /** * Sets the DoCommand costs counter to a value.