2005-10-30 18:01:51 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// multiplaymgr.hpp
|
|
|
|
//
|
|
|
|
// Written by Duncan McCreanor, started February 2003.
|
|
|
|
// duncan.mccreanor@airservicesaustralia.com
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 Airservices Australia
|
|
|
|
// Copyright (C) 2005 Oliver Schroeder
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-10-30 18:01:51 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef MULTIPLAYMGR_H
|
|
|
|
#define MULTIPLAYMGR_H
|
|
|
|
|
|
|
|
#define MULTIPLAYTXMGR_HID "$Id$"
|
|
|
|
|
|
|
|
#include "mpmessages.hxx"
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include STL_STRING
|
|
|
|
SG_USING_STD(string);
|
|
|
|
#include <vector>
|
|
|
|
SG_USING_STD(vector);
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
2006-02-09 12:29:05 +00:00
|
|
|
#include <simgear/props/props.hxx>
|
2005-10-30 18:01:51 +00:00
|
|
|
#include <plib/netSocket.h>
|
|
|
|
#include <Main/globals.hxx>
|
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
#include <AIModel/AIMultiplayer.hxx>
|
|
|
|
|
|
|
|
struct FGExternalMotionInfo;
|
2005-10-30 18:01:51 +00:00
|
|
|
|
|
|
|
class FGMultiplayMgr
|
|
|
|
{
|
|
|
|
public:
|
2006-10-10 05:17:07 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
struct IdPropertyList {
|
|
|
|
unsigned id;
|
|
|
|
const char* name;
|
2006-10-10 05:17:07 +00:00
|
|
|
SGPropertyNode::Type type;
|
2006-02-17 09:43:33 +00:00
|
|
|
};
|
|
|
|
static IdPropertyList sIdPropertyList[];
|
2006-02-09 12:29:05 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
FGMultiplayMgr();
|
|
|
|
~FGMultiplayMgr();
|
|
|
|
bool init(void);
|
|
|
|
void Close(void);
|
|
|
|
// transmitter
|
|
|
|
void SendMyPosition(const FGExternalMotionData& motionInfo);
|
|
|
|
void SendTextMessage(const string &sMsgText);
|
|
|
|
void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u);
|
|
|
|
|
|
|
|
// receiver
|
|
|
|
void ProcessPosMsg(const char *Msg, netAddress & SenderAddress,
|
|
|
|
unsigned len, long stamp);
|
|
|
|
void ProcessChatMsg(const char *Msg, netAddress & SenderAddress);
|
|
|
|
void Update(void);
|
|
|
|
|
2005-10-30 18:01:51 +00:00
|
|
|
private:
|
2006-02-17 09:43:33 +00:00
|
|
|
FGAIMultiplayer* addMultiplayer(const std::string& callsign,
|
|
|
|
const std::string& modelName);
|
|
|
|
FGAIMultiplayer* getMultiplayer(const std::string& callsign);
|
|
|
|
|
|
|
|
/// maps from the callsign string to the FGAIMultiplayer
|
2008-03-22 09:31:06 +00:00
|
|
|
typedef std::map<std::string, osg::ref_ptr<FGAIMultiplayer> > MultiPlayerMap;
|
2006-02-17 09:43:33 +00:00
|
|
|
MultiPlayerMap mMultiPlayerMap;
|
|
|
|
|
|
|
|
netSocket* mSocket;
|
|
|
|
netAddress mServer;
|
|
|
|
bool mHaveServer;
|
|
|
|
bool mInitialised;
|
|
|
|
string mCallsign;
|
2005-10-30 18:01:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|