Merge branch 'master' into jgrpp

Remove the viewport sign cache as this is now superseded by the kd tree
implementation

# Conflicts:
#	src/crashlog.cpp
#	src/lang/english.txt
#	src/misc.cpp
#	src/pathfinder/follow_track.hpp
#	src/pbs.cpp
#	src/rail_cmd.cpp
#	src/saveload/vehicle_sl.cpp
#	src/settings.cpp
#	src/settings_gui.cpp
#	src/ship_cmd.cpp
#	src/station.cpp
#	src/station_base.h
#	src/station_cmd.cpp
#	src/table/settings.ini
#	src/thread/thread_morphos.cpp
#	src/town_cmd.cpp
#	src/train_cmd.cpp
#	src/viewport.cpp
#	src/waypoint.cpp
This commit is contained in:
Jonathan G Rennison
2019-03-12 18:00:36 +00:00
177 changed files with 3131 additions and 2247 deletions

View File

@@ -21,48 +21,12 @@
#include "../../safeguards.h"
#ifdef __MORPHOS__
/* the library base is required here */
struct Library *SocketBase = NULL;
#endif
/**
* Initializes the network core (as that is needed for some platforms
* @return true if the core has been initialized, false otherwise
*/
bool NetworkCoreInitialize()
{
#if defined(__MORPHOS__) || defined(__AMIGA__)
/*
* IMPORTANT NOTE: SocketBase needs to be initialized before we use _any_
* network related function, else: crash.
*/
DEBUG(net, 3, "[core] loading bsd socket library");
SocketBase = OpenLibrary("bsdsocket.library", 4);
if (SocketBase == NULL) {
DEBUG(net, 0, "[core] can't open bsdsocket.library version 4, network unavailable");
return false;
}
#if defined(__AMIGA__)
/* for usleep() implementation (only required for legacy AmigaOS builds) */
TimerPort = CreateMsgPort();
if (TimerPort != NULL) {
TimerRequest = (struct timerequest*)CreateIORequest(TimerPort, sizeof(struct timerequest);
if (TimerRequest != NULL) {
if (OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest*)TimerRequest, 0) == 0) {
TimerBase = TimerRequest->tr_node.io_Device;
if (TimerBase == NULL) {
/* free resources... */
DEBUG(net, 0, "[core] can't initialize timer, network unavailable");
return false;
}
}
}
}
#endif /* __AMIGA__ */
#endif /* __MORPHOS__ / __AMIGA__ */
/* Let's load the network in windows */
#ifdef _WIN32
{
@@ -83,17 +47,6 @@ bool NetworkCoreInitialize()
*/
void NetworkCoreShutdown()
{
#if defined(__MORPHOS__) || defined(__AMIGA__)
/* free allocated resources */
#if defined(__AMIGA__)
if (TimerBase != NULL) CloseDevice((struct IORequest*)TimerRequest); // XXX This smells wrong
if (TimerRequest != NULL) DeleteIORequest(TimerRequest);
if (TimerPort != NULL) DeleteMsgPort(TimerPort);
#endif
if (SocketBase != NULL) CloseLibrary(SocketBase);
#endif
#if defined(_WIN32)
WSACleanup();
#endif

View File

@@ -24,7 +24,7 @@
*/
static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast);
#if defined(BEOS_NET_SERVER) || defined(__HAIKU__) /* doesn't have neither getifaddrs or net/if.h */
#if defined(__HAIKU__) /* doesn't have neither getifaddrs or net/if.h */
/* Based on Andrew Bachmann's netstat+.c. Big thanks to him! */
extern "C" int _netstat(int fd, char **output, int verbose);

View File

@@ -61,50 +61,34 @@ typedef unsigned long in_addr_t;
# endif
# define SOCKET int
# define INVALID_SOCKET -1
# if !defined(__MORPHOS__) && !defined(__AMIGA__)
# define ioctlsocket ioctl
# if !defined(BEOS_NET_SERVER)
# define closesocket close
# endif
# define GET_LAST_ERROR() (errno)
# endif
# define ioctlsocket ioctl
# define closesocket close
# define GET_LAST_ERROR() (errno)
/* Need this for FIONREAD on solaris */
# define BSD_COMP
/* Includes needed for UNIX-like systems */
# include <unistd.h>
# include <sys/ioctl.h>
# if defined(__BEOS__) && defined(BEOS_NET_SERVER)
# include <be/net/socket.h>
# include <be/kernel/OS.h> /* snooze() */
# include <be/net/netdb.h>
typedef unsigned long in_addr_t;
# define INADDR_NONE INADDR_BROADCAST
# else
# include <sys/socket.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <arpa/inet.h>
# include <net/if.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <arpa/inet.h>
# include <net/if.h>
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__INNOTEK_LIBC__) \
&& !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__INNOTEK_LIBC__) \
&& !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
/* If for any reason ifaddrs.h does not exist on your system, comment out
* the following two lines and an alternative way will be used to fetch
* the list of IPs from the system. */
# include <ifaddrs.h>
# define HAVE_GETIFADDRS
# endif
# if !defined(INADDR_NONE)
# define INADDR_NONE 0xffffffff
# endif
# if defined(__BEOS__) && !defined(BEOS_NET_SERVER)
/* needed on Zeta */
# include <sys/sockio.h>
# endif
# endif /* BEOS_NET_SERVER */
# include <ifaddrs.h>
# define HAVE_GETIFADDRS
# endif
# if !defined(INADDR_NONE)
# define INADDR_NONE 0xffffffff
# endif
# if !defined(__BEOS__) && defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 1)
# if defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 1)
typedef uint32_t in_addr_t;
# endif
@@ -113,14 +97,6 @@ typedef unsigned long in_addr_t;
# include <netdb.h>
#endif /* UNIX */
#ifdef __BEOS__
typedef int socklen_t;
#endif
#ifdef __HAIKU__
#define IPV6_V6ONLY 27
#endif
/* OS/2 stuff */
#if defined(__OS2__)
# define SOCKET int
@@ -177,39 +153,6 @@ typedef unsigned long in_addr_t;
#endif /* OS/2 */
/* MorphOS and Amiga stuff */
#if defined(__MORPHOS__) || defined(__AMIGA__)
# include <exec/types.h>
# include <proto/exec.h> /* required for Open/CloseLibrary() */
/* MorphOS defines his network functions with UBYTE arrays while we
* use char arrays. This gives tons of unneeded warnings */
# define UBYTE char
# if defined(__MORPHOS__)
# include <sys/filio.h> /* FIO* defines */
# include <sys/sockio.h> /* SIO* defines */
# include <netinet/in.h>
# else /* __AMIGA__ */
# include <proto/socket.h>
# endif
/* Make the names compatible */
# define closesocket(s) CloseSocket(s)
# define GET_LAST_ERROR() Errno()
# define ioctlsocket(s, request, status) IoctlSocket((LONG)s, (ULONG)request, (char*)status)
# define ioctl ioctlsocket
typedef unsigned int in_addr_t;
typedef long socklen_t;
extern struct Library *SocketBase;
# ifdef __AMIGA__
/* for usleep() implementation */
extern struct Device *TimerBase;
extern struct MsgPort *TimerPort;
extern struct timerequest *TimerRequest;
# endif
#endif /* __MORPHOS__ || __AMIGA__ */
/**
* Try to set the socket into non-blocking mode.
* @param d The socket to set the non-blocking more for.
@@ -222,11 +165,7 @@ static inline bool SetNonBlocking(SOCKET d)
#else
int nonblocking = 1;
#endif
#if (defined(__BEOS__) && defined(BEOS_NET_SERVER))
return setsockopt(d, SOL_SOCKET, SO_NONBLOCK, &nonblocking, sizeof(nonblocking)) == 0;
#else
return ioctlsocket(d, FIONBIO, &nonblocking) == 0;
#endif
}
/**
@@ -237,13 +176,9 @@ static inline bool SetNonBlocking(SOCKET d)
static inline bool SetNoDelay(SOCKET d)
{
/* XXX should this be done at all? */
#if !defined(BEOS_NET_SERVER) /* not implemented on BeOS net_server */
int b = 1;
/* The (const char*) cast is needed for windows */
return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b)) == 0;
#else
return true;
#endif
}
/* Make sure these structures have the size we expect them to be */

