From e46c59d4d0d63026dc7b9a5f89caf784a5aa57ec Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 19 Mar 2003 20:45:09 +0000 Subject: [PATCH] Add multiplayer support from Duncan McCreanor and Diarmuid Tyson --- configure.ac | 28 ++- docs-mini/README.multiplayer | 72 ++++++ src/Main/Makefile.am | 1 + src/Main/fg_init.cxx | 23 +- src/Main/fg_io.cxx | 19 +- src/Main/globals.hxx | 33 ++- src/Main/main.cxx | 23 +- src/Main/options.cxx | 43 +++- src/Makefile.am | 20 +- src/Model/model.cxx | 3 +- src/Model/model.hxx | 14 +- src/MultiPlayer/.cvsignore | 3 + src/MultiPlayer/Makefile.am | 7 + src/MultiPlayer/mpmessages.hxx | 68 ++++++ src/MultiPlayer/mpplayer.cxx | 294 ++++++++++++++++++++++++ src/MultiPlayer/mpplayer.hxx | 153 +++++++++++++ src/MultiPlayer/multiplayrxmgr.cxx | 346 +++++++++++++++++++++++++++++ src/MultiPlayer/multiplayrxmgr.hxx | 111 +++++++++ src/MultiPlayer/multiplaytxmgr.cxx | 229 +++++++++++++++++++ src/MultiPlayer/multiplaytxmgr.hxx | 102 +++++++++ src/Network/Makefile.am | 1 + src/Network/multiplay.cxx | 135 +++++++++++ src/Network/multiplay.hxx | 81 +++++++ 23 files changed, 1771 insertions(+), 38 deletions(-) create mode 100644 docs-mini/README.multiplayer create mode 100644 src/MultiPlayer/.cvsignore create mode 100644 src/MultiPlayer/Makefile.am create mode 100644 src/MultiPlayer/mpmessages.hxx create mode 100644 src/MultiPlayer/mpplayer.cxx create mode 100644 src/MultiPlayer/mpplayer.hxx create mode 100644 src/MultiPlayer/multiplayrxmgr.cxx create mode 100644 src/MultiPlayer/multiplayrxmgr.hxx create mode 100644 src/MultiPlayer/multiplaytxmgr.cxx create mode 100644 src/MultiPlayer/multiplaytxmgr.hxx create mode 100644 src/Network/multiplay.cxx create mode 100644 src/Network/multiplay.hxx diff --git a/configure.ac b/configure.ac index dd2a5b897..7bbdbe8af 100644 --- a/configure.ac +++ b/configure.ac @@ -57,16 +57,30 @@ if test "x$with_logging" = "xno" ; then AC_DEFINE([FG_NDEBUG], 1, [Define for no logging output]) fi +# Specify if we want to build with default Multiplayer support +# default to with_network=yes +AC_ARG_WITH(multiplayer, [ --with-multiplayer Include default multiplayer support]) +if test "x$with_multiplayer" = "xno" ; then + echo "Building without default multiplayer support" +else + echo "Building with default multiplayer support" + AC_DEFINE([FG_MPLAYER_AS], 1, [Define to build with default multiplayer support]) +fi +AM_CONDITIONAL(ENABLE_MPLAYER_AS, test "x$with_multiplayer" != "xno") + + # Specify if we want to build with Oliver's networking support # default to with_network=yes -AC_ARG_WITH(network_olk, [ --with-network-olk Include Oliver's multi-pilot networking support]) +NETWORK_DIRS=Network +AC_ARG_WITH(network_olk, [ --with-network-olk Include Oliver's multi-pilot networking support [default=no]]) if test "x$with_network_olk" = "xno" ; then echo "Building without Oliver's multi-pilot network support" else echo "Building with Oliver's multi-pilot network support" AC_DEFINE([FG_NETWORK_OLK], 1, [Define to build with Oliver's networking]) fi -AM_CONDITIONAL(ENABLE_NETWORK_OLK, test "x$with_network_olk" != "xno") +AM_CONDITIONAL(ENABLE_NETWORK_OLK, test "x$with_network_olk" != "xno" -a "x$with_multiplayer" = "xno") + # Specify if we want to use WeatherCM instead of FGEnvironment. @@ -82,7 +96,7 @@ fi AM_CONDITIONAL(ENABLE_WEATHERCM, test "x$with_weathercm" = "xyes") dnl Specify if we want the old menubar; default to the new one -AC_ARG_WITH(old-menubar, [ --with-old-menubar Use the old menu bar]) +AC_ARG_WITH(old-menubar, [ --with-old-menubar Use the old menu bar]) if test "x$with_old_menubar" = "xyes" ; then echo "Building with old menubar" AC_DEFINE([FG_OLD_MENUBAR], 1, @@ -90,7 +104,6 @@ if test "x$with_old_menubar" = "xyes" ; then else echo "Building with new menubar" fi -AM_CONDITIONAL(ENABLE_WEATHERCM, test "x$with_weathercm" = "xyes") dnl Thread related checks AC_ARG_WITH(threads, [ --with-threads Include tile loading threads [default=no]]) @@ -590,6 +603,7 @@ AC_CONFIG_FILES([ \ src/Main/runfgfs \ src/Main/runfgfs.bat \ src/Model/Makefile \ + src/MultiPlayer/Makefile \ src/Navaids/Makefile \ src/Network/Makefile \ src/NetworkOLK/Makefile \ @@ -639,6 +653,12 @@ else echo "Using FGEnvironment" fi +if test "x$with_multiplayer" != "xno"; then + echo "Using default multiplayer support" +elif test "x$with_network_olk" != "xno"; then + echo "Using Oliver's multi-pilot network support" +fi + if test "x$with_old_menubar" != "x"; then echo "Using old menubar" else diff --git a/docs-mini/README.multiplayer b/docs-mini/README.multiplayer new file mode 100644 index 000000000..ee081a139 --- /dev/null +++ b/docs-mini/README.multiplayer @@ -0,0 +1,72 @@ +The commands are of the form: + +--multiplay=in | out,Hz,destination address,destination port +--callsign=a_unique_name + + +Below are some examples of startup commands that demonstrate the use of the +multiplayer facilities. + +For two players on a local network or across the internet: +---------------------------------------------------------- +Player1: +--multiplay=out,10,192.168.0.3,5500 --multiplay=in,10,192.168.0.2,5501 +--callsign=player1 + +Player2: +--multiplay=out,10,192.168.0.2,5501 --multiplay=in,10,192.168.0.3,5500 +--callsign=player2 + + +For multiple players on a local network: +---------------------------------------- +Player1: +--multiplay=out,10,255.255.255.255,5500 +--multiplay=in,10,255.255.255.255,5500 --callsign=player1 + +Playern: +--multiplay=out,10,255.255.255.255,5500 +--multiplay=in,10,255.255.255.255,5500 --callsign=playern + +Note that the callsign is used to identify each player in a multiplayer game +so the callsigns must be unique. The multiplayer code ignores packets that +are sent back to itself, as would occur with broadcasting when the rx and tx +ports are the same. + + +Multiple players sending to a single player: +-------------------------------------------- +Player1: +--multiplay=out,10,192.168.0.2,5500 --callsign=player1 + +Player2: +--multiplay=out,10,192.168.0.2,5500 --callsign=player2 + +Player3: +--multiplay=out,10,192.168.0.2,5500 --callsign=player3 + +Player4 (rx only): +--multiplay=in,10,192.168.0.2,5500 --callsign=player4 + +This demonstrates that it is possible to have multiple instances of +Flightgear that send to a single instance that displays all the traffic. This +is the sort of implementation that we are considering for use as a tower +visual simulator. + + +For use with a server (when one is created): +-------------------------------------------- +Player1: +--multiplay=out,10,serveraddress,6000 --multiplay=in,10,myaddress,5500 +--callsign=player1 + +Player2: +--multiplay=out,10,serveraddress,6000 --multiplay=in,10,myaddress,5501 +--callsign=player2 + +Playern: +--multiplay=out,10,serveraddress,6000 --multiplay=in,10,myaddress,5502 +--callsign=playern + +The server would simply act as a packet forwarding mechanism. When it +receives a packet, it sends it to all other active players. diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index bdca16c8d..81e7d4623 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -73,6 +73,7 @@ fgfs_LDADD = \ $(top_builddir)/src/Input/libInput.a \ $(top_builddir)/src/Instrumentation/libInstrumentation.a \ $(top_builddir)/src/Model/libModel.a \ + $(top_builddir)/src/MultiPlayer/libMultiPlayer.a \ $(top_builddir)/src/Navaids/libNavaids.a \ $(top_builddir)/src/Scenery/libScenery.a \ $(SCRIPTING_LIBS) \ diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 363a0590a..0731cc05c 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -118,6 +118,11 @@ #include