AM_CONDITIONAL(ENABLE_NETWORK_OLK, test "x$with_network_olk" != "xno" -a "x$with_multiplayer" = "xno")
AM_CONDITIONAL(ENABLE_MPLAYER_AS, test "x$with_multiplayer" != "xno")
+AC_ARG_WITH(multiserver, [ --with-multiserver Include multiplayer client/server support])
+
+if test "x$with_multiserver" = "xno"; then
+ echo "Building without multiplayer client/server support"
+else
+ echo "Building with multiplayer client/server support"
+ AC_DEFINE([FG_MSERVER_AS], 1, [Define to build with multiplayer client/server support])
+fi
+
+AM_CONDITIONAL(ENABLE_MSERVER_AS, test "x$with_multiserver" != "xno")
# Specify if we want to use WeatherCM instead of FGEnvironment.
# default to with_weathercm=no
src/Replay/Makefile \
src/Scenery/Makefile \
src/Scripting/Makefile \
+ src/Server/Makefile \
src/Sound/Makefile \
src/Systems/Makefile \
src/Time/Makefile \
echo "Using Oliver's multi-pilot network support"
fi
+if test "x$with_multiserver" != "xno"; then
+ echo "Using multiplayer client/server support"
+fi
+
if test "x$with_threads" = "xyes"; then
echo "threads: yes"
else
MPLAYER_LIBS =
endif
+if ENABLE_MSERVER_AS
+MSERVER_LIBS = $(top_builddir)/src/Server/libServer.a
+MSERVER_BINS = fgmp
+else
+MSERVER_LIBS =
+MSERVER_BINS =
+endif
+
if ENABLE_NETWORK_OLK
NETWORK_LIBS = $(top_builddir)/src/NetworkOLK/libNetworkOLK.a
else
EXTRA_DIST = 3dfx.sh runfgfs.in runfgfs.bat.in
-bin_PROGRAMS = fgfs
+bin_PROGRAMS = fgfs $(MSERVER_BINS)
noinst_SCRIPTS = runfgfs.bat runfgfs
$(opengl_LIBS) \
$(audio_LIBS)
+if ENABLE_MSERVER_AS
+
+fgmp_SOURCES = bootstrap.cxx
+
+fgmp_LDADD = $(fgfs_LDADD) $(MSERVER_LIBS)
+
+endif
+
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
MPLAYER_DIRS =
endif
+if ENABLE_MSERVER_AS
+MSERVER_DIRS = Server
+else
+MSERVER_DIRS =
+endif
+
if ENABLE_NETWORK_OLK
NETWORK_DIRS = NetworkOLK
else
Navaids \
Network \
$(MPLAYER_DIRS) \
+ $(MSERVER_DIRS) \
$(NETWORK_DIRS) \
Objects \
Replay \
--- /dev/null
+noinst_LIBRARIES = libServer.a
+noinst_PROGRAMS = buftest msgtest
+
+if ENABLE_MSERVER_AS
+
+MSERVER_AS = \
+ msg_0001_hello.cxx \
+ msg_0001_hello.hxx \
+ messagebuf.cxx \
+ messagebuf.hxx \
+ message.cxx \
+ message.hxx
+
+MSERVER_BUF = buftest.cxx
+
+MSERVER_MSG = msgtest.cxx
+
+else
+
+MSERVER_AS =
+
+MSERVER_BUF =
+
+MSERVER_MSG =
+
+endif
+
+libServer_a_SOURCES = $(MSERVER_AS)
+
+buftest_SOURCES = $(MSERVER_BUF)
+buftest_LDADD = libServer.a
+
+msgtest_SOURCES = $(MSERVER_MSG)
+msgtest_LDADD = libServer.a
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
--- /dev/null
+#include "message.hxx"\r
+\r
+main(int argc, char **argv)\r
+{\r
+ FGMPSMessageBuf buf1, buf2;\r
+\r
+ buf1.clr();\r
+ buf1.put(fgmps_som8, true);\r
+ buf1.put(1);\r
+ for (int i=0; i<256; i++) {\r
+ buf1.put(fgmps_uchar, true);\r
+ buf1.put(i);\r
+ }\r
+ buf1.put(fgmps_eom, true);\r
+\r
+ buf2.set(buf1.str());\r
+\r
+ bool done=false;\r
+ while (!done) {\r
+ unsigned char mid8, uval8;\r
+ unsigned int mid16, uval16;\r
+ unsigned long uval32;\r
+ unsigned long long uval64;\r
+ char val8;\r
+ int val16;\r
+ long val32;\r
+ long long val64;\r
+ float valf;\r
+ double vald;\r
+ string vals;\r
+ printf("dump: ");\r
+ for (int i=0; i<16; i++) printf("%02x ", buf2.peek(i));\r
+ printf("\n");\r
+ try {\r
+ int tag = buf2.get(true);\r
+ switch (tag) {\r
+ case fgmps_som8:\r
+ mid8 = *(unsigned char *)buf2.read1();\r
+ printf("Start Message ID = %02x\n", mid8);\r
+ break;\r
+ case fgmps_som16:\r
+ mid16 = *(unsigned int *)buf2.read2();\r
+ printf("Start Message ID = %04x\n", mid16);\r
+ break;\r
+ case fgmps_eom:\r
+ printf("End Of Message\n", tag);\r
+ done = true;\r
+ break;\r
+ case fgmps_uchar:\r
+ uval8 = *(unsigned char *)buf2.read1();\r
+ printf("uchar = %02x\n", uval8);\r
+ break;\r
+ case fgmps_uint:\r
+ uval16 = *(unsigned int *)buf2.read2();\r
+ printf("uint = %04x\n", uval16);\r
+ break;\r
+ case fgmps_ulong:\r
+ uval32 = *(unsigned long *)buf2.read4();\r
+ printf("ulong = %08lx\n", uval32);\r
+ break;\r
+ case fgmps_ulonglong:\r
+ uval64 = *(unsigned long long *)buf2.read8();\r
+ printf("ulonglong = %16llx\n", uval64);\r
+ break;\r
+ default:\r
+ printf("Unknown prefix = %02x\n", tag);\r
+ done = true;\r
+ break;\r
+ }\r
+ } catch (FGMPSDataException e) {\r
+ done = true;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+// message.hxx -- Multiplayer Client/Server message base class\r
+//\r
+// Written by John Barrett, started November 2003.\r
+//\r
+// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com\r
+//\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License as\r
+// published by the Free Software Foundation; either version 2 of the\r
+// License, or (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful, but\r
+// WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software\r
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+//\r
+\r
+\r
+#include "message.hxx"\r
+\r
+FGMPSMessage::FGMPSMessage() \r
+{\r
+ msgid = 0x0000;\r
+ elements[0].type = fgmps_null;\r
+ elements[0].data = NULL; \r
+ \r
+}\r
+\r
+\r
+\r
--- /dev/null
+// message.hxx -- Multiplayer Client/Server message base class\r
+//\r
+// Written by John Barrett, started November 2003.\r
+//\r
+// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com\r
+//\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License as\r
+// published by the Free Software Foundation; either version 2 of the\r
+// License, or (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful, but\r
+// WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software\r
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+//\r
+\r
+\r
+#ifndef _FG_MPS_MESSAGE_HXX\r
+#define _FG_MPS_MESSAGE_HXX\r
+\r
+#include <simgear/compiler.h>\r
+\r
+#include STL_STRING\r
+#include <stdexcept>\r
+\r
+SG_USING_STD(string);\r
+SG_USING_STD(invalid_argument);\r
+\r
+#include "messagebuf.hxx"\r
+\r
+typedef enum \r
+{\r
+ fgmps_null = 0x00,\r
+ fgmps_uchar = 0xf0,\r
+ fgmps_uint = 0xf1,\r
+ fgmps_ulong = 0xf2,\r
+ fgmps_ulonglong = 0xf3,\r
+ fgmps_char = 0xf4,\r
+ fgmps_int = 0xf5,\r
+ fgmps_long = 0xf6,\r
+ fgmps_longlong = 0xf7,\r
+ fgmps_float = 0xf8,\r
+ fgmps_double = 0xf9,\r
+ fgmps_string = 0xfa,\r
+ fgmps_reserved = 0xfb,\r
+ fgmps_eom = 0xfc,\r
+ fgmps_som8 = 0xfd,\r
+ fgmps_som16 = 0xfe,\r
+ fgmps_esc = 0xfe\r
+} FGMPSMsgElementType;\r
+\r
+typedef struct \r
+{\r
+ FGMPSMsgElementType type;\r
+ void * data;\r
+} FGMPSMsgElementEntry;\r
+\r
+#define FGMPSMsgElementArrayEnd {fgmps_null, 0}\r
+\r
+class FGMPSMessage\r
+{\r
+private:\r
+ FGMPSMsgElementEntry elements[1];\r
+ static unsigned int msgid;\r
+protected:\r
+ FGMPSMessageBuf msg;\r
+public:\r
+ FGMPSMessage();\r
+ ~FGMPSMessage() {}\r
+\r
+ virtual string encodemsg() {}\r
+ virtual FGMPSMessage* decodemsg(string msg) {}\r
+ virtual FGMPSMsgElementEntry* getelements() { return elements; }\r
+ virtual unsigned int getmessageid() { return msgid; }\r
+\r
+};\r
+\r
+#endif\r
--- /dev/null
+#include "messagebuf.hxx"\r
+\r
+#include <netinet/in.h>\r
+\r
+unsigned char FGMPSMessageBuf::get(bool raw)\r
+{\r
+ if (pos >= buf.length())\r
+ throw FGMPSDataException( "FGMPSMessageBuf: Read past end of buffer" );\r
+ if (raw) return buf[pos++];\r
+ if ((unsigned char)buf[pos] == 0xff) {\r
+ pos++;\r
+ return ((unsigned char)buf[pos++] ^ 0xff);\r
+ }\r
+ return buf[pos++];\r
+}\r
+\r
+void FGMPSMessageBuf::put(unsigned char byte, bool raw)\r
+{\r
+ if (!raw) {\r
+ if ((byte & 0xf0) == 0xf0) {\r
+ buf += 0xff;\r
+ byte = byte ^ 0xff;\r
+ }\r
+ }\r
+ buf += byte;\r
+}\r
+\r
+void FGMPSMessageBuf::write1(void* data)\r
+{\r
+ put(*(unsigned char *)data);\r
+}\r
+\r
+void FGMPSMessageBuf::write2(void* data)\r
+{\r
+ *((uint16_t*)tmp) = htons(*((uint16_t*)data));\r
+ put(tmp[0]); \r
+ put(tmp[1]); \r
+}\r
+\r
+void FGMPSMessageBuf::write4(void* data)\r
+{\r
+ *((uint32_t*)tmp) = htonl(*((uint32_t*)data));\r
+ put(tmp[0]); \r
+ put(tmp[1]); \r
+ put(tmp[2]); \r
+ put(tmp[3]); \r
+}\r
+\r
+void FGMPSMessageBuf::write8(void* data)\r
+{\r
+ *((uint32_t*)tmp+0) = htonl(*((uint32_t*)data+4));\r
+ *((uint32_t*)tmp+4) = htonl(*((uint32_t*)data+0));\r
+ put(tmp[0]); \r
+ put(tmp[1]); \r
+ put(tmp[2]); \r
+ put(tmp[3]); \r
+ put(tmp[4]); \r
+ put(tmp[5]); \r
+ put(tmp[6]); \r
+ put(tmp[7]); \r
+}\r
+\r
+void FGMPSMessageBuf::writef(float data)\r
+{\r
+ write4(&data);\r
+}\r
+\r
+void FGMPSMessageBuf::writed(double data)\r
+{\r
+ write8(&data);\r
+}\r
+\r
+void FGMPSMessageBuf::writes(string data)\r
+{\r
+ for (int i=0; i<data.length(); i++) put(data[i]);\r
+}\r
+\r
+void* FGMPSMessageBuf::read1()\r
+{\r
+ tmp[0] = get();\r
+ return tmp;\r
+}\r
+\r
+void* FGMPSMessageBuf::read2()\r
+{\r
+ tmp[0] = get();\r
+ tmp[1] = get();\r
+ *((uint16_t*)tmp) = ntohs(*((uint16_t*)tmp));\r
+ return tmp;\r
+}\r
+\r
+void* FGMPSMessageBuf::read4()\r
+{\r
+ tmp[0] = get();\r
+ tmp[1] = get();\r
+ tmp[2] = get();\r
+ tmp[3] = get();\r
+ *((uint32_t*)tmp) = ntohl(*((uint32_t*)tmp));\r
+ return tmp;\r
+}\r
+\r
+void* FGMPSMessageBuf::read8()\r
+{\r
+ unsigned char res[32];\r
+\r
+ res[0] = get();\r
+ res[1] = get();\r
+ res[2] = get();\r
+ res[3] = get();\r
+ res[4] = get();\r
+ res[5] = get();\r
+ res[6] = get();\r
+ res[7] = get();\r
+ *((uint32_t*)tmp+4) = ntohl(*((uint32_t*)res+0));\r
+ *((uint32_t*)tmp+0) = ntohl(*((uint32_t*)res+4));\r
+ return tmp;\r
+}\r
+\r
+float FGMPSMessageBuf::readf()\r
+{\r
+ return *((float*)read4());\r
+}\r
+\r
+double FGMPSMessageBuf::readd()\r
+{\r
+ return *((double*)read8());\r
+}\r
+\r
+string FGMPSMessageBuf::reads(size_t length)\r
+{\r
+ string res = "";\r
+ for (int i=0; i<length; i++) res += get();\r
+ return res;\r
+}\r
+\r
+\r
+\r
--- /dev/null
+// messagebuf.hxx -- Multiplayer Client/Server message buffer class\r
+//\r
+// Written by John Barrett, started November 2003.\r
+//\r
+// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com\r
+//\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License as\r
+// published by the Free Software Foundation; either version 2 of the\r
+// License, or (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful, but\r
+// WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software\r
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+//\r
+\r
+\r
+#ifndef _FG_MPS_MESSAGEBUF_HXX\r
+#define _FG_MPS_MESSAGEBUF_HXX\r
+\r
+#include <simgear/compiler.h>\r
+\r
+#include STL_STRING\r
+#include <stdexcept>\r
+\r
+SG_USING_STD(string);\r
+SG_USING_STD(invalid_argument);\r
+\r
+class FGMPSDataException : public invalid_argument\r
+{\r
+public:\r
+ FGMPSDataException( const string& what_string )\r
+ : invalid_argument(what_string) {}\r
+};\r
+\r
+class FGMPSMessageBuf \r
+{\r
+\r
+private:\r
+ string buf;\r
+ size_t pos;\r
+ unsigned char tmp[16];\r
+\r
+public:\r
+\r
+ FGMPSMessageBuf() { init(""); }\r
+ FGMPSMessageBuf(string data) { init(data); }\r
+\r
+ ~FGMPSMessageBuf() {}\r
+\r
+ void init(string data)\r
+ {\r
+ buf = data;\r
+ pos = 0;\r
+ }\r
+\r
+ void clr() { buf = ""; }\r
+ void add(string data) { buf += data; }\r
+ void set(string data) { buf = data; }\r
+ string& str() { return buf; }\r
+ size_t ofs() { return pos; }\r
+ void ofs(size_t val) { pos = val; }\r
+\r
+ unsigned char get(bool raw = false);\r
+ unsigned char peek(size_t ofs = 0) { return buf[pos+ofs]; }\r
+ void put(unsigned char byte, bool raw = false);\r
+\r
+ void write1(void* data);\r
+ void write2(void* data);\r
+ void write4(void* data);\r
+ void write8(void* data);\r
+ void writef(float data);\r
+ void writed(double data);\r
+ void writes(string data);\r
+\r
+ void* read1();\r
+ void* read2();\r
+ void* read4();\r
+ void* read8();\r
+ float readf();\r
+ double readd();\r
+ string reads(size_t length);\r
+\r
+ string& buffer() { return buf; }\r
+};\r
+\r
+#endif\r
--- /dev/null
+// message.hxx -- Multiplayer Client/Server message base class\r
+//\r
+// Written by John Barrett, started November 2003.\r
+//\r
+// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com\r
+//\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License as\r
+// published by the Free Software Foundation; either version 2 of the\r
+// License, or (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful, but\r
+// WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software\r
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+//\r
+\r
+\r
+#include "msg_0001_hello.hxx"\r
+\r
+FGMPSMsg0001Hello::FGMPSMsg0001Hello() \r
+{\r
+ msgid = 0x0001;\r
+ elements[0].type = fgmps_uint; elements[0].data = &this->vermajor; \r
+ elements[1].type = fgmps_uint; elements[0].data = &this->verminor; \r
+ elements[2].type = fgmps_uint; elements[0].data = &this->verpatch; \r
+ elements[3].type = fgmps_string; elements[0].data = &this->servname; \r
+ elements[4].type = fgmps_null; elements[4].data = NULL; \r
+}\r
+\r
+\r
+\r
+\r
--- /dev/null
+// message.hxx -- Multiplayer Client/Server message base class\r
+//\r
+// Written by John Barrett, started November 2003.\r
+//\r
+// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com\r
+//\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License as\r
+// published by the Free Software Foundation; either version 2 of the\r
+// License, or (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful, but\r
+// WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software\r
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+//\r
+\r
+\r
+#ifndef _FG_MPS_MSG0001_HXX\r
+#define _FG_MPS_MSG0001_HXX\r
+\r
+#include "message.hxx"\r
+\r
+class FGMPSMsg0001Hello\r
+{\r
+private:\r
+ FGMPSMsgElementEntry elements[5];\r
+ unsigned int msgid;\r
+public:\r
+ FGMPSMsg0001Hello();\r
+ ~FGMPSMsg0001Hello() {}\r
+\r
+ virtual string encodemsg() {}\r
+ virtual FGMPSMessage* decodemsg(string msg) {}\r
+ virtual FGMPSMsgElementEntry* getelements() { return elements; }\r
+ virtual unsigned int getmessageid() { return msgid; }\r
+\r
+ unsigned int vermajor;\r
+ unsigned int verminor;\r
+ unsigned int verpatch;\r
+ string servname;\r
+};\r
+\r
+#endif\r
--- /dev/null
+#include "messagebuf.hxx"\r
+\r
+main(int argc, char **argv)\r
+{\r
+ printf("Hello\n");\r
+}\r