View File

@@ -233,11 +233,7 @@ bool NetworkTCPSocketHandler::CanSendReceive()
FD_SET(this->sock, &write_fd);
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
if (select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv) < 0) return false;
#else
if (WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL) < 0) return false;
#endif
this->writable = !!FD_ISSET(this->sock, &write_fd);
return FD_ISSET(this->sock, &read_fd) != 0;

View File

@@ -310,11 +310,7 @@ int NetworkHTTPSocketHandler::Receive()
}
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
int n = select(FD_SETSIZE, &read_fd, NULL, NULL, &tv);
#else
int n = WaitSelect(FD_SETSIZE, &read_fd, NULL, NULL, &tv, NULL);
#endif
if (n == -1) return;
for (NetworkHTTPSocketHandler **iter = _http_connections.Begin(); iter < _http_connections.End(); /* nothing */) {

View File

@@ -118,11 +118,7 @@ public:
}
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
if (select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv) < 0) return false;
#else
if (WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL) < 0) return false;
#endif
/* accept clients.. */
for (SocketList::iterator s = sockets.Begin(); s != sockets.End(); s++) {

View File

@@ -127,7 +127,6 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a
p->PrepareToSend();
#ifndef BEOS_NET_SERVER /* will work around this, some day; maybe. */
if (broadcast) {
/* Enable broadcast */
unsigned long val = 1;
@@ -135,7 +134,6 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a
DEBUG(net, 1, "[udp] setting broadcast failed with: %i", GET_LAST_ERROR());
}
}
#endif
/* Send the buffer */
int res = sendto(s->second, (const char*)p->buffer, p->size, 0, (const struct sockaddr *)send.GetAddress(), send.GetAddressLength());