mirror of https://github.com/OpenTTD/OpenTTD
(svn r19858) [1.0] -Backport from trunk:
- Fix: Compilation for NetBSD [FS#3809, FS#3840] (r19853, r19781) - Fix: Drawing fallback sprites for unavailable NewGRF waypoints failed (r19852) - Fix: Ensure that both texts of the NewGRF gui download button fit (r19823) - Fix: Kicking clients by IP did not work [FS#3784] (r19818) - Fix: Compilation with MinGW GCC 4.5.0 and UNICODE (r19787)release/1.0
parent
eee6e228c7
commit
0c01de0929
|
@ -2304,6 +2304,13 @@ detect_library() {
|
|||
if [ -z "$res" ]; then
|
||||
log 2 " trying /usr/local/include/$4$5... no"
|
||||
fi
|
||||
if [ -z "$res" ] && [ "$os" = "NETBSD" ]; then
|
||||
eval "$2=`ls -1 /usr/pkg/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
|
||||
eval "res=\$$2"
|
||||
if [ -z "$res" ]; then
|
||||
log 2 " trying /usr/pkg/include/$4$5... no"
|
||||
fi
|
||||
fi
|
||||
|
||||
eval "res=\$$2"
|
||||
if [ -n "$res" ] && ( [ -n "$force_static" ] || ( [ "$enable_static" != "0" ] && [ "$os" != "OSX" ] ) ); then
|
||||
|
|
|
@ -391,12 +391,59 @@ DEF_CONSOLE_CMD(ConClearBuffer)
|
|||
**********************************/
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
static bool ConKickOrBan(const char *argv, bool ban)
|
||||
{
|
||||
const char *ip = argv;
|
||||
|
||||
if (strchr(argv, '.') == NULL && strchr(argv, ':') == NULL) { // banning with ID
|
||||
ClientID client_id = (ClientID)atoi(argv);
|
||||
|
||||
if (client_id == CLIENT_ID_SERVER) {
|
||||
IConsolePrintF(CC_ERROR, "ERROR: Silly boy, you can not %s yourself!", ban ? "ban" : "kick");
|
||||
return true;
|
||||
}
|
||||
|
||||
NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(client_id);
|
||||
if (ci == NULL) {
|
||||
IConsoleError("Invalid client");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!ban) {
|
||||
/* Kick only this client, not all clients with that IP */
|
||||
NetworkServerKickClient(client_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* When banning, kick+ban all clients with that IP */
|
||||
ip = GetClientIP(ci);
|
||||
}
|
||||
|
||||
uint n = NetworkServerKickOrBanIP(ip, ban);
|
||||
if (n == 0) {
|
||||
IConsolePrint(CC_DEFAULT, ban ? "Client not online, address added to banlist" : "Client not found");
|
||||
} else {
|
||||
IConsolePrintF(CC_DEFAULT, "%sed %u client(s)", ban ? "Bann" : "Kick", n);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConKick)
|
||||
{
|
||||
if (argc == 0) {
|
||||
IConsoleHelp("Kick a client from a network game. Usage: 'kick <ip | client-id>'");
|
||||
IConsoleHelp("For client-id's, see the command 'clients'");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argc != 2) return false;
|
||||
|
||||
return ConKickOrBan(argv[1], false);
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConBan)
|
||||
{
|
||||
NetworkClientInfo *ci;
|
||||
const char *banip = NULL;
|
||||
ClientID client_id;
|
||||
|
||||
if (argc == 0) {
|
||||
IConsoleHelp("Ban a client from a network game. Usage: 'ban <ip | client-id>'");
|
||||
IConsoleHelp("For client-id's, see the command 'clients'");
|
||||
|
@ -406,39 +453,7 @@ DEF_CONSOLE_CMD(ConBan)
|
|||
|
||||
if (argc != 2) return false;
|
||||
|
||||
if (strchr(argv[1], '.') == NULL && strchr(argv[1], ':') == NULL) { // banning with ID
|
||||
client_id = (ClientID)atoi(argv[1]);
|
||||
ci = NetworkFindClientInfoFromClientID(client_id);
|
||||
} else { // banning IP
|
||||
ci = NetworkFindClientInfoFromIP(argv[1]);
|
||||
if (ci == NULL) {
|
||||
banip = argv[1];
|
||||
client_id = (ClientID)-1;
|
||||
} else {
|
||||
client_id = ci->client_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (client_id == CLIENT_ID_SERVER) {
|
||||
IConsoleError("Silly boy, you can not ban yourself!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (client_id == INVALID_CLIENT_ID || (ci == NULL && client_id != (ClientID)-1)) {
|
||||
IConsoleError("Invalid client");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ci != NULL) {
|
||||
IConsolePrint(CC_DEFAULT, "Client banned");
|
||||
banip = GetClientIP(ci);
|
||||
} else {
|
||||
IConsolePrint(CC_DEFAULT, "Client not online, banned IP");
|
||||
}
|
||||
|
||||
NetworkServerBanIP(banip);
|
||||
|
||||
return true;
|
||||
return ConKickOrBan(argv[1], true);
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConUnBan)
|
||||
|
@ -595,46 +610,6 @@ DEF_CONSOLE_CMD(ConClientNickChange)
|
|||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConKick)
|
||||
{
|
||||
NetworkClientInfo *ci;
|
||||
ClientID client_id;
|
||||
|
||||
if (argc == 0) {
|
||||
IConsoleHelp("Kick a client from a network game. Usage: 'kick <ip | client-id>'");
|
||||
IConsoleHelp("For client-id's, see the command 'clients'");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argc != 2) return false;
|
||||
|
||||
if (strchr(argv[1], '.') == NULL) {
|
||||
client_id = (ClientID)atoi(argv[1]);
|
||||
ci = NetworkFindClientInfoFromClientID(client_id);
|
||||
} else {
|
||||
ci = NetworkFindClientInfoFromIP(argv[1]);
|
||||
client_id = (ci == NULL) ? INVALID_CLIENT_ID : ci->client_id;
|
||||
}
|
||||
|
||||
if (client_id == CLIENT_ID_SERVER) {
|
||||
IConsoleError("Silly boy, you can not kick yourself!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (client_id == INVALID_CLIENT_ID) {
|
||||
IConsoleError("Invalid client");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ci != NULL) {
|
||||
NetworkServerKickClient(client_id);
|
||||
} else {
|
||||
IConsoleError("Client not found");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConJoinCompany)
|
||||
{
|
||||
if (argc < 2) {
|
||||
|
|
|
@ -127,7 +127,7 @@ static inline void OTTDfreeaddrinfo(struct addrinfo *ai)
|
|||
|
||||
/* UNIX stuff */
|
||||
#if defined(UNIX) && !defined(__OS2__)
|
||||
# if defined(OPENBSD)
|
||||
# if defined(OPENBSD) || defined(__NetBSD__)
|
||||
# define AI_ADDRCONFIG 0
|
||||
# endif
|
||||
# define SOCKET int
|
||||
|
|
|
@ -79,7 +79,7 @@ void NetworkServerSendError(ClientID client_id, NetworkErrorCode error);
|
|||
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0);
|
||||
|
||||
void NetworkServerKickClient(ClientID client_id);
|
||||
void NetworkServerBanIP(const char *banip);
|
||||
uint NetworkServerKickOrBanIP(const char *ip, bool ban);
|
||||
|
||||
void NetworkInitChatMessage();
|
||||
void CDECL NetworkAddChatMessage(TextColour colour, uint8 duration, const char *message, ...) WARN_FORMAT(3, 4);
|
||||
|
|
|
@ -1786,7 +1786,7 @@ static void ClientList_Ban(byte client_no)
|
|||
|
||||
if (ci == NULL) return;
|
||||
|
||||
NetworkServerBanIP(GetClientIP(ci));
|
||||
NetworkServerKickOrBanIP(GetClientIP(ci), true);
|
||||
}
|
||||
|
||||
static void ClientList_GiveMoney(byte client_no)
|
||||
|
|
|
@ -1808,19 +1808,24 @@ void NetworkServerKickClient(ClientID client_id)
|
|||
NetworkServerSendError(client_id, NETWORK_ERROR_KICKED);
|
||||
}
|
||||
|
||||
void NetworkServerBanIP(const char *banip)
|
||||
uint NetworkServerKickOrBanIP(const char *ip, bool ban)
|
||||
{
|
||||
NetworkClientInfo *ci;
|
||||
/* Add address to ban-list */
|
||||
if (ban) *_network_ban_list.Append() = strdup(ip);
|
||||
|
||||
uint n = 0;
|
||||
|
||||
/* There can be multiple clients with the same IP, kick them all */
|
||||
NetworkClientInfo *ci;
|
||||
FOR_ALL_CLIENT_INFOS(ci) {
|
||||
if (ci->client_address.IsInNetmask(const_cast<char *>(banip))) {
|
||||
if (ci->client_id == CLIENT_ID_SERVER) continue;
|
||||
if (ci->client_address.IsInNetmask(const_cast<char *>(ip))) {
|
||||
NetworkServerKickClient(ci->client_id);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add user to ban-list */
|
||||
*_network_ban_list.Append() = strdup(banip);
|
||||
return n;
|
||||
}
|
||||
|
||||
bool NetworkCompanyHasClients(CompanyID company)
|
||||
|
|
|
@ -613,6 +613,14 @@ struct NewGRFWindow : public Window {
|
|||
*size = maxdim(d, *size);
|
||||
break;
|
||||
}
|
||||
|
||||
case SNGRFS_CONTENT_DOWNLOAD: {
|
||||
Dimension d = GetStringBoundingBox(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON);
|
||||
*size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT));
|
||||
size->width += padding.width;
|
||||
size->height += padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
# include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Unix implementation for the crash logger.
|
||||
*/
|
||||
|
|
|
@ -2379,7 +2379,7 @@ static void DrawTile_Station(TileInfo *ti)
|
|||
palette = PALETTE_TO_GREY;
|
||||
}
|
||||
|
||||
if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationType(ti->tile)][GetStationGfx(ti->tile)];
|
||||
if (t == NULL || t->seq == NULL) t = GetStationTileLayout(GetStationType(ti->tile), GetStationGfx(ti->tile));
|
||||
|
||||
/* don't show foundation for docks */
|
||||
if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile)) {
|
||||
|
@ -2501,7 +2501,7 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro
|
|||
{
|
||||
int32 total_offset = 0;
|
||||
PaletteID pal = COMPANY_SPRITE_COLOUR(_local_company);
|
||||
const DrawTileSprites *t = &_station_display_datas[st][image];
|
||||
const DrawTileSprites *t = GetStationTileLayout(st, image);
|
||||
const RailtypeInfo *rti = NULL;
|
||||
|
||||
if (railtype != INVALID_RAILTYPE) {
|
||||
|
|
|
@ -248,6 +248,7 @@
|
|||
|
||||
/* XXX - WinCE without MSVCRT doesn't support wfopen, so it seems */
|
||||
#if !defined(WINCE)
|
||||
namespace std { using ::_tfopen; }
|
||||
#define fopen(file, mode) _tfopen(OTTD2FS(file), _T(mode))
|
||||
#define unlink(file) _tunlink(OTTD2FS(file))
|
||||
#endif /* WINCE */
|
||||
|
|
|
@ -246,13 +246,18 @@ static inline bool IsWhitespace(WChar c)
|
|||
;
|
||||
}
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
/* Needed for NetBSD version (so feature) testing */
|
||||
#ifdef __NetBSD__
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_GNU_SOURCE) && !(defined(__NetBSD_Version__) && 400000000 < __NetBSD_Version__ )
|
||||
/* strndup is a GNU extension */
|
||||
char *strndup(const char *s, size_t len);
|
||||
#endif /* !_GNU_SOURCE */
|
||||
|
||||
/* strcasestr is available for _GNU_SOURCE, BSD and some Apple */
|
||||
#if defined(_GNU_SOURCE) || (defined(__BSD_VISIBLE) && __BSD_VISIBLE) || (defined(__APPLE__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)))
|
||||
#if defined(_GNU_SOURCE) || (defined(__BSD_VISIBLE) && __BSD_VISIBLE) || (defined(__APPLE__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))) || _NETBSD_SOURCE
|
||||
# undef DEFINE_STRCASESTR
|
||||
#else
|
||||
# define DEFINE_STRCASESTR
|
||||
|
|
|
@ -954,11 +954,21 @@ static const DrawTileSprites _station_display_datas_buoy[] = {
|
|||
static const DrawTileSprites _station_display_datas_waypoint[] = {
|
||||
TILE_SPRITE_LINE(SPR_RAIL_TRACK_X, _station_display_datas_waypoint_X)
|
||||
TILE_SPRITE_LINE(SPR_RAIL_TRACK_Y, _station_display_datas_waypoint_Y)
|
||||
TILE_SPRITE_LINE(SPR_RAIL_TRACK_X, _station_display_datas_waypoint_X)
|
||||
TILE_SPRITE_LINE(SPR_RAIL_TRACK_Y, _station_display_datas_waypoint_Y)
|
||||
TILE_SPRITE_LINE(SPR_RAIL_TRACK_X, _station_display_datas_waypoint_X)
|
||||
TILE_SPRITE_LINE(SPR_RAIL_TRACK_Y, _station_display_datas_waypoint_Y)
|
||||
TILE_SPRITE_LINE(SPR_RAIL_TRACK_X, _station_display_datas_waypoint_X)
|
||||
TILE_SPRITE_LINE(SPR_RAIL_TRACK_Y, _station_display_datas_waypoint_Y)
|
||||
};
|
||||
|
||||
#undef TILE_SPRITE_LINE
|
||||
#undef TILE_SPRITE_NULL
|
||||
|
||||
/* Default waypoint is also drawn as fallback for NewGRF waypoints.
|
||||
* As these are drawn/build like stations, they may use the same number of layouts. */
|
||||
assert_compile(lengthof(_station_display_datas_rail) == lengthof(_station_display_datas_waypoint));
|
||||
|
||||
static const DrawTileSprites * const _station_display_datas[] = {
|
||||
_station_display_datas_rail,
|
||||
_station_display_datas_airport,
|
||||
|
|
Loading…
Reference in New Issue