diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-04-16 15:07:42 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-04-17 18:51:28 +0300 |
commit | 159806140fd33e6ddab951c0f6f180cfbf927d38 (patch) | |
tree | da076be3baa4d987fb5935e220a3d901c926e0e7 /source/gameengine/Network | |
parent | 28b996a9d2090efdd74115a653629ef9d7d871f7 (diff) |
Removing Blender Game Engine from Blender 2.8
Folders removed entirely:
* //extern/recastnavigation
* //intern/decklink
* //intern/moto
* //source/blender/editors/space_logic
* //source/blenderplayer
* //source/gameengine
This includes DNA data and any reference to the BGE code in Blender itself.
We are bumping the subversion.
Pending tasks:
* Tile/clamp code in image editor draw code.
* Viewport drawing code (so much of this will go away because of BI removal
that we can wait until then to remove this.
Diffstat (limited to 'source/gameengine/Network')
-rw-r--r-- | source/gameengine/Network/CMakeLists.txt | 48 | ||||
-rw-r--r-- | source/gameengine/Network/LoopBackNetwork/CMakeLists.txt | 43 | ||||
-rw-r--r-- | source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp | 112 | ||||
-rw-r--r-- | source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h | 63 | ||||
-rw-r--r-- | source/gameengine/Network/NG_NetworkDeviceInterface.h | 82 | ||||
-rw-r--r-- | source/gameengine/Network/NG_NetworkMessage.cpp | 55 | ||||
-rw-r--r-- | source/gameengine/Network/NG_NetworkMessage.h | 138 | ||||
-rw-r--r-- | source/gameengine/Network/NG_NetworkObject.cpp | 46 | ||||
-rw-r--r-- | source/gameengine/Network/NG_NetworkObject.h | 55 | ||||
-rw-r--r-- | source/gameengine/Network/NG_NetworkScene.cpp | 272 | ||||
-rw-r--r-- | source/gameengine/Network/NG_NetworkScene.h | 118 |
11 files changed, 0 insertions, 1032 deletions
diff --git a/source/gameengine/Network/CMakeLists.txt b/source/gameengine/Network/CMakeLists.txt deleted file mode 100644 index 019fc3e6032..00000000000 --- a/source/gameengine/Network/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -set(INC - . - ../../../intern/container - ../../../intern/string - ../../blender/blenlib -) - -set(INC_SYS - ../../../intern/moto/include -) - -set(SRC - NG_NetworkMessage.cpp - NG_NetworkObject.cpp - NG_NetworkScene.cpp - - NG_NetworkDeviceInterface.h - NG_NetworkMessage.h - NG_NetworkObject.h - NG_NetworkScene.h -) - -blender_add_lib(ge_logic_ngnetwork "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt deleted file mode 100644 index 75877575614..00000000000 --- a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# 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 Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -set(INC - . - .. - ../../../../intern/container - ../../../../intern/string -) - -set(INC_SYS - -) - -set(SRC - NG_LoopBackNetworkDeviceInterface.cpp - - NG_LoopBackNetworkDeviceInterface.h -) - -blender_add_lib(ge_logic_loopbacknetwork "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp deleted file mode 100644 index c57bd304ca2..00000000000 --- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * LoopbackNetworkDeviceInterface derived from NG_NetworkDeviceInterface - */ - -/** \file gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp - * \ingroup bgenetlb - */ - - -#include "NG_LoopBackNetworkDeviceInterface.h" -#include "NG_NetworkMessage.h" - -using namespace std; - -// temporary debugging printf's -#ifdef NAN_NET_DEBUG - #include <stdio.h> -#endif - -NG_LoopBackNetworkDeviceInterface::NG_LoopBackNetworkDeviceInterface() -{ - m_currentQueue=0; - Online(); // LoopBackdevices are 'online' immediately -} - -NG_LoopBackNetworkDeviceInterface::~NG_LoopBackNetworkDeviceInterface() -{ -} - -// perhaps this should go to the shared/common implementation too -void NG_LoopBackNetworkDeviceInterface::NextFrame() -{ - // Release reference to the messages while emptying the queue - while (m_messages[m_currentQueue].size() > 0) { -#ifdef NAN_NET_DEBUG - printf("NG_LBNDI::NextFrame %d '%s'\n", m_currentQueue, m_messages[m_currentQueue][0]->GetSubject().ReadPtr()); -#endif - // Should do assert(m_events[0]); - m_messages[m_currentQueue][0]->Release(); - m_messages[m_currentQueue].pop_front(); - } - //m_messages[m_currentQueue].clear(); - - m_currentQueue=1-m_currentQueue; -} - -void NG_LoopBackNetworkDeviceInterface::SendNetworkMessage(NG_NetworkMessage* nwmsg) -{ -#ifdef NAN_NET_DEBUG - printf("NG_LBNDI::SendNetworkMessage %d, '%s'->'%s' '%s' '%s'\n", - 1-m_currentQueue, - nwmsg->GetDestinationName().ReadPtr(), - nwmsg->GetSenderName().ReadPtr(), - nwmsg->GetSubject().ReadPtr(), - nwmsg->GetMessageText().ReadPtr()); -#endif - int backqueue = 1-m_currentQueue; - - nwmsg->AddRef(); - m_messages[backqueue].push_back(nwmsg); -} - -vector<NG_NetworkMessage*> NG_LoopBackNetworkDeviceInterface::RetrieveNetworkMessages() -{ - vector<NG_NetworkMessage*> messages; - - std::deque<NG_NetworkMessage*>::iterator mesit=m_messages[m_currentQueue].begin(); - for (; !(mesit == m_messages[m_currentQueue].end()); ++mesit) - { - - // We don't increase the reference count for these messages. We - // are passing a vector of messages in the interface and not - // explicitily storing the messgaes for long term usage - - messages.push_back(*mesit); - -#ifdef NAN_NET_DEBUG - printf("NG_LBNDI::RetrieveNetworkMessages %d '%s'->'%s' '%s' '%s'\n", - m_currentQueue, - (*mesit)->GetDestinationName().ReadPtr(), - (*mesit)->GetSenderName().ReadPtr(), - (*mesit)->GetSubject().ReadPtr(), - (*mesit)->GetMessageText().ReadPtr()); -#endif - } - return messages; -} - diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h deleted file mode 100644 index 8bbb1e91e35..00000000000 --- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file NG_LoopBackNetworkDeviceInterface.h - * \ingroup bgenetlb - * \brief LoopbackNetworkDeviceInterface derived from NG_NetworkDeviceInterface - */ -#ifndef __NG_LOOPBACKNETWORKDEVICEINTERFACE_H__ -#define __NG_LOOPBACKNETWORKDEVICEINTERFACE_H__ - -#include <deque> -#include "NG_NetworkDeviceInterface.h" - -class NG_LoopBackNetworkDeviceInterface : public NG_NetworkDeviceInterface -{ - std::deque<NG_NetworkMessage*> m_messages[2]; - int m_currentQueue; - -public: - NG_LoopBackNetworkDeviceInterface(); - virtual ~NG_LoopBackNetworkDeviceInterface(); - - /** - * Clear message buffer - */ - virtual void NextFrame(); - - bool Connect(char *address, unsigned int port, char *password, - unsigned int localport, unsigned int timeout) - { - return true; - } - bool Disconnect(void) {return true;} - - virtual void SendNetworkMessage(class NG_NetworkMessage* msg); - virtual std::vector<NG_NetworkMessage*> RetrieveNetworkMessages(); -}; - -#endif /* __NG_LOOPBACKNETWORKDEVICEINTERFACE_H__ */ diff --git a/source/gameengine/Network/NG_NetworkDeviceInterface.h b/source/gameengine/Network/NG_NetworkDeviceInterface.h deleted file mode 100644 index 7fcf799db31..00000000000 --- a/source/gameengine/Network/NG_NetworkDeviceInterface.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file NG_NetworkDeviceInterface.h - * \ingroup bgenet - * \brief Functions like (de)initialize network, get library version - * To be derived by loopback and network libraries - */ - -#ifndef __NG_NETWORKDEVICEINTERFACE_H__ -#define __NG_NETWORKDEVICEINTERFACE_H__ - -#include "NG_NetworkMessage.h" -#include <vector> - -class NG_NetworkDeviceInterface -{ -private: - // candidates for shared/common implementation class - bool m_online; -public: - NG_NetworkDeviceInterface() {} - virtual ~NG_NetworkDeviceInterface() {} - - virtual void NextFrame()=0; - - /** - * Mark network connection online - */ - void Online(void) { m_online = true; } - /** - * Mark network connection offline - */ - void Offline(void) { m_online = false; } - /** - * Is the network connection established ? - */ - bool IsOnline(void) { return m_online; } - - virtual bool Connect(char *address, unsigned int port, char *password, - unsigned int localport, unsigned int timeout)=0; - virtual bool Disconnect(void)=0; - - virtual void SendNetworkMessage(NG_NetworkMessage* msg)=0; - /** - * read NG_NetworkMessage from library buffer, may be - * irrelevant for loopbackdevices - */ - - virtual std::vector<NG_NetworkMessage*> RetrieveNetworkMessages()=0; - - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkDeviceInterface") -#endif -}; - -#endif /* __NG_NETWORKDEVICEINTERFACE_H__ */ diff --git a/source/gameengine/Network/NG_NetworkMessage.cpp b/source/gameengine/Network/NG_NetworkMessage.cpp deleted file mode 100644 index 23ae2529b7a..00000000000 --- a/source/gameengine/Network/NG_NetworkMessage.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * generic Network Message implementation - */ - -/** \file gameengine/Network/NG_NetworkMessage.cpp - * \ingroup bgenet - */ - -#include "NG_NetworkMessage.h" -#include <assert.h> - -int NG_NetworkMessage::s_nextID = 3; // just some number to start with - -NG_NetworkMessage::NG_NetworkMessage( - const STR_String& to, - const STR_String& from, - const STR_String& subject, - const STR_String& body) : - m_uniqueMessageID(s_nextID++), - m_refcount(1), - m_to(to), - m_from(from), - m_subject(subject), - m_message(body) -{ -} - -NG_NetworkMessage::~NG_NetworkMessage() -{ - assert(m_refcount==0); -} diff --git a/source/gameengine/Network/NG_NetworkMessage.h b/source/gameengine/Network/NG_NetworkMessage.h deleted file mode 100644 index 6ed266557fc..00000000000 --- a/source/gameengine/Network/NG_NetworkMessage.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file NG_NetworkMessage.h - * \ingroup bgenet - * \brief generic Network Message class - */ -#ifndef __NG_NETWORKMESSAGE_H__ -#define __NG_NETWORKMESSAGE_H__ - -#include "STR_HashedString.h" - -#ifdef WITH_CXX_GUARDEDALLOC -#include "MEM_guardedalloc.h" -#endif - -class NG_NetworkMessage -{ - static int s_nextID; - int m_uniqueMessageID; // intern counting MessageID - unsigned int m_ClientId; - int m_refcount; - - STR_String m_to; // receiver - STR_String m_from; // sender - STR_String m_subject; // empty or propName - STR_String m_message; // message or propValue - -protected: - ~NG_NetworkMessage(); - -public: - NG_NetworkMessage( - const STR_String& to, - const STR_String& from, - const STR_String& subject, - const STR_String& body); - - void AddRef() { - m_refcount++; - } - - // This is not nice code you should'nt need to resort to - // delete this. - void Release() - { - if (! --m_refcount) - { - delete this; - } - } - - /** - * set the content of this message - */ - void SetMessageText(const STR_String& msgtext) { - m_message = msgtext; - } - - /** - * get the (read-only) To part of this message - */ - const STR_String& GetDestinationName() { return m_to; } - - /** - * get the (read-only) From part of this message - */ - const STR_String& GetSenderName() { return m_from; } - - /** - * get the (read-only) Subject part of this message - */ - const STR_String& GetSubject() { return m_subject; } - - /** - * get the (read-only) Body part of this message - */ - const STR_String& GetMessageText() { -//cout << "GetMessageText " << m_message << "\n"; - return m_message; - } - const STR_String& GetMessageText() const { -//cout << "GetMessageText " << m_message << "\n"; - return m_message; - } - - /** - * Set the NetworkMessage sender identifier - */ - void SetSender(unsigned int ClientId) { - m_ClientId = ClientId; - } - - /** - * Get the NetworkMessage sender identifier - */ - unsigned int GetSender(void) { - return m_ClientId; - } - - /** - * get the unique Network Message ID - */ - int GetMessageID() { - return m_uniqueMessageID; - } - - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkMessage") -#endif -}; - -#endif /* __NG_NETWORKMESSAGE_H__ */ diff --git a/source/gameengine/Network/NG_NetworkObject.cpp b/source/gameengine/Network/NG_NetworkObject.cpp deleted file mode 100644 index 5cd42a2e45a..00000000000 --- a/source/gameengine/Network/NG_NetworkObject.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * NetworkGame_NetworkObject generic Network Object implementation - */ - -/** \file gameengine/Network/NG_NetworkObject.cpp - * \ingroup bgenet - */ - -#include "NG_NetworkObject.h" - -NG_NetworkObject::NG_NetworkObject() -{ -} - -NG_NetworkObject::~NG_NetworkObject() -{ -} - -const STR_String& NG_NetworkObject::GetName() -{ - return m_name; -} diff --git a/source/gameengine/Network/NG_NetworkObject.h b/source/gameengine/Network/NG_NetworkObject.h deleted file mode 100644 index 54459cad55d..00000000000 --- a/source/gameengine/Network/NG_NetworkObject.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file NG_NetworkObject.h - * \ingroup bgenet - * \brief generic Network Object class - */ -#ifndef __NG_NETWORKOBJECT_H__ -#define __NG_NETWORKOBJECT_H__ - -#include "STR_String.h" - -#ifdef WITH_CXX_GUARDEDALLOC -#include "MEM_guardedalloc.h" -#endif - -class NG_NetworkObject -{ - STR_String m_name; -public: - NG_NetworkObject(); - ~NG_NetworkObject(); - const STR_String& GetName(); - - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkObject") -#endif -}; - -#endif /* __NG_NETWORKOBJECT_H__ */ diff --git a/source/gameengine/Network/NG_NetworkScene.cpp b/source/gameengine/Network/NG_NetworkScene.cpp deleted file mode 100644 index 3dbfb53d03d..00000000000 --- a/source/gameengine/Network/NG_NetworkScene.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * NetworkSceneManagement generic implementation - */ - -/** \file gameengine/Network/NG_NetworkScene.cpp - * \ingroup bgenet - */ - -#include <stdio.h> -#include <MT_assert.h> -#include <algorithm> - -#include "NG_NetworkScene.h" -#include "NG_NetworkDeviceInterface.h" -#include "NG_NetworkMessage.h" -#include "NG_NetworkObject.h" - -NG_NetworkScene::NG_NetworkScene(NG_NetworkDeviceInterface* nic) -{ - m_networkdevice = nic; -} - -NG_NetworkScene::~NG_NetworkScene() -{ - ClearAllMessageMaps(); -} - -/** - * progress one frame, handle all network traffic - */ -void NG_NetworkScene::proceed(double curtime) -{ - if (!m_networkdevice) return; - if (!m_networkdevice->IsOnline()) return; - - ClearAllMessageMaps(); - - // read all NetworkMessages from the device - vector<NG_NetworkMessage*> messages = - m_networkdevice->RetrieveNetworkMessages(); - - vector<NG_NetworkMessage*>::iterator mesit = messages.begin(); - for (; !(mesit == messages.end()); mesit++) { - NG_NetworkMessage* message = (*mesit); - vector<NG_NetworkMessage*>* tmplist=NULL; - - vector<NG_NetworkMessage*>** tmplistptr = - m_messagesByDestinationName[message->GetDestinationName()]; - // if there is already a vector of messages, append, else create - // a new vector and insert into map - if (!tmplistptr) { - tmplist = new vector<NG_NetworkMessage*>; - m_messagesByDestinationName.insert(message->GetDestinationName(), - tmplist); - } else { - tmplist = *tmplistptr; - } - message->AddRef(); - tmplist->push_back(message); - tmplist = NULL; - - tmplistptr = m_messagesBySenderName[message->GetSenderName()]; - // if there is already a vector of messages, append, else create - // a new vector and insert into map - if (!tmplistptr) { - tmplist = new vector<NG_NetworkMessage*>; - m_messagesBySenderName.insert(message->GetSenderName(), tmplist); - } else { - tmplist = *tmplistptr; - } - message->AddRef(); - tmplist->push_back(message); - tmplist = NULL; - - tmplistptr = m_messagesBySubject[message->GetSubject()]; - // if there is already a vector of messages, append, else create - // a new vector and insert into map - if (!tmplistptr) { - tmplist = new vector<NG_NetworkMessage*>; - m_messagesBySubject.insert(message->GetSubject(), tmplist); - } else { - tmplist = *tmplistptr; - } - message->AddRef(); - tmplist->push_back(message); - tmplist = NULL; - } -} - -/** - * add a network object to the network scene - */ -void NG_NetworkScene::AddObject(NG_NetworkObject* object) -{ - if (! m_networkdevice->IsOnline()) return; - - const STR_String& name = object->GetName(); - m_networkObjects.insert(name, object); -} - -/** - * remove a network object from the network scene - */ -void NG_NetworkScene::RemoveObject(NG_NetworkObject* object) -{ - if (! m_networkdevice->IsOnline()) return; - - const STR_String& name = object->GetName(); - m_networkObjects.remove(name); -} - -/** - * remove all network scene objects at once - */ -void NG_NetworkScene::RemoveAllObjects() -{ - m_networkObjects.clear(); -} - -/** - * get a single network object given its name - */ -NG_NetworkObject* NG_NetworkScene::FindNetworkObject(const STR_String& objname) -{ - NG_NetworkObject *nwobj = NULL; - if (! m_networkdevice->IsOnline()) return nwobj; - - NG_NetworkObject **nwobjptr = m_networkObjects[objname]; - if (nwobjptr) { - nwobj = *nwobjptr; - } - - return nwobj; -} - -bool NG_NetworkScene::ConstraintsAreValid( - const STR_String& from, - const STR_String& subject, - NG_NetworkMessage* message) -{ - vector<NG_NetworkMessage*>** fromlistptr = m_messagesBySenderName[from]; - vector<NG_NetworkMessage*>** subjectlistptr = m_messagesBySubject[subject]; - - vector<NG_NetworkMessage*>* fromlist = (fromlistptr ? *fromlistptr : NULL); - vector<NG_NetworkMessage*>* subjectlist = (subjectlistptr ? *subjectlistptr : NULL); - - return ( - ( from.IsEmpty() || (!fromlist ? false : (!(std::find(fromlist->begin(), fromlist->end(), message) == fromlist->end()))) - ) && - ( subject.IsEmpty() || (!subjectlist ? false : (!(std::find(subjectlist->begin(), subjectlist->end(), message) == subjectlist->end()))) - )); -} - -vector<NG_NetworkMessage*> NG_NetworkScene::FindMessages( - const STR_String& to, - const STR_String& from, - const STR_String& subject, - bool spamallowed) -{ - vector<NG_NetworkMessage*> foundmessages; - bool notfound = false; - - // broad phase - notfound = ((to.IsEmpty() || spamallowed) ? notfound : m_messagesByDestinationName[to] == NULL); - if (!notfound) - notfound = (from.IsEmpty() ? notfound : m_messagesBySenderName[from] == NULL); - if (!notfound) - notfound = (subject.IsEmpty() ? notfound : m_messagesBySubject[subject] == NULL); - if (notfound) { - // it's definitely NOT in the scene, so stop looking - } else { // narrow phase - // possibly it's there, but maybe not (false hit) - if (to.IsEmpty()) { - // take all messages, and check other fields - MT_assert(!"objectnames that are empty are not valid, so make it a hobby project :)\n"); - } else { - //todo: find intersection of messages (that are in other 2 maps) - vector<NG_NetworkMessage*>** tolistptr = m_messagesByDestinationName[to]; - if (tolistptr) { - vector<NG_NetworkMessage*>* tolist = *tolistptr; - vector<NG_NetworkMessage*>::iterator listit; - for (listit=tolist->begin();!(listit==tolist->end());listit++) { - NG_NetworkMessage* message = *listit; - if (ConstraintsAreValid(from, subject, message)) { - message->AddRef(); - foundmessages.push_back(message); - } - } - } - // TODO find intersection of messages (that are in other 2 maps) - if (spamallowed) { - tolistptr = m_messagesByDestinationName[""]; - if (tolistptr) { - vector<NG_NetworkMessage*>* tolist = *tolistptr; - vector<NG_NetworkMessage*>::iterator listit; - for (listit=tolist->begin();!(listit==tolist->end());listit++) { - NG_NetworkMessage* message = *listit; - if (ConstraintsAreValid(from, subject, message)) { - message->AddRef(); - foundmessages.push_back(message); - } - } - } - } - } - } - return foundmessages; -} - -void NG_NetworkScene::SendMessage( - const STR_String& to, - const STR_String& from, - const STR_String& subject, - const STR_String& message) -{ - NG_NetworkMessage* msg = new NG_NetworkMessage(to, from, subject, message); - m_networkdevice->SendNetworkMessage(msg); - msg->Release(); -} - -void NG_NetworkScene::ClearAllMessageMaps(void) -{ - ClearMessageMap(m_messagesByDestinationName); - ClearMessageMap(m_messagesBySenderName); - ClearMessageMap(m_messagesBySubject); -} - -void NG_NetworkScene::ClearMessageMap(TMessageMap& map) -{ - // Release the messages in the map - for (int i = 0; i < map.size(); i++) { - vector<NG_NetworkMessage*>* msglist; - msglist = *(map.at(i)); - - // Iterate through the current vector and release all it's messages - vector<NG_NetworkMessage*>::iterator msgit; - for (msgit = msglist->begin(); msgit != msglist->end(); msgit++) { - (*msgit)->Release(); - } - - // Delete the actual vector - delete (msglist); - } - - // Empty the map - map.clear(); -} - diff --git a/source/gameengine/Network/NG_NetworkScene.h b/source/gameengine/Network/NG_NetworkScene.h deleted file mode 100644 index e6233852ee2..00000000000 --- a/source/gameengine/Network/NG_NetworkScene.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * 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 Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file NG_NetworkScene.h - * \ingroup bgenet - * \brief NetworkSceneManagement generic class - */ -#ifndef __NG_NETWORKSCENE_H__ -#define __NG_NETWORKSCENE_H__ - -#include "CTR_Map.h" -#include "STR_HashedString.h" -#include <vector> - -#ifdef WITH_CXX_GUARDEDALLOC -#include "MEM_guardedalloc.h" -#endif - -//MSVC defines SendMessage as a win api function, even though we aren't using it -#ifdef SendMessage -# undef SendMessage -#endif - -using namespace std; - -class NG_NetworkDeviceInterface; - -class NG_NetworkScene -{ - class NG_NetworkDeviceInterface *m_networkdevice; - CTR_Map<STR_HashedString, class NG_NetworkObject *> m_networkObjects; - - // CTR_Maps used as a 'Bloom' filter - typedef CTR_Map<STR_HashedString, std::vector<class NG_NetworkMessage*>* > TMessageMap; - TMessageMap m_messagesByDestinationName; - TMessageMap m_messagesBySenderName; - TMessageMap m_messagesBySubject; - -public: - NG_NetworkScene(NG_NetworkDeviceInterface *nic); - ~NG_NetworkScene(); - - /** - * progress one frame, handle all network traffic - */ - void proceed(double curtime); - - /** - * add a networkobject to the scene - */ - void AddObject(NG_NetworkObject* object); - - /** - * remove a networkobject to the scene - */ - void RemoveObject(NG_NetworkObject* object); - - /** - * remove all objects at once - */ - void RemoveAllObjects(); - - /** - * send a message (ascii text) over the network - */ - void SendMessage(const STR_String& to,const STR_String& from,const STR_String& subject,const STR_String& message); - - /** - * find an object by name - */ - NG_NetworkObject* FindNetworkObject(const STR_String& objname); - - bool ConstraintsAreValid(const STR_String& from,const STR_String& subject,class NG_NetworkMessage* message); - vector<NG_NetworkMessage*> FindMessages(const STR_String& to,const STR_String& from,const STR_String& subject,bool spamallowed); - -protected: - /** - * Releases messages in message map members. - */ - void ClearAllMessageMaps(void); - - /** - * Releases messages for the given message map. - * \param map Message map with messages. - */ - void ClearMessageMap(TMessageMap& map); - - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkScene") -#endif -}; - -#endif /* __NG_NETWORKSCENE_H__ */ |