From ec3e1b88467a31d33855ff6c7ab5b47f16b782a5 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 17 Oct 2012 19:11:03 +0000 Subject: [PATCH] (svn r24606) [1.2] -Backport from trunk: - Fix: [Script] API documentation mistakes/omissions (r24584) - Fix: Do not add duplicates to the ban list [FS#5308] (r24580) - Fix: Draw the window resize sprite bottom-aligned [FS#5324] (r24577) - Fix: Vehicle list at buoys did no longer work [FS#5319] (r24576) - Fix: [Windows] Do not cast away const in OS specific code (r24572, r24571) --- src/network/core/os_abstraction.h | 2 +- src/network/network_server.cpp | 11 ++++++++++- src/os/windows/win32.cpp | 4 ++-- src/script/api/script_engine.hpp | 3 +++ src/script/api/script_order.hpp | 8 ++++++-- src/script/api/script_tile.hpp | 2 +- src/script/api/script_vehicle.hpp | 3 +++ src/waypoint_gui.cpp | 2 +- src/widget.cpp | 6 ++++-- 9 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h index 133f3d9581..980c6f7f6d 100644 --- a/src/network/core/os_abstraction.h +++ b/src/network/core/os_abstraction.h @@ -57,7 +57,7 @@ static inline int OTTDgetnameinfo(const struct sockaddr *sa, socklen_t salen, ch if (getnameinfo != NULL) return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); - strncpy(host, inet_ntoa(((struct sockaddr_in *)sa)->sin_addr), hostlen); + strncpy(host, inet_ntoa(((const struct sockaddr_in *)sa)->sin_addr), hostlen); return 0; } #define getnameinfo OTTDgetnameinfo diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index cd4e5f5641..3464efa9cb 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -2052,7 +2052,16 @@ uint NetworkServerKickOrBanIP(ClientID client_id, bool ban) uint NetworkServerKickOrBanIP(const char *ip, bool ban) { /* Add address to ban-list */ - if (ban) *_network_ban_list.Append() = strdup(ip); + if (ban) { + bool contains = false; + for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) { + if (strcmp(*iter, ip) == 0) { + contains = true; + break; + } + } + if (!contains) *_network_ban_list.Append() = strdup(ip); + } uint n = 0; diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index dc38a69b35..065ed3737e 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -239,7 +239,7 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb * http://www.gamedev.net/community/forums/topic.asp?topic_id=294070&whichpage=1� * XXX - not entirely correct, since filetimes on FAT aren't UTC but local, * this won't entirely be correct, but we use the time only for comparsion. */ - sb->st_mtime = (time_t)((*(uint64*)&fd->ftLastWriteTime - posix_epoch_hns) / 1E7); + sb->st_mtime = (time_t)((*(const uint64*)&fd->ftLastWriteTime - posix_epoch_hns) / 1E7); sb->st_mode = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG; return true; @@ -560,7 +560,7 @@ bool GetClipboardContents(char *buffer, size_t buff_len) cbuf = GetClipboardData(CF_UNICODETEXT); ptr = (const char*)GlobalLock(cbuf); - const char *ret = convert_from_fs((wchar_t*)ptr, buffer, buff_len); + const char *ret = convert_from_fs((const wchar_t*)ptr, buffer, buff_len); GlobalUnlock(cbuf); CloseClipboard(); diff --git a/src/script/api/script_engine.hpp b/src/script/api/script_engine.hpp index c97707acd2..06eb9064a8 100644 --- a/src/script/api/script_engine.hpp +++ b/src/script/api/script_engine.hpp @@ -253,6 +253,9 @@ public: /** * Get the maximum allowed distance between two orders for an engine. + * The distance returned is a vehicle-type specific distance indepenent from other + * map distances, you may use the result of this function to compare it + * with the result of ScriptOrder::GetOrderDistance. * @param engine_id The engine to get the max distance for. * @pre IsValidEngine(engine_id). * @return The maximum distance between two orders for the engine diff --git a/src/script/api/script_order.hpp b/src/script/api/script_order.hpp index 63607fb2cd..715ba95cba 100644 --- a/src/script/api/script_order.hpp +++ b/src/script/api/script_order.hpp @@ -34,7 +34,7 @@ public: /** Destination of new order is to far away from the previous order */ ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION, // [STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION] - /* Aircraft has not enough range to copy/share orders. */ + /** Aircraft has not enough range to copy/share orders. */ ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE, // [STR_ERROR_AIRCRAFT_NOT_ENOUGH_RANGE] }; @@ -585,9 +585,13 @@ public: /** * Get the distance between two points for a vehicle type. + * Use this function to compute the distance between two tiles wrt. a vehicle type. + * These vehicle-type specific distances are indepenent from other map distances, you may + * use the result of this function to compare it with the result of + * ScriptEngine::GetMaximumOrderDistance or ScriptVehicle::GetMaximumOrderDistance. * @param vehicle_type The vehicle type to get the distance for. * @param origin_tile Origin, can be any tile or a tile of a specific station. - * @param dest_tile Destination, ca be any tile or a tile of a specific station. + * @param dest_tile Destination, can be any tile or a tile of a specific station. * @return The distance between the origin and the destination for a vehicle of the given vehicle type. * @see ScriptEngine::GetMaximumOrderDistance and ScriptVehicle::GetMaximumOrderDistance */ diff --git a/src/script/api/script_tile.hpp b/src/script/api/script_tile.hpp index 96f1a39bb6..e4d9cda984 100644 --- a/src/script/api/script_tile.hpp +++ b/src/script/api/script_tile.hpp @@ -400,7 +400,7 @@ public: /** * Level all tiles in the rectangle between start_tile and end_tile so they * are at the same height. All tiles will be raised or lowered until - * they are at height ScriptTile::GetHeight(start_tile). + * they are at height ScriptTile::GetCornerHeight(start_tile, ScriptTile::CORNER_N). * @param start_tile One corner of the rectangle to level. * @param end_tile The opposite corner of the rectangle. * @pre start_tile < ScriptMap::GetMapSize(). diff --git a/src/script/api/script_vehicle.hpp b/src/script/api/script_vehicle.hpp index bbcf929759..6d1245814a 100644 --- a/src/script/api/script_vehicle.hpp +++ b/src/script/api/script_vehicle.hpp @@ -549,6 +549,9 @@ public: /** * Get the maximum allowed distance between two orders for a vehicle. + * The distance returned is a vehicle-type specific distance indepenent from other + * map distances, you may use the result of this function to compare it + * with the result of ScriptOrder::GetOrderDistance. * @param vehicle_id The vehicle to get the distance for. * @pre IsValidVehicle(vehicle_id). * @return The maximum distance between two orders for this vehicle diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 586ada9254..202f7c7f69 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -107,7 +107,7 @@ public: break; case WID_W_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders - ShowVehicleListWindow(this->owner, this->vt, this->wp->index); + ShowVehicleListWindow(this->wp->owner, this->vt, this->wp->index); break; } } diff --git a/src/widget.cpp b/src/widget.cpp index 9f25f42cec..36cd2bfab1 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -480,9 +480,11 @@ static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bo { DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE); if (at_left) { - DrawSprite(SPR_WINDOW_RESIZE_LEFT, PAL_NONE, r.left + WD_RESIZEBOX_RIGHT + clicked, r.top + WD_RESIZEBOX_TOP + clicked); + DrawSprite(SPR_WINDOW_RESIZE_LEFT, PAL_NONE, r.left + WD_RESIZEBOX_RIGHT + clicked, + r.bottom - WD_RESIZEBOX_BOTTOM - GetSpriteSize(SPR_WINDOW_RESIZE_LEFT).height + clicked); } else { - DrawSprite(SPR_WINDOW_RESIZE_RIGHT, PAL_NONE, r.left + WD_RESIZEBOX_LEFT + clicked, r.top + WD_RESIZEBOX_TOP + clicked); + DrawSprite(SPR_WINDOW_RESIZE_RIGHT, PAL_NONE, r.left + WD_RESIZEBOX_LEFT + clicked, + r.bottom - WD_RESIZEBOX_BOTTOM - GetSpriteSize(SPR_WINDOW_RESIZE_RIGHT).height + clicked); } }