5 #include "ai_sign.hpp" |
5 #include "ai_sign.hpp" |
6 #include "table/strings.h" |
6 #include "table/strings.h" |
7 #include "../../command_func.h" |
7 #include "../../command_func.h" |
8 #include "../../core/alloc_func.hpp" |
8 #include "../../core/alloc_func.hpp" |
9 #include "../../signs_base.h" |
9 #include "../../signs_base.h" |
|
10 #include "../../string_func.h" |
10 #include "../../strings_func.h" |
11 #include "../../strings_func.h" |
11 #include "../../tile_map.h" |
12 #include "../../tile_map.h" |
12 |
13 |
13 /* static */ SignID AISign::GetMaxSignID() |
14 /* static */ SignID AISign::GetMaxSignID() |
14 { |
15 { |
44 return ::TileVirtXY(sign->x, sign->y); |
45 return ::TileVirtXY(sign->x, sign->y); |
45 } |
46 } |
46 |
47 |
47 /* static */ bool AISign::RemoveSign(SignID sign_id) |
48 /* static */ bool AISign::RemoveSign(SignID sign_id) |
48 { |
49 { |
|
50 EnforcePrecondition(false, IsValidSign(sign_id)); |
49 _cmd_text = ""; |
51 _cmd_text = ""; |
50 return AIObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN); |
52 return AIObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN); |
51 } |
53 } |
52 |
54 |
53 /* static */ SignID AISign::BuildSign(TileIndex location, const char *text) |
55 /* static */ SignID AISign::BuildSign(TileIndex location, const char *text) |
54 { |
56 { |
55 if (!::IsValidTile(location)) return INVALID_SIGN; |
57 EnforcePrecondition(INVALID_SIGN, ::IsValidTile(location)); |
|
58 EnforcePrecondition(INVALID_SIGN, !StrEmpty(text)); |
56 |
59 |
57 /* Reset the internal NewSignID in case we are in TestMode */ |
60 /* Reset the internal NewSignID in case we are in TestMode */ |
58 AIObject::SetNewSignID(0); |
61 AIObject::SetNewSignID(0); |
59 |
62 |
60 bool ret = AIObject::DoCommand(location, 0, 0, CMD_PLACE_SIGN); |
63 bool ret = AIObject::DoCommand(location, 0, 0, CMD_PLACE_SIGN); |