00001 //----------------------------------------------------------------------------------- 00002 // 00003 // Pro-Vocation Light Engine (PVLE) 00004 // Copyright (C) 2007-2009 Sukender, KinoX & Buzib 00005 // For more information, contact us : sukender@free.fr 00006 // 00007 // This program is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // For any use that is not compatible with the terms of the GNU 00013 // General Public License, please contact the authors for alternative 00014 // licensing options. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License along 00022 // with this program; if not, write to the Free Software Foundation, Inc., 00023 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00024 // 00025 //----------------------------------------------------------------------------------- 00026 00027 #ifndef NET_PVLE_GHOST_CONNECTION_H 00028 #define NET_PVLE_GHOST_CONNECTION_H 00029 00030 #include <PVLE/Config.h> 00031 00032 #ifdef PVLE_NETWORKING 00033 00034 #include <PVLE/Export.h> 00035 #include <tnl/tnlNetInterface.h> 00036 #include <tnl/tnlGhostConnection.h> 00037 #include <PVLE/Input/Control.h> 00038 00039 class PVLEPlayer; 00040 00042 class PVLE_EXPORT PVLEGhostConnection : public TNL::GhostConnection { 00043 public: 00044 PVLEGhostConnection() : pPlayerGhost(NULL), pPlayerGhostParent(NULL) {} 00045 00046 PVLEPlayer * getClientPlayer() const { return pPlayerGhost; } 00047 PVLEPlayer * getServerPlayer() const { return pPlayerGhostParent; } 00048 00049 virtual void onConnectionEstablished() { 00050 // Call the parent's onConnectionEstablished. By default this will set the initiator to be a connection to "server" and the non-initiator to be a connection to "client" 00051 TNL::GhostConnection::onConnectionEstablished(); 00052 00053 // TODO Perhaps client simulated net parameters (setSimulatedNetParams()) should be sent to the server ? TNL does packet dropping on receiving AND sending... So is this necessary ? 00054 } 00055 00057 virtual void onConnectionTerminated(TerminationReason reason, const char *edString); 00058 00060 TNL_DECLARE_RPC(rpcPlayerGhostInit, (TNL::S32 playerGhostId)); 00061 00063 void receiveControlEvent(const ControlEvent & ce); 00064 00065 protected: 00066 friend class PVLEPlayer; 00067 00068 PVLEPlayer * pPlayerGhost; 00069 PVLEPlayer * pPlayerGhostParent; 00070 }; 00071 00072 #endif // PVLE_NETWORKING 00073 #endif // NET_PVLE_GHOST_CONNECTION_